summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2015-03-02 07:24:27 -0500
committerTom Rini <trini@konsulko.com>2015-03-02 07:24:27 -0500
commit57c6941b433722ab83a50dab35b8ab5a0954942a (patch)
treec1e785f490e844420407c6de8331bdc76df0817c /drivers/usb
parenta1b341989b241be6e308ec9328d2fbb08049c8f9 (diff)
parentc01c418717d718603e746fbc7885f76a5f8f73a5 (diff)
downloadu-boot-imx-57c6941b433722ab83a50dab35b8ab5a0954942a.zip
u-boot-imx-57c6941b433722ab83a50dab35b8ab5a0954942a.tar.gz
u-boot-imx-57c6941b433722ab83a50dab35b8ab5a0954942a.tar.bz2
Merge git://git.denx.de/u-boot-usb
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/f_fastboot.c83
-rw-r--r--drivers/usb/host/xhci-exynos5.c2
-rw-r--r--drivers/usb/musb-new/omap2430.c16
3 files changed, 95 insertions, 6 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 310175a..751ec9e 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -55,6 +55,7 @@ static inline struct f_fastboot *func_to_fastboot(struct usb_function *f)
static struct f_fastboot *fastboot_func;
static unsigned int download_size;
static unsigned int download_bytes;
+static bool is_high_speed;
static struct usb_endpoint_descriptor fs_ep_in = {
.bLength = USB_DT_ENDPOINT_SIZE,
@@ -136,6 +137,7 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f)
int id;
struct usb_gadget *gadget = c->cdev->gadget;
struct f_fastboot *f_fb = func_to_fastboot(f);
+ const char *s;
/* DYNAMIC interface numbers assignments */
id = usb_interface_id(c, f);
@@ -161,6 +163,10 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f)
hs_ep_out.bEndpointAddress = fs_ep_out.bEndpointAddress;
+ s = getenv("serial#");
+ if (s)
+ g_dnl_set_serialnumber((char *)s);
+
return 0;
}
@@ -219,10 +225,13 @@ static int fastboot_set_alt(struct usb_function *f,
__func__, f->name, interface, alt);
/* make sure we don't enable the ep twice */
- if (gadget->speed == USB_SPEED_HIGH)
+ if (gadget->speed == USB_SPEED_HIGH) {
ret = usb_ep_enable(f_fb->out_ep, &hs_ep_out);
- else
+ is_high_speed = true;
+ } else {
ret = usb_ep_enable(f_fb->out_ep, &fs_ep_out);
+ is_high_speed = false;
+ }
if (ret) {
puts("failed to enable out ep\n");
return ret;
@@ -370,13 +379,20 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req)
fastboot_tx_write_str(response);
}
-static unsigned int rx_bytes_expected(void)
+static unsigned int rx_bytes_expected(unsigned int maxpacket)
{
int rx_remain = download_size - download_bytes;
+ int rem = 0;
if (rx_remain < 0)
return 0;
if (rx_remain > EP_BUFFER_SIZE)
return EP_BUFFER_SIZE;
+ if (rx_remain < maxpacket) {
+ rx_remain = maxpacket;
+ } else if (rx_remain % maxpacket != 0) {
+ rem = rx_remain % maxpacket;
+ rx_remain = rx_remain + (maxpacket - rem);
+ }
return rx_remain;
}
@@ -388,6 +404,7 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req)
const unsigned char *buffer = req->buf;
unsigned int buffer_size = req->actual;
unsigned int pre_dot_num, now_dot_num;
+ unsigned int max;
if (req->status != 0) {
printf("Bad status: %d\n", req->status);
@@ -425,7 +442,9 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req)
printf("\ndownloading of %d bytes finished\n", download_bytes);
} else {
- req->length = rx_bytes_expected();
+ max = is_high_speed ? hs_ep_out.wMaxPacketSize :
+ fs_ep_out.wMaxPacketSize;
+ req->length = rx_bytes_expected(max);
if (req->length < ep->maxpacket)
req->length = ep->maxpacket;
}
@@ -438,6 +457,7 @@ static void cb_download(struct usb_ep *ep, struct usb_request *req)
{
char *cmd = req->buf;
char response[RESPONSE_LEN];
+ unsigned int max;
strsep(&cmd, ":");
download_size = simple_strtoul(cmd, NULL, 16);
@@ -453,7 +473,9 @@ static void cb_download(struct usb_ep *ep, struct usb_request *req)
} else {
sprintf(response, "DATA%08x", download_size);
req->complete = rx_handler_dl_image;
- req->length = rx_bytes_expected();
+ max = is_high_speed ? hs_ep_out.wMaxPacketSize :
+ fs_ep_out.wMaxPacketSize;
+ req->length = rx_bytes_expected(max);
if (req->length < ep->maxpacket)
req->length = ep->maxpacket;
}
@@ -513,6 +535,50 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req)
}
#endif
+static void cb_oem(struct usb_ep *ep, struct usb_request *req)
+{
+ char *cmd = req->buf;
+#ifdef CONFIG_FASTBOOT_FLASH
+ if (strncmp("format", cmd + 4, 6) == 0) {
+ char cmdbuf[32];
+ sprintf(cmdbuf, "gpt write mmc %x $partitions",
+ CONFIG_FASTBOOT_FLASH_MMC_DEV);
+ if (run_command(cmdbuf, 0))
+ fastboot_tx_write_str("FAIL");
+ else
+ fastboot_tx_write_str("OKAY");
+ } else
+#endif
+ if (strncmp("unlock", cmd + 4, 8) == 0) {
+ fastboot_tx_write_str("FAILnot implemented");
+ }
+ else {
+ fastboot_tx_write_str("FAILunknown oem command");
+ }
+}
+
+#ifdef CONFIG_FASTBOOT_FLASH
+static void cb_erase(struct usb_ep *ep, struct usb_request *req)
+{
+ char *cmd = req->buf;
+ char response[RESPONSE_LEN];
+
+ strsep(&cmd, ":");
+ if (!cmd) {
+ error("missing partition name");
+ fastboot_tx_write_str("FAILmissing partition name");
+ return;
+ }
+
+ strcpy(response, "FAILno flash device defined");
+
+#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+ fb_mmc_erase(cmd, response);
+#endif
+ fastboot_tx_write_str(response);
+}
+#endif
+
struct cmd_dispatch_info {
char *cmd;
void (*cb)(struct usb_ep *ep, struct usb_request *req);
@@ -539,8 +605,15 @@ static const struct cmd_dispatch_info cmd_dispatch_info[] = {
{
.cmd = "flash",
.cb = cb_flash,
+ }, {
+ .cmd = "erase",
+ .cb = cb_erase,
},
#endif
+ {
+ .cmd = "oem",
+ .cb = cb_oem,
+ },
};
static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
diff --git a/drivers/usb/host/xhci-exynos5.c b/drivers/usb/host/xhci-exynos5.c
index a77c8bc..3f86fdc 100644
--- a/drivers/usb/host/xhci-exynos5.c
+++ b/drivers/usb/host/xhci-exynos5.c
@@ -182,7 +182,7 @@ static void exynos5_usb3_phy_exit(struct exynos_usb3_phy *phy)
set_usbdrd_phy_ctrl(POWER_USB_DRD_PHY_CTRL_DISABLE);
}
-void dwc3_set_mode(struct dwc3 *dwc3_reg, u32 mode)
+static void dwc3_set_mode(struct dwc3 *dwc3_reg, u32 mode)
{
clrsetbits_le32(&dwc3_reg->g_ctl,
DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG),
diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c
index 98f4830..31a280e 100644
--- a/drivers/usb/musb-new/omap2430.c
+++ b/drivers/usb/musb-new/omap2430.c
@@ -321,6 +321,7 @@ static int omap2430_musb_init(struct musb *musb)
{
u32 l;
int status = 0;
+ unsigned long int start;
#ifndef __UBOOT__
struct device *dev = musb->controller;
struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
@@ -331,6 +332,21 @@ static int omap2430_musb_init(struct musb *musb)
(struct omap_musb_board_data *)musb->controller;
#endif
+ /* Reset the controller */
+ musb_writel(musb->mregs, OTG_SYSCONFIG, SOFTRST);
+
+ start = get_timer(0);
+
+ while (1) {
+ l = musb_readl(musb->mregs, OTG_SYSCONFIG);
+ if ((l & SOFTRST) == 0)
+ break;
+
+ if (get_timer(start) > (CONFIG_SYS_HZ / 1000)) {
+ dev_err(musb->controller, "MUSB reset is taking too long\n");
+ return -ENODEV;
+ }
+ }
#ifndef __UBOOT__
/* We require some kind of external transceiver, hooked