forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/usb/host/ohci-at91.c
....@@ -115,7 +115,6 @@
115115 static void at91_stop_hc(struct platform_device *pdev)
116116 {
117117 struct usb_hcd *hcd = platform_get_drvdata(pdev);
118
- struct ohci_regs __iomem *regs = hcd->regs;
119118 struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd);
120119
121120 dev_dbg(&pdev->dev, "stop\n");
....@@ -123,7 +122,7 @@
123122 /*
124123 * Put the USB host controller into reset.
125124 */
126
- writel(0, &regs->control);
125
+ usb_hcd_platform_shutdown(pdev);
127126
128127 /*
129128 * Stop the USB clocks.
....@@ -141,8 +140,11 @@
141140 struct regmap *regmap;
142141
143142 regmap = syscon_regmap_lookup_by_compatible("atmel,sama5d2-sfr");
144
- if (IS_ERR(regmap))
145
- regmap = NULL;
143
+ if (IS_ERR(regmap)) {
144
+ regmap = syscon_regmap_lookup_by_compatible("microchip,sam9x60-sfr");
145
+ if (IS_ERR(regmap))
146
+ regmap = NULL;
147
+ }
146148
147149 return regmap;
148150 }
....@@ -151,7 +153,7 @@
151153 /* always called with process context; sleeping is OK */
152154
153155
154
-/**
156
+/*
155157 * usb_hcd_at91_probe - initialize AT91-based HCDs
156158 * Context: !in_interrupt()
157159 *
....@@ -242,9 +244,8 @@
242244
243245 /* may be called with controller, bus, and devices active */
244246
245
-/**
247
+/*
246248 * usb_hcd_at91_remove - shutdown processing for AT91-based HCDs
247
- * @dev: USB Host Controller being removed
248249 * Context: !in_interrupt()
249250 *
250251 * Reverses the effect of usb_hcd_at91_probe(), first invoking
....@@ -605,8 +606,6 @@
605606 if (ohci_at91->wakeup)
606607 enable_irq_wake(hcd->irq);
607608
608
- ohci_at91_port_suspend(ohci_at91->sfr_regmap, 1);
609
-
610609 ret = ohci_suspend(hcd, ohci_at91->wakeup);
611610 if (ret) {
612611 if (ohci_at91->wakeup)
....@@ -625,7 +624,11 @@
625624
626625 /* flush the writes */
627626 (void) ohci_readl (ohci, &ohci->regs->control);
627
+ msleep(1);
628
+ ohci_at91_port_suspend(ohci_at91->sfr_regmap, 1);
628629 at91_stop_clock(ohci_at91);
630
+ } else {
631
+ ohci_at91_port_suspend(ohci_at91->sfr_regmap, 1);
629632 }
630633
631634 return ret;
....@@ -637,14 +640,20 @@
637640 struct usb_hcd *hcd = dev_get_drvdata(dev);
638641 struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd);
639642
643
+ ohci_at91_port_suspend(ohci_at91->sfr_regmap, 0);
644
+
640645 if (ohci_at91->wakeup)
641646 disable_irq_wake(hcd->irq);
647
+ else
648
+ at91_start_clock(ohci_at91);
642649
643
- at91_start_clock(ohci_at91);
644
-
645
- ohci_resume(hcd, false);
646
-
647
- ohci_at91_port_suspend(ohci_at91->sfr_regmap, 0);
650
+ /*
651
+ * According to the comment in ohci_hcd_at91_drv_suspend()
652
+ * we need to do a reset if the 48Mhz clock was stopped,
653
+ * that is, if ohci_at91->wakeup is clear. Tell ohci_resume()
654
+ * to reset in this case by setting its "hibernated" flag.
655
+ */
656
+ ohci_resume(hcd, !ohci_at91->wakeup);
648657
649658 return 0;
650659 }