Skip to content

Commit

Permalink
Add dwc_otg driver
Browse files Browse the repository at this point in the history
Signed-off-by: popcornmix <popcornmix@gmail.com>
  • Loading branch information
popcornmix authored and bootc committed May 8, 2012
1 parent b1be7dd commit f58f847
Show file tree
Hide file tree
Showing 341 changed files with 124,759 additions and 58 deletions.
1 change: 1 addition & 0 deletions drivers/usb/Makefile
Expand Up @@ -23,6 +23,7 @@ obj-$(CONFIG_USB_U132_HCD) += host/
obj-$(CONFIG_USB_R8A66597_HCD) += host/
obj-$(CONFIG_USB_HWA_HCD) += host/
obj-$(CONFIG_USB_ISP1760_HCD) += host/
obj-$(CONFIG_USB_DWCOTG) += host/
obj-$(CONFIG_USB_IMX21_HCD) += host/
obj-$(CONFIG_USB_FSL_MPH_DR_OF) += host/

Expand Down
1 change: 1 addition & 0 deletions drivers/usb/core/generic.c
Expand Up @@ -149,6 +149,7 @@ int usb_choose_configuration(struct usb_device *udev)
dev_warn(&udev->dev,
"no configuration chosen from %d choice%s\n",
num_configs, plural(num_configs));
dev_warn(&udev->dev, "No support over %dmA\n", udev->bus_mA);
}
return i;
}
Expand Down
48 changes: 41 additions & 7 deletions drivers/usb/core/hub.c
Expand Up @@ -1075,6 +1075,8 @@ static int hub_configure(struct usb_hub *hub,
INIT_WORK(&hub->tt.clear_work, hub_tt_work);
switch (hdev->descriptor.bDeviceProtocol) {
case 0:
dev_dbg(hub_dev, "TT with no hub-specific protocol - "
"no TT\n");
break;
case 1:
dev_dbg(hub_dev, "Single TT\n");
Expand All @@ -1091,6 +1093,7 @@ static int hub_configure(struct usb_hub *hub,
hub->tt.hub = hdev;
break;
case 3:
dev_dbg(hub_dev, "USB 3.0 hub - no TT\n");
/* USB 3.0 hubs don't have a TT */
break;
default:
Expand Down Expand Up @@ -1723,6 +1726,12 @@ static inline void announce_device(struct usb_device *udev) { }
#endif

#ifdef CONFIG_USB_OTG

static int enable_whitelist;
module_param(enable_whitelist, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(enable_whitelist,
"only recognize devices in OTG whitelist if true");

#include "otg_whitelist.h"
#endif

Expand Down Expand Up @@ -1777,9 +1786,15 @@ static int usb_enumerate_device_otg(struct usb_device *udev)
dev_info(&udev->dev,
"can't set HNP mode: %d\n",
err);
dev_printk(KERN_CRIT, &udev->dev,
"Not Connected/Responding\n");

bus->b_hnp_enable = 0;
} else {
dev_info(&udev->dev,
"HNP Not Supported\n");
}
}
}
}
}

