devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] regulator: userspace-consumer: add DT support
@ 2014-07-30 13:53 Laxman Dewangan
  2014-07-30 13:54 ` [PATCH 1/2] regulator: userspace-consumer: add DT binding details Laxman Dewangan
  0 siblings, 1 reply; 6+ messages in thread
From: Laxman Dewangan @ 2014-07-30 13:53 UTC (permalink / raw)
  To: broonie-DgEjT+Ai2ygdnm+yROfE0A
  Cc: lgirdwood-Re5JQEeQqe8AvxtiuMwx3w, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	pawel.moll-5wv7dgnIgG8, mark.rutland-5wv7dgnIgG8,
	ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, grant.likely-QSEj5FYQhm4dnm+yROfE0A,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Laxman Dewangan

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.

Signed-off-by: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 drivers/regulator/userspace-consumer.c | 48 ++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c
index 765acc1..91d50a2 100644
--- a/drivers/regulator/userspace-consumer.c
+++ b/drivers/regulator/userspace-consumer.c
@@ -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,
 	},
 };
 
-- 
1.8.1.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 1/2] regulator: userspace-consumer: add DT binding details
  2014-07-30 13:53 [PATCH 2/2] regulator: userspace-consumer: add DT support Laxman Dewangan
@ 2014-07-30 13:54 ` Laxman Dewangan
       [not found]   ` <1406728440-17837-2-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Laxman Dewangan @ 2014-07-30 13:54 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
	galak, grant.likely, devicetree, linux-kernel, Laxman Dewangan

Add DT binding document and details DT binding for the driver
regulator/userspace-consumer.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
 .../bindings/regulator/userspace-consumer.txt      | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/userspace-consumer.txt

diff --git a/Documentation/devicetree/bindings/regulator/userspace-consumer.txt b/Documentation/devicetree/bindings/regulator/userspace-consumer.txt
new file mode 100644
index 0000000..73c651c
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/userspace-consumer.txt
@@ -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 = <&reg1>;
+		vcc-supply = <&reg2>;
+		vdd-3v3-supply = <&reg3>;
+	};
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] regulator: userspace-consumer: add DT binding details
       [not found]   ` <1406728440-17837-2-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2014-07-30 15:53     ` Mark Rutland
  2014-07-30 16:40       ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Rutland @ 2014-07-30 15:53 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	lgirdwood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, Pawel Moll,
	ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org,
	galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

On Wed, Jul 30, 2014 at 02:54:00PM +0100, Laxman Dewangan wrote:
> Add DT binding document and details DT binding for the driver
> regulator/userspace-consumer.
> 
> Signed-off-by: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---
>  .../bindings/regulator/userspace-consumer.txt      | 26 ++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/regulator/userspace-consumer.txt
> 
> diff --git a/Documentation/devicetree/bindings/regulator/userspace-consumer.txt b/Documentation/devicetree/bindings/regulator/userspace-consumer.txt
> new file mode 100644
> index 0000000..73c651c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/regulator/userspace-consumer.txt
> @@ -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.

> +- 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 = <&reg1>;
> +		vcc-supply = <&reg2>;
> +		vdd-3v3-supply = <&reg3>;
> +	};
> -- 
> 1.8.1.5
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] regulator: userspace-consumer: add DT binding details
  2014-07-30 15:53     ` Mark Rutland
@ 2014-07-30 16:40       ` Mark Brown
  2014-08-06  7:33         ` Laxman Dewangan
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2014-07-30 16:40 UTC (permalink / raw)
  To: Mark Rutland
  Cc: Laxman Dewangan,
	lgirdwood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, Pawel Moll,
	ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org,
	galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

[-- Attachment #1: Type: text/plain, Size: 598 bytes --]

On Wed, Jul 30, 2014 at 04:53:03PM +0100, Mark Rutland wrote:
> On Wed, Jul 30, 2014 at 02:54:00PM +0100, Laxman Dewangan wrote:

> > +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.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] regulator: userspace-consumer: add DT binding details
  2014-07-30 16:40       ` Mark Brown
@ 2014-08-06  7:33         ` Laxman Dewangan
  2014-08-06 10:59           ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Laxman Dewangan @ 2014-08-06  7:33 UTC (permalink / raw)
  To: Mark Brown, Mark Rutland
  Cc: lgirdwood@gmail.com, robh+dt@kernel.org, Pawel Moll,
	ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
	grant.likely@linaro.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Wednesday 30 July 2014 10:10 PM, Mark Brown wrote:
> * PGP Signed by an unknown key
>
> On Wed, Jul 30, 2014 at 04:53:03PM +0100, Mark Rutland wrote:
>> On Wed, Jul 30, 2014 at 02:54:00PM +0100, Laxman Dewangan wrote:
>>> +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.
>

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] regulator: userspace-consumer: add DT binding details
  2014-08-06  7:33         ` Laxman Dewangan
@ 2014-08-06 10:59           ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2014-08-06 10:59 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: Mark Rutland, lgirdwood@gmail.com, robh+dt@kernel.org, Pawel Moll,
	ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
	grant.likely@linaro.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 741 bytes --]

On Wed, Aug 06, 2014 at 01:03:52PM +0530, Laxman Dewangan wrote:
> On Wednesday 30 July 2014 10:10 PM, Mark Brown wrote:

> >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.

> 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.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-08-06 10:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-30 13:53 [PATCH 2/2] regulator: userspace-consumer: add DT support Laxman Dewangan
2014-07-30 13:54 ` [PATCH 1/2] regulator: userspace-consumer: add DT binding details Laxman Dewangan
     [not found]   ` <1406728440-17837-2-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-07-30 15:53     ` Mark Rutland
2014-07-30 16:40       ` Mark Brown
2014-08-06  7:33         ` Laxman Dewangan
2014-08-06 10:59           ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).