Skip to contentSkip to conversation

ARM: mx5/babbage: Use gpio_request_one in babbage_fec_reset

PATCH New Fabio Estevam 2 participants 6 messages Mar 17, 2011

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

PATCH 1/4 ARM: mx5/babbage: Use gpio_request_one in babbage_fec_reset

Current code inside babbage_fec_reset uses gpio_direction_output with initial value of the GPIO and also sets the GPIO value via gpio_set_value to the same level right after. This is not needed.

By using gpio_request_one it is possible to set the direction and initial value in one shot.

---
 arch/arm/mach-mx5/board-mx51_babbage.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
arch/arm/mach-mx5/board-mx51_babbage.c +2 -3
index b2ecd19..ff79395 100644
@@ -228,13 +228,12 @@ static inline void babbage_fec_reset(void)
 	int ret;
 
 	/* reset FEC PHY */
-	ret = gpio_request(BABBAGE_FEC_PHY_RESET, "fec-phy-reset");
+	ret = gpio_request_one(BABBAGE_FEC_PHY_RESET, 
+					GPIOF_OUT_INIT_LOW, "fec-phy-reset");
 	if (ret) {
 		printk(KERN_ERR"failed to get GPIO_FEC_PHY_RESET: %d\n", ret);
 		return;
 	}
-	gpio_direction_output(BABBAGE_FEC_PHY_RESET, 0);
-	gpio_set_value(BABBAGE_FEC_PHY_RESET, 0);
 	msleep(1);
 	gpio_set_value(BABBAGE_FEC_PHY_RESET, 1);
 }
Signature · 1 line
1.6.0.4
#1 lore raw

PATCH 2/4 ARM: mx5/babbage: Use gpio_request_one in babbage_usbhub_reset

Current code inside babbage_usbhub_reset uses gpio_direction_output with initial value of the GPIO and also sets the GPIO value via gpio_set_value to the same level right after. This is not needed.

By using gpio_request_one it is possible to set the direction and initial value in one shot.

---
 arch/arm/mach-mx5/board-mx51_babbage.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
arch/arm/mach-mx5/board-mx51_babbage.c +3 -6
index ff79395..cba8307 100644
@@ -209,17 +209,14 @@ static inline void babbage_usbhub_reset(void)
 	int ret;
 
 	/* Bring USB hub out of reset */
-	ret = gpio_request(BABBAGE_USB_HUB_RESET, "GPIO1_7");
+	ret = gpio_request_one(BABBAGE_USB_HUB_RESET, 
+					GPIOF_OUT_INIT_LOW, "GPIO1_7");
 	if (ret) {
 		printk(KERN_ERR"failed to get GPIO_USB_HUB_RESET: %d\n", ret);
 		return;
 	}
-	gpio_direction_output(BABBAGE_USB_HUB_RESET, 0);
 
-	/* USB HUB RESET - De-assert USB HUB RESET_N */
-	msleep(1);
-	gpio_set_value(BABBAGE_USB_HUB_RESET, 0);
-	msleep(1);
+	msleep(2);
 	gpio_set_value(BABBAGE_USB_HUB_RESET, 1);
 }
 
Signature · 1 line
1.6.0.4
#2 lore raw

PATCH 3/4 ARM: mx5/mx53_evk: Use gpio_request_one in mx53_evk_fec_reset

Current code inside mx53_evk_fec_reset uses gpio_direction_output with initial value of the GPIO and also sets the GPIO value via gpio_set_value right after. This is not needed.

By using gpio_request_one it is possible to set the direction and initial value in one shot.

---
 arch/arm/mach-mx5/board-mx53_evk.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
arch/arm/mach-mx5/board-mx53_evk.c +2 -3
index 7b5735c..8ca55c0 100644
@@ -82,13 +82,12 @@ static inline void mx53_evk_fec_reset(void)
 	int ret;
 
 	/* reset FEC PHY */
-	ret = gpio_request(SMD_FEC_PHY_RST, "fec-phy-reset");
+	ret = gpio_request_one(SMD_FEC_PHY_RST, GPIOF_OUT_INIT_LOW,
+							"fec-phy-reset");
 	if (ret) {
 		printk(KERN_ERR"failed to get GPIO_FEC_PHY_RESET: %d\n", ret);
 		return;
 	}
-	gpio_direction_output(SMD_FEC_PHY_RST, 0);
-	gpio_set_value(SMD_FEC_PHY_RST, 0);
 	msleep(1);
 	gpio_set_value(SMD_FEC_PHY_RST, 1);
 }
Signature · 1 line
1.6.0.4
#3 lore raw

