aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ehci-pci.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2012-07-09 15:55:14 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-09 16:35:05 -0400
commit1a49e2ac9651df7349867a5cf44e2c83de1046af (patch)
treeb4ba01d645073947dcf8bbe1972b7af740031b5b /drivers/usb/host/ehci-pci.c
parent1530280084c3905be6fce802cbfa83fb3bbb8839 (diff)
EHCI: centralize controller initialization
This patch (as1564c) converts the EHCI platform drivers to use the central ehci_setup() routine for generic controller initialization rather than each having its own idiosyncratic approach. The major point of difficulty lies in ehci-pci's many vendor- and device-specific workarounds. Some of them have to be applied before calling ehci_setup() and some after, which necessitates a fair amount of code motion. The other platform drivers require much smaller changes. One point not addressed by the patch is whether ports should be powered on or off following initialization. The different drivers appear to handle this pretty much at random. In fact it shouldn't matter, because the hub driver turns on power to all ports when it binds to the root hub. Straightening that out will be left for another day. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/ehci-pci.c')
-rw-r--r--drivers/usb/host/ehci-pci.c160
1 files changed, 79 insertions, 81 deletions
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 6e767bce0605..21e5f963f331 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -54,6 +54,17 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
54 u32 temp; 54 u32 temp;
55 int retval; 55 int retval;
56 56
57 ehci->caps = hcd->regs;
58
59 /*
60 * ehci_init() causes memory for DMA transfers to be
61 * allocated. Thus, any vendor-specific workarounds based on
62 * limiting the type of memory used for DMA transfers must
63 * happen before ehci_setup() is called.
64 *
65 * Most other workarounds can be done either before or after
66 * init and reset; they are located here too.
67 */
57 switch (pdev->vendor) { 68 switch (pdev->vendor) {
58 case PCI_VENDOR_ID_TOSHIBA_2: 69 case PCI_VENDOR_ID_TOSHIBA_2:
59 /* celleb's companion chip */ 70 /* celleb's companion chip */
@@ -66,20 +77,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
66#endif 77#endif
67 } 78 }
68 break; 79 break;
69 }
70
71 ehci->caps = hcd->regs;
72 ehci->regs = hcd->regs +
73 HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
74
75 dbg_hcs_params(ehci, "reset");
76 dbg_hcc_params(ehci, "reset");
77
78 /* ehci_init() causes memory for DMA transfers to be
79 * allocated. Thus, any vendor-specific workarounds based on
80 * limiting the type of memory used for DMA transfers must
81 * happen before ehci_init() is called. */
82 switch (pdev->vendor) {
83 case PCI_VENDOR_ID_NVIDIA: 80 case PCI_VENDOR_ID_NVIDIA:
84 /* NVidia reports that certain chips don't handle 81 /* NVidia reports that certain chips don't handle
85 * QH, ITD, or SITD addresses above 2GB. (But TD, 82 * QH, ITD, or SITD addresses above 2GB. (But TD,
@@ -95,61 +92,28 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
95 ehci_warn(ehci, "can't enable NVidia " 92 ehci_warn(ehci, "can't enable NVidia "
96 "workaround for >2GB RAM\n"); 93 "workaround for >2GB RAM\n");
97 break; 94 break;
98 }
99 break;
100 }
101 95
102 /* cache this readonly data; minimize chip reads */ 96 /* Some NForce2 chips have problems with selective suspend;
103 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); 97 * fixed in newer silicon.
104
105 retval = ehci_halt(ehci);
106 if (retval)
107 return retval;
108
109 if ((pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x7808) ||
110 (pdev->vendor == PCI_VENDOR_ID_ATI && pdev->device == 0x4396)) {
111 /* EHCI controller on AMD SB700/SB800/Hudson-2/3 platforms may
112 * read/write memory space which does not belong to it when
113 * there is NULL pointer with T-bit set to 1 in the frame list
114 * table. To avoid the issue, the frame list link pointer
115 * should always contain a valid pointer to a inactive qh.
116 */ 98 */
117 ehci->use_dummy_qh = 1; 99 case 0x0068:
118 ehci_info(ehci, "applying AMD SB700/SB800/Hudson-2/3 EHCI " 100 if (pdev->revision < 0xa4)
119 "dummy qh workaround\n"); 101 ehci->no_selective_suspend = 1;
120 } 102 break;
121 103 }
122 /* data structure init */
123 retval = ehci_init(hcd);
124 if (retval)
125 return retval;
126
127 switch (pdev->vendor) {
128 case PCI_VENDOR_ID_NEC:
129 ehci->need_io_watchdog = 0;
130 break; 104 break;
131 case PCI_VENDOR_ID_INTEL: 105 case PCI_VENDOR_ID_INTEL:
132 ehci->need_io_watchdog = 0;
133 ehci->fs_i_thresh = 1; 106 ehci->fs_i_thresh = 1;
134 if (pdev->device == 0x27cc) { 107 if (pdev->device == 0x27cc) {
135 ehci->broken_periodic = 1; 108 ehci->broken_periodic = 1;
136 ehci_info(ehci, "using broken periodic workaround\n"); 109 ehci_info(ehci, "using broken periodic workaround\n");
137 } 110 }
138 if (pdev->device == 0x0806 || pdev->device == 0x0811 111 if (pdev->device == PCI_DEVICE_ID_INTEL_CE4100_USB)
139 || pdev->device == 0x0829) {
140 ehci_info(ehci, "disable lpm for langwell/penwell\n");
141 ehci->has_lpm = 0;
142 }
143 if (pdev->device == PCI_DEVICE_ID_INTEL_CE4100_USB) {
144 hcd->has_tt = 1; 112 hcd->has_tt = 1;
145 tdi_reset(ehci);
146 }
147 break; 113 break;
148 case PCI_VENDOR_ID_TDI: 114 case PCI_VENDOR_ID_TDI:
149 if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { 115 if (pdev->device == PCI_DEVICE_ID_TDI_EHCI)
150 hcd->has_tt = 1; 116 hcd->has_tt = 1;
151 tdi_reset(ehci);
152 }
153 break; 117 break;
154 case PCI_VENDOR_ID_AMD: 118 case PCI_VENDOR_ID_AMD:
155 /* AMD PLL quirk */ 119 /* AMD PLL quirk */
@@ -161,28 +125,17 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
161 retval = -EIO; 125 retval = -EIO;
162 goto done; 126 goto done;
163 } 127 }
164 break;
165 case PCI_VENDOR_ID_NVIDIA:
166 switch (pdev->device) {
167 /* Some NForce2 chips have problems with selective suspend;
168 * fixed in newer silicon.
169 */
170 case 0x0068:
171 if (pdev->revision < 0xa4)
172 ehci->no_selective_suspend = 1;
173 break;
174 128
175 /* MCP89 chips on the MacBookAir3,1 give EPROTO when 129 /*
176 * fetching device descriptors unless LPM is disabled. 130 * EHCI controller on AMD SB700/SB800/Hudson-2/3 platforms may
177 * There are also intermittent problems enumerating 131 * read/write memory space which does not belong to it when
178 * devices with PPCD enabled. 132 * there is NULL pointer with T-bit set to 1 in the frame list
133 * table. To avoid the issue, the frame list link pointer
134 * should always contain a valid pointer to a inactive qh.
179 */ 135 */
180 case 0x0d9d: 136 if (pdev->device == 0x7808) {
181 ehci_info(ehci, "disable lpm/ppcd for nvidia mcp89"); 137 ehci->use_dummy_qh = 1;
182 ehci->has_lpm = 0; 138 ehci_info(ehci, "applying AMD SB700/SB800/Hudson-2/3 EHCI dummy qh workaround\n");
183 ehci->has_ppcd = 0;
184 ehci->command &= ~CMD_PPCEE;
185 break;
186 } 139 }
187 break; 140 break;
188 case PCI_VENDOR_ID_VIA: 141 case PCI_VENDOR_ID_VIA:
@@ -203,6 +156,18 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
203 /* AMD PLL quirk */ 156 /* AMD PLL quirk */
204 if (usb_amd_find_chipset_info()) 157 if (usb_amd_find_chipset_info())
205 ehci->amd_pll_fix = 1; 158 ehci->amd_pll_fix = 1;
159
160 /*
161 * EHCI controller on AMD SB700/SB800/Hudson-2/3 platforms may
162 * read/write memory space which does not belong to it when
163 * there is NULL pointer with T-bit set to 1 in the frame list
164 * table. To avoid the issue, the frame list link pointer
165 * should always contain a valid pointer to a inactive qh.
166 */
167 if (pdev->device == 0x4396) {
168 ehci->use_dummy_qh = 1;
169 ehci_info(ehci, "applying AMD SB700/SB800/Hudson-2/3 EHCI dummy qh workaround\n");
170 }
206 /* SB600 and old version of SB700 have a bug in EHCI controller, 171 /* SB600 and old version of SB700 have a bug in EHCI controller,
207 * which causes usb devices lose response in some cases. 172 * which causes usb devices lose response in some cases.
208 */ 173 */
@@ -231,6 +196,40 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
231 break; 196 break;
232 } 197 }
233 198
199 retval = ehci_setup(hcd);
200 if (retval)
201 return retval;
202
203 /* These workarounds need to be applied after ehci_setup() */
204 switch (pdev->vendor) {
205 case PCI_VENDOR_ID_NEC:
206 ehci->need_io_watchdog = 0;
207 break;
208 case PCI_VENDOR_ID_INTEL:
209 ehci->need_io_watchdog = 0;
210 if (pdev->device == 0x0806 || pdev->device == 0x0811
211 || pdev->device == 0x0829) {
212 ehci_info(ehci, "disable lpm for langwell/penwell\n");
213 ehci->has_lpm = 0;
214 }
215 break;
216 case PCI_VENDOR_ID_NVIDIA:
217 switch (pdev->device) {
218 /* MCP89 chips on the MacBookAir3,1 give EPROTO when
219 * fetching device descriptors unless LPM is disabled.
220 * There are also intermittent problems enumerating
221 * devices with PPCD enabled.
222 */
223 case 0x0d9d:
224 ehci_info(ehci, "disable lpm/ppcd for nvidia mcp89");
225 ehci->has_lpm = 0;
226 ehci->has_ppcd = 0;
227 ehci->command &= ~CMD_PPCEE;
228 break;
229 }
230 break;
231 }
232
234 /* optional debug port, normally in the first BAR */ 233 /* optional debug port, normally in the first BAR */
235 temp = pci_find_capability(pdev, 0x0a); 234 temp = pci_find_capability(pdev, 0x0a);
236 if (temp) { 235 if (temp) {
@@ -238,7 +237,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
238 temp >>= 16; 237 temp >>= 16;
239 if ((temp & (3 << 13)) == (1 << 13)) { 238 if ((temp & (3 << 13)) == (1 << 13)) {
240 temp &= 0x1fff; 239 temp &= 0x1fff;
241 ehci->debug = ehci_to_hcd(ehci)->regs + temp; 240 ehci->debug = hcd->regs + temp;
242 temp = ehci_readl(ehci, &ehci->debug->control); 241 temp = ehci_readl(ehci, &ehci->debug->control);
243 ehci_info(ehci, "debug port %d%s\n", 242 ehci_info(ehci, "debug port %d%s\n",
244 HCS_DEBUG_PORT(ehci->hcs_params), 243 HCS_DEBUG_PORT(ehci->hcs_params),
@@ -250,8 +249,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
250 } 249 }
251 } 250 }
252 251
253 ehci_reset(ehci);
254
255 /* at least the Genesys GL880S needs fixup here */ 252 /* at least the Genesys GL880S needs fixup here */
256 temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); 253 temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params);
257 temp &= 0x0f; 254 temp &= 0x0f;
@@ -275,10 +272,11 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
275 } 272 }
276 273
277 /* Serial Bus Release Number is at PCI 0x60 offset */ 274 /* Serial Bus Release Number is at PCI 0x60 offset */
278 pci_read_config_byte(pdev, 0x60, &ehci->sbrn);
279 if (pdev->vendor == PCI_VENDOR_ID_STMICRO 275 if (pdev->vendor == PCI_VENDOR_ID_STMICRO
280 && pdev->device == PCI_DEVICE_ID_STMICRO_USB_HOST) 276 && pdev->device == PCI_DEVICE_ID_STMICRO_USB_HOST)
281 ehci->sbrn = 0x20; /* ConneXT has no sbrn register */ 277 ; /* ConneXT has no sbrn register */
278 else
279 pci_read_config_byte(pdev, 0x60, &ehci->sbrn);
282 280
283 /* Keep this around for a while just in case some EHCI 281 /* Keep this around for a while just in case some EHCI
284 * implementation uses legacy PCI PM support. This test 282 * implementation uses legacy PCI PM support. This test