Lines Matching +full:four +full:- +full:lane

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2016-2020, NVIDIA CORPORATION. All rights reserved.
21 #define HS_CURR_LEVEL_PADX_SHIFT(x) ((x) ? (11 + (x - 1) * 6) : 0)
267 writel(value, priv->ao_regs + offset); in ao_writel()
272 return readl(priv->ao_regs + offset); in ao_readl()
291 return ERR_PTR(-ENOMEM); in tegra186_usb2_lane_probe()
293 INIT_LIST_HEAD(&usb2->base.list); in tegra186_usb2_lane_probe()
294 usb2->base.soc = &pad->soc->lanes[index]; in tegra186_usb2_lane_probe()
295 usb2->base.index = index; in tegra186_usb2_lane_probe()
296 usb2->base.pad = pad; in tegra186_usb2_lane_probe()
297 usb2->base.np = np; in tegra186_usb2_lane_probe()
299 err = tegra_xusb_lane_parse_dt(&usb2->base, np); in tegra186_usb2_lane_probe()
305 return &usb2->base; in tegra186_usb2_lane_probe()
308 static void tegra186_usb2_lane_remove(struct tegra_xusb_lane *lane) in tegra186_usb2_lane_remove() argument
310 struct tegra_xusb_usb2_lane *usb2 = to_usb2_lane(lane); in tegra186_usb2_lane_remove()
315 static int tegra186_utmi_enable_phy_sleepwalk(struct tegra_xusb_lane *lane, in tegra186_utmi_enable_phy_sleepwalk() argument
318 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra186_utmi_enable_phy_sleepwalk()
320 unsigned int index = lane->index; in tegra186_utmi_enable_phy_sleepwalk()
323 mutex_lock(&padctl->lock); in tegra186_utmi_enable_phy_sleepwalk()
400 /* setup the pull-ups and pull-downs of the signals during the four in tegra186_utmi_enable_phy_sleepwalk()
411 /* J state: D+/D- = high/low, K state: D+/D- = low/high */ in tegra186_utmi_enable_phy_sleepwalk()
418 /* J state: D+/D- = low/high, K state: D+/D- = high/low */ in tegra186_utmi_enable_phy_sleepwalk()
455 mutex_unlock(&padctl->lock); in tegra186_utmi_enable_phy_sleepwalk()
460 static int tegra186_utmi_disable_phy_sleepwalk(struct tegra_xusb_lane *lane) in tegra186_utmi_disable_phy_sleepwalk() argument
462 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra186_utmi_disable_phy_sleepwalk()
464 unsigned int index = lane->index; in tegra186_utmi_disable_phy_sleepwalk()
467 mutex_lock(&padctl->lock); in tegra186_utmi_disable_phy_sleepwalk()
496 mutex_unlock(&padctl->lock); in tegra186_utmi_disable_phy_sleepwalk()
501 static int tegra186_utmi_enable_phy_wake(struct tegra_xusb_lane *lane) in tegra186_utmi_enable_phy_wake() argument
503 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra186_utmi_enable_phy_wake()
504 unsigned int index = lane->index; in tegra186_utmi_enable_phy_wake()
507 mutex_lock(&padctl->lock); in tegra186_utmi_enable_phy_wake()
521 mutex_unlock(&padctl->lock); in tegra186_utmi_enable_phy_wake()
526 static int tegra186_utmi_disable_phy_wake(struct tegra_xusb_lane *lane) in tegra186_utmi_disable_phy_wake() argument
528 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra186_utmi_disable_phy_wake()
529 unsigned int index = lane->index; in tegra186_utmi_disable_phy_wake()
532 mutex_lock(&padctl->lock); in tegra186_utmi_disable_phy_wake()
546 mutex_unlock(&padctl->lock); in tegra186_utmi_disable_phy_wake()
551 static bool tegra186_utmi_phy_remote_wake_detected(struct tegra_xusb_lane *lane) in tegra186_utmi_phy_remote_wake_detected() argument
553 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra186_utmi_phy_remote_wake_detected()
554 unsigned int index = lane->index; in tegra186_utmi_phy_remote_wake_detected()
578 struct device *dev = padctl->dev; in tegra186_utmi_bias_pad_power_on()
582 mutex_lock(&padctl->lock); in tegra186_utmi_bias_pad_power_on()
584 if (priv->bias_pad_enable++ > 0) { in tegra186_utmi_bias_pad_power_on()
585 mutex_unlock(&padctl->lock); in tegra186_utmi_bias_pad_power_on()
589 err = clk_prepare_enable(priv->usb2_trk_clk); in tegra186_utmi_bias_pad_power_on()
603 value |= HS_SQUELCH_LEVEL(priv->calib.hs_squelch); in tegra186_utmi_bias_pad_power_on()
612 mutex_unlock(&padctl->lock); in tegra186_utmi_bias_pad_power_on()
620 mutex_lock(&padctl->lock); in tegra186_utmi_bias_pad_power_off()
622 if (WARN_ON(priv->bias_pad_enable == 0)) { in tegra186_utmi_bias_pad_power_off()
623 mutex_unlock(&padctl->lock); in tegra186_utmi_bias_pad_power_off()
627 if (--priv->bias_pad_enable > 0) { in tegra186_utmi_bias_pad_power_off()
628 mutex_unlock(&padctl->lock); in tegra186_utmi_bias_pad_power_off()
636 clk_disable_unprepare(priv->usb2_trk_clk); in tegra186_utmi_bias_pad_power_off()
638 mutex_unlock(&padctl->lock); in tegra186_utmi_bias_pad_power_off()
643 struct tegra_xusb_lane *lane = phy_get_drvdata(phy); in tegra_phy_xusb_utmi_pad_power_on() local
644 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra_phy_xusb_utmi_pad_power_on()
646 struct device *dev = padctl->dev; in tegra_phy_xusb_utmi_pad_power_on()
647 unsigned int index = lane->index; in tegra_phy_xusb_utmi_pad_power_on()
655 dev_err(dev, "no port found for USB2 lane %u\n", index); in tegra_phy_xusb_utmi_pad_power_on()
674 struct tegra_xusb_lane *lane = phy_get_drvdata(phy); in tegra_phy_xusb_utmi_pad_power_down() local
675 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra_phy_xusb_utmi_pad_power_down()
676 unsigned int index = lane->index; in tegra_phy_xusb_utmi_pad_power_down()
700 dev_dbg(padctl->dev, "%s vbus override\n", status ? "set" : "clear"); in tegra186_xusb_padctl_vbus_override()
722 dev_dbg(padctl->dev, "%s id override\n", status ? "set" : "clear"); in tegra186_xusb_padctl_id_override()
750 struct tegra_xusb_lane *lane = phy_get_drvdata(phy); in tegra186_utmi_phy_set_mode() local
751 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra186_utmi_phy_set_mode()
753 lane->index); in tegra186_utmi_phy_set_mode()
756 mutex_lock(&padctl->lock); in tegra186_utmi_phy_set_mode()
758 dev_dbg(&port->base.dev, "%s: mode %d", __func__, mode); in tegra186_utmi_phy_set_mode()
764 err = regulator_enable(port->supply); in tegra186_utmi_phy_set_mode()
773 if (regulator_is_enabled(port->supply)) in tegra186_utmi_phy_set_mode()
774 regulator_disable(port->supply); in tegra186_utmi_phy_set_mode()
781 mutex_unlock(&padctl->lock); in tegra186_utmi_phy_set_mode()
788 struct tegra_xusb_lane *lane = phy_get_drvdata(phy); in tegra186_utmi_phy_power_on() local
789 struct tegra_xusb_usb2_lane *usb2 = to_usb2_lane(lane); in tegra186_utmi_phy_power_on()
790 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra186_utmi_phy_power_on()
793 unsigned int index = lane->index; in tegra186_utmi_phy_power_on()
794 struct device *dev = padctl->dev; in tegra186_utmi_phy_power_on()
799 dev_err(dev, "no port found for USB2 lane %u\n", index); in tegra186_utmi_phy_power_on()
800 return -ENODEV; in tegra186_utmi_phy_power_on()
811 if (port->mode == USB_DR_MODE_UNKNOWN) in tegra186_utmi_phy_power_on()
813 else if (port->mode == USB_DR_MODE_PERIPHERAL) in tegra186_utmi_phy_power_on()
815 else if (port->mode == USB_DR_MODE_HOST) in tegra186_utmi_phy_power_on()
817 else if (port->mode == USB_DR_MODE_OTG) in tegra186_utmi_phy_power_on()
827 if (usb2->hs_curr_level_offset) { in tegra186_utmi_phy_power_on()
830 hs_current_level = (int)priv->calib.hs_curr_level[index] + in tegra186_utmi_phy_power_on()
831 usb2->hs_curr_level_offset; in tegra186_utmi_phy_power_on()
840 value |= HS_CURR_LEVEL(priv->calib.hs_curr_level[index]); in tegra186_utmi_phy_power_on()
847 value |= TERM_RANGE_ADJ(priv->calib.hs_term_range_adj); in tegra186_utmi_phy_power_on()
849 value |= RPD_CTRL(priv->calib.rpd_ctrl); in tegra186_utmi_phy_power_on()
867 struct tegra_xusb_lane *lane = phy_get_drvdata(phy); in tegra186_utmi_phy_init() local
868 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra186_utmi_phy_init()
870 unsigned int index = lane->index; in tegra186_utmi_phy_init()
871 struct device *dev = padctl->dev; in tegra186_utmi_phy_init()
876 dev_err(dev, "no port found for USB2 lane %u\n", index); in tegra186_utmi_phy_init()
877 return -ENODEV; in tegra186_utmi_phy_init()
880 if (port->supply && port->mode == USB_DR_MODE_HOST) { in tegra186_utmi_phy_init()
881 err = regulator_enable(port->supply); in tegra186_utmi_phy_init()
894 struct tegra_xusb_lane *lane = phy_get_drvdata(phy); in tegra186_utmi_phy_exit() local
895 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra186_utmi_phy_exit()
897 unsigned int index = lane->index; in tegra186_utmi_phy_exit()
898 struct device *dev = padctl->dev; in tegra186_utmi_phy_exit()
903 dev_err(dev, "no port found for USB2 lane %u\n", index); in tegra186_utmi_phy_exit()
904 return -ENODEV; in tegra186_utmi_phy_exit()
907 if (port->supply && port->mode == USB_DR_MODE_HOST) { in tegra186_utmi_phy_exit()
908 err = regulator_disable(port->supply); in tegra186_utmi_phy_exit()
940 return ERR_PTR(-ENOMEM); in tegra186_usb2_pad_probe()
942 pad = &usb2->base; in tegra186_usb2_pad_probe()
943 pad->ops = &tegra186_usb2_lane_ops; in tegra186_usb2_pad_probe()
944 pad->soc = soc; in tegra186_usb2_pad_probe()
952 priv->usb2_trk_clk = devm_clk_get(&pad->dev, "trk"); in tegra186_usb2_pad_probe()
953 if (IS_ERR(priv->usb2_trk_clk)) { in tegra186_usb2_pad_probe()
954 err = PTR_ERR(priv->usb2_trk_clk); in tegra186_usb2_pad_probe()
955 dev_dbg(&pad->dev, "failed to get usb2 trk clock: %d\n", err); in tegra186_usb2_pad_probe()
963 dev_set_drvdata(&pad->dev, pad); in tegra186_usb2_pad_probe()
968 device_unregister(&pad->dev); in tegra186_usb2_pad_probe()
1001 return tegra_xusb_find_lane(port->padctl, "usb2", port->index); in tegra186_usb2_port_map()
1022 return ERR_PTR(-ENOMEM); in tegra186_usb3_lane_probe()
1024 INIT_LIST_HEAD(&usb3->base.list); in tegra186_usb3_lane_probe()
1025 usb3->base.soc = &pad->soc->lanes[index]; in tegra186_usb3_lane_probe()
1026 usb3->base.index = index; in tegra186_usb3_lane_probe()
1027 usb3->base.pad = pad; in tegra186_usb3_lane_probe()
1028 usb3->base.np = np; in tegra186_usb3_lane_probe()
1030 err = tegra_xusb_lane_parse_dt(&usb3->base, np); in tegra186_usb3_lane_probe()
1036 return &usb3->base; in tegra186_usb3_lane_probe()
1039 static void tegra186_usb3_lane_remove(struct tegra_xusb_lane *lane) in tegra186_usb3_lane_remove() argument
1041 struct tegra_xusb_usb3_lane *usb3 = to_usb3_lane(lane); in tegra186_usb3_lane_remove()
1046 static int tegra186_usb3_enable_phy_sleepwalk(struct tegra_xusb_lane *lane, in tegra186_usb3_enable_phy_sleepwalk() argument
1049 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra186_usb3_enable_phy_sleepwalk()
1050 unsigned int index = lane->index; in tegra186_usb3_enable_phy_sleepwalk()
1053 mutex_lock(&padctl->lock); in tegra186_usb3_enable_phy_sleepwalk()
1067 mutex_unlock(&padctl->lock); in tegra186_usb3_enable_phy_sleepwalk()
1072 static int tegra186_usb3_disable_phy_sleepwalk(struct tegra_xusb_lane *lane) in tegra186_usb3_disable_phy_sleepwalk() argument
1074 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra186_usb3_disable_phy_sleepwalk()
1075 unsigned int index = lane->index; in tegra186_usb3_disable_phy_sleepwalk()
1078 mutex_lock(&padctl->lock); in tegra186_usb3_disable_phy_sleepwalk()
1090 mutex_unlock(&padctl->lock); in tegra186_usb3_disable_phy_sleepwalk()
1095 static int tegra186_usb3_enable_phy_wake(struct tegra_xusb_lane *lane) in tegra186_usb3_enable_phy_wake() argument
1097 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra186_usb3_enable_phy_wake()
1098 unsigned int index = lane->index; in tegra186_usb3_enable_phy_wake()
1101 mutex_lock(&padctl->lock); in tegra186_usb3_enable_phy_wake()
1115 mutex_unlock(&padctl->lock); in tegra186_usb3_enable_phy_wake()
1120 static int tegra186_usb3_disable_phy_wake(struct tegra_xusb_lane *lane) in tegra186_usb3_disable_phy_wake() argument
1122 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra186_usb3_disable_phy_wake()
1123 unsigned int index = lane->index; in tegra186_usb3_disable_phy_wake()
1126 mutex_lock(&padctl->lock); in tegra186_usb3_disable_phy_wake()
1140 mutex_unlock(&padctl->lock); in tegra186_usb3_disable_phy_wake()
1145 static bool tegra186_usb3_phy_remote_wake_detected(struct tegra_xusb_lane *lane) in tegra186_usb3_phy_remote_wake_detected() argument
1147 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra186_usb3_phy_remote_wake_detected()
1148 unsigned int index = lane->index; in tegra186_usb3_phy_remote_wake_detected()
1180 return tegra_xusb_find_lane(port->padctl, "usb3", port->index); in tegra186_usb3_port_map()
1193 struct tegra_xusb_lane *lane = phy_get_drvdata(phy); in tegra186_usb3_phy_power_on() local
1194 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra186_usb3_phy_power_on()
1197 unsigned int index = lane->index; in tegra186_usb3_phy_power_on()
1198 struct device *dev = padctl->dev; in tegra186_usb3_phy_power_on()
1203 dev_err(dev, "no port found for USB3 lane %u\n", index); in tegra186_usb3_phy_power_on()
1204 return -ENODEV; in tegra186_usb3_phy_power_on()
1207 usb2 = tegra_xusb_find_usb2_port(padctl, port->port); in tegra186_usb3_phy_power_on()
1209 dev_err(dev, "no companion port found for USB3 lane %u\n", in tegra186_usb3_phy_power_on()
1211 return -ENODEV; in tegra186_usb3_phy_power_on()
1214 mutex_lock(&padctl->lock); in tegra186_usb3_phy_power_on()
1219 if (usb2->mode == USB_DR_MODE_UNKNOWN) in tegra186_usb3_phy_power_on()
1221 else if (usb2->mode == USB_DR_MODE_PERIPHERAL) in tegra186_usb3_phy_power_on()
1223 else if (usb2->mode == USB_DR_MODE_HOST) in tegra186_usb3_phy_power_on()
1225 else if (usb2->mode == USB_DR_MODE_OTG) in tegra186_usb3_phy_power_on()
1230 if (padctl->soc->supports_gen2 && port->disable_gen2) { in tegra186_usb3_phy_power_on()
1255 mutex_unlock(&padctl->lock); in tegra186_usb3_phy_power_on()
1262 struct tegra_xusb_lane *lane = phy_get_drvdata(phy); in tegra186_usb3_phy_power_off() local
1263 struct tegra_xusb_padctl *padctl = lane->pad->padctl; in tegra186_usb3_phy_power_off()
1265 unsigned int index = lane->index; in tegra186_usb3_phy_power_off()
1266 struct device *dev = padctl->dev; in tegra186_usb3_phy_power_off()
1271 dev_err(dev, "no port found for USB3 lane %u\n", index); in tegra186_usb3_phy_power_off()
1272 return -ENODEV; in tegra186_usb3_phy_power_off()
1275 mutex_lock(&padctl->lock); in tegra186_usb3_phy_power_off()
1293 mutex_unlock(&padctl->lock); in tegra186_usb3_phy_power_off()
1327 return ERR_PTR(-ENOMEM); in tegra186_usb3_pad_probe()
1329 pad = &usb3->base; in tegra186_usb3_pad_probe()
1330 pad->ops = &tegra186_usb3_lane_ops; in tegra186_usb3_pad_probe()
1331 pad->soc = soc; in tegra186_usb3_pad_probe()
1343 dev_set_drvdata(&pad->dev, pad); in tegra186_usb3_pad_probe()
1348 device_unregister(&pad->dev); in tegra186_usb3_pad_probe()
1372 struct device *dev = padctl->base.dev; in tegra186_xusb_read_fuse_calibration()
1377 count = padctl->base.soc->ports.usb2.count; in tegra186_xusb_read_fuse_calibration()
1381 return -ENOMEM; in tegra186_xusb_read_fuse_calibration()
1385 if (err != -EPROBE_DEFER) in tegra186_xusb_read_fuse_calibration()
1397 padctl->calib.hs_curr_level = level; in tegra186_xusb_read_fuse_calibration()
1399 padctl->calib.hs_squelch = (value >> HS_SQUELCH_SHIFT) & in tegra186_xusb_read_fuse_calibration()
1401 padctl->calib.hs_term_range_adj = (value >> HS_TERM_RANGE_ADJ_SHIFT) & in tegra186_xusb_read_fuse_calibration()
1412 padctl->calib.rpd_ctrl = (value >> RPD_CTRL_SHIFT) & RPD_CTRL_MASK; in tegra186_xusb_read_fuse_calibration()
1428 return ERR_PTR(-ENOMEM); in tegra186_xusb_padctl_probe()
1430 priv->base.dev = dev; in tegra186_xusb_padctl_probe()
1431 priv->base.soc = soc; in tegra186_xusb_padctl_probe()
1434 priv->ao_regs = devm_ioremap_resource(dev, res); in tegra186_xusb_padctl_probe()
1435 if (IS_ERR(priv->ao_regs)) in tegra186_xusb_padctl_probe()
1436 return ERR_CAST(priv->ao_regs); in tegra186_xusb_padctl_probe()
1442 return &priv->base; in tegra186_xusb_padctl_probe()
1449 priv->context.vbus_id = padctl_readl(padctl, USB2_VBUS_ID); in tegra186_xusb_padctl_save()
1450 priv->context.usb2_pad_mux = padctl_readl(padctl, XUSB_PADCTL_USB2_PAD_MUX); in tegra186_xusb_padctl_save()
1451 priv->context.usb2_port_cap = padctl_readl(padctl, XUSB_PADCTL_USB2_PORT_CAP); in tegra186_xusb_padctl_save()
1452 priv->context.ss_port_cap = padctl_readl(padctl, XUSB_PADCTL_SS_PORT_CAP); in tegra186_xusb_padctl_save()
1459 padctl_writel(padctl, priv->context.usb2_pad_mux, XUSB_PADCTL_USB2_PAD_MUX); in tegra186_xusb_padctl_restore()
1460 padctl_writel(padctl, priv->context.usb2_port_cap, XUSB_PADCTL_USB2_PORT_CAP); in tegra186_xusb_padctl_restore()
1461 padctl_writel(padctl, priv->context.ss_port_cap, XUSB_PADCTL_SS_PORT_CAP); in tegra186_xusb_padctl_restore()
1462 padctl_writel(padctl, priv->context.vbus_id, USB2_VBUS_ID); in tegra186_xusb_padctl_restore()
1493 "avdd-pll-erefeut",
1494 "avdd-usb",
1495 "vclamp-usb",
1496 "vddio-hsic",
1500 TEGRA186_LANE("usb2-0", 0, 0, 0, usb2),
1501 TEGRA186_LANE("usb2-1", 0, 0, 0, usb2),
1502 TEGRA186_LANE("usb2-2", 0, 0, 0, usb2),
1513 TEGRA186_LANE("usb3-0", 0, 0, 0, usb3),
1514 TEGRA186_LANE("usb3-1", 0, 0, 0, usb3),
1515 TEGRA186_LANE("usb3-2", 0, 0, 0, usb3),
1561 "avdd-usb",
1562 "vclamp-usb",
1566 TEGRA186_LANE("usb2-0", 0, 0, 0, usb2),
1567 TEGRA186_LANE("usb2-1", 0, 0, 0, usb2),
1568 TEGRA186_LANE("usb2-2", 0, 0, 0, usb2),
1569 TEGRA186_LANE("usb2-3", 0, 0, 0, usb2),
1580 TEGRA186_LANE("usb3-0", 0, 0, 0, usb3),
1581 TEGRA186_LANE("usb3-1", 0, 0, 0, usb3),
1582 TEGRA186_LANE("usb3-2", 0, 0, 0, usb3),
1583 TEGRA186_LANE("usb3-3", 0, 0, 0, usb3),