[PATCH v2 0/2] gpio-twl4030: add new device tree properties

STALE5079d

Revision v2 of 2 in this series.

6 messages, 3 authors, 2012-09-07 · open the first message on its own page

[PATCH v2 0/2] gpio-twl4030: add new device tree properties

From: Florian Vaussard <hidden>
Date: 2012-09-05 07:46:24

Hello,

A number of platform data are missing when using twl4030/gpio from a
device tree. This patchset adds the missing properties, updates the 
documentation with the new bindings, and updates existing device trees.
It mainly enables LEDA and LEDB outputs, as well as pullups /
pulldowns on GPIOs.

The 1st patch changes the device driver and updates the documentation.
The 2nd patch updates the device trees for BeagleBoard and omap3-evm.

Changes since v1: 
- Patches on driver and documentation merged into the same patch
- Put device trees' values in hexadecimal
- Handle bool property using of_property_read_bool()
- Prefix the patches with the correct convention

Tested on Gumstix Overo. V1 was tested on omap3-evm by Vaibhav Hiremath.

BTW: who will merge this?

Regards,
Florian


Florian Vaussard (2):
  gpio/twl4030: get platform data from device tree
  ARM: dts: omap3: Add gpio-twl4030 properties for BeagleBoard and
    omap3-EVM

 .../devicetree/bindings/gpio/gpio-twl4030.txt      |    6 ++
 arch/arm/boot/dts/omap3-beagle.dts                 |   20 +++++
 arch/arm/boot/dts/omap3-evm.dts                    |   13 +++
 drivers/gpio/gpio-twl4030.c                        |   84 +++++++++++++------
 4 files changed, 96 insertions(+), 27 deletions(-)

-- 
1.7.5.4

[PATCH 1/2] gpio/twl4030: get platform data from device tree

From: Florian Vaussard <hidden>
Date: 2012-09-05 07:46:25

Adds a number of missing device tree properties for
twl4030/gpio, and update bindings:
- "ti,use-leds"  -> .use_leds
- "ti,debounce"  -> .debounce
- "ti,mmc-cd"    -> .mmc_cd
- "ti,pullups"   -> .pullups
- "ti,pulldowns" -> .pulldowns

Signed-off-by: Florian Vaussard <redacted>
Acked-by: Linus Walleij <redacted>
Acked-by: Vaibhav Hiremath <redacted>
---
 .../devicetree/bindings/gpio/gpio-twl4030.txt      |    6 ++
 drivers/gpio/gpio-twl4030.c                        |   84 +++++++++++++------
 2 files changed, 63 insertions(+), 27 deletions(-)
diff --git a/Documentation/devicetree/bindings/gpio/gpio-twl4030.txt b/Documentation/devicetree/bindings/gpio/gpio-twl4030.txt
index 16695d9..66788fd 100644
--- a/Documentation/devicetree/bindings/gpio/gpio-twl4030.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio-twl4030.txt
@@ -11,6 +11,11 @@ Required properties:
 - interrupt-controller: Mark the device node as an interrupt controller
   The first cell is the GPIO number.
   The second cell is not used.
+- ti,use-leds : Enables LEDA and LEDB outputs if set
+- ti,debounce : if n-th bit is set, debounces GPIO-n
+- ti,mmc-cd : if n-th bit is set, GPIO-n controls VMMC(n+1)
+- ti,pullups : if n-th bit is set, set a pullup on GPIO-n
+- ti,pulldowns : if n-th bit is set, set a pulldown on GPIO-n
 
 Example:
 
@@ -20,4 +25,5 @@ twl_gpio: gpio {
     gpio-controller;
     #interrupt-cells = <2>;
     interrupt-controller;
+    ti,use-leds;
 };
diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index 94256fe..477c1d9 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -395,6 +395,31 @@ static int __devinit gpio_twl4030_debounce(u32 debounce, u8 mmc_cd)
 
 static int gpio_twl4030_remove(struct platform_device *pdev);
 
