mbox series

[0/2] usb: dwc3: Add avoiding vbus glitch happen during xhci reset

Message ID 20190116064820.20007-1-ran.wang_1@nxp.com
Headers show
Series usb: dwc3: Add avoiding vbus glitch happen during xhci reset | expand

Message

Ran Wang Jan. 16, 2019, 6:48 a.m. UTC
This to fix USB enumeration compatibility issue found on DWC3 (host mode)
IP only.

Some pre-discussion mails can be referred from:
https://lkml.org/lkml/2018/11/23/387
https://lkml.org/lkml/2018/11/22/683

As to the workaround, I know programming xhci register in DWC3 dirver
(probe function) is not good from perspective of SW stack, but it seems
to be the only place to fix this real existing problem (test result show
that doing this in xhci-plat.c or xhci.c would not hlep on this kind of
failure). If who have better idea, please let me know, thanks in advanced.

Ran Wang (2):
 dt-bindings: Add workaround for host mode VBUS glitch when boot
 dwc3 core driver: Add avoiding vbus glitch happen during xhci reset

 Documentation/devicetree/bindings/usb/dwc3.txt |    3 +++
 drivers/usb/dwc3/core.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/usb/dwc3/core.h |   10 +++++++++-
 3 files changed, 60 insertions(+), 0 deletions(-)

Comments

Felipe Balbi Jan. 16, 2019, 8:21 a.m. UTC | #1
Hi,

Ran Wang <ran.wang_1@nxp.com> writes:
> +static void dwc3_power_off_all_roothub_ports(struct dwc3 *dwc)
> +{
> +	int i, port_num;
> +	u32 reg, op_regs_base, offset;
> +	void __iomem		*xhci_regs;
> +
> +	/* xhci regs is not mapped yet, do it temperary here */
> +	if (dwc->xhci_resources[0].start) {
> +		xhci_regs = ioremap(dwc->xhci_resources[0].start,
> +				DWC3_XHCI_REGS_END);
> +		if (IS_ERR(xhci_regs)) {
> +			dev_err(dwc->dev, "Failed to ioremap xhci_regs\n");
> +			return;
> +		}
> +
> +		op_regs_base = HC_LENGTH(readl(xhci_regs));
> +		reg = readl(xhci_regs + XHCI_HCSPARAMS1);
> +		port_num = HCS_MAX_PORTS(reg);
> +
> +		for (i = 1; i <= port_num; i++) {
> +			offset = op_regs_base + XHCI_PORTSC_BASE + 0x10*(i-1);
> +			reg = readl(xhci_regs + offset);
> +			reg &= ~PORT_POWER;
> +			writel(reg, xhci_regs + offset);
> +		}
> +
> +		iounmap(xhci_regs);

why can't this be done during xhci_gen_setup()?