--- zzzz-none-000/linux-4.4.271/drivers/usb/host/ehci-hcd.c 2021-06-03 06:22:09.000000000 +0000 +++ dakota-7530ac-750/linux-4.4.271/drivers/usb/host/ehci-hcd.c 2023-01-11 09:25:42.000000000 +0000 @@ -103,6 +103,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) /*-------------------------------------------------------------------------*/ @@ -253,6 +259,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, @@ -652,7 +689,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 */ @@ -739,6 +776,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))