Commit 16297cfb authored by Mateusz Zalega's avatar Mateusz Zalega Committed by Marek Vasut

usb: new board-specific USB init interface

This commit unifies board-specific USB initialization implementations
under one symbol (usb_board_init), declaration of which is available in
usb.h.

New API allows selective initialization of USB controllers whenever needed.
Signed-off-by: default avatarMateusz Zalega <m.zalega@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: default avatarLukasz Majewski <l.majewski@samsung.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Lukasz Majewski <l.majewski@samsung.com>
parent f3d7cff5
...@@ -131,8 +131,7 @@ ...@@ -131,8 +131,7 @@
/* USB3_IF_USB_PHY_VBUS_SENSORS_0 */ /* USB3_IF_USB_PHY_VBUS_SENSORS_0 */
#define VBUS_VLD_STS (1 << 26) #define VBUS_VLD_STS (1 << 26)
/* Setup USB on the board */ /* Setup USB on the board */
int board_usb_init(const void *blob); int usb_process_devicetree(const void *blob);
#endif /* _TEGRA_USB_H_ */ #endif /* _TEGRA_USB_H_ */
...@@ -145,8 +145,8 @@ struct omap_ehci { ...@@ -145,8 +145,8 @@ struct omap_ehci {
struct ehci_hccr; struct ehci_hccr;
struct ehci_hcor; struct ehci_hcor;
int omap_ehci_hcd_init(struct omap_usbhs_board_data *usbhs_pdata, int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata,
struct ehci_hccr **hccr, struct ehci_hcor **hcor); struct ehci_hccr **hccr, struct ehci_hcor **hcor);
int omap_ehci_hcd_stop(void); int omap_ehci_hcd_stop(void);
#endif /* _OMAP_COMMON_EHCI_H_ */ #endif /* _OMAP_COMMON_EHCI_H_ */
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <asm/4xx_pcie.h> #include <asm/4xx_pcie.h>
#include <asm/ppc4xx-gpio.h> #include <asm/ppc4xx-gpio.h>
#include <asm/errno.h> #include <asm/errno.h>
#include <usb.h>
extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */ extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */
...@@ -188,7 +189,7 @@ int board_early_init_f(void) ...@@ -188,7 +189,7 @@ int board_early_init_f(void)
} }
#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT) #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT)
int usb_board_init(void) int board_usb_init(int index, enum board_usb_init_type init)
{ {
struct board_bcsr *bcsr_data = struct board_bcsr *bcsr_data =
(struct board_bcsr *)CONFIG_SYS_BCSR_BASE; (struct board_bcsr *)CONFIG_SYS_BCSR_BASE;
...@@ -229,7 +230,7 @@ int usb_board_stop(void) ...@@ -229,7 +230,7 @@ int usb_board_stop(void)
return 0; return 0;
} }
int usb_board_init_fail(void) int board_usb_cleanup(int index, enum board_usb_init_type init)
{ {
return usb_board_stop(); return usb_board_stop();
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <asm/io.h> #include <asm/io.h>
#include <spartan3.h> #include <spartan3.h>
#include <command.h> #include <command.h>
#include <usb.h>
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -59,7 +60,7 @@ void dram_init_banksize(void) ...@@ -59,7 +60,7 @@ void dram_init_banksize(void)
} }
#ifdef CONFIG_CMD_USB #ifdef CONFIG_CMD_USB
int usb_board_init(void) int board_usb_init(int index, enum board_usb_init_type init)
{ {
writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) & writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) &
~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE), ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE),
...@@ -90,9 +91,9 @@ int usb_board_init(void) ...@@ -90,9 +91,9 @@ int usb_board_init(void)
return 0; return 0;
} }
void usb_board_init_fail(void) int board_usb_cleanup(int index, enum board_usb_init_type init)
{ {
return; return 0;
} }
void usb_board_stop(void) void usb_board_stop(void)
......
...@@ -591,7 +591,7 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) ...@@ -591,7 +591,7 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, offset, 0xC0); twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, offset, 0xC0);
udelay(1); udelay(1);
return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor); return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
} }
int ehci_hcd_stop(void) int ehci_hcd_stop(void)
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <mtd/cfi_flash.h> #include <mtd/cfi_flash.h>
#include <asm/4xx_pci.h> #include <asm/4xx_pci.h>
#include <pci.h> #include <pci.h>
#include <usb.h>
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -428,7 +429,7 @@ void reset_phy(void) ...@@ -428,7 +429,7 @@ void reset_phy(void)
} }
#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT) #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT)
int usb_board_init(void) int board_usb_init(int index, enum board_usb_init_type init)
{ {
return 0; return 0;
} }
...@@ -453,9 +454,8 @@ int usb_board_stop(void) ...@@ -453,9 +454,8 @@ int usb_board_stop(void)
return 0; return 0;
} }
int usb_board_init_fail(void) int board_usb_cleanup(int index, enum board_usb_init_type init)
{ {
usb_board_stop(); return usb_board_stop();
return 0;
} }
#endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT) */ #endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT) */
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#endif #endif
#include <serial.h> #include <serial.h>
#include <asm/4xx_pci.h> #include <asm/4xx_pci.h>
#include <usb.h>
#include "fpga.h" #include "fpga.h"
#include "pmc440.h" #include "pmc440.h"
...@@ -821,7 +822,7 @@ int bootstrap_eeprom_read (unsigned dev_addr, unsigned offset, ...@@ -821,7 +822,7 @@ int bootstrap_eeprom_read (unsigned dev_addr, unsigned offset,
} }
#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT) #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT)
int usb_board_init(void) int board_usb_init(int index, enum board_usb_init_type init)
{ {
char *act = getenv("usbact"); char *act = getenv("usbact");
int i; int i;
...@@ -845,10 +846,9 @@ int usb_board_stop(void) ...@@ -845,10 +846,9 @@ int usb_board_stop(void)
return 0; return 0;
} }
int usb_board_init_fail(void) int board_usb_cleanup(int index, enum board_usb_init_type init)
{ {
usb_board_stop(); return usb_board_stop();
return 0;
} }
#endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT) */ #endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT) */
......
...@@ -42,7 +42,7 @@ static struct omap_usbhs_board_data usbhs_bdata = { ...@@ -42,7 +42,7 @@ static struct omap_usbhs_board_data usbhs_bdata = {
int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
{ {
return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor); return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
} }
int ehci_hcd_stop(int index) int ehci_hcd_stop(int index)
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <netdev.h> #include <netdev.h>
#include <serial.h> #include <serial.h>
#include <asm/io.h> #include <asm/io.h>
#include <usb.h>
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -58,7 +59,7 @@ int board_mmc_init(bd_t *bis) ...@@ -58,7 +59,7 @@ int board_mmc_init(bd_t *bis)
#endif #endif
#ifdef CONFIG_CMD_USB #ifdef CONFIG_CMD_USB
int usb_board_init(void) int board_usb_init(int index, enum board_usb_init_type init)
{ {
writel((UHCHR | UHCHR_PCPL | UHCHR_PSPL) & writel((UHCHR | UHCHR_PCPL | UHCHR_PSPL) &
~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE), ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE),
...@@ -89,9 +90,9 @@ int usb_board_init(void) ...@@ -89,9 +90,9 @@ int usb_board_init(void)
return 0; return 0;
} }
void usb_board_init_fail(void) int board_usb_cleanup(int index, enum board_usb_init_type init)
{ {
return; return 0;
} }
void usb_board_stop(void) void usb_board_stop(void)
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#ifdef CONFIG_USB_EHCI_TEGRA #ifdef CONFIG_USB_EHCI_TEGRA
#include <asm/arch-tegra/usb.h> #include <asm/arch-tegra/usb.h>
#include <asm/arch/usb.h> #include <asm/arch/usb.h>
#include <usb.h>
#endif #endif
#ifdef CONFIG_TEGRA_MMC #ifdef CONFIG_TEGRA_MMC
#include <asm/arch-tegra/tegra_mmc.h> #include <asm/arch-tegra/tegra_mmc.h>
...@@ -153,8 +154,9 @@ int board_init(void) ...@@ -153,8 +154,9 @@ int board_init(void)
#ifdef CONFIG_USB_EHCI_TEGRA #ifdef CONFIG_USB_EHCI_TEGRA
pin_mux_usb(); pin_mux_usb();
board_usb_init(gd->fdt_blob); usb_process_devicetree(gd->fdt_blob);
#endif #endif
#ifdef CONFIG_LCD #ifdef CONFIG_LCD
tegra_lcd_check_next_stage(gd->fdt_blob, 0); tegra_lcd_check_next_stage(gd->fdt_blob, 0);
#endif #endif
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <power/max8997_muic.h> #include <power/max8997_muic.h>
#include <power/battery.h> #include <power/battery.h>
#include <power/max17042_fg.h> #include <power/max17042_fg.h>
#include <usb.h>
#include <usb_mass_storage.h> #include <usb_mass_storage.h>
#include "setup.h" #include "setup.h"
...@@ -495,10 +496,10 @@ struct s3c_plat_otg_data s5pc210_otg_data = { ...@@ -495,10 +496,10 @@ struct s3c_plat_otg_data s5pc210_otg_data = {
.usb_flags = PHY0_SLEEP, .usb_flags = PHY0_SLEEP,
}; };
void board_usb_init(void) int board_usb_init(int index, enum board_usb_init_type init)
{ {
debug("USB_udc_probe\n"); debug("USB_udc_probe\n");
s3c_udc_probe(&s5pc210_otg_data); return s3c_udc_probe(&s5pc210_otg_data);
} }
#endif #endif
......
...@@ -53,7 +53,7 @@ static struct omap_usbhs_board_data usbhs_bdata = { ...@@ -53,7 +53,7 @@ static struct omap_usbhs_board_data usbhs_bdata = {
int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
{ {
return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor); return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
} }
int ehci_hcd_stop(int index) int ehci_hcd_stop(int index)
......
...@@ -104,7 +104,7 @@ static struct omap_usbhs_board_data usbhs_bdata = { ...@@ -104,7 +104,7 @@ static struct omap_usbhs_board_data usbhs_bdata = {
int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
{ {
return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor); return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
} }
int ehci_hcd_stop(int index) int ehci_hcd_stop(int index)
......
...@@ -523,7 +523,7 @@ static struct omap_usbhs_board_data usbhs_bdata = { ...@@ -523,7 +523,7 @@ static struct omap_usbhs_board_data usbhs_bdata = {
int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
{ {
return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor); return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
} }
int ehci_hcd_stop(int index) int ehci_hcd_stop(int index)
......
...@@ -184,7 +184,7 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) ...@@ -184,7 +184,7 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
eth_setenv_enetaddr("usbethaddr", device_mac); eth_setenv_enetaddr("usbethaddr", device_mac);
} }
ret = omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor); ret = omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
if (ret < 0) { if (ret < 0) {
puts("Failed to initialize ehci\n"); puts("Failed to initialize ehci\n");
return ret; return ret;
......
...@@ -279,7 +279,7 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) ...@@ -279,7 +279,7 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
utmi_clk |= HSUSBHOST_CLKCTRL_CLKSEL_UTMI_P1_MASK; utmi_clk |= HSUSBHOST_CLKCTRL_CLKSEL_UTMI_P1_MASK;
sr32((void *)CM_L3INIT_HSUSBHOST_CLKCTRL, 0, 32, utmi_clk); sr32((void *)CM_L3INIT_HSUSBHOST_CLKCTRL, 0, 32, utmi_clk);
ret = omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor); ret = omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <netdev.h> #include <netdev.h>
#include <asm/io.h> #include <asm/io.h>
#include <serial.h> #include <serial.h>
#include <usb.h>
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -39,7 +40,7 @@ int dram_init(void) ...@@ -39,7 +40,7 @@ int dram_init(void)
} }
#ifdef CONFIG_CMD_USB #ifdef CONFIG_CMD_USB
int usb_board_init(void) int board_usb_init(int index, enum board_usb_init_type init)
{ {
writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) & writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) &
~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE), ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE),
...@@ -70,9 +71,9 @@ int usb_board_init(void) ...@@ -70,9 +71,9 @@ int usb_board_init(void)
return 0; return 0;
} }
void usb_board_init_fail(void) int board_usb_cleanup(int index, enum board_usb_init_type init)
{ {
return; return 0;
} }
void usb_board_stop(void) void usb_board_stop(void)
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <asm/arch/regs-mmc.h> #include <asm/arch/regs-mmc.h>
#include <netdev.h> #include <netdev.h>
#include <asm/io.h> #include <asm/io.h>
#include <usb.h>
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -42,7 +43,7 @@ extern struct serial_device serial_stuart_device; ...@@ -42,7 +43,7 @@ extern struct serial_device serial_stuart_device;
* Miscelaneous platform dependent initialisations * Miscelaneous platform dependent initialisations
*/ */
int usb_board_init(void) int board_usb_init(int index, enum board_usb_init_type init)
{ {
writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) & writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) &
~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE), ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE),
...@@ -69,9 +70,9 @@ int usb_board_init(void) ...@@ -69,9 +70,9 @@ int usb_board_init(void)
return 0; return 0;
} }
void usb_board_init_fail(void) int board_usb_cleanup(int index, enum board_usb_init_type init)
{ {
return; return 0;
} }
void usb_board_stop(void) void usb_board_stop(void)
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <netdev.h> #include <netdev.h>
#include <serial.h> #include <serial.h>
#include <asm/io.h> #include <asm/io.h>
#include <usb.h>
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -66,7 +67,7 @@ int board_mmc_init(bd_t *bis) ...@@ -66,7 +67,7 @@ int board_mmc_init(bd_t *bis)
#endif #endif
#ifdef CONFIG_CMD_USB #ifdef CONFIG_CMD_USB
int usb_board_init(void) int board_usb_init(int index, enum board_usb_init_type init)
{ {
writel((UHCHR | UHCHR_PCPL | UHCHR_PSPL) & writel((UHCHR | UHCHR_PCPL | UHCHR_PSPL) &
~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE), ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE),
...@@ -97,9 +98,9 @@ int usb_board_init(void) ...@@ -97,9 +98,9 @@ int usb_board_init(void)
return 0; return 0;
} }
void usb_board_init_fail(void) int board_usb_cleanup(int index, enum board_usb_init_type init)
{ {
return; return 0;
} }
void usb_board_stop(void) void usb_board_stop(void)
......
...@@ -11,27 +11,32 @@ ...@@ -11,27 +11,32 @@
#include <common.h> #include <common.h>
#include <dfu.h> #include <dfu.h>
#include <g_dnl.h> #include <g_dnl.h>
#include <usb.h>
static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{ {
if (argc < 4)
return CMD_RET_USAGE;
char *usb_controller = argv[1];
char *interface = argv[2];
char *devstring = argv[3];
char *s = "dfu"; char *s = "dfu";
int ret, i = 0; int ret, i = 0;
if (argc < 3) ret = dfu_init_env_entities(interface, simple_strtoul(devstring,
return CMD_RET_USAGE; NULL, 10));
ret = dfu_init_env_entities(argv[1], simple_strtoul(argv[2], NULL, 10));
if (ret) if (ret)
return ret; return ret;
if (argc > 3 && strcmp(argv[3], "list") == 0) { if (argc > 4 && strcmp(argv[4], "list") == 0) {
dfu_show_entities(); dfu_show_entities();
goto done; goto done;
} }
#ifdef CONFIG_TRATS int controller_index = simple_strtoul(usb_controller, NULL, 0);
board_usb_init(); board_usb_init(controller_index, USB_INIT_DEVICE);
#endif
g_dnl_register(s); g_dnl_register(s);
while (1) { while (1) {
...@@ -62,8 +67,9 @@ done: ...@@ -62,8 +67,9 @@ done:
U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu, U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
"Device Firmware Upgrade", "Device Firmware Upgrade",
"<interface> <dev> [list]\n" "<USB_controller> <interface> <dev> [list]\n"
" - device firmware upgrade on a device <dev>\n" " - device firmware upgrade via <USB_controller>\n"
" attached to interface <interface>\n" " on device <dev>, attached to interface\n"
" [list] - list available alt settings" " <interface>\n"
" [list] - list available alt settings\n"
); );
...@@ -8,51 +8,53 @@ ...@@ -8,51 +8,53 @@
#include <common.h> #include <common.h>
#include <command.h> #include <command.h>
#include <g_dnl.h> #include <g_dnl.h>
#include <usb.h>
#include <usb_mass_storage.h> #include <usb_mass_storage.h>
int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag, int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
int argc, char * const argv[]) int argc, char * const argv[])
{ {
char *ep; if (argc < 3)
unsigned int dev_num = 0, offset = 0, part_size = 0; return CMD_RET_USAGE;
int rc;
struct ums_board_info *ums_info; const char *usb_controller = argv[1];
static char *s = "ums"; const char *mmc_devstring = argv[2];
if (argc < 2) {
printf("usage: ums <dev> - e.g. ums 0\n");
return 0;
}
dev_num = (int)simple_strtoul(argv[1], &ep, 16);
unsigned int dev_num = (unsigned int)(simple_strtoul(mmc_devstring,
NULL, 0));
if (dev_num) { if (dev_num) {
puts("\nSet eMMC device to 0! - e.g. ums 0\n"); error("Set eMMC device to 0! - e.g. ums 0");
goto fail; goto fail;
} }
board_usb_init(); unsigned int controller_index = (unsigned int)(simple_strtoul(
ums_info = board_ums_init(dev_num, offset, part_size); usb_controller, NULL, 0));
if (board_usb_init(controller_index, USB_INIT_DEVICE)) {
error("Couldn't init USB controller.");
goto fail;
}
struct ums_board_info *ums_info = board_ums_init(dev_num, 0, 0);
if (!ums_info) { if (!ums_info) {
printf("MMC: %d -> NOT available\n", dev_num); error("MMC: %d -> NOT available", dev_num);
goto fail; goto fail;
} }
rc = fsg_init(ums_info);
int rc = fsg_init(ums_info);
if (rc) { if (rc) {
printf("cmd ums: fsg_init failed\n"); error("fsg_init failed");
goto fail; goto fail;
} }
g_dnl_register(s); g_dnl_register("ums");
while (1) { while (1) {
/* Handle control-c and timeouts */ /* Handle control-c and timeouts */
if (ctrlc()) { if (ctrlc()) {
printf("The remote end did not respond in time.\n"); error("The remote end did not respond in time.");
goto exit; goto exit;
} }
usb_gadget_handle_interrupts(); usb_gadget_handle_interrupts();
/* Check if USB cable has been detached */ /* Check if USB cable has been detached */
if (fsg_main_thread(NULL) == EIO) if (fsg_main_thread(NULL) == EIO)
...@@ -68,5 +70,5 @@ fail: ...@@ -68,5 +70,5 @@ fail:
U_BOOT_CMD(ums, CONFIG_SYS_MAXARGS, 1, do_usb_mass_storage, U_BOOT_CMD(ums, CONFIG_SYS_MAXARGS, 1, do_usb_mass_storage,
"Use the UMS [User Mass Storage]", "Use the UMS [User Mass Storage]",
"ums - User Mass Storage Gadget" "<USB_controller> <mmc_dev>"
); );
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/ctype.h> #include <linux/ctype.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
#include <compiler.h>
#include <usb.h> #include <usb.h>
#ifdef CONFIG_4xx #ifdef CONFIG_4xx
...@@ -1066,4 +1067,9 @@ int usb_new_device(struct usb_device *dev) ...@@ -1066,4 +1067,9 @@ int usb_new_device(struct usb_device *dev)
return 0; return 0;
} }
__weak
int board_usb_init(int index, enum board_usb_init_type init)
{
return 0;
}
/* EOF */ /* EOF */
...@@ -330,7 +330,7 @@ int dfu_read(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num) ...@@ -330,7 +330,7 @@ int dfu_read(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
}