Re: [PATCH 1/2] regulator: gpio-regulator: Allow use of GPIO controlled regulators though DT

2012-10-22 Thread Mark Brown
On Mon, Oct 22, 2012 at 10:13:55AM +0100, Lee Jones wrote:
> On Wed, 17 Oct 2012, Mark Brown wrote:

> > This should really be part of the patch adding the bindings...

> Would you like me to send the patch-set again?

When I said I'd applied the patch that was what I meant.


signature.asc
Description: Digital signature


Re: [PATCH 1/2] regulator: gpio-regulator: Allow use of GPIO controlled regulators though DT

2012-10-22 Thread Lee Jones
On Wed, 17 Oct 2012, Mark Brown wrote:

> On Tue, Oct 16, 2012 at 09:01:09AM +0100, Lee Jones wrote:
> 
> > I'm assuming it's just the documentation patch you're missing.
> 
> > Let me resend it as a single patch.
> 
> This should really be part of the patch adding the bindings...

Would you like me to send the patch-set again?

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] regulator: gpio-regulator: Allow use of GPIO controlled regulators though DT

2012-10-17 Thread Mark Brown
On Tue, Oct 16, 2012 at 09:01:09AM +0100, Lee Jones wrote:

> I'm assuming it's just the documentation patch you're missing.

> Let me resend it as a single patch.

This should really be part of the patch adding the bindings...


signature.asc
Description: Digital signature


Re: [PATCH 1/2] regulator: gpio-regulator: Allow use of GPIO controlled regulators though DT

2012-10-16 Thread Lee Jones
On Tue, 16 Oct 2012, Mark Brown wrote:

> On Tue, Oct 16, 2012 at 08:29:56AM +0100, Lee Jones wrote:
> > On Tue, 16 Oct 2012, Mark Brown wrote:
> 
> > > Not looked at the patch yet but patch 2 doesn't seem to have appeared?
> 
> > Has it arrived yet?
> 
> > Arnd responded to it, so it hit the list.
> 
> > Since Arnd's comments I've also fired v2 up - do you see it/them?
> 
> Not in my inbox, I'm not looking at the list right now.

Strange, both emails had you in CC.

I'm assuming it's just the documentation patch you're missing.

Let me resend it as a single patch.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] regulator: gpio-regulator: Allow use of GPIO controlled regulators though DT

2012-10-16 Thread Mark Brown
On Tue, Oct 16, 2012 at 08:29:56AM +0100, Lee Jones wrote:
> On Tue, 16 Oct 2012, Mark Brown wrote:

> > Not looked at the patch yet but patch 2 doesn't seem to have appeared?

> Has it arrived yet?

> Arnd responded to it, so it hit the list.

> Since Arnd's comments I've also fired v2 up - do you see it/them?

Not in my inbox, I'm not looking at the list right now.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] regulator: gpio-regulator: Allow use of GPIO controlled regulators though DT

2012-10-16 Thread Lee Jones
On Tue, 16 Oct 2012, Mark Brown wrote:

> On Mon, Oct 15, 2012 at 02:16:59PM +0100, Lee Jones wrote:
> > Here we provide the GPIO Regulator driver with Device Tree capability, so
> > that when a platform is booting with DT instead of platform data we can
> > still make full use of it.
> 
> Not looked at the patch yet but patch 2 doesn't seem to have appeared?

Has it arrived yet?

Arnd responded to it, so it hit the list.

Since Arnd's comments I've also fired v2 up - do you see it/them?

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] regulator: gpio-regulator: Allow use of GPIO controlled regulators though DT

2012-10-15 Thread Mark Brown
On Mon, Oct 15, 2012 at 02:16:59PM +0100, Lee Jones wrote:
> Here we provide the GPIO Regulator driver with Device Tree capability, so
> that when a platform is booting with DT instead of platform data we can
> still make full use of it.

Not looked at the patch yet but patch 2 doesn't seem to have appeared?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] regulator: gpio-regulator: Allow use of GPIO controlled regulators though DT

2012-10-15 Thread Lee Jones
Here we provide the GPIO Regulator driver with Device Tree capability, so
that when a platform is booting with DT instead of platform data we can
still make full use of it.

Cc: Mark Brown 
Signed-off-by: Lee Jones 
---
 drivers/regulator/gpio-regulator.c |   94 
 1 file changed, 94 insertions(+)

