summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/arm/include/asm/arch-s5pc1xx/gpio.h13
-rw-r--r--arch/arm/include/asm/arch-s5pc2xx/gpio.h29
-rw-r--r--drivers/gpio/s5p_gpio.c44
3 files changed, 86 insertions, 0 deletions
diff --git a/arch/arm/include/asm/arch-s5pc1xx/gpio.h b/arch/arm/include/asm/arch-s5pc1xx/gpio.h
index 903de9c..76b901b 100644
--- a/arch/arm/include/asm/arch-s5pc1xx/gpio.h
+++ b/arch/arm/include/asm/arch-s5pc1xx/gpio.h
@@ -134,6 +134,19 @@ unsigned int s5p_gpio_get_value(struct s5p_gpio_bank *bank, int gpio);
void s5p_gpio_set_pull(struct s5p_gpio_bank *bank, int gpio, int mode);
void s5p_gpio_set_drv(struct s5p_gpio_bank *bank, int gpio, int mode);
void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode);
+
+/* GPIO pins per bank */
+#define GPIO_PER_BANK 8
+
+static inline unsigned int s5p_gpio_base(int nr)
+{
+ return S5PC110_GPIO_BASE;
+}
+
+#define s5pc110_gpio_get_nr(bank, pin) \
+ ((((((unsigned int)&(((struct s5pc110_gpio *)S5PC110_GPIO_BASE)->bank))\
+ - S5PC110_GPIO_BASE) / sizeof(struct s5p_gpio_bank)) \
+ * GPIO_PER_BANK) + pin)
#endif
/* Pin configurations */
diff --git a/arch/arm/include/asm/arch-s5pc2xx/gpio.h b/arch/arm/include/asm/arch-s5pc2xx/gpio.h
index 8db5895..8be620c 100644
--- a/arch/arm/include/asm/arch-s5pc2xx/gpio.h
+++ b/arch/arm/include/asm/arch-s5pc2xx/gpio.h
@@ -88,6 +88,35 @@ unsigned int s5p_gpio_get_value(struct s5p_gpio_bank *bank, int gpio);
void s5p_gpio_set_pull(struct s5p_gpio_bank *bank, int gpio, int mode);
void s5p_gpio_set_drv(struct s5p_gpio_bank *bank, int gpio, int mode);
void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode);
+
+/* GPIO pins per bank */
+#define GPIO_PER_BANK 8
+
+#define s5pc210_gpio_part1_get_nr(bank, pin) \
+ ((((((unsigned int) &(((struct s5pc210_gpio_part1 *) \
+ S5PC210_GPIO_PART1_BASE)->bank)) \
+ - S5PC210_GPIO_PART1_BASE) / sizeof(struct s5p_gpio_bank)) \
+ * GPIO_PER_BANK) + pin)
+
+#define GPIO_PART1_MAX ((sizeof(struct s5pc210_gpio_part1) \
+ / sizeof(struct s5p_gpio_bank)) * GPIO_PER_BANK)
+
+#define s5pc210_gpio_part2_get_nr(bank, pin) \
+ (((((((unsigned int) &(((struct s5pc210_gpio_part2 *) \
+ S5PC210_GPIO_PART2_BASE)->bank)) \
+ - S5PC210_GPIO_PART2_BASE) / sizeof(struct s5p_gpio_bank)) \
+ * GPIO_PER_BANK) + pin) + GPIO_PART1_MAX)
+
+static inline unsigned int s5p_gpio_base(int nr)
+{
+ if (nr < GPIO_PART1_MAX)
+ return S5PC210_GPIO_PART1_BASE;
+ else
+ return S5PC210_GPIO_PART2_BASE;
+
+ return 0;
+}
+
#endif
/* Pin configurations */
diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c
index 2043859..1edf9a2 100644
--- a/drivers/gpio/s5p_gpio.c
+++ b/drivers/gpio/s5p_gpio.c
@@ -141,3 +141,47 @@ void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode)
writel(value, &bank->drv);
}
+
+struct s5p_gpio_bank *s5p_gpio_get_bank(int nr)
+{
+ int bank = nr / GPIO_PER_BANK;
+ bank *= sizeof(struct s5p_gpio_bank);
+
+ return (struct s5p_gpio_bank *) (s5p_gpio_base(nr) + bank);
+}
+
+int s5p_gpio_get_pin(int nr)
+{
+ return nr % GPIO_PER_BANK;
+}
+
+int gpio_request(int gpio, const char *label)
+{
+ return 0;
+}
+
+int gpio_direction_input(int nr)
+{
+ s5p_gpio_direction_input(s5p_gpio_get_bank(nr),
+ s5p_gpio_get_pin(nr));
+ return 0;
+}
+
+int gpio_direction_output(int nr, int value)
+{
+ s5p_gpio_direction_output(s5p_gpio_get_bank(nr),
+ s5p_gpio_get_pin(nr), value);
+ return 0;
+}
+
+int gpio_get_value(int nr)
+{
+ return (int) s5p_gpio_get_value(s5p_gpio_get_bank(nr),
+ s5p_gpio_get_pin(nr));
+}
+
+void gpio_set_value(int nr, int value)
+{
+ s5p_gpio_set_value(s5p_gpio_get_bank(nr),
+ s5p_gpio_get_pin(nr), value);
+}