Lines Matching refs:padctl

74 tegra_xusb_find_pad_node(struct tegra_xusb_padctl *padctl, const char *name)  in tegra_xusb_find_pad_node()  argument
78 pads = of_get_child_by_name(padctl->dev->of_node, "pads"); in tegra_xusb_find_pad_node()
148 struct tegra_xusb_padctl *padctl, in tegra_xusb_pad_init() argument
155 pad->dev.parent = padctl->dev; in tegra_xusb_pad_init()
158 pad->padctl = padctl; in tegra_xusb_pad_init()
218 list_add_tail(&lane->list, &pad->padctl->lanes); in tegra_xusb_pad_register()
253 tegra_xusb_pad_create(struct tegra_xusb_padctl *padctl, in tegra_xusb_pad_create() argument
260 np = tegra_xusb_find_pad_node(padctl, soc->name); in tegra_xusb_pad_create()
264 pad = soc->ops->probe(padctl, soc, np); in tegra_xusb_pad_create()
267 dev_err(padctl->dev, "failed to create pad %s: %d\n", in tegra_xusb_pad_create()
274 padctl->pcie = pad; in tegra_xusb_pad_create()
277 padctl->sata = pad; in tegra_xusb_pad_create()
280 padctl->usb2 = pad; in tegra_xusb_pad_create()
283 padctl->ulpi = pad; in tegra_xusb_pad_create()
286 padctl->hsic = pad; in tegra_xusb_pad_create()
291 static void __tegra_xusb_remove_pads(struct tegra_xusb_padctl *padctl) in __tegra_xusb_remove_pads() argument
295 list_for_each_entry_safe_reverse(pad, tmp, &padctl->pads, list) { in __tegra_xusb_remove_pads()
301 static void tegra_xusb_remove_pads(struct tegra_xusb_padctl *padctl) in tegra_xusb_remove_pads() argument
303 mutex_lock(&padctl->lock); in tegra_xusb_remove_pads()
304 __tegra_xusb_remove_pads(padctl); in tegra_xusb_remove_pads()
305 mutex_unlock(&padctl->lock); in tegra_xusb_remove_pads()
310 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra_xusb_lane_program() local
319 value = padctl_readl(padctl, soc->offset); in tegra_xusb_lane_program()
322 padctl_writel(padctl, value, soc->offset); in tegra_xusb_lane_program()
339 static int tegra_xusb_setup_pads(struct tegra_xusb_padctl *padctl) in tegra_xusb_setup_pads() argument
344 mutex_lock(&padctl->lock); in tegra_xusb_setup_pads()
346 for (i = 0; i < padctl->soc->num_pads; i++) { in tegra_xusb_setup_pads()
347 const struct tegra_xusb_pad_soc *soc = padctl->soc->pads[i]; in tegra_xusb_setup_pads()
350 pad = tegra_xusb_pad_create(padctl, soc); in tegra_xusb_setup_pads()
353 dev_err(padctl->dev, "failed to create pad %s: %d\n", in tegra_xusb_setup_pads()
355 __tegra_xusb_remove_pads(padctl); in tegra_xusb_setup_pads()
356 mutex_unlock(&padctl->lock); in tegra_xusb_setup_pads()
363 list_add_tail(&pad->list, &padctl->pads); in tegra_xusb_setup_pads()
366 list_for_each_entry(pad, &padctl->pads, list) in tegra_xusb_setup_pads()
369 mutex_unlock(&padctl->lock); in tegra_xusb_setup_pads()
381 struct tegra_xusb_lane *tegra_xusb_find_lane(struct tegra_xusb_padctl *padctl, in tegra_xusb_find_lane() argument
392 list_for_each_entry(lane, &padctl->lanes, list) { in tegra_xusb_find_lane()
414 lane = tegra_xusb_find_lane(port->padctl, map->type, in tegra_xusb_port_find_lane()
433 tegra_xusb_find_port_node(struct tegra_xusb_padctl *padctl, const char *type, in tegra_xusb_find_port_node() argument
439 ports = of_get_child_by_name(padctl->dev->of_node, "ports"); in tegra_xusb_find_port_node()
456 tegra_xusb_find_port(struct tegra_xusb_padctl *padctl, const char *type, in tegra_xusb_find_port() argument
462 np = tegra_xusb_find_port_node(padctl, type, index); in tegra_xusb_find_port()
466 list_for_each_entry(port, &padctl->ports, list) { in tegra_xusb_find_port()
479 tegra_xusb_find_usb2_port(struct tegra_xusb_padctl *padctl, unsigned int index) in tegra_xusb_find_usb2_port() argument
483 port = tegra_xusb_find_port(padctl, "usb2", index); in tegra_xusb_find_usb2_port()
491 tegra_xusb_find_usb3_port(struct tegra_xusb_padctl *padctl, unsigned int index) in tegra_xusb_find_usb3_port() argument
495 port = tegra_xusb_find_port(padctl, "usb3", index); in tegra_xusb_find_usb3_port()
511 struct tegra_xusb_padctl *padctl, in tegra_xusb_port_init() argument
519 port->padctl = padctl; in tegra_xusb_port_init()
525 port->dev.parent = padctl->dev; in tegra_xusb_port_init()
579 static int tegra_xusb_add_usb2_port(struct tegra_xusb_padctl *padctl, in tegra_xusb_add_usb2_port() argument
590 np = tegra_xusb_find_port_node(padctl, "usb2", index); in tegra_xusb_add_usb2_port()
594 usb2 = devm_kzalloc(padctl->dev, sizeof(*usb2), GFP_KERNEL); in tegra_xusb_add_usb2_port()
600 err = tegra_xusb_port_init(&usb2->base, padctl, np, "usb2", index); in tegra_xusb_add_usb2_port()
604 usb2->base.ops = padctl->soc->ports.usb2.ops; in tegra_xusb_add_usb2_port()
618 list_add_tail(&usb2->base.list, &padctl->ports); in tegra_xusb_add_usb2_port()
635 static int tegra_xusb_add_ulpi_port(struct tegra_xusb_padctl *padctl, in tegra_xusb_add_ulpi_port() argument
642 np = tegra_xusb_find_port_node(padctl, "ulpi", index); in tegra_xusb_add_ulpi_port()
646 ulpi = devm_kzalloc(padctl->dev, sizeof(*ulpi), GFP_KERNEL); in tegra_xusb_add_ulpi_port()
652 err = tegra_xusb_port_init(&ulpi->base, padctl, np, "ulpi", index); in tegra_xusb_add_ulpi_port()
656 ulpi->base.ops = padctl->soc->ports.ulpi.ops; in tegra_xusb_add_ulpi_port()
670 list_add_tail(&ulpi->base.list, &padctl->ports); in tegra_xusb_add_ulpi_port()
683 static int tegra_xusb_add_hsic_port(struct tegra_xusb_padctl *padctl, in tegra_xusb_add_hsic_port() argument
690 np = tegra_xusb_find_port_node(padctl, "hsic", index); in tegra_xusb_add_hsic_port()
694 hsic = devm_kzalloc(padctl->dev, sizeof(*hsic), GFP_KERNEL); in tegra_xusb_add_hsic_port()
700 err = tegra_xusb_port_init(&hsic->base, padctl, np, "hsic", index); in tegra_xusb_add_hsic_port()
704 hsic->base.ops = padctl->soc->ports.hsic.ops; in tegra_xusb_add_hsic_port()
718 list_add_tail(&hsic->base.list, &padctl->ports); in tegra_xusb_add_hsic_port()
746 static int tegra_xusb_add_usb3_port(struct tegra_xusb_padctl *padctl, in tegra_xusb_add_usb3_port() argument
758 np = tegra_xusb_find_port_node(padctl, "usb3", index); in tegra_xusb_add_usb3_port()
762 usb3 = devm_kzalloc(padctl->dev, sizeof(*usb3), GFP_KERNEL); in tegra_xusb_add_usb3_port()
768 err = tegra_xusb_port_init(&usb3->base, padctl, np, "usb3", index); in tegra_xusb_add_usb3_port()
772 usb3->base.ops = padctl->soc->ports.usb3.ops; in tegra_xusb_add_usb3_port()
786 list_add_tail(&usb3->base.list, &padctl->ports); in tegra_xusb_add_usb3_port()
793 static void __tegra_xusb_remove_ports(struct tegra_xusb_padctl *padctl) in __tegra_xusb_remove_ports() argument
797 list_for_each_entry_safe_reverse(port, tmp, &padctl->ports, list) { in __tegra_xusb_remove_ports()
803 static int tegra_xusb_setup_ports(struct tegra_xusb_padctl *padctl) in tegra_xusb_setup_ports() argument
809 mutex_lock(&padctl->lock); in tegra_xusb_setup_ports()
811 for (i = 0; i < padctl->soc->ports.usb2.count; i++) { in tegra_xusb_setup_ports()
812 err = tegra_xusb_add_usb2_port(padctl, i); in tegra_xusb_setup_ports()
817 for (i = 0; i < padctl->soc->ports.ulpi.count; i++) { in tegra_xusb_setup_ports()
818 err = tegra_xusb_add_ulpi_port(padctl, i); in tegra_xusb_setup_ports()
823 for (i = 0; i < padctl->soc->ports.hsic.count; i++) { in tegra_xusb_setup_ports()
824 err = tegra_xusb_add_hsic_port(padctl, i); in tegra_xusb_setup_ports()
829 for (i = 0; i < padctl->soc->ports.usb3.count; i++) { in tegra_xusb_setup_ports()
830 err = tegra_xusb_add_usb3_port(padctl, i); in tegra_xusb_setup_ports()
835 list_for_each_entry(port, &padctl->ports, list) { in tegra_xusb_setup_ports()
838 dev_err(padctl->dev, "failed to enable port %s: %d\n", in tegra_xusb_setup_ports()
845 __tegra_xusb_remove_ports(padctl); in tegra_xusb_setup_ports()
847 mutex_unlock(&padctl->lock); in tegra_xusb_setup_ports()
851 static void tegra_xusb_remove_ports(struct tegra_xusb_padctl *padctl) in tegra_xusb_remove_ports() argument
853 mutex_lock(&padctl->lock); in tegra_xusb_remove_ports()
854 __tegra_xusb_remove_ports(padctl); in tegra_xusb_remove_ports()
855 mutex_unlock(&padctl->lock); in tegra_xusb_remove_ports()
862 struct tegra_xusb_padctl *padctl; in tegra_xusb_padctl_probe() local
880 padctl = soc->ops->probe(&pdev->dev, soc); in tegra_xusb_padctl_probe()
881 if (IS_ERR(padctl)) in tegra_xusb_padctl_probe()
882 return PTR_ERR(padctl); in tegra_xusb_padctl_probe()
884 platform_set_drvdata(pdev, padctl); in tegra_xusb_padctl_probe()
885 INIT_LIST_HEAD(&padctl->ports); in tegra_xusb_padctl_probe()
886 INIT_LIST_HEAD(&padctl->lanes); in tegra_xusb_padctl_probe()
887 INIT_LIST_HEAD(&padctl->pads); in tegra_xusb_padctl_probe()
888 mutex_init(&padctl->lock); in tegra_xusb_padctl_probe()
891 padctl->regs = devm_ioremap_resource(&pdev->dev, res); in tegra_xusb_padctl_probe()
892 if (IS_ERR(padctl->regs)) { in tegra_xusb_padctl_probe()
893 err = PTR_ERR(padctl->regs); in tegra_xusb_padctl_probe()
897 padctl->rst = devm_reset_control_get(&pdev->dev, NULL); in tegra_xusb_padctl_probe()
898 if (IS_ERR(padctl->rst)) { in tegra_xusb_padctl_probe()
899 err = PTR_ERR(padctl->rst); in tegra_xusb_padctl_probe()
903 padctl->supplies = devm_kcalloc(&pdev->dev, padctl->soc->num_supplies, in tegra_xusb_padctl_probe()
904 sizeof(*padctl->supplies), GFP_KERNEL); in tegra_xusb_padctl_probe()
905 if (!padctl->supplies) { in tegra_xusb_padctl_probe()
910 for (i = 0; i < padctl->soc->num_supplies; i++) in tegra_xusb_padctl_probe()
911 padctl->supplies[i].supply = padctl->soc->supply_names[i]; in tegra_xusb_padctl_probe()
913 err = devm_regulator_bulk_get(&pdev->dev, padctl->soc->num_supplies, in tegra_xusb_padctl_probe()
914 padctl->supplies); in tegra_xusb_padctl_probe()
920 err = reset_control_deassert(padctl->rst); in tegra_xusb_padctl_probe()
924 err = regulator_bulk_enable(padctl->soc->num_supplies, in tegra_xusb_padctl_probe()
925 padctl->supplies); in tegra_xusb_padctl_probe()
931 err = tegra_xusb_setup_pads(padctl); in tegra_xusb_padctl_probe()
937 err = tegra_xusb_setup_ports(padctl); in tegra_xusb_padctl_probe()
946 tegra_xusb_remove_pads(padctl); in tegra_xusb_padctl_probe()
948 regulator_bulk_disable(padctl->soc->num_supplies, padctl->supplies); in tegra_xusb_padctl_probe()
950 reset_control_assert(padctl->rst); in tegra_xusb_padctl_probe()
952 soc->ops->remove(padctl); in tegra_xusb_padctl_probe()
958 struct tegra_xusb_padctl *padctl = platform_get_drvdata(pdev); in tegra_xusb_padctl_remove() local
961 tegra_xusb_remove_ports(padctl); in tegra_xusb_padctl_remove()
962 tegra_xusb_remove_pads(padctl); in tegra_xusb_padctl_remove()
964 err = regulator_bulk_disable(padctl->soc->num_supplies, in tegra_xusb_padctl_remove()
965 padctl->supplies); in tegra_xusb_padctl_remove()
969 err = reset_control_assert(padctl->rst); in tegra_xusb_padctl_remove()
973 padctl->soc->ops->remove(padctl); in tegra_xusb_padctl_remove()
990 struct tegra_xusb_padctl *padctl; in tegra_xusb_padctl_get() local
1011 padctl = platform_get_drvdata(pdev); in tegra_xusb_padctl_get()
1012 if (!padctl) { in tegra_xusb_padctl_get()
1017 return padctl; in tegra_xusb_padctl_get()
1021 void tegra_xusb_padctl_put(struct tegra_xusb_padctl *padctl) in tegra_xusb_padctl_put() argument
1023 if (padctl) in tegra_xusb_padctl_put()
1024 put_device(padctl->dev); in tegra_xusb_padctl_put()
1028 int tegra_xusb_padctl_usb3_save_context(struct tegra_xusb_padctl *padctl, in tegra_xusb_padctl_usb3_save_context() argument
1031 if (padctl->soc->ops->usb3_save_context) in tegra_xusb_padctl_usb3_save_context()
1032 return padctl->soc->ops->usb3_save_context(padctl, port); in tegra_xusb_padctl_usb3_save_context()
1038 int tegra_xusb_padctl_hsic_set_idle(struct tegra_xusb_padctl *padctl, in tegra_xusb_padctl_hsic_set_idle() argument
1041 if (padctl->soc->ops->hsic_set_idle) in tegra_xusb_padctl_hsic_set_idle()
1042 return padctl->soc->ops->hsic_set_idle(padctl, port, idle); in tegra_xusb_padctl_hsic_set_idle()
1048 int tegra_xusb_padctl_usb3_set_lfps_detect(struct tegra_xusb_padctl *padctl, in tegra_xusb_padctl_usb3_set_lfps_detect() argument
1051 if (padctl->soc->ops->usb3_set_lfps_detect) in tegra_xusb_padctl_usb3_set_lfps_detect()
1052 return padctl->soc->ops->usb3_set_lfps_detect(padctl, port, in tegra_xusb_padctl_usb3_set_lfps_detect()