Lines Matching refs:qphy
81 static int phy_8x16_regulators_enable(struct phy_8x16 *qphy) in phy_8x16_regulators_enable() argument
85 ret = regulator_set_voltage(qphy->vdd, HSPHY_VDD_MIN, HSPHY_VDD_MAX); in phy_8x16_regulators_enable()
89 ret = regulator_enable(qphy->vdd); in phy_8x16_regulators_enable()
93 ret = regulator_set_voltage(qphy->v3p3, HSPHY_3P3_MIN, HSPHY_3P3_MAX); in phy_8x16_regulators_enable()
97 ret = regulator_enable(qphy->v3p3); in phy_8x16_regulators_enable()
101 ret = regulator_set_voltage(qphy->v1p8, HSPHY_1P8_MIN, HSPHY_1P8_MAX); in phy_8x16_regulators_enable()
105 ret = regulator_enable(qphy->v1p8); in phy_8x16_regulators_enable()
112 regulator_disable(qphy->v3p3); in phy_8x16_regulators_enable()
114 regulator_disable(qphy->vdd); in phy_8x16_regulators_enable()
119 static void phy_8x16_regulators_disable(struct phy_8x16 *qphy) in phy_8x16_regulators_disable() argument
121 regulator_disable(qphy->v1p8); in phy_8x16_regulators_disable()
122 regulator_disable(qphy->v3p3); in phy_8x16_regulators_disable()
123 regulator_disable(qphy->vdd); in phy_8x16_regulators_disable()
129 struct phy_8x16 *qphy = container_of(phy, struct phy_8x16, phy); in phy_8x16_notify_connect() local
133 usb_phy_io_write(&qphy->phy, val, ULPI_SET(ULPI_MISC_A)); in phy_8x16_notify_connect()
135 val = readl(qphy->regs + HSPHY_USBCMD); in phy_8x16_notify_connect()
137 writel(val, qphy->regs + HSPHY_USBCMD); in phy_8x16_notify_connect()
145 struct phy_8x16 *qphy = container_of(phy, struct phy_8x16, phy); in phy_8x16_notify_disconnect() local
149 usb_phy_io_write(&qphy->phy, val, ULPI_CLR(ULPI_MISC_A)); in phy_8x16_notify_disconnect()
151 val = readl(qphy->regs + HSPHY_USBCMD); in phy_8x16_notify_disconnect()
153 writel(val, qphy->regs + HSPHY_USBCMD); in phy_8x16_notify_disconnect()
158 static int phy_8x16_vbus_on(struct phy_8x16 *qphy) in phy_8x16_vbus_on() argument
160 phy_8x16_notify_connect(&qphy->phy, USB_SPEED_UNKNOWN); in phy_8x16_vbus_on()
163 gpiod_set_value_cansleep(qphy->switch_gpio, 0); in phy_8x16_vbus_on()
168 static int phy_8x16_vbus_off(struct phy_8x16 *qphy) in phy_8x16_vbus_off() argument
170 phy_8x16_notify_disconnect(&qphy->phy, USB_SPEED_UNKNOWN); in phy_8x16_vbus_off()
173 gpiod_set_value_cansleep(qphy->switch_gpio, 1); in phy_8x16_vbus_off()
181 struct phy_8x16 *qphy = container_of(nb, struct phy_8x16, vbus_notify); in phy_8x16_vbus_notify() local
184 phy_8x16_vbus_on(qphy); in phy_8x16_vbus_notify()
186 phy_8x16_vbus_off(qphy); in phy_8x16_vbus_notify()
193 struct phy_8x16 *qphy = container_of(phy, struct phy_8x16, phy); in phy_8x16_init() local
201 reset_control_reset(qphy->phy_reset); in phy_8x16_init()
204 val = readl(qphy->regs + HSPHY_CTRL); in phy_8x16_init()
206 writel(val, qphy->regs + HSPHY_CTRL); in phy_8x16_init()
216 val = readl(qphy->regs + HSPHY_CTRL); in phy_8x16_init()
218 writel(val, qphy->regs + HSPHY_CTRL); in phy_8x16_init()
222 writel(0x00, qphy->regs + HSPHY_AHBBURST); in phy_8x16_init()
223 writel(0x08, qphy->regs + HSPHY_AHBMODE); in phy_8x16_init()
226 val = readl(qphy->regs + HSPHY_GENCONFIG); in phy_8x16_init()
228 writel(val, qphy->regs + HSPHY_GENCONFIG); in phy_8x16_init()
230 val = readl(qphy->regs + HSPHY_GENCONFIG_2); in phy_8x16_init()
232 writel(val, qphy->regs + HSPHY_GENCONFIG_2); in phy_8x16_init()
237 state = extcon_get_cable_state_(qphy->vbus_edev, EXTCON_USB); in phy_8x16_init()
239 phy_8x16_vbus_on(qphy); in phy_8x16_init()
241 phy_8x16_vbus_off(qphy); in phy_8x16_init()
243 val = usb_phy_io_read(&qphy->phy, ULPI_FUNC_CTRL); in phy_8x16_init()
246 usb_phy_io_write(&qphy->phy, val, ULPI_FUNC_CTRL); in phy_8x16_init()
262 static int phy_8x16_read_devicetree(struct phy_8x16 *qphy) in phy_8x16_read_devicetree() argument
265 struct device *dev = qphy->phy.dev; in phy_8x16_read_devicetree()
268 qphy->core_clk = devm_clk_get(dev, "core"); in phy_8x16_read_devicetree()
269 if (IS_ERR(qphy->core_clk)) in phy_8x16_read_devicetree()
270 return PTR_ERR(qphy->core_clk); in phy_8x16_read_devicetree()
272 qphy->iface_clk = devm_clk_get(dev, "iface"); in phy_8x16_read_devicetree()
273 if (IS_ERR(qphy->iface_clk)) in phy_8x16_read_devicetree()
274 return PTR_ERR(qphy->iface_clk); in phy_8x16_read_devicetree()
284 qphy->v3p3 = regs[0].consumer; in phy_8x16_read_devicetree()
285 qphy->v1p8 = regs[1].consumer; in phy_8x16_read_devicetree()
286 qphy->vdd = regs[2].consumer; in phy_8x16_read_devicetree()
288 qphy->phy_reset = devm_reset_control_get(dev, "phy"); in phy_8x16_read_devicetree()
289 if (IS_ERR(qphy->phy_reset)) in phy_8x16_read_devicetree()
290 return PTR_ERR(qphy->phy_reset); in phy_8x16_read_devicetree()
292 qphy->switch_gpio = devm_gpiod_get_optional(dev, "switch", in phy_8x16_read_devicetree()
294 if (IS_ERR(qphy->switch_gpio)) in phy_8x16_read_devicetree()
295 return PTR_ERR(qphy->switch_gpio); in phy_8x16_read_devicetree()
303 struct phy_8x16 *qphy; in phy_8x16_reboot_notify() local
305 qphy = container_of(this, struct phy_8x16, reboot_notify); in phy_8x16_reboot_notify()
311 gpiod_set_value_cansleep(qphy->switch_gpio, 0); in phy_8x16_reboot_notify()
317 struct phy_8x16 *qphy; in phy_8x16_probe() local
322 qphy = devm_kzalloc(&pdev->dev, sizeof(*qphy), GFP_KERNEL); in phy_8x16_probe()
323 if (!qphy) in phy_8x16_probe()
326 platform_set_drvdata(pdev, qphy); in phy_8x16_probe()
332 qphy->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res)); in phy_8x16_probe()
333 if (!qphy->regs) in phy_8x16_probe()
336 phy = &qphy->phy; in phy_8x16_probe()
343 phy->io_priv = qphy->regs + HSPHY_ULPI_VIEWPORT; in phy_8x16_probe()
347 ret = phy_8x16_read_devicetree(qphy); in phy_8x16_probe()
351 qphy->vbus_edev = extcon_get_edev_by_phandle(phy->dev, 0); in phy_8x16_probe()
352 if (IS_ERR(qphy->vbus_edev)) in phy_8x16_probe()
353 return PTR_ERR(qphy->vbus_edev); in phy_8x16_probe()
355 ret = clk_set_rate(qphy->core_clk, INT_MAX); in phy_8x16_probe()
359 ret = clk_prepare_enable(qphy->core_clk); in phy_8x16_probe()
363 ret = clk_prepare_enable(qphy->iface_clk); in phy_8x16_probe()
367 ret = phy_8x16_regulators_enable(qphy); in phy_8x16_probe()
371 qphy->vbus_notify.notifier_call = phy_8x16_vbus_notify; in phy_8x16_probe()
372 ret = extcon_register_notifier(qphy->vbus_edev, EXTCON_USB, in phy_8x16_probe()
373 &qphy->vbus_notify); in phy_8x16_probe()
377 ret = usb_add_phy_dev(&qphy->phy); in phy_8x16_probe()
381 qphy->reboot_notify.notifier_call = phy_8x16_reboot_notify; in phy_8x16_probe()
382 register_reboot_notifier(&qphy->reboot_notify); in phy_8x16_probe()
387 extcon_unregister_notifier(qphy->vbus_edev, EXTCON_USB, in phy_8x16_probe()
388 &qphy->vbus_notify); in phy_8x16_probe()
390 phy_8x16_regulators_disable(qphy); in phy_8x16_probe()
392 clk_disable_unprepare(qphy->iface_clk); in phy_8x16_probe()
394 clk_disable_unprepare(qphy->core_clk); in phy_8x16_probe()
400 struct phy_8x16 *qphy = platform_get_drvdata(pdev); in phy_8x16_remove() local
402 unregister_reboot_notifier(&qphy->reboot_notify); in phy_8x16_remove()
403 extcon_unregister_notifier(qphy->vbus_edev, EXTCON_USB, in phy_8x16_remove()
404 &qphy->vbus_notify); in phy_8x16_remove()
410 gpiod_set_value_cansleep(qphy->switch_gpio, 0); in phy_8x16_remove()
412 usb_remove_phy(&qphy->phy); in phy_8x16_remove()
414 clk_disable_unprepare(qphy->iface_clk); in phy_8x16_remove()
415 clk_disable_unprepare(qphy->core_clk); in phy_8x16_remove()
416 phy_8x16_regulators_disable(qphy); in phy_8x16_remove()