summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards/at91sam9263ek
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-02-27 01:55:38 +0800
committerJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-03-12 17:59:07 +0800
commita889694323f51359524c9306ba1403d076c24b08 (patch)
treea5b1c30d90e557279f8c5eb2c9fa0eb03d05d786 /arch/arm/boards/at91sam9263ek
parent14f301af8511d49880bf062732b244adfa5f1330 (diff)
downloadbarebox-a889694323f51359524c9306ba1403d076c24b08.tar.gz
barebox-a889694323f51359524c9306ba1403d076c24b08.tar.xz
at91sam9263ek: add dfu and usb serial support
if left_click 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/at91sam9263ek')
-rw-r--r--arch/arm/boards/at91sam9263ek/env/bin/init_board51
-rw-r--r--arch/arm/boards/at91sam9263ek/init.c29
2 files changed, 80 insertions, 0 deletions
diff --git a/arch/arm/boards/at91sam9263ek/env/bin/init_board b/arch/arm/boards/at91sam9263ek/env/bin/init_board
new file mode 100644
index 0000000000..ae2ac7d766
--- /dev/null
+++ b/arch/arm/boards/at91sam9263ek/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 ds2 1
+dfu ${dfu_config} -P ${product_id} -V ${vendor_id}
+led ds2 0
diff --git a/arch/arm/boards/at91sam9263ek/init.c b/arch/arm/boards/at91sam9263ek/init.c
index 42b38ba287..4a8d1678b6 100644
--- a/arch/arm/boards/at91sam9263ek/init.c
+++ b/arch/arm/boards/at91sam9263ek/init.c
@@ -137,6 +137,33 @@ static void ek_device_add_leds(void)
static void ek_device_add_leds(void) {}
#endif
+#if defined(CONFIG_USB_GADGET_DRIVER_AT91)
+/*
+ * USB Device port
+ */
+static struct at91_udc_data __initdata ek_udc_data = {
+ .vbus_pin = AT91_PIN_PA25,
+ .pullup_pin = -EINVAL, /* pull-up driven by UDC */
+};
+
+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_PC5, 1);
+ at91_set_deglitch(AT91_PIN_PC5, 1);
+ export_env_ull("dfu_button", AT91_PIN_PC5);
+ at91_set_gpio_input(AT91_PIN_PC4, 1);
+ at91_set_deglitch(AT91_PIN_PC4, 1);
+ export_env_ull("right_click", AT91_PIN_PC4);
+}
+
static int at91sam9263ek_mem_init(void)
{
at91_add_device_sdram(64 * 1024 * 1024);
@@ -160,6 +187,8 @@ static int at91sam9263ek_devices_init(void)
add_cfi_flash_device(0, AT91_CHIPSELECT_0, 8 * 1024 * 1024, 0);
ek_add_device_mci();
ek_device_add_leds();
+ ek_add_device_udc();
+ ek_add_device_buttons();
if (IS_ENABLED(CONFIG_DRIVER_CFI) && cdev_by_name("nor0")) {
devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self");