Skip to content

Commit c2eaacd

Browse files
committed
Add dwc_otg driver
Signed-off-by: popcornmix <[email protected]>
1 parent 93dad39 commit c2eaacd

File tree

341 files changed

+124762
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

341 files changed

+124762
-59
lines changed

drivers/usb/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ obj-$(CONFIG_USB_U132_HCD) += host/
2121
obj-$(CONFIG_USB_R8A66597_HCD) += host/
2222
obj-$(CONFIG_USB_HWA_HCD) += host/
2323
obj-$(CONFIG_USB_ISP1760_HCD) += host/
24+
obj-$(CONFIG_USB_DWCOTG) += host/
2425
obj-$(CONFIG_USB_IMX21_HCD) += host/
2526
obj-$(CONFIG_USB_FSL_MPH_DR_OF) += host/
2627

drivers/usb/core/generic.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ int usb_choose_configuration(struct usb_device *udev)
149149
dev_warn(&udev->dev,
150150
"no configuration chosen from %d choice%s\n",
151151
num_configs, plural(num_configs));
152+
dev_warn(&udev->dev, "No support over %dmA\n", udev->bus_mA);
152153
}
153154
return i;
154155
}

drivers/usb/core/hub.c

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,8 @@ static int hub_configure(struct usb_hub *hub,
10711071
INIT_WORK(&hub->tt.clear_work, hub_tt_work);
10721072
switch (hdev->descriptor.bDeviceProtocol) {
10731073
case 0:
1074+
dev_dbg(hub_dev, "TT with no hub-specific protocol - "
1075+
"no TT\n");
10741076
break;
10751077
case 1:
10761078
dev_dbg(hub_dev, "Single TT\n");
@@ -1087,6 +1089,7 @@ static int hub_configure(struct usb_hub *hub,
10871089
hub->tt.hub = hdev;
10881090
break;
10891091
case 3:
1092+
dev_dbg(hub_dev, "USB 3.0 hub - no TT\n");
10901093
/* USB 3.0 hubs don't have a TT */
10911094
break;
10921095
default:
@@ -1724,6 +1727,12 @@ static inline void announce_device(struct usb_device *udev) { }
17241727
#endif
17251728

17261729
#ifdef CONFIG_USB_OTG
1730+
1731+
static int enable_whitelist;
1732+
module_param(enable_whitelist, bool, S_IRUGO | S_IWUSR);
1733+
MODULE_PARM_DESC(enable_whitelist,
1734+
"only recognize devices in OTG whitelist if true");
1735+
17271736
#include "otg_whitelist.h"
17281737
#endif
17291738

@@ -1778,9 +1787,15 @@ static int usb_enumerate_device_otg(struct usb_device *udev)
17781787
dev_info(&udev->dev,
17791788
"can't set HNP mode: %d\n",
17801789
err);
1790+
dev_printk(KERN_CRIT, &udev->dev,
1791+
"Not Connected/Responding\n");
1792+
17811793
bus->b_hnp_enable = 0;
1794+
} else {
1795+
dev_info(&udev->dev,
1796+
"HNP Not Supported\n");
17821797
}
1783-
}
1798+
}
17841799
}
17851800
}
17861801

