Skip to content
Permalink
Browse files

Add dwc_otg driver

Signed-off-by: popcornmix <popcornmix@gmail.com>
  • Loading branch information
popcornmix committed Jan 17, 2012
1 parent 93dad39 commit c2eaacd30565604bbf776ca6e83c9889ea87ea74
Showing 341 changed files with 124,762 additions and 59 deletions.
@@ -21,6 +21,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/

@@ -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;
}
@@ -1071,6 +1071,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");
@@ -1087,6 +1089,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:
@@ -1724,6 +1727,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

@@ -1778,9 +1787,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");
}
}
}
}
}

@@ -1789,12 +1804,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:
@@ -2377,8 +2407,8 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
status = 0;
} else {
/* device has up to 10 msec to fully suspend */
dev_dbg(&udev->dev, "usb %ssuspend\n",
(msg.event & PM_EVENT_AUTO ? "auto-" : ""));
// dev_dbg(&udev->dev, "usb %ssuspend\n",
// (msg.event & PM_EVENT_AUTO ? "auto-" : ""));
usb_set_device_state(udev, USB_STATE_SUSPENDED);
msleep(10);
}
@@ -2932,7 +2962,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) {
@@ -3353,8 +3385,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 ||
@@ -1836,6 +1836,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()

1 comment on commit c2eaacd

@hexameron

This comment has been minimized.

Copy link
Contributor

@hexameron hexameron commented on c2eaacd Jan 29, 2012

Your patch for drivers/usb/gadget/Kconfig has duplicates.

Please sign in to comment.