diff mbox

[2/2] GPIO: gpio-pxa: fix devicetree functions

Message ID 1343230539-7196-2-git-send-email-zonque@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Mack July 25, 2012, 3:35 p.m. UTC
Provide an of_xlate function for the PXA GPIO chips and make it work for
devicetree environments.

Successfully tested on a PXA3xx board.

Signed-off-by: Daniel Mack <zonque@gmail.com>
---
 drivers/gpio/gpio-pxa.c |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Comments

Linus Walleij Aug. 4, 2012, 11:16 p.m. UTC | #1
On Wed, Jul 25, 2012 at 5:35 PM, Daniel Mack <zonque@gmail.com> wrote:

> Provide an of_xlate function for the PXA GPIO chips and make it work for
> devicetree environments.
>
> Successfully tested on a PXA3xx board.
>
> Signed-off-by: Daniel Mack <zonque@gmail.com>

Could the PXA maintainers pls have a look at this patch, if you're working
on DT support especially...

BTW: I guess this is not a fix for issues in the current kernel HEAD?
Is it OK to have this for the next (v3.7) cycle?

Yours,
Linus Walleij
Haojian Zhuang Aug. 5, 2012, 3:52 a.m. UTC | #2
On Sun, Aug 5, 2012 at 7:16 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Wed, Jul 25, 2012 at 5:35 PM, Daniel Mack <zonque@gmail.com> wrote:
>
>> Provide an of_xlate function for the PXA GPIO chips and make it work for
>> devicetree environments.
>>
>> Successfully tested on a PXA3xx board.
>>
>> Signed-off-by: Daniel Mack <zonque@gmail.com>
>
> Could the PXA maintainers pls have a look at this patch, if you're working
> on DT support especially...
>
> BTW: I guess this is not a fix for issues in the current kernel HEAD?
> Is it OK to have this for the next (v3.7) cycle?
>
It's a real fix. Since of_get_named_gpio_flags() needs to get flags of gpio.
This function is widely used in mmc/usb/... drivers. So it requires
vendor's gpio
driver to support parse flags from DT script.

gpio-pxa driver doesn't support flags before. Now Daniel's patch can
fix this issue.
So I'm OK on this patch.

Regards
Haojian
Linus Walleij Aug. 5, 2012, 9:40 a.m. UTC | #3
On Sun, Aug 5, 2012 at 5:52 AM, Haojian Zhuang <haojian.zhuang@gmail.com> wrote:
> On Sun, Aug 5, 2012 at 7:16 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
>> On Wed, Jul 25, 2012 at 5:35 PM, Daniel Mack <zonque@gmail.com> wrote:
>>
>>> Provide an of_xlate function for the PXA GPIO chips and make it work for
>>> devicetree environments.
>>>
>>> Successfully tested on a PXA3xx board.
>>>
>>> Signed-off-by: Daniel Mack <zonque@gmail.com>
>>
>> Could the PXA maintainers pls have a look at this patch, if you're working
>> on DT support especially...
>>
>> BTW: I guess this is not a fix for issues in the current kernel HEAD?
>> Is it OK to have this for the next (v3.7) cycle?
>>
> It's a real fix. Since of_get_named_gpio_flags() needs to get flags of gpio.
> This function is widely used in mmc/usb/... drivers. So it requires
> vendor's gpio
> driver to support parse flags from DT script.

OK I take that as an ACK so I've put it on my fixes branch with
your Acked-by.

Thanks,
Linus Walleij
Haojian Zhuang Aug. 5, 2012, 12:58 p.m. UTC | #4
On Sun, Aug 5, 2012 at 5:40 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Sun, Aug 5, 2012 at 5:52 AM, Haojian Zhuang <haojian.zhuang@gmail.com> wrote:
>> On Sun, Aug 5, 2012 at 7:16 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
>>> On Wed, Jul 25, 2012 at 5:35 PM, Daniel Mack <zonque@gmail.com> wrote:
>>>
>>>> Provide an of_xlate function for the PXA GPIO chips and make it work for
>>>> devicetree environments.
>>>>
>>>> Successfully tested on a PXA3xx board.
>>>>
>>>> Signed-off-by: Daniel Mack <zonque@gmail.com>
>>>
>>> Could the PXA maintainers pls have a look at this patch, if you're working
>>> on DT support especially...
>>>
>>> BTW: I guess this is not a fix for issues in the current kernel HEAD?
>>> Is it OK to have this for the next (v3.7) cycle?
>>>
>> It's a real fix. Since of_get_named_gpio_flags() needs to get flags of gpio.
>> This function is widely used in mmc/usb/... drivers. So it requires
>> vendor's gpio
>> driver to support parse flags from DT script.
>
> OK I take that as an ACK so I've put it on my fixes branch with
> your Acked-by.
>
Thanks. Let me revert it from pxa git tree.

Regards
Haojian
diff mbox

Patch

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 6d0cb9d..f47e6b3 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -63,6 +63,7 @@  static int irq_base;
 
 #ifdef CONFIG_OF
 static struct irq_domain *domain;
+static struct device_node *pxa_gpio_of_node;
 #endif
 
 struct pxa_gpio_chip {
@@ -229,6 +230,24 @@  static void pxa_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 				(value ? GPSR_OFFSET : GPCR_OFFSET));
 }
 
+#ifdef CONFIG_OF_GPIO
+static int pxa_gpio_of_xlate(struct gpio_chip *gc,
+			     const struct of_phandle_args *gpiospec,
+			     u32 *flags)
+{
+	if (gpiospec->args[0] > pxa_last_gpio)
+		return -EINVAL;
+
+	if (gc != &pxa_gpio_chips[gpiospec->args[0] / 32].chip)
+		return -EINVAL;
+
+	if (flags)
+		*flags = gpiospec->args[1];
+
+	return gpiospec->args[0] % 32;
+}
+#endif
+
 static int __devinit pxa_init_gpio_chip(int gpio_end,
 					int (*set_wake)(unsigned int, unsigned int))
 {
@@ -256,6 +275,11 @@  static int __devinit pxa_init_gpio_chip(int gpio_end,
 		c->get = pxa_gpio_get;
 		c->set = pxa_gpio_set;
 		c->to_irq = pxa_gpio_to_irq;
+#ifdef CONFIG_OF_GPIO
+		c->of_node = pxa_gpio_of_node;
+		c->of_xlate = pxa_gpio_of_xlate;
+		c->of_gpio_n_cells = 2;
+#endif
 
 		/* number of GPIOs on last bank may be less than 32 */
 		c->ngpio = (gpio + 31 > gpio_end) ? (gpio_end - gpio + 1) : 32;
@@ -457,6 +481,7 @@  static int pxa_irq_domain_map(struct irq_domain *d, unsigned int irq,
 
 const struct irq_domain_ops pxa_irq_domain_ops = {
 	.map	= pxa_irq_domain_map,
+	.xlate	= irq_domain_xlate_twocell,
 };
 
 #ifdef CONFIG_OF
@@ -497,6 +522,7 @@  static int __devinit pxa_gpio_probe_dt(struct platform_device *pdev)
 	}
 	domain = irq_domain_add_legacy(np, nr_gpios, irq_base, 0,
 				       &pxa_irq_domain_ops, NULL);
+	pxa_gpio_of_node = np;
 	return 0;
 err:
 	iounmap(gpio_reg_base);