PATCH 4/4 ARM: mx5/mx53_evk: Make the reset pin name more meaningful

As there is a mx53_smd board in the kernel, using SMD_FEC_PHY_RST as the pin name can be misleading when used on a MX53_EVK board.

Change the pin name to reflect the board name.

---
 arch/arm/mach-mx5/board-mx53_evk.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-mx5/board-mx53_evk.c +3 -3
index d771999..2af3f43 100644
@@ -34,7 +34,7 @@
 #include <mach/imx-uart.h>
 #include <mach/iomux-mx53.h>
 
-#define SMD_FEC_PHY_RST		IMX_GPIO_NR(7, 6)
+#define MX53_EVK_FEC_PHY_RST	IMX_GPIO_NR(7, 6)
 #define EVK_ECSPI1_CS0		IMX_GPIO_NR(2, 30)
 #define EVK_ECSPI1_CS1		IMX_GPIO_NR(3, 19)
 
@@ -82,14 +82,14 @@ static inline void mx53_evk_fec_reset(void)
 	int ret;
 
 	/* reset FEC PHY */
-	ret = gpio_request_one(SMD_FEC_PHY_RST, GPIOF_OUT_INIT_LOW,
+	ret = gpio_request_one(MX53_EVK_FEC_PHY_RST, GPIOF_OUT_INIT_LOW,
 							"fec-phy-reset");
 	if (ret) {
 		printk(KERN_ERR"failed to get GPIO_FEC_PHY_RESET: %d\n", ret);
 		return;
 	}
 	msleep(1);
-	gpio_set_value(SMD_FEC_PHY_RST, 1);
+	gpio_set_value(MX53_EVK_FEC_PHY_RST, 1);
 }
 
 static struct fec_platform_data mx53_evk_fec_pdata = {
Signature · 1 line
1.6.0.4
#4 lore raw

PATCH 2/4 ARM: mx5/babbage: Use gpio_request_one in babbage_usbhub_reset

In reply to Fabio Estevam

Hello Fabio,

Quoted 24 lines · Fabio Estevam

Current code inside babbage_usbhub_reset uses gpio_direction_output with initial value of the GPIO and also sets the GPIO value via gpio_set_value to the same level right after. This is not needed.

By using gpio_request_one it is possible to set the direction and initial value in one shot.

---
 arch/arm/mach-mx5/board-mx51_babbage.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
arch/arm/mach-mx5/board-mx51_babbage.c +2 -1
index ff79395..cba8307 100644
@@ -209,17 +209,14 @@ static inline void babbage_usbhub_reset(void)
 	int ret;
 
 	/* Bring USB hub out of reset */
-	ret = gpio_request(BABBAGE_USB_HUB_RESET, "GPIO1_7");
+	ret = gpio_request_one(BABBAGE_USB_HUB_RESET, 
+					GPIOF_OUT_INIT_LOW, "GPIO1_7");
 	if (ret) {
 		printk(KERN_ERR"failed to get GPIO_USB_HUB_RESET: %d\n", ret);
 		return;

arch/arm/mach-mx5/board-mx51_babbage.c static inline void babbage_usbhub_reset(void) · line 221

Quoted 10 lines
arch/arm/mach-mx5/board-mx51_babbage.c +1 -5
 	}
-	gpio_direction_output(BABBAGE_USB_HUB_RESET, 0);
 
-	/* USB HUB RESET - De-assert USB HUB RESET_N */
-	msleep(1);
-	gpio_set_value(BABBAGE_USB_HUB_RESET, 0);
-	msleep(1);
+	msleep(2);
 	gpio_set_value(BABBAGE_USB_HUB_RESET, 1);
 }

I think the first comment ("Bring USB hub out of reset") is wrong, shouldn't it be:

	/* reset USB hub */
	ret = gpio_request_one(BABBAGE_USB_HUB_RESET, ...
	if (ret)
		...
	msleep(2);
	/* deassert reset */
	gpio_set_value(BABBAGE_USB_HUB_RESET, 1);

because "bring out of reset" is only the set_value(.., 1);?

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#5 lore raw

PATCH 1/4 ARM: mx5/babbage: Use gpio_request_one in babbage_fec_reset

In reply to Fabio Estevam
Quoted 6 lines · Fabio Estevam

Current code inside babbage_fec_reset uses gpio_direction_output with initial value of the GPIO and also sets the GPIO value via gpio_set_value to the same level right after. This is not needed.

By using gpio_request_one it is possible to set the direction and initial value in one shot.

1, 3 and 4 in this series.

Thanks
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |