mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 10/12] usb-a926x: add dfu support
Date: Sat, 31 Dec 2011 16:21:36 +0100	[thread overview]
Message-ID: <1325344898-7076-10-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <20111231151655.GB945@game.jcrosoft.org>

detect it at boot time

if the user button is pressed 5s and the vbus is 1 start the dfu

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/usb-a926x/env/bin/init_board |   43 ++++++++++++++++++++++++++
 arch/arm/boards/usb-a926x/init.c             |    9 +++++
 2 files changed, 52 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/boards/usb-a926x/env/bin/init_board

diff --git a/arch/arm/boards/usb-a926x/env/bin/init_board b/arch/arm/boards/usb-a926x/env/bin/init_board
new file mode 100644
index 0000000..77e5c1a
--- /dev/null
+++ b/arch/arm/boards/usb-a926x/env/bin/init_board
@@ -0,0 +1,43 @@
+#!/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"
+
+gpio_get_value ${dfu_button}
+if [ $? != 0 ]
+then
+	exit
+fi
+
+if [ $at91_udc0.vbus != 1 ]
+then
+	echo "No USB Device cable plugged, normal boot"
+	exit
+fi
+
+echo "${button_name} pressed detected wait ${button_wait}s"
+timeout -s -a ${button_wait}
+
+gpio_get_value ${dfu_button}
+if [ $? != 0 ]
+then
+	echo "${button_name} released, normal boot"
+	exit
+fi
+
+if [ $at91_udc0.vbus != 1 ]
+then
+	echo "No USB Device cable plugged, normal boot"
+	exit
+fi
+
+echo ""
+echo "Start DFU Mode"
+echo ""
+
+dfu ${dfu_config} -P ${product_id} -V ${vendor_id}
diff --git a/arch/arm/boards/usb-a926x/init.c b/arch/arm/boards/usb-a926x/init.c
index 469d98e..364c1ba 100644
--- a/arch/arm/boards/usb-a926x/init.c
+++ b/arch/arm/boards/usb-a926x/init.c
@@ -211,6 +211,14 @@ static int usb_a9260_mem_init(void)
 }
 mem_initcall(usb_a9260_mem_init);
 
+static void __init ek_add_device_button(void)
+{
+	at91_set_GPIO_periph(AT91_PIN_PB10, 1);	/* user push button, pull up enabled */
+	at91_set_deglitch(AT91_PIN_PB10, 1);
+
+	export_env_ull("dfu_button", AT91_PIN_PB10);
+}
+
 static int usb_a9260_devices_init(void)
 {
 	usb_a9260_add_device_nand();
@@ -220,6 +228,7 @@ static int usb_a9260_devices_init(void)
 	at91_add_device_usbh_ohci(&ek_usbh_data);
 	ek_add_device_udc();
 	ek_add_led();
+	ek_add_device_button();
 
 	armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
 	usb_a9260_set_board_type();
-- 
1.7.7


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2011-12-31 15:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-31 15:16 AT91: Pull Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 01/12] atmel: reference boards and Caloa boards bbt option enabled Jean-Christophe PLAGNIOL-VILLARD
2012-01-03  9:37   ` Sascha Hauer
2012-01-03 10:33     ` Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 02/12] ARM: import memcpy_from/toio and memset_io from linux Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 03/12] mtd: atmel_nand: optimize read/write buffer functions Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 04/12] atmel_nand: drop dead code Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 05/12] at91: add sram memory devices Jean-Christophe PLAGNIOL-VILLARD
2012-01-04 13:42   ` Sascha Hauer
2011-12-31 15:21 ` [PATCH 06/12] at91sam9263ek: add nor partition Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 07/12] at91sam9x: switch lowlevel init to c Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 08/12] at91/gpio: simplify resources Jean-Christophe PLAGNIOL-VILLARD
2012-01-04 13:40   ` Sascha Hauer
2012-01-04 18:01     ` Jean-Christophe PLAGNIOL-VILLARD
2012-01-04 18:05     ` Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 09/12] usb-a926x: add led support Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2011-12-31 15:21 ` [PATCH 11/12] at91_udc: update vbus param only if updated Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 12/12] usb-a926x: update defconfig Jean-Christophe PLAGNIOL-VILLARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1325344898-7076-10-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox