• Home
  • Raw
  • Download

Lines Matching +full:elastic +full:- +full:limit

1 // SPDX-License-Identifier: GPL-2.0
205 void __iomem *base = phy->regs; in set_pts()
208 if (phy->soc_config->has_hostpc) { in set_pts()
224 void __iomem *base = phy->regs; in set_phcd()
227 if (phy->soc_config->has_hostpc) { in set_phcd()
248 ret = clk_prepare_enable(phy->pad_clk); in utmip_pad_open()
250 dev_err(phy->u_phy.dev, in utmip_pad_open()
251 "Failed to enable UTMI-pads clock: %d\n", ret); in utmip_pad_open()
257 ret = reset_control_deassert(phy->pad_rst); in utmip_pad_open()
259 dev_err(phy->u_phy.dev, in utmip_pad_open()
260 "Failed to initialize UTMI-pads reset: %d\n", ret); in utmip_pad_open()
264 ret = reset_control_assert(phy->pad_rst); in utmip_pad_open()
266 dev_err(phy->u_phy.dev, in utmip_pad_open()
267 "Failed to assert UTMI-pads reset: %d\n", ret); in utmip_pad_open()
273 ret = reset_control_deassert(phy->pad_rst); in utmip_pad_open()
275 dev_err(phy->u_phy.dev, in utmip_pad_open()
276 "Failed to deassert UTMI-pads reset: %d\n", ret); in utmip_pad_open()
280 clk_disable_unprepare(phy->pad_clk); in utmip_pad_open()
289 ret = clk_prepare_enable(phy->pad_clk); in utmip_pad_close()
291 dev_err(phy->u_phy.dev, in utmip_pad_close()
292 "Failed to enable UTMI-pads clock: %d\n", ret); in utmip_pad_close()
296 ret = reset_control_assert(phy->pad_rst); in utmip_pad_close()
298 dev_err(phy->u_phy.dev, in utmip_pad_close()
299 "Failed to assert UTMI-pads reset: %d\n", ret); in utmip_pad_close()
303 clk_disable_unprepare(phy->pad_clk); in utmip_pad_close()
310 struct tegra_utmip_config *config = phy->config; in utmip_pad_power_on()
311 void __iomem *base = phy->pad_regs; in utmip_pad_power_on()
315 err = clk_prepare_enable(phy->pad_clk); in utmip_pad_power_on()
325 if (phy->soc_config->requires_extra_tuning_parameters) { in utmip_pad_power_on()
330 val |= UTMIP_HSSQUELCH_LEVEL(config->hssquelch_level); in utmip_pad_power_on()
331 val |= UTMIP_HSDISCON_LEVEL(config->hsdiscon_level); in utmip_pad_power_on()
332 val |= UTMIP_HSDISCON_LEVEL_MSB(config->hsdiscon_level); in utmip_pad_power_on()
339 clk_disable_unprepare(phy->pad_clk); in utmip_pad_power_on()
346 void __iomem *base = phy->pad_regs; in utmip_pad_power_off()
350 ret = clk_prepare_enable(phy->pad_clk); in utmip_pad_power_off()
357 dev_err(phy->u_phy.dev, "UTMIP pad already powered off\n"); in utmip_pad_power_off()
358 ret = -EINVAL; in utmip_pad_power_off()
362 if (--utmip_pad_count == 0) { in utmip_pad_power_off()
370 clk_disable_unprepare(phy->pad_clk); in utmip_pad_power_off()
385 void __iomem *base = phy->regs; in utmi_phy_clk_disable()
396 if (phy->is_legacy_phy) { in utmi_phy_clk_disable()
411 dev_err(phy->u_phy.dev, in utmi_phy_clk_disable()
417 void __iomem *base = phy->regs; in utmi_phy_clk_enable()
429 if (phy->is_legacy_phy) { in utmi_phy_clk_enable()
445 dev_err(phy->u_phy.dev, in utmi_phy_clk_enable()
451 struct tegra_utmip_config *config = phy->config; in utmi_phy_power_on()
452 void __iomem *base = phy->regs; in utmi_phy_power_on()
460 if (phy->is_legacy_phy) { in utmi_phy_power_on()
472 val |= UTMIP_IDLE_WAIT(config->idle_wait_delay); in utmi_phy_power_on()
473 val |= UTMIP_ELASTIC_LIMIT(config->elastic_limit); in utmi_phy_power_on()
478 val |= UTMIP_HS_SYNC_START_DLY(config->hssync_start_delay); in utmi_phy_power_on()
483 val |= UTMIP_BIAS_DEBOUNCE_A(phy->freq->debounce); in utmi_phy_power_on()
490 if (!phy->soc_config->utmi_pll_config_in_car_module) { in utmi_phy_power_on()
494 val |= UTMIP_PLL_ACTIVE_DLY_COUNT(phy->freq->active_delay) | in utmi_phy_power_on()
495 UTMIP_PLLU_STABLE_COUNT(phy->freq->stable_count); in utmi_phy_power_on()
501 val |= UTMIP_XTAL_FREQ_COUNT(phy->freq->xtal_freq_count) | in utmi_phy_power_on()
502 UTMIP_PLLU_ENABLE_DLY_COUNT(phy->freq->enable_delay); in utmi_phy_power_on()
506 if (phy->mode == USB_DR_MODE_PERIPHERAL) { in utmi_phy_power_on()
530 if (!config->xcvr_setup_use_fuses) { in utmi_phy_power_on()
531 val |= UTMIP_XCVR_SETUP(config->xcvr_setup); in utmi_phy_power_on()
532 val |= UTMIP_XCVR_SETUP_MSB(config->xcvr_setup); in utmi_phy_power_on()
534 val |= UTMIP_XCVR_LSFSLEW(config->xcvr_lsfslew); in utmi_phy_power_on()
535 val |= UTMIP_XCVR_LSRSLEW(config->xcvr_lsrslew); in utmi_phy_power_on()
537 if (phy->soc_config->requires_extra_tuning_parameters) { in utmi_phy_power_on()
539 val |= UTMIP_XCVR_HSSLEW(config->xcvr_hsslew); in utmi_phy_power_on()
540 val |= UTMIP_XCVR_HSSLEW_MSB(config->xcvr_hsslew); in utmi_phy_power_on()
547 val |= UTMIP_XCVR_TERM_RANGE_ADJ(config->term_range_adj); in utmi_phy_power_on()
556 if (config->xcvr_setup_use_fuses) in utmi_phy_power_on()
562 if (!phy->is_legacy_phy) { in utmi_phy_power_on()
572 if (phy->is_legacy_phy) { in utmi_phy_power_on()
585 if (phy->soc_config->requires_usbmode_setup) { in utmi_phy_power_on()
588 if (phy->mode == USB_DR_MODE_HOST) in utmi_phy_power_on()
595 if (!phy->is_legacy_phy) in utmi_phy_power_on()
603 void __iomem *base = phy->regs; in utmi_phy_power_off()
608 if (phy->mode == USB_DR_MODE_PERIPHERAL) { in utmi_phy_power_off()
638 void __iomem *base = phy->regs; in utmi_phy_preresume()
648 void __iomem *base = phy->regs; in utmi_phy_postresume()
659 void __iomem *base = phy->regs; in utmi_phy_restore_start()
679 void __iomem *base = phy->regs; in utmi_phy_restore_end()
690 void __iomem *base = phy->regs; in ulpi_phy_power_on()
694 gpiod_set_value_cansleep(phy->reset_gpio, 1); in ulpi_phy_power_on()
696 err = clk_prepare_enable(phy->clk); in ulpi_phy_power_on()
702 gpiod_set_value_cansleep(phy->reset_gpio, 0); in ulpi_phy_power_on()
733 err = usb_phy_io_write(phy->ulpi, 0x40, 0x08); in ulpi_phy_power_on()
735 dev_err(phy->u_phy.dev, "ULPI write failed: %d\n", err); in ulpi_phy_power_on()
739 err = usb_phy_io_write(phy->ulpi, 0x80, 0x0B); in ulpi_phy_power_on()
741 dev_err(phy->u_phy.dev, "ULPI write failed: %d\n", err); in ulpi_phy_power_on()
757 clk_disable_unprepare(phy->clk); in ulpi_phy_power_on()
764 gpiod_set_value_cansleep(phy->reset_gpio, 1); in ulpi_phy_power_off()
766 clk_disable_unprepare(phy->clk); in ulpi_phy_power_off()
775 if (phy->powered_on) in tegra_usb_phy_power_on()
778 if (phy->is_ulpi_phy) in tegra_usb_phy_power_on()
785 phy->powered_on = true; in tegra_usb_phy_power_on()
794 if (!phy->powered_on) in tegra_usb_phy_power_off()
797 if (phy->is_ulpi_phy) in tegra_usb_phy_power_off()
804 phy->powered_on = false; in tegra_usb_phy_power_off()
813 if (WARN_ON(!phy->freq)) in tegra_usb_phy_shutdown()
818 if (!phy->is_ulpi_phy) in tegra_usb_phy_shutdown()
821 regulator_disable(phy->vbus); in tegra_usb_phy_shutdown()
822 clk_disable_unprepare(phy->pll_u); in tegra_usb_phy_shutdown()
824 phy->freq = NULL; in tegra_usb_phy_shutdown()
831 if (WARN_ON(!phy->freq)) in tegra_usb_phy_set_suspend()
832 return -EINVAL; in tegra_usb_phy_set_suspend()
847 if (WARN_ON(phy->freq)) in tegra_usb_phy_init()
850 err = clk_prepare_enable(phy->pll_u); in tegra_usb_phy_init()
854 parent_rate = clk_get_rate(clk_get_parent(phy->pll_u)); in tegra_usb_phy_init()
857 phy->freq = &tegra_freq_table[i]; in tegra_usb_phy_init()
861 if (!phy->freq) { in tegra_usb_phy_init()
862 dev_err(phy->u_phy.dev, "Invalid pll_u parent rate %ld\n", in tegra_usb_phy_init()
864 err = -EINVAL; in tegra_usb_phy_init()
868 err = regulator_enable(phy->vbus); in tegra_usb_phy_init()
870 dev_err(phy->u_phy.dev, in tegra_usb_phy_init()
875 if (!phy->is_ulpi_phy) { in tegra_usb_phy_init()
888 if (!phy->is_ulpi_phy) in tegra_usb_phy_init()
892 regulator_disable(phy->vbus); in tegra_usb_phy_init()
895 clk_disable_unprepare(phy->pll_u); in tegra_usb_phy_init()
897 phy->freq = NULL; in tegra_usb_phy_init()
906 if (!phy->is_ulpi_phy) in tegra_usb_phy_preresume()
915 if (!phy->is_ulpi_phy) in tegra_usb_phy_postresume()
925 if (!phy->is_ulpi_phy) in tegra_ehci_phy_restore_start()
934 if (!phy->is_ulpi_phy) in tegra_ehci_phy_restore_end()
945 err = of_property_read_u32(pdev->dev.of_node, param, &value); in read_utmi_param()
947 dev_err(&pdev->dev, in read_utmi_param()
963 tegra_phy->is_ulpi_phy = false; in utmi_phy_probe()
967 dev_err(&pdev->dev, "Failed to get UTMI pad regs\n"); in utmi_phy_probe()
968 return -ENXIO; in utmi_phy_probe()
975 tegra_phy->pad_regs = devm_ioremap(&pdev->dev, res->start, in utmi_phy_probe()
977 if (!tegra_phy->pad_regs) { in utmi_phy_probe()
978 dev_err(&pdev->dev, "Failed to remap UTMI pad regs\n"); in utmi_phy_probe()
979 return -ENOMEM; in utmi_phy_probe()
982 tegra_phy->config = devm_kzalloc(&pdev->dev, sizeof(*config), in utmi_phy_probe()
984 if (!tegra_phy->config) in utmi_phy_probe()
985 return -ENOMEM; in utmi_phy_probe()
987 config = tegra_phy->config; in utmi_phy_probe()
989 err = read_utmi_param(pdev, "nvidia,hssync-start-delay", in utmi_phy_probe()
990 &config->hssync_start_delay); in utmi_phy_probe()
994 err = read_utmi_param(pdev, "nvidia,elastic-limit", in utmi_phy_probe()
995 &config->elastic_limit); in utmi_phy_probe()
999 err = read_utmi_param(pdev, "nvidia,idle-wait-delay", in utmi_phy_probe()
1000 &config->idle_wait_delay); in utmi_phy_probe()
1004 err = read_utmi_param(pdev, "nvidia,term-range-adj", in utmi_phy_probe()
1005 &config->term_range_adj); in utmi_phy_probe()
1009 err = read_utmi_param(pdev, "nvidia,xcvr-lsfslew", in utmi_phy_probe()
1010 &config->xcvr_lsfslew); in utmi_phy_probe()
1014 err = read_utmi_param(pdev, "nvidia,xcvr-lsrslew", in utmi_phy_probe()
1015 &config->xcvr_lsrslew); in utmi_phy_probe()
1019 if (tegra_phy->soc_config->requires_extra_tuning_parameters) { in utmi_phy_probe()
1020 err = read_utmi_param(pdev, "nvidia,xcvr-hsslew", in utmi_phy_probe()
1021 &config->xcvr_hsslew); in utmi_phy_probe()
1025 err = read_utmi_param(pdev, "nvidia,hssquelch-level", in utmi_phy_probe()
1026 &config->hssquelch_level); in utmi_phy_probe()
1030 err = read_utmi_param(pdev, "nvidia,hsdiscon-level", in utmi_phy_probe()
1031 &config->hsdiscon_level); in utmi_phy_probe()
1036 config->xcvr_setup_use_fuses = of_property_read_bool( in utmi_phy_probe()
1037 pdev->dev.of_node, "nvidia,xcvr-setup-use-fuses"); in utmi_phy_probe()
1039 if (!config->xcvr_setup_use_fuses) { in utmi_phy_probe()
1040 err = read_utmi_param(pdev, "nvidia,xcvr-setup", in utmi_phy_probe()
1041 &config->xcvr_setup); in utmi_phy_probe()
1064 { .compatible = "nvidia,tegra30-usb-phy", .data = &tegra30_soc_config },
1065 { .compatible = "nvidia,tegra20-usb-phy", .data = &tegra20_soc_config },
1072 struct device_node *np = pdev->dev.of_node; in tegra_usb_phy_probe()
1081 tegra_phy = devm_kzalloc(&pdev->dev, sizeof(*tegra_phy), GFP_KERNEL); in tegra_usb_phy_probe()
1083 return -ENOMEM; in tegra_usb_phy_probe()
1085 tegra_phy->soc_config = of_device_get_match_data(&pdev->dev); in tegra_usb_phy_probe()
1089 dev_err(&pdev->dev, "Failed to get I/O memory\n"); in tegra_usb_phy_probe()
1090 return -ENXIO; in tegra_usb_phy_probe()
1097 tegra_phy->regs = devm_ioremap(&pdev->dev, res->start, in tegra_usb_phy_probe()
1099 if (!tegra_phy->regs) { in tegra_usb_phy_probe()
1100 dev_err(&pdev->dev, "Failed to remap I/O memory\n"); in tegra_usb_phy_probe()
1101 return -ENOMEM; in tegra_usb_phy_probe()
1104 tegra_phy->is_legacy_phy = in tegra_usb_phy_probe()
1105 of_property_read_bool(np, "nvidia,has-legacy-mode"); in tegra_usb_phy_probe()
1108 tegra_phy->mode = usb_get_dr_mode(&pdev->dev); in tegra_usb_phy_probe()
1110 tegra_phy->mode = USB_DR_MODE_HOST; in tegra_usb_phy_probe()
1112 if (tegra_phy->mode == USB_DR_MODE_UNKNOWN) { in tegra_usb_phy_probe()
1113 dev_err(&pdev->dev, "dr_mode is invalid\n"); in tegra_usb_phy_probe()
1114 return -EINVAL; in tegra_usb_phy_probe()
1118 tegra_phy->vbus = devm_regulator_get(&pdev->dev, "vbus"); in tegra_usb_phy_probe()
1119 if (IS_ERR(tegra_phy->vbus)) in tegra_usb_phy_probe()
1120 return PTR_ERR(tegra_phy->vbus); in tegra_usb_phy_probe()
1122 tegra_phy->pll_u = devm_clk_get(&pdev->dev, "pll_u"); in tegra_usb_phy_probe()
1123 err = PTR_ERR_OR_ZERO(tegra_phy->pll_u); in tegra_usb_phy_probe()
1125 dev_err(&pdev->dev, "Failed to get pll_u clock: %d\n", err); in tegra_usb_phy_probe()
1136 tegra_phy->pad_clk = devm_clk_get(&pdev->dev, "utmi-pads"); in tegra_usb_phy_probe()
1137 err = PTR_ERR_OR_ZERO(tegra_phy->pad_clk); in tegra_usb_phy_probe()
1139 dev_err(&pdev->dev, in tegra_usb_phy_probe()
1144 reset = devm_reset_control_get_optional_shared(&pdev->dev, in tegra_usb_phy_probe()
1145 "utmi-pads"); in tegra_usb_phy_probe()
1148 dev_err(&pdev->dev, in tegra_usb_phy_probe()
1149 "Failed to get UTMI-pads reset: %d\n", err); in tegra_usb_phy_probe()
1152 tegra_phy->pad_rst = reset; in tegra_usb_phy_probe()
1156 tegra_phy->is_ulpi_phy = true; in tegra_usb_phy_probe()
1158 tegra_phy->clk = devm_clk_get(&pdev->dev, "ulpi-link"); in tegra_usb_phy_probe()
1159 err = PTR_ERR_OR_ZERO(tegra_phy->clk); in tegra_usb_phy_probe()
1161 dev_err(&pdev->dev, in tegra_usb_phy_probe()
1166 gpiod = devm_gpiod_get_from_of_node(&pdev->dev, np, in tegra_usb_phy_probe()
1167 "nvidia,phy-reset-gpio", in tegra_usb_phy_probe()
1172 dev_err(&pdev->dev, in tegra_usb_phy_probe()
1176 tegra_phy->reset_gpio = gpiod; in tegra_usb_phy_probe()
1178 phy = devm_otg_ulpi_create(&pdev->dev, in tegra_usb_phy_probe()
1181 dev_err(&pdev->dev, "Failed to create ULPI OTG\n"); in tegra_usb_phy_probe()
1182 return -ENOMEM; in tegra_usb_phy_probe()
1185 tegra_phy->ulpi = phy; in tegra_usb_phy_probe()
1186 tegra_phy->ulpi->io_priv = tegra_phy->regs + ULPI_VIEWPORT; in tegra_usb_phy_probe()
1190 dev_err(&pdev->dev, "phy_type %u is invalid or unsupported\n", in tegra_usb_phy_probe()
1192 return -EINVAL; in tegra_usb_phy_probe()
1195 tegra_phy->u_phy.dev = &pdev->dev; in tegra_usb_phy_probe()
1196 tegra_phy->u_phy.init = tegra_usb_phy_init; in tegra_usb_phy_probe()
1197 tegra_phy->u_phy.shutdown = tegra_usb_phy_shutdown; in tegra_usb_phy_probe()
1198 tegra_phy->u_phy.set_suspend = tegra_usb_phy_set_suspend; in tegra_usb_phy_probe()
1202 return usb_add_phy_dev(&tegra_phy->u_phy); in tegra_usb_phy_probe()
1209 usb_remove_phy(&tegra_phy->u_phy); in tegra_usb_phy_remove()
1218 .name = "tegra-phy",