Lines Matching +full:hi3660 +full:- +full:usb +full:- +full:phy
1 // SPDX-License-Identifier: GPL-2.0
3 * Phy provider for USB 3.0 controller on HiSilicon 3660 platform
5 * Copyright (C) 2017-2018 Hilisicon Electronics Co., Ltd.
14 #include <linux/phy/phy.h>
54 /* This value config the default txtune parameter of the usb 2.0 phy */
65 static int hi3660_phy_init(struct phy *phy) in hi3660_phy_init() argument
67 struct hi3660_priv *priv = phy_get_drvdata(phy); in hi3660_phy_init()
71 /* usb refclk iso disable */ in hi3660_phy_init()
72 ret = regmap_write(priv->peri_crg, PERI_CRG_ISODIS, USB_REFCLK_ISO_EN); in hi3660_phy_init()
78 ret = regmap_write(priv->pctrl, PCTRL_PERI_CTRL3, val); in hi3660_phy_init()
82 /* assert phy */ in hi3660_phy_init()
84 ret = regmap_write(priv->peri_crg, PERI_CRG_RSTEN4, val); in hi3660_phy_init()
88 /* enable phy ref clk */ in hi3660_phy_init()
91 ret = regmap_update_bits(priv->otg_bc, USBOTG3_CTRL0, mask, val); in hi3660_phy_init()
97 ret = regmap_update_bits(priv->otg_bc, USBOTG3_CTRL7, mask, val); in hi3660_phy_init()
103 ret = regmap_update_bits(priv->otg_bc, USBOTG3_CTRL2, mask, 0); in hi3660_phy_init()
110 /* deassert phy */ in hi3660_phy_init()
112 ret = regmap_write(priv->peri_crg, PERI_CRG_RSTDIS4, val); in hi3660_phy_init()
116 /* delay for phy deasserted */ in hi3660_phy_init()
122 ret = regmap_update_bits(priv->otg_bc, USBOTG3_CTRL3, mask, val); in hi3660_phy_init()
129 ret = regmap_write(priv->otg_bc, USBOTG3_CTRL4, in hi3660_phy_init()
130 priv->eye_diagram_param); in hi3660_phy_init()
136 dev_err(priv->dev, "failed to init phy ret: %d\n", ret); in hi3660_phy_init()
140 static int hi3660_phy_exit(struct phy *phy) in hi3660_phy_exit() argument
142 struct hi3660_priv *priv = phy_get_drvdata(phy); in hi3660_phy_exit()
146 /* assert phy */ in hi3660_phy_exit()
148 ret = regmap_write(priv->peri_crg, PERI_CRG_RSTEN4, val); in hi3660_phy_exit()
154 ret = regmap_write(priv->pctrl, PCTRL_PERI_CTRL3, val); in hi3660_phy_exit()
160 dev_err(priv->dev, "failed to exit phy ret: %d\n", ret); in hi3660_phy_exit()
173 struct device *dev = &pdev->dev; in hi3660_phy_probe()
174 struct phy *phy; in hi3660_phy_probe() local
179 return -ENOMEM; in hi3660_phy_probe()
181 priv->dev = dev; in hi3660_phy_probe()
182 priv->peri_crg = syscon_regmap_lookup_by_phandle(dev->of_node, in hi3660_phy_probe()
183 "hisilicon,pericrg-syscon"); in hi3660_phy_probe()
184 if (IS_ERR(priv->peri_crg)) { in hi3660_phy_probe()
185 dev_err(dev, "no hisilicon,pericrg-syscon\n"); in hi3660_phy_probe()
186 return PTR_ERR(priv->peri_crg); in hi3660_phy_probe()
189 priv->pctrl = syscon_regmap_lookup_by_phandle(dev->of_node, in hi3660_phy_probe()
190 "hisilicon,pctrl-syscon"); in hi3660_phy_probe()
191 if (IS_ERR(priv->pctrl)) { in hi3660_phy_probe()
192 dev_err(dev, "no hisilicon,pctrl-syscon\n"); in hi3660_phy_probe()
193 return PTR_ERR(priv->pctrl); in hi3660_phy_probe()
196 /* node of hi3660 phy is a sub-node of usb3_otg_bc */ in hi3660_phy_probe()
197 priv->otg_bc = syscon_node_to_regmap(dev->parent->of_node); in hi3660_phy_probe()
198 if (IS_ERR(priv->otg_bc)) { in hi3660_phy_probe()
199 dev_err(dev, "no hisilicon,usb3-otg-bc-syscon\n"); in hi3660_phy_probe()
200 return PTR_ERR(priv->otg_bc); in hi3660_phy_probe()
203 if (of_property_read_u32(dev->of_node, "hisilicon,eye-diagram-param", in hi3660_phy_probe()
204 &(priv->eye_diagram_param))) in hi3660_phy_probe()
205 priv->eye_diagram_param = HI3660_USB_DEFAULT_PHY_PARAM; in hi3660_phy_probe()
207 phy = devm_phy_create(dev, NULL, &hi3660_phy_ops); in hi3660_phy_probe()
208 if (IS_ERR(phy)) in hi3660_phy_probe()
209 return PTR_ERR(phy); in hi3660_phy_probe()
211 phy_set_drvdata(phy, priv); in hi3660_phy_probe()
217 {.compatible = "hisilicon,hi3660-usb-phy",},
225 .name = "hi3660-usb-phy",
233 MODULE_DESCRIPTION("Hilisicon Hi3660 USB3 PHY Driver");