aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ehci-hcd.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-11 17:48:20 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-11 17:48:20 -0500
commit414a6750e59b0b687034764c464e9ddecac0f7a6 (patch)
tree18a5ceb11359cd72fcb2d31b5eabf3e35328697f /drivers/usb/host/ehci-hcd.c
parentc6bd5bcc4983f1a2d2f87a3769bf309482ee8c04 (diff)
parentfb37ef98015f864d22be223a0e0d93547cd1d4ef (diff)
Merge tag 'usb-3.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB patches from Greg Kroah-Hartman: "Here's the big set of USB patches for 3.8-rc1. Lots of USB host driver cleanups in here, and a bit of a reorg of the EHCI driver to make it easier for the different EHCI platform drivers to all work together nicer, which was a reduction in overall code. We also deleted some unused firmware files, and got rid of the very old file_storage usb gadget driver that had been broken for a long time. This means we ended up removing way more code than added, always a nice thing to see: 310 files changed, 3028 insertions(+), 10754 deletions(-) Other than that, the usual set of new device ids, driver fixes, gadget driver and controller updates and the like. All of these have been in the linux-next tree for a number of weeks. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>" * tag 'usb-3.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (228 commits) USB: mark uas driver as BROKEN xhci: Add Lynx Point LP to list of Intel switchable hosts uwb: fix uwb_dev_unlock() missed at an error path in uwb_rc_cmd_async() USB: ftdi_sio: Add support for Newport AGILIS motor drivers MAINTAINERS: remove drivers/block/ub.c USB: chipidea: fix use after free bug ezusb: add dependency to USB usb: ftdi_sio: fixup BeagleBone A5+ quirk USB: cp210x: add Virtenio Preon32 device id usb: storage: remove redundant memset() in usb_probe_stor1() USB: option: blacklist network interface on Huawei E173 USB: OHCI: workaround for hardware bug: retired TDs not added to the Done Queue USB: add new zte 3g-dongle's pid to option.c USB: opticon: switch to generic read implementation USB: opticon: refactor reab-urb processing USB: opticon: use usb-serial bulk-in urb USB: opticon: increase bulk-in size USB: opticon: use port as urb context USB: opticon: pass port to get_serial_info USB: opticon: make private data port specific ...
Diffstat (limited to 'drivers/usb/host/ehci-hcd.c')
-rw-r--r--drivers/usb/host/ehci-hcd.c204
1 files changed, 102 insertions, 102 deletions
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 6bf6c42481e8..c97503bb0b0e 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -39,7 +39,6 @@
39#include <linux/dma-mapping.h> 39#include <linux/dma-mapping.h>
40#include <linux/debugfs.h> 40#include <linux/debugfs.h>
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <linux/uaccess.h>
43 42
44#include <asm/byteorder.h> 43#include <asm/byteorder.h>
45#include <asm/io.h> 44#include <asm/io.h>
@@ -108,19 +107,39 @@ static bool ignore_oc = 0;
108module_param (ignore_oc, bool, S_IRUGO); 107module_param (ignore_oc, bool, S_IRUGO);
109MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications"); 108MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications");
110 109
111/* for link power management(LPM) feature */
112static unsigned int hird;
113module_param(hird, int, S_IRUGO);
114MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us");
115
116#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) 110#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT)
117 111
118/*-------------------------------------------------------------------------*/ 112/*-------------------------------------------------------------------------*/
119 113
120#include "ehci.h" 114#include "ehci.h"
121#include "ehci-dbg.c"
122#include "pci-quirks.h" 115#include "pci-quirks.h"
123 116
117/*
118 * The MosChip MCS9990 controller updates its microframe counter
119 * a little before the frame counter, and occasionally we will read
120 * the invalid intermediate value. Avoid problems by checking the
121 * microframe number (the low-order 3 bits); if they are 0 then
122 * re-read the register to get the correct value.
123 */
124static unsigned ehci_moschip_read_frame_index(struct ehci_hcd *ehci)
125{
126 unsigned uf;
127
128 uf = ehci_readl(ehci, &ehci->regs->frame_index);
129 if (unlikely((uf & 7) == 0))
130 uf = ehci_readl(ehci, &ehci->regs->frame_index);
131 return uf;
132}
133
134static inline unsigned ehci_read_frame_index(struct ehci_hcd *ehci)
135{
136 if (ehci->frame_index_bug)
137 return ehci_moschip_read_frame_index(ehci);
138 return ehci_readl(ehci, &ehci->regs->frame_index);
139}
140
141#include "ehci-dbg.c"
142
124/*-------------------------------------------------------------------------*/ 143/*-------------------------------------------------------------------------*/
125 144
126/* 145/*
@@ -293,7 +312,6 @@ static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh);
293 312
294#include "ehci-timer.c" 313#include "ehci-timer.c"
295#include "ehci-hub.c" 314#include "ehci-hub.c"
296#include "ehci-lpm.c"
297#include "ehci-mem.c" 315#include "ehci-mem.c"
298#include "ehci-q.c" 316#include "ehci-q.c"
299#include "ehci-sched.c" 317#include "ehci-sched.c"
@@ -353,24 +371,6 @@ static void ehci_shutdown(struct usb_hcd *hcd)
353 hrtimer_cancel(&ehci->hrtimer); 371 hrtimer_cancel(&ehci->hrtimer);
354} 372}
355 373
356static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
357{
358 unsigned port;
359
360 if (!HCS_PPC (ehci->hcs_params))
361 return;
362
363 ehci_dbg (ehci, "...power%s ports...\n", is_on ? "up" : "down");
364 for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; )
365 (void) ehci_hub_control(ehci_to_hcd(ehci),
366 is_on ? SetPortFeature : ClearPortFeature,
367 USB_PORT_FEAT_POWER,
368 port--, NULL, 0);
369 /* Flush those writes */
370 ehci_readl(ehci, &ehci->regs->command);
371 msleep(20);
372}
373
374/*-------------------------------------------------------------------------*/ 374/*-------------------------------------------------------------------------*/
375 375
376/* 376/*
@@ -503,7 +503,7 @@ static int ehci_init(struct usb_hcd *hcd)
503 503
504 /* controllers may cache some of the periodic schedule ... */ 504 /* controllers may cache some of the periodic schedule ... */
505 if (HCC_ISOC_CACHE(hcc_params)) // full frame cache 505 if (HCC_ISOC_CACHE(hcc_params)) // full frame cache
506 ehci->i_thresh = 2 + 8; 506 ehci->i_thresh = 0;
507 else // N microframes cached 507 else // N microframes cached
508 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); 508 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params);
509 509
@@ -555,17 +555,6 @@ static int ehci_init(struct usb_hcd *hcd)
555 temp &= ~(3 << 2); 555 temp &= ~(3 << 2);
556 temp |= (EHCI_TUNE_FLS << 2); 556 temp |= (EHCI_TUNE_FLS << 2);
557 } 557 }
558 if (HCC_LPM(hcc_params)) {
559 /* support link power management EHCI 1.1 addendum */
560 ehci_dbg(ehci, "support lpm\n");
561 ehci->has_lpm = 1;
562 if (hird > 0xf) {
563 ehci_dbg(ehci, "hird %d invalid, use default 0",
564 hird);
565 hird = 0;
566 }
567 temp |= hird << 24;
568 }
569 ehci->command = temp; 558 ehci->command = temp;
570 559
571 /* Accept arbitrarily long scatter-gather lists */ 560 /* Accept arbitrarily long scatter-gather lists */
@@ -660,7 +649,7 @@ static int ehci_run (struct usb_hcd *hcd)
660 return 0; 649 return 0;
661} 650}
662 651
663static int ehci_setup(struct usb_hcd *hcd) 652int ehci_setup(struct usb_hcd *hcd)
664{ 653{
665 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 654 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
666 int retval; 655 int retval;
@@ -691,6 +680,7 @@ static int ehci_setup(struct usb_hcd *hcd)
691 680
692 return 0; 681 return 0;
693} 682}
683EXPORT_SYMBOL_GPL(ehci_setup);
694 684
695/*-------------------------------------------------------------------------*/ 685/*-------------------------------------------------------------------------*/
696 686
@@ -1096,7 +1086,7 @@ static int ehci_get_frame (struct usb_hcd *hcd)
1096 1086
1097/* These routines handle the generic parts of controller suspend/resume */ 1087/* These routines handle the generic parts of controller suspend/resume */
1098 1088
1099static int __maybe_unused ehci_suspend(struct usb_hcd *hcd, bool do_wakeup) 1089int ehci_suspend(struct usb_hcd *hcd, bool do_wakeup)
1100{ 1090{
1101 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 1091 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1102 1092
@@ -1119,9 +1109,10 @@ static int __maybe_unused ehci_suspend(struct usb_hcd *hcd, bool do_wakeup)
1119 1109
1120 return 0; 1110 return 0;
1121} 1111}
1112EXPORT_SYMBOL_GPL(ehci_suspend);
1122 1113
1123/* Returns 0 if power was preserved, 1 if power was lost */ 1114/* Returns 0 if power was preserved, 1 if power was lost */
1124static int __maybe_unused ehci_resume(struct usb_hcd *hcd, bool hibernated) 1115int ehci_resume(struct usb_hcd *hcd, bool hibernated)
1125{ 1116{
1126 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 1117 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1127 1118
@@ -1177,33 +1168,83 @@ static int __maybe_unused ehci_resume(struct usb_hcd *hcd, bool hibernated)
1177 ehci->rh_state = EHCI_RH_SUSPENDED; 1168 ehci->rh_state = EHCI_RH_SUSPENDED;
1178 spin_unlock_irq(&ehci->lock); 1169 spin_unlock_irq(&ehci->lock);
1179 1170
1180 /* here we "know" root ports should always stay powered */
1181 ehci_port_power(ehci, 1);
1182
1183 return 1; 1171 return 1;
1184} 1172}
1173EXPORT_SYMBOL_GPL(ehci_resume);
1185 1174
1186#endif 1175#endif
1187 1176
1188/*-------------------------------------------------------------------------*/ 1177/*-------------------------------------------------------------------------*/
1189 1178
1190/* 1179/*
1191 * The EHCI in ChipIdea HDRC cannot be a separate module or device, 1180 * Generic structure: This gets copied for platform drivers so that
1192 * because its registers (and irq) are shared between host/gadget/otg 1181 * individual entries can be overridden as needed.
1193 * functions and in order to facilitate role switching we cannot
1194 * give the ehci driver exclusive access to those.
1195 */ 1182 */
1196#ifndef CHIPIDEA_EHCI 1183
1184static const struct hc_driver ehci_hc_driver = {
1185 .description = hcd_name,
1186 .product_desc = "EHCI Host Controller",
1187 .hcd_priv_size = sizeof(struct ehci_hcd),
1188
1189 /*
1190 * generic hardware linkage
1191 */
1192 .irq = ehci_irq,
1193 .flags = HCD_MEMORY | HCD_USB2,
1194
1195 /*
1196 * basic lifecycle operations
1197 */
1198 .reset = ehci_setup,
1199 .start = ehci_run,
1200 .stop = ehci_stop,
1201 .shutdown = ehci_shutdown,
1202
1203 /*
1204 * managing i/o requests and associated device resources
1205 */
1206 .urb_enqueue = ehci_urb_enqueue,
1207 .urb_dequeue = ehci_urb_dequeue,
1208 .endpoint_disable = ehci_endpoint_disable,
1209 .endpoint_reset = ehci_endpoint_reset,
1210 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
1211
1212 /*
1213 * scheduling support
1214 */
1215 .get_frame_number = ehci_get_frame,
1216
1217 /*
1218 * root hub support
1219 */
1220 .hub_status_data = ehci_hub_status_data,
1221 .hub_control = ehci_hub_control,
1222 .bus_suspend = ehci_bus_suspend,
1223 .bus_resume = ehci_bus_resume,
1224 .relinquish_port = ehci_relinquish_port,
1225 .port_handed_over = ehci_port_handed_over,
1226};
1227
1228void ehci_init_driver(struct hc_driver *drv,
1229 const struct ehci_driver_overrides *over)
1230{
1231 /* Copy the generic table to drv and then apply the overrides */
1232 *drv = ehci_hc_driver;
1233
1234 if (over) {
1235 drv->hcd_priv_size += over->extra_priv_size;
1236 if (over->reset)
1237 drv->reset = over->reset;
1238 }
1239}
1240EXPORT_SYMBOL_GPL(ehci_init_driver);
1241
1242/*-------------------------------------------------------------------------*/
1197 1243
1198MODULE_DESCRIPTION(DRIVER_DESC); 1244MODULE_DESCRIPTION(DRIVER_DESC);
1199MODULE_AUTHOR (DRIVER_AUTHOR); 1245MODULE_AUTHOR (DRIVER_AUTHOR);
1200MODULE_LICENSE ("GPL"); 1246MODULE_LICENSE ("GPL");
1201 1247
1202#ifdef CONFIG_PCI
1203#include "ehci-pci.c"
1204#define PCI_DRIVER ehci_pci_driver
1205#endif
1206
1207#ifdef CONFIG_USB_EHCI_FSL 1248#ifdef CONFIG_USB_EHCI_FSL
1208#include "ehci-fsl.c" 1249#include "ehci-fsl.c"
1209#define PLATFORM_DRIVER ehci_fsl_driver 1250#define PLATFORM_DRIVER ehci_fsl_driver
@@ -1219,11 +1260,6 @@ MODULE_LICENSE ("GPL");
1219#define PLATFORM_DRIVER ehci_hcd_sh_driver 1260#define PLATFORM_DRIVER ehci_hcd_sh_driver
1220#endif 1261#endif
1221 1262
1222#ifdef CONFIG_MIPS_ALCHEMY
1223#include "ehci-au1xxx.c"
1224#define PLATFORM_DRIVER ehci_hcd_au1xxx_driver
1225#endif
1226
1227#ifdef CONFIG_USB_EHCI_HCD_OMAP 1263#ifdef CONFIG_USB_EHCI_HCD_OMAP
1228#include "ehci-omap.c" 1264#include "ehci-omap.c"
1229#define PLATFORM_DRIVER ehci_hcd_omap_driver 1265#define PLATFORM_DRIVER ehci_hcd_omap_driver
@@ -1249,11 +1285,6 @@ MODULE_LICENSE ("GPL");
1249#define PLATFORM_DRIVER ehci_orion_driver 1285#define PLATFORM_DRIVER ehci_orion_driver
1250#endif 1286#endif
1251 1287
1252#ifdef CONFIG_ARCH_IXP4XX
1253#include "ehci-ixp4xx.c"
1254#define PLATFORM_DRIVER ixp4xx_ehci_driver
1255#endif
1256
1257#ifdef CONFIG_USB_W90X900_EHCI 1288#ifdef CONFIG_USB_W90X900_EHCI
1258#include "ehci-w90x900.c" 1289#include "ehci-w90x900.c"
1259#define PLATFORM_DRIVER ehci_hcd_w90x900_driver 1290#define PLATFORM_DRIVER ehci_hcd_w90x900_driver
@@ -1269,11 +1300,6 @@ MODULE_LICENSE ("GPL");
1269#define PLATFORM_DRIVER ehci_octeon_driver 1300#define PLATFORM_DRIVER ehci_octeon_driver
1270#endif 1301#endif
1271 1302
1272#ifdef CONFIG_USB_CNS3XXX_EHCI
1273#include "ehci-cns3xxx.c"
1274#define PLATFORM_DRIVER cns3xxx_ehci_driver
1275#endif
1276
1277#ifdef CONFIG_ARCH_VT8500 1303#ifdef CONFIG_ARCH_VT8500
1278#include "ehci-vt8500.c" 1304#include "ehci-vt8500.c"
1279#define PLATFORM_DRIVER vt8500_ehci_driver 1305#define PLATFORM_DRIVER vt8500_ehci_driver
@@ -1314,34 +1340,23 @@ MODULE_LICENSE ("GPL");
1314#define PLATFORM_DRIVER ehci_grlib_driver 1340#define PLATFORM_DRIVER ehci_grlib_driver
1315#endif 1341#endif
1316 1342
1317#ifdef CONFIG_CPU_XLR
1318#include "ehci-xls.c"
1319#define PLATFORM_DRIVER ehci_xls_driver
1320#endif
1321
1322#ifdef CONFIG_USB_EHCI_MV 1343#ifdef CONFIG_USB_EHCI_MV
1323#include "ehci-mv.c" 1344#include "ehci-mv.c"
1324#define PLATFORM_DRIVER ehci_mv_driver 1345#define PLATFORM_DRIVER ehci_mv_driver
1325#endif 1346#endif
1326 1347
1327#ifdef CONFIG_MACH_LOONGSON1
1328#include "ehci-ls1x.c"
1329#define PLATFORM_DRIVER ehci_ls1x_driver
1330#endif
1331
1332#ifdef CONFIG_MIPS_SEAD3 1348#ifdef CONFIG_MIPS_SEAD3
1333#include "ehci-sead3.c" 1349#include "ehci-sead3.c"
1334#define PLATFORM_DRIVER ehci_hcd_sead3_driver 1350#define PLATFORM_DRIVER ehci_hcd_sead3_driver
1335#endif 1351#endif
1336 1352
1337#ifdef CONFIG_USB_EHCI_HCD_PLATFORM 1353#if !IS_ENABLED(CONFIG_USB_EHCI_PCI) && \
1338#include "ehci-platform.c" 1354 !IS_ENABLED(CONFIG_USB_EHCI_HCD_PLATFORM) && \
1339#define PLATFORM_DRIVER ehci_platform_driver 1355 !defined(CONFIG_USB_CHIPIDEA_HOST) && \
1340#endif 1356 !defined(PLATFORM_DRIVER) && \
1341 1357 !defined(PS3_SYSTEM_BUS_DRIVER) && \
1342#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ 1358 !defined(OF_PLATFORM_DRIVER) && \
1343 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ 1359 !defined(XILINX_OF_PLATFORM_DRIVER)
1344 !defined(XILINX_OF_PLATFORM_DRIVER)
1345#error "missing bus glue for ehci-hcd" 1360#error "missing bus glue for ehci-hcd"
1346#endif 1361#endif
1347 1362
@@ -1378,12 +1393,6 @@ static int __init ehci_hcd_init(void)
1378 goto clean0; 1393 goto clean0;
1379#endif 1394#endif
1380 1395
1381#ifdef PCI_DRIVER
1382 retval = pci_register_driver(&PCI_DRIVER);
1383 if (retval < 0)
1384 goto clean1;
1385#endif
1386
1387#ifdef PS3_SYSTEM_BUS_DRIVER 1396#ifdef PS3_SYSTEM_BUS_DRIVER
1388 retval = ps3_ehci_driver_register(&PS3_SYSTEM_BUS_DRIVER); 1397 retval = ps3_ehci_driver_register(&PS3_SYSTEM_BUS_DRIVER);
1389 if (retval < 0) 1398 if (retval < 0)
@@ -1415,10 +1424,6 @@ clean3:
1415 ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1424 ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
1416clean2: 1425clean2:
1417#endif 1426#endif
1418#ifdef PCI_DRIVER
1419 pci_unregister_driver(&PCI_DRIVER);
1420clean1:
1421#endif
1422#ifdef PLATFORM_DRIVER 1427#ifdef PLATFORM_DRIVER
1423 platform_driver_unregister(&PLATFORM_DRIVER); 1428 platform_driver_unregister(&PLATFORM_DRIVER);
1424clean0: 1429clean0:
@@ -1444,9 +1449,6 @@ static void __exit ehci_hcd_cleanup(void)
1444#ifdef PLATFORM_DRIVER 1449#ifdef PLATFORM_DRIVER
1445 platform_driver_unregister(&PLATFORM_DRIVER); 1450 platform_driver_unregister(&PLATFORM_DRIVER);
1446#endif 1451#endif
1447#ifdef PCI_DRIVER
1448 pci_unregister_driver(&PCI_DRIVER);
1449#endif
1450#ifdef PS3_SYSTEM_BUS_DRIVER 1452#ifdef PS3_SYSTEM_BUS_DRIVER
1451 ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1453 ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
1452#endif 1454#endif
@@ -1456,5 +1458,3 @@ static void __exit ehci_hcd_cleanup(void)
1456 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); 1458 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
1457} 1459}
1458module_exit(ehci_hcd_cleanup); 1460module_exit(ehci_hcd_cleanup);
1459
1460#endif /* CHIPIDEA_EHCI */