^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* Copyright (c) 2020, Broadcom */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/clk.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/dma-mapping.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/usb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/usb/hcd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/iopoll.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "ehci.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define hcd_to_ehci_priv(h) ((struct brcm_priv *)hcd_to_ehci(h)->priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct brcm_priv {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct clk *clk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * ehci_brcm_wait_for_sof
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * Wait for start of next microframe, then wait extra delay microseconds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static inline void ehci_brcm_wait_for_sof(struct ehci_hcd *ehci, u32 delay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) u32 frame_idx = ehci_readl(ehci, &ehci->regs->frame_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) u32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) int res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /* Wait for next microframe (every 125 usecs) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) res = readl_relaxed_poll_timeout(&ehci->regs->frame_index, val,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) val != frame_idx, 1, 130);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) if (res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) ehci_err(ehci, "Error waiting for SOF\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) udelay(delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * ehci_brcm_hub_control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * The EHCI controller has a bug where it can violate the SOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * interval between the first two SOF's transmitted after resume
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * if the resume occurs near the end of the microframe. This causees
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * the controller to detect babble on the suspended port and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * will eventually cause the controller to reset the port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * The fix is to Intercept the echi-hcd request to complete RESUME and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * align it to the start of the next microframe.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * See SWLINUX-1909 for more details
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) static int ehci_brcm_hub_control(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct usb_hcd *hcd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) u16 typeReq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) u16 wValue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) u16 wIndex,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) u16 wLength)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct ehci_hcd *ehci = hcd_to_ehci(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) int ports = HCS_N_PORTS(ehci->hcs_params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) u32 __iomem *status_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) int retval, irq_disabled = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) status_reg = &ehci->regs->port_status[(wIndex & 0xff) - 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * RESUME is cleared when GetPortStatus() is called 20ms after start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * of RESUME
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) if ((typeReq == GetPortStatus) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) (wIndex && wIndex <= ports) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) ehci->reset_done[wIndex-1] &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) time_after_eq(jiffies, ehci->reset_done[wIndex-1]) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) (ehci_readl(ehci, status_reg) & PORT_RESUME)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * to make sure we are not interrupted until RESUME bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * is cleared, disable interrupts on current CPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) ehci_dbg(ehci, "SOF alignment workaround\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) irq_disabled = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) local_irq_save(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) ehci_brcm_wait_for_sof(ehci, 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) retval = ehci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) if (irq_disabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) local_irq_restore(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) static int ehci_brcm_reset(struct usb_hcd *hcd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct ehci_hcd *ehci = hcd_to_ehci(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) ehci->big_endian_mmio = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) ehci->caps = (void __iomem *)hcd->regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) len = HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) ehci->regs = (void __iomem *)(hcd->regs + len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) /* This fixes the lockup during reboot due to prior interrupts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) ehci_writel(ehci, CMD_RESET, &ehci->regs->command);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) mdelay(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * SWLINUX-1705: Avoid OUT packet underflows during high memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * bus usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * port_status[0x0f] = Broadcom-proprietary USB_EHCI_INSNREG00 @ 0x90
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) ehci_writel(ehci, 0x00800040, &ehci->regs->port_status[0x10]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) ehci_writel(ehci, 0x00000001, &ehci->regs->port_status[0x12]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) return ehci_setup(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static struct hc_driver __read_mostly ehci_brcm_hc_driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static const struct ehci_driver_overrides brcm_overrides __initconst = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) .reset = ehci_brcm_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) .extra_priv_size = sizeof(struct brcm_priv),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static int ehci_brcm_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) struct device *dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) struct resource *res_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct brcm_priv *priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) struct usb_hcd *hcd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) err = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) irq = platform_get_irq(pdev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) if (irq <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) return irq ? irq : -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) /* Hook the hub control routine to work around a bug */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) ehci_brcm_hc_driver.hub_control = ehci_brcm_hub_control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /* initialize hcd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) hcd = usb_create_hcd(&ehci_brcm_hc_driver, dev, dev_name(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) if (!hcd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) platform_set_drvdata(pdev, hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) priv = hcd_to_ehci_priv(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) priv->clk = devm_clk_get_optional(dev, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if (IS_ERR(priv->clk)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) err = PTR_ERR(priv->clk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) goto err_hcd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) err = clk_prepare_enable(priv->clk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) goto err_hcd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) hcd->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res_mem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) if (IS_ERR(hcd->regs)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) err = PTR_ERR(hcd->regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) goto err_clk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) hcd->rsrc_start = res_mem->start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) hcd->rsrc_len = resource_size(res_mem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) err = usb_add_hcd(hcd, irq, IRQF_SHARED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) goto err_clk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) device_wakeup_enable(hcd->self.controller);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) device_enable_async_suspend(hcd->self.controller);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) err_clk:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) clk_disable_unprepare(priv->clk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) err_hcd:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) usb_put_hcd(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) static int ehci_brcm_remove(struct platform_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) struct usb_hcd *hcd = platform_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) struct brcm_priv *priv = hcd_to_ehci_priv(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) usb_remove_hcd(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) clk_disable_unprepare(priv->clk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) usb_put_hcd(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) static int __maybe_unused ehci_brcm_suspend(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) struct usb_hcd *hcd = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) struct brcm_priv *priv = hcd_to_ehci_priv(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) bool do_wakeup = device_may_wakeup(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) ret = ehci_suspend(hcd, do_wakeup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) clk_disable_unprepare(priv->clk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) static int __maybe_unused ehci_brcm_resume(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) struct usb_hcd *hcd = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) struct ehci_hcd *ehci = hcd_to_ehci(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) struct brcm_priv *priv = hcd_to_ehci_priv(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) err = clk_prepare_enable(priv->clk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) * SWLINUX-1705: Avoid OUT packet underflows during high memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) * bus usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * port_status[0x0f] = Broadcom-proprietary USB_EHCI_INSNREG00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * @ 0x90
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) ehci_writel(ehci, 0x00800040, &ehci->regs->port_status[0x10]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) ehci_writel(ehci, 0x00000001, &ehci->regs->port_status[0x12]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) ehci_resume(hcd, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) pm_runtime_disable(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) pm_runtime_set_active(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) pm_runtime_enable(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) static SIMPLE_DEV_PM_OPS(ehci_brcm_pm_ops, ehci_brcm_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) ehci_brcm_resume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) static const struct of_device_id brcm_ehci_of_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) { .compatible = "brcm,ehci-brcm-v2", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) { .compatible = "brcm,bcm7445-ehci", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) static struct platform_driver ehci_brcm_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) .probe = ehci_brcm_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) .remove = ehci_brcm_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) .shutdown = usb_hcd_platform_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) .name = "ehci-brcm",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) .pm = &ehci_brcm_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) .of_match_table = brcm_ehci_of_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) static int __init ehci_brcm_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) if (usb_disabled())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) ehci_init_driver(&ehci_brcm_hc_driver, &brcm_overrides);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) return platform_driver_register(&ehci_brcm_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) module_init(ehci_brcm_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) static void __exit ehci_brcm_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) platform_driver_unregister(&ehci_brcm_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) module_exit(ehci_brcm_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) MODULE_ALIAS("platform:ehci-brcm");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) MODULE_DESCRIPTION("EHCI Broadcom STB driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) MODULE_AUTHOR("Al Cooper");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) MODULE_LICENSE("GPL");