• Home
  • Raw
  • Download

Lines Matching +full:ulpi +full:- +full:0

1 // SPDX-License-Identifier: GPL-2.0-only
6 #include <linux/ulpi/driver.h>
7 #include <linux/ulpi/regs.h>
16 #define ULPI_PWR_CLK_MNG_REG 0x88
17 # define ULPI_PWR_OTG_COMP_DISABLE BIT(0)
19 #define ULPI_MISC_A 0x96
21 # define ULPI_MISC_A_VBUSVLDEXT BIT(0)
30 struct ulpi *ulpi; member
49 if (!uphy->vbus_edev) { in qcom_usb_hs_phy_set_mode()
50 u8 val = 0; in qcom_usb_hs_phy_set_mode()
63 ret = ulpi_write(uphy->ulpi, ULPI_USB_INT_EN_RISE, val); in qcom_usb_hs_phy_set_mode()
66 ret = ulpi_write(uphy->ulpi, ULPI_USB_INT_EN_FALL, val); in qcom_usb_hs_phy_set_mode()
77 return -EINVAL; in qcom_usb_hs_phy_set_mode()
80 ret = ulpi_write(uphy->ulpi, ULPI_SET(ULPI_PWR_CLK_MNG_REG), in qcom_usb_hs_phy_set_mode()
84 ret = ulpi_write(uphy->ulpi, addr, ULPI_MISC_A_VBUSVLDEXTSEL); in qcom_usb_hs_phy_set_mode()
104 return ulpi_write(uphy->ulpi, addr, ULPI_MISC_A_VBUSVLDEXT); in qcom_usb_hs_phy_vbus_notifier()
110 struct ulpi *ulpi = uphy->ulpi; in qcom_usb_hs_phy_power_on() local
114 ret = clk_prepare_enable(uphy->ref_clk); in qcom_usb_hs_phy_power_on()
118 ret = clk_prepare_enable(uphy->sleep_clk); in qcom_usb_hs_phy_power_on()
122 ret = regulator_set_load(uphy->v1p8, 50000); in qcom_usb_hs_phy_power_on()
123 if (ret < 0) in qcom_usb_hs_phy_power_on()
126 ret = regulator_enable(uphy->v1p8); in qcom_usb_hs_phy_power_on()
130 ret = regulator_set_voltage_triplet(uphy->v3p3, 3050000, 3300000, in qcom_usb_hs_phy_power_on()
135 ret = regulator_set_load(uphy->v3p3, 50000); in qcom_usb_hs_phy_power_on()
136 if (ret < 0) in qcom_usb_hs_phy_power_on()
139 ret = regulator_enable(uphy->v3p3); in qcom_usb_hs_phy_power_on()
143 for (seq = uphy->init_seq; seq->addr; seq++) { in qcom_usb_hs_phy_power_on()
144 ret = ulpi_write(ulpi, ULPI_EXT_VENDOR_SPECIFIC + seq->addr, in qcom_usb_hs_phy_power_on()
145 seq->val); in qcom_usb_hs_phy_power_on()
150 if (uphy->reset) { in qcom_usb_hs_phy_power_on()
151 ret = reset_control_reset(uphy->reset); in qcom_usb_hs_phy_power_on()
156 if (uphy->vbus_edev) { in qcom_usb_hs_phy_power_on()
157 state = extcon_get_state(uphy->vbus_edev, EXTCON_USB); in qcom_usb_hs_phy_power_on()
159 qcom_usb_hs_phy_vbus_notifier(&uphy->vbus_notify, state, in qcom_usb_hs_phy_power_on()
160 uphy->vbus_edev); in qcom_usb_hs_phy_power_on()
161 ret = extcon_register_notifier(uphy->vbus_edev, EXTCON_USB, in qcom_usb_hs_phy_power_on()
162 &uphy->vbus_notify); in qcom_usb_hs_phy_power_on()
167 return 0; in qcom_usb_hs_phy_power_on()
169 regulator_disable(uphy->v3p3); in qcom_usb_hs_phy_power_on()
171 regulator_disable(uphy->v1p8); in qcom_usb_hs_phy_power_on()
173 clk_disable_unprepare(uphy->sleep_clk); in qcom_usb_hs_phy_power_on()
175 clk_disable_unprepare(uphy->ref_clk); in qcom_usb_hs_phy_power_on()
183 if (uphy->vbus_edev) in qcom_usb_hs_phy_power_off()
184 extcon_unregister_notifier(uphy->vbus_edev, EXTCON_USB, in qcom_usb_hs_phy_power_off()
185 &uphy->vbus_notify); in qcom_usb_hs_phy_power_off()
186 regulator_disable(uphy->v3p3); in qcom_usb_hs_phy_power_off()
187 regulator_disable(uphy->v1p8); in qcom_usb_hs_phy_power_off()
188 clk_disable_unprepare(uphy->sleep_clk); in qcom_usb_hs_phy_power_off()
189 clk_disable_unprepare(uphy->ref_clk); in qcom_usb_hs_phy_power_off()
191 return 0; in qcom_usb_hs_phy_power_off()
201 static int qcom_usb_hs_phy_probe(struct ulpi *ulpi) in qcom_usb_hs_phy_probe() argument
211 uphy = devm_kzalloc(&ulpi->dev, sizeof(*uphy), GFP_KERNEL); in qcom_usb_hs_phy_probe()
213 return -ENOMEM; in qcom_usb_hs_phy_probe()
214 ulpi_set_drvdata(ulpi, uphy); in qcom_usb_hs_phy_probe()
215 uphy->ulpi = ulpi; in qcom_usb_hs_phy_probe()
217 size = of_property_count_u8_elems(ulpi->dev.of_node, "qcom,init-seq"); in qcom_usb_hs_phy_probe()
218 if (size < 0) in qcom_usb_hs_phy_probe()
219 size = 0; in qcom_usb_hs_phy_probe()
220 uphy->init_seq = devm_kmalloc_array(&ulpi->dev, (size / 2) + 1, in qcom_usb_hs_phy_probe()
221 sizeof(*uphy->init_seq), GFP_KERNEL); in qcom_usb_hs_phy_probe()
222 if (!uphy->init_seq) in qcom_usb_hs_phy_probe()
223 return -ENOMEM; in qcom_usb_hs_phy_probe()
224 ret = of_property_read_u8_array(ulpi->dev.of_node, "qcom,init-seq", in qcom_usb_hs_phy_probe()
225 (u8 *)uphy->init_seq, size); in qcom_usb_hs_phy_probe()
229 uphy->init_seq[size / 2].addr = uphy->init_seq[size / 2].val = 0; in qcom_usb_hs_phy_probe()
231 uphy->ref_clk = clk = devm_clk_get(&ulpi->dev, "ref"); in qcom_usb_hs_phy_probe()
235 uphy->sleep_clk = clk = devm_clk_get(&ulpi->dev, "sleep"); in qcom_usb_hs_phy_probe()
239 uphy->v1p8 = reg = devm_regulator_get(&ulpi->dev, "v1p8"); in qcom_usb_hs_phy_probe()
243 uphy->v3p3 = reg = devm_regulator_get(&ulpi->dev, "v3p3"); in qcom_usb_hs_phy_probe()
247 uphy->reset = reset = devm_reset_control_get(&ulpi->dev, "por"); in qcom_usb_hs_phy_probe()
249 if (PTR_ERR(reset) == -EPROBE_DEFER) in qcom_usb_hs_phy_probe()
251 uphy->reset = NULL; in qcom_usb_hs_phy_probe()
254 uphy->phy = devm_phy_create(&ulpi->dev, ulpi->dev.of_node, in qcom_usb_hs_phy_probe()
256 if (IS_ERR(uphy->phy)) in qcom_usb_hs_phy_probe()
257 return PTR_ERR(uphy->phy); in qcom_usb_hs_phy_probe()
259 uphy->vbus_edev = extcon_get_edev_by_phandle(&ulpi->dev, 0); in qcom_usb_hs_phy_probe()
260 if (IS_ERR(uphy->vbus_edev)) { in qcom_usb_hs_phy_probe()
261 if (PTR_ERR(uphy->vbus_edev) != -ENODEV) in qcom_usb_hs_phy_probe()
262 return PTR_ERR(uphy->vbus_edev); in qcom_usb_hs_phy_probe()
263 uphy->vbus_edev = NULL; in qcom_usb_hs_phy_probe()
266 uphy->vbus_notify.notifier_call = qcom_usb_hs_phy_vbus_notifier; in qcom_usb_hs_phy_probe()
267 phy_set_drvdata(uphy->phy, uphy); in qcom_usb_hs_phy_probe()
269 p = devm_of_phy_provider_register(&ulpi->dev, of_phy_simple_xlate); in qcom_usb_hs_phy_probe()
274 { .compatible = "qcom,usb-hs-phy", },