diff --git a/drivers/regulator/gpio-regulator.c 
b/drivers/regulator/gpio-regulator.c
index 8b5944f..e467d0a 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -28,9 +28,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
+#include 
 
 struct gpio_regulator_data {
struct regulator_desc desc;
@@ -129,6 +132,84 @@ static struct regulator_ops gpio_regulator_voltage_ops = {
.list_voltage = gpio_regulator_list_voltage,
 };
 
+struct gpio_regulator_config *
+of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
+{
+   struct gpio_regulator_config *config;
+   struct property *prop;
+   const char *regtype;
+   int proplen, gpio, i;
+
+   config = devm_kzalloc(dev,
+   sizeof(struct gpio_regulator_config),
+   GFP_KERNEL);
+   if (!config)
+   return ERR_PTR(-ENOMEM);
+
+   config->init_data = of_get_regulator_init_data(dev, np);
+   if (!config->init_data)
+   return ERR_PTR(-EINVAL);
+
+   config->supply_name = config->init_data->constraints.name;
+
+   if (of_property_read_bool(np, "enable-active-high"))
+   config->enable_high = true;
+
+   if (of_property_read_bool(np, "enable-at-boot"))
+   config->enabled_at_boot = true;
+
+   of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
+
+   config->enable_gpio = of_get_named_gpio(np, "enable-gpio", 0);
+
+   /* Fetch GPIOs. */
+   for (i = 0; ; i++)
+   if (of_get_named_gpio(np, "gpios", i) < 0)
+   break;
+   config->nr_gpios = i;
+
+   config->gpios = devm_kzalloc(dev,
+   sizeof(struct gpio) * config->nr_gpios,
+   GFP_KERNEL);
+   if (!config->gpios)
+   return ERR_PTR(-ENOMEM);
+
+   for (i = 0; config->nr_gpios; i++) {
+   gpio = of_get_named_gpio(np, "gpios", i);
+   if (gpio < 0)
+   break;
+   config->gpios[i].gpio = gpio;
+   }
+
+   /* Fetch states. */
+   prop = of_find_property(np, "states", NULL);
+   proplen = prop->length / sizeof(int);
+
+   config->states = devm_kzalloc(dev,
+   sizeof(struct gpio_regulator_state)
+   * (proplen / 2),
+   GFP_KERNEL);
+   if (!config->states)
+   return ERR_PTR(-ENOMEM);
+
+   for (i = 0; i < proplen / 2; i++) {
+   config->states[i].value =
+   be32_to_cpup((int *)prop->value + (i * 2));
+   config->states[i].gpios =
+   be32_to_cpup((int *)prop->value + (i * 2 + 1));
+   }
+   config->nr_states = i;
+
+   of_property_read_string(np, "regulator-type", ®type);
+
+   if (!strncmp("voltage", regtype, 7))
+   config->type = REGULATOR_VOLTAGE;
+   else if (!strncmp("current", regtype, 7))
+   config->type = REGULATOR_CURRENT;
+
+   return config;
+}
+
 static struct regulator_ops gpio_regulator_current_ops = {
.get_current_limit = gpio_regulator_get_value,
.set_current_limit = gpio_regulator_set_current_limit,
@@ -137,10 +218,17 @@ static struct regulator_ops gpio_regulator_current_ops = {
 static int __devinit gpio_regulator_probe(struct platform_device *pdev)
 {
struct gpio_regulator_config *config = pdev->dev.platform_data;
+   struct device_node *np = pdev->dev.of_node;
struct gpio_regulator_data *drvdata;
struct regulator_config cfg = { };
int ptr, ret, state;
 
+   if (np) {
+   config = of_get_gpio_regulator_config(&pdev->dev, np);
+   if (IS_ERR(config))
+   return PTR_ERR(config);
+   }
+
drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data),
   GFP_KERNEL);
if (drvdata == NULL) {
@@ -270,12 +358,18 @@ static int __devexit gpio_regulator_remove(struct 
platform_device *pdev)
return 0;
 }
 
+static const struct of_device_id regulator_gpio_of_match[] __devinitconst = {
+   { .compatible = "regulator-gpio", },
+   {},
+};
+
 static struct platform_driver gpio_regulator_driver = {
.probe  = gpio_regulator_probe,
.remove = __devexit_p(gpio_regulator_remove),
.driver = {
.name   = "gpio-regulator",
.owner  = THIS_MODULE,
+