+static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev)
+{
+	struct twl4030_gpio_platform_data *omap_twl_info;
+
+	omap_twl_info = devm_kzalloc(dev, sizeof(*omap_twl_info), GFP_KERNEL);
+	if (!omap_twl_info)
+		return NULL;
+
+	omap_twl_info->gpio_base = -1;
+
+	omap_twl_info->use_leds = of_property_read_bool(dev->of_node,
+			"ti,use-leds");
+
+	of_property_read_u32(dev->of_node, "ti,debounce",
+				&omap_twl_info->debounce);
+	of_property_read_u32(dev->of_node, "ti,mmc-cd",
+				(u32 *)&omap_twl_info->mmc_cd);
+	of_property_read_u32(dev->of_node, "ti,pullups",
+				&omap_twl_info->pullups);
+	of_property_read_u32(dev->of_node, "ti,pulldowns",
+				&omap_twl_info->pulldowns);
+
+	return omap_twl_info;
+}
+
 static int __devinit gpio_twl4030_probe(struct platform_device *pdev)
 {
 	struct twl4030_gpio_platform_data *pdata = pdev->dev.platform_data;
@@ -423,39 +448,44 @@ static int __devinit gpio_twl4030_probe(struct platform_device *pdev)
 	twl4030_gpio_irq_base = irq_base;
 
 no_irqs:
-	twl_gpiochip.base = -1;
 	twl_gpiochip.ngpio = TWL4030_GPIO_MAX;
 	twl_gpiochip.dev = &pdev->dev;
 
-	if (pdata) {
-		twl_gpiochip.base = pdata->gpio_base;
+	if (node)
+		pdata = of_gpio_twl4030(&pdev->dev);
 
-		/*
-		 * NOTE:  boards may waste power if they don't set pullups
-		 * and pulldowns correctly ... default for non-ULPI pins is
-		 * pulldown, and some other pins may have external pullups
-		 * or pulldowns.  Careful!
-		 */
-		ret = gpio_twl4030_pulls(pdata->pullups, pdata->pulldowns);
-		if (ret)
-			dev_dbg(&pdev->dev, "pullups %.05x %.05x --> %d\n",
-					pdata->pullups, pdata->pulldowns,
-					ret);
-
-		ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd);
-		if (ret)
-			dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n",
-					pdata->debounce, pdata->mmc_cd,
-					ret);
-
-		/*
-		 * NOTE: we assume VIBRA_CTL.VIBRA_EN, in MODULE_AUDIO_VOICE,
-		 * is (still) clear if use_leds is set.
-		 */
-		if (pdata->use_leds)
-			twl_gpiochip.ngpio += 2;
+	if (pdata == NULL) {
+		dev_err(&pdev->dev, "Platform data is missing\n");
+		return -ENXIO;
 	}
 
+	twl_gpiochip.base = pdata->gpio_base;
+
+	/*
+	 * NOTE:  boards may waste power if they don't set pullups
+	 * and pulldowns correctly ... default for non-ULPI pins is
+	 * pulldown, and some other pins may have external pullups
+	 * or pulldowns.  Careful!
+	 */
+	ret = gpio_twl4030_pulls(pdata->pullups, pdata->pulldowns);
+	if (ret)
+		dev_dbg(&pdev->dev, "pullups %.05x %.05x --> %d\n",
+				pdata->pullups, pdata->pulldowns,
+				ret);
+
+	ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd);
+	if (ret)
+		dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n",
+				pdata->debounce, pdata->mmc_cd,
+				ret);
+
+	/*
+	 * NOTE: we assume VIBRA_CTL.VIBRA_EN, in MODULE_AUDIO_VOICE,
+	 * is (still) clear if use_leds is set.
+	 */
+	if (pdata->use_leds)
+		twl_gpiochip.ngpio += 2;
+
 	ret = gpiochip_add(&twl_gpiochip);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret);
-- 
1.7.5.4

[PATCH 2/2] ARM: dts: omap3: Add gpio-twl4030 properties for BeagleBoard and omap3-EVM

From: Florian Vaussard <hidden>
Date: 2012-09-05 07:46:26

Add device tree properties for twl4030/gpio, according to the
platform data of corresponding boards. This enables the led
connected to LEDB output for both boards, as well as
pullups/pulldowns on GPIO for the BeagleBoard.

Signed-off-by: Florian Vaussard <redacted>
Acked-by: Linus Walleij <redacted>
Acked-by: Vaibhav Hiremath <redacted>
---
 arch/arm/boot/dts/omap3-beagle.dts |   20 ++++++++++++++++++++
 arch/arm/boot/dts/omap3-evm.dts    |   13 +++++++++++++
 2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/arch/arm/boot/dts/omap3-beagle.dts b/arch/arm/boot/dts/omap3-beagle.dts
index cdcb98c..c7256d5 100644
--- a/arch/arm/boot/dts/omap3-beagle.dts
+++ b/arch/arm/boot/dts/omap3-beagle.dts
@@ -17,6 +17,14 @@
 		device_type = "memory";
 		reg = <0x80000000 0x20000000>; /* 512 MB */
 	};
+
+	leds {
+		compatible = "gpio-leds";
+		pmu_stat {
+			label = "beagleboard::pmu_stat";
+			gpios = <&twl_gpio 19 0>; /* LEDB */
+		};
+	};
 };
 
 &i2c1 {
@@ -67,3 +75,15 @@
 &mmc3 {
 	status = "disabled";
 };
+
+&twl_gpio {
+	ti,use-leds;
+	/* pullups: BIT(1) */
+	ti,pullups = <0x000002>;
+	/*
+	 * pulldowns:
+	 * BIT(2), BIT(6), BIT(7), BIT(8), BIT(13)
+	 * BIT(15), BIT(16), BIT(17)
+	 */
+	ti,pulldowns = <0x03a1c4>;
+};
diff --git a/arch/arm/boot/dts/omap3-evm.dts b/arch/arm/boot/dts/omap3-evm.dts
index f349ee9..e8ba1c2 100644
--- a/arch/arm/boot/dts/omap3-evm.dts
+++ b/arch/arm/boot/dts/omap3-evm.dts
@@ -17,6 +17,15 @@
 		device_type = "memory";
 		reg = <0x80000000 0x10000000>; /* 256 MB */
 	};
