]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[ARM] KS8695: Fixup the KS8695 GPIO to be GPIOLIB
authorDaniel Silverstone <dsilvers@simtec.co.uk>
Sat, 13 Dec 2008 20:44:12 +0000 (20:44 +0000)
committerBen Dooks <ben-linux@fluff.org>
Sun, 14 Dec 2008 11:34:47 +0000 (11:34 +0000)
This patch is as small a change as possible to the KS8695 GPIO layer
to use GPIOLIB to allow the generic GPIO expanders and the like to
be compiled.

As a side-effect, we also remove __init_or_module from several
functions which could be called by drivers such as i2c-gpio which
could plausibly be compiled into a non-modular kernel.

Signed-off-by: Daniel Silverstone <dsilvers@simtec.co.uk>
Signed-off-by: Vincent Sanders <vince@simtec.co.uk>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
arch/arm/Kconfig
arch/arm/mach-ks8695/board-micrel.c
arch/arm/mach-ks8695/gpio.c
arch/arm/mach-ks8695/include/mach/gpio.h

index 4546f8b2ce8cfc8ab6c1f9bfdc5f69feebc10a72..d953ed95701e7cb73a8f81f700a93c4a8896afd7 100644 (file)
@@ -397,6 +397,7 @@ config ARCH_KS8695
        bool "Micrel/Kendin KS8695"
        select CPU_ARM922T
        select GENERIC_GPIO
+        select ARCH_REQUIRE_GPIOLIB
        help
          Support for Micrel/Kendin KS8695 "Centaur" (ARM922T) based
          System-on-Chip devices.
index 0468e93b7d3b3c2656f1537aa0a9698e3123cb87..8ceaf5ac6e2ca405bc4843b7f66fb8141807c8b3 100644 (file)
@@ -18,6 +18,7 @@
 #include <asm/mach/map.h>
 #include <asm/mach/irq.h>
 
+#include <mach/gpio.h>
 #include <mach/devices.h>
 
 #include "generic.h"
