]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
gpio:fix: Proper handling of GPIO subsystem parts at Samsung devices
authorŁukasz Majewski <l.majewski@samsung.com>
Tue, 4 Sep 2012 21:47:46 +0000 (21:47 +0000)
committerMinkyu Kang <mk7.kang@samsung.com>
Thu, 15 Nov 2012 12:08:18 +0000 (21:08 +0900)
Now proper GPIO parts numbering is handled at Samsung devices.
This fix is necessary for code using GPIO located at other banks
than first.

Test HW:
- Exynos4210 - Trats
- S5PC110 - goni

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
arch/arm/include/asm/arch-exynos/gpio.h
arch/arm/include/asm/arch-s5pc1xx/gpio.h
drivers/gpio/s5p_gpio.c

index 97be4eac052d122573bbd750e0081a2bda611420..4db8fd640e0f78006d040f5abe53c1100585269f 100644 (file)
@@ -207,6 +207,25 @@ static inline unsigned int s5p_gpio_base(int nr)
        return 0;
 }
 
+static inline unsigned int s5p_gpio_part_max(int nr)
+{
+       if (cpu_is_exynos5()) {
+               if (nr < EXYNOS5_GPIO_PART1_MAX)
+                       return 0;
+               else if (nr < EXYNOS5_GPIO_PART2_MAX)
+                       return EXYNOS5_GPIO_PART1_MAX;
+               else
+                       return EXYNOS5_GPIO_PART2_MAX;
+
+       } else if (cpu_is_exynos4()) {
+               if (nr < EXYNOS4_GPIO_PART1_MAX)
+                       return 0;
+               else
+                       return EXYNOS4_GPIO_PART1_MAX;
+       }
+
+       return 0;
+}
 #endif
 
 /* Pin configurations */
index 76b901b3977bbc5110f45ad47546400e479775ed..00e498d834b3dea2164cbdfc0dcdec40999fa16f 100644 (file)
@@ -143,7 +143,12 @@ static inline unsigned int s5p_gpio_base(int nr)
        return S5PC110_GPIO_BASE;
 }
 
-#define s5pc110_gpio_get_nr(bank, pin) \
+static inline unsigned int s5p_gpio_part_max(int nr)
+{
+       return 0;
+}
+
+#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)
index 47f321392791cfc093c6f6b14b8433c500f7e032..656bf4a06c22072f2c228cb69cf174ee7b089b3b 100644 (file)
@@ -144,9 +144,11 @@ void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode)
 
 struct s5p_gpio_bank *s5p_gpio_get_bank(unsigned gpio)
 {
-       int bank = gpio / GPIO_PER_BANK;
-       bank *= sizeof(struct s5p_gpio_bank);
+       int bank;
+       unsigned g = gpio - s5p_gpio_part_max(gpio);
 
+       bank = g / GPIO_PER_BANK;
+       bank *= sizeof(struct s5p_gpio_bank);
        return (struct s5p_gpio_bank *) (s5p_gpio_base(gpio) + bank);
 }