Device tree of regulators

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Device tree of regulators

6,772 Views
wangvictor
Contributor III

Hi All,

I'm using Android6.0 to build image for my customized board which have no PMIC.

When I read the device tree settings there is a regulators defined like below code.

/ {

regulators {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <0>;

reg_1p8v: regulator@0 {
compatible = "regulator-fixed";
reg = <0>;
regulator-name = "1P8V";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-always-on;
};

reg_2p5v: regulator@1 {
compatible = "regulator-fixed";
reg = <1>;
regulator-name = "2P5V";
regulator-min-microvolt = <2500000>;
regulator-max-microvolt = <2500000>;
regulator-always-on;
};

reg_3p3v: regulator@2 {
compatible = "regulator-fixed";
reg = <2>;
regulator-name = "3P3V";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};

reg_usbotg_vbus: regulator@3 {
compatible = "regulator-fixed";
reg = <3>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_reg_usbotg_vbus>;
regulator-name = "usb_otg_vbus";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
gpio = GP_REG_USBOTG;
enable-active-high;
};

reg_wlan_en: regulator@4 {
compatible = "regulator-fixed";
reg = <4>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_reg_wlan_en>;
regulator-name = "wlan-en";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
gpio = GP_REG_WLAN_EN;
startup-delay-us = <70000>;
enable-active-high;
};
};

};

I do find it is related to the kernel-driver driver/regulator/fixed.c

But I don't know what this capable to do?

if it is setting up the voltage, Is this voltage coming up form CPU?

If so which pin it will come out?

Thanks in Advanced !

Labels (3)
Tags (1)
0 Kudos
5 Replies

3,962 Views
igorpadykov
NXP Employee
NXP Employee

Hi victor

one can look at general linux documentation:

linux/fixed-regulator.txt at master · torvalds/linux · GitHub 

detailed adp150 example description on

ADP150 Regulator Fixed Voltage Linux Driver [Analog Devices Wiki] 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

3,962 Views
wangvictor
Contributor III

@igorpadykov‌

Thanks for the reply.

But still got something confused.

Here is the code that boundary defined in the imx6qdl.nitrogen6x.dtsi

/ {

regulators {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <0>;

reg_1p8v: regulator@0 {
compatible = "regulator-fixed";
reg = <0>;
regulator-name = "1P8V";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-always-on;
};

reg_usbotg_vbus: regulator@1 {
compatible = "regulator-fixed";
reg = <1>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_reg_usbotg_vbus>;
regulator-name = "usb_otg_vbus";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
gpio = GP_REG_USBOTG;
enable-active-high;
};

};

I could understand that reg_usbotg_vbus is defined to output the 5V voltage out form gpio(GP_REG_USBOTG) and it is always in high mode.

But for the reg_1p8v I couldn't understand which gpio did they want to output. 

What is different between the one which have defined gpio and the one without gpio?

Besides, what is the mainly meaning with vin-supply?

According to regulator-fixed.txt, it describe that is a name for the voltage you want to input.

But I see the example with other dtsi file it defined as below.

reg_5v: regulator@3 {
compatible = "regulator-fixed";
enable-active-high;
gpio = GP_5V_BST_EN;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_reg_5v>;
reg = <3>;
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
regulator-name = "5V";
vin-supply = <&swbst_reg>;
};

I couldn't really know why I have already defined regulator-min-microvolt = <5000000>; and

regulator-max-microvolt = <5000000>; but still defined vin-supply which related to the swbst_reg?

swbst_reg:

swbst_reg: swbst {
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5150000>;
};

Thanks in Advanced.

0 Kudos

3,962 Views
igorpadykov
NXP Employee
NXP Employee

additional dts properties can be added to proprietary linux releases, so it

is necessary to check boundary devices linux sources, seems driver/regulator/fixed.c in the case.

Best regards
igor

0 Kudos

3,962 Views
wangvictor
Contributor III

igorpadykov

Thanks for the reply!

when I take a look to the fixed.c, I think it is a no use defined.

The following is function probe.

static int reg_fixed_voltage_probe(struct platform_device *pdev)
{
struct fixed_voltage_config *config;
struct fixed_voltage_data *drvdata;
struct regulator_config cfg = { };
int ret;
struct clk *clk_slow;

if (pdev->dev.of_node) {
config = of_get_fixed_voltage_config(&pdev->dev);
if (IS_ERR(config))
return PTR_ERR(config);
} else {
config = dev_get_platdata(&pdev->dev);
}

if (!config)
return -ENOMEM;

drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data),
GFP_KERNEL);
if (drvdata == NULL) {
dev_err(&pdev->dev, "Failed to allocate device data\n");
ret = -ENOMEM;
goto err;
}

clk_slow = devm_clk_get(&pdev->dev, "slow");
if (!IS_ERR(clk_slow))
clk_prepare_enable(clk_slow);

drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
if (drvdata->desc.name == NULL) {
dev_err(&pdev->dev, "Failed to allocate supply name\n");
ret = -ENOMEM;
goto err;
}
drvdata->desc.type = REGULATOR_VOLTAGE;
drvdata->desc.owner = THIS_MODULE;
drvdata->desc.ops = &fixed_voltage_ops;

drvdata->desc.enable_time = config->startup_delay;

if (config->input_supply) {
drvdata->desc.supply_name = kstrdup(config->input_supply,

GFP_KERNEL);
if (!drvdata->desc.supply_name) {
dev_err(&pdev->dev,
"Failed to allocate input supply\n");
ret = -ENOMEM;
goto err_name;
}
}

if (config->microvolts)
drvdata->desc.n_voltages = 1;

drvdata->desc.fixed_uV = config->microvolts;

if (config->gpio >= 0)
cfg.ena_gpio = config->gpio;
cfg.ena_gpio_invert = !config->enable_high;
if (config->enabled_at_boot) {
if (config->enable_high)
cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
else
cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW;
} else {
if (config->enable_high)
cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW;
else
cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
}
if (config->gpio_is_open_drain)
cfg.ena_gpio_flags |= GPIOF_OPEN_DRAIN;

cfg.dev = &pdev->dev;
cfg.init_data = config->init_data;
cfg.driver_data = drvdata;
cfg.of_node = pdev->dev.of_node;

drvdata->dev = regulator_register(&drvdata->desc, &cfg);
if (IS_ERR(drvdata->dev)) {
ret = PTR_ERR(drvdata->dev);
dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
goto err_input;
}

platform_set_drvdata(pdev, drvdata);

dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name,
drvdata->desc.fixed_uV);

return 0;

err_input:
kfree(drvdata->desc.supply_name);
err_name:
kfree(drvdata->desc.name);
err:
return ret;
}

There is no gpio defined, so the cfg.ena_gpio is NULL.

But why need to defined this inside dtsi if there is no use?

So I take a look at imx6qdl-sabrelite.dtsi and compare it.

It defined the same no use parameter too.

reg_1p8v: regulator@0 {
compatible = "regulator-fixed";
reg = <0>;
regulator-name = "1P8V";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-always-on;
};

Is there necessary to defined it? 

Or I could ignore it?

0 Kudos

3,962 Views
igorpadykov
NXP Employee
NXP Employee

regulators entries are parsed and registered in probe function fixed.c :  reg_fixed_voltage_probe().

Best regards
igor

0 Kudos