Lines Matching +full:xusb +full:- +full:padctl

1 /*-
49 #include <dt-bindings/pinctrl/pinctrl-tegra-xusb.h>
170 #define WR4(_sc, _r, _v) bus_write_4((_sc)->mem_res, (_r), (_v))
171 #define RD4(_sc, _r) bus_read_4((_sc)->mem_res, (_r))
190 {"nvidia,tegra124-xusb-padctl", 1},
223 .name = n "-" #p, \
239 /* Pads - a group of lannes. */
284 static char *otg_mux[] = {"snps", "xusb", "uart", "rsvd"};
285 static char *usb_mux[] = {"snps", "xusb"};
286 static char *pci_mux[] = {"pcie", "usb3-ss", "sata", "rsvd"};
305 .name = n "-" #p, \
341 LANE_MAP(0, PADCTL_PAD_PCIE, 0), /* port USB3-0 -> lane PCIE-0 */
342 LANE_MAP(1, PADCTL_PAD_PCIE, 1), /* port USB3-1 -> lane PCIE-1 */
343 /* -- or -- */
344 LANE_MAP(1, PADCTL_PAD_SATA, 0), /* port USB3-1 -> lane SATA-0 */
359 /* -------------------------------------------------------------------------
369 if (port->internal) in usb3_port_init()
370 reg &= ~SS_PORT_MAP_PORT_INTERNAL(port->idx); in usb3_port_init()
372 reg |= SS_PORT_MAP_PORT_INTERNAL(port->idx); in usb3_port_init()
373 reg &= ~SS_PORT_MAP_PORT_MAP(port->idx, ~0); in usb3_port_init()
374 reg |= SS_PORT_MAP_PORT_MAP(port->idx, port->companion); in usb3_port_init()
377 reg = RD4(sc, XUSB_PADCTL_IOPHY_USB3_PAD_CTL2(port->idx)); in usb3_port_init()
384 WR4(sc, XUSB_PADCTL_IOPHY_USB3_PAD_CTL2(port->idx), reg); in usb3_port_init()
386 WR4(sc, XUSB_PADCTL_IOPHY_USB3_PAD_CTL4(port->idx), in usb3_port_init()
390 reg &= ~ELPG_PROGRAM_SSP_ELPG_VCORE_DOWN(port->idx); in usb3_port_init()
395 reg &= ~ELPG_PROGRAM_SSP_ELPG_CLAMP_EN_EARLY(port->idx); in usb3_port_init()
400 reg &= ~ELPG_PROGRAM_SSP_ELPG_CLAMP_EN(port->idx); in usb3_port_init()
430 for (i = 100; i > 0; i--) { in pcie_powerup()
437 device_printf(sc->dev, "Failed to power up PCIe phy\n"); in pcie_powerup()
441 reg |= USB3_PAD_MUX_PCIE_IDDQ_DISABLE(lane->idx); in pcie_powerup()
453 reg &= ~USB3_PAD_MUX_PCIE_IDDQ_DISABLE(lane->idx); in pcie_powerdown()
489 for (i = 100; i >= 0; i--) { in sata_powerup()
496 device_printf(sc->dev, "Failed to power up SATA phy\n"); in sata_powerup()
553 device_printf(sc->dev, "Cannot find port for lane: %s\n", in usb2_powerup()
554 lane->name); in usb2_powerup()
559 reg |= USB2_BIAS_PAD_CTL0_HS_SQUELCH_LEVEL(sc->hs_squelch_level); in usb2_powerup()
564 reg &= ~USB2_PORT_CAP_PORT_CAP(lane->idx, ~0); in usb2_powerup()
565 reg |= USB2_PORT_CAP_PORT_CAP(lane->idx, USB2_PORT_CAP_PORT_CAP_HOST); in usb2_powerup()
568 reg = RD4(sc, XUSB_PADCTL_USB2_OTG_PAD_CTL0(lane->idx)); in usb2_powerup()
577 if (lane->idx == 0) { in usb2_powerup()
578 reg |= USB2_OTG_PAD_CTL0_HS_CURR_LEVEL(sc->hs_curr_level_0); in usb2_powerup()
581 reg |= USB2_OTG_PAD_CTL0_HS_CURR_LEVEL(sc->hs_curr_level_123); in usb2_powerup()
584 WR4(sc, XUSB_PADCTL_USB2_OTG_PAD_CTL0(lane->idx), reg); in usb2_powerup()
586 reg = RD4(sc, XUSB_PADCTL_USB2_OTG_PAD_CTL1(lane->idx)); in usb2_powerup()
593 reg |= USB2_OTG_PAD_CTL1_TERM_RANGE_ADJ(sc->hs_term_range_adj); in usb2_powerup()
594 reg |= USB2_OTG_PAD_CTL1_HS_IREF_CAP(sc->hs_iref_cap); in usb2_powerup()
595 WR4(sc, XUSB_PADCTL_USB2_OTG_PAD_CTL1(lane->idx), reg); in usb2_powerup()
597 if (port != NULL && port->supply_vbus != NULL) { in usb2_powerup()
598 rv = regulator_enable(port->supply_vbus); in usb2_powerup()
600 device_printf(sc->dev, in usb2_powerup()
621 device_printf(sc->dev, "Cannot find port for lane: %s\n", in usb2_powerdown()
622 lane->name); in usb2_powerdown()
628 if (port != NULL && port->supply_vbus != NULL) { in usb2_powerdown()
629 rv = regulator_enable(port->supply_vbus); in usb2_powerdown()
631 device_printf(sc->dev, in usb2_powerdown()
704 if (!lane->enabled) { in xusbpadctl_phy_enable()
706 lane->name); in xusbpadctl_phy_enable()
709 pad = lane->pad; in xusbpadctl_phy_enable()
711 if (sc->phy_ena_cnt == 0) { in xusbpadctl_phy_enable()
716 sc->phy_ena_cnt++; in xusbpadctl_phy_enable()
720 rv = pad->powerup(sc, lane); in xusbpadctl_phy_enable()
722 rv = pad->powerdown(sc, lane); in xusbpadctl_phy_enable()
727 if (sc->phy_ena_cnt == 1) { in xusbpadctl_phy_enable()
732 sc->phy_ena_cnt--; in xusbpadctl_phy_enable()
738 /* -------------------------------------------------------------------------
788 if (type == lanes_tbl[i].pad->type && idx == lanes_tbl[i].idx) in search_pad_lane()
808 if (strcmp(tmp->mux[tmp->mux_idx], "usb3-ss") != 0) in search_usb3_pad_lane()
811 device_printf(sc->dev, "Duplicated mappings found for" in search_usb3_pad_lane()
812 " lanes: %s and %s\n", lane->name, tmp->name); in search_usb3_pad_lane()
837 for (i = 0; i < lane->nmux; i++) { in search_mux()
838 if (strcmp(fnc_name, lane->mux[i]) == 0) in search_mux()
841 return (-1); in search_mux()
849 reg = RD4(sc, lane->reg); in config_lane()
850 reg &= ~(lane->mask << lane->shift); in config_lane()
851 reg |= (lane->mux_idx & lane->mask) << lane->shift; in config_lane()
852 WR4(sc, lane->reg, reg); in config_lane()
870 device_printf(sc->dev, "Cannot read lane name.\n"); in process_lane()
876 device_printf(sc->dev, "Unknown lane: %s\n", name); in process_lane()
884 device_printf(sc->dev, "Cannot read lane function.\n"); in process_lane()
889 lane->mux_idx = search_mux(sc, lane, function); in process_lane()
890 if (lane->mux_idx == ~0) { in process_lane()
891 device_printf(sc->dev, "Unknown function %s for lane %s\n", in process_lane()
899 device_printf(sc->dev, "Cannot configure lane: %s: %d\n", in process_lane()
904 lane->pad = pad; in process_lane()
905 lane->enabled = true; in process_lane()
906 pad->lanes[pad->nlanes++] = lane; in process_lane()
910 phy_init.id = lane - lanes_tbl; in process_lane()
912 phynode = phynode_create(sc->dev, &xusbpadctl_phynode_class, &phy_init); in process_lane()
914 device_printf(sc->dev, "Cannot create phy\n"); in process_lane()
919 device_printf(sc->dev, "Cannot create phy\n"); in process_lane()
943 device_printf(sc->dev, "Cannot read pad name.\n"); in process_pad()
948 device_printf(sc->dev, "Unknown pad: %s\n", name); in process_pad()
956 device_printf(sc->dev, "Cannot find regulators subnode\n"); in process_pad()
969 pad->enabled = true; in process_pad()
988 device_printf(sc->dev, "Cannot read port name.\n"); in process_port()
994 device_printf(sc->dev, "Unknown port: %s\n", name); in process_port()
999 if (port->type == PADCTL_PORT_USB3) { in process_port()
1000 rv = OF_getencprop(node, "nvidia,usb2-companion", in process_port()
1001 &(port->companion), sizeof(port->companion)); in process_port()
1003 device_printf(sc->dev, in process_port()
1004 "Missing 'nvidia,usb2-companion' property " in process_port()
1011 if (OF_hasprop(node, "vbus-supply")) { in process_port()
1012 rv = regulator_get_by_ofw_property(sc->dev, 0, in process_port()
1013 "vbus-supply", &port->supply_vbus); in process_port()
1015 device_printf(sc->dev, in process_port()
1016 "Cannot get 'vbus-supply' regulator " in process_port()
1024 port->internal = true; in process_port()
1026 if (port->lane == NULL) { in process_port()
1027 switch(port->type) { in process_port()
1030 port->lane = search_pad_lane(sc, PADCTL_PAD_USB2, in process_port()
1031 port->idx); in process_port()
1034 port->lane = search_pad_lane(sc, PADCTL_PAD_ULPI, in process_port()
1035 port->idx); in process_port()
1038 port->lane = search_pad_lane(sc, PADCTL_PAD_HSIC, in process_port()
1039 port->idx); in process_port()
1042 port->lane = search_usb3_pad_lane(sc, port->idx); in process_port()
1046 if (port->lane == NULL) { in process_port()
1047 device_printf(sc->dev, "Cannot find lane for port: %s\n", name); in process_port()
1051 port->enabled = true; in process_port()
1069 device_printf(sc->dev, "Cannot find pads subnode.\n"); in parse_fdt()
1082 device_printf(sc->dev, "Cannot find ports subnode.\n"); in parse_fdt()
1101 /* All XUSB pad calibrations are packed into single dword.*/ in load_calibration()
1103 sc->hs_curr_level_0 = FUSE_XUSB_CALIB_HS_CURR_LEVEL_0(reg); in load_calibration()
1104 sc->hs_curr_level_123 = FUSE_XUSB_CALIB_HS_CURR_LEVEL_123(reg); in load_calibration()
1105 sc->hs_iref_cap = FUSE_XUSB_CALIB_HS_IREF_CAP(reg); in load_calibration()
1106 sc->hs_squelch_level = FUSE_XUSB_CALIB_HS_SQUELCH_LEVEL(reg); in load_calibration()
1107 sc->hs_term_range_adj = FUSE_XUSB_CALIB_HS_TERM_RANGE_ADJ(reg); in load_calibration()
1110 /* -------------------------------------------------------------------------
1121 if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) in xusbpadctl_probe()
1124 device_set_desc(dev, "Tegra XUSB phy"); in xusbpadctl_probe()
1145 sc->dev = dev; in xusbpadctl_attach()
1149 sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in xusbpadctl_attach()
1151 if (sc->mem_res == NULL) { in xusbpadctl_attach()
1156 rv = hwreset_get_by_ofw_name(dev, 0, "padctl", &sc->rst); in xusbpadctl_attach()
1158 device_printf(dev, "Cannot get 'padctl' reset: %d\n", rv); in xusbpadctl_attach()
1161 rv = hwreset_deassert(sc->rst); in xusbpadctl_attach()
1163 device_printf(dev, "Cannot unreset 'padctl' reset: %d\n", rv); in xusbpadctl_attach()
1176 if (!port->enabled) in xusbpadctl_attach()
1178 if (port->init == NULL) in xusbpadctl_attach()
1180 rv = port->init(sc, port); in xusbpadctl_attach()
1183 port->name); in xusbpadctl_attach()