+
+	leds {
+		compatible = "gpio-leds";
+		ledb {
+			label = "omap3evm::ledb";
+			gpios = <&twl_gpio 19 0>; /* LEDB */
+			linux,default-trigger = "default-on";
+		};
+	};
 };
 
 &i2c1 {
@@ -46,3 +55,7 @@
 		reg = <0x5c>;
 	};
 };
+
+&twl_gpio {
+	ti,use-leds;
+};
-- 
1.7.5.4

Re: [PATCH v2 0/2] gpio-twl4030: add new device tree properties

From: Benoit Cousson <hidden>
Date: 2012-09-05 14:41:26

Hi Florian,

On 09/05/2012 09:46 AM, Florian Vaussard wrote:
Hello,

A number of platform data are missing when using twl4030/gpio from a
device tree. This patchset adds the missing properties, updates the 
documentation with the new bindings, and updates existing device trees.
It mainly enables LEDA and LEDB outputs, as well as pullups /
pulldowns on GPIOs.

The 1st patch changes the device driver and updates the documentation.
The 2nd patch updates the device trees for BeagleBoard and omap3-evm.

Changes since v1: 
- Patches on driver and documentation merged into the same patch
- Put device trees' values in hexadecimal
- Handle bool property using of_property_read_bool()
- Prefix the patches with the correct convention
Thanks for the update.
Tested on Gumstix Overo. V1 was tested on omap3-evm by Vaibhav Hiremath.
I've just tested it on beagle xM. I can play with D12 led using:

echo 255 > /sys/class/leds/beagleboard\:\:pmu_stat/brightness

Tested-by: Benoit Cousson <redacted>

BTW: who will merge this?
Since Linus already acked it, Tony can merge it.


Tony,

I can add that series in my DTS series for 3.7 if you want.

Regards,
Benoit

Re: [PATCH v2 0/2] gpio-twl4030: add new device tree properties

From: Tony Lindgren <tony@atomide.com>
Date: 2012-09-06 20:51:23

* Benoit Cousson [off-list ref] [120905 07:42]:
Hi Florian,

On 09/05/2012 09:46 AM, Florian Vaussard wrote:
quoted
Hello,

A number of platform data are missing when using twl4030/gpio from a
device tree. This patchset adds the missing properties, updates the 
documentation with the new bindings, and updates existing device trees.
It mainly enables LEDA and LEDB outputs, as well as pullups /
pulldowns on GPIOs.

The 1st patch changes the device driver and updates the documentation.
The 2nd patch updates the device trees for BeagleBoard and omap3-evm.

Changes since v1: 
- Patches on driver and documentation merged into the same patch
- Put device trees' values in hexadecimal
- Handle bool property using of_property_read_bool()
- Prefix the patches with the correct convention
Thanks for the update.
quoted
Tested on Gumstix Overo. V1 was tested on omap3-evm by Vaibhav Hiremath.
I've just tested it on beagle xM. I can play with D12 led using:

echo 255 > /sys/class/leds/beagleboard\:\:pmu_stat/brightness

Tested-by: Benoit Cousson <redacted>

quoted
BTW: who will merge this?
Since Linus already acked it, Tony can merge it.


Tony,

I can add that series in my DTS series for 3.7 if you want.
Yes please do thanks.

Tony

Re: [PATCH v2 0/2] gpio-twl4030: add new device tree properties

From: Benoit Cousson <hidden>
Date: 2012-09-07 08:55:43

On 09/06/2012 10:51 PM, Tony Lindgren wrote:
* Benoit Cousson [off-list ref] [120905 07:42]:
quoted
Hi Florian,

On 09/05/2012 09:46 AM, Florian Vaussard wrote:
quoted
Hello,

A number of platform data are missing when using twl4030/gpio from a
device tree. This patchset adds the missing properties, updates the 
documentation with the new bindings, and updates existing device trees.
It mainly enables LEDA and LEDB outputs, as well as pullups /
pulldowns on GPIOs.

The 1st patch changes the device driver and updates the documentation.
The 2nd patch updates the device trees for BeagleBoard and omap3-evm.

Changes since v1: 
- Patches on driver and documentation merged into the same patch
- Put device trees' values in hexadecimal
- Handle bool property using of_property_read_bool()
- Prefix the patches with the correct convention
Thanks for the update.
quoted
Tested on Gumstix Overo. V1 was tested on omap3-evm by Vaibhav Hiremath.
I've just tested it on beagle xM. I can play with D12 led using:

echo 255 > /sys/class/leds/beagleboard\:\:pmu_stat/brightness

Tested-by: Benoit Cousson <redacted>

quoted
BTW: who will merge this?
Since Linus already acked it, Tony can merge it.


Tony,

I can add that series in my DTS series for 3.7 if you want.
Yes please do thanks.
On top of that series, I realized that beagle was missing the other
LEDs. So I've just posted the support for the two missing ones.

[PATCH] ARM: dts: omap3-beagle: Add heartbeat and mmc LEDs support

Regards,
Benoit
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help