Lines Matching refs:padctl

86 tegra_xusb_find_pad_node(struct tegra_xusb_padctl *padctl, const char *name)  in tegra_xusb_find_pad_node()  argument
90 pads = of_get_child_by_name(padctl->dev->of_node, "pads"); in tegra_xusb_find_pad_node()
160 struct tegra_xusb_padctl *padctl, in tegra_xusb_pad_init() argument
167 pad->dev.parent = padctl->dev; in tegra_xusb_pad_init()
170 pad->padctl = padctl; in tegra_xusb_pad_init()
230 list_add_tail(&lane->list, &pad->padctl->lanes); in tegra_xusb_pad_register()
265 tegra_xusb_pad_create(struct tegra_xusb_padctl *padctl, in tegra_xusb_pad_create() argument
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()
286 padctl->pcie = pad; in tegra_xusb_pad_create()
289 padctl->sata = pad; in tegra_xusb_pad_create()
292 padctl->usb2 = pad; in tegra_xusb_pad_create()
295 padctl->ulpi = pad; in tegra_xusb_pad_create()
298 padctl->hsic = pad; in tegra_xusb_pad_create()
303 static void __tegra_xusb_remove_pads(struct tegra_xusb_padctl *padctl) in __tegra_xusb_remove_pads() argument
307 list_for_each_entry_safe_reverse(pad, tmp, &padctl->pads, list) { in __tegra_xusb_remove_pads()
313 static void tegra_xusb_remove_pads(struct tegra_xusb_padctl *padctl) in tegra_xusb_remove_pads() argument
315 mutex_lock(&padctl->lock); in tegra_xusb_remove_pads()
316 __tegra_xusb_remove_pads(padctl); 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() local
334 value = padctl_readl(padctl, soc->offset); in tegra_xusb_lane_program()
337 padctl_writel(padctl, value, soc->offset); in tegra_xusb_lane_program()
357 static int tegra_xusb_setup_pads(struct tegra_xusb_padctl *padctl) in tegra_xusb_setup_pads() argument
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()
368 pad = tegra_xusb_pad_create(padctl, soc); in tegra_xusb_setup_pads()
371 dev_err(padctl->dev, "failed to create pad %s: %d\n", in tegra_xusb_setup_pads()
373 __tegra_xusb_remove_pads(padctl); 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()
399 struct tegra_xusb_lane *tegra_xusb_find_lane(struct tegra_xusb_padctl *padctl, in tegra_xusb_find_lane() argument
410 list_for_each_entry(lane, &padctl->lanes, list) { in tegra_xusb_find_lane()
432 lane = tegra_xusb_find_lane(port->padctl, map->type, in tegra_xusb_port_find_lane()
451 tegra_xusb_find_port_node(struct tegra_xusb_padctl *padctl, const char *type, in tegra_xusb_find_port_node() argument
457 ports = of_get_child_by_name(padctl->dev->of_node, "ports"); in tegra_xusb_find_port_node()
474 tegra_xusb_find_port(struct tegra_xusb_padctl *padctl, const char *type, in tegra_xusb_find_port() argument
480 np = tegra_xusb_find_port_node(padctl, type, index); in tegra_xusb_find_port()
484 list_for_each_entry(port, &padctl->ports, list) { in tegra_xusb_find_port()
497 tegra_xusb_find_usb2_port(struct tegra_xusb_padctl *padctl, unsigned int index) in tegra_xusb_find_usb2_port() argument
501 port = tegra_xusb_find_port(padctl, "usb2", index); in tegra_xusb_find_usb2_port()
509 tegra_xusb_find_usb3_port(struct tegra_xusb_padctl *padctl, unsigned int index) in tegra_xusb_find_usb3_port() argument
513 port = tegra_xusb_find_port(padctl, "usb3", index); in tegra_xusb_find_usb3_port()
533 struct tegra_xusb_padctl *padctl, in tegra_xusb_port_init() argument
541 port->padctl = padctl; in tegra_xusb_port_init()
547 port->dev.parent = padctl->dev; in tegra_xusb_port_init()
701 lane = tegra_xusb_find_lane(port->padctl, "usb2", port->index); in tegra_xusb_setup_usb_role_switch()
782 static int tegra_xusb_add_usb2_port(struct tegra_xusb_padctl *padctl, in tegra_xusb_add_usb2_port() argument
793 np = tegra_xusb_find_port_node(padctl, "usb2", index); in tegra_xusb_add_usb2_port()
803 err = tegra_xusb_port_init(&usb2->base, padctl, np, "usb2", index); in tegra_xusb_add_usb2_port()
807 usb2->base.ops = padctl->soc->ports.usb2.ops; in tegra_xusb_add_usb2_port()
822 list_add_tail(&usb2->base.list, &padctl->ports); in tegra_xusb_add_usb2_port()
853 static int tegra_xusb_add_ulpi_port(struct tegra_xusb_padctl *padctl, in tegra_xusb_add_ulpi_port() argument
860 np = tegra_xusb_find_port_node(padctl, "ulpi", index); in tegra_xusb_add_ulpi_port()
870 err = tegra_xusb_port_init(&ulpi->base, padctl, np, "ulpi", index); in tegra_xusb_add_ulpi_port()
874 ulpi->base.ops = padctl->soc->ports.ulpi.ops; in tegra_xusb_add_ulpi_port()
889 list_add_tail(&ulpi->base.list, &padctl->ports); in tegra_xusb_add_ulpi_port()
909 static int tegra_xusb_add_hsic_port(struct tegra_xusb_padctl *padctl, in tegra_xusb_add_hsic_port() argument
916 np = tegra_xusb_find_port_node(padctl, "hsic", index); in tegra_xusb_add_hsic_port()
926 err = tegra_xusb_port_init(&hsic->base, padctl, np, "hsic", index); in tegra_xusb_add_hsic_port()
930 hsic->base.ops = padctl->soc->ports.hsic.ops; in tegra_xusb_add_hsic_port()
944 list_add_tail(&hsic->base.list, &padctl->ports); in tegra_xusb_add_hsic_port()
989 static int tegra_xusb_add_usb3_port(struct tegra_xusb_padctl *padctl, in tegra_xusb_add_usb3_port() argument
1001 np = tegra_xusb_find_port_node(padctl, "usb3", index); in tegra_xusb_add_usb3_port()
1011 err = tegra_xusb_port_init(&usb3->base, padctl, np, "usb3", index); in tegra_xusb_add_usb3_port()
1015 usb3->base.ops = padctl->soc->ports.usb3.ops; in tegra_xusb_add_usb3_port()
1029 list_add_tail(&usb3->base.list, &padctl->ports); in tegra_xusb_add_usb3_port()
1043 static void __tegra_xusb_remove_ports(struct tegra_xusb_padctl *padctl) in __tegra_xusb_remove_ports() argument
1047 list_for_each_entry_safe_reverse(port, tmp, &padctl->ports, list) { in __tegra_xusb_remove_ports()
1053 static int tegra_xusb_find_unused_usb3_port(struct tegra_xusb_padctl *padctl) in tegra_xusb_find_unused_usb3_port() argument
1058 for (i = 0; i < padctl->soc->ports.usb3.count; i++) { in tegra_xusb_find_unused_usb3_port()
1059 np = tegra_xusb_find_port_node(padctl, "usb3", i); in tegra_xusb_find_unused_usb3_port()
1071 struct tegra_xusb_padctl *padctl = usb2->base.padctl; in tegra_xusb_port_is_companion() local
1073 for (i = 0; i < padctl->soc->ports.usb3.count; i++) { in tegra_xusb_port_is_companion()
1074 usb3 = tegra_xusb_find_usb3_port(padctl, i); in tegra_xusb_port_is_companion()
1092 fake = tegra_xusb_find_unused_usb3_port(usb2->base.padctl); in tegra_xusb_update_usb3_fake_port()
1105 static int tegra_xusb_setup_ports(struct tegra_xusb_padctl *padctl) in tegra_xusb_setup_ports() argument
1112 mutex_lock(&padctl->lock); in tegra_xusb_setup_ports()
1114 for (i = 0; i < padctl->soc->ports.usb2.count; i++) { in tegra_xusb_setup_ports()
1115 err = tegra_xusb_add_usb2_port(padctl, i); in tegra_xusb_setup_ports()
1120 for (i = 0; i < padctl->soc->ports.ulpi.count; i++) { in tegra_xusb_setup_ports()
1121 err = tegra_xusb_add_ulpi_port(padctl, i); in tegra_xusb_setup_ports()
1126 for (i = 0; i < padctl->soc->ports.hsic.count; i++) { in tegra_xusb_setup_ports()
1127 err = tegra_xusb_add_hsic_port(padctl, i); in tegra_xusb_setup_ports()
1132 for (i = 0; i < padctl->soc->ports.usb3.count; i++) { in tegra_xusb_setup_ports()
1133 err = tegra_xusb_add_usb3_port(padctl, i); in tegra_xusb_setup_ports()
1138 if (padctl->soc->need_fake_usb3_port) { in tegra_xusb_setup_ports()
1139 for (i = 0; i < padctl->soc->ports.usb2.count; i++) { in tegra_xusb_setup_ports()
1140 usb2 = tegra_xusb_find_usb2_port(padctl, i); in tegra_xusb_setup_ports()
1150 list_for_each_entry(port, &padctl->ports, list) { in tegra_xusb_setup_ports()
1153 dev_err(padctl->dev, "failed to enable port %s: %d\n", in tegra_xusb_setup_ports()
1160 __tegra_xusb_remove_ports(padctl); in tegra_xusb_setup_ports()
1162 mutex_unlock(&padctl->lock); in tegra_xusb_setup_ports()
1166 static void tegra_xusb_remove_ports(struct tegra_xusb_padctl *padctl) in tegra_xusb_remove_ports() argument
1168 mutex_lock(&padctl->lock); in tegra_xusb_remove_ports()
1169 __tegra_xusb_remove_ports(padctl); in tegra_xusb_remove_ports()
1170 mutex_unlock(&padctl->lock); in tegra_xusb_remove_ports()
1177 struct tegra_xusb_padctl *padctl; in tegra_xusb_padctl_probe() local
1193 padctl = soc->ops->probe(&pdev->dev, soc); in tegra_xusb_padctl_probe()
1194 if (IS_ERR(padctl)) in tegra_xusb_padctl_probe()
1195 return PTR_ERR(padctl); in tegra_xusb_padctl_probe()
1197 platform_set_drvdata(pdev, padctl); in tegra_xusb_padctl_probe()
1198 INIT_LIST_HEAD(&padctl->ports); in tegra_xusb_padctl_probe()
1199 INIT_LIST_HEAD(&padctl->lanes); in tegra_xusb_padctl_probe()
1200 INIT_LIST_HEAD(&padctl->pads); in tegra_xusb_padctl_probe()
1201 mutex_init(&padctl->lock); in tegra_xusb_padctl_probe()
1203 padctl->regs = devm_platform_ioremap_resource(pdev, 0); in tegra_xusb_padctl_probe()
1204 if (IS_ERR(padctl->regs)) { in tegra_xusb_padctl_probe()
1205 err = PTR_ERR(padctl->regs); in tegra_xusb_padctl_probe()
1209 padctl->rst = devm_reset_control_get(&pdev->dev, NULL); in tegra_xusb_padctl_probe()
1210 if (IS_ERR(padctl->rst)) { in tegra_xusb_padctl_probe()
1211 err = PTR_ERR(padctl->rst); in tegra_xusb_padctl_probe()
1215 padctl->supplies = devm_kcalloc(&pdev->dev, padctl->soc->num_supplies, in tegra_xusb_padctl_probe()
1216 sizeof(*padctl->supplies), GFP_KERNEL); in tegra_xusb_padctl_probe()
1217 if (!padctl->supplies) { in tegra_xusb_padctl_probe()
1222 regulator_bulk_set_supply_names(padctl->supplies, in tegra_xusb_padctl_probe()
1223 padctl->soc->supply_names, in tegra_xusb_padctl_probe()
1224 padctl->soc->num_supplies); in tegra_xusb_padctl_probe()
1226 err = devm_regulator_bulk_get(&pdev->dev, padctl->soc->num_supplies, in tegra_xusb_padctl_probe()
1227 padctl->supplies); in tegra_xusb_padctl_probe()
1233 err = reset_control_deassert(padctl->rst); in tegra_xusb_padctl_probe()
1237 err = regulator_bulk_enable(padctl->soc->num_supplies, in tegra_xusb_padctl_probe()
1238 padctl->supplies); in tegra_xusb_padctl_probe()
1244 err = tegra_xusb_setup_pads(padctl); in tegra_xusb_padctl_probe()
1250 err = tegra_xusb_setup_ports(padctl); in tegra_xusb_padctl_probe()
1265 tegra_xusb_remove_pads(padctl); in tegra_xusb_padctl_probe()
1267 regulator_bulk_disable(padctl->soc->num_supplies, padctl->supplies); in tegra_xusb_padctl_probe()
1269 reset_control_assert(padctl->rst); in tegra_xusb_padctl_probe()
1272 soc->ops->remove(padctl); in tegra_xusb_padctl_probe()
1278 struct tegra_xusb_padctl *padctl = platform_get_drvdata(pdev); in tegra_xusb_padctl_remove() local
1281 tegra_xusb_remove_ports(padctl); in tegra_xusb_padctl_remove()
1282 tegra_xusb_remove_pads(padctl); in tegra_xusb_padctl_remove()
1284 err = regulator_bulk_disable(padctl->soc->num_supplies, in tegra_xusb_padctl_remove()
1285 padctl->supplies); in tegra_xusb_padctl_remove()
1289 err = reset_control_assert(padctl->rst); in tegra_xusb_padctl_remove()
1293 padctl->soc->ops->remove(padctl); in tegra_xusb_padctl_remove()
1298 struct tegra_xusb_padctl *padctl = dev_get_drvdata(dev); in tegra_xusb_padctl_suspend_noirq() local
1300 if (padctl->soc && padctl->soc->ops && padctl->soc->ops->suspend_noirq) in tegra_xusb_padctl_suspend_noirq()
1301 return padctl->soc->ops->suspend_noirq(padctl); in tegra_xusb_padctl_suspend_noirq()
1308 struct tegra_xusb_padctl *padctl = dev_get_drvdata(dev); in tegra_xusb_padctl_resume_noirq() local
1310 if (padctl->soc && padctl->soc->ops && padctl->soc->ops->resume_noirq) in tegra_xusb_padctl_resume_noirq()
1311 return padctl->soc->ops->resume_noirq(padctl); in tegra_xusb_padctl_resume_noirq()
1334 struct tegra_xusb_padctl *padctl; in tegra_xusb_padctl_get() local
1355 padctl = platform_get_drvdata(pdev); in tegra_xusb_padctl_get()
1356 if (!padctl) { in tegra_xusb_padctl_get()
1361 return padctl; in tegra_xusb_padctl_get()
1365 void tegra_xusb_padctl_put(struct tegra_xusb_padctl *padctl) in tegra_xusb_padctl_put() argument
1367 if (padctl) in tegra_xusb_padctl_put()
1368 put_device(padctl->dev); in tegra_xusb_padctl_put()
1372 int tegra_xusb_padctl_usb3_save_context(struct tegra_xusb_padctl *padctl, in tegra_xusb_padctl_usb3_save_context() argument
1375 if (padctl->soc->ops->usb3_save_context) in tegra_xusb_padctl_usb3_save_context()
1376 return padctl->soc->ops->usb3_save_context(padctl, port); in tegra_xusb_padctl_usb3_save_context()
1382 int tegra_xusb_padctl_hsic_set_idle(struct tegra_xusb_padctl *padctl, in tegra_xusb_padctl_hsic_set_idle() argument
1385 if (padctl->soc->ops->hsic_set_idle) in tegra_xusb_padctl_hsic_set_idle()
1386 return padctl->soc->ops->hsic_set_idle(padctl, port, idle); in tegra_xusb_padctl_hsic_set_idle()
1392 int tegra_xusb_padctl_enable_phy_sleepwalk(struct tegra_xusb_padctl *padctl, struct phy *phy, in tegra_xusb_padctl_enable_phy_sleepwalk() argument
1404 int tegra_xusb_padctl_disable_phy_sleepwalk(struct tegra_xusb_padctl *padctl, struct phy *phy) in tegra_xusb_padctl_disable_phy_sleepwalk() argument
1415 int tegra_xusb_padctl_enable_phy_wake(struct tegra_xusb_padctl *padctl, struct phy *phy) in tegra_xusb_padctl_enable_phy_wake() argument
1426 int tegra_xusb_padctl_disable_phy_wake(struct tegra_xusb_padctl *padctl, struct phy *phy) in tegra_xusb_padctl_disable_phy_wake() argument
1437 bool tegra_xusb_padctl_remote_wake_detected(struct tegra_xusb_padctl *padctl, struct phy *phy) in tegra_xusb_padctl_remote_wake_detected() argument
1448 int tegra_xusb_padctl_usb3_set_lfps_detect(struct tegra_xusb_padctl *padctl, in tegra_xusb_padctl_usb3_set_lfps_detect() argument
1451 if (padctl->soc->ops->usb3_set_lfps_detect) in tegra_xusb_padctl_usb3_set_lfps_detect()
1452 return padctl->soc->ops->usb3_set_lfps_detect(padctl, port, in tegra_xusb_padctl_usb3_set_lfps_detect()
1459 int tegra_xusb_padctl_set_vbus_override(struct tegra_xusb_padctl *padctl, in tegra_xusb_padctl_set_vbus_override() argument
1462 if (padctl->soc->ops->vbus_override) in tegra_xusb_padctl_set_vbus_override()
1463 return padctl->soc->ops->vbus_override(padctl, val); in tegra_xusb_padctl_set_vbus_override()
1472 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra_phy_xusb_utmi_port_reset() local
1474 if (padctl->soc->ops->utmi_port_reset) in tegra_phy_xusb_utmi_port_reset()
1475 return padctl->soc->ops->utmi_port_reset(phy); in tegra_phy_xusb_utmi_port_reset()
1484 struct tegra_xusb_padctl *padctl; in tegra_phy_xusb_utmi_pad_power_on() local
1490 padctl = lane->pad->padctl; in tegra_phy_xusb_utmi_pad_power_on()
1492 if (padctl->soc->ops->utmi_pad_power_on) in tegra_phy_xusb_utmi_pad_power_on()
1493 padctl->soc->ops->utmi_pad_power_on(phy); in tegra_phy_xusb_utmi_pad_power_on()
1500 struct tegra_xusb_padctl *padctl; in tegra_phy_xusb_utmi_pad_power_down() local
1506 padctl = lane->pad->padctl; in tegra_phy_xusb_utmi_pad_power_down()
1508 if (padctl->soc->ops->utmi_pad_power_down) in tegra_phy_xusb_utmi_pad_power_down()
1509 padctl->soc->ops->utmi_pad_power_down(phy); in tegra_phy_xusb_utmi_pad_power_down()
1513 int tegra_xusb_padctl_get_usb3_companion(struct tegra_xusb_padctl *padctl, in tegra_xusb_padctl_get_usb3_companion() argument
1520 usb2 = tegra_xusb_find_usb2_port(padctl, port); in tegra_xusb_padctl_get_usb3_companion()
1524 for (i = 0; i < padctl->soc->ports.usb3.count; i++) { in tegra_xusb_padctl_get_usb3_companion()
1525 usb3 = tegra_xusb_find_usb3_port(padctl, i); in tegra_xusb_padctl_get_usb3_companion()