hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/drivers/usb/host/xhci-mtk.c
....@@ -77,7 +77,7 @@
7777 {
7878 struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs;
7979 u32 value, check_val;
80
- int u3_ports_disabed = 0;
80
+ int u3_ports_disabled = 0;
8181 int ret;
8282 int i;
8383
....@@ -92,7 +92,7 @@
9292 /* power on and enable u3 ports except skipped ones */
9393 for (i = 0; i < mtk->num_u3_ports; i++) {
9494 if ((0x1 << i) & mtk->u3p_dis_msk) {
95
- u3_ports_disabed++;
95
+ u3_ports_disabled++;
9696 continue;
9797 }
9898
....@@ -117,7 +117,7 @@
117117 check_val = STS1_SYSPLL_STABLE | STS1_REF_RST |
118118 STS1_SYS125_RST | STS1_XHCI_RST;
119119
120
- if (mtk->num_u3_ports > u3_ports_disabed)
120
+ if (mtk->num_u3_ports > u3_ports_disabled)
121121 check_val |= STS1_U3_MAC_RST;
122122
123123 ret = readl_poll_timeout(&ippc->ip_pw_sts1, value,
....@@ -206,19 +206,6 @@
206206 return xhci_mtk_host_enable(mtk);
207207 }
208208
209
-/* ignore the error if the clock does not exist */
210
-static struct clk *optional_clk_get(struct device *dev, const char *id)
211
-{
212
- struct clk *opt_clk;
213
-
214
- opt_clk = devm_clk_get(dev, id);
215
- /* ignore error number except EPROBE_DEFER */
216
- if (IS_ERR(opt_clk) && (PTR_ERR(opt_clk) != -EPROBE_DEFER))
217
- opt_clk = NULL;
218
-
219
- return opt_clk;
220
-}
221
-
222209 static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk)
223210 {
224211 struct device *dev = mtk->dev;
....@@ -229,15 +216,19 @@
229216 return PTR_ERR(mtk->sys_clk);
230217 }
231218
232
- mtk->ref_clk = optional_clk_get(dev, "ref_ck");
219
+ mtk->xhci_clk = devm_clk_get_optional(dev, "xhci_ck");
220
+ if (IS_ERR(mtk->xhci_clk))
221
+ return PTR_ERR(mtk->xhci_clk);
222
+
223
+ mtk->ref_clk = devm_clk_get_optional(dev, "ref_ck");
233224 if (IS_ERR(mtk->ref_clk))
234225 return PTR_ERR(mtk->ref_clk);
235226
236
- mtk->mcu_clk = optional_clk_get(dev, "mcu_ck");
227
+ mtk->mcu_clk = devm_clk_get_optional(dev, "mcu_ck");
237228 if (IS_ERR(mtk->mcu_clk))
238229 return PTR_ERR(mtk->mcu_clk);
239230
240
- mtk->dma_clk = optional_clk_get(dev, "dma_ck");
231
+ mtk->dma_clk = devm_clk_get_optional(dev, "dma_ck");
241232 return PTR_ERR_OR_ZERO(mtk->dma_clk);
242233 }
243234
....@@ -257,6 +248,12 @@
257248 goto sys_clk_err;
258249 }
259250
251
+ ret = clk_prepare_enable(mtk->xhci_clk);
252
+ if (ret) {
253
+ dev_err(mtk->dev, "failed to enable xhci_clk\n");
254
+ goto xhci_clk_err;
255
+ }
256
+
260257 ret = clk_prepare_enable(mtk->mcu_clk);
261258 if (ret) {
262259 dev_err(mtk->dev, "failed to enable mcu_clk\n");
....@@ -274,6 +271,8 @@
274271 dma_clk_err:
275272 clk_disable_unprepare(mtk->mcu_clk);
276273 mcu_clk_err:
274
+ clk_disable_unprepare(mtk->xhci_clk);
275
+xhci_clk_err:
277276 clk_disable_unprepare(mtk->sys_clk);
278277 sys_clk_err:
279278 clk_disable_unprepare(mtk->ref_clk);
....@@ -285,6 +284,7 @@
285284 {
286285 clk_disable_unprepare(mtk->dma_clk);
287286 clk_disable_unprepare(mtk->mcu_clk);
287
+ clk_disable_unprepare(mtk->xhci_clk);
288288 clk_disable_unprepare(mtk->sys_clk);
289289 clk_disable_unprepare(mtk->ref_clk);
290290 }
....@@ -343,13 +343,6 @@
343343 if (mtk->uwk_en)
344344 usb_wakeup_ip_sleep_set(mtk, enable);
345345 }
346
-
347
-static int xhci_mtk_setup(struct usb_hcd *hcd);
348
-static const struct xhci_driver_overrides xhci_mtk_overrides __initconst = {
349
- .reset = xhci_mtk_setup,
350
-};
351
-
352
-static struct hc_driver __read_mostly xhci_mtk_hc_driver;
353346
354347 static int xhci_mtk_ldos_enable(struct xhci_hcd_mtk *mtk)
355348 {
....@@ -431,6 +424,16 @@
431424 return ret;
432425 }
433426
427
+static const struct xhci_driver_overrides xhci_mtk_overrides __initconst = {
428
+ .reset = xhci_mtk_setup,
429
+ .add_endpoint = xhci_mtk_add_ep,
430
+ .drop_endpoint = xhci_mtk_drop_ep,
431
+ .check_bandwidth = xhci_mtk_check_bandwidth,
432
+ .reset_bandwidth = xhci_mtk_reset_bandwidth,
433
+};
434
+
435
+static struct hc_driver __read_mostly xhci_mtk_hc_driver;
436
+
434437 static int xhci_mtk_probe(struct platform_device *pdev)
435438 {
436439 struct device *dev = &pdev->dev;
....@@ -498,11 +501,6 @@
498501 goto disable_clk;
499502 }
500503
501
- /* Initialize dma_mask and coherent_dma_mask to 32-bits */
502
- ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
503
- if (ret)
504
- goto disable_clk;
505
-
506504 hcd = usb_create_hcd(driver, dev, dev_name(dev));
507505 if (!hcd) {
508506 ret = -ENOMEM;
....@@ -538,6 +536,7 @@
538536 }
539537
540538 device_init_wakeup(dev, true);
539
+ dma_set_max_seg_size(dev, UINT_MAX);
541540
542541 xhci = hcd_to_xhci(hcd);
543542 xhci->main_hcd = hcd;