@@ -1789,12 +1804,27 @@ static int usb_enumerate_device_otg(struct usb_device *udev)
17891804
/* Maybe it can talk to us, though we can't talk to it.
17901805
* (Includes HNP test device.)
17911806
*/
1792-
if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
1807+
if (udev->bus->b_hnp_enable || udev->bus->is_b_host ||
1808+
udev->descriptor.idVendor == 0x1a0a) {
17931809
err = usb_port_suspend(udev, PMSG_SUSPEND);
1794-
if (err < 0)
1810+
if (err < 0) {
17951811
dev_dbg(&udev->dev, "HNP fail, %d\n", err);
1812+
} else {
1813+
/* Return Connection Refused(ECONNREFUSED)
1814+
* instead of No Device(ENODEV) so that the
1815+
* retry loop in hub_port_connect_change() is
1816+
* exited without disabling the port
1817+
*/
1818+
err = -ECONNREFUSED;
1819+
goto fail;
1820+
}
17961821
}
1797-
err = -ENOTSUPP;
1822+
//err = -ENOTSUPP;
1823+
/* Return Not Connected (ENOTCONN) instead of No
1824+
* Device(ENODEV) so that the retry loop in
1825+
* hub_port_connect_change() is exited
1826+
*/
1827+
err = -ENOTCONN;
17981828
goto fail;
17991829
}
18001830
fail:
@@ -2377,8 +2407,8 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
23772407
status = 0;
23782408
} else {
23792409
/* device has up to 10 msec to fully suspend */
2380-
dev_dbg(&udev->dev, "usb %ssuspend\n",
2381-
(msg.event & PM_EVENT_AUTO ? "auto-" : ""));
2410+
// dev_dbg(&udev->dev, "usb %ssuspend\n",
2411+
// (msg.event & PM_EVENT_AUTO ? "auto-" : ""));
23822412
usb_set_device_state(udev, USB_STATE_SUSPENDED);
23832413
msleep(10);
23842414
}
@@ -2932,7 +2962,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
29322962
buf->bMaxPacketSize0 = 0;
29332963
r = usb_control_msg(udev, usb_rcvaddr0pipe(),
29342964
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
2935-
USB_DT_DEVICE << 8, 0,
2965+
USB_DT_DEVICE << 8,
2966+
//USB_DT_DEVICE << 64, // DWC patch suggestion!
2967+
0,
29362968
buf, GET_DESCRIPTOR_BUFSIZE,
29372969
initial_descriptor_timeout);
29382970
switch (buf->bMaxPacketSize0) {
@@ -3353,8 +3385,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
33533385
release_devnum(udev);
33543386
hub_free_dev(udev);
33553387
usb_put_dev(udev);
3356-
if ((status == -ENOTCONN) || (status == -ENOTSUPP))
3357-
break;
3388+
if (status == -ENOTCONN || status == -ENOTSUPP ||
3389+
status == -ECONNREFUSED)
3390+
// break; //DWC patch
3391+
return;
33583392
}
33593393
if (hub->hdev->parent ||
33603394
!hcd->driver->port_handed_over ||

drivers/usb/core/message.c

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,6 +1836,85 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
18361836
if (cp->string == NULL &&
18371837
!(dev->quirks & USB_QUIRK_CONFIG_INTF_STRINGS))
18381838
cp->string = usb_cache_string(dev, cp->desc.iConfiguration);
1839+
/* Uncomment this define to enable the HS Electrical Test support */
1840+
#define DWC_HS_ELECT_TST 1
1841+
#ifdef DWC_HS_ELECT_TST
1842+
/* Here we implement the HS Electrical Test support. The
1843+
* tester uses a vendor ID of 0x1A0A to indicate we should
1844+
* run a special test sequence. The product ID tells us
1845+
* which sequence to run. We invoke the test sequence by
1846+
* sending a non-standard SetFeature command to our root
1847+
* hub port. Our dwc_otg_hcd_hub_control() routine will
1848+
* recognize the command and perform the desired test
1849+
* sequence.
1850+
*/
1851+
if (dev->descriptor.idVendor == 0x1A0A) {
1852+
/* HSOTG Electrical Test */
1853+
dev_warn(&dev->dev, "VID from HSOTG Electrical Test Fixture\n");
1854+
1855+
if (dev->bus && dev->bus->root_hub) {
1856+
struct usb_device *hdev = dev->bus->root_hub;
1857+
dev_warn(&dev->dev, "Got PID 0x%x\n", dev->descriptor.idProduct);
1858+
1859+
switch (dev->descriptor.idProduct) {
1860+
case 0x0101: /* TEST_SE0_NAK */
1861+
dev_warn(&dev->dev, "TEST_SE0_NAK\n");
1862+
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
1863+
USB_REQ_SET_FEATURE, USB_RT_PORT,
1864+
USB_PORT_FEAT_TEST, 0x300, NULL, 0, HZ);
1865+
break;
1866+
1867+
case 0x0102: /* TEST_J */
1868+
dev_warn(&dev->dev, "TEST_J\n");
1869+
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
1870+
USB_REQ_SET_FEATURE, USB_RT_PORT,
1871+
USB_PORT_FEAT_TEST, 0x100, NULL, 0, HZ);
1872+
break;
1873+
1874+
case 0x0103: /* TEST_K */
1875+
dev_warn(&dev->dev, "TEST_K\n");
1876+
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
1877+
USB_REQ_SET_FEATURE, USB_RT_PORT,
1878+
USB_PORT_FEAT_TEST, 0x200, NULL, 0, HZ);
1879+
break;
1880+
1881+
case 0x0104: /* TEST_PACKET */
1882+
dev_warn(&dev->dev, "TEST_PACKET\n");
1883+
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
1884+
USB_REQ_SET_FEATURE, USB_RT_PORT,
1885+
USB_PORT_FEAT_TEST, 0x400, NULL, 0, HZ);
1886+
break;
1887+
1888+
case 0x0105: /* TEST_FORCE_ENABLE */
1889+
dev_warn(&dev->dev, "TEST_FORCE_ENABLE\n");
1890+
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
1891+
USB_REQ_SET_FEATURE, USB_RT_PORT,
1892+
USB_PORT_FEAT_TEST, 0x500, NULL, 0, HZ);
1893+
break;
1894+
1895+
case 0x0106: /* HS_HOST_PORT_SUSPEND_RESUME */
1896+
dev_warn(&dev->dev, "HS_HOST_PORT_SUSPEND_RESUME\n");
1897+
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
1898+
USB_REQ_SET_FEATURE, USB_RT_PORT,
1899+
USB_PORT_FEAT_TEST, 0x600, NULL, 0, 40 * HZ);
1900+
break;
1901+
1902+
case 0x0107: /* SINGLE_STEP_GET_DEVICE_DESCRIPTOR setup */
1903+
dev_warn(&dev->dev, "SINGLE_STEP_GET_DEVICE_DESCRIPTOR setup\n");
1904+
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
1905+
USB_REQ_SET_FEATURE, USB_RT_PORT,
1906+
USB_PORT_FEAT_TEST, 0x700, NULL, 0, 40 * HZ);
1907+
break;
1908+
1909+
case 0x0108: /* SINGLE_STEP_GET_DEVICE_DESCRIPTOR execute */
1910+
dev_warn(&dev->dev, "SINGLE_STEP_GET_DEVICE_DESCRIPTOR execute\n");
1911+
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
1912+
USB_REQ_SET_FEATURE, USB_RT_PORT,
1913+
USB_PORT_FEAT_TEST, 0x800, NULL, 0, 40 * HZ);
1914+
}
1915+
}
1916+
}
1917+
#endif /* DWC_HS_ELECT_TST */
18391918

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

0 commit comments

Comments
 (0)