/* * Setup PLL. * The reference clock is the frequency of quartz resonator * connected to pins REFCLK_XIN and REFCLK_XOUT of the SoC. * Register init values are matching the 40MHz default clock. * The crystal used for all platform boards is now 25MHz. * See the functional specification for details.
*/
reg = readl(PORT_REGS(port) + UTMI_PLL_CTRL_REG);
reg &= ~(PLL_REFDIV_MASK | PLL_FBDIV_MASK | PLL_SEL_LPFR_MASK);
reg |= (PLL_REFDIV_VAL << PLL_REFDIV_OFFSET) |
(PLL_FBDIV_VAL << PLL_FBDIV_OFFSET);
writel(reg, PORT_REGS(port) + UTMI_PLL_CTRL_REG);
/* Power down UTMI PHY port */
regmap_clear_bits(utmi->syscon, SYSCON_UTMI_CFG_REG(port->id),
UTMI_PHY_CFG_PU_MASK);
for (i = 0; i < UTMI_PHY_PORTS; i++) { int test = regmap_test_bits(utmi->syscon,
SYSCON_UTMI_CFG_REG(i),
UTMI_PHY_CFG_PU_MASK); /* skip PLL shutdown if there are active UTMI PHY ports */ if (test != 0) return 0;
}
/* PLL Power down if all UTMI PHYs are down */
regmap_clear_bits(utmi->syscon, SYSCON_USB_CFG_REG, USB_CFG_PLL_MASK);
/* It is necessary to power off UTMI before configuration */
ret = mvebu_cp110_utmi_phy_power_off(phy); if (ret) {
dev_err(dev, "UTMI power OFF before power ON failed\n"); return ret;
}
/* * If UTMI port is connected to USB Device controller, * configure the USB MUX prior to UTMI PHY initialization. * The single USB device controller can be connected * to UTMI0 or to UTMI1 PHY port, but not to both.
*/ if (port->dr_mode == USB_DR_MODE_PERIPHERAL) {
regmap_update_bits(utmi->syscon, SYSCON_USB_CFG_REG,
USB_CFG_DEVICE_EN_MASK | USB_CFG_DEVICE_MUX_MASK,
USB_CFG_DEVICE_EN_MASK |
(port->id << USB_CFG_DEVICE_MUX_OFFSET));
}
/* Set Test suspendm mode and enable Test UTMI select */
reg = readl(PORT_REGS(port) + UTMI_CTRL_STATUS0_REG);
reg |= SUSPENDM | TEST_SEL;
writel(reg, PORT_REGS(port) + UTMI_CTRL_STATUS0_REG);
/* Wait for UTMI power down */
mdelay(1);
/* PHY port setup first */
mvebu_cp110_utmi_port_setup(port);
/* Power UP UTMI PHY */
regmap_set_bits(utmi->syscon, SYSCON_UTMI_CFG_REG(port->id),
UTMI_PHY_CFG_PU_MASK);
utmi = devm_kzalloc(dev, sizeof(*utmi), GFP_KERNEL); if (!utmi) return -ENOMEM;
utmi->dev = dev;
/* Get system controller region */
utmi->syscon = syscon_regmap_lookup_by_phandle(dev->of_node, "marvell,system-controller"); if (IS_ERR(utmi->syscon)) {
dev_err(dev, "Missing UTMI system controller\n"); return PTR_ERR(utmi->syscon);
}
/* Get UTMI memory region */
utmi->regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(utmi->regs)) return PTR_ERR(utmi->regs);
ret = of_property_read_u32(child, "reg", &port_id); if ((ret < 0) || (port_id >= UTMI_PHY_PORTS)) {
dev_err(dev, "invalid 'reg' property on child %pOF\n",
child); continue;
}
port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL); if (!port) {
of_node_put(child); return -ENOMEM;
}
port->dr_mode = of_usb_get_dr_mode_by_phy(child, -1); if ((port->dr_mode != USB_DR_MODE_HOST) &&
(port->dr_mode != USB_DR_MODE_PERIPHERAL)) {
dev_err(&pdev->dev, "Missing dual role setting of the port%d, will use HOST mode\n",
port_id);
port->dr_mode = USB_DR_MODE_HOST;
}
if (port->dr_mode == USB_DR_MODE_PERIPHERAL) {
usb_devices++; if (usb_devices > 1) {
dev_err(dev, "Single USB device allowed! Port%d will use HOST mode\n",
port_id);
port->dr_mode = USB_DR_MODE_HOST;
}
}
of_property_for_each_u32(dev->of_node, "swap-dx-lanes", swap_dx) if (swap_dx == port_id)
port->swap_dx = 1;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.