Expand All @@ -1788,12 +1803,27 @@ static int usb_enumerate_device_otg(struct usb_device *udev)
/* Maybe it can talk to us, though we can't talk to it.
* (Includes HNP test device.)
*/
if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
if (udev->bus->b_hnp_enable || udev->bus->is_b_host ||
udev->descriptor.idVendor == 0x1a0a) {
err = usb_port_suspend(udev, PMSG_SUSPEND);
if (err < 0)
if (err < 0) {
dev_dbg(&udev->dev, "HNP fail, %d\n", err);
} else {
/* Return Connection Refused(ECONNREFUSED)
* instead of No Device(ENODEV) so that the
* retry loop in hub_port_connect_change() is
* exited without disabling the port
*/
err = -ECONNREFUSED;
goto fail;
}
}
err = -ENOTSUPP;
//err = -ENOTSUPP;
/* Return Not Connected (ENOTCONN) instead of No
* Device(ENODEV) so that the retry loop in
* hub_port_connect_change() is exited
*/
err = -ENOTCONN;
goto fail;
}
fail:
Expand Down Expand Up @@ -2980,7 +3010,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
buf->bMaxPacketSize0 = 0;
r = usb_control_msg(udev, usb_rcvaddr0pipe(),
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
USB_DT_DEVICE << 8, 0,
USB_DT_DEVICE << 8,
//USB_DT_DEVICE << 64, // DWC patch suggestion!
0,
buf, GET_DESCRIPTOR_BUFSIZE,
initial_descriptor_timeout);
switch (buf->bMaxPacketSize0) {
Expand Down Expand Up @@ -3426,8 +3458,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
release_devnum(udev);
hub_free_dev(udev);
usb_put_dev(udev);
if ((status == -ENOTCONN) || (status == -ENOTSUPP))
break;
if (status == -ENOTCONN || status == -ENOTSUPP ||
status == -ECONNREFUSED)
// break; //DWC patch
return;
}
if (hub->hdev->parent ||
!hcd->driver->port_handed_over ||
Expand Down
79 changes: 79 additions & 0 deletions drivers/usb/core/message.c
Expand Up @@ -1837,6 +1837,85 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
if (cp->string == NULL &&
!(dev->quirks & USB_QUIRK_CONFIG_INTF_STRINGS))
cp->string = usb_cache_string(dev, cp->desc.iConfiguration);
/* Uncomment this define to enable the HS Electrical Test support */
#define DWC_HS_ELECT_TST 1
#ifdef DWC_HS_ELECT_TST
/* Here we implement the HS Electrical Test support. The
* tester uses a vendor ID of 0x1A0A to indicate we should
* run a special test sequence. The product ID tells us
* which sequence to run. We invoke the test sequence by
* sending a non-standard SetFeature command to our root
* hub port. Our dwc_otg_hcd_hub_control() routine will
* recognize the command and perform the desired test
* sequence.
*/
if (dev->descriptor.idVendor == 0x1A0A) {
/* HSOTG Electrical Test */
dev_warn(&dev->dev, "VID from HSOTG Electrical Test Fixture\n");

if (dev->bus && dev->bus->root_hub) {
struct usb_device *hdev = dev->bus->root_hub;
dev_warn(&dev->dev, "Got PID 0x%x\n", dev->descriptor.idProduct);

switch (dev->descriptor.idProduct) {
case 0x0101: /* TEST_SE0_NAK */
dev_warn(&dev->dev, "TEST_SE0_NAK\n");
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
USB_REQ_SET_FEATURE, USB_RT_PORT,
USB_PORT_FEAT_TEST, 0x300, NULL, 0, HZ);
break;

case 0x0102: /* TEST_J */
dev_warn(&dev->dev, "TEST_J\n");
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
USB_REQ_SET_FEATURE, USB_RT_PORT,
USB_PORT_FEAT_TEST, 0x100, NULL, 0, HZ);
break;

case 0x0103: /* TEST_K */
dev_warn(&dev->dev, "TEST_K\n");
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
USB_REQ_SET_FEATURE, USB_RT_PORT,
USB_PORT_FEAT_TEST, 0x200, NULL, 0, HZ);
break;

case 0x0104: /* TEST_PACKET */
dev_warn(&dev->dev, "TEST_PACKET\n");
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
USB_REQ_SET_FEATURE, USB_RT_PORT,
USB_PORT_FEAT_TEST, 0x400, NULL, 0, HZ);
break;

case 0x0105: /* TEST_FORCE_ENABLE */
dev_warn(&dev->dev, "TEST_FORCE_ENABLE\n");
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
USB_REQ_SET_FEATURE, USB_RT_PORT,
USB_PORT_FEAT_TEST, 0x500, NULL, 0, HZ);
break;

case 0x0106: /* HS_HOST_PORT_SUSPEND_RESUME */
dev_warn(&dev->dev, "HS_HOST_PORT_SUSPEND_RESUME\n");
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
USB_REQ_SET_FEATURE, USB_RT_PORT,
USB_PORT_FEAT_TEST, 0x600, NULL, 0, 40 * HZ);
break;

case 0x0107: /* SINGLE_STEP_GET_DEVICE_DESCRIPTOR setup */
dev_warn(&dev->dev, "SINGLE_STEP_GET_DEVICE_DESCRIPTOR setup\n");
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
USB_REQ_SET_FEATURE, USB_RT_PORT,
USB_PORT_FEAT_TEST, 0x700, NULL, 0, 40 * HZ);
break;

case 0x0108: /* SINGLE_STEP_GET_DEVICE_DESCRIPTOR execute */
dev_warn(&dev->dev, "SINGLE_STEP_GET_DEVICE_DESCRIPTOR execute\n");
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
USB_REQ_SET_FEATURE, USB_RT_PORT,
USB_PORT_FEAT_TEST, 0x800, NULL, 0, 40 * HZ);
}
}
}
#endif /* DWC_HS_ELECT_TST */

/* Now that all the interfaces are set up, register them
* to trigger binding of drivers to interfaces. probe()
Expand Down

0 comments on commit f58f847

Please sign in to comment.