• Home
  • Raw
  • Download

Lines Matching full:phy

3  * omap-usb2.c - USB PHY, talking to USB controller on TI SoCs.
17 #include <linux/phy/omap_control_phy.h>
18 #include <linux/phy/omap_usb.h>
19 #include <linux/phy/phy.h>
54 struct usb_phy phy; member
70 #define phy_to_omapusb(x) container_of((x), struct omap_usb, phy)
93 * this phy
94 * @comparator - the companion phy(comparator) for this phy
96 * The phy companion driver should call this API passing the phy_companion
97 * filled with set_vbus and start_srp to be used by usb phy.
99 * For use by phy companion driver
103 struct omap_usb *phy; in omap_usb2_set_comparator() local
109 phy = phy_to_omapusb(x); in omap_usb2_set_comparator()
110 phy->comparator = comparator; in omap_usb2_set_comparator()
117 struct omap_usb *phy = phy_to_omapusb(otg->usb_phy); in omap_usb_set_vbus() local
119 if (!phy->comparator) in omap_usb_set_vbus()
122 return phy->comparator->set_vbus(phy->comparator, enabled); in omap_usb_set_vbus()
127 struct omap_usb *phy = phy_to_omapusb(otg->usb_phy); in omap_usb_start_srp() local
129 if (!phy->comparator) in omap_usb_start_srp()
132 return phy->comparator->start_srp(phy->comparator); in omap_usb_start_srp()
154 static int omap_usb_phy_power(struct omap_usb *phy, int on) in omap_usb_phy_power() argument
159 if (!phy->syscon_phy_power) { in omap_usb_phy_power()
160 omap_control_phy_power(phy->control_dev, on); in omap_usb_phy_power()
165 val = phy->power_on; in omap_usb_phy_power()
167 val = phy->power_off; in omap_usb_phy_power()
169 ret = regmap_update_bits(phy->syscon_phy_power, phy->power_reg, in omap_usb_phy_power()
170 phy->mask, val); in omap_usb_phy_power()
174 static int omap_usb_power_off(struct phy *x) in omap_usb_power_off()
176 struct omap_usb *phy = phy_get_drvdata(x); in omap_usb_power_off() local
178 return omap_usb_phy_power(phy, false); in omap_usb_power_off()
181 static int omap_usb_power_on(struct phy *x) in omap_usb_power_on()
183 struct omap_usb *phy = phy_get_drvdata(x); in omap_usb_power_on() local
185 return omap_usb_phy_power(phy, true); in omap_usb_power_on()
188 static int omap_usb2_disable_clocks(struct omap_usb *phy) in omap_usb2_disable_clocks() argument
190 clk_disable_unprepare(phy->wkupclk); in omap_usb2_disable_clocks()
191 if (!IS_ERR(phy->optclk)) in omap_usb2_disable_clocks()
192 clk_disable_unprepare(phy->optclk); in omap_usb2_disable_clocks()
197 static int omap_usb2_enable_clocks(struct omap_usb *phy) in omap_usb2_enable_clocks() argument
201 ret = clk_prepare_enable(phy->wkupclk); in omap_usb2_enable_clocks()
203 dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret); in omap_usb2_enable_clocks()
207 if (!IS_ERR(phy->optclk)) { in omap_usb2_enable_clocks()
208 ret = clk_prepare_enable(phy->optclk); in omap_usb2_enable_clocks()
210 dev_err(phy->dev, "Failed to enable optclk %d\n", ret); in omap_usb2_enable_clocks()
218 clk_disable_unprepare(phy->wkupclk); in omap_usb2_enable_clocks()
224 static int omap_usb_init(struct phy *x) in omap_usb_init()
226 struct omap_usb *phy = phy_get_drvdata(x); in omap_usb_init() local
229 omap_usb2_enable_clocks(phy); in omap_usb_init()
231 if (phy->flags & OMAP_USB2_CALIBRATE_FALSE_DISCONNECT) { in omap_usb_init()
234 * Reduce the sensitivity of internal PHY by enabling the in omap_usb_init()
240 val = omap_usb_readl(phy->phy_base, USB2PHY_ANA_CONFIG1); in omap_usb_init()
242 omap_usb_writel(phy->phy_base, USB2PHY_ANA_CONFIG1, val); in omap_usb_init()
245 if (phy->flags & OMAP_USB2_DISABLE_CHRG_DET) { in omap_usb_init()
246 val = omap_usb_readl(phy->phy_base, USB2PHY_CHRG_DET); in omap_usb_init()
249 omap_usb_writel(phy->phy_base, USB2PHY_CHRG_DET, val); in omap_usb_init()
255 static int omap_usb_exit(struct phy *x) in omap_usb_exit()
257 struct omap_usb *phy = phy_get_drvdata(x); in omap_usb_exit() local
259 return omap_usb2_disable_clocks(phy); in omap_usb_exit()
345 static void omap_usb2_init_errata(struct omap_usb *phy) in omap_usb2_init_errata() argument
362 phy->flags |= OMAP_USB2_DISABLE_CHRG_DET; in omap_usb2_init_errata()
367 struct omap_usb *phy; in omap_usb2_probe() local
368 struct phy *generic_phy; in omap_usb2_probe()
385 phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL); in omap_usb2_probe()
386 if (!phy) in omap_usb2_probe()
393 phy->dev = &pdev->dev; in omap_usb2_probe()
395 phy->phy.dev = phy->dev; in omap_usb2_probe()
396 phy->phy.label = phy_data->label; in omap_usb2_probe()
397 phy->phy.otg = otg; in omap_usb2_probe()
398 phy->phy.type = USB_PHY_TYPE_USB2; in omap_usb2_probe()
399 phy->mask = phy_data->mask; in omap_usb2_probe()
400 phy->power_on = phy_data->power_on; in omap_usb2_probe()
401 phy->power_off = phy_data->power_off; in omap_usb2_probe()
402 phy->flags = phy_data->flags; in omap_usb2_probe()
404 omap_usb2_init_errata(phy); in omap_usb2_probe()
407 phy->phy_base = devm_ioremap_resource(&pdev->dev, res); in omap_usb2_probe()
408 if (IS_ERR(phy->phy_base)) in omap_usb2_probe()
409 return PTR_ERR(phy->phy_base); in omap_usb2_probe()
411 phy->syscon_phy_power = syscon_regmap_lookup_by_phandle(node, in omap_usb2_probe()
412 "syscon-phy-power"); in omap_usb2_probe()
413 if (IS_ERR(phy->syscon_phy_power)) { in omap_usb2_probe()
415 "can't get syscon-phy-power, using control device\n"); in omap_usb2_probe()
416 phy->syscon_phy_power = NULL; in omap_usb2_probe()
430 phy->control_dev = &control_pdev->dev; in omap_usb2_probe()
433 "syscon-phy-power", 1, in omap_usb2_probe()
434 &phy->power_reg)) { in omap_usb2_probe()
441 phy->wkupclk = devm_clk_get(phy->dev, "wkupclk"); in omap_usb2_probe()
442 if (IS_ERR(phy->wkupclk)) { in omap_usb2_probe()
443 if (PTR_ERR(phy->wkupclk) == -EPROBE_DEFER) in omap_usb2_probe()
447 PTR_ERR(phy->wkupclk)); in omap_usb2_probe()
448 phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k"); in omap_usb2_probe()
450 if (IS_ERR(phy->wkupclk)) { in omap_usb2_probe()
451 if (PTR_ERR(phy->wkupclk) != -EPROBE_DEFER) in omap_usb2_probe()
453 return PTR_ERR(phy->wkupclk); in omap_usb2_probe()
460 phy->optclk = devm_clk_get(phy->dev, "refclk"); in omap_usb2_probe()
461 if (IS_ERR(phy->optclk)) { in omap_usb2_probe()
462 if (PTR_ERR(phy->optclk) == -EPROBE_DEFER) in omap_usb2_probe()
466 phy->optclk = devm_clk_get(phy->dev, "usb_otg_ss_refclk960m"); in omap_usb2_probe()
468 if (IS_ERR(phy->optclk)) { in omap_usb2_probe()
469 if (PTR_ERR(phy->optclk) != -EPROBE_DEFER) { in omap_usb2_probe()
485 otg->usb_phy = &phy->phy; in omap_usb2_probe()
487 platform_set_drvdata(pdev, phy); in omap_usb2_probe()
488 pm_runtime_enable(phy->dev); in omap_usb2_probe()
490 generic_phy = devm_phy_create(phy->dev, NULL, &ops); in omap_usb2_probe()
492 pm_runtime_disable(phy->dev); in omap_usb2_probe()
496 phy_set_drvdata(generic_phy, phy); in omap_usb2_probe()
499 phy_provider = devm_of_phy_provider_register(phy->dev, in omap_usb2_probe()
502 pm_runtime_disable(phy->dev); in omap_usb2_probe()
506 usb_add_phy_dev(&phy->phy); in omap_usb2_probe()
513 struct omap_usb *phy = platform_get_drvdata(pdev); in omap_usb2_remove() local
515 usb_remove_phy(&phy->phy); in omap_usb2_remove()
516 pm_runtime_disable(phy->dev); in omap_usb2_remove()
534 MODULE_DESCRIPTION("OMAP USB2 phy driver");