[PATCH v2 06/10] eukrea_cpuimx25&35: use switch action to launch usbserial or dfu

Eric Bénard eric at eukrea.com
Fri May 18 03:41:41 EDT 2012


Signed-off-by: Eric Bénard <eric at eukrea.com>
---
 arch/arm/boards/eukrea_cpuimx25/env/bin/init_board |   21 ++++++++++++++++++++
 arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c  |    7 ++++++
 arch/arm/boards/eukrea_cpuimx35/env/bin/init_board |   21 ++++++++++++++++++++
 arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c  |   10 +++++++-
 4 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boards/eukrea_cpuimx25/env/bin/init_board b/arch/arm/boards/eukrea_cpuimx25/env/bin/init_board
index 2199b88..ff3365d 100644
--- a/arch/arm/boards/eukrea_cpuimx25/env/bin/init_board
+++ b/arch/arm/boards/eukrea_cpuimx25/env/bin/init_board
@@ -9,6 +9,27 @@ elif [ -f /env/logo.bmp.lzo ]; then
 	fb0.enable=1
 fi
 
+gpio_get_value 82
+if [ $? -eq 0 ]; then
+	gpio_set_value 83 0
+	usbserial
+	timeout -s -a 2
+	gpio_get_value 82
+	if [ $? -eq 0 ]; then
+		usbserial -d
+		dfu -V 0x1234 -P 0x1234 /dev/nand0.barebox.bb(barebox)sr,/dev/nand0.kernel.bb(kernel)r,/dev/nand0.root.bb(root)r
+		gpio_get_value 82
+		if [ $? -eq 0 ]; then
+			usbserial
+			autoboot_timeout=60
+		else
+			reset
+		fi
+	else
+		autoboot_timeout=28
+	fi
+fi
+
 if [ -z $eth0.ethaddr ]; then
 	while [ -z $eth0.ethaddr ]; do
 		readline "no MAC address set for eth0. please enter the one found on your board: " eth0.ethaddr
diff --git a/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c b/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
index 75a99f7..07a8bc0 100644
--- a/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
+++ b/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
@@ -216,6 +216,8 @@ static struct pad_desc eukrea_cpuimx25_pads[] = {
 	MX25_PAD_SD1_DATA3__SD1_DATA3,
 	/* LED */
 	MX25_PAD_POWER_FAIL__GPIO_3_19,
+	/* SWITCH */
+	MX25_PAD_VSTBY_ACK__GPIO_3_18,
 };
 
 static int eukrea_cpuimx25_devices_init(void)
@@ -246,6 +248,9 @@ static int eukrea_cpuimx25_devices_init(void)
 	/* LED : default OFF */
 	gpio_direction_output(2 * 32 + 19, 1);
 
+	/* Switch : input */
+	gpio_direction_input(2 * 32 + 18);
+
 	imx25_add_fb(&eukrea_cpuimx25_fb_data);
 
 	imx25_add_i2c0(NULL);
@@ -255,10 +260,12 @@ static int eukrea_cpuimx25_devices_init(void)
 	imx25_usb_init();
 	add_generic_usb_ehci_device(-1, IMX_OTG_BASE + 0x400, NULL);
 #endif
+#ifdef CONFIG_USB_GADGET
 	/* Workaround ENGcm09152 */
 	writel(readl(IMX_OTG_BASE + 0x608) | (1 << 23), IMX_OTG_BASE + 0x608);
 	add_generic_device("fsl-udc", -1, NULL, IMX_OTG_BASE, 0x200,
 			   IORESOURCE_MEM, &usb_pdata);
+#endif
 
 	armlinux_set_bootparams((void *)0x80000100);
 	armlinux_set_architecture(MACH_TYPE_EUKREA_CPUIMX25SD);
diff --git a/arch/arm/boards/eukrea_cpuimx35/env/bin/init_board b/arch/arm/boards/eukrea_cpuimx35/env/bin/init_board
index cb624e5..89fd9a9 100644
--- a/arch/arm/boards/eukrea_cpuimx35/env/bin/init_board
+++ b/arch/arm/boards/eukrea_cpuimx35/env/bin/init_board
@@ -11,6 +11,27 @@ elif [ -f /env/logo.bmp.lzo ]; then
 	gpio_set_value 1 1
 fi
 
+gpio_get_value 89
+if [ $? -eq 0 ]; then
+	gpio_set_value 93 0
+	usbserial
+	timeout -s -a 2
+	gpio_get_value 89
+	if [ $? -eq 0 ]; then
+		usbserial -d
+		dfu -V 0x1234 -P 0x1234 /dev/nand0.barebox.bb(barebox)sr,/dev/nand0.kernel.bb(kernel)r,/dev/nand0.root.bb(root)r
+		gpio_get_value 89
+		if [ $? -eq 0 ]; then
+			usbserial
+			autoboot_timeout=60
+		else
+			reset
+		fi
+	else
+		autoboot_timeout=28
+	fi
+fi
+
 if [ -z $eth0.ethaddr ]; then
 	while [ -z $eth0.ethaddr ]; do
 		readline "no MAC address set for eth0. please enter the one found on your board: " eth0.ethaddr
diff --git a/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c b/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
index 17da569..bfdd9de 100644
--- a/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
+++ b/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
@@ -161,6 +161,12 @@ static int eukrea_cpuimx35_devices_init(void)
 	imx35_add_i2c0(NULL);
 	imx35_add_mmc0(NULL);
 
+	/* led default off */
+	gpio_direction_output(32 * 2 + 29, 1);
+
+	/* Switch : input */
+	gpio_direction_input(32 * 2 + 25);
+
 #ifdef CONFIG_USB
 	imx35_usb_init();
 	add_generic_usb_ehci_device(-1, IMX_OTG_BASE + 0x400, NULL);
@@ -220,6 +226,8 @@ static struct pad_desc eukrea_cpuimx35_pads[] = {
 	MX35_PAD_SD1_DATA1__ESDHC1_DAT1,
 	MX35_PAD_SD1_DATA2__ESDHC1_DAT2,
 	MX35_PAD_SD1_DATA3__ESDHC1_DAT3,
+
+	MX35_PAD_LD19__GPIO3_25,
 };
 
 static int eukrea_cpuimx35_console_init(void)
@@ -231,8 +239,6 @@ static int eukrea_cpuimx35_console_init(void)
 	gpio_direction_output(4, 0);
 	/* backlight default off */
 	gpio_direction_output(1, 0);
-	/* led default off */
-	gpio_direction_output(32 * 2 + 29, 1);
 
 	imx35_add_uart0();
 	return 0;
-- 
1.7.7.6




More information about the barebox mailing list