@@ -39,6 +40,8 @@ static void __init micrel_init(void)
 {
        printk(KERN_INFO "Micrel KS8695 Development Board initializing\n");
 
+       ks8695_register_gpios();
+
 #ifdef CONFIG_PCI
        ks8695_init_pci(&micrel_pci);
 #endif
index 9aecf0c4b8b1e47b8c65e0655c3eaa0774e38554..26d6346f38f1ffb0d11ce53db123d31d8802068f 100644 (file)
@@ -2,6 +2,8 @@
  * arch/arm/mach-ks8695/gpio.c
  *
  * Copyright (C) 2006 Andrew Victor
+ * Updated to GPIOLIB, Copyright 2008 Simtec Electronics
+ *                     Daniel Silverstone <dsilvers@simtec.co.uk>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -35,7 +37,7 @@
  * Configure a GPIO line for either GPIO function, or its internal
  * function (Interrupt, Timer, etc).
  */
-static void __init_or_module ks8695_gpio_mode(unsigned int pin, short gpio)
+static void ks8695_gpio_mode(unsigned int pin, short gpio)
 {
        unsigned int enable[] = { IOPC_IOEINT0EN, IOPC_IOEINT1EN, IOPC_IOEINT2EN, IOPC_IOEINT3EN, IOPC_IOTIM0EN, IOPC_IOTIM1EN };
        unsigned long x, flags;
@@ -61,7 +63,7 @@ static unsigned short gpio_irq[] = { KS8695_IRQ_EXTERN0, KS8695_IRQ_EXTERN1, KS8
 /*
  * Configure GPIO pin as external interrupt source.
  */
-int __init_or_module ks8695_gpio_interrupt(unsigned int pin, unsigned int type)
+int ks8695_gpio_interrupt(unsigned int pin, unsigned int type)
 {
        unsigned long x, flags;
 
@@ -94,7 +96,7 @@ EXPORT_SYMBOL(ks8695_gpio_interrupt);
 /*
  * Configure the GPIO line as an input.
  */
-int __init_or_module gpio_direction_input(unsigned int pin)
+static int ks8695_gpio_direction_input(struct gpio_chip *gc, unsigned int pin)
 {
        unsigned long x, flags;
 
@@ -115,13 +117,13 @@ int __init_or_module gpio_direction_input(unsigned int pin)
 
        return 0;
 }
-EXPORT_SYMBOL(gpio_direction_input);
 
 
 /*
  * Configure the GPIO line as an output, with default state.
  */
-int __init_or_module gpio_direction_output(unsigned int pin, unsigned int state)
+static int ks8695_gpio_direction_output(struct gpio_chip *gc,
+                                       unsigned int pin, int state)
 {
        unsigned long x, flags;
 
@@ -150,13 +152,13 @@ int __init_or_module gpio_direction_output(unsigned int pin, unsigned int state)
 
        return 0;
 }
-EXPORT_SYMBOL(gpio_direction_output);
 
 
 /*
  * Set the state of an output GPIO line.
  */
-void gpio_set_value(unsigned int pin, unsigned int state)
+static void ks8695_gpio_set_value(struct gpio_chip *gc,
+                                 unsigned int pin, int state)
 {
        unsigned long x, flags;
 
@@ -175,13 +177,12 @@ void gpio_set_value(unsigned int pin, unsigned int state)
 
        local_irq_restore(flags);
 }
-EXPORT_SYMBOL(gpio_set_value);
 
 
 /*
  * Read the state of a GPIO line.
  */
-int gpio_get_value(unsigned int pin)
+static int ks8695_gpio_get_value(struct gpio_chip *gc, unsigned int pin)
 {
        unsigned long x;
 
@@ -191,7 +192,6 @@ int gpio_get_value(unsigned int pin)
        x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPD);
        return (x & IOPD(pin)) != 0;
 }
-EXPORT_SYMBOL(gpio_get_value);
 
 
 /*
@@ -219,6 +219,25 @@ int irq_to_gpio(unsigned int irq)
 }
 EXPORT_SYMBOL(irq_to_gpio);
 
+/* GPIOLIB interface */
+
+static struct gpio_chip ks8695_gpio_chip = {
+       .label                  = "KS8695",
+       .direction_input        = ks8695_gpio_direction_input,
+       .direction_output       = ks8695_gpio_direction_output,
+       .get                    = ks8695_gpio_get_value,
+       .set                    = ks8695_gpio_set_value,
+       .base                   = 0,
+       .ngpio                  = 16,
+       .can_sleep              = 0,
+};
+
+/* Register the GPIOs */
+void ks8695_register_gpios(void)
+{
+       if (gpiochip_add(&ks8695_gpio_chip))
+               printk(KERN_ERR "Unable to register core GPIOs\n");
+}
 
 /* .... Debug interface ..................................................... */
 
index d4af5c335f1616aace85c43a4fa6b57f25c21006..6379f2fe843d52ffbccbee9f017033850d309794 100644 (file)
 #define KS8695_GPIO_14         14
 #define KS8695_GPIO_15         15
 
-
 /*
  * Configure GPIO pin as external interrupt source.
  */
-int __init_or_module ks8695_gpio_interrupt(unsigned int pin, unsigned int type);
-
-/*
- * Configure the GPIO line as an input.
- */
-int __init_or_module gpio_direction_input(unsigned int pin);
-
-/*
- * Configure the GPIO line as an output, with default state.
- */
-int __init_or_module gpio_direction_output(unsigned int pin, unsigned int state);
-
-/*
- * Set the state of an output GPIO line.
- */
-void gpio_set_value(unsigned int pin, unsigned int state);
-
-/*
- * Read the state of a GPIO line.
- */
-int gpio_get_value(unsigned int pin);
+extern int ks8695_gpio_interrupt(unsigned int pin, unsigned int type);
 
 /*
  * Map GPIO line to IRQ number.
  */
-int gpio_to_irq(unsigned int pin);
+extern int gpio_to_irq(unsigned int pin);
 
 /*
  * Map IRQ number to GPIO line.
  */
-int irq_to_gpio(unsigned int irq);
-
+extern int irq_to_gpio(unsigned int irq);
 
 #include <asm-generic/gpio.h>
 
-static inline int gpio_request(unsigned int pin, const char *label)
-{
-       return 0;
-}
+/* If it turns out that we need to optimise GPIO access for the
+ * Micrel's GPIOs, then these can be changed to check their argument
+ * directly as static inlines. However for now it's probably not
+ * worthwhile.
+ */
+#define gpio_get_value __gpio_get_value
+#define gpio_set_value __gpio_set_value
 
-static inline void gpio_free(unsigned int pin)
-{
-       might_sleep();
-}
+/* Register the GPIOs */
+extern void ks8695_register_gpios(void);
 
 #endif