regulator-fixed and regulator-gpio

发布时间 2023-08-28 19:58:57作者: Hancer

1、regulator-fixed


作用:创建一个固定的 regulator。一般是一个 GPIO 控制了一路电,只有开(enable) \ 关(disabled)两种操作


device-tree node

io_vdd_en: regulator-JW5217DFND {
	compatible = "regulator-fixed";
	pinctrl-names = "default";
	pinctrl-0 = <&io_vdd_en_pins_default>;
	gpios = <&wkup_gpio0 69 GPIO_ACTIVE_HIGH>;
	regulator-name = "jw5217dfnd";
	regulator-min-microvolt = <3300000>;
	regulator-max-microvolt = <3300000>;
	regulator-always-on;
	regulator-boot-on;
	enable-active-high;
	vin-supply = <&vsys_3v3>;
};

解析:

compatible = "regulator-fixed";

固定的 regulator。特点:不能控制电压,只能 enable 和 disabled,没设备用的时候自动关电(disabled)。

gpios = <&wkup_gpio0 69 GPIO_ACTIVE_HIGH>;

控制电的 GPIO。开电时(enabled)的将 GPIO 置为有效电平,关电时(disabled)置为无效电平。

regulator-always-on;

一直开电,防止因其他原因被关电,否则需要在其他驱动中获取此 regulator 来手动控制。
当指定了此选项后,会有一个的虚拟设备一直在使用此 regulator,可通过如下命令查看到:

cat /sys/class/regulator/regulator.*/num_users      # 查看有多少个设备在使用此 regulator
cat /sys/class/regulator/regulator.*/state          # 查看此 regulator 的状态:enabled or disabled

regulator-boot-on;

开机时自动上电。注意:若一段时间内无设备在使用此 regulator,则会自动关电(猜测应该是系统低功耗导致的),因此必须加上 regulator-always-on。

enable-active-high;

指定 enable GPIO 的极性。注意:此属性会覆盖 GPIO 属性中的 GPIO_ACTIVE_xxx(建议两者设置成一致,否则会有警告)。仅适用于 regulator。



2、regulator-gpio


device-tree node

vdd_sd_dv: regulator-TLV71033 {
	compatible = "regulator-gpio";
	regulator-name = "tlv71033";
	pinctrl-names = "default";
	pinctrl-0 = <&vdd_sd_dv_pins_default>;
	regulator-min-microvolt = <1800000>;
	regulator-max-microvolt = <3300000>;
	regulator-boot-on;
	vin-supply = <&vsys_5v0>;
	gpios = <&main_gpio0 8 GPIO_ACTIVE_HIGH>;
	states = <1800000 0x0>,
			<3300000 0x1>;
};

未完。。。