Skip to contentSkip to conversation

gpiodev - ARM PXA implementation

RFC PATCH In review Paul Sokolovsky 1 participant 1 message Apr 10, 2007

lore
Share & tools
lore
#0 lore raw

RFC PATCH 2/3 gpiodev - ARM PXA implementation

Hello linux-arm-kernel,

GPIODEV API: Support for ARM PXA2xx CPU. Implementation is based on Generic GPIO API. Generally, GPIODEV implementation should be provided by device driver. But CPU-builtin devices in the current code are treated is special manner ("arch devices"), so this approach is followed for GPIODEV too.

Index: arch/arm/mach-pxa/generic.c
===================================================================
RCS file: /cvs/linux/kernel26/arch/arm/mach-pxa/generic.c,v retrieving revision 1.39
retrieving revision 1.41

arm/mach-pxa/generic.c 10 Apr 2007 15:35:33 -0000 1.41 renamed from arm/mach-pxa/generic.c 24 Feb 2007 13:14:41 -0000 1.39 +37 -0
diff -u -r1.39 -r1.41
@@ -24,6 +24,7 @@
 #include <linux/ioport.h>
 #include <linux/pm.h>
 #include <linux/string.h>
+#include <linux/gpiodev.h>
 
 #include <linux/sched.h>
 #include <asm/cnt32_to_63.h>
@@ -530,6 +531,41 @@
        .id             = -1,
 };
 
+
+static int pxa_gpiodev_get_value(struct device *dev, int gpio)
+{
+       return __gpio_get_value(gpio);
+}
+
+static void pxa_gpiodev_set_value(struct device *dev, int gpio, int value)
+{
+       __gpio_set_value(gpio, value);
+}
+
+static int pxa_gpiodev_to_irq(struct device *dev, int gpio)
+{
+       return IRQ_GPIO(gpio);
+}
+
+
+struct pxagpio_platform_data {
+       struct gpiodev_ops gpiodev_ops;
+} pxagpio_platform_data = {
+       .gpiodev_ops = {
+               .get = pxa_gpiodev_get_value,
+               .set = pxa_gpiodev_set_value,
+               .to_irq = pxa_gpiodev_to_irq,
+       }
+};
+
+struct platform_device pxagpio_device = {
+       .name           = "pxa2xx-gpio",
+       .id             = -1,
+       .dev            = {
+               .platform_data = &pxagpio_platform_data
+       }
+};
+
 static struct platform_device *devices[] __initdata = {
        &pxamci_device,
        &udc_device,
@@ -541,6 +580,7 @@
        &i2c_device,
        &i2s_device,
        &pxartc_device,
+       &pxagpio_device,
 };
 
 static int __init pxa_init(void)
Signature · 2 lines
Best regards,
 Paul                          mailto:[email protected]