Lines Matching +full:disable +full:- +full:port +full:- +full:power +full:- +full:control
1 // SPDX-License-Identifier: GPL-2.0
81 #define PORT_REGS(p) ((p)->priv->regs + (p)->id * 0x1000)
84 * struct mvebu_cp110_utmi - PHY driver data
99 * struct mvebu_cp110_utmi_port - PHY port data
102 * @id: PHY port ID
104 * @swap_dx: whether to swap d+/d- signals
113 static void mvebu_cp110_utmi_port_setup(struct mvebu_cp110_utmi_port *port) in mvebu_cp110_utmi_port_setup() argument
125 reg = readl(PORT_REGS(port) + UTMI_PLL_CTRL_REG); in mvebu_cp110_utmi_port_setup()
129 writel(reg, PORT_REGS(port) + UTMI_PLL_CTRL_REG); in mvebu_cp110_utmi_port_setup()
132 reg = readl(PORT_REGS(port) + UTMI_CAL_CTRL_REG); in mvebu_cp110_utmi_port_setup()
135 writel(reg, PORT_REGS(port) + UTMI_CAL_CTRL_REG); in mvebu_cp110_utmi_port_setup()
137 /* Set LS TX driver strength coarse control */ in mvebu_cp110_utmi_port_setup()
138 reg = readl(PORT_REGS(port) + UTMI_TX_CH_CTRL_REG); in mvebu_cp110_utmi_port_setup()
141 writel(reg, PORT_REGS(port) + UTMI_TX_CH_CTRL_REG); in mvebu_cp110_utmi_port_setup()
143 /* Disable SQ and enable analog squelch detect */ in mvebu_cp110_utmi_port_setup()
144 reg = readl(PORT_REGS(port) + UTMI_RX_CH_CTRL0_REG); in mvebu_cp110_utmi_port_setup()
147 writel(reg, PORT_REGS(port) + UTMI_RX_CH_CTRL0_REG); in mvebu_cp110_utmi_port_setup()
153 reg = readl(PORT_REGS(port) + UTMI_RX_CH_CTRL1_REG); in mvebu_cp110_utmi_port_setup()
156 writel(reg, PORT_REGS(port) + UTMI_RX_CH_CTRL1_REG); in mvebu_cp110_utmi_port_setup()
159 * Set Control VDAT Reference Voltage - 0.325V and in mvebu_cp110_utmi_port_setup()
160 * Control VSRC Reference Voltage - 0.6V in mvebu_cp110_utmi_port_setup()
162 reg = readl(PORT_REGS(port) + UTMI_CHGDTC_CTRL_REG); in mvebu_cp110_utmi_port_setup()
165 writel(reg, PORT_REGS(port) + UTMI_CHGDTC_CTRL_REG); in mvebu_cp110_utmi_port_setup()
167 /* Swap D+/D- */ in mvebu_cp110_utmi_port_setup()
168 reg = readl(PORT_REGS(port) + UTMI_DIG_CTRL1_REG); in mvebu_cp110_utmi_port_setup()
170 if (port->swap_dx) in mvebu_cp110_utmi_port_setup()
172 writel(reg, PORT_REGS(port) + UTMI_DIG_CTRL1_REG); in mvebu_cp110_utmi_port_setup()
177 struct mvebu_cp110_utmi_port *port = phy_get_drvdata(phy); in mvebu_cp110_utmi_phy_power_off() local
178 struct mvebu_cp110_utmi *utmi = port->priv; in mvebu_cp110_utmi_phy_power_off()
181 /* Power down UTMI PHY port */ in mvebu_cp110_utmi_phy_power_off()
182 regmap_clear_bits(utmi->syscon, SYSCON_UTMI_CFG_REG(port->id), in mvebu_cp110_utmi_phy_power_off()
186 int test = regmap_test_bits(utmi->syscon, in mvebu_cp110_utmi_phy_power_off()
194 /* PLL Power down if all UTMI PHYs are down */ in mvebu_cp110_utmi_phy_power_off()
195 regmap_clear_bits(utmi->syscon, SYSCON_USB_CFG_REG, USB_CFG_PLL_MASK); in mvebu_cp110_utmi_phy_power_off()
202 struct mvebu_cp110_utmi_port *port = phy_get_drvdata(phy); in mvebu_cp110_utmi_phy_power_on() local
203 struct mvebu_cp110_utmi *utmi = port->priv; in mvebu_cp110_utmi_phy_power_on()
204 struct device *dev = &phy->dev; in mvebu_cp110_utmi_phy_power_on()
208 /* It is necessary to power off UTMI before configuration */ in mvebu_cp110_utmi_phy_power_on()
211 dev_err(dev, "UTMI power OFF before power ON failed\n"); in mvebu_cp110_utmi_phy_power_on()
216 * If UTMI port is connected to USB Device controller, in mvebu_cp110_utmi_phy_power_on()
219 * to UTMI0 or to UTMI1 PHY port, but not to both. in mvebu_cp110_utmi_phy_power_on()
221 if (port->dr_mode == USB_DR_MODE_PERIPHERAL) { in mvebu_cp110_utmi_phy_power_on()
222 regmap_update_bits(utmi->syscon, SYSCON_USB_CFG_REG, in mvebu_cp110_utmi_phy_power_on()
225 (port->id << USB_CFG_DEVICE_MUX_OFFSET)); in mvebu_cp110_utmi_phy_power_on()
229 reg = readl(PORT_REGS(port) + UTMI_CTRL_STATUS0_REG); in mvebu_cp110_utmi_phy_power_on()
231 writel(reg, PORT_REGS(port) + UTMI_CTRL_STATUS0_REG); in mvebu_cp110_utmi_phy_power_on()
233 /* Wait for UTMI power down */ in mvebu_cp110_utmi_phy_power_on()
236 /* PHY port setup first */ in mvebu_cp110_utmi_phy_power_on()
237 mvebu_cp110_utmi_port_setup(port); in mvebu_cp110_utmi_phy_power_on()
239 /* Power UP UTMI PHY */ in mvebu_cp110_utmi_phy_power_on()
240 regmap_set_bits(utmi->syscon, SYSCON_UTMI_CFG_REG(port->id), in mvebu_cp110_utmi_phy_power_on()
243 /* Disable Test UTMI select */ in mvebu_cp110_utmi_phy_power_on()
244 reg = readl(PORT_REGS(port) + UTMI_CTRL_STATUS0_REG); in mvebu_cp110_utmi_phy_power_on()
246 writel(reg, PORT_REGS(port) + UTMI_CTRL_STATUS0_REG); in mvebu_cp110_utmi_phy_power_on()
249 ret = readl_poll_timeout(PORT_REGS(port) + UTMI_CAL_CTRL_REG, reg, in mvebu_cp110_utmi_phy_power_on()
258 ret = readl_poll_timeout(PORT_REGS(port) + UTMI_CAL_CTRL_REG, reg, in mvebu_cp110_utmi_phy_power_on()
267 ret = readl_poll_timeout(PORT_REGS(port) + UTMI_PLL_CTRL_REG, reg, in mvebu_cp110_utmi_phy_power_on()
275 /* PLL Power up */ in mvebu_cp110_utmi_phy_power_on()
276 regmap_set_bits(utmi->syscon, SYSCON_USB_CFG_REG, USB_CFG_PLL_MASK); in mvebu_cp110_utmi_phy_power_on()
288 { .compatible = "marvell,cp110-utmi-phy" },
295 struct device *dev = &pdev->dev; in mvebu_cp110_utmi_phy_probe()
304 return -ENOMEM; in mvebu_cp110_utmi_phy_probe()
306 utmi->dev = dev; in mvebu_cp110_utmi_phy_probe()
309 utmi->syscon = syscon_regmap_lookup_by_phandle(dev->of_node, in mvebu_cp110_utmi_phy_probe()
310 "marvell,system-controller"); in mvebu_cp110_utmi_phy_probe()
311 if (IS_ERR(utmi->syscon)) { in mvebu_cp110_utmi_phy_probe()
313 return PTR_ERR(utmi->syscon); in mvebu_cp110_utmi_phy_probe()
317 utmi->regs = devm_platform_ioremap_resource(pdev, 0); in mvebu_cp110_utmi_phy_probe()
318 if (IS_ERR(utmi->regs)) in mvebu_cp110_utmi_phy_probe()
319 return PTR_ERR(utmi->regs); in mvebu_cp110_utmi_phy_probe()
321 for_each_available_child_of_node(dev->of_node, child) { in mvebu_cp110_utmi_phy_probe()
322 struct mvebu_cp110_utmi_port *port; in mvebu_cp110_utmi_phy_probe() local
335 port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL); in mvebu_cp110_utmi_phy_probe()
336 if (!port) { in mvebu_cp110_utmi_phy_probe()
338 return -ENOMEM; in mvebu_cp110_utmi_phy_probe()
341 port->dr_mode = of_usb_get_dr_mode_by_phy(child, -1); in mvebu_cp110_utmi_phy_probe()
342 if ((port->dr_mode != USB_DR_MODE_HOST) && in mvebu_cp110_utmi_phy_probe()
343 (port->dr_mode != USB_DR_MODE_PERIPHERAL)) { in mvebu_cp110_utmi_phy_probe()
344 dev_err(&pdev->dev, in mvebu_cp110_utmi_phy_probe()
345 "Missing dual role setting of the port%d, will use HOST mode\n", in mvebu_cp110_utmi_phy_probe()
347 port->dr_mode = USB_DR_MODE_HOST; in mvebu_cp110_utmi_phy_probe()
350 if (port->dr_mode == USB_DR_MODE_PERIPHERAL) { in mvebu_cp110_utmi_phy_probe()
354 "Single USB device allowed! Port%d will use HOST mode\n", in mvebu_cp110_utmi_phy_probe()
356 port->dr_mode = USB_DR_MODE_HOST; in mvebu_cp110_utmi_phy_probe()
360 of_property_for_each_u32(dev->of_node, "swap-dx-lanes", swap_dx) in mvebu_cp110_utmi_phy_probe()
362 port->swap_dx = 1; in mvebu_cp110_utmi_phy_probe()
365 utmi->ops = &mvebu_cp110_utmi_phy_ops; in mvebu_cp110_utmi_phy_probe()
368 phy = devm_phy_create(dev, child, utmi->ops); in mvebu_cp110_utmi_phy_probe()
375 port->priv = utmi; in mvebu_cp110_utmi_phy_probe()
376 port->id = port_id; in mvebu_cp110_utmi_phy_probe()
377 phy_set_drvdata(phy, port); in mvebu_cp110_utmi_phy_probe()
392 .name = "mvebu-cp110-utmi-phy",