Lines Matching +full:port +full:- +full:id
1 // SPDX-License-Identifier: GPL-2.0
31 #define SYSCON_UTMI_CFG_REG(id) (0x440 + (id) * 4) argument
79 #define PORT_REGS(p) ((p)->priv->regs + (p)->id * 0x1000)
82 * struct mvebu_cp110_utmi - PHY driver data
97 * struct mvebu_cp110_utmi_port - PHY port data
100 * @id: PHY port ID
105 u32 id; member
109 static void mvebu_cp110_utmi_port_setup(struct mvebu_cp110_utmi_port *port) in mvebu_cp110_utmi_port_setup() argument
121 reg = readl(PORT_REGS(port) + UTMI_PLL_CTRL_REG); in mvebu_cp110_utmi_port_setup()
125 writel(reg, PORT_REGS(port) + UTMI_PLL_CTRL_REG); in mvebu_cp110_utmi_port_setup()
128 reg = readl(PORT_REGS(port) + UTMI_CAL_CTRL_REG); in mvebu_cp110_utmi_port_setup()
131 writel(reg, PORT_REGS(port) + UTMI_CAL_CTRL_REG); in mvebu_cp110_utmi_port_setup()
134 reg = readl(PORT_REGS(port) + UTMI_TX_CH_CTRL_REG); in mvebu_cp110_utmi_port_setup()
137 writel(reg, PORT_REGS(port) + UTMI_TX_CH_CTRL_REG); in mvebu_cp110_utmi_port_setup()
140 reg = readl(PORT_REGS(port) + UTMI_RX_CH_CTRL0_REG); in mvebu_cp110_utmi_port_setup()
143 writel(reg, PORT_REGS(port) + UTMI_RX_CH_CTRL0_REG); in mvebu_cp110_utmi_port_setup()
149 reg = readl(PORT_REGS(port) + UTMI_RX_CH_CTRL1_REG); in mvebu_cp110_utmi_port_setup()
152 writel(reg, PORT_REGS(port) + UTMI_RX_CH_CTRL1_REG); in mvebu_cp110_utmi_port_setup()
155 * Set Control VDAT Reference Voltage - 0.325V and in mvebu_cp110_utmi_port_setup()
156 * Control VSRC Reference Voltage - 0.6V in mvebu_cp110_utmi_port_setup()
158 reg = readl(PORT_REGS(port) + UTMI_CHGDTC_CTRL_REG); in mvebu_cp110_utmi_port_setup()
161 writel(reg, PORT_REGS(port) + UTMI_CHGDTC_CTRL_REG); in mvebu_cp110_utmi_port_setup()
166 struct mvebu_cp110_utmi_port *port = phy_get_drvdata(phy); in mvebu_cp110_utmi_phy_power_off() local
167 struct mvebu_cp110_utmi *utmi = port->priv; in mvebu_cp110_utmi_phy_power_off()
170 /* Power down UTMI PHY port */ in mvebu_cp110_utmi_phy_power_off()
171 regmap_clear_bits(utmi->syscon, SYSCON_UTMI_CFG_REG(port->id), in mvebu_cp110_utmi_phy_power_off()
175 int test = regmap_test_bits(utmi->syscon, in mvebu_cp110_utmi_phy_power_off()
184 regmap_clear_bits(utmi->syscon, SYSCON_USB_CFG_REG, USB_CFG_PLL_MASK); in mvebu_cp110_utmi_phy_power_off()
191 struct mvebu_cp110_utmi_port *port = phy_get_drvdata(phy); in mvebu_cp110_utmi_phy_power_on() local
192 struct mvebu_cp110_utmi *utmi = port->priv; in mvebu_cp110_utmi_phy_power_on()
193 struct device *dev = &phy->dev; in mvebu_cp110_utmi_phy_power_on()
205 * If UTMI port is connected to USB Device controller, in mvebu_cp110_utmi_phy_power_on()
208 * to UTMI0 or to UTMI1 PHY port, but not to both. in mvebu_cp110_utmi_phy_power_on()
210 if (port->dr_mode == USB_DR_MODE_PERIPHERAL) { in mvebu_cp110_utmi_phy_power_on()
211 regmap_update_bits(utmi->syscon, SYSCON_USB_CFG_REG, in mvebu_cp110_utmi_phy_power_on()
214 (port->id << USB_CFG_DEVICE_MUX_OFFSET)); in mvebu_cp110_utmi_phy_power_on()
218 reg = readl(PORT_REGS(port) + UTMI_CTRL_STATUS0_REG); in mvebu_cp110_utmi_phy_power_on()
220 writel(reg, PORT_REGS(port) + UTMI_CTRL_STATUS0_REG); in mvebu_cp110_utmi_phy_power_on()
225 /* PHY port setup first */ in mvebu_cp110_utmi_phy_power_on()
226 mvebu_cp110_utmi_port_setup(port); in mvebu_cp110_utmi_phy_power_on()
229 regmap_set_bits(utmi->syscon, SYSCON_UTMI_CFG_REG(port->id), in mvebu_cp110_utmi_phy_power_on()
233 reg = readl(PORT_REGS(port) + UTMI_CTRL_STATUS0_REG); in mvebu_cp110_utmi_phy_power_on()
235 writel(reg, PORT_REGS(port) + UTMI_CTRL_STATUS0_REG); in mvebu_cp110_utmi_phy_power_on()
238 ret = readl_poll_timeout(PORT_REGS(port) + UTMI_CAL_CTRL_REG, reg, in mvebu_cp110_utmi_phy_power_on()
247 ret = readl_poll_timeout(PORT_REGS(port) + UTMI_CAL_CTRL_REG, reg, in mvebu_cp110_utmi_phy_power_on()
256 ret = readl_poll_timeout(PORT_REGS(port) + UTMI_PLL_CTRL_REG, reg, in mvebu_cp110_utmi_phy_power_on()
265 regmap_set_bits(utmi->syscon, SYSCON_USB_CFG_REG, USB_CFG_PLL_MASK); in mvebu_cp110_utmi_phy_power_on()
277 { .compatible = "marvell,cp110-utmi-phy" },
284 struct device *dev = &pdev->dev; in mvebu_cp110_utmi_phy_probe()
292 return -ENOMEM; in mvebu_cp110_utmi_phy_probe()
294 utmi->dev = dev; in mvebu_cp110_utmi_phy_probe()
297 utmi->syscon = syscon_regmap_lookup_by_phandle(dev->of_node, in mvebu_cp110_utmi_phy_probe()
298 "marvell,system-controller"); in mvebu_cp110_utmi_phy_probe()
299 if (IS_ERR(utmi->syscon)) { in mvebu_cp110_utmi_phy_probe()
301 return PTR_ERR(utmi->syscon); in mvebu_cp110_utmi_phy_probe()
305 utmi->regs = devm_platform_ioremap_resource(pdev, 0); in mvebu_cp110_utmi_phy_probe()
306 if (IS_ERR(utmi->regs)) in mvebu_cp110_utmi_phy_probe()
307 return PTR_ERR(utmi->regs); in mvebu_cp110_utmi_phy_probe()
309 for_each_available_child_of_node(dev->of_node, child) { in mvebu_cp110_utmi_phy_probe()
310 struct mvebu_cp110_utmi_port *port; in mvebu_cp110_utmi_phy_probe() local
323 port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL); in mvebu_cp110_utmi_phy_probe()
324 if (!port) { in mvebu_cp110_utmi_phy_probe()
326 return -ENOMEM; in mvebu_cp110_utmi_phy_probe()
329 port->dr_mode = of_usb_get_dr_mode_by_phy(child, -1); in mvebu_cp110_utmi_phy_probe()
330 if ((port->dr_mode != USB_DR_MODE_HOST) && in mvebu_cp110_utmi_phy_probe()
331 (port->dr_mode != USB_DR_MODE_PERIPHERAL)) { in mvebu_cp110_utmi_phy_probe()
332 dev_err(&pdev->dev, in mvebu_cp110_utmi_phy_probe()
333 "Missing dual role setting of the port%d, will use HOST mode\n", in mvebu_cp110_utmi_phy_probe()
335 port->dr_mode = USB_DR_MODE_HOST; in mvebu_cp110_utmi_phy_probe()
338 if (port->dr_mode == USB_DR_MODE_PERIPHERAL) { in mvebu_cp110_utmi_phy_probe()
342 "Single USB device allowed! Port%d will use HOST mode\n", in mvebu_cp110_utmi_phy_probe()
344 port->dr_mode = USB_DR_MODE_HOST; in mvebu_cp110_utmi_phy_probe()
349 utmi->ops = &mvebu_cp110_utmi_phy_ops; in mvebu_cp110_utmi_phy_probe()
352 phy = devm_phy_create(dev, child, utmi->ops); in mvebu_cp110_utmi_phy_probe()
359 port->priv = utmi; in mvebu_cp110_utmi_phy_probe()
360 port->id = port_id; in mvebu_cp110_utmi_phy_probe()
361 phy_set_drvdata(phy, port); in mvebu_cp110_utmi_phy_probe()
376 .name = "mvebu-cp110-utmi-phy",