usb/gadget: add the fastboot gadget

This patch contains an implementation of the fastboot protocol on the
device side and a little of documentation.
The gadget expects the new-style gadget framework.
The gadget implements the getvar, reboot, download and reboot commands.
What is missing is the flash handling i.e. writting the image to media.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy at linutronix.de>

From u-boot mailing list:
http://lists.denx.de/pipermail/u-boot/2011-September/101557.html

Change-Id: Ic797f498f0f7547d0daa7fd4e3c7215b7d01b487
usb/gadget: fastboot: build fixes for u-boot 2013

* add speed parameter for fastboot gadget
* use usb_gadget_connect/disconnect instead of udc_init/udc_exit
* change #if CONFIG_CMD_FASTBOOT to #ifdef CONFIG_CMD_FASTBOOT
* a couple of build fixes

Change-Id: Id6393aefa329f9ea67376a55e68017c8fcbb1fa5
Signed-off-by: Vishveshwar Bhat <vishveshwar.bhat@ti.com>
fastboot: implement fastboot_board_init

Initial implementation for AM335xevm

Some values are hard-coded. Ultimately these would be moved
to the board-specific config file.

Change-Id: Id2cf27986558db8855fb1362e37c01d0b261b885
Signed-off-by: Vishveshwar Bhat <vishveshwar.bhat@ti.com>
usb/gadget: fastboot: do not hardcode VID/PID

These will be defined in the board config.

Change-Id: I73d7b64bd321b7f25789e53d7d7ec095d5962ca6
Signed-off-by: Vishveshwar Bhat <vishveshwar.bhat@ti.com>
FASTBOOT: add SD/MMC/eMMC flashing support

This patch adds the fastboot SD/MMC/eMMC flashing support.

Commands:
fastboot oem format
fastboot flash <partition> <image>

Change-Id: Ic96769cc6441e1ea7cb5a2b3559e3e0d7d5c6ac8
Signed-off-by: Pankaj Bharadiya <pankaj.bharadiya@ti.com>
FASTBOOT: Fix fastboot hang issue

Looks like there is a race condition while sending a response for download completion
and receiving new flash command from host. These Tx and Rx operations are getting handled
in same irq handler and Rx queue operations are getting deleted before processing.
Because of this u-boot crashes while sending next response

Re-arrange the Response call to Fix this issue.
Note: This is a hacked approach. proper fix need to be identified.

Change-Id: Ib0768e7379345c9398897bbc06302f2c7314980a
Signed-off-by: Pankaj Bharadiya <pankaj.bharadiya@ti.com>
FASTBOOT: null terminate received command string

Change-Id: Iaa19c1286f2a3674925ae899542748d4723fc3b9
Signed-off-by: Pankaj Bharadiya <pankaj.bharadiya@ti.com>
FASTBOOT: move fastboot transfer buffer size to board config file

Makes this customizable for different boards.

Change-Id: I700919d5060f3a9e977486bbb1d4d5dd8df7db4a
Signed-off-by: Vishveshwar Bhat <vishveshwar.bhat@ti.com>
FASTBOOT: handle emmc flashing in seperate function

Change-Id: I9c5e41754d3de79e95770cfeac05aaa76058d19f
Signed-off-by: Pankaj Bharadiya <pankaj.bharadiya@ti.com>
FASTBOOT: move global variables to fb config struct

Change-Id: Id67bb10f5adf3767e6509da79cbe2a2f63325296
Signed-off-by: Pankaj Bharadiya <pankaj.bharadiya@ti.com>
FASTBOOT: handle mmc related operations in seperate file

Separate flashing logic from fastboot from core fastboot logic

Change-Id: Ib16209c65d7604dc0754a42a948e4260fa4293a3
Signed-off-by: Pankaj Bharadiya <pankaj.bharadiya@ti.com>
FASTBOOT: Add nand flashing support

Nand flashing support will be enabled if CONFIG_FASTBOOT_NAND is
defined otherwise by default mmc flashing will get enabled.

Change-Id: If603135b2e10cb2d0b8dd4dcb0fa47d9fd985eb3
Signed-off-by: Pankaj Bharadiya <pankaj.bharadiya@ti.com>
FASTBOOT: update copyrights

Change-Id: I7558494d453307e6b6de2c88653bd13026bee7d6
Signed-off-by: Pankaj Bharadiya <pankaj.bharadiya@ti.com>
FASTBOOT: Add option to select mmc device

Change-Id: I31e081cc152524d5687913047db4367c7df2e05a
Signed-off-by: Pankaj Bharadiya <pankaj.bharadiya@ti.com>
Add Support for MMC0 and MMC1 eMMC raw boot

This patch adds booti boot command support for MMC raw boot.
Set CONFIG_MMC_FASTBOOT_DEV macro to 0 or 1 to select MMC0 or MMC1 device
respectively

Change-Id: I8750383351af1b4ccbb077ca886d0e7a7fd4908b
Signed-off-by: Pankaj Bharadiya <pankaj.bharadiya@ti.com>
FASTBOOT: make the vendor ID configurable

Signed-off-by: Max Liao <liaops@embedinfo.com>
FASTBOOT: WIP: temp solution for runtime issues

This patch uses following temp solution for fastboot runtime issues:
  - won't check usb_gadget_connect() return value.
  - won't set gadget_is_connected to false.
  - using 125us delay for stuck issue.

Signed-off-by: Max Liao <liaops@embedinfo.com>
FASTBOOT: add support to check fastboot mode

Check whether need to execute fastboot when system booting.

Signed-off-by: Max Liao <liaops@embedinfo.com>
FASTBOOT: add more nand option

This patch implement the following functions:
  - ECC configuration option for TI OMAP SoCs.
  - Save environment option for TI OMAP SoCs.
  - Add nand write with trimffs option support.
  - Add option to disable nand flash partition to be written.

Signed-off-by: Max Liao <liaops@embedinfo.com>
FASTBOOT: add nand partition table for Atmel EK

Signed-off-by: Max Liao <liaops@embedinfo.com>