linux的电源管理:
linux中的电源需要指定supply与consumer
reg_usb_otg_vbus: usb_otg_vbus {
compatible = "regulator-fixed";
regulator-name = "usb_otg_vbus";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
gpio = <&gpio1 9 0>;
enable-active-high;
regulator-boot-on;
regulator-always-on;
};
&usbotg {
vbus-supply = <®_usb_otg_vbus>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usbotg_2>;
disable-over-current;
status = "okay";
};
其中usb_otg_vbus为supply , usbotg为consumer, 在linux的dts文件中可以看出两者的关系
在具体的驱动程序中,需要使用devm_regulator_get(dev,"vbus")或regulator_get(dev,"vbus")
注意:第二个参数”vbus“在函数内部会与”supply“进行拼接成”vbus-supply“