Skip to contentSkip to conversation

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

PATCH New Lukasz Majewski 2 participants 3 messages Sep 5, 2012 – Sep 18, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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

---
 arch/arm/include/asm/arch-exynos/gpio.h  |   19 +++++++++++++++++++
 arch/arm/include/asm/arch-s5pc1xx/gpio.h |    7 ++++++-
 drivers/gpio/s5p_gpio.c                  |    6 ++++--
 3 files changed, 29 insertions(+), 3 deletions(-)
arch/arm/include/asm/arch-exynos/gpio.h +19 -0
index 7a9bb90..fdb52fa 100644
@@ -204,6 +204,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 */
arch/arm/include/asm/arch-s5pc1xx/gpio.h +6 -1
index 76b901b..00e498d 100644
@@ -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)
drivers/gpio/s5p_gpio.c +4 -2
index 47f3213..656bf4a 100644
@@ -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);
 }
 
Signature · 1 line
1.7.2.3
#1 lore raw

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

Hi Minkyu,

Quoted 74 lines

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

---
 arch/arm/include/asm/arch-exynos/gpio.h  |   19 +++++++++++++++++++
 arch/arm/include/asm/arch-s5pc1xx/gpio.h |    7 ++++++-
 drivers/gpio/s5p_gpio.c                  |    6 ++++--
 3 files changed, 29 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/arch/arm/include/asm/arch-exynos/gpio.h index 7a9bb90..fdb52fa 100644 --- a/arch/arm/include/asm/arch-exynos/gpio.h +++ b/arch/arm/include/asm/arch-exynos/gpio.h

arch/arm/include/asm/arch-exynos/gpio.h +19 -0
@@ -204,6 +204,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 */
(quoted diff) +0 -0

b/arch/arm/include/asm/arch-s5pc1xx/gpio.h index 76b901b..00e498d 100644 --- a/arch/arm/include/asm/arch-s5pc1xx/gpio.h +++ b/arch/arm/include/asm/arch-s5pc1xx/gpio.h

arch/arm/include/asm/arch-s5pc1xx/gpio.h +6 -1
@@ -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)) \
arch/arm/include/asm/arch-s5pc1xx/gpio.h +0 -0
 	  * GPIO_PER_BANK) + pin)
drivers/gpio/s5p_gpio.c +0 -0
index 47f3213..656bf4a 100644
@@ -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)
 {

drivers/gpio/s5p_gpio.c void s5p_gpio_set_rate(struct s5p_gpio_bank · line 154

Quoted 10 lines
drivers/gpio/s5p_gpio.c +4 -2
-	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);
 }
 

Do you have any comments about this fix?

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
#2 lore raw

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

Dear Lukasz Majewski,

Quoted 19 lines · Lukasz Majewski

Hi Minkyu,

Quoted 17 lines

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

---
 arch/arm/include/asm/arch-exynos/gpio.h  |   19 +++++++++++++++++++
 arch/arm/include/asm/arch-s5pc1xx/gpio.h |    7 ++++++-
 drivers/gpio/s5p_gpio.c                  |    6 ++++--
 3 files changed, 29 insertions(+), 3 deletions(-)

applied to u-boot-samsung.

Thanks.
Minkyu Kang.

Signature · 2 lines
from. prom.
www.promsoft.net