Skip to content
Snippets Groups Projects
Commit 822593f0 authored by Łukasz Majewski's avatar Łukasz Majewski Committed by Minkyu Kang
Browse files

gpio:fix: Proper handling of GPIO subsystem parts at Samsung devices


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: default avatarLukasz Majewski <l.majewski@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarMinkyu Kang <mk7.kang@samsung.com>
parent ccfa3985
No related branches found
No related tags found
No related merge requests found
...@@ -207,6 +207,25 @@ static inline unsigned int s5p_gpio_base(int nr) ...@@ -207,6 +207,25 @@ static inline unsigned int s5p_gpio_base(int nr)
return 0; 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 #endif
/* Pin configurations */ /* Pin configurations */
......
...@@ -143,7 +143,12 @@ static inline unsigned int s5p_gpio_base(int nr) ...@@ -143,7 +143,12 @@ static inline unsigned int s5p_gpio_base(int nr)
return S5PC110_GPIO_BASE; 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))\ ((((((unsigned int)&(((struct s5pc110_gpio *)S5PC110_GPIO_BASE)->bank))\
- S5PC110_GPIO_BASE) / sizeof(struct s5p_gpio_bank)) \ - S5PC110_GPIO_BASE) / sizeof(struct s5p_gpio_bank)) \
* GPIO_PER_BANK) + pin) * GPIO_PER_BANK) + pin)
......
...@@ -144,9 +144,11 @@ void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode) ...@@ -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) struct s5p_gpio_bank *s5p_gpio_get_bank(unsigned gpio)
{ {
int bank = gpio / GPIO_PER_BANK; int bank;
bank *= sizeof(struct s5p_gpio_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); return (struct s5p_gpio_bank *) (s5p_gpio_base(gpio) + bank);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment