Lines Matching +full:tegra194 +full:- +full:pcie

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2014-2022, NVIDIA CORPORATION. All rights reserved.
31 if (args->args_count != 0) in tegra_xusb_pad_of_xlate()
32 return ERR_PTR(-EINVAL); in tegra_xusb_pad_of_xlate()
34 for (i = 0; i < pad->soc->num_lanes; i++) { in tegra_xusb_pad_of_xlate()
35 if (!pad->lanes[i]) in tegra_xusb_pad_of_xlate()
38 if (pad->lanes[i]->dev.of_node == args->np) { in tegra_xusb_pad_of_xlate()
39 phy = pad->lanes[i]; in tegra_xusb_pad_of_xlate()
45 phy = ERR_PTR(-ENODEV); in tegra_xusb_pad_of_xlate()
53 .compatible = "nvidia,tegra124-xusb-padctl",
59 .compatible = "nvidia,tegra210-xusb-padctl",
65 .compatible = "nvidia,tegra186-xusb-padctl",
71 .compatible = "nvidia,tegra194-xusb-padctl",
77 .compatible = "nvidia,tegra234-xusb-padctl",
90 pads = of_get_child_by_name(padctl->dev->of_node, "pads"); in tegra_xusb_find_pad_node()
105 lanes = of_get_child_by_name(pad->dev.of_node, "lanes"); in tegra_xusb_pad_find_phy_node()
109 np = of_get_child_by_name(lanes, pad->soc->lanes[index].name); in tegra_xusb_pad_find_phy_node()
118 struct device *dev = &lane->pad->dev; in tegra_xusb_lane_parse_dt()
126 err = match_string(lane->soc->funcs, lane->soc->num_funcs, function); in tegra_xusb_lane_parse_dt()
133 lane->function = err; in tegra_xusb_lane_parse_dt()
143 lane->pad->ops->remove(lane); in tegra_xusb_lane_destroy()
152 pad->soc->ops->remove(pad); in tegra_xusb_pad_release()
165 device_initialize(&pad->dev); in tegra_xusb_pad_init()
166 INIT_LIST_HEAD(&pad->list); in tegra_xusb_pad_init()
167 pad->dev.parent = padctl->dev; in tegra_xusb_pad_init()
168 pad->dev.type = &tegra_xusb_pad_type; in tegra_xusb_pad_init()
169 pad->dev.of_node = np; in tegra_xusb_pad_init()
170 pad->padctl = padctl; in tegra_xusb_pad_init()
172 err = dev_set_name(&pad->dev, "%s", pad->soc->name); in tegra_xusb_pad_init()
176 err = device_add(&pad->dev); in tegra_xusb_pad_init()
183 device_unregister(&pad->dev); in tegra_xusb_pad_init()
195 children = of_get_child_by_name(pad->dev.of_node, "lanes"); in tegra_xusb_pad_register()
197 return -ENODEV; in tegra_xusb_pad_register()
199 pad->lanes = devm_kcalloc(&pad->dev, pad->soc->num_lanes, sizeof(lane), in tegra_xusb_pad_register()
201 if (!pad->lanes) { in tegra_xusb_pad_register()
203 return -ENOMEM; in tegra_xusb_pad_register()
206 for (i = 0; i < pad->soc->num_lanes; i++) { in tegra_xusb_pad_register()
216 pad->lanes[i] = phy_create(&pad->dev, np, ops); in tegra_xusb_pad_register()
217 if (IS_ERR(pad->lanes[i])) { in tegra_xusb_pad_register()
218 err = PTR_ERR(pad->lanes[i]); in tegra_xusb_pad_register()
223 lane = pad->ops->probe(pad, np, i); in tegra_xusb_pad_register()
225 phy_destroy(pad->lanes[i]); in tegra_xusb_pad_register()
230 list_add_tail(&lane->list, &pad->padctl->lanes); in tegra_xusb_pad_register()
231 phy_set_drvdata(pad->lanes[i], lane); in tegra_xusb_pad_register()
234 pad->provider = of_phy_provider_register_full(&pad->dev, children, in tegra_xusb_pad_register()
236 if (IS_ERR(pad->provider)) { in tegra_xusb_pad_register()
237 err = PTR_ERR(pad->provider); in tegra_xusb_pad_register()
244 while (i--) in tegra_xusb_pad_register()
245 tegra_xusb_lane_destroy(pad->lanes[i]); in tegra_xusb_pad_register()
254 unsigned int i = pad->soc->num_lanes; in tegra_xusb_pad_unregister()
256 of_phy_provider_unregister(pad->provider); in tegra_xusb_pad_unregister()
258 while (i--) in tegra_xusb_pad_unregister()
259 tegra_xusb_lane_destroy(pad->lanes[i]); in tegra_xusb_pad_unregister()
261 device_unregister(&pad->dev); in tegra_xusb_pad_unregister()
272 np = tegra_xusb_find_pad_node(padctl, soc->name); in tegra_xusb_pad_create()
276 pad = soc->ops->probe(padctl, soc, np); in tegra_xusb_pad_create()
279 dev_err(padctl->dev, "failed to create pad %s: %d\n", in tegra_xusb_pad_create()
280 soc->name, err); in tegra_xusb_pad_create()
284 /* XXX move this into ->probe() to avoid string comparison */ in tegra_xusb_pad_create()
285 if (strcmp(soc->name, "pcie") == 0) in tegra_xusb_pad_create()
286 padctl->pcie = pad; in tegra_xusb_pad_create()
288 if (strcmp(soc->name, "sata") == 0) in tegra_xusb_pad_create()
289 padctl->sata = pad; in tegra_xusb_pad_create()
291 if (strcmp(soc->name, "usb2") == 0) in tegra_xusb_pad_create()
292 padctl->usb2 = pad; in tegra_xusb_pad_create()
294 if (strcmp(soc->name, "ulpi") == 0) in tegra_xusb_pad_create()
295 padctl->ulpi = pad; in tegra_xusb_pad_create()
297 if (strcmp(soc->name, "hsic") == 0) in tegra_xusb_pad_create()
298 padctl->hsic = pad; in tegra_xusb_pad_create()
307 list_for_each_entry_safe_reverse(pad, tmp, &padctl->pads, list) { in __tegra_xusb_remove_pads()
308 list_del(&pad->list); in __tegra_xusb_remove_pads()
315 mutex_lock(&padctl->lock); in tegra_xusb_remove_pads()
317 mutex_unlock(&padctl->lock); in tegra_xusb_remove_pads()
322 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra_xusb_lane_program()
323 const struct tegra_xusb_lane_soc *soc = lane->soc; in tegra_xusb_lane_program()
327 if (soc->num_funcs < 2) in tegra_xusb_lane_program()
330 if (lane->pad->ops->iddq_enable) in tegra_xusb_lane_program()
331 lane->pad->ops->iddq_enable(lane); in tegra_xusb_lane_program()
334 value = padctl_readl(padctl, soc->offset); in tegra_xusb_lane_program()
335 value &= ~(soc->mask << soc->shift); in tegra_xusb_lane_program()
336 value |= lane->function << soc->shift; in tegra_xusb_lane_program()
337 padctl_writel(padctl, value, soc->offset); in tegra_xusb_lane_program()
339 if (lane->pad->ops->iddq_disable) in tegra_xusb_lane_program()
340 lane->pad->ops->iddq_disable(lane); in tegra_xusb_lane_program()
347 for (i = 0; i < pad->soc->num_lanes; i++) { in tegra_xusb_pad_program()
350 if (pad->lanes[i]) { in tegra_xusb_pad_program()
351 lane = phy_get_drvdata(pad->lanes[i]); in tegra_xusb_pad_program()
362 mutex_lock(&padctl->lock); in tegra_xusb_setup_pads()
364 for (i = 0; i < padctl->soc->num_pads; i++) { in tegra_xusb_setup_pads()
365 const struct tegra_xusb_pad_soc *soc = padctl->soc->pads[i]; in tegra_xusb_setup_pads()
371 dev_err(padctl->dev, "failed to create pad %s: %d\n", in tegra_xusb_setup_pads()
372 soc->name, err); in tegra_xusb_setup_pads()
374 mutex_unlock(&padctl->lock); in tegra_xusb_setup_pads()
381 list_add_tail(&pad->list, &padctl->pads); in tegra_xusb_setup_pads()
384 list_for_each_entry(pad, &padctl->pads, list) in tegra_xusb_setup_pads()
387 mutex_unlock(&padctl->lock); in tegra_xusb_setup_pads()
394 const char *func = lane->soc->funcs[lane->function]; in tegra_xusb_lane_check()
403 struct tegra_xusb_lane *lane, *hit = ERR_PTR(-ENODEV); in tegra_xusb_find_lane()
406 name = kasprintf(GFP_KERNEL, "%s-%u", type, index); in tegra_xusb_find_lane()
408 return ERR_PTR(-ENOMEM); in tegra_xusb_find_lane()
410 list_for_each_entry(lane, &padctl->lanes, list) { in tegra_xusb_find_lane()
411 if (strcmp(lane->soc->name, name) == 0) { in tegra_xusb_find_lane()
426 struct tegra_xusb_lane *lane, *match = ERR_PTR(-ENODEV); in tegra_xusb_port_find_lane()
428 for (; map->type; map++) { in tegra_xusb_port_find_lane()
429 if (port->index != map->port) in tegra_xusb_port_find_lane()
432 lane = tegra_xusb_find_lane(port->padctl, map->type, in tegra_xusb_port_find_lane()
433 map->index); in tegra_xusb_port_find_lane()
441 dev_err(&port->dev, "conflicting match: %s-%u / %s\n", in tegra_xusb_port_find_lane()
442 map->type, map->index, match->soc->name); in tegra_xusb_port_find_lane()
457 ports = of_get_child_by_name(padctl->dev->of_node, "ports"); in tegra_xusb_find_port_node()
461 name = kasprintf(GFP_KERNEL, "%s-%u", type, index); in tegra_xusb_find_port_node()
484 list_for_each_entry(port, &padctl->ports, list) { in tegra_xusb_find_port()
485 if (np == port->dev.of_node) { in tegra_xusb_find_port()
524 if (port->ops->release) in tegra_xusb_port_release()
525 port->ops->release(port); in tegra_xusb_port_release()
540 INIT_LIST_HEAD(&port->list); in tegra_xusb_port_init()
541 port->padctl = padctl; in tegra_xusb_port_init()
542 port->index = index; in tegra_xusb_port_init()
544 device_initialize(&port->dev); in tegra_xusb_port_init()
545 port->dev.type = &tegra_xusb_port_type; in tegra_xusb_port_init()
546 port->dev.of_node = of_node_get(np); in tegra_xusb_port_init()
547 port->dev.parent = padctl->dev; in tegra_xusb_port_init()
549 err = dev_set_name(&port->dev, "%s-%u", name, index); in tegra_xusb_port_init()
553 err = device_add(&port->dev); in tegra_xusb_port_init()
560 device_unregister(&port->dev); in tegra_xusb_port_init()
566 if (!IS_ERR_OR_NULL(port->usb_role_sw)) { in tegra_xusb_port_unregister()
567 of_platform_depopulate(&port->dev); in tegra_xusb_port_unregister()
568 usb_role_switch_unregister(port->usb_role_sw); in tegra_xusb_port_unregister()
569 cancel_work_sync(&port->usb_phy_work); in tegra_xusb_port_unregister()
570 usb_remove_phy(&port->usb_phy); in tegra_xusb_port_unregister()
571 port->usb_phy.dev->driver = NULL; in tegra_xusb_port_unregister()
574 if (port->ops->remove) in tegra_xusb_port_unregister()
575 port->ops->remove(port); in tegra_xusb_port_unregister()
577 device_unregister(&port->dev); in tegra_xusb_port_unregister()
612 enum usb_role role = usb_role_switch_get_role(port->usb_role_sw); in tegra_xusb_usb_phy_work()
614 usb_phy_set_event(&port->usb_phy, to_usb_phy_event(role)); in tegra_xusb_usb_phy_work()
616 dev_dbg(&port->dev, "%s(): calling notifier for role %s\n", __func__, in tegra_xusb_usb_phy_work()
619 atomic_notifier_call_chain(&port->usb_phy.notifier, 0, &port->usb_phy); in tegra_xusb_usb_phy_work()
627 dev_dbg(&port->dev, "%s(): role %s\n", __func__, usb_roles[role]); in tegra_xusb_role_sw_set()
629 schedule_work(&port->usb_phy_work); in tegra_xusb_role_sw_set()
637 struct tegra_xusb_port *port = container_of(otg->usb_phy, in tegra_xusb_set_peripheral()
642 schedule_work(&port->usb_phy_work); in tegra_xusb_set_peripheral()
649 struct tegra_xusb_port *port = container_of(otg->usb_phy, in tegra_xusb_set_host()
654 schedule_work(&port->usb_phy_work); in tegra_xusb_set_host()
664 .fwnode = dev_fwnode(&port->dev), in tegra_xusb_setup_usb_role_switch()
672 * suboptimal solution. TODO: Need to revisit this in a follow-up patch in tegra_xusb_setup_usb_role_switch()
676 port->dev.driver = devm_kzalloc(&port->dev, in tegra_xusb_setup_usb_role_switch()
679 if (!port->dev.driver) in tegra_xusb_setup_usb_role_switch()
680 return -ENOMEM; in tegra_xusb_setup_usb_role_switch()
682 port->dev.driver->owner = THIS_MODULE; in tegra_xusb_setup_usb_role_switch()
684 port->usb_role_sw = usb_role_switch_register(&port->dev, in tegra_xusb_setup_usb_role_switch()
686 if (IS_ERR(port->usb_role_sw)) { in tegra_xusb_setup_usb_role_switch()
687 err = PTR_ERR(port->usb_role_sw); in tegra_xusb_setup_usb_role_switch()
688 dev_err(&port->dev, "failed to register USB role switch: %d", in tegra_xusb_setup_usb_role_switch()
693 INIT_WORK(&port->usb_phy_work, tegra_xusb_usb_phy_work); in tegra_xusb_setup_usb_role_switch()
694 usb_role_switch_set_drvdata(port->usb_role_sw, port); in tegra_xusb_setup_usb_role_switch()
696 port->usb_phy.otg = devm_kzalloc(&port->dev, sizeof(struct usb_otg), in tegra_xusb_setup_usb_role_switch()
698 if (!port->usb_phy.otg) in tegra_xusb_setup_usb_role_switch()
699 return -ENOMEM; in tegra_xusb_setup_usb_role_switch()
701 lane = tegra_xusb_find_lane(port->padctl, "usb2", port->index); in tegra_xusb_setup_usb_role_switch()
706 * Assign phy dev to usb-phy dev. Host/device drivers can use phy in tegra_xusb_setup_usb_role_switch()
707 * reference to retrieve usb-phy details. in tegra_xusb_setup_usb_role_switch()
709 port->usb_phy.dev = &lane->pad->lanes[port->index]->dev; in tegra_xusb_setup_usb_role_switch()
710 port->usb_phy.dev->driver = port->dev.driver; in tegra_xusb_setup_usb_role_switch()
711 port->usb_phy.otg->usb_phy = &port->usb_phy; in tegra_xusb_setup_usb_role_switch()
712 port->usb_phy.otg->set_peripheral = tegra_xusb_set_peripheral; in tegra_xusb_setup_usb_role_switch()
713 port->usb_phy.otg->set_host = tegra_xusb_set_host; in tegra_xusb_setup_usb_role_switch()
715 err = usb_add_phy_dev(&port->usb_phy); in tegra_xusb_setup_usb_role_switch()
717 dev_err(&port->dev, "Failed to add USB PHY: %d\n", err); in tegra_xusb_setup_usb_role_switch()
722 of_platform_populate(port->dev.of_node, NULL, NULL, &port->dev); in tegra_xusb_setup_usb_role_switch()
730 enum usb_dr_mode mode = usb_get_role_switch_default_mode(&port->dev); in tegra_xusb_parse_usb_role_default_mode()
738 usb_role_switch_set_role(port->usb_role_sw, role); in tegra_xusb_parse_usb_role_default_mode()
739 dev_dbg(&port->dev, "usb role default mode is %s", modes[mode]); in tegra_xusb_parse_usb_role_default_mode()
745 struct tegra_xusb_port *port = &usb2->base; in tegra_xusb_usb2_port_parse_dt()
746 struct device_node *np = port->dev.of_node; in tegra_xusb_usb2_port_parse_dt()
750 usb2->internal = of_property_read_bool(np, "nvidia,internal"); in tegra_xusb_usb2_port_parse_dt()
755 dev_err(&port->dev, "invalid value %s for \"mode\"\n", in tegra_xusb_usb2_port_parse_dt()
757 usb2->mode = USB_DR_MODE_UNKNOWN; in tegra_xusb_usb2_port_parse_dt()
759 usb2->mode = err; in tegra_xusb_usb2_port_parse_dt()
762 usb2->mode = USB_DR_MODE_HOST; in tegra_xusb_usb2_port_parse_dt()
765 /* usb-role-switch property is mandatory for OTG/Peripheral modes */ in tegra_xusb_usb2_port_parse_dt()
766 if (usb2->mode == USB_DR_MODE_PERIPHERAL || in tegra_xusb_usb2_port_parse_dt()
767 usb2->mode == USB_DR_MODE_OTG) { in tegra_xusb_usb2_port_parse_dt()
768 if (of_property_read_bool(np, "usb-role-switch")) { in tegra_xusb_usb2_port_parse_dt()
774 dev_err(&port->dev, "usb-role-switch not found for %s mode", in tegra_xusb_usb2_port_parse_dt()
775 modes[usb2->mode]); in tegra_xusb_usb2_port_parse_dt()
776 return -EINVAL; in tegra_xusb_usb2_port_parse_dt()
780 usb2->supply = regulator_get(&port->dev, "vbus"); in tegra_xusb_usb2_port_parse_dt()
781 return PTR_ERR_OR_ZERO(usb2->supply); in tegra_xusb_usb2_port_parse_dt()
801 err = -ENOMEM; in tegra_xusb_add_usb2_port()
805 err = tegra_xusb_port_init(&usb2->base, padctl, np, "usb2", index); in tegra_xusb_add_usb2_port()
809 usb2->base.ops = padctl->soc->ports.usb2.ops; in tegra_xusb_add_usb2_port()
811 usb2->base.lane = usb2->base.ops->map(&usb2->base); in tegra_xusb_add_usb2_port()
812 if (IS_ERR(usb2->base.lane)) { in tegra_xusb_add_usb2_port()
813 err = PTR_ERR(usb2->base.lane); in tegra_xusb_add_usb2_port()
814 tegra_xusb_port_unregister(&usb2->base); in tegra_xusb_add_usb2_port()
820 tegra_xusb_port_unregister(&usb2->base); in tegra_xusb_add_usb2_port()
824 list_add_tail(&usb2->base.list, &padctl->ports); in tegra_xusb_add_usb2_port()
842 regulator_put(usb2->supply); in tegra_xusb_usb2_port_remove()
847 struct tegra_xusb_port *port = &ulpi->base; in tegra_xusb_ulpi_port_parse_dt()
848 struct device_node *np = port->dev.of_node; in tegra_xusb_ulpi_port_parse_dt()
850 ulpi->internal = of_property_read_bool(np, "nvidia,internal"); in tegra_xusb_ulpi_port_parse_dt()
868 err = -ENOMEM; in tegra_xusb_add_ulpi_port()
872 err = tegra_xusb_port_init(&ulpi->base, padctl, np, "ulpi", index); in tegra_xusb_add_ulpi_port()
876 ulpi->base.ops = padctl->soc->ports.ulpi.ops; in tegra_xusb_add_ulpi_port()
878 ulpi->base.lane = ulpi->base.ops->map(&ulpi->base); in tegra_xusb_add_ulpi_port()
879 if (IS_ERR(ulpi->base.lane)) { in tegra_xusb_add_ulpi_port()
880 err = PTR_ERR(ulpi->base.lane); in tegra_xusb_add_ulpi_port()
881 tegra_xusb_port_unregister(&ulpi->base); in tegra_xusb_add_ulpi_port()
887 tegra_xusb_port_unregister(&ulpi->base); in tegra_xusb_add_ulpi_port()
891 list_add_tail(&ulpi->base.list, &padctl->ports); in tegra_xusb_add_ulpi_port()
924 err = -ENOMEM; in tegra_xusb_add_hsic_port()
928 err = tegra_xusb_port_init(&hsic->base, padctl, np, "hsic", index); in tegra_xusb_add_hsic_port()
932 hsic->base.ops = padctl->soc->ports.hsic.ops; in tegra_xusb_add_hsic_port()
934 hsic->base.lane = hsic->base.ops->map(&hsic->base); in tegra_xusb_add_hsic_port()
935 if (IS_ERR(hsic->base.lane)) { in tegra_xusb_add_hsic_port()
936 err = PTR_ERR(hsic->base.lane); in tegra_xusb_add_hsic_port()
942 tegra_xusb_port_unregister(&hsic->base); in tegra_xusb_add_hsic_port()
946 list_add_tail(&hsic->base.list, &padctl->ports); in tegra_xusb_add_hsic_port()
962 struct tegra_xusb_port *port = &usb3->base; in tegra_xusb_usb3_port_parse_dt()
963 struct device_node *np = port->dev.of_node; in tegra_xusb_usb3_port_parse_dt()
968 err = of_property_read_u32(np, "nvidia,usb2-companion", &value); in tegra_xusb_usb3_port_parse_dt()
970 dev_err(&port->dev, "failed to read port: %d\n", err); in tegra_xusb_usb3_port_parse_dt()
974 usb3->port = value; in tegra_xusb_usb3_port_parse_dt()
976 usb3->internal = of_property_read_bool(np, "nvidia,internal"); in tegra_xusb_usb3_port_parse_dt()
978 if (device_property_present(&port->dev, "maximum-speed")) { in tegra_xusb_usb3_port_parse_dt()
979 maximum_speed = usb_get_maximum_speed(&port->dev); in tegra_xusb_usb3_port_parse_dt()
981 usb3->disable_gen2 = true; in tegra_xusb_usb3_port_parse_dt()
983 usb3->disable_gen2 = false; in tegra_xusb_usb3_port_parse_dt()
985 return -EINVAL; in tegra_xusb_usb3_port_parse_dt()
1009 err = -ENOMEM; in tegra_xusb_add_usb3_port()
1013 err = tegra_xusb_port_init(&usb3->base, padctl, np, "usb3", index); in tegra_xusb_add_usb3_port()
1017 usb3->base.ops = padctl->soc->ports.usb3.ops; in tegra_xusb_add_usb3_port()
1019 usb3->base.lane = usb3->base.ops->map(&usb3->base); in tegra_xusb_add_usb3_port()
1020 if (IS_ERR(usb3->base.lane)) { in tegra_xusb_add_usb3_port()
1021 err = PTR_ERR(usb3->base.lane); in tegra_xusb_add_usb3_port()
1027 tegra_xusb_port_unregister(&usb3->base); in tegra_xusb_add_usb3_port()
1031 list_add_tail(&usb3->base.list, &padctl->ports); in tegra_xusb_add_usb3_port()
1049 list_for_each_entry_safe_reverse(port, tmp, &padctl->ports, list) { in __tegra_xusb_remove_ports()
1050 list_del(&port->list); in __tegra_xusb_remove_ports()
1060 for (i = 0; i < padctl->soc->ports.usb3.count; i++) { in tegra_xusb_find_unused_usb3_port()
1066 return -ENODEV; in tegra_xusb_find_unused_usb3_port()
1073 struct tegra_xusb_padctl *padctl = usb2->base.padctl; in tegra_xusb_port_is_companion()
1075 for (i = 0; i < padctl->soc->ports.usb3.count; i++) { in tegra_xusb_port_is_companion()
1077 if (usb3 && usb3->port == usb2->base.index) in tegra_xusb_port_is_companion()
1089 usb2->usb3_port_fake = -1; in tegra_xusb_update_usb3_fake_port()
1091 if ((usb2->mode == USB_DR_MODE_OTG || in tegra_xusb_update_usb3_fake_port()
1092 usb2->mode == USB_DR_MODE_PERIPHERAL) && in tegra_xusb_update_usb3_fake_port()
1094 fake = tegra_xusb_find_unused_usb3_port(usb2->base.padctl); in tegra_xusb_update_usb3_fake_port()
1096 dev_err(&usb2->base.dev, "no unused USB3 ports available\n"); in tegra_xusb_update_usb3_fake_port()
1097 return -ENODEV; in tegra_xusb_update_usb3_fake_port()
1100 dev_dbg(&usb2->base.dev, "Found unused usb3 port: %d\n", fake); in tegra_xusb_update_usb3_fake_port()
1101 usb2->usb3_port_fake = fake; in tegra_xusb_update_usb3_fake_port()
1114 mutex_lock(&padctl->lock); in tegra_xusb_setup_ports()
1116 for (i = 0; i < padctl->soc->ports.usb2.count; i++) { in tegra_xusb_setup_ports()
1122 for (i = 0; i < padctl->soc->ports.ulpi.count; i++) { in tegra_xusb_setup_ports()
1128 for (i = 0; i < padctl->soc->ports.hsic.count; i++) { in tegra_xusb_setup_ports()
1134 for (i = 0; i < padctl->soc->ports.usb3.count; i++) { in tegra_xusb_setup_ports()
1140 if (padctl->soc->need_fake_usb3_port) { in tegra_xusb_setup_ports()
1141 for (i = 0; i < padctl->soc->ports.usb2.count; i++) { in tegra_xusb_setup_ports()
1152 list_for_each_entry(port, &padctl->ports, list) { in tegra_xusb_setup_ports()
1153 err = port->ops->enable(port); in tegra_xusb_setup_ports()
1155 dev_err(padctl->dev, "failed to enable port %s: %d\n", in tegra_xusb_setup_ports()
1156 dev_name(&port->dev), err); in tegra_xusb_setup_ports()
1164 mutex_unlock(&padctl->lock); in tegra_xusb_setup_ports()
1170 mutex_lock(&padctl->lock); in tegra_xusb_remove_ports()
1172 mutex_unlock(&padctl->lock); in tegra_xusb_remove_ports()
1177 struct device_node *np = pdev->dev.of_node; in tegra_xusb_padctl_probe()
1186 dev_warn(&pdev->dev, "deprecated DT, using legacy driver\n"); in tegra_xusb_padctl_probe()
1192 match = of_match_node(tegra_xusb_padctl_of_match, pdev->dev.of_node); in tegra_xusb_padctl_probe()
1193 soc = match->data; in tegra_xusb_padctl_probe()
1195 padctl = soc->ops->probe(&pdev->dev, soc); in tegra_xusb_padctl_probe()
1200 INIT_LIST_HEAD(&padctl->ports); in tegra_xusb_padctl_probe()
1201 INIT_LIST_HEAD(&padctl->lanes); in tegra_xusb_padctl_probe()
1202 INIT_LIST_HEAD(&padctl->pads); in tegra_xusb_padctl_probe()
1203 mutex_init(&padctl->lock); in tegra_xusb_padctl_probe()
1205 padctl->regs = devm_platform_ioremap_resource(pdev, 0); in tegra_xusb_padctl_probe()
1206 if (IS_ERR(padctl->regs)) { in tegra_xusb_padctl_probe()
1207 err = PTR_ERR(padctl->regs); in tegra_xusb_padctl_probe()
1211 padctl->rst = devm_reset_control_get(&pdev->dev, NULL); in tegra_xusb_padctl_probe()
1212 if (IS_ERR(padctl->rst)) { in tegra_xusb_padctl_probe()
1213 err = PTR_ERR(padctl->rst); in tegra_xusb_padctl_probe()
1217 padctl->supplies = devm_kcalloc(&pdev->dev, padctl->soc->num_supplies, in tegra_xusb_padctl_probe()
1218 sizeof(*padctl->supplies), GFP_KERNEL); in tegra_xusb_padctl_probe()
1219 if (!padctl->supplies) { in tegra_xusb_padctl_probe()
1220 err = -ENOMEM; in tegra_xusb_padctl_probe()
1224 regulator_bulk_set_supply_names(padctl->supplies, in tegra_xusb_padctl_probe()
1225 padctl->soc->supply_names, in tegra_xusb_padctl_probe()
1226 padctl->soc->num_supplies); in tegra_xusb_padctl_probe()
1228 err = devm_regulator_bulk_get(&pdev->dev, padctl->soc->num_supplies, in tegra_xusb_padctl_probe()
1229 padctl->supplies); in tegra_xusb_padctl_probe()
1231 dev_err_probe(&pdev->dev, err, "failed to get regulators\n"); in tegra_xusb_padctl_probe()
1235 err = reset_control_deassert(padctl->rst); in tegra_xusb_padctl_probe()
1239 err = regulator_bulk_enable(padctl->soc->num_supplies, in tegra_xusb_padctl_probe()
1240 padctl->supplies); in tegra_xusb_padctl_probe()
1242 dev_err(&pdev->dev, "failed to enable supplies: %d\n", err); in tegra_xusb_padctl_probe()
1248 dev_err(&pdev->dev, "failed to setup pads: %d\n", err); in tegra_xusb_padctl_probe()
1256 if (err == -EPROBE_DEFER) in tegra_xusb_padctl_probe()
1259 dev_printk(level, &pdev->dev, in tegra_xusb_padctl_probe()
1269 regulator_bulk_disable(padctl->soc->num_supplies, padctl->supplies); in tegra_xusb_padctl_probe()
1271 reset_control_assert(padctl->rst); in tegra_xusb_padctl_probe()
1274 soc->ops->remove(padctl); in tegra_xusb_padctl_probe()
1286 err = regulator_bulk_disable(padctl->soc->num_supplies, in tegra_xusb_padctl_remove()
1287 padctl->supplies); in tegra_xusb_padctl_remove()
1289 dev_err(&pdev->dev, "failed to disable supplies: %d\n", err); in tegra_xusb_padctl_remove()
1291 err = reset_control_assert(padctl->rst); in tegra_xusb_padctl_remove()
1293 dev_err(&pdev->dev, "failed to assert reset: %d\n", err); in tegra_xusb_padctl_remove()
1295 padctl->soc->ops->remove(padctl); in tegra_xusb_padctl_remove()
1302 if (padctl->soc && padctl->soc->ops && padctl->soc->ops->suspend_noirq) in tegra_xusb_padctl_suspend_noirq()
1303 return padctl->soc->ops->suspend_noirq(padctl); in tegra_xusb_padctl_suspend_noirq()
1312 if (padctl->soc && padctl->soc->ops && padctl->soc->ops->resume_noirq) in tegra_xusb_padctl_resume_noirq()
1313 return padctl->soc->ops->resume_noirq(padctl); in tegra_xusb_padctl_resume_noirq()
1325 .name = "tegra-xusb-padctl",
1340 np = of_parse_phandle(dev->of_node, "nvidia,xusb-padctl", 0); in tegra_xusb_padctl_get()
1342 return ERR_PTR(-EINVAL); in tegra_xusb_padctl_get()
1352 return ERR_PTR(-ENODEV); in tegra_xusb_padctl_get()
1359 put_device(&pdev->dev); in tegra_xusb_padctl_get()
1360 return ERR_PTR(-EPROBE_DEFER); in tegra_xusb_padctl_get()
1370 put_device(padctl->dev); in tegra_xusb_padctl_put()
1377 if (padctl->soc->ops->usb3_save_context) in tegra_xusb_padctl_usb3_save_context()
1378 return padctl->soc->ops->usb3_save_context(padctl, port); in tegra_xusb_padctl_usb3_save_context()
1380 return -ENOSYS; in tegra_xusb_padctl_usb3_save_context()
1387 if (padctl->soc->ops->hsic_set_idle) in tegra_xusb_padctl_hsic_set_idle()
1388 return padctl->soc->ops->hsic_set_idle(padctl, port, idle); in tegra_xusb_padctl_hsic_set_idle()
1390 return -ENOSYS; in tegra_xusb_padctl_hsic_set_idle()
1399 if (lane->pad->ops->enable_phy_sleepwalk) in tegra_xusb_padctl_enable_phy_sleepwalk()
1400 return lane->pad->ops->enable_phy_sleepwalk(lane, speed); in tegra_xusb_padctl_enable_phy_sleepwalk()
1402 return -EOPNOTSUPP; in tegra_xusb_padctl_enable_phy_sleepwalk()
1410 if (lane->pad->ops->disable_phy_sleepwalk) in tegra_xusb_padctl_disable_phy_sleepwalk()
1411 return lane->pad->ops->disable_phy_sleepwalk(lane); in tegra_xusb_padctl_disable_phy_sleepwalk()
1413 return -EOPNOTSUPP; in tegra_xusb_padctl_disable_phy_sleepwalk()
1421 if (lane->pad->ops->enable_phy_wake) in tegra_xusb_padctl_enable_phy_wake()
1422 return lane->pad->ops->enable_phy_wake(lane); in tegra_xusb_padctl_enable_phy_wake()
1424 return -EOPNOTSUPP; in tegra_xusb_padctl_enable_phy_wake()
1432 if (lane->pad->ops->disable_phy_wake) in tegra_xusb_padctl_disable_phy_wake()
1433 return lane->pad->ops->disable_phy_wake(lane); in tegra_xusb_padctl_disable_phy_wake()
1435 return -EOPNOTSUPP; in tegra_xusb_padctl_disable_phy_wake()
1443 if (lane->pad->ops->remote_wake_detected) in tegra_xusb_padctl_remote_wake_detected()
1444 return lane->pad->ops->remote_wake_detected(lane); in tegra_xusb_padctl_remote_wake_detected()
1453 if (padctl->soc->ops->usb3_set_lfps_detect) in tegra_xusb_padctl_usb3_set_lfps_detect()
1454 return padctl->soc->ops->usb3_set_lfps_detect(padctl, port, in tegra_xusb_padctl_usb3_set_lfps_detect()
1457 return -ENOSYS; in tegra_xusb_padctl_usb3_set_lfps_detect()
1464 if (padctl->soc->ops->vbus_override) in tegra_xusb_padctl_set_vbus_override()
1465 return padctl->soc->ops->vbus_override(padctl, val); in tegra_xusb_padctl_set_vbus_override()
1467 return -ENOTSUPP; in tegra_xusb_padctl_set_vbus_override()
1474 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra_phy_xusb_utmi_port_reset()
1476 if (padctl->soc->ops->utmi_port_reset) in tegra_phy_xusb_utmi_port_reset()
1477 return padctl->soc->ops->utmi_port_reset(phy); in tegra_phy_xusb_utmi_port_reset()
1479 return -ENOTSUPP; in tegra_phy_xusb_utmi_port_reset()
1492 padctl = lane->pad->padctl; in tegra_phy_xusb_utmi_pad_power_on()
1494 if (padctl->soc->ops->utmi_pad_power_on) in tegra_phy_xusb_utmi_pad_power_on()
1495 padctl->soc->ops->utmi_pad_power_on(phy); in tegra_phy_xusb_utmi_pad_power_on()
1508 padctl = lane->pad->padctl; in tegra_phy_xusb_utmi_pad_power_down()
1510 if (padctl->soc->ops->utmi_pad_power_down) in tegra_phy_xusb_utmi_pad_power_down()
1511 padctl->soc->ops->utmi_pad_power_down(phy); in tegra_phy_xusb_utmi_pad_power_down()
1524 return -EINVAL; in tegra_xusb_padctl_get_usb3_companion()
1526 for (i = 0; i < padctl->soc->ports.usb3.count; i++) { in tegra_xusb_padctl_get_usb3_companion()
1528 if (usb3 && usb3->port == usb2->base.index) in tegra_xusb_padctl_get_usb3_companion()
1529 return usb3->base.index; in tegra_xusb_padctl_get_usb3_companion()
1532 return -ENODEV; in tegra_xusb_padctl_get_usb3_companion()
1541 return -ENODEV; in tegra_xusb_padctl_get_port_number()
1545 return lane->index; in tegra_xusb_padctl_get_port_number()