Lines Matching refs:phy
197 static void set_pts(struct tegra_usb_phy *phy, u8 pts_val) in set_pts() argument
199 void __iomem *base = phy->regs; in set_pts()
202 if (phy->soc_config->has_hostpc) { in set_pts()
215 static void set_phcd(struct tegra_usb_phy *phy, bool enable) in set_phcd() argument
217 void __iomem *base = phy->regs; in set_phcd()
220 if (phy->soc_config->has_hostpc) { in set_phcd()
237 static int utmip_pad_open(struct tegra_usb_phy *phy) in utmip_pad_open() argument
241 phy->pad_clk = devm_clk_get(phy->u_phy.dev, "utmi-pads"); in utmip_pad_open()
242 if (IS_ERR(phy->pad_clk)) { in utmip_pad_open()
243 ret = PTR_ERR(phy->pad_clk); in utmip_pad_open()
244 dev_err(phy->u_phy.dev, in utmip_pad_open()
249 phy->pad_rst = devm_reset_control_get_optional_shared( in utmip_pad_open()
250 phy->u_phy.dev, "utmi-pads"); in utmip_pad_open()
251 if (IS_ERR(phy->pad_rst)) { in utmip_pad_open()
252 ret = PTR_ERR(phy->pad_rst); in utmip_pad_open()
253 dev_err(phy->u_phy.dev, in utmip_pad_open()
258 ret = clk_prepare_enable(phy->pad_clk); in utmip_pad_open()
260 dev_err(phy->u_phy.dev, in utmip_pad_open()
267 ret = reset_control_deassert(phy->pad_rst); in utmip_pad_open()
269 dev_err(phy->u_phy.dev, in utmip_pad_open()
274 ret = reset_control_assert(phy->pad_rst); in utmip_pad_open()
276 dev_err(phy->u_phy.dev, in utmip_pad_open()
283 ret = reset_control_deassert(phy->pad_rst); in utmip_pad_open()
285 dev_err(phy->u_phy.dev, in utmip_pad_open()
290 clk_disable_unprepare(phy->pad_clk); in utmip_pad_open()
295 static int utmip_pad_close(struct tegra_usb_phy *phy) in utmip_pad_close() argument
299 ret = clk_prepare_enable(phy->pad_clk); in utmip_pad_close()
301 dev_err(phy->u_phy.dev, in utmip_pad_close()
306 ret = reset_control_assert(phy->pad_rst); in utmip_pad_close()
308 dev_err(phy->u_phy.dev, in utmip_pad_close()
313 clk_disable_unprepare(phy->pad_clk); in utmip_pad_close()
318 static void utmip_pad_power_on(struct tegra_usb_phy *phy) in utmip_pad_power_on() argument
321 void __iomem *base = phy->pad_regs; in utmip_pad_power_on()
322 struct tegra_utmip_config *config = phy->config; in utmip_pad_power_on()
324 clk_prepare_enable(phy->pad_clk); in utmip_pad_power_on()
332 if (phy->soc_config->requires_extra_tuning_parameters) { in utmip_pad_power_on()
346 clk_disable_unprepare(phy->pad_clk); in utmip_pad_power_on()
349 static int utmip_pad_power_off(struct tegra_usb_phy *phy) in utmip_pad_power_off() argument
352 void __iomem *base = phy->pad_regs; in utmip_pad_power_off()
355 dev_err(phy->u_phy.dev, "UTMIP pad already powered off\n"); in utmip_pad_power_off()
359 clk_prepare_enable(phy->pad_clk); in utmip_pad_power_off()
371 clk_disable_unprepare(phy->pad_clk); in utmip_pad_power_off()
384 static void utmi_phy_clk_disable(struct tegra_usb_phy *phy) in utmi_phy_clk_disable() argument
387 void __iomem *base = phy->regs; in utmi_phy_clk_disable()
397 if (phy->is_legacy_phy) { in utmi_phy_clk_disable()
408 set_phcd(phy, true); in utmi_phy_clk_disable()
411 dev_err(phy->u_phy.dev, in utmi_phy_clk_disable()
415 static void utmi_phy_clk_enable(struct tegra_usb_phy *phy) in utmi_phy_clk_enable() argument
418 void __iomem *base = phy->regs; in utmi_phy_clk_enable()
429 if (phy->is_legacy_phy) { in utmi_phy_clk_enable()
440 set_phcd(phy, false); in utmi_phy_clk_enable()
444 dev_err(phy->u_phy.dev, in utmi_phy_clk_enable()
448 static int utmi_phy_power_on(struct tegra_usb_phy *phy) in utmi_phy_power_on() argument
451 void __iomem *base = phy->regs; in utmi_phy_power_on()
452 struct tegra_utmip_config *config = phy->config; in utmi_phy_power_on()
458 if (phy->is_legacy_phy) { in utmi_phy_power_on()
481 val |= UTMIP_BIAS_DEBOUNCE_A(phy->freq->debounce); in utmi_phy_power_on()
488 if (!phy->soc_config->utmi_pll_config_in_car_module) { in utmi_phy_power_on()
492 val |= UTMIP_PLL_ACTIVE_DLY_COUNT(phy->freq->active_delay) | in utmi_phy_power_on()
493 UTMIP_PLLU_STABLE_COUNT(phy->freq->stable_count); in utmi_phy_power_on()
499 val |= UTMIP_XTAL_FREQ_COUNT(phy->freq->xtal_freq_count) | in utmi_phy_power_on()
500 UTMIP_PLLU_ENABLE_DLY_COUNT(phy->freq->enable_delay); in utmi_phy_power_on()
504 if (phy->mode == USB_DR_MODE_PERIPHERAL) { in utmi_phy_power_on()
518 utmip_pad_power_on(phy); in utmi_phy_power_on()
533 if (phy->soc_config->requires_extra_tuning_parameters) { in utmi_phy_power_on()
558 if (!phy->is_legacy_phy) { in utmi_phy_power_on()
568 if (phy->is_legacy_phy) { in utmi_phy_power_on()
579 utmi_phy_clk_enable(phy); in utmi_phy_power_on()
581 if (phy->soc_config->requires_usbmode_setup) { in utmi_phy_power_on()
584 if (phy->mode == USB_DR_MODE_HOST) in utmi_phy_power_on()
591 if (!phy->is_legacy_phy) in utmi_phy_power_on()
592 set_pts(phy, 0); in utmi_phy_power_on()
597 static int utmi_phy_power_off(struct tegra_usb_phy *phy) in utmi_phy_power_off() argument
600 void __iomem *base = phy->regs; in utmi_phy_power_off()
602 utmi_phy_clk_disable(phy); in utmi_phy_power_off()
604 if (phy->mode == USB_DR_MODE_PERIPHERAL) { in utmi_phy_power_off()
629 return utmip_pad_power_off(phy); in utmi_phy_power_off()
632 static void utmi_phy_preresume(struct tegra_usb_phy *phy) in utmi_phy_preresume() argument
635 void __iomem *base = phy->regs; in utmi_phy_preresume()
642 static void utmi_phy_postresume(struct tegra_usb_phy *phy) in utmi_phy_postresume() argument
645 void __iomem *base = phy->regs; in utmi_phy_postresume()
652 static void utmi_phy_restore_start(struct tegra_usb_phy *phy, in utmi_phy_restore_start() argument
656 void __iomem *base = phy->regs; in utmi_phy_restore_start()
673 static void utmi_phy_restore_end(struct tegra_usb_phy *phy) in utmi_phy_restore_end() argument
676 void __iomem *base = phy->regs; in utmi_phy_restore_end()
684 static int ulpi_phy_power_on(struct tegra_usb_phy *phy) in ulpi_phy_power_on() argument
688 void __iomem *base = phy->regs; in ulpi_phy_power_on()
690 ret = gpio_direction_output(phy->reset_gpio, 0); in ulpi_phy_power_on()
692 dev_err(phy->u_phy.dev, "GPIO %d not set to 0: %d\n", in ulpi_phy_power_on()
693 phy->reset_gpio, ret); in ulpi_phy_power_on()
697 ret = gpio_direction_output(phy->reset_gpio, 1); in ulpi_phy_power_on()
699 dev_err(phy->u_phy.dev, "GPIO %d not set to 1: %d\n", in ulpi_phy_power_on()
700 phy->reset_gpio, ret); in ulpi_phy_power_on()
704 clk_prepare_enable(phy->clk); in ulpi_phy_power_on()
734 ret = usb_phy_io_write(phy->ulpi, 0x40, 0x08); in ulpi_phy_power_on()
736 dev_err(phy->u_phy.dev, "ULPI write failed: %d\n", ret); in ulpi_phy_power_on()
740 ret = usb_phy_io_write(phy->ulpi, 0x80, 0x0B); in ulpi_phy_power_on()
742 dev_err(phy->u_phy.dev, "ULPI write failed: %d\n", ret); in ulpi_phy_power_on()
758 static int ulpi_phy_power_off(struct tegra_usb_phy *phy) in ulpi_phy_power_off() argument
760 clk_disable(phy->clk); in ulpi_phy_power_off()
761 return gpio_direction_output(phy->reset_gpio, 0); in ulpi_phy_power_off()
764 static void tegra_usb_phy_close(struct tegra_usb_phy *phy) in tegra_usb_phy_close() argument
766 if (!IS_ERR(phy->vbus)) in tegra_usb_phy_close()
767 regulator_disable(phy->vbus); in tegra_usb_phy_close()
769 if (!phy->is_ulpi_phy) in tegra_usb_phy_close()
770 utmip_pad_close(phy); in tegra_usb_phy_close()
772 clk_disable_unprepare(phy->pll_u); in tegra_usb_phy_close()
775 static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy) in tegra_usb_phy_power_on() argument
777 if (phy->is_ulpi_phy) in tegra_usb_phy_power_on()
778 return ulpi_phy_power_on(phy); in tegra_usb_phy_power_on()
780 return utmi_phy_power_on(phy); in tegra_usb_phy_power_on()
783 static int tegra_usb_phy_power_off(struct tegra_usb_phy *phy) in tegra_usb_phy_power_off() argument
785 if (phy->is_ulpi_phy) in tegra_usb_phy_power_off()
786 return ulpi_phy_power_off(phy); in tegra_usb_phy_power_off()
788 return utmi_phy_power_off(phy); in tegra_usb_phy_power_off()
793 struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); in tegra_usb_phy_suspend() local
795 return tegra_usb_phy_power_off(phy); in tegra_usb_phy_suspend()
797 return tegra_usb_phy_power_on(phy); in tegra_usb_phy_suspend()
800 static int ulpi_open(struct tegra_usb_phy *phy) in ulpi_open() argument
804 phy->clk = devm_clk_get(phy->u_phy.dev, "ulpi-link"); in ulpi_open()
805 if (IS_ERR(phy->clk)) { in ulpi_open()
806 err = PTR_ERR(phy->clk); in ulpi_open()
807 dev_err(phy->u_phy.dev, "Failed to get ULPI clock: %d\n", err); in ulpi_open()
811 err = devm_gpio_request(phy->u_phy.dev, phy->reset_gpio, in ulpi_open()
814 dev_err(phy->u_phy.dev, "Request failed for GPIO %d: %d\n", in ulpi_open()
815 phy->reset_gpio, err); in ulpi_open()
819 err = gpio_direction_output(phy->reset_gpio, 0); in ulpi_open()
821 dev_err(phy->u_phy.dev, in ulpi_open()
823 phy->reset_gpio, err); in ulpi_open()
827 phy->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0); in ulpi_open()
828 if (!phy->ulpi) { in ulpi_open()
829 dev_err(phy->u_phy.dev, "Failed to create ULPI OTG\n"); in ulpi_open()
834 phy->ulpi->io_priv = phy->regs + ULPI_VIEWPORT; in ulpi_open()
838 static int tegra_usb_phy_init(struct tegra_usb_phy *phy) in tegra_usb_phy_init() argument
844 phy->pll_u = devm_clk_get(phy->u_phy.dev, "pll_u"); in tegra_usb_phy_init()
845 if (IS_ERR(phy->pll_u)) { in tegra_usb_phy_init()
846 err = PTR_ERR(phy->pll_u); in tegra_usb_phy_init()
847 dev_err(phy->u_phy.dev, in tegra_usb_phy_init()
852 err = clk_prepare_enable(phy->pll_u); in tegra_usb_phy_init()
856 parent_rate = clk_get_rate(clk_get_parent(phy->pll_u)); in tegra_usb_phy_init()
859 phy->freq = &tegra_freq_table[i]; in tegra_usb_phy_init()
863 if (!phy->freq) { in tegra_usb_phy_init()
864 dev_err(phy->u_phy.dev, "Invalid pll_u parent rate %ld\n", in tegra_usb_phy_init()
870 if (!IS_ERR(phy->vbus)) { in tegra_usb_phy_init()
871 err = regulator_enable(phy->vbus); in tegra_usb_phy_init()
873 dev_err(phy->u_phy.dev, in tegra_usb_phy_init()
880 if (phy->is_ulpi_phy) in tegra_usb_phy_init()
881 err = ulpi_open(phy); in tegra_usb_phy_init()
883 err = utmip_pad_open(phy); in tegra_usb_phy_init()
890 clk_disable_unprepare(phy->pll_u); in tegra_usb_phy_init()
896 struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); in tegra_usb_phy_preresume() local
898 if (!phy->is_ulpi_phy) in tegra_usb_phy_preresume()
899 utmi_phy_preresume(phy); in tegra_usb_phy_preresume()
905 struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); in tegra_usb_phy_postresume() local
907 if (!phy->is_ulpi_phy) in tegra_usb_phy_postresume()
908 utmi_phy_postresume(phy); in tegra_usb_phy_postresume()
915 struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); in tegra_ehci_phy_restore_start() local
917 if (!phy->is_ulpi_phy) in tegra_ehci_phy_restore_start()
918 utmi_phy_restore_start(phy, port_speed); in tegra_ehci_phy_restore_start()
924 struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); in tegra_ehci_phy_restore_end() local
926 if (!phy->is_ulpi_phy) in tegra_ehci_phy_restore_end()
927 utmi_phy_restore_end(phy); in tegra_ehci_phy_restore_end()