diff options
author | Przemyslaw Marczak <p.marczak@samsung.com> | 2014-01-22 11:24:10 +0100 |
---|---|---|
committer | Minkyu Kang <mk7.kang@samsung.com> | 2014-02-03 15:36:14 +0900 |
commit | 8475c869c30cbeef1695396b43bc240cc0d35f5a (patch) | |
tree | 8f31f7df5b8bec2a11a73f88cefd1a687ef12827 /drivers/gpio | |
parent | 047eada42a776468426be1f05d3203f90ce3a8d8 (diff) | |
download | u-boot-8475c869c30cbeef1695396b43bc240cc0d35f5a.tar.gz u-boot-8475c869c30cbeef1695396b43bc240cc0d35f5a.tar.xz u-boot-8475c869c30cbeef1695396b43bc240cc0d35f5a.zip |
s5p: gpio: change gpio coding method for s5p gpio.
Old s5p gpio coding method was not clean and was not working properly
for all parts and banks. New method is clean and easy to extend.
Gpio coding mask:
0x000000ff - pin number
0x00ffff00 - bank offset
0xff000000 - part number
Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/s5p_gpio.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c index 7eeb96d19f..11a0472c69 100644 --- a/drivers/gpio/s5p_gpio.c +++ b/drivers/gpio/s5p_gpio.c @@ -9,6 +9,11 @@ #include <asm/io.h> #include <asm/gpio.h> +#define S5P_GPIO_GET_BANK(x) ((x >> S5P_GPIO_BANK_SHIFT) \ + & S5P_GPIO_BANK_MASK) + +#define S5P_GPIO_GET_PIN(x) (x & S5P_GPIO_PIN_MASK) + #define CON_MASK(x) (0xf << ((x) << 2)) #define CON_SFR(x, v) ((v) << ((x) << 2)) @@ -124,17 +129,15 @@ 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; - unsigned g = gpio - s5p_gpio_part_max(gpio); + unsigned bank = S5P_GPIO_GET_BANK(gpio); + unsigned base = s5p_gpio_base(gpio); - bank = g / GPIO_PER_BANK; - bank *= sizeof(struct s5p_gpio_bank); - return (struct s5p_gpio_bank *) (s5p_gpio_base(gpio) + bank); + return (struct s5p_gpio_bank *)(base + bank); } int s5p_gpio_get_pin(unsigned gpio) { - return gpio % GPIO_PER_BANK; + return S5P_GPIO_GET_PIN(gpio); } /* Common GPIO API */ |