Lines Matching +full:d +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0
221 static void set_pts(struct tegra_usb_phy *phy, u8 pts_val) in set_pts() argument
223 void __iomem *base = phy->regs; in set_pts()
226 if (phy->soc_config->has_hostpc) { in set_pts()
240 static void set_phcd(struct tegra_usb_phy *phy, bool enable) in set_phcd() argument
242 void __iomem *base = phy->regs; in set_phcd()
245 if (phy->soc_config->has_hostpc) { in set_phcd()
262 static int utmip_pad_open(struct tegra_usb_phy *phy) in utmip_pad_open() argument
266 ret = clk_prepare_enable(phy->pad_clk); in utmip_pad_open()
268 dev_err(phy->u_phy.dev, in utmip_pad_open()
269 "Failed to enable UTMI-pads clock: %d\n", ret); in utmip_pad_open()
275 ret = reset_control_deassert(phy->pad_rst); in utmip_pad_open()
277 dev_err(phy->u_phy.dev, in utmip_pad_open()
278 "Failed to initialize UTMI-pads reset: %d\n", ret); in utmip_pad_open()
282 ret = reset_control_assert(phy->pad_rst); in utmip_pad_open()
284 dev_err(phy->u_phy.dev, in utmip_pad_open()
285 "Failed to assert UTMI-pads reset: %d\n", ret); in utmip_pad_open()
291 ret = reset_control_deassert(phy->pad_rst); in utmip_pad_open()
293 dev_err(phy->u_phy.dev, in utmip_pad_open()
294 "Failed to deassert UTMI-pads reset: %d\n", ret); in utmip_pad_open()
298 clk_disable_unprepare(phy->pad_clk); in utmip_pad_open()
303 static int utmip_pad_close(struct tegra_usb_phy *phy) in utmip_pad_close() argument
307 ret = clk_prepare_enable(phy->pad_clk); in utmip_pad_close()
309 dev_err(phy->u_phy.dev, in utmip_pad_close()
310 "Failed to enable UTMI-pads clock: %d\n", ret); in utmip_pad_close()
314 ret = reset_control_assert(phy->pad_rst); in utmip_pad_close()
316 dev_err(phy->u_phy.dev, in utmip_pad_close()
317 "Failed to assert UTMI-pads reset: %d\n", ret); in utmip_pad_close()
321 clk_disable_unprepare(phy->pad_clk); in utmip_pad_close()
326 static int utmip_pad_power_on(struct tegra_usb_phy *phy) in utmip_pad_power_on() argument
328 struct tegra_utmip_config *config = phy->config; in utmip_pad_power_on()
329 void __iomem *base = phy->pad_regs; in utmip_pad_power_on()
333 err = clk_prepare_enable(phy->pad_clk); in utmip_pad_power_on()
343 if (phy->soc_config->requires_extra_tuning_parameters) { in utmip_pad_power_on()
348 val |= UTMIP_HSSQUELCH_LEVEL(config->hssquelch_level); in utmip_pad_power_on()
349 val |= UTMIP_HSDISCON_LEVEL(config->hsdiscon_level); in utmip_pad_power_on()
350 val |= UTMIP_HSDISCON_LEVEL_MSB(config->hsdiscon_level); in utmip_pad_power_on()
355 if (phy->pad_wakeup) { in utmip_pad_power_on()
356 phy->pad_wakeup = false; in utmip_pad_power_on()
357 utmip_pad_count--; in utmip_pad_power_on()
362 clk_disable_unprepare(phy->pad_clk); in utmip_pad_power_on()
367 static int utmip_pad_power_off(struct tegra_usb_phy *phy) in utmip_pad_power_off() argument
369 void __iomem *base = phy->pad_regs; in utmip_pad_power_off()
373 ret = clk_prepare_enable(phy->pad_clk); in utmip_pad_power_off()
380 dev_err(phy->u_phy.dev, "UTMIP pad already powered off\n"); in utmip_pad_power_off()
381 ret = -EINVAL; in utmip_pad_power_off()
387 * to save power if wake is enabled, but the VBUS-change detection in utmip_pad_power_off()
388 * method is board-specific and these circuits may need to be enabled in utmip_pad_power_off()
391 if (phy->wakeup_enabled) { in utmip_pad_power_off()
392 phy->pad_wakeup = true; in utmip_pad_power_off()
396 if (--utmip_pad_count == 0) { in utmip_pad_power_off()
404 clk_disable_unprepare(phy->pad_clk); in utmip_pad_power_off()
417 static void utmi_phy_clk_disable(struct tegra_usb_phy *phy) in utmi_phy_clk_disable() argument
419 void __iomem *base = phy->regs; in utmi_phy_clk_disable()
423 * The USB driver may have already initiated the phy clock in utmi_phy_clk_disable()
430 if (phy->is_legacy_phy) { in utmi_phy_clk_disable()
441 set_phcd(phy, true); in utmi_phy_clk_disable()
445 dev_err(phy->u_phy.dev, in utmi_phy_clk_disable()
446 "Timeout waiting for PHY to stabilize on disable\n"); in utmi_phy_clk_disable()
449 static void utmi_phy_clk_enable(struct tegra_usb_phy *phy) in utmi_phy_clk_enable() argument
451 void __iomem *base = phy->regs; in utmi_phy_clk_enable()
455 * The USB driver may have already initiated the phy clock in utmi_phy_clk_enable()
463 if (phy->is_legacy_phy) { in utmi_phy_clk_enable()
474 set_phcd(phy, false); in utmi_phy_clk_enable()
479 dev_err(phy->u_phy.dev, in utmi_phy_clk_enable()
480 "Timeout waiting for PHY to stabilize on enable\n"); in utmi_phy_clk_enable()
483 static int utmi_phy_power_on(struct tegra_usb_phy *phy) in utmi_phy_power_on() argument
485 struct tegra_utmip_config *config = phy->config; in utmi_phy_power_on()
486 void __iomem *base = phy->regs; in utmi_phy_power_on()
494 if (phy->is_legacy_phy) { in utmi_phy_power_on()
506 val |= UTMIP_IDLE_WAIT(config->idle_wait_delay); in utmi_phy_power_on()
507 val |= UTMIP_ELASTIC_LIMIT(config->elastic_limit); in utmi_phy_power_on()
512 val |= UTMIP_HS_SYNC_START_DLY(config->hssync_start_delay); in utmi_phy_power_on()
517 val |= UTMIP_BIAS_DEBOUNCE_A(phy->freq->debounce); in utmi_phy_power_on()
524 if (!phy->soc_config->utmi_pll_config_in_car_module) { in utmi_phy_power_on()
528 val |= UTMIP_PLL_ACTIVE_DLY_COUNT(phy->freq->active_delay) | in utmi_phy_power_on()
529 UTMIP_PLLU_STABLE_COUNT(phy->freq->stable_count); in utmi_phy_power_on()
535 val |= UTMIP_XTAL_FREQ_COUNT(phy->freq->xtal_freq_count) | in utmi_phy_power_on()
536 UTMIP_PLLU_ENABLE_DLY_COUNT(phy->freq->enable_delay); in utmi_phy_power_on()
544 if (phy->mode != USB_DR_MODE_HOST) { in utmi_phy_power_on()
568 err = utmip_pad_power_on(phy); in utmi_phy_power_on()
578 if (!config->xcvr_setup_use_fuses) { in utmi_phy_power_on()
579 val |= UTMIP_XCVR_SETUP(config->xcvr_setup); in utmi_phy_power_on()
580 val |= UTMIP_XCVR_SETUP_MSB(config->xcvr_setup); in utmi_phy_power_on()
582 val |= UTMIP_XCVR_LSFSLEW(config->xcvr_lsfslew); in utmi_phy_power_on()
583 val |= UTMIP_XCVR_LSRSLEW(config->xcvr_lsrslew); in utmi_phy_power_on()
585 if (phy->soc_config->requires_extra_tuning_parameters) { in utmi_phy_power_on()
587 val |= UTMIP_XCVR_HSSLEW(config->xcvr_hsslew); in utmi_phy_power_on()
588 val |= UTMIP_XCVR_HSSLEW_MSB(config->xcvr_hsslew); in utmi_phy_power_on()
595 val |= UTMIP_XCVR_TERM_RANGE_ADJ(config->term_range_adj); in utmi_phy_power_on()
604 if (config->xcvr_setup_use_fuses) in utmi_phy_power_on()
610 if (!phy->is_legacy_phy) { in utmi_phy_power_on()
620 if (phy->is_legacy_phy) { in utmi_phy_power_on()
631 utmi_phy_clk_enable(phy); in utmi_phy_power_on()
633 if (phy->soc_config->requires_usbmode_setup) { in utmi_phy_power_on()
636 if (phy->mode == USB_DR_MODE_HOST) in utmi_phy_power_on()
643 if (!phy->is_legacy_phy) in utmi_phy_power_on()
644 set_pts(phy, 0); in utmi_phy_power_on()
649 static int utmi_phy_power_off(struct tegra_usb_phy *phy) in utmi_phy_power_off() argument
651 void __iomem *base = phy->regs; in utmi_phy_power_off()
656 * otherwise PHY will immediately wake up from suspend. in utmi_phy_power_off()
658 if (phy->wakeup_enabled && phy->mode != USB_DR_MODE_HOST) in utmi_phy_power_off()
663 utmi_phy_clk_disable(phy); in utmi_phy_power_off()
665 /* PHY won't resume if reset is asserted */ in utmi_phy_power_off()
666 if (!phy->wakeup_enabled) { in utmi_phy_power_off()
676 if (!phy->wakeup_enabled) { in utmi_phy_power_off()
688 if (phy->wakeup_enabled) { in utmi_phy_power_off()
699 if (phy->mode != USB_DR_MODE_HOST) { in utmi_phy_power_off()
711 return utmip_pad_power_off(phy); in utmi_phy_power_off()
714 static int ulpi_phy_power_on(struct tegra_usb_phy *phy) in ulpi_phy_power_on() argument
716 void __iomem *base = phy->regs; in ulpi_phy_power_on()
720 gpiod_set_value_cansleep(phy->reset_gpio, 1); in ulpi_phy_power_on()
722 err = clk_prepare_enable(phy->clk); in ulpi_phy_power_on()
728 gpiod_set_value_cansleep(phy->reset_gpio, 0); in ulpi_phy_power_on()
759 err = usb_phy_io_write(phy->ulpi, 0x40, 0x08); in ulpi_phy_power_on()
761 dev_err(phy->u_phy.dev, "ULPI write failed: %d\n", err); in ulpi_phy_power_on()
765 err = usb_phy_io_write(phy->ulpi, 0x80, 0x0B); in ulpi_phy_power_on()
767 dev_err(phy->u_phy.dev, "ULPI write failed: %d\n", err); in ulpi_phy_power_on()
783 clk_disable_unprepare(phy->clk); in ulpi_phy_power_on()
788 static int ulpi_phy_power_off(struct tegra_usb_phy *phy) in ulpi_phy_power_off() argument
790 gpiod_set_value_cansleep(phy->reset_gpio, 1); in ulpi_phy_power_off()
792 clk_disable_unprepare(phy->clk); in ulpi_phy_power_off()
795 * Wakeup currently unimplemented for ULPI, thus PHY needs to be in ulpi_phy_power_off()
796 * force-resumed. in ulpi_phy_power_off()
798 if (WARN_ON_ONCE(phy->wakeup_enabled)) { in ulpi_phy_power_off()
799 ulpi_phy_power_on(phy); in ulpi_phy_power_off()
800 return -EOPNOTSUPP; in ulpi_phy_power_off()
806 static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy) in tegra_usb_phy_power_on() argument
810 if (phy->powered_on) in tegra_usb_phy_power_on()
813 if (phy->is_ulpi_phy) in tegra_usb_phy_power_on()
814 err = ulpi_phy_power_on(phy); in tegra_usb_phy_power_on()
816 err = utmi_phy_power_on(phy); in tegra_usb_phy_power_on()
820 phy->powered_on = true; in tegra_usb_phy_power_on()
822 /* Let PHY settle down */ in tegra_usb_phy_power_on()
828 static int tegra_usb_phy_power_off(struct tegra_usb_phy *phy) in tegra_usb_phy_power_off() argument
832 if (!phy->powered_on) in tegra_usb_phy_power_off()
835 if (phy->is_ulpi_phy) in tegra_usb_phy_power_off()
836 err = ulpi_phy_power_off(phy); in tegra_usb_phy_power_off()
838 err = utmi_phy_power_off(phy); in tegra_usb_phy_power_off()
842 phy->powered_on = false; in tegra_usb_phy_power_off()
849 struct tegra_usb_phy *phy = to_tegra_usb_phy(u_phy); in tegra_usb_phy_shutdown() local
851 if (WARN_ON(!phy->freq)) in tegra_usb_phy_shutdown()
855 tegra_usb_phy_power_off(phy); in tegra_usb_phy_shutdown()
857 if (!phy->is_ulpi_phy) in tegra_usb_phy_shutdown()
858 utmip_pad_close(phy); in tegra_usb_phy_shutdown()
860 regulator_disable(phy->vbus); in tegra_usb_phy_shutdown()
861 clk_disable_unprepare(phy->pll_u); in tegra_usb_phy_shutdown()
863 phy->freq = NULL; in tegra_usb_phy_shutdown()
869 struct tegra_usb_phy *phy = data; in tegra_usb_phy_isr() local
870 void __iomem *base = phy->regs; in tegra_usb_phy_isr()
873 * The PHY interrupt also wakes the USB controller driver since in tegra_usb_phy_isr()
874 * interrupt is shared. We don't do anything in the PHY driver, in tegra_usb_phy_isr()
885 struct tegra_usb_phy *phy = to_tegra_usb_phy(u_phy); in tegra_usb_phy_set_wakeup() local
886 void __iomem *base = phy->regs; in tegra_usb_phy_set_wakeup()
890 if (phy->wakeup_enabled && phy->mode != USB_DR_MODE_HOST && in tegra_usb_phy_set_wakeup()
891 phy->irq > 0) { in tegra_usb_phy_set_wakeup()
892 disable_irq(phy->irq); in tegra_usb_phy_set_wakeup()
898 enable_irq(phy->irq); in tegra_usb_phy_set_wakeup()
900 free_irq(phy->irq, phy); in tegra_usb_phy_set_wakeup()
902 phy->wakeup_enabled = false; in tegra_usb_phy_set_wakeup()
905 if (enable && phy->mode != USB_DR_MODE_HOST && phy->irq > 0) { in tegra_usb_phy_set_wakeup()
906 ret = request_irq(phy->irq, tegra_usb_phy_isr, IRQF_SHARED, in tegra_usb_phy_set_wakeup()
907 dev_name(phy->u_phy.dev), phy); in tegra_usb_phy_set_wakeup()
909 disable_irq(phy->irq); in tegra_usb_phy_set_wakeup()
913 * generated. The ID-change event requires to have in tegra_usb_phy_set_wakeup()
920 enable_irq(phy->irq); in tegra_usb_phy_set_wakeup()
922 dev_err(phy->u_phy.dev, in tegra_usb_phy_set_wakeup()
923 "Failed to request interrupt: %d", ret); in tegra_usb_phy_set_wakeup()
928 phy->wakeup_enabled = enable; in tegra_usb_phy_set_wakeup()
935 struct tegra_usb_phy *phy = to_tegra_usb_phy(u_phy); in tegra_usb_phy_set_suspend() local
938 if (WARN_ON(!phy->freq)) in tegra_usb_phy_set_suspend()
939 return -EINVAL; in tegra_usb_phy_set_suspend()
942 * PHY is sharing IRQ with the CI driver, hence here we either in tegra_usb_phy_set_suspend()
943 * disable interrupt for both PHY and CI or for CI only. The in tegra_usb_phy_set_suspend()
948 if (phy->irq > 0) in tegra_usb_phy_set_suspend()
949 disable_irq(phy->irq); in tegra_usb_phy_set_suspend()
952 ret = tegra_usb_phy_power_off(phy); in tegra_usb_phy_set_suspend()
954 ret = tegra_usb_phy_power_on(phy); in tegra_usb_phy_set_suspend()
956 if (phy->irq > 0) in tegra_usb_phy_set_suspend()
957 enable_irq(phy->irq); in tegra_usb_phy_set_suspend()
962 static int tegra_usb_phy_configure_pmc(struct tegra_usb_phy *phy) in tegra_usb_phy_configure_pmc() argument
966 /* older device-trees don't have PMC regmap */ in tegra_usb_phy_configure_pmc()
967 if (!phy->pmc_regmap) in tegra_usb_phy_configure_pmc()
975 if (!phy->soc_config->requires_pmc_ao_power_up) in tegra_usb_phy_configure_pmc()
978 /* enable VBUS wake-up detector */ in tegra_usb_phy_configure_pmc()
979 if (phy->mode != USB_DR_MODE_HOST) in tegra_usb_phy_configure_pmc()
980 val |= VBUS_WAKEUP_PD_P0 << phy->instance * 4; in tegra_usb_phy_configure_pmc()
982 /* enable ID-pin ACC detector for OTG mode switching */ in tegra_usb_phy_configure_pmc()
983 if (phy->mode == USB_DR_MODE_OTG) in tegra_usb_phy_configure_pmc()
984 val |= ID_PD_P0 << phy->instance * 4; in tegra_usb_phy_configure_pmc()
987 err = regmap_set_bits(phy->pmc_regmap, PMC_USB_AO, val); in tegra_usb_phy_configure_pmc()
989 dev_err(phy->u_phy.dev, "Failed to disable PMC AO: %d\n", err); in tegra_usb_phy_configure_pmc()
996 err = regmap_clear_bits(phy->pmc_regmap, PMC_USB_AO, val); in tegra_usb_phy_configure_pmc()
998 dev_err(phy->u_phy.dev, "Failed to enable PMC AO: %d\n", err); in tegra_usb_phy_configure_pmc()
1010 struct tegra_usb_phy *phy = to_tegra_usb_phy(u_phy); in tegra_usb_phy_init() local
1015 if (WARN_ON(phy->freq)) in tegra_usb_phy_init()
1018 err = clk_prepare_enable(phy->pll_u); in tegra_usb_phy_init()
1022 parent_rate = clk_get_rate(clk_get_parent(phy->pll_u)); in tegra_usb_phy_init()
1025 phy->freq = &tegra_freq_table[i]; in tegra_usb_phy_init()
1029 if (!phy->freq) { in tegra_usb_phy_init()
1030 dev_err(phy->u_phy.dev, "Invalid pll_u parent rate %ld\n", in tegra_usb_phy_init()
1032 err = -EINVAL; in tegra_usb_phy_init()
1036 err = regulator_enable(phy->vbus); in tegra_usb_phy_init()
1038 dev_err(phy->u_phy.dev, in tegra_usb_phy_init()
1039 "Failed to enable USB VBUS regulator: %d\n", err); in tegra_usb_phy_init()
1043 if (!phy->is_ulpi_phy) { in tegra_usb_phy_init()
1044 err = utmip_pad_open(phy); in tegra_usb_phy_init()
1049 err = tegra_usb_phy_configure_pmc(phy); in tegra_usb_phy_init()
1053 err = tegra_usb_phy_power_on(phy); in tegra_usb_phy_init()
1060 if (!phy->is_ulpi_phy) in tegra_usb_phy_init()
1061 utmip_pad_close(phy); in tegra_usb_phy_init()
1064 regulator_disable(phy->vbus); in tegra_usb_phy_init()
1067 clk_disable_unprepare(phy->pll_u); in tegra_usb_phy_init()
1069 phy->freq = NULL; in tegra_usb_phy_init()
1080 err = of_property_read_u32(pdev->dev.of_node, param, &value); in read_utmi_param()
1082 dev_err(&pdev->dev, in read_utmi_param()
1083 "Failed to read USB UTMI parameter %s: %d\n", in read_utmi_param()
1098 tegra_phy->is_ulpi_phy = false; in utmi_phy_probe()
1102 dev_err(&pdev->dev, "Failed to get UTMI pad regs\n"); in utmi_phy_probe()
1103 return -ENXIO; in utmi_phy_probe()
1110 tegra_phy->pad_regs = devm_ioremap(&pdev->dev, res->start, in utmi_phy_probe()
1112 if (!tegra_phy->pad_regs) { in utmi_phy_probe()
1113 dev_err(&pdev->dev, "Failed to remap UTMI pad regs\n"); in utmi_phy_probe()
1114 return -ENOMEM; in utmi_phy_probe()
1117 tegra_phy->config = devm_kzalloc(&pdev->dev, sizeof(*config), in utmi_phy_probe()
1119 if (!tegra_phy->config) in utmi_phy_probe()
1120 return -ENOMEM; in utmi_phy_probe()
1122 config = tegra_phy->config; in utmi_phy_probe()
1124 err = read_utmi_param(pdev, "nvidia,hssync-start-delay", in utmi_phy_probe()
1125 &config->hssync_start_delay); in utmi_phy_probe()
1129 err = read_utmi_param(pdev, "nvidia,elastic-limit", in utmi_phy_probe()
1130 &config->elastic_limit); in utmi_phy_probe()
1134 err = read_utmi_param(pdev, "nvidia,idle-wait-delay", in utmi_phy_probe()
1135 &config->idle_wait_delay); in utmi_phy_probe()
1139 err = read_utmi_param(pdev, "nvidia,term-range-adj", in utmi_phy_probe()
1140 &config->term_range_adj); in utmi_phy_probe()
1144 err = read_utmi_param(pdev, "nvidia,xcvr-lsfslew", in utmi_phy_probe()
1145 &config->xcvr_lsfslew); in utmi_phy_probe()
1149 err = read_utmi_param(pdev, "nvidia,xcvr-lsrslew", in utmi_phy_probe()
1150 &config->xcvr_lsrslew); in utmi_phy_probe()
1154 if (tegra_phy->soc_config->requires_extra_tuning_parameters) { in utmi_phy_probe()
1155 err = read_utmi_param(pdev, "nvidia,xcvr-hsslew", in utmi_phy_probe()
1156 &config->xcvr_hsslew); in utmi_phy_probe()
1160 err = read_utmi_param(pdev, "nvidia,hssquelch-level", in utmi_phy_probe()
1161 &config->hssquelch_level); in utmi_phy_probe()
1165 err = read_utmi_param(pdev, "nvidia,hsdiscon-level", in utmi_phy_probe()
1166 &config->hsdiscon_level); in utmi_phy_probe()
1171 config->xcvr_setup_use_fuses = of_property_read_bool( in utmi_phy_probe()
1172 pdev->dev.of_node, "nvidia,xcvr-setup-use-fuses"); in utmi_phy_probe()
1174 if (!config->xcvr_setup_use_fuses) { in utmi_phy_probe()
1175 err = read_utmi_param(pdev, "nvidia,xcvr-setup", in utmi_phy_probe()
1176 &config->xcvr_setup); in utmi_phy_probe()
1190 struct tegra_usb_phy *phy) in tegra_usb_phy_parse_pmc() argument
1196 err = of_parse_phandle_with_fixed_args(dev->of_node, "nvidia,pmc", in tegra_usb_phy_parse_pmc()
1199 if (err != -ENOENT) in tegra_usb_phy_parse_pmc()
1202 dev_warn_once(dev, "nvidia,pmc is missing, please update your device-tree\n"); in tegra_usb_phy_parse_pmc()
1209 return -ENODEV; in tegra_usb_phy_parse_pmc()
1212 &pmc_pdev->dev); in tegra_usb_phy_parse_pmc()
1217 return -EPROBE_DEFER; in tegra_usb_phy_parse_pmc()
1219 phy->pmc_regmap = dev_get_regmap(&pmc_pdev->dev, "usb_sleepwalk"); in tegra_usb_phy_parse_pmc()
1220 if (!phy->pmc_regmap) in tegra_usb_phy_parse_pmc()
1221 return -EINVAL; in tegra_usb_phy_parse_pmc()
1223 phy->instance = args.args[0]; in tegra_usb_phy_parse_pmc()
1245 { .compatible = "nvidia,tegra30-usb-phy", .data = &tegra30_soc_config },
1246 { .compatible = "nvidia,tegra20-usb-phy", .data = &tegra20_soc_config },
1253 struct device_node *np = pdev->dev.of_node; in tegra_usb_phy_probe()
1259 struct usb_phy *phy; in tegra_usb_phy_probe() local
1262 tegra_phy = devm_kzalloc(&pdev->dev, sizeof(*tegra_phy), GFP_KERNEL); in tegra_usb_phy_probe()
1264 return -ENOMEM; in tegra_usb_phy_probe()
1266 tegra_phy->soc_config = of_device_get_match_data(&pdev->dev); in tegra_usb_phy_probe()
1267 tegra_phy->irq = platform_get_irq_optional(pdev, 0); in tegra_usb_phy_probe()
1271 dev_err(&pdev->dev, "Failed to get I/O memory\n"); in tegra_usb_phy_probe()
1272 return -ENXIO; in tegra_usb_phy_probe()
1276 * Note that PHY and USB controller are using shared registers, in tegra_usb_phy_probe()
1279 tegra_phy->regs = devm_ioremap(&pdev->dev, res->start, in tegra_usb_phy_probe()
1281 if (!tegra_phy->regs) { in tegra_usb_phy_probe()
1282 dev_err(&pdev->dev, "Failed to remap I/O memory\n"); in tegra_usb_phy_probe()
1283 return -ENOMEM; in tegra_usb_phy_probe()
1286 tegra_phy->is_legacy_phy = in tegra_usb_phy_probe()
1287 of_property_read_bool(np, "nvidia,has-legacy-mode"); in tegra_usb_phy_probe()
1290 tegra_phy->mode = usb_get_dr_mode(&pdev->dev); in tegra_usb_phy_probe()
1292 tegra_phy->mode = USB_DR_MODE_HOST; in tegra_usb_phy_probe()
1294 if (tegra_phy->mode == USB_DR_MODE_UNKNOWN) { in tegra_usb_phy_probe()
1295 dev_err(&pdev->dev, "dr_mode is invalid\n"); in tegra_usb_phy_probe()
1296 return -EINVAL; in tegra_usb_phy_probe()
1300 tegra_phy->vbus = devm_regulator_get(&pdev->dev, "vbus"); in tegra_usb_phy_probe()
1301 if (IS_ERR(tegra_phy->vbus)) in tegra_usb_phy_probe()
1302 return PTR_ERR(tegra_phy->vbus); in tegra_usb_phy_probe()
1304 tegra_phy->pll_u = devm_clk_get(&pdev->dev, "pll_u"); in tegra_usb_phy_probe()
1305 err = PTR_ERR_OR_ZERO(tegra_phy->pll_u); in tegra_usb_phy_probe()
1307 dev_err(&pdev->dev, "Failed to get pll_u clock: %d\n", err); in tegra_usb_phy_probe()
1311 err = tegra_usb_phy_parse_pmc(&pdev->dev, tegra_phy); in tegra_usb_phy_probe()
1313 dev_err_probe(&pdev->dev, err, "Failed to get PMC regmap\n"); in tegra_usb_phy_probe()
1324 tegra_phy->pad_clk = devm_clk_get(&pdev->dev, "utmi-pads"); in tegra_usb_phy_probe()
1325 err = PTR_ERR_OR_ZERO(tegra_phy->pad_clk); in tegra_usb_phy_probe()
1327 dev_err(&pdev->dev, in tegra_usb_phy_probe()
1328 "Failed to get UTMIP pad clock: %d\n", err); in tegra_usb_phy_probe()
1332 reset = devm_reset_control_get_optional_shared(&pdev->dev, in tegra_usb_phy_probe()
1333 "utmi-pads"); in tegra_usb_phy_probe()
1336 dev_err(&pdev->dev, in tegra_usb_phy_probe()
1337 "Failed to get UTMI-pads reset: %d\n", err); in tegra_usb_phy_probe()
1340 tegra_phy->pad_rst = reset; in tegra_usb_phy_probe()
1344 tegra_phy->is_ulpi_phy = true; in tegra_usb_phy_probe()
1346 tegra_phy->clk = devm_clk_get(&pdev->dev, "ulpi-link"); in tegra_usb_phy_probe()
1347 err = PTR_ERR_OR_ZERO(tegra_phy->clk); in tegra_usb_phy_probe()
1349 dev_err(&pdev->dev, in tegra_usb_phy_probe()
1350 "Failed to get ULPI clock: %d\n", err); in tegra_usb_phy_probe()
1354 gpiod = devm_gpiod_get(&pdev->dev, "nvidia,phy-reset", in tegra_usb_phy_probe()
1358 dev_err(&pdev->dev, in tegra_usb_phy_probe()
1359 "Request failed for reset GPIO: %d\n", err); in tegra_usb_phy_probe()
1365 dev_err(&pdev->dev, in tegra_usb_phy_probe()
1366 "Failed to set up reset GPIO name: %d\n", err); in tegra_usb_phy_probe()
1370 tegra_phy->reset_gpio = gpiod; in tegra_usb_phy_probe()
1372 phy = devm_otg_ulpi_create(&pdev->dev, in tegra_usb_phy_probe()
1374 if (!phy) { in tegra_usb_phy_probe()
1375 dev_err(&pdev->dev, "Failed to create ULPI OTG\n"); in tegra_usb_phy_probe()
1376 return -ENOMEM; in tegra_usb_phy_probe()
1379 tegra_phy->ulpi = phy; in tegra_usb_phy_probe()
1380 tegra_phy->ulpi->io_priv = tegra_phy->regs + ULPI_VIEWPORT; in tegra_usb_phy_probe()
1384 dev_err(&pdev->dev, "phy_type %u is invalid or unsupported\n", in tegra_usb_phy_probe()
1386 return -EINVAL; in tegra_usb_phy_probe()
1389 tegra_phy->u_phy.dev = &pdev->dev; in tegra_usb_phy_probe()
1390 tegra_phy->u_phy.init = tegra_usb_phy_init; in tegra_usb_phy_probe()
1391 tegra_phy->u_phy.shutdown = tegra_usb_phy_shutdown; in tegra_usb_phy_probe()
1392 tegra_phy->u_phy.set_wakeup = tegra_usb_phy_set_wakeup; in tegra_usb_phy_probe()
1393 tegra_phy->u_phy.set_suspend = tegra_usb_phy_set_suspend; in tegra_usb_phy_probe()
1397 return usb_add_phy_dev(&tegra_phy->u_phy); in tegra_usb_phy_probe()
1404 usb_remove_phy(&tegra_phy->u_phy); in tegra_usb_phy_remove()
1411 .name = "tegra-phy",
1417 MODULE_DESCRIPTION("Tegra USB PHY driver");