Lines Matching +full:imx7ulp +full:- +full:clock

1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2012-2014 Freescale Semiconductor, Inc.
42 /* imx7ulp */
65 /* imx7ulp */
188 { .compatible = "fsl,imx6sx-usbphy", .data = &imx6sx_phy_data, },
189 { .compatible = "fsl,imx6sl-usbphy", .data = &imx6sl_phy_data, },
190 { .compatible = "fsl,imx6q-usbphy", .data = &imx6q_phy_data, },
191 { .compatible = "fsl,imx23-usbphy", .data = &imx23_phy_data, },
192 { .compatible = "fsl,vf610-usbphy", .data = &vf610_phy_data, },
193 { .compatible = "fsl,imx6ul-usbphy", .data = &imx6ul_phy_data, },
194 { .compatible = "fsl,imx7ulp-usbphy", .data = &imx7ulp_phy_data, },
211 return mxs_phy->data == &imx6q_phy_data; in is_imx6q_phy()
216 return mxs_phy->data == &imx6sl_phy_data; in is_imx6sl_phy()
221 return mxs_phy->data == &imx7ulp_phy_data; in is_imx7ulp_phy()
225 * PHY needs some 32K cycles to switch from 32K clock to
226 * bus (such as AHB/AXI, etc) clock.
235 void __iomem *base = mxs_phy->phy.io_priv; in mxs_phy_tx_init()
239 if (mxs_phy->tx_reg_mask) { in mxs_phy_tx_init()
241 phytx &= ~mxs_phy->tx_reg_mask; in mxs_phy_tx_init()
242 phytx |= mxs_phy->tx_reg_set; in mxs_phy_tx_init()
279 void __iomem *base = mxs_phy->phy.io_priv; in mxs_phy_hw_init()
296 * - Auto clock/power on in mxs_phy_hw_init()
297 * - Enable full/low speed support in mxs_phy_hw_init()
308 if (mxs_phy->data->flags & MXS_PHY_NEED_IP_FIX) in mxs_phy_hw_init()
311 if (mxs_phy->regmap_anatop) { in mxs_phy_hw_init()
312 unsigned int reg = mxs_phy->port_id ? in mxs_phy_hw_init()
319 regmap_write(mxs_phy->regmap_anatop, reg, in mxs_phy_hw_init()
339 if (!mxs_phy->regmap_anatop) in mxs_phy_get_vbus_status()
342 if (mxs_phy->port_id == 0) in mxs_phy_get_vbus_status()
343 regmap_read(mxs_phy->regmap_anatop, in mxs_phy_get_vbus_status()
346 else if (mxs_phy->port_id == 1) in mxs_phy_get_vbus_status()
347 regmap_read(mxs_phy->regmap_anatop, in mxs_phy_get_vbus_status()
359 void __iomem *base = mxs_phy->phy.io_priv; in __mxs_phy_disconnect_line()
366 if (mxs_phy->port_id == 0) { in __mxs_phy_disconnect_line()
369 regmap_write(mxs_phy->regmap_anatop, reg, in __mxs_phy_disconnect_line()
372 } else if (mxs_phy->port_id == 1) { in __mxs_phy_disconnect_line()
375 regmap_write(mxs_phy->regmap_anatop, reg, in __mxs_phy_disconnect_line()
391 void __iomem *base = mxs_phy->phy.io_priv; in mxs_phy_is_otg_host()
406 if (!(mxs_phy->data->flags & MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS)) in mxs_phy_disconnect_line()
410 if (!mxs_phy->regmap_anatop) in mxs_phy_disconnect_line()
428 ret = clk_prepare_enable(mxs_phy->clk); in mxs_phy_init()
447 writel(value, phy->io_priv + HW_USBPHY_CTRL_CLR); in mxs_phy_shutdown()
448 writel(0xffffffff, phy->io_priv + HW_USBPHY_PWD); in mxs_phy_shutdown()
451 phy->io_priv + HW_USBPHY_CTRL_SET); in mxs_phy_shutdown()
454 mxs_phy_pll_enable(phy->io_priv, false); in mxs_phy_shutdown()
456 clk_disable_unprepare(mxs_phy->clk); in mxs_phy_shutdown()
468 if (!mxs_phy->regmap_anatop) in mxs_phy_is_low_speed_connection()
471 if (mxs_phy->port_id == 0) in mxs_phy_is_low_speed_connection()
473 else if (mxs_phy->port_id == 1) in mxs_phy_is_low_speed_connection()
476 regmap_read(mxs_phy->regmap_anatop, reg, &line_state); in mxs_phy_is_low_speed_connection()
505 writel(0xffbfffff, x->io_priv + HW_USBPHY_PWD); in mxs_phy_suspend()
507 writel(0xffffffff, x->io_priv + HW_USBPHY_PWD); in mxs_phy_suspend()
510 x->io_priv + HW_USBPHY_CTRL_SET); in mxs_phy_suspend()
511 clk_disable_unprepare(mxs_phy->clk); in mxs_phy_suspend()
514 ret = clk_prepare_enable(mxs_phy->clk); in mxs_phy_suspend()
518 x->io_priv + HW_USBPHY_CTRL_CLR); in mxs_phy_suspend()
519 writel(0, x->io_priv + HW_USBPHY_PWD); in mxs_phy_suspend()
533 writel_relaxed(value, x->io_priv + HW_USBPHY_CTRL_SET); in mxs_phy_set_wakeup()
535 writel_relaxed(value, x->io_priv + HW_USBPHY_CTRL_CLR); in mxs_phy_set_wakeup()
545 dev_dbg(phy->dev, "%s device has connected\n", in mxs_phy_on_connect()
550 phy->io_priv + HW_USBPHY_CTRL_SET); in mxs_phy_on_connect()
558 dev_dbg(phy->dev, "%s device has disconnected\n", in mxs_phy_on_disconnect()
562 if (readl(phy->io_priv + HW_USBPHY_CTRL) & in mxs_phy_on_disconnect()
565 phy->io_priv + HW_USBPHY_CTRL_CLR); in mxs_phy_on_disconnect()
573 struct regmap *regmap = x->regmap_anatop; in mxs_charger_data_contact_detect()
580 dev_err(x->phy.dev, "vbus is not valid\n"); in mxs_charger_data_contact_detect()
581 return -EINVAL; in mxs_charger_data_contact_detect()
588 * - Do not check whether a charger is connected to the USB port in mxs_charger_data_contact_detect()
589 * - Check whether the USB plug has been in contact with each other in mxs_charger_data_contact_detect()
612 dev_err(x->phy.dev, in mxs_charger_data_contact_detect()
618 return -ENXIO; in mxs_charger_data_contact_detect()
626 struct regmap *regmap = x->regmap_anatop; in mxs_charger_primary_detection()
631 * - Do check whether a charger is connected to the USB port in mxs_charger_primary_detection()
632 * - Do not Check whether the USB plug has been in contact with in mxs_charger_primary_detection()
645 dev_dbg(x->phy.dev, "It is a standard downstream port\n"); in mxs_charger_primary_detection()
662 struct regmap *regmap = x->regmap_anatop; in mxs_charger_secondary_detection()
669 dev_dbg(x->phy.dev, "It is a dedicate charging port\n"); in mxs_charger_secondary_detection()
672 dev_dbg(x->phy.dev, "It is a charging downstream port\n"); in mxs_charger_secondary_detection()
680 struct regmap *regmap = mxs_phy->regmap_anatop; in mxs_phy_charger_detect()
681 void __iomem *base = phy->io_priv; in mxs_phy_charger_detect()
718 struct device_node *np = pdev->dev.of_node; in mxs_phy_probe()
721 of_id = of_match_device(mxs_phy_dt_ids, &pdev->dev); in mxs_phy_probe()
723 return -ENODEV; in mxs_phy_probe()
729 clk = devm_clk_get(&pdev->dev, NULL); in mxs_phy_probe()
731 dev_err(&pdev->dev, in mxs_phy_probe()
732 "can't get the clock, err=%ld", PTR_ERR(clk)); in mxs_phy_probe()
736 mxs_phy = devm_kzalloc(&pdev->dev, sizeof(*mxs_phy), GFP_KERNEL); in mxs_phy_probe()
738 return -ENOMEM; in mxs_phy_probe()
742 mxs_phy->regmap_anatop = syscon_regmap_lookup_by_phandle in mxs_phy_probe()
744 if (IS_ERR(mxs_phy->regmap_anatop)) { in mxs_phy_probe()
745 dev_dbg(&pdev->dev, in mxs_phy_probe()
747 return PTR_ERR(mxs_phy->regmap_anatop); in mxs_phy_probe()
752 if (!of_property_read_u32(np, "fsl,tx-cal-45-dn-ohms", &val) && in mxs_phy_probe()
754 /* Scale to a 4-bit value */ in mxs_phy_probe()
755 val = (MXS_PHY_TX_CAL45_MAX - val) * 0xF in mxs_phy_probe()
756 / (MXS_PHY_TX_CAL45_MAX - MXS_PHY_TX_CAL45_MIN); in mxs_phy_probe()
757 mxs_phy->tx_reg_mask |= GM_USBPHY_TX_TXCAL45DN(~0); in mxs_phy_probe()
758 mxs_phy->tx_reg_set |= GM_USBPHY_TX_TXCAL45DN(val); in mxs_phy_probe()
761 if (!of_property_read_u32(np, "fsl,tx-cal-45-dp-ohms", &val) && in mxs_phy_probe()
763 /* Scale to a 4-bit value. */ in mxs_phy_probe()
764 val = (MXS_PHY_TX_CAL45_MAX - val) * 0xF in mxs_phy_probe()
765 / (MXS_PHY_TX_CAL45_MAX - MXS_PHY_TX_CAL45_MIN); in mxs_phy_probe()
766 mxs_phy->tx_reg_mask |= GM_USBPHY_TX_TXCAL45DP(~0); in mxs_phy_probe()
767 mxs_phy->tx_reg_set |= GM_USBPHY_TX_TXCAL45DP(val); in mxs_phy_probe()
770 if (!of_property_read_u32(np, "fsl,tx-d-cal", &val) && in mxs_phy_probe()
772 /* Scale to a 4-bit value. Round up the values and heavily in mxs_phy_probe()
775 val = ((MXS_PHY_TX_D_CAL_MAX - val) * 0xF in mxs_phy_probe()
776 + (MXS_PHY_TX_D_CAL_MAX - MXS_PHY_TX_D_CAL_MIN) * 2/3) in mxs_phy_probe()
777 / (MXS_PHY_TX_D_CAL_MAX - MXS_PHY_TX_D_CAL_MIN); in mxs_phy_probe()
778 mxs_phy->tx_reg_mask |= GM_USBPHY_TX_D_CAL(~0); in mxs_phy_probe()
779 mxs_phy->tx_reg_set |= GM_USBPHY_TX_D_CAL(val); in mxs_phy_probe()
784 dev_dbg(&pdev->dev, "failed to get alias id, errno %d\n", ret); in mxs_phy_probe()
785 mxs_phy->port_id = ret; in mxs_phy_probe()
787 mxs_phy->phy.io_priv = base; in mxs_phy_probe()
788 mxs_phy->phy.dev = &pdev->dev; in mxs_phy_probe()
789 mxs_phy->phy.label = DRIVER_NAME; in mxs_phy_probe()
790 mxs_phy->phy.init = mxs_phy_init; in mxs_phy_probe()
791 mxs_phy->phy.shutdown = mxs_phy_shutdown; in mxs_phy_probe()
792 mxs_phy->phy.set_suspend = mxs_phy_suspend; in mxs_phy_probe()
793 mxs_phy->phy.notify_connect = mxs_phy_on_connect; in mxs_phy_probe()
794 mxs_phy->phy.notify_disconnect = mxs_phy_on_disconnect; in mxs_phy_probe()
795 mxs_phy->phy.type = USB_PHY_TYPE_USB2; in mxs_phy_probe()
796 mxs_phy->phy.set_wakeup = mxs_phy_set_wakeup; in mxs_phy_probe()
797 mxs_phy->phy.charger_detect = mxs_phy_charger_detect; in mxs_phy_probe()
799 mxs_phy->clk = clk; in mxs_phy_probe()
800 mxs_phy->data = of_id->data; in mxs_phy_probe()
804 device_set_wakeup_capable(&pdev->dev, true); in mxs_phy_probe()
806 return usb_add_phy_dev(&mxs_phy->phy); in mxs_phy_probe()
813 usb_remove_phy(&mxs_phy->phy); in mxs_phy_remove()
824 if (!mxs_phy->regmap_anatop) in mxs_phy_enable_ldo_in_suspend()
828 regmap_write(mxs_phy->regmap_anatop, reg, in mxs_phy_enable_ldo_in_suspend()
831 regmap_write(mxs_phy->regmap_anatop, in mxs_phy_enable_ldo_in_suspend()
881 MODULE_ALIAS("platform:mxs-usb-phy");