美文网首页
imx8qxp Linux Regulators 使用

imx8qxp Linux Regulators 使用

作者: jackniu_ae28 | 来源:发表于2020-05-13 09:11 被阅读0次

1.regulators 是什么?

linux 代码中对负载电源进行开关和稳压控制的模型叫做regulators,具体是如何实现的呢请看下面的图:

image.png

例如: usb otg 要对usb_otg1_vbus控制,这时需要一个电源控制芯片nx5p3290,同时需要对其管脚BB_USB_OTG1_PWR_ON进行控制。软件使用模型 reg_usb_otg1_vbus来进行电源开关控制。

参考:Documentation/devicetree/bindings/regulator/fixed-regulator.txt
下面通过:定义 解析 获取 使用 过程进行分析。

2. usb otg 软件对 regulators 的 dts 定义:

regulators {                           /*fsl-imx8qxp-mek.dtsi 定义中 regulators*/
    reg_usb_otg1_vbus: regulator@0 {
            compatible = "regulator-fixed";
            reg = <0>;
            regulator-name = "usb_otg1_vbus";
            regulator-min-microvolt = <5000000>;
            regulator-max-microvolt = <5000000>;
            gpio = <&pca9557_b 2 GPIO_ACTIVE_HIGH>;
            enable-active-high;
        };
}

&usbotg1 {                        /*fsl-imx8qxp-mek.dtsi 定义对regulators的使用*/
    vbus-supply = <&reg_usb_otg1_vbus>;
    srp-disable;
    hnp-disable;
    adp-disable;
    power-polarity-active-high;
    disable-over-current;
    status = "okay";
};

usbotg1: usb@5b0d0000 {              /*fsl-imx8dx.dtsi 定义*/
        compatible = "fsl,imx8qm-usb", "fsl,imx27-usb";
        reg = <0x0 0x5b0d0000 0x0 0x200>;
        interrupt-parent = <&wu>;
        status = "disabled";
}

设备树属性 vbus-supply = <&reg_usb_otg1_vbus>; 使用文件 drivers\regulator\fixed.c 解析出来,解析代码如下:config->gpio = of_get_named_gpio(np, "gpio", 0);

4. 获取device tree vbus-supply属性的代码

image.png
获取方法:
1.获取设备树vbus-supply属性,使用 platdata->reg_vbus = devm_regulator_get(dev, "vbus"); 获取
2.在函数of_get_regulator 中使用snprintf(prop_name, 32, "%s-supply", supply);函数拼接最终获取regulator属性。

5.使用过程使用 vbus-supply属性控制外部电源,以usb otg为例:

1.当拔插 usb otg1 时出现如下调用Astah 图otg-pull-out.asta
2.当插入调用图Astah是 otg-pull-in.asta

相关文章

网友评论

      本文标题:imx8qxp Linux Regulators 使用

      本文链接:https://www.haomeiwen.com/subject/gsaynhtx.html