gpio: lpc32xx: fix issues with port3 gpio
Subsystems (3)
PATCH v2 1/1 gpio: lpc32xx: fix issues with port3 gpio
From: Sylvain Lemieux <[email protected]>
The current simplify lpc32xx gpio driver implementation assume a maximum of 32 GPIO per port; there are a total of 22 GPI, 24 GPO and 6 GPIO to managed on port 3.
Update the driver to fix the following:
1) When requesting GPI_xx and GPO_xx on port 3 (xx is the same number) the second call to "gpio_request" will return -EBUSY.
2) The status of GPO_xx pin report the status of the corresponding GPI_xx pin when using the "gpio status" command.
3) The gpio driver may setup the direction register for the wrong gpio when calling "gpio_direction_input" (GPI_xx) or "gpio_direction_output" (GPO_xx) on port 3; the call to the direction is require to use the "gpio status" command.
The following change were done in the driver:
1) port3 GPI are cache in a separate 32 bits in the array.
2) port3 direction register written only for GPIO pins.
3) port3 GPO & GPIO (as output) are read using "p3_outp_state".
4) LPC32XX_GPI_P3_GRP updated to match the change.
---
To reproduce the issues, the following test can be execute:
1) Add to source code:
int ret1 = gpio_request(LPC32XX_GPIO(LPC32XX_GPO_P3_GRP, 19), "GPO_19"); int ret2 = gpio_request(LPC32XX_GPIO(LPC32XX_GPI_P3_GRP, 19), "GPI_19");
The second call return "-EBUSY".
2) Setup a logical 0 on GPI_19 pin
--> gpio set 115
gpio: pin 115 (gpio 115) value is 1
--> gpio status
115: output: 0 [x] GPO_19
Setup a logic 1 on GPI_19 pin
--> gpio clear115
gpio: pin 115 (gpio 115) value is 0
--> gpio status
115: output: 1 [x] GPO_19
3) Add to source code:
(void)gpio_request(LPC32XX_GPIO(LPC32XX_GPI_P3_GRP, 25), "GPI_25");
--> gpio status
121: unknown
Add to source code: (void)gpio_request(LPC32XX_GPIO(LPC32XX_GPI_P3_GRP, 25), "GPI_25"); (void)gpio_direction_input(LPC32XX_GPIO(LPC32XX_GPI_P3_GRP, 25));
--> gpio status
121: input: 0 [x] GPI_25
The direction register is written and GPIO_0 is configured as input.
Changes from v1 to v2:
* Regenarate the patch; the patch did not apply.
Note:
I am sending the patch using <[email protected]>, until I can submit patch using my regular e-mail <[email protected]>.
arch/arm/include/asm/arch-lpc32xx/gpio_grp.h | 4 +-- drivers/gpio/lpc32xx_gpio.c | 41 ++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 8 deletions(-)
arch/arm/include/asm/arch-lpc32xx/gpio_grp.h +2 -2
@@ -12,7 +12,7 @@/* * Macro to map the pin for the lpc32xx_gpio driver. -* Note: - GPIOS are considered here as homogeneous and linear, from 0 to 127; +* Note: - GPIOS are considered here as homogeneous and linear from 0 to 159; * mapping is done per register, as group of 32. * (see drivers/gpio/lpc32xx_gpio.c for details). * - macros can be use with the following pins:
@@ -26,9 +26,9 @@#define LPC32XX_GPIO_P0_GRP 0#define LPC32XX_GPIO_P1_GRP 32#define LPC32XX_GPIO_P2_GRP 64 -#define LPC32XX_GPI_P3_GRP 96#define LPC32XX_GPO_P3_GRP 96#define LPC32XX_GPIO_P3_GRP (LPC32XX_GPO_P3_GRP + 25) +#define LPC32XX_GPI_P3_GRP 128/* * A specific GPIO can be selected with this macro
drivers/gpio/lpc32xx_gpio.c +35 -6
96 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 1/1 gpio: lpc32xx: fix issues with port3 gpio
Quoted 18 lines · slemieux.tyco at gmail.com
From: Sylvain Lemieux <[email protected]>
The current simplify lpc32xx gpio driver implementation assume a maximum of 32 GPIO per port; there are a total of 22 GPI, 24 GPO and 6 GPIO to managed on port 3.
Update the driver to fix the following:
1) When requestingGPI_xxandGPO_xxon port 3 (xx is the same number) the second call to "gpio_request" will return-EBUSY.2) The status of
GPO_xxpin report the status of the correspondingGPI_xxpin when using the "gpio status" command.3) The gpio driver may setup the direction register for the wrong gpio when calling "
gpio_direction_input" (GPI_xx) or "gpio_direction_output" (GPO_xx) on port 3; the call to the direction is require to use the "gpio status" command.
Quoted 7 lines
The following change were done in the driver:
1) port3 GPI are cache in a separate 32 bits in the array.
2) port3 direction register written only for GPIO pins.
3) port3 GPO & GPIO (as output) are read using "p3_outp_state".
4)LPC32XX_GPI_P3_GRPupdated to match the change.Signed-off-by Sylvain Lemieux <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/ebe37ddc/attachment.sig>