Lines Matching refs:phy
206 static void set_pts(struct tegra_usb_phy *phy, u8 pts_val) in set_pts() argument
208 void __iomem *base = phy->regs; in set_pts()
211 if (phy->soc_config->has_hostpc) { in set_pts()
224 static void set_phcd(struct tegra_usb_phy *phy, bool enable) in set_phcd() argument
226 void __iomem *base = phy->regs; in set_phcd()
229 if (phy->soc_config->has_hostpc) { in set_phcd()
246 static int utmip_pad_open(struct tegra_usb_phy *phy) in utmip_pad_open() argument
248 phy->pad_clk = devm_clk_get(phy->u_phy.dev, "utmi-pads"); in utmip_pad_open()
249 if (IS_ERR(phy->pad_clk)) { in utmip_pad_open()
251 return PTR_ERR(phy->pad_clk); in utmip_pad_open()
257 static void utmip_pad_power_on(struct tegra_usb_phy *phy) in utmip_pad_power_on() argument
260 void __iomem *base = phy->pad_regs; in utmip_pad_power_on()
261 struct tegra_utmip_config *config = phy->config; in utmip_pad_power_on()
263 clk_prepare_enable(phy->pad_clk); in utmip_pad_power_on()
271 if (phy->soc_config->requires_extra_tuning_parameters) { in utmip_pad_power_on()
285 clk_disable_unprepare(phy->pad_clk); in utmip_pad_power_on()
288 static int utmip_pad_power_off(struct tegra_usb_phy *phy) in utmip_pad_power_off() argument
291 void __iomem *base = phy->pad_regs; in utmip_pad_power_off()
298 clk_prepare_enable(phy->pad_clk); in utmip_pad_power_off()
310 clk_disable_unprepare(phy->pad_clk); in utmip_pad_power_off()
327 static void utmi_phy_clk_disable(struct tegra_usb_phy *phy) in utmi_phy_clk_disable() argument
330 void __iomem *base = phy->regs; in utmi_phy_clk_disable()
332 if (phy->is_legacy_phy) { in utmi_phy_clk_disable()
343 set_phcd(phy, true); in utmi_phy_clk_disable()
349 static void utmi_phy_clk_enable(struct tegra_usb_phy *phy) in utmi_phy_clk_enable() argument
352 void __iomem *base = phy->regs; in utmi_phy_clk_enable()
354 if (phy->is_legacy_phy) { in utmi_phy_clk_enable()
365 set_phcd(phy, false); in utmi_phy_clk_enable()
372 static int utmi_phy_power_on(struct tegra_usb_phy *phy) in utmi_phy_power_on() argument
375 void __iomem *base = phy->regs; in utmi_phy_power_on()
376 struct tegra_utmip_config *config = phy->config; in utmi_phy_power_on()
382 if (phy->is_legacy_phy) { in utmi_phy_power_on()
405 val |= UTMIP_BIAS_DEBOUNCE_A(phy->freq->debounce); in utmi_phy_power_on()
412 if (!phy->soc_config->utmi_pll_config_in_car_module) { in utmi_phy_power_on()
416 val |= UTMIP_PLL_ACTIVE_DLY_COUNT(phy->freq->active_delay) | in utmi_phy_power_on()
417 UTMIP_PLLU_STABLE_COUNT(phy->freq->stable_count); in utmi_phy_power_on()
423 val |= UTMIP_XTAL_FREQ_COUNT(phy->freq->xtal_freq_count) | in utmi_phy_power_on()
424 UTMIP_PLLU_ENABLE_DLY_COUNT(phy->freq->enable_delay); in utmi_phy_power_on()
428 if (phy->mode == USB_DR_MODE_PERIPHERAL) { in utmi_phy_power_on()
442 utmip_pad_power_on(phy); in utmi_phy_power_on()
457 if (phy->soc_config->requires_extra_tuning_parameters) { in utmi_phy_power_on()
482 if (!phy->is_legacy_phy) { in utmi_phy_power_on()
492 if (phy->is_legacy_phy) { in utmi_phy_power_on()
503 utmi_phy_clk_enable(phy); in utmi_phy_power_on()
505 if (phy->soc_config->requires_usbmode_setup) { in utmi_phy_power_on()
508 if (phy->mode == USB_DR_MODE_HOST) in utmi_phy_power_on()
515 if (!phy->is_legacy_phy) in utmi_phy_power_on()
516 set_pts(phy, 0); in utmi_phy_power_on()
521 static int utmi_phy_power_off(struct tegra_usb_phy *phy) in utmi_phy_power_off() argument
524 void __iomem *base = phy->regs; in utmi_phy_power_off()
526 utmi_phy_clk_disable(phy); in utmi_phy_power_off()
528 if (phy->mode == USB_DR_MODE_PERIPHERAL) { in utmi_phy_power_off()
553 return utmip_pad_power_off(phy); in utmi_phy_power_off()
556 static void utmi_phy_preresume(struct tegra_usb_phy *phy) in utmi_phy_preresume() argument
559 void __iomem *base = phy->regs; in utmi_phy_preresume()
566 static void utmi_phy_postresume(struct tegra_usb_phy *phy) in utmi_phy_postresume() argument
569 void __iomem *base = phy->regs; in utmi_phy_postresume()
576 static void utmi_phy_restore_start(struct tegra_usb_phy *phy, in utmi_phy_restore_start() argument
580 void __iomem *base = phy->regs; in utmi_phy_restore_start()
597 static void utmi_phy_restore_end(struct tegra_usb_phy *phy) in utmi_phy_restore_end() argument
600 void __iomem *base = phy->regs; in utmi_phy_restore_end()
608 static int ulpi_phy_power_on(struct tegra_usb_phy *phy) in ulpi_phy_power_on() argument
612 void __iomem *base = phy->regs; in ulpi_phy_power_on()
614 ret = gpio_direction_output(phy->reset_gpio, 0); in ulpi_phy_power_on()
616 dev_err(phy->u_phy.dev, "gpio %d not set to 0\n", in ulpi_phy_power_on()
617 phy->reset_gpio); in ulpi_phy_power_on()
621 ret = gpio_direction_output(phy->reset_gpio, 1); in ulpi_phy_power_on()
623 dev_err(phy->u_phy.dev, "gpio %d not set to 1\n", in ulpi_phy_power_on()
624 phy->reset_gpio); in ulpi_phy_power_on()
628 clk_prepare_enable(phy->clk); in ulpi_phy_power_on()
658 ret = usb_phy_io_write(phy->ulpi, 0x40, 0x08); in ulpi_phy_power_on()
664 ret = usb_phy_io_write(phy->ulpi, 0x80, 0x0B); in ulpi_phy_power_on()
682 static int ulpi_phy_power_off(struct tegra_usb_phy *phy) in ulpi_phy_power_off() argument
684 clk_disable(phy->clk); in ulpi_phy_power_off()
685 return gpio_direction_output(phy->reset_gpio, 0); in ulpi_phy_power_off()
688 static void tegra_usb_phy_close(struct tegra_usb_phy *phy) in tegra_usb_phy_close() argument
690 if (!IS_ERR(phy->vbus)) in tegra_usb_phy_close()
691 regulator_disable(phy->vbus); in tegra_usb_phy_close()
693 clk_disable_unprepare(phy->pll_u); in tegra_usb_phy_close()
696 static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy) in tegra_usb_phy_power_on() argument
698 if (phy->is_ulpi_phy) in tegra_usb_phy_power_on()
699 return ulpi_phy_power_on(phy); in tegra_usb_phy_power_on()
701 return utmi_phy_power_on(phy); in tegra_usb_phy_power_on()
704 static int tegra_usb_phy_power_off(struct tegra_usb_phy *phy) in tegra_usb_phy_power_off() argument
706 if (phy->is_ulpi_phy) in tegra_usb_phy_power_off()
707 return ulpi_phy_power_off(phy); in tegra_usb_phy_power_off()
709 return utmi_phy_power_off(phy); in tegra_usb_phy_power_off()
714 struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); in tegra_usb_phy_suspend() local
716 return tegra_usb_phy_power_off(phy); in tegra_usb_phy_suspend()
718 return tegra_usb_phy_power_on(phy); in tegra_usb_phy_suspend()
721 static int ulpi_open(struct tegra_usb_phy *phy) in ulpi_open() argument
725 phy->clk = devm_clk_get(phy->u_phy.dev, "ulpi-link"); in ulpi_open()
726 if (IS_ERR(phy->clk)) { in ulpi_open()
728 return PTR_ERR(phy->clk); in ulpi_open()
731 err = devm_gpio_request(phy->u_phy.dev, phy->reset_gpio, in ulpi_open()
734 dev_err(phy->u_phy.dev, "request failed for gpio: %d\n", in ulpi_open()
735 phy->reset_gpio); in ulpi_open()
739 err = gpio_direction_output(phy->reset_gpio, 0); in ulpi_open()
741 dev_err(phy->u_phy.dev, "gpio %d direction not set to output\n", in ulpi_open()
742 phy->reset_gpio); in ulpi_open()
746 phy->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0); in ulpi_open()
747 if (!phy->ulpi) { in ulpi_open()
748 dev_err(phy->u_phy.dev, "otg_ulpi_create returned NULL\n"); in ulpi_open()
753 phy->ulpi->io_priv = phy->regs + ULPI_VIEWPORT; in ulpi_open()
757 static int tegra_usb_phy_init(struct tegra_usb_phy *phy) in tegra_usb_phy_init() argument
763 phy->pll_u = devm_clk_get(phy->u_phy.dev, "pll_u"); in tegra_usb_phy_init()
764 if (IS_ERR(phy->pll_u)) { in tegra_usb_phy_init()
766 return PTR_ERR(phy->pll_u); in tegra_usb_phy_init()
769 err = clk_prepare_enable(phy->pll_u); in tegra_usb_phy_init()
773 parent_rate = clk_get_rate(clk_get_parent(phy->pll_u)); in tegra_usb_phy_init()
776 phy->freq = &tegra_freq_table[i]; in tegra_usb_phy_init()
780 if (!phy->freq) { in tegra_usb_phy_init()
786 if (!IS_ERR(phy->vbus)) { in tegra_usb_phy_init()
787 err = regulator_enable(phy->vbus); in tegra_usb_phy_init()
789 dev_err(phy->u_phy.dev, in tegra_usb_phy_init()
796 if (phy->is_ulpi_phy) in tegra_usb_phy_init()
797 err = ulpi_open(phy); in tegra_usb_phy_init()
799 err = utmip_pad_open(phy); in tegra_usb_phy_init()
806 clk_disable_unprepare(phy->pll_u); in tegra_usb_phy_init()
812 struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); in tegra_usb_phy_preresume() local
814 if (!phy->is_ulpi_phy) in tegra_usb_phy_preresume()
815 utmi_phy_preresume(phy); in tegra_usb_phy_preresume()
821 struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); in tegra_usb_phy_postresume() local
823 if (!phy->is_ulpi_phy) in tegra_usb_phy_postresume()
824 utmi_phy_postresume(phy); in tegra_usb_phy_postresume()
831 struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); in tegra_ehci_phy_restore_start() local
833 if (!phy->is_ulpi_phy) in tegra_ehci_phy_restore_start()
834 utmi_phy_restore_start(phy, port_speed); in tegra_ehci_phy_restore_start()
840 struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); in tegra_ehci_phy_restore_end() local
842 if (!phy->is_ulpi_phy) in tegra_ehci_phy_restore_end()
843 utmi_phy_restore_end(phy); in tegra_ehci_phy_restore_end()