regulator: userspace-consumer: add DT support
Subsystems (2)
PATCH 2/2 regulator: userspace-consumer: add DT support
Add DT support of the regulator driver userspace-consumer. The supply names for this driver is provided through DT properties so that proper regulator handle can be acquired.
--- drivers/regulator/userspace-consumer.c | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
drivers/regulator/userspace-consumer.c +48 -0
@@ -23,6 +23,7 @@#include <linux/regulator/consumer.h> #include <linux/regulator/userspace-consumer.h> #include <linux/slab.h> +#include <linux/of.h> struct userspace_consumer_data {const char *name;
@@ -105,6 +106,41 @@ static const struct attribute_group attr_group = { .attrs = attributes, }; +static struct regulator_userspace_consumer_data *get_pdata_from_dt_node ( +struct platform_device *pdev) +{ +struct regulator_userspace_consumer_data *pdata; +struct device_node *np = pdev->dev.of_node; +struct property *prop; +const char *supply; +int num_supplies; +int count =0 ; + + pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL ); +if (!pdata) +return ERR_PTR (-ENOMEM ); + + pdata->name =of_get_property (np,"regulator-name" ,NULL ); + pdata->init_on =of_property_read_bool (np,"regulator-boot-on" ); + + num_supplies =of_property_count_strings (np,"regulator-supplies" ); +if (num_supplies <0 ) { +dev_err (&pdev->dev, +"could not parse property regulator-supplies\n" ); +return ERR_PTR (-EINVAL ); + } + pdata->num_supplies = num_supplies; + pdata->supplies =devm_kzalloc (&pdev->dev, num_supplies * +sizeof (*pdata->supplies),GFP_KERNEL ); +if (!pdata->supplies) +return ERR_PTR (-ENOMEM ); + +of_property_for_each_string (np,"regulator-supplies" , prop, supply) + pdata->supplies[count++].supply = supply; + +return pdata; +} +static int regulator_userspace_consumer_probe (struct platform_device *pdev) {struct regulator_userspace_consumer_data *pdata;
@@ -112,6 +148,11 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)int ret; pdata =dev_get_platdata (&pdev->dev); +if (!pdata && pdev->dev.of_node) { + pdata =get_pdata_from_dt_node (pdev); +if (IS_ERR (pdata)) +return PTR_ERR (pdata); + }if (!pdata)return -EINVAL ;
@@ -171,11 +212,18 @@ static int regulator_userspace_consumer_remove(struct platform_device *pdev)return 0 ; } +static const struct of_device_id regulator_userspace_consumer_of_match[] = { + { .compatible ="reg-userspace-consumer" , }, + {}, +}; +MODULE_DEVICE_TABLE (of, regulator_userspace_consumer_of_match); +static struct platform_driver regulator_userspace_consumer_driver = { .probe = regulator_userspace_consumer_probe, .remove = regulator_userspace_consumer_remove, .driver = { .name ="reg-userspace-consumer" , + .of_match_table = regulator_userspace_consumer_of_match, }, };
Signature · 6 lines
1.8.1.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/2 regulator: userspace-consumer: add DT binding details
Add DT binding document and details DT binding for the driver regulator/userspace-consumer.
--- .../bindings/regulator/userspace-consumer.txt | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/userspace-consumer.txt
Documentation/devicetree/bindings/regulator/userspace-consumer.txt new file +26 -0
@@ -0,0 +1,26 @@ +Userspace consumer regulators + +Required properties: +- compatible : Must be "reg-userspace-consumer". +- regulator-supplies: Supply names for this regulator. This can be + multiple strings. + +Optional properties: +- regulator-name: Name of the consumer line. +- regulator-boot-on: Enable regulator on booting. + +With all supply names, there should be <supply-name>-supply to pass regulators +handle as defined in regulator.txt. + +Example: + + userspace-consumer { + compatible = "reg-userspace-consumer"; + + regulator-name = "gps-consumer"; + regulator-boot-on; + regulator-supplies = "vdd", "vcc", "vdd-3v3"; + vdd-supply = <®1>; + vcc-supply = <®2>; + vdd-3v3-supply = <®3>; + };
Signature · 1 line
1.8.1.5
Re: [PATCH 1/2] regulator: userspace-consumer: add DT binding details
Quoted 15 lines · Laxman Dewangan
Add DT binding document and details DT binding for the driver regulator/userspace-consumer.
Signed-off-by Laxman Dewangan <[email protected]>--- .../bindings/regulator/userspace-consumer.txt | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/userspace-consumer.txtDocumentation/devicetree/bindings/regulator/userspace-consumer.txt new file +0
-0
Documentation/devicetree/bindings/regulator/userspace-consumer.txt line 4
Quoted 4 lines
Documentation/devicetree/bindings/regulator/userspace-consumer.txt new file +4
-0@@ -0,0 +1,26 @@ +Userspace consumer regulators + +Required properties: +- compatible : Must be "reg-userspace-consumer".
I would never expect to see "userspace" in a DT beinding string; this is entirely a software abstraction description and has nothing to do with the interaction of HW components.
Why do you think we need this in the DT?
Thanks,
Mark.
Quoted 26 lines
Documentation/devicetree/bindings/regulator/userspace-consumer.txt new file +22
-0+- regulator-supplies: Supply names for this regulator. This can be + multiple strings. + +Optional properties: +- regulator-name: Name of the consumer line. +- regulator-boot-on: Enable regulator on booting. + +With all supply names, there should be <supply-name>-supply to pass regulators +handle as defined in regulator.txt. + +Example: + + userspace-consumer { + compatible = "reg-userspace-consumer"; + + regulator-name = "gps-consumer"; + regulator-boot-on; + regulator-supplies = "vdd", "vcc", "vdd-3v3"; + vdd-supply = <®1>; + vcc-supply = <®2>; + vdd-3v3-supply = <®3>; + };Signature · 1 line
1.8.1.5
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Mark Brown
maintainerRe: [PATCH 1/2] regulator: userspace-consumer: add DT binding details
Quoted 10 lines · Mark Rutland
Quoted 2 lines · Laxman Dewangan
+Required properties:
+- compatible : Must be "reg-userspace-consumer".I would never expect to see "userspace" in a DT beinding string; this is entirely a software abstraction description and has nothing to do with the interaction of HW components.
Why do you think we need this in the DT?
Yes, this is test code - it is not intended to be used in production. Any binding should be for the consumer using this, not for this implementation detail.
Re: [PATCH 1/2] regulator: userspace-consumer: add DT binding details
Quoted 6 lines · Mark Brown
* PGP Signed by an unknown key
Quoted 3 lines · Mark Rutland
Quoted 2 lines · Laxman Dewangan
+Required properties:
+- compatible : Must be "reg-userspace-consumer".
Quoted 8 lines
Quoted 4 lines
I would never expect to see "userspace" in a DT beinding string; this is entirely a software abstraction description and has nothing to do with the interaction of HW components.
Why do you think we need this in the DT?Yes, this is test code - it is not intended to be used in production. Any binding should be for the consumer using this, not for this implementation detail.
We have the GPS module and its driver in the user space. There is no code for GPS on kernel. Just power on and open port from user space, get the information.
On this case, how do we power on GPS module if we don't expose it? It need two power source for digital section and analog section.
Mark Brown
maintainerRe: [PATCH 1/2] regulator: userspace-consumer: add DT binding details
Quoted 9 lines · Laxman Dewangan
Quoted 3 lines · Mark Brown
Yes, this is test code - it is not intended to be used in production. Any binding should be for the consumer using this, not for this implementation detail.
We have the GPS module and its driver in the user space. There is no code for GPS on kernel. Just power on and open port from user space, get the information.
That's an implementation detail of how you've provided this on Linux.
Quoted 2 lines
On this case, how do we power on GPS module if we don't expose it? It need two power source for digital section and analog section.
Describe the hardware in the device tree and then bind what's needed to that.