--- zzzz-none-000/linux-4.4.60/drivers/usb/host/ehci-hcd.c 2017-04-08 07:53:53.000000000 +0000 +++ jet-2400-727/linux-4.4.60/drivers/usb/host/ehci-hcd.c 2021-03-17 14:36:41.000000000 +0000 @@ -102,6 +102,12 @@ module_param (ignore_oc, bool, S_IRUGO); MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications"); +#if defined(CONFIG_SOC_QCA955X) || defined(CONFIG_SOC_QCA956X) +static unsigned int fatal_counter = 0; +module_param (fatal_counter, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC (fatal_counter, "number of fatal errors"); +#endif + #define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) /*-------------------------------------------------------------------------*/ @@ -252,6 +258,37 @@ command |= CMD_RESET; dbg_cmd (ehci, "reset", command); ehci_writel(ehci, command, &ehci->regs->command); + + if (ehci->qca_force_host_mode) { + u32 usbmode; + + udelay(1000); + + usbmode = ehci_readl(ehci, &ehci->regs->usbmode); + usbmode |= USBMODE_CM_HC | (1 << 4); + ehci_writel(ehci, usbmode, &ehci->regs->usbmode); + + ehci_dbg(ehci, "forced host mode, usbmode: %08x\n", + ehci_readl(ehci, &ehci->regs->usbmode)); + } + + if (ehci->qca_force_16bit_ptw) { + u32 port_status; + + udelay(1000); + + /* enable 16-bit UTMI interface */ + port_status = ehci_readl(ehci, &ehci->regs->port_status[0]); + port_status |= BIT(28); + ehci_writel(ehci, port_status, &ehci->regs->port_status[0]); + + ehci_dbg(ehci, "16-bit UTMI interface enabled, status: %08x\n", + ehci_readl(ehci, &ehci->regs->port_status[0])); + } + + if (ehci->reset_notifier) + ehci->reset_notifier(ehci_to_hcd(ehci)); + ehci->rh_state = EHCI_RH_HALTED; ehci->next_statechange = jiffies; retval = ehci_handshake(ehci, &ehci->regs->command, @@ -639,7 +676,7 @@ "USB %x.%x started, EHCI %x.%02x%s\n", ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), temp >> 8, temp & 0xff, - ignore_oc ? ", overcurrent ignored" : ""); + (ignore_oc || ehci->ignore_oc) ? ", overcurrent ignored" : ""); ehci_writel(ehci, INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */ @@ -726,6 +763,21 @@ cmd = ehci_readl(ehci, &ehci->regs->command); bh = 0; +#if defined(CONFIG_SOC_QCA955X) || defined(CONFIG_SOC_QCA956X) +#define STS_RX_OVERFLOW STS_FATAL + /* AVM/BC 25.03.2014: Atheros BSP */ + if (unlikely ((status & STS_RX_OVERFLOW) != 0)) { + fatal_counter++; + //ehci_dbg(ehci, "Rx Overflow encountered\n"); + printk(KERN_INFO "%s Rx Overflow encountered\n", __FUNCTION__); + ehci_writel(ehci, cmd | CMD_RUN, &ehci->regs->command); + status &= ~STS_RX_OVERFLOW; + udelay(5); + } + #undef STS_RX_OVERFLOW + +#endif /* CONFIG_MACH_AR934x */ + /* normal [4.15.1.2] or error [4.15.1.1] completion */ if (likely ((status & (STS_INT|STS_ERR)) != 0)) { if (likely ((status & STS_ERR) == 0))