rk: refactor gpio.h and add new gpio_is_valid
author黄涛 <huangtao@rock-chips.com>
Wed, 12 Dec 2012 08:28:10 +0000 (16:28 +0800)
committer黄涛 <huangtao@rock-chips.com>
Wed, 12 Dec 2012 08:28:10 +0000 (16:28 +0800)
arch/arm/mach-rk2928/include/mach/gpio.h
arch/arm/mach-rk30/include/mach/gpio.h
arch/arm/plat-rk/include/plat/gpio.h
include/asm-generic/gpio.h

index caf0c55929bd2abbf226cee947bb2b876ebde43f..4cf8254be0ad877c6cd7a7b6a97e71d8c86741e5 100755 (executable)
 
 #include <plat/gpio.h>
 
-#ifndef __ASSEMBLY__                                         
-extern void __init rk30_gpio_init(void); 
-static inline int gpio_to_irq(unsigned gpio)
-{
-       return gpio - PIN_BASE + NR_GIC_IRQS;
-}
-
-static inline int irq_to_gpio(unsigned irq)
-{
-       return irq - NR_GIC_IRQS + PIN_BASE;
-}
-
-#endif /* __ASSEMBLY__ */
-
 #endif
index 43c915d1102bb5eafaa84bc12b33689b7dab0bfa..d5ce06f1251743dd2cfd6e95fd0a01596787b804 100755 (executable)
 
 #include <plat/gpio.h>
 
-#ifndef __ASSEMBLY__                                         
-extern void __init rk30_gpio_init(void);
-
-static inline int gpio_to_irq(unsigned gpio)
-{
-       return gpio - PIN_BASE + NR_GIC_IRQS;
-}
-
-static inline int irq_to_gpio(unsigned irq)
-{
-       return irq - NR_GIC_IRQS + PIN_BASE;
-}
-#endif /* __ASSEMBLY__ */
-
 #endif
index f83ff524d2f14465c369f722f5621be93b936b09..20656edb2ac748d437bd0dbe8c15d7fd27bf2fe9 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __PLAT_GPIO_H
 #define __PLAT_GPIO_H
 
+#include <linux/types.h>
+
 /*
  * tp_int = <bank><goff><off><driving force><wake_en><irq_flags><reserve>
  * tp_rst = <bank><goff><off><driving force><active_low><pull_mode><reserve>
@@ -86,7 +88,24 @@ typedef enum GPIOIntType {
        GPIOEdgelRising
 }eGPIOIntType_t;
 
-#ifndef __ASSEMBLY__                                         
+static inline bool gpio_is_valid(int number)
+{
+       return number >= PIN_BASE && number < ARCH_NR_GPIOS;
+}
+
+#define gpio_is_valid gpio_is_valid
+
+extern void __init rk30_gpio_init(void);
+
+static inline int gpio_to_irq(unsigned gpio)
+{
+       return gpio - PIN_BASE + NR_GIC_IRQS;
+}
+
+static inline int irq_to_gpio(unsigned irq)
+{
+       return irq - NR_GIC_IRQS + PIN_BASE;
+}
 
 #include <asm/errno.h>
 #include <asm-generic/gpio.h>          /* cansleep wrappers */
@@ -95,6 +114,4 @@ typedef enum GPIOIntType {
 #define gpio_set_value __gpio_set_value
 #define gpio_cansleep  __gpio_cansleep
 
-#endif /* __ASSEMBLY__ */
-
 #endif
index 5ba10a40e523e4d7b17890a11783f59f8f77e857..44238fba36a3f13d93a72dff74fca1838efd9962 100644 (file)
  * platform data and other tables.
  */
 
+#ifndef gpio_is_valid
 static inline bool gpio_is_valid(int number)
 {
        return number >= 0 && number < ARCH_NR_GPIOS;
 }
+#endif
 
 struct device;
 struct seq_file;