Lines Matching +full:tegra124 +full:- +full:usb +full:- +full:phy
1 // SPDX-License-Identifier: GPL-2.0-only
10 #include <linux/phy/phy.h>
20 #include <dt-bindings/pinctrl/pinctrl-tegra-xusb.h>
23 #include "../pinctrl-utils.h"
91 struct phy *phys[2];
99 writel(value, padctl->regs + offset); in padctl_writel()
105 return readl(padctl->regs + offset); in padctl_readl()
112 return padctl->soc->num_pins; in tegra_xusb_padctl_get_groups_count()
120 return padctl->soc->pins[group].name; in tegra_xusb_padctl_get_group_name()
129 * For the tegra-xusb pad controller groups are synonymous in tegra_xusb_padctl_get_group_pins()
132 *pins = &pinctrl->desc->pins[group].number; in tegra_xusb_padctl_get_group_pins()
168 if (err != -EINVAL) in tegra_xusb_padctl_parse_subnode()
177 if (err == -EINVAL) in tegra_xusb_padctl_parse_subnode()
185 err = pinctrl_utils_add_config(padctl->pinctrl, &configs, in tegra_xusb_padctl_parse_subnode()
203 err = pinctrl_utils_reserve_map(padctl->pinctrl, maps, reserved_maps, in tegra_xusb_padctl_parse_subnode()
210 err = pinctrl_utils_add_map_mux(padctl->pinctrl, maps, in tegra_xusb_padctl_parse_subnode()
218 err = pinctrl_utils_add_map_configs(padctl->pinctrl, in tegra_xusb_padctl_parse_subnode()
272 return padctl->soc->num_functions; in tegra_xusb_padctl_get_functions_count()
281 return padctl->soc->functions[function].name; in tegra_xusb_padctl_get_function_name()
291 *num_groups = padctl->soc->functions[function].num_groups; in tegra_xusb_padctl_get_function_groups()
292 *groups = padctl->soc->functions[function].groups; in tegra_xusb_padctl_get_function_groups()
306 lane = &padctl->soc->lanes[group]; in tegra_xusb_padctl_pinmux_set()
308 for (i = 0; i < lane->num_funcs; i++) in tegra_xusb_padctl_pinmux_set()
309 if (lane->funcs[i] == function) in tegra_xusb_padctl_pinmux_set()
312 if (i >= lane->num_funcs) in tegra_xusb_padctl_pinmux_set()
313 return -EINVAL; in tegra_xusb_padctl_pinmux_set()
315 value = padctl_readl(padctl, lane->offset); in tegra_xusb_padctl_pinmux_set()
316 value &= ~(lane->mask << lane->shift); in tegra_xusb_padctl_pinmux_set()
317 value |= i << lane->shift; in tegra_xusb_padctl_pinmux_set()
318 padctl_writel(padctl, value, lane->offset); in tegra_xusb_padctl_pinmux_set()
340 lane = &padctl->soc->lanes[group]; in tegra_xusb_padctl_pinconf_group_get()
345 if (lane->iddq == 0) in tegra_xusb_padctl_pinconf_group_get()
346 return -EINVAL; in tegra_xusb_padctl_pinconf_group_get()
348 value = padctl_readl(padctl, lane->offset); in tegra_xusb_padctl_pinconf_group_get()
350 if (value & BIT(lane->iddq)) in tegra_xusb_padctl_pinconf_group_get()
359 dev_err(padctl->dev, "invalid configuration parameter: %04x\n", in tegra_xusb_padctl_pinconf_group_get()
361 return -ENOTSUPP; in tegra_xusb_padctl_pinconf_group_get()
379 lane = &padctl->soc->lanes[group]; in tegra_xusb_padctl_pinconf_group_set()
388 if (lane->iddq == 0) in tegra_xusb_padctl_pinconf_group_set()
389 return -EINVAL; in tegra_xusb_padctl_pinconf_group_set()
391 regval = padctl_readl(padctl, lane->offset); in tegra_xusb_padctl_pinconf_group_set()
394 regval &= ~BIT(lane->iddq); in tegra_xusb_padctl_pinconf_group_set()
396 regval |= BIT(lane->iddq); in tegra_xusb_padctl_pinconf_group_set()
398 padctl_writel(padctl, regval, lane->offset); in tegra_xusb_padctl_pinconf_group_set()
402 dev_err(padctl->dev, in tegra_xusb_padctl_pinconf_group_set()
405 return -ENOTSUPP; in tegra_xusb_padctl_pinconf_group_set()
484 mutex_lock(&padctl->lock); in tegra_xusb_padctl_enable()
486 if (padctl->enable++ > 0) in tegra_xusb_padctl_enable()
506 mutex_unlock(&padctl->lock); in tegra_xusb_padctl_enable()
514 mutex_lock(&padctl->lock); in tegra_xusb_padctl_disable()
516 if (WARN_ON(padctl->enable == 0)) in tegra_xusb_padctl_disable()
519 if (--padctl->enable > 0) in tegra_xusb_padctl_disable()
539 mutex_unlock(&padctl->lock); in tegra_xusb_padctl_disable()
543 static int tegra_xusb_phy_init(struct phy *phy) in tegra_xusb_phy_init() argument
545 struct tegra_xusb_padctl *padctl = phy_get_drvdata(phy); in tegra_xusb_phy_init()
550 static int tegra_xusb_phy_exit(struct phy *phy) in tegra_xusb_phy_exit() argument
552 struct tegra_xusb_padctl *padctl = phy_get_drvdata(phy); in tegra_xusb_phy_exit()
557 static int pcie_phy_power_on(struct phy *phy) in pcie_phy_power_on() argument
559 struct tegra_xusb_padctl *padctl = phy_get_drvdata(phy); in pcie_phy_power_on()
561 int err = -ETIMEDOUT; in pcie_phy_power_on()
593 static int pcie_phy_power_off(struct phy *phy) in pcie_phy_power_off() argument
595 struct tegra_xusb_padctl *padctl = phy_get_drvdata(phy); in pcie_phy_power_off()
613 static int sata_phy_power_on(struct phy *phy) in sata_phy_power_on() argument
615 struct tegra_xusb_padctl *padctl = phy_get_drvdata(phy); in sata_phy_power_on()
617 int err = -ETIMEDOUT; in sata_phy_power_on()
653 static int sata_phy_power_off(struct phy *phy) in sata_phy_power_off() argument
655 struct tegra_xusb_padctl *padctl = phy_get_drvdata(phy); in sata_phy_power_off()
687 static struct phy *tegra_xusb_padctl_xlate(struct device *dev, in tegra_xusb_padctl_xlate()
691 unsigned int index = args->args[0]; in tegra_xusb_padctl_xlate()
693 if (args->args_count <= 0) in tegra_xusb_padctl_xlate()
694 return ERR_PTR(-EINVAL); in tegra_xusb_padctl_xlate()
696 if (index >= ARRAY_SIZE(padctl->phys)) in tegra_xusb_padctl_xlate()
697 return ERR_PTR(-EINVAL); in tegra_xusb_padctl_xlate()
699 return padctl->phys[index]; in tegra_xusb_padctl_xlate()
716 PINCTRL_PIN(PIN_OTG_0, "otg-0"),
717 PINCTRL_PIN(PIN_OTG_1, "otg-1"),
718 PINCTRL_PIN(PIN_OTG_2, "otg-2"),
719 PINCTRL_PIN(PIN_ULPI_0, "ulpi-0"),
720 PINCTRL_PIN(PIN_HSIC_0, "hsic-0"),
721 PINCTRL_PIN(PIN_HSIC_1, "hsic-1"),
722 PINCTRL_PIN(PIN_PCIE_0, "pcie-0"),
723 PINCTRL_PIN(PIN_PCIE_1, "pcie-1"),
724 PINCTRL_PIN(PIN_PCIE_2, "pcie-2"),
725 PINCTRL_PIN(PIN_PCIE_3, "pcie-3"),
726 PINCTRL_PIN(PIN_PCIE_4, "pcie-4"),
727 PINCTRL_PIN(PIN_SATA_0, "sata-0"),
731 "otg-0",
732 "otg-1",
733 "otg-2",
734 "ulpi-0",
735 "hsic-0",
736 "hsic-1",
740 "otg-0",
741 "otg-1",
742 "otg-2",
743 "ulpi-0",
744 "hsic-0",
745 "hsic-1",
749 "otg-0",
750 "otg-1",
751 "otg-2",
755 "pcie-0",
756 "pcie-1",
757 "pcie-2",
758 "pcie-3",
759 "pcie-4",
763 "pcie-0",
764 "pcie-1",
765 "sata-0",
769 "sata-0",
773 "otg-0",
774 "otg-1",
775 "otg-2",
776 "pcie-0",
777 "pcie-1",
778 "pcie-2",
779 "pcie-3",
780 "pcie-4",
781 "sata-0",
842 TEGRA124_LANE("otg-0", 0x004, 0, 0x3, 0, otg),
843 TEGRA124_LANE("otg-1", 0x004, 2, 0x3, 0, otg),
844 TEGRA124_LANE("otg-2", 0x004, 4, 0x3, 0, otg),
845 TEGRA124_LANE("ulpi-0", 0x004, 12, 0x1, 0, usb),
846 TEGRA124_LANE("hsic-0", 0x004, 14, 0x1, 0, usb),
847 TEGRA124_LANE("hsic-1", 0x004, 15, 0x1, 0, usb),
848 TEGRA124_LANE("pcie-0", 0x134, 16, 0x3, 1, pci),
849 TEGRA124_LANE("pcie-1", 0x134, 18, 0x3, 2, pci),
850 TEGRA124_LANE("pcie-2", 0x134, 20, 0x3, 3, pci),
851 TEGRA124_LANE("pcie-3", 0x134, 22, 0x3, 4, pci),
852 TEGRA124_LANE("pcie-4", 0x134, 24, 0x3, 5, pci),
853 TEGRA124_LANE("sata-0", 0x134, 26, 0x3, 6, pci),
866 { .compatible = "nvidia,tegra124-xusb-padctl", .data = &tegra124_soc },
879 struct phy *phy; in tegra_xusb_padctl_legacy_probe() local
882 padctl = devm_kzalloc(&pdev->dev, sizeof(*padctl), GFP_KERNEL); in tegra_xusb_padctl_legacy_probe()
884 return -ENOMEM; in tegra_xusb_padctl_legacy_probe()
887 mutex_init(&padctl->lock); in tegra_xusb_padctl_legacy_probe()
888 padctl->dev = &pdev->dev; in tegra_xusb_padctl_legacy_probe()
893 * Tegra124. of_device_get_match_data() would attempt to use the table in tegra_xusb_padctl_legacy_probe()
896 match = of_match_node(tegra_xusb_padctl_of_match, pdev->dev.of_node); in tegra_xusb_padctl_legacy_probe()
897 padctl->soc = match->data; in tegra_xusb_padctl_legacy_probe()
899 padctl->regs = devm_platform_ioremap_resource(pdev, 0); in tegra_xusb_padctl_legacy_probe()
900 if (IS_ERR(padctl->regs)) in tegra_xusb_padctl_legacy_probe()
901 return PTR_ERR(padctl->regs); in tegra_xusb_padctl_legacy_probe()
903 padctl->rst = devm_reset_control_get_exclusive(&pdev->dev, NULL); in tegra_xusb_padctl_legacy_probe()
904 if (IS_ERR(padctl->rst)) in tegra_xusb_padctl_legacy_probe()
905 return PTR_ERR(padctl->rst); in tegra_xusb_padctl_legacy_probe()
907 err = reset_control_deassert(padctl->rst); in tegra_xusb_padctl_legacy_probe()
911 memset(&padctl->desc, 0, sizeof(padctl->desc)); in tegra_xusb_padctl_legacy_probe()
912 padctl->desc.name = dev_name(padctl->dev); in tegra_xusb_padctl_legacy_probe()
913 padctl->desc.pins = tegra124_pins; in tegra_xusb_padctl_legacy_probe()
914 padctl->desc.npins = ARRAY_SIZE(tegra124_pins); in tegra_xusb_padctl_legacy_probe()
915 padctl->desc.pctlops = &tegra_xusb_padctl_pinctrl_ops; in tegra_xusb_padctl_legacy_probe()
916 padctl->desc.pmxops = &tegra_xusb_padctl_pinmux_ops; in tegra_xusb_padctl_legacy_probe()
917 padctl->desc.confops = &tegra_xusb_padctl_pinconf_ops; in tegra_xusb_padctl_legacy_probe()
918 padctl->desc.owner = THIS_MODULE; in tegra_xusb_padctl_legacy_probe()
920 padctl->pinctrl = devm_pinctrl_register(&pdev->dev, &padctl->desc, in tegra_xusb_padctl_legacy_probe()
922 if (IS_ERR(padctl->pinctrl)) { in tegra_xusb_padctl_legacy_probe()
923 dev_err(&pdev->dev, "failed to register pincontrol\n"); in tegra_xusb_padctl_legacy_probe()
924 err = PTR_ERR(padctl->pinctrl); in tegra_xusb_padctl_legacy_probe()
928 phy = devm_phy_create(&pdev->dev, NULL, &pcie_phy_ops); in tegra_xusb_padctl_legacy_probe()
929 if (IS_ERR(phy)) { in tegra_xusb_padctl_legacy_probe()
930 err = PTR_ERR(phy); in tegra_xusb_padctl_legacy_probe()
934 padctl->phys[TEGRA_XUSB_PADCTL_PCIE] = phy; in tegra_xusb_padctl_legacy_probe()
935 phy_set_drvdata(phy, padctl); in tegra_xusb_padctl_legacy_probe()
937 phy = devm_phy_create(&pdev->dev, NULL, &sata_phy_ops); in tegra_xusb_padctl_legacy_probe()
938 if (IS_ERR(phy)) { in tegra_xusb_padctl_legacy_probe()
939 err = PTR_ERR(phy); in tegra_xusb_padctl_legacy_probe()
943 padctl->phys[TEGRA_XUSB_PADCTL_SATA] = phy; in tegra_xusb_padctl_legacy_probe()
944 phy_set_drvdata(phy, padctl); in tegra_xusb_padctl_legacy_probe()
946 padctl->provider = devm_of_phy_provider_register(&pdev->dev, in tegra_xusb_padctl_legacy_probe()
948 if (IS_ERR(padctl->provider)) { in tegra_xusb_padctl_legacy_probe()
949 err = PTR_ERR(padctl->provider); in tegra_xusb_padctl_legacy_probe()
950 dev_err(&pdev->dev, "failed to register PHYs: %d\n", err); in tegra_xusb_padctl_legacy_probe()
957 reset_control_assert(padctl->rst); in tegra_xusb_padctl_legacy_probe()
967 err = reset_control_assert(padctl->rst); in tegra_xusb_padctl_legacy_remove()
969 dev_err(&pdev->dev, "failed to assert reset: %d\n", err); in tegra_xusb_padctl_legacy_remove()