[2/3] usb: dwc3: pci: Enable ULPI Refclk on platforms where the firmware doesnot
From: Andy Shevchenko <hidden>
Date: 2018-06-07 13:30:45
On Thu, Jun 7, 2018 at 1:38 PM, Hans de Goede [off-list ref] wrote:
On some Bay Trail (BYT) systems the firmware does not enable the ULPI Refclk. This commit adds a helper which checks and if necessary enabled the Refclk and calls this helper for BYT machines.
quoted hunk
+static void dwc3_pci_enable_ulpi_refclock(struct pci_dev *pci) +{ + void __iomem *reg; + struct resource res; + struct device *dev = &pci->dev; + u32 value; +
quoted hunk
+ res.start = pci_resource_start(pci, 1); + res.end = pci_resource_end(pci, 1); + res.name = "dwc_usb3_bar1"; + res.flags = IORESOURCE_MEM; + + reg = devm_ioremap_resource(dev, &res); + if (IS_ERR(reg)) { + dev_err(dev, "cannot check GP_RWREG1 to assert ulpi refclock\n"); + return; + }
I'm not sure I understand what's wrong with simple pci_iomap() & Co (perhaps pcim_iomap() / pcim_iomap_regions() and others)
quoted hunk
+ + value = readl(reg + GP_RWREG1); + if (!(value & GP_RWREG1_ULPI_REFCLK_DISABLE)) + return; /* ULPI refclk already enabled */ + + dev_warn(dev, "ULPI refclock is disabled from the BIOS, enabling it\n"); + value &= ~GP_RWREG1_ULPI_REFCLK_DISABLE; + writel(value, reg + GP_RWREG1);
+ msleep(100);
This has to be explained.
+}