[RK3399][Android7.1] PWM的配置

DTS:

  • kernel\include\dt-bindings\display\screen-timing\panel-toshiba-tc358775.dtsi

panel@0 {
        compatible = "simple-panel-dsi";
        reg = <0>;
        backlight = <&backlight>;
        enable-gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>;
        .....
        }
  • kernel\arch\arm64\boot\dts\rockchip\rk3399-sapphire.dtsi

    backlight: backlight {
        status = "disabled";
        compatible = "pwm-backlight";
        pwms = <&pwm1 0 25000 0>;
        brightness-levels = <
              0   1   2   3   4   5   6   7
              8   9  10  11  12  13  14  15
             16  17  18  19  20  21  22  23
             24  25  26  27  28  29  30  31
             32  33  34  35  36  37  38  39
             40  41  42  43  44  45  46  47
             48  49  50  51  52  53  54  55
             56  57  58  59  60  61  62  63
             64  65  66  67  68  69  70  71
             72  73  74  75  76  77  78  79
             80  81  82  83  84  85  86  87
             88  89  90  91  92  93  94  95
             96  97  98  99 100 101 102 103
            104 105 106 107 108 109 110 111
            112 113 114 115 116 117 118 119
            120 121 122 123 124 125 126 127
            128 129 130 131 132 133 134 135
            136 137 138 139 140 141 142 143
            144 145 146 147 148 149 150 151
            152 153 154 155 156 157 158 159
            160 161 162 163 164 165 166 167
            168 169 170 171 172 173 174 175
            176 177 178 179 180 181 182 183
            184 185 186 187 188 189 190 191
            192 193 194 195 196 197 198 199
            200 201 202 203 204 205 206 207
            208 209 210 211 212 213 214 215
            216 217 218 219 220 221 222 223
            224 225 226 227 228 229 230 231
            232 233 234 235 236 237 238 239
            240 241 242 243 244 245 246 247
            248 249 250 251 252 253 254 255>;
        default-brightness-level = <200>;
    }
&pwm1 {
    status = "okay";
};
  • kernel\arch\arm64\boot\dts\rockchip\rk3399.dtsi

    pwm1: pwm@ff420010 {
        compatible = "rockchip,rk3399-pwm", "rockchip,rk3288-pwm";
        reg = <0x0 0xff420010 0x0 0x10>;
        #pwm-cells = <3>;
        pinctrl-names = "active";
        pinctrl-0 = <&pwm1_pin>;
        clocks = <&pmucru PCLK_RKPWM_PMU>;
        clock-names = "pwm";
        status = "disabled";
    };

KERNEL:

  • kernel\drivers\video\backlight\pwm_bl.c

pwm_backlight_probe
    ->devm_pwm_get
        ->pwm_get
            ->of_pwm_get
                //  1.args.np:对应的是PWM1指向的设备节点;  
                //  2.args.args[0]~args.args[2]:分别对应的是pwms域指向的后三位;
                //  3.#pwm-cells:指向pwm1中对应的域,值为3;
                ->of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index,&args);
                // 通过节点获取pwm在注册的时候分配并填充的pwm_chip指针结构;
                ->pc = of_node_to_pwmchip(args.np);
                // 通过pwm_chip指针pc调用of_xlate完成pwm设备的申请
                ->pwm = pc->of_xlate(pc, &args);
  • kernel\drivers\pwm\pwm-rockchip.c
static int rockchip_pwm_probe(struct platform_device *pdev)
{
    ....
    pc->data = id->data;
    pc->chip.dev = &pdev->dev;
    pc->chip.ops = &rockchip_pwm_ops;
    pc->chip.base = -1;
    pc->chip.npwm = 1;
    //这个flags为TRUE
    if (pc->data->supports_polarity) {
        //背光初始化会通过of_xlate调用of_pwm_xlate_with_flags
        pc->chip.of_xlate = of_pwm_xlate_with_flags;
        pc->chip.of_pwm_n_cells = 3;
    }

    ret = pwmchip_add(&pc->chip);
    ...
}
of_pwm_xlate_with_flags
    ->pwm = pwm_request_from_chip(pc, args->args[0], NULL);
        ->pwm = &chip->pwms[index];
        ->pwm_device_request(pwm, label);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值