summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards/at91sam9261ek
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-03-01 15:58:56 +0800
committerJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-03-12 18:03:14 +0800
commit85f5d9645da5b759a1e1023571baf62a2783373c (patch)
tree89b674f5ad33d1a0436b18a4100eac0de53d58fb /arch/arm/boards/at91sam9261ek
parent2607cac17bf97fee6703e8d79a437fe242528266 (diff)
downloadbarebox-85f5d9645da5b759a1e1023571baf62a2783373c.tar.gz
barebox-85f5d9645da5b759a1e1023571baf62a2783373c.tar.xz
at91sam9261ek/9g10ek: add dfu and usb serial support
if bp3 is pressed 5s during boot enable dfu otherwise usbserial Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'arch/arm/boards/at91sam9261ek')
-rw-r--r--arch/arm/boards/at91sam9261ek/env/bin/init_board51
-rw-r--r--arch/arm/boards/at91sam9261ek/init.c26
2 files changed, 77 insertions, 0 deletions
diff --git a/arch/arm/boards/at91sam9261ek/env/bin/init_board b/arch/arm/boards/at91sam9261ek/env/bin/init_board
new file mode 100644
index 0000000000..a76a660aba
--- /dev/null
+++ b/arch/arm/boards/at91sam9261ek/env/bin/init_board
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+button_name="dfu_bp"
+button_wait=5
+
+product_id=0x1234
+vendor_id=0x4321
+
+dfu_config="/dev/nand0.barebox.bb(barebox)sr,/dev/nand0.kernel.bb(kernel)r,/dev/nand0.rootfs.bb(rootfs)r"
+
+if [ $at91_udc0.vbus != 1 ]
+then
+ echo "No USB Device cable plugged, normal boot"
+ exit
+fi
+
+gpio_get_value ${dfu_button}
+if [ $? != 0 ]
+then
+ autoboot_timeout=16
+ echo "enable tty over USB Device, increase the boot delay to ${autoboot_timeout}s"
+ usbserial
+ exit
+fi
+
+echo "${button_name} pressed detected wait ${button_wait}s"
+timeout -s -a ${button_wait}
+
+if [ $at91_udc0.vbus != 1 ]
+then
+ echo "No USB Device cable plugged, normal boot"
+ exit
+fi
+
+gpio_get_value ${dfu_button}
+if [ $? != 0 ]
+then
+ echo "${button_name} released, normal boot"
+ autoboot_timeout=16
+ echo "enable tty over USB Device, increase the boot delay to ${autoboot_timeout}s"
+ usbserial
+ exit
+fi
+
+echo ""
+echo "Start DFU Mode"
+echo ""
+
+led ds7 1
+dfu ${dfu_config} -P ${product_id} -V ${vendor_id}
+led ds7 0
diff --git a/arch/arm/boards/at91sam9261ek/init.c b/arch/arm/boards/at91sam9261ek/init.c
index 6327b59764..2952a76bfe 100644
--- a/arch/arm/boards/at91sam9261ek/init.c
+++ b/arch/arm/boards/at91sam9261ek/init.c
@@ -135,6 +135,30 @@ static void __init ek_add_device_dm9000(void)
static void __init ek_add_device_dm9000(void) {}
#endif /* CONFIG_DRIVER_NET_DM9K */
+#if defined(CONFIG_USB_GADGET_DRIVER_AT91)
+/*
+ * USB Device port
+ */
+static struct at91_udc_data __initdata ek_udc_data = {
+ .vbus_pin = AT91_PIN_PB29,
+ .pullup_pin = 0,
+};
+
+static void ek_add_device_udc(void)
+{
+ at91_add_device_udc(&ek_udc_data);
+}
+#else
+static void ek_add_device_udc(void) {}
+#endif
+
+static void __init ek_add_device_buttons(void)
+{
+ at91_set_gpio_input(AT91_PIN_PA27, 1);
+ at91_set_deglitch(AT91_PIN_PA27, 1);
+ export_env_ull("dfu_button", AT91_PIN_PA27);
+}
+
#ifdef CONFIG_LED_GPIO
struct gpio_led ek_leds[] = {
{
@@ -184,6 +208,8 @@ static int at91sam9261ek_devices_init(void)
ek_add_device_nand();
ek_add_device_dm9000();
+ ek_add_device_udc();
+ ek_add_device_buttons();
ek_device_add_leds();
devfs_add_partition("nand0", 0x00000, SZ_128K, PARTITION_FIXED, "at91bootstrap_raw");