Lines Matching +full:num +full:- +full:ss +full:- +full:bits
1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (c) 2014-2020, NVIDIA CORPORATION. All rights reserved.
11 #include <linux/dma-mapping.h>
194 unsigned int num; member
322 return readl(tegra->fpci_base + offset); in fpci_readl()
328 writel(value, tegra->fpci_base + offset); in fpci_writel()
333 return readl(tegra->ipfs_base + offset); in ipfs_readl()
339 writel(value, tegra->ipfs_base + offset); in ipfs_writel()
344 return readl(tegra->bar2_base + offset); in bar2_readl()
350 writel(value, tegra->bar2_base + offset); in bar2_writel()
355 const struct tegra_xusb_soc_ops *ops = tegra->soc->ops; in csb_readl()
357 return ops->csb_reg_readl(tegra, offset); in csb_readl()
363 const struct tegra_xusb_soc_ops *ops = tegra->soc->ops; in csb_writel()
365 ops->csb_reg_writel(tegra, value, offset); in csb_writel()
412 struct clk *clk = tegra->ss_src_clk; in tegra_xusb_set_ss_clk()
426 new_parent_rate = clk_get_rate(tegra->pll_u_480m); in tegra_xusb_set_ss_clk()
433 err = clk_set_parent(clk, tegra->pll_u_480m); in tegra_xusb_set_ss_clk()
449 err = clk_set_parent(clk, tegra->clk_m); in tegra_xusb_set_ss_clk()
460 dev_err(tegra->dev, "Invalid SS rate: %lu Hz\n", rate); in tegra_xusb_set_ss_clk()
461 return -EINVAL; in tegra_xusb_set_ss_clk()
465 dev_err(tegra->dev, "SS clock doesn't match requested rate\n"); in tegra_xusb_set_ss_clk()
466 return -EINVAL; in tegra_xusb_set_ss_clk()
475 return (value >> start) & ((1 << count) - 1); in extract_field()
513 return (msg->cmd & CMD_TYPE_MASK) << CMD_TYPE_SHIFT | in tegra_xusb_mbox_pack()
514 (msg->data & CMD_DATA_MASK) << CMD_DATA_SHIFT; in tegra_xusb_mbox_pack()
519 msg->cmd = (value >> CMD_TYPE_SHIFT) & CMD_TYPE_MASK; in tegra_xusb_mbox_unpack()
520 msg->data = (value >> CMD_DATA_SHIFT) & CMD_DATA_MASK; in tegra_xusb_mbox_unpack()
539 const struct tegra_xusb_soc_ops *ops = tegra->soc->ops; in tegra_xusb_mbox_send()
547 if (!(msg->cmd == MBOX_CMD_ACK || msg->cmd == MBOX_CMD_NAK)) { in tegra_xusb_mbox_send()
548 value = ops->mbox_reg_readl(tegra, tegra->soc->mbox.owner); in tegra_xusb_mbox_send()
550 dev_err(tegra->dev, "mailbox is busy\n"); in tegra_xusb_mbox_send()
551 return -EBUSY; in tegra_xusb_mbox_send()
554 ops->mbox_reg_writel(tegra, MBOX_OWNER_SW, tegra->soc->mbox.owner); in tegra_xusb_mbox_send()
556 value = ops->mbox_reg_readl(tegra, tegra->soc->mbox.owner); in tegra_xusb_mbox_send()
558 dev_err(tegra->dev, "failed to acquire mailbox\n"); in tegra_xusb_mbox_send()
559 return -EBUSY; in tegra_xusb_mbox_send()
566 ops->mbox_reg_writel(tegra, value, tegra->soc->mbox.data_in); in tegra_xusb_mbox_send()
568 value = ops->mbox_reg_readl(tegra, tegra->soc->mbox.cmd); in tegra_xusb_mbox_send()
570 ops->mbox_reg_writel(tegra, value, tegra->soc->mbox.cmd); in tegra_xusb_mbox_send()
576 value = ops->mbox_reg_readl(tegra, tegra->soc->mbox.owner); in tegra_xusb_mbox_send()
584 value = ops->mbox_reg_readl(tegra, tegra->soc->mbox.owner); in tegra_xusb_mbox_send()
587 return -ETIMEDOUT; in tegra_xusb_mbox_send()
596 const struct tegra_xusb_soc_ops *ops = tegra->soc->ops; in tegra_xusb_mbox_irq()
600 value = ops->mbox_reg_readl(tegra, tegra->soc->mbox.smi_intr); in tegra_xusb_mbox_irq()
601 ops->mbox_reg_writel(tegra, value, tegra->soc->mbox.smi_intr); in tegra_xusb_mbox_irq()
604 dev_err(tegra->dev, "controller firmware hang\n"); in tegra_xusb_mbox_irq()
612 struct tegra_xusb_padctl *padctl = tegra->padctl; in tegra_xusb_mbox_handle()
613 const struct tegra_xusb_soc *soc = tegra->soc; in tegra_xusb_mbox_handle()
614 struct device *dev = tegra->dev; in tegra_xusb_mbox_handle()
623 switch (msg->cmd) { in tegra_xusb_mbox_handle()
626 rsp.data = clk_get_rate(tegra->falcon_clk) / 1000; in tegra_xusb_mbox_handle()
627 if (rsp.data != msg->data) in tegra_xusb_mbox_handle()
636 if (tegra->soc->scale_ss_clock) { in tegra_xusb_mbox_handle()
637 err = tegra_xusb_set_ss_clk(tegra, msg->data * 1000); in tegra_xusb_mbox_handle()
643 rsp.data = clk_get_rate(tegra->ss_src_clk) / 1000; in tegra_xusb_mbox_handle()
646 rsp.data = msg->data; in tegra_xusb_mbox_handle()
660 err = tegra_xusb_padctl_usb3_save_context(padctl, msg->data); in tegra_xusb_mbox_handle()
663 msg->data, err); in tegra_xusb_mbox_handle()
669 rsp.data = msg->data; in tegra_xusb_mbox_handle()
674 if (msg->cmd == MBOX_CMD_STOP_HSIC_IDLE) in tegra_xusb_mbox_handle()
679 mask = extract_field(msg->data, 1 + soc->ports.hsic.offset, in tegra_xusb_mbox_handle()
680 soc->ports.hsic.count); in tegra_xusb_mbox_handle()
697 rsp.data = msg->data; in tegra_xusb_mbox_handle()
702 if (msg->cmd == MBOX_CMD_DISABLE_SS_LFPS_DETECTION) in tegra_xusb_mbox_handle()
707 mask = extract_field(msg->data, 1 + soc->ports.usb3.offset, in tegra_xusb_mbox_handle()
708 soc->ports.usb3.count); in tegra_xusb_mbox_handle()
710 for_each_set_bit(port, &mask, soc->ports.usb3.count) { in tegra_xusb_mbox_handle()
734 rsp.data = msg->data; in tegra_xusb_mbox_handle()
738 dev_warn(dev, "unknown message: %#x\n", msg->cmd); in tegra_xusb_mbox_handle()
754 const struct tegra_xusb_soc_ops *ops = tegra->soc->ops; in tegra_xusb_mbox_thread()
758 mutex_lock(&tegra->lock); in tegra_xusb_mbox_thread()
760 if (pm_runtime_suspended(tegra->dev) || tegra->suspended) in tegra_xusb_mbox_thread()
763 value = ops->mbox_reg_readl(tegra, tegra->soc->mbox.data_out); in tegra_xusb_mbox_thread()
766 value = ops->mbox_reg_readl(tegra, tegra->soc->mbox.cmd); in tegra_xusb_mbox_thread()
768 ops->mbox_reg_writel(tegra, value, tegra->soc->mbox.cmd); in tegra_xusb_mbox_thread()
772 ops->mbox_reg_writel(tegra, MBOX_OWNER_NONE, tegra->soc->mbox.owner); in tegra_xusb_mbox_thread()
777 mutex_unlock(&tegra->lock); in tegra_xusb_mbox_thread()
783 u32 regs = tegra->hcd->rsrc_start; in tegra_xusb_config()
786 if (tegra->soc->has_ipfs) { in tegra_xusb_config()
801 if (tegra->bar2) { in tegra_xusb_config()
804 value |= tegra->bar2->start & in tegra_xusb_config()
816 if (tegra->soc->has_ipfs) { in tegra_xusb_config()
831 err = clk_prepare_enable(tegra->pll_e); in tegra_xusb_clk_enable()
835 err = clk_prepare_enable(tegra->host_clk); in tegra_xusb_clk_enable()
839 err = clk_prepare_enable(tegra->ss_clk); in tegra_xusb_clk_enable()
843 err = clk_prepare_enable(tegra->falcon_clk); in tegra_xusb_clk_enable()
847 err = clk_prepare_enable(tegra->fs_src_clk); in tegra_xusb_clk_enable()
851 err = clk_prepare_enable(tegra->hs_src_clk); in tegra_xusb_clk_enable()
855 if (tegra->soc->scale_ss_clock) { in tegra_xusb_clk_enable()
864 clk_disable_unprepare(tegra->hs_src_clk); in tegra_xusb_clk_enable()
866 clk_disable_unprepare(tegra->fs_src_clk); in tegra_xusb_clk_enable()
868 clk_disable_unprepare(tegra->falcon_clk); in tegra_xusb_clk_enable()
870 clk_disable_unprepare(tegra->ss_clk); in tegra_xusb_clk_enable()
872 clk_disable_unprepare(tegra->host_clk); in tegra_xusb_clk_enable()
874 clk_disable_unprepare(tegra->pll_e); in tegra_xusb_clk_enable()
880 clk_disable_unprepare(tegra->pll_e); in tegra_xusb_clk_disable()
881 clk_disable_unprepare(tegra->host_clk); in tegra_xusb_clk_disable()
882 clk_disable_unprepare(tegra->ss_clk); in tegra_xusb_clk_disable()
883 clk_disable_unprepare(tegra->falcon_clk); in tegra_xusb_clk_disable()
884 clk_disable_unprepare(tegra->fs_src_clk); in tegra_xusb_clk_disable()
885 clk_disable_unprepare(tegra->hs_src_clk); in tegra_xusb_clk_disable()
893 for (i = 0; i < tegra->num_phys; i++) { in tegra_xusb_phy_enable()
894 err = phy_init(tegra->phys[i]); in tegra_xusb_phy_enable()
898 err = phy_power_on(tegra->phys[i]); in tegra_xusb_phy_enable()
900 phy_exit(tegra->phys[i]); in tegra_xusb_phy_enable()
908 while (i--) { in tegra_xusb_phy_enable()
909 phy_power_off(tegra->phys[i]); in tegra_xusb_phy_enable()
910 phy_exit(tegra->phys[i]); in tegra_xusb_phy_enable()
920 for (i = 0; i < tegra->num_phys; i++) { in tegra_xusb_phy_disable()
921 phy_power_off(tegra->phys[i]); in tegra_xusb_phy_disable()
922 phy_exit(tegra->phys[i]); in tegra_xusb_phy_disable()
929 const struct tegra_xusb_context_soc *soc = tegra->soc->context; in tegra_xusb_init_context()
931 tegra->context.ipfs = devm_kcalloc(tegra->dev, soc->ipfs.num_offsets, in tegra_xusb_init_context()
933 if (!tegra->context.ipfs) in tegra_xusb_init_context()
934 return -ENOMEM; in tegra_xusb_init_context()
936 tegra->context.fpci = devm_kcalloc(tegra->dev, soc->fpci.num_offsets, in tegra_xusb_init_context()
938 if (!tegra->context.fpci) in tegra_xusb_init_context()
939 return -ENOMEM; in tegra_xusb_init_context()
956 err = request_firmware(&fw, tegra->soc->firmware, tegra->dev); in tegra_xusb_request_firmware()
958 dev_err(tegra->dev, "failed to request firmware: %d\n", err); in tegra_xusb_request_firmware()
963 header = (struct tegra_xusb_fw_header *)fw->data; in tegra_xusb_request_firmware()
964 tegra->fw.size = le32_to_cpu(header->fwimg_len); in tegra_xusb_request_firmware()
966 tegra->fw.virt = dma_alloc_coherent(tegra->dev, tegra->fw.size, in tegra_xusb_request_firmware()
967 &tegra->fw.phys, GFP_KERNEL); in tegra_xusb_request_firmware()
968 if (!tegra->fw.virt) { in tegra_xusb_request_firmware()
969 dev_err(tegra->dev, "failed to allocate memory for firmware\n"); in tegra_xusb_request_firmware()
971 return -ENOMEM; in tegra_xusb_request_firmware()
974 header = (struct tegra_xusb_fw_header *)tegra->fw.virt; in tegra_xusb_request_firmware()
975 memcpy(tegra->fw.virt, fw->data, tegra->fw.size); in tegra_xusb_request_firmware()
988 cap_regs = tegra->regs; in tegra_xusb_wait_for_falcon()
989 op_regs = tegra->regs + HC_LENGTH(readl(&cap_regs->hc_capbase)); in tegra_xusb_wait_for_falcon()
991 ret = readl_poll_timeout(&op_regs->status, value, !(value & STS_CNR), 1000, 200000); in tegra_xusb_wait_for_falcon()
994 dev_err(tegra->dev, "XHCI Controller not ready. Falcon state: 0x%x\n", in tegra_xusb_wait_for_falcon()
1004 struct device *dev = tegra->dev; in tegra_xusb_load_firmware_rom()
1010 header = (struct tegra_xusb_fw_header *)tegra->fw.virt; in tegra_xusb_load_firmware_rom()
1019 csb_writel(tegra, tegra->fw.size, XUSB_CSB_MP_ILOAD_ATTR); in tegra_xusb_load_firmware_rom()
1025 address = tegra->fw.phys + sizeof(*header); in tegra_xusb_load_firmware_rom()
1039 code_tag_blocks = DIV_ROUND_UP(le32_to_cpu(header->boot_codetag), in tegra_xusb_load_firmware_rom()
1041 code_size_blocks = DIV_ROUND_UP(le32_to_cpu(header->boot_codesize), in tegra_xusb_load_firmware_rom()
1055 /* Setup Falcon auto-fill. */ in tegra_xusb_load_firmware_rom()
1077 csb_writel(tegra, le32_to_cpu(header->boot_codetag), in tegra_xusb_load_firmware_rom()
1084 return -EIO; in tegra_xusb_load_firmware_rom()
1086 timestamp = le32_to_cpu(header->fwimg_created_time); in tegra_xusb_load_firmware_rom()
1112 return -EIO; in tegra_xusb_init_ifr_firmware()
1118 dev_info(tegra->dev, "Firmware timestamp: %ptTs UTC\n", ×tamp); in tegra_xusb_init_ifr_firmware()
1125 if (!tegra->soc->firmware) in tegra_xusb_load_firmware()
1134 if (!tegra->use_genpd) in tegra_xusb_powerdomain_remove()
1137 if (!IS_ERR_OR_NULL(tegra->genpd_dev_ss)) in tegra_xusb_powerdomain_remove()
1138 dev_pm_domain_detach(tegra->genpd_dev_ss, true); in tegra_xusb_powerdomain_remove()
1139 if (!IS_ERR_OR_NULL(tegra->genpd_dev_host)) in tegra_xusb_powerdomain_remove()
1140 dev_pm_domain_detach(tegra->genpd_dev_host, true); in tegra_xusb_powerdomain_remove()
1148 tegra->genpd_dev_host = dev_pm_domain_attach_by_name(dev, "xusb_host"); in tegra_xusb_powerdomain_init()
1149 if (IS_ERR(tegra->genpd_dev_host)) { in tegra_xusb_powerdomain_init()
1150 err = PTR_ERR(tegra->genpd_dev_host); in tegra_xusb_powerdomain_init()
1151 dev_err(dev, "failed to get host pm-domain: %d\n", err); in tegra_xusb_powerdomain_init()
1155 tegra->genpd_dev_ss = dev_pm_domain_attach_by_name(dev, "xusb_ss"); in tegra_xusb_powerdomain_init()
1156 if (IS_ERR(tegra->genpd_dev_ss)) { in tegra_xusb_powerdomain_init()
1157 err = PTR_ERR(tegra->genpd_dev_ss); in tegra_xusb_powerdomain_init()
1158 dev_err(dev, "failed to get superspeed pm-domain: %d\n", err); in tegra_xusb_powerdomain_init()
1162 tegra->use_genpd = true; in tegra_xusb_powerdomain_init()
1169 struct device *dev = tegra->dev; in tegra_xusb_unpowergate_partitions()
1172 if (tegra->use_genpd) { in tegra_xusb_unpowergate_partitions()
1173 rc = pm_runtime_resume_and_get(tegra->genpd_dev_ss); in tegra_xusb_unpowergate_partitions()
1175 dev_err(dev, "failed to enable XUSB SS partition\n"); in tegra_xusb_unpowergate_partitions()
1179 rc = pm_runtime_resume_and_get(tegra->genpd_dev_host); in tegra_xusb_unpowergate_partitions()
1182 pm_runtime_put_sync(tegra->genpd_dev_ss); in tegra_xusb_unpowergate_partitions()
1187 tegra->ss_clk, in tegra_xusb_unpowergate_partitions()
1188 tegra->ss_rst); in tegra_xusb_unpowergate_partitions()
1190 dev_err(dev, "failed to enable XUSB SS partition\n"); in tegra_xusb_unpowergate_partitions()
1195 tegra->host_clk, in tegra_xusb_unpowergate_partitions()
1196 tegra->host_rst); in tegra_xusb_unpowergate_partitions()
1209 struct device *dev = tegra->dev; in tegra_xusb_powergate_partitions()
1212 if (tegra->use_genpd) { in tegra_xusb_powergate_partitions()
1213 rc = pm_runtime_put_sync(tegra->genpd_dev_host); in tegra_xusb_powergate_partitions()
1219 rc = pm_runtime_put_sync(tegra->genpd_dev_ss); in tegra_xusb_powergate_partitions()
1221 dev_err(dev, "failed to disable XUSB SS partition\n"); in tegra_xusb_powergate_partitions()
1222 pm_runtime_get_sync(tegra->genpd_dev_host); in tegra_xusb_powergate_partitions()
1234 dev_err(dev, "failed to disable XUSB SS partition\n"); in tegra_xusb_powergate_partitions()
1236 tegra->host_clk, in tegra_xusb_powergate_partitions()
1237 tegra->host_rst); in tegra_xusb_powergate_partitions()
1256 dev_err(tegra->dev, "failed to enable messages: %d\n", err); in __tegra_xusb_enable_firmware_messages()
1265 mutex_lock(&tegra->lock); in tegra_xusb_padctl_irq()
1267 if (tegra->suspended) { in tegra_xusb_padctl_irq()
1268 mutex_unlock(&tegra->lock); in tegra_xusb_padctl_irq()
1272 mutex_unlock(&tegra->lock); in tegra_xusb_padctl_irq()
1274 pm_runtime_resume(tegra->dev); in tegra_xusb_padctl_irq()
1283 mutex_lock(&tegra->lock); in tegra_xusb_enable_firmware_messages()
1285 mutex_unlock(&tegra->lock); in tegra_xusb_enable_firmware_messages()
1293 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xhci_set_port_power()
1294 struct usb_hcd *hcd = main ? xhci->main_hcd : xhci->shared_hcd; in tegra_xhci_set_port_power()
1297 u16 wIndex = main ? tegra->otg_usb2_port + 1 : tegra->otg_usb3_port + 1; in tegra_xhci_set_port_power()
1302 dev_dbg(tegra->dev, "%s():%s %s port power\n", __func__, in tegra_xhci_set_port_power()
1303 set ? "set" : "clear", main ? "HS" : "SS"); in tegra_xhci_set_port_power()
1305 hcd->driver->hub_control(hcd, typeReq, USB_PORT_FEAT_POWER, wIndex, in tegra_xhci_set_port_power()
1318 } while (--wait > 0); in tegra_xhci_set_port_power()
1321 dev_info(tegra->dev, "failed to %s %s PP %d\n", in tegra_xhci_set_port_power()
1323 main ? "HS" : "SS", status); in tegra_xhci_set_port_power()
1331 for (i = 0; i < tegra->soc->num_types; i++) { in tegra_xusb_get_phy()
1332 if (!strncmp(tegra->soc->phy_types[i].name, name, in tegra_xusb_get_phy()
1334 return tegra->phys[phy_count+port]; in tegra_xusb_get_phy()
1336 phy_count += tegra->soc->phy_types[i].num; in tegra_xusb_get_phy()
1346 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xhci_id_work()
1349 tegra->otg_usb2_port); in tegra_xhci_id_work()
1353 dev_dbg(tegra->dev, "host mode %s\n", str_on_off(tegra->host_mode)); in tegra_xhci_id_work()
1355 mutex_lock(&tegra->lock); in tegra_xhci_id_work()
1357 if (tegra->host_mode) in tegra_xhci_id_work()
1362 mutex_unlock(&tegra->lock); in tegra_xhci_id_work()
1364 tegra->otg_usb3_port = tegra_xusb_padctl_get_usb3_companion(tegra->padctl, in tegra_xhci_id_work()
1365 tegra->otg_usb2_port); in tegra_xhci_id_work()
1367 if (tegra->host_mode) { in tegra_xhci_id_work()
1369 if (tegra->otg_usb3_port >= 0) { in tegra_xhci_id_work()
1370 if (tegra->soc->otg_reset_sspi) { in tegra_xhci_id_work()
1373 xhci->shared_hcd, GetPortStatus, in tegra_xhci_id_work()
1374 0, tegra->otg_usb3_port+1, in tegra_xhci_id_work()
1382 msg.data = tegra->otg_usb3_port+1; in tegra_xhci_id_work()
1386 dev_info(tegra->dev, in tegra_xhci_id_work()
1398 if (tegra->otg_usb3_port >= 0) in tegra_xhci_id_work()
1408 return (tegra->usbphy[index] != NULL); in is_usb2_otg_phy()
1413 struct tegra_xusb_padctl *padctl = tegra->padctl; in is_usb3_otg_phy()
1417 for (i = 0; i < tegra->num_usb_phys; i++) { in is_usb3_otg_phy()
1430 if (strcmp(tegra->soc->phy_types[phy_type].name, "hsic") == 0) in is_host_mode_phy()
1433 if (strcmp(tegra->soc->phy_types[phy_type].name, "usb2") == 0) { in is_host_mode_phy()
1435 return ((index == tegra->otg_usb2_port) && tegra->host_mode); in is_host_mode_phy()
1440 if (strcmp(tegra->soc->phy_types[phy_type].name, "usb3") == 0) { in is_host_mode_phy()
1442 return ((index == tegra->otg_usb3_port) && tegra->host_mode); in is_host_mode_phy()
1456 for (i = 0; i < tegra->num_usb_phys; i++) { in tegra_xusb_get_usb2_port()
1457 if (tegra->usbphy[i] && usbphy == tegra->usbphy[i]) in tegra_xusb_get_usb2_port()
1461 return -1; in tegra_xusb_get_usb2_port()
1471 dev_dbg(tegra->dev, "%s(): action is %d", __func__, usbphy->last_event); in tegra_xhci_id_notify()
1473 if ((tegra->host_mode && usbphy->last_event == USB_EVENT_ID) || in tegra_xhci_id_notify()
1474 (!tegra->host_mode && usbphy->last_event != USB_EVENT_ID)) { in tegra_xhci_id_notify()
1475 dev_dbg(tegra->dev, "Same role(%d) received. Ignore", in tegra_xhci_id_notify()
1476 tegra->host_mode); in tegra_xhci_id_notify()
1480 tegra->otg_usb2_port = tegra_xusb_get_usb2_port(tegra, usbphy); in tegra_xhci_id_notify()
1482 tegra->host_mode = (usbphy->last_event == USB_EVENT_ID) ? true : false; in tegra_xhci_id_notify()
1484 schedule_work(&tegra->id_work); in tegra_xhci_id_notify()
1493 tegra->usbphy = devm_kcalloc(tegra->dev, tegra->num_usb_phys, in tegra_xusb_init_usb_phy()
1494 sizeof(*tegra->usbphy), GFP_KERNEL); in tegra_xusb_init_usb_phy()
1495 if (!tegra->usbphy) in tegra_xusb_init_usb_phy()
1496 return -ENOMEM; in tegra_xusb_init_usb_phy()
1498 INIT_WORK(&tegra->id_work, tegra_xhci_id_work); in tegra_xusb_init_usb_phy()
1499 tegra->id_nb.notifier_call = tegra_xhci_id_notify; in tegra_xusb_init_usb_phy()
1500 tegra->otg_usb2_port = -EINVAL; in tegra_xusb_init_usb_phy()
1501 tegra->otg_usb3_port = -EINVAL; in tegra_xusb_init_usb_phy()
1503 for (i = 0; i < tegra->num_usb_phys; i++) { in tegra_xusb_init_usb_phy()
1509 tegra->usbphy[i] = devm_usb_get_phy_by_node(tegra->dev, in tegra_xusb_init_usb_phy()
1510 phy->dev.of_node, in tegra_xusb_init_usb_phy()
1511 &tegra->id_nb); in tegra_xusb_init_usb_phy()
1512 if (!IS_ERR(tegra->usbphy[i])) { in tegra_xusb_init_usb_phy()
1513 dev_dbg(tegra->dev, "usbphy-%d registered", i); in tegra_xusb_init_usb_phy()
1514 otg_set_host(tegra->usbphy[i]->otg, &tegra->hcd->self); in tegra_xusb_init_usb_phy()
1517 * usb-phy is optional, continue if its not available. in tegra_xusb_init_usb_phy()
1519 tegra->usbphy[i] = NULL; in tegra_xusb_init_usb_phy()
1530 cancel_work_sync(&tegra->id_work); in tegra_xusb_deinit_usb_phy()
1532 for (i = 0; i < tegra->num_usb_phys; i++) in tegra_xusb_deinit_usb_phy()
1533 if (tegra->usbphy[i]) in tegra_xusb_deinit_usb_phy()
1534 otg_set_host(tegra->usbphy[i]->otg, NULL); in tegra_xusb_deinit_usb_phy()
1549 tegra = devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL); in tegra_xusb_probe()
1551 return -ENOMEM; in tegra_xusb_probe()
1553 tegra->soc = of_device_get_match_data(&pdev->dev); in tegra_xusb_probe()
1554 mutex_init(&tegra->lock); in tegra_xusb_probe()
1555 tegra->dev = &pdev->dev; in tegra_xusb_probe()
1561 tegra->regs = devm_platform_get_and_ioremap_resource(pdev, 0, ®s); in tegra_xusb_probe()
1562 if (IS_ERR(tegra->regs)) in tegra_xusb_probe()
1563 return PTR_ERR(tegra->regs); in tegra_xusb_probe()
1565 tegra->fpci_base = devm_platform_ioremap_resource(pdev, 1); in tegra_xusb_probe()
1566 if (IS_ERR(tegra->fpci_base)) in tegra_xusb_probe()
1567 return PTR_ERR(tegra->fpci_base); in tegra_xusb_probe()
1569 if (tegra->soc->has_ipfs) { in tegra_xusb_probe()
1570 tegra->ipfs_base = devm_platform_ioremap_resource(pdev, 2); in tegra_xusb_probe()
1571 if (IS_ERR(tegra->ipfs_base)) in tegra_xusb_probe()
1572 return PTR_ERR(tegra->ipfs_base); in tegra_xusb_probe()
1573 } else if (tegra->soc->has_bar2) { in tegra_xusb_probe()
1574 tegra->bar2_base = devm_platform_get_and_ioremap_resource(pdev, 2, &tegra->bar2); in tegra_xusb_probe()
1575 if (IS_ERR(tegra->bar2_base)) in tegra_xusb_probe()
1576 return PTR_ERR(tegra->bar2_base); in tegra_xusb_probe()
1579 tegra->xhci_irq = platform_get_irq(pdev, 0); in tegra_xusb_probe()
1580 if (tegra->xhci_irq < 0) in tegra_xusb_probe()
1581 return tegra->xhci_irq; in tegra_xusb_probe()
1583 tegra->mbox_irq = platform_get_irq(pdev, 1); in tegra_xusb_probe()
1584 if (tegra->mbox_irq < 0) in tegra_xusb_probe()
1585 return tegra->mbox_irq; in tegra_xusb_probe()
1587 tegra->padctl = tegra_xusb_padctl_get(&pdev->dev); in tegra_xusb_probe()
1588 if (IS_ERR(tegra->padctl)) in tegra_xusb_probe()
1589 return PTR_ERR(tegra->padctl); in tegra_xusb_probe()
1591 np = of_parse_phandle(pdev->dev.of_node, "nvidia,xusb-padctl", 0); in tegra_xusb_probe()
1593 err = -ENODEV; in tegra_xusb_probe()
1597 tegra->padctl_irq = of_irq_get(np, 0); in tegra_xusb_probe()
1598 if (tegra->padctl_irq == -EPROBE_DEFER) { in tegra_xusb_probe()
1599 err = tegra->padctl_irq; in tegra_xusb_probe()
1601 } else if (tegra->padctl_irq <= 0) { in tegra_xusb_probe()
1602 /* Older device-trees don't have padctrl interrupt */ in tegra_xusb_probe()
1603 tegra->padctl_irq = 0; in tegra_xusb_probe()
1604 dev_dbg(&pdev->dev, in tegra_xusb_probe()
1608 tegra->host_clk = devm_clk_get(&pdev->dev, "xusb_host"); in tegra_xusb_probe()
1609 if (IS_ERR(tegra->host_clk)) { in tegra_xusb_probe()
1610 err = PTR_ERR(tegra->host_clk); in tegra_xusb_probe()
1611 dev_err(&pdev->dev, "failed to get xusb_host: %d\n", err); in tegra_xusb_probe()
1615 tegra->falcon_clk = devm_clk_get(&pdev->dev, "xusb_falcon_src"); in tegra_xusb_probe()
1616 if (IS_ERR(tegra->falcon_clk)) { in tegra_xusb_probe()
1617 err = PTR_ERR(tegra->falcon_clk); in tegra_xusb_probe()
1618 dev_err(&pdev->dev, "failed to get xusb_falcon_src: %d\n", err); in tegra_xusb_probe()
1622 tegra->ss_clk = devm_clk_get(&pdev->dev, "xusb_ss"); in tegra_xusb_probe()
1623 if (IS_ERR(tegra->ss_clk)) { in tegra_xusb_probe()
1624 err = PTR_ERR(tegra->ss_clk); in tegra_xusb_probe()
1625 dev_err(&pdev->dev, "failed to get xusb_ss: %d\n", err); in tegra_xusb_probe()
1629 tegra->ss_src_clk = devm_clk_get(&pdev->dev, "xusb_ss_src"); in tegra_xusb_probe()
1630 if (IS_ERR(tegra->ss_src_clk)) { in tegra_xusb_probe()
1631 err = PTR_ERR(tegra->ss_src_clk); in tegra_xusb_probe()
1632 dev_err(&pdev->dev, "failed to get xusb_ss_src: %d\n", err); in tegra_xusb_probe()
1636 tegra->hs_src_clk = devm_clk_get(&pdev->dev, "xusb_hs_src"); in tegra_xusb_probe()
1637 if (IS_ERR(tegra->hs_src_clk)) { in tegra_xusb_probe()
1638 err = PTR_ERR(tegra->hs_src_clk); in tegra_xusb_probe()
1639 dev_err(&pdev->dev, "failed to get xusb_hs_src: %d\n", err); in tegra_xusb_probe()
1643 tegra->fs_src_clk = devm_clk_get(&pdev->dev, "xusb_fs_src"); in tegra_xusb_probe()
1644 if (IS_ERR(tegra->fs_src_clk)) { in tegra_xusb_probe()
1645 err = PTR_ERR(tegra->fs_src_clk); in tegra_xusb_probe()
1646 dev_err(&pdev->dev, "failed to get xusb_fs_src: %d\n", err); in tegra_xusb_probe()
1650 tegra->pll_u_480m = devm_clk_get(&pdev->dev, "pll_u_480m"); in tegra_xusb_probe()
1651 if (IS_ERR(tegra->pll_u_480m)) { in tegra_xusb_probe()
1652 err = PTR_ERR(tegra->pll_u_480m); in tegra_xusb_probe()
1653 dev_err(&pdev->dev, "failed to get pll_u_480m: %d\n", err); in tegra_xusb_probe()
1657 tegra->clk_m = devm_clk_get(&pdev->dev, "clk_m"); in tegra_xusb_probe()
1658 if (IS_ERR(tegra->clk_m)) { in tegra_xusb_probe()
1659 err = PTR_ERR(tegra->clk_m); in tegra_xusb_probe()
1660 dev_err(&pdev->dev, "failed to get clk_m: %d\n", err); in tegra_xusb_probe()
1664 tegra->pll_e = devm_clk_get(&pdev->dev, "pll_e"); in tegra_xusb_probe()
1665 if (IS_ERR(tegra->pll_e)) { in tegra_xusb_probe()
1666 err = PTR_ERR(tegra->pll_e); in tegra_xusb_probe()
1667 dev_err(&pdev->dev, "failed to get pll_e: %d\n", err); in tegra_xusb_probe()
1671 if (!of_property_present(pdev->dev.of_node, "power-domains")) { in tegra_xusb_probe()
1672 tegra->host_rst = devm_reset_control_get(&pdev->dev, in tegra_xusb_probe()
1674 if (IS_ERR(tegra->host_rst)) { in tegra_xusb_probe()
1675 err = PTR_ERR(tegra->host_rst); in tegra_xusb_probe()
1676 dev_err(&pdev->dev, in tegra_xusb_probe()
1681 tegra->ss_rst = devm_reset_control_get(&pdev->dev, "xusb_ss"); in tegra_xusb_probe()
1682 if (IS_ERR(tegra->ss_rst)) { in tegra_xusb_probe()
1683 err = PTR_ERR(tegra->ss_rst); in tegra_xusb_probe()
1684 dev_err(&pdev->dev, "failed to get xusb_ss reset: %d\n", in tegra_xusb_probe()
1689 err = tegra_xusb_powerdomain_init(&pdev->dev, tegra); in tegra_xusb_probe()
1694 tegra->supplies = devm_kcalloc(&pdev->dev, tegra->soc->num_supplies, in tegra_xusb_probe()
1695 sizeof(*tegra->supplies), GFP_KERNEL); in tegra_xusb_probe()
1696 if (!tegra->supplies) { in tegra_xusb_probe()
1697 err = -ENOMEM; in tegra_xusb_probe()
1701 regulator_bulk_set_supply_names(tegra->supplies, in tegra_xusb_probe()
1702 tegra->soc->supply_names, in tegra_xusb_probe()
1703 tegra->soc->num_supplies); in tegra_xusb_probe()
1705 err = devm_regulator_bulk_get(&pdev->dev, tegra->soc->num_supplies, in tegra_xusb_probe()
1706 tegra->supplies); in tegra_xusb_probe()
1708 dev_err(&pdev->dev, "failed to get regulators: %d\n", err); in tegra_xusb_probe()
1712 for (i = 0; i < tegra->soc->num_types; i++) { in tegra_xusb_probe()
1713 if (!strncmp(tegra->soc->phy_types[i].name, "usb2", 4)) in tegra_xusb_probe()
1714 tegra->num_usb_phys = tegra->soc->phy_types[i].num; in tegra_xusb_probe()
1715 tegra->num_phys += tegra->soc->phy_types[i].num; in tegra_xusb_probe()
1718 tegra->phys = devm_kcalloc(&pdev->dev, tegra->num_phys, in tegra_xusb_probe()
1719 sizeof(*tegra->phys), GFP_KERNEL); in tegra_xusb_probe()
1720 if (!tegra->phys) { in tegra_xusb_probe()
1721 err = -ENOMEM; in tegra_xusb_probe()
1725 for (i = 0, k = 0; i < tegra->soc->num_types; i++) { in tegra_xusb_probe()
1728 for (j = 0; j < tegra->soc->phy_types[i].num; j++) { in tegra_xusb_probe()
1729 snprintf(prop, sizeof(prop), "%s-%d", in tegra_xusb_probe()
1730 tegra->soc->phy_types[i].name, j); in tegra_xusb_probe()
1732 phy = devm_phy_optional_get(&pdev->dev, prop); in tegra_xusb_probe()
1734 dev_err(&pdev->dev, in tegra_xusb_probe()
1741 tegra->phys[k++] = phy; in tegra_xusb_probe()
1745 tegra->hcd = usb_create_hcd(&tegra_xhci_hc_driver, &pdev->dev, in tegra_xusb_probe()
1746 dev_name(&pdev->dev)); in tegra_xusb_probe()
1747 if (!tegra->hcd) { in tegra_xusb_probe()
1748 err = -ENOMEM; in tegra_xusb_probe()
1752 tegra->hcd->skip_phy_initialization = 1; in tegra_xusb_probe()
1753 tegra->hcd->regs = tegra->regs; in tegra_xusb_probe()
1754 tegra->hcd->rsrc_start = regs->start; in tegra_xusb_probe()
1755 tegra->hcd->rsrc_len = resource_size(regs); in tegra_xusb_probe()
1765 dev_err(tegra->dev, "failed to enable clocks: %d\n", err); in tegra_xusb_probe()
1769 err = regulator_bulk_enable(tegra->soc->num_supplies, tegra->supplies); in tegra_xusb_probe()
1771 dev_err(tegra->dev, "failed to enable regulators: %d\n", err); in tegra_xusb_probe()
1777 dev_err(&pdev->dev, "failed to enable PHYs: %d\n", err); in tegra_xusb_probe()
1782 * The XUSB Falcon microcontroller can only address 40 bits, so set in tegra_xusb_probe()
1785 err = dma_set_mask_and_coherent(tegra->dev, DMA_BIT_MASK(40)); in tegra_xusb_probe()
1787 dev_err(&pdev->dev, "failed to set DMA mask: %d\n", err); in tegra_xusb_probe()
1791 if (tegra->soc->firmware) { in tegra_xusb_probe()
1794 dev_err(&pdev->dev, in tegra_xusb_probe()
1808 dev_err(&pdev->dev, "failed to load firmware: %d\n", err); in tegra_xusb_probe()
1812 err = usb_add_hcd(tegra->hcd, tegra->xhci_irq, IRQF_SHARED); in tegra_xusb_probe()
1814 dev_err(&pdev->dev, "failed to add USB HCD: %d\n", err); in tegra_xusb_probe()
1818 device_wakeup_enable(tegra->hcd->self.controller); in tegra_xusb_probe()
1820 xhci = hcd_to_xhci(tegra->hcd); in tegra_xusb_probe()
1822 xhci->shared_hcd = usb_create_shared_hcd(&tegra_xhci_hc_driver, in tegra_xusb_probe()
1823 &pdev->dev, in tegra_xusb_probe()
1824 dev_name(&pdev->dev), in tegra_xusb_probe()
1825 tegra->hcd); in tegra_xusb_probe()
1826 if (!xhci->shared_hcd) { in tegra_xusb_probe()
1827 dev_err(&pdev->dev, "failed to create shared HCD\n"); in tegra_xusb_probe()
1828 err = -ENOMEM; in tegra_xusb_probe()
1832 if (HCC_MAX_PSA(xhci->hcc_params) >= 4) in tegra_xusb_probe()
1833 xhci->shared_hcd->can_do_streams = 1; in tegra_xusb_probe()
1835 err = usb_add_hcd(xhci->shared_hcd, tegra->xhci_irq, IRQF_SHARED); in tegra_xusb_probe()
1837 dev_err(&pdev->dev, "failed to add shared HCD: %d\n", err); in tegra_xusb_probe()
1841 err = devm_request_threaded_irq(&pdev->dev, tegra->mbox_irq, in tegra_xusb_probe()
1844 dev_name(&pdev->dev), tegra); in tegra_xusb_probe()
1846 dev_err(&pdev->dev, "failed to request IRQ: %d\n", err); in tegra_xusb_probe()
1850 if (tegra->padctl_irq) { in tegra_xusb_probe()
1851 err = devm_request_threaded_irq(&pdev->dev, tegra->padctl_irq, in tegra_xusb_probe()
1853 IRQF_ONESHOT, dev_name(&pdev->dev), in tegra_xusb_probe()
1856 dev_err(&pdev->dev, "failed to request padctl IRQ: %d\n", err); in tegra_xusb_probe()
1863 dev_err(&pdev->dev, "failed to enable messages: %d\n", err); in tegra_xusb_probe()
1869 dev_err(&pdev->dev, "failed to init USB PHY: %d\n", err); in tegra_xusb_probe()
1874 device_init_wakeup(&tegra->hcd->self.root_hub->dev, true); in tegra_xusb_probe()
1875 device_init_wakeup(&xhci->shared_hcd->self.root_hub->dev, true); in tegra_xusb_probe()
1877 pm_runtime_use_autosuspend(tegra->dev); in tegra_xusb_probe()
1878 pm_runtime_set_autosuspend_delay(tegra->dev, 2000); in tegra_xusb_probe()
1879 pm_runtime_mark_last_busy(tegra->dev); in tegra_xusb_probe()
1880 pm_runtime_set_active(tegra->dev); in tegra_xusb_probe()
1882 if (tegra->padctl_irq) { in tegra_xusb_probe()
1883 device_init_wakeup(tegra->dev, true); in tegra_xusb_probe()
1884 pm_runtime_enable(tegra->dev); in tegra_xusb_probe()
1890 usb_remove_hcd(xhci->shared_hcd); in tegra_xusb_probe()
1892 usb_put_hcd(xhci->shared_hcd); in tegra_xusb_probe()
1894 usb_remove_hcd(tegra->hcd); in tegra_xusb_probe()
1898 dma_free_coherent(&pdev->dev, tegra->fw.size, tegra->fw.virt, in tegra_xusb_probe()
1899 tegra->fw.phys); in tegra_xusb_probe()
1903 regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies); in tegra_xusb_probe()
1907 usb_put_hcd(tegra->hcd); in tegra_xusb_probe()
1909 tegra_xusb_powerdomain_remove(&pdev->dev, tegra); in tegra_xusb_probe()
1912 tegra_xusb_padctl_put(tegra->padctl); in tegra_xusb_probe()
1919 tegra_xusb_powerdomain_remove(tegra->dev, tegra); in tegra_xusb_disable()
1922 regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies); in tegra_xusb_disable()
1928 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xusb_remove()
1932 pm_runtime_get_sync(&pdev->dev); in tegra_xusb_remove()
1933 usb_remove_hcd(xhci->shared_hcd); in tegra_xusb_remove()
1934 usb_put_hcd(xhci->shared_hcd); in tegra_xusb_remove()
1935 xhci->shared_hcd = NULL; in tegra_xusb_remove()
1936 usb_remove_hcd(tegra->hcd); in tegra_xusb_remove()
1937 usb_put_hcd(tegra->hcd); in tegra_xusb_remove()
1939 dma_free_coherent(&pdev->dev, tegra->fw.size, tegra->fw.virt, in tegra_xusb_remove()
1940 tegra->fw.phys); in tegra_xusb_remove()
1942 if (tegra->padctl_irq) in tegra_xusb_remove()
1943 pm_runtime_disable(&pdev->dev); in tegra_xusb_remove()
1945 pm_runtime_put(&pdev->dev); in tegra_xusb_remove()
1948 tegra_xusb_padctl_put(tegra->padctl); in tegra_xusb_remove()
1955 pm_runtime_get_sync(&pdev->dev); in tegra_xusb_shutdown()
1956 disable_irq(tegra->xhci_irq); in tegra_xusb_shutdown()
1957 xhci_shutdown(tegra->hcd); in tegra_xusb_shutdown()
1963 struct device *dev = hub->hcd->self.controller; in xhci_hub_ports_suspended()
1968 for (i = 0; i < hub->num_ports; i++) { in xhci_hub_ports_suspended()
1969 value = readl(hub->ports[i]->addr); in xhci_hub_ports_suspended()
1974 dev_info(dev, "%u-%u isn't suspended: %#010x\n", in xhci_hub_ports_suspended()
1975 hub->hcd->self.busnum, i + 1, value); in xhci_hub_ports_suspended()
1985 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xusb_check_ports()
1986 struct xhci_bus_state *bus_state = &xhci->usb2_rhub.bus_state; in tegra_xusb_check_ports()
1990 if (bus_state->bus_suspended) { in tegra_xusb_check_ports()
1997 spin_lock_irqsave(&xhci->lock, flags); in tegra_xusb_check_ports()
1999 if (!xhci_hub_ports_suspended(&xhci->usb2_rhub) || in tegra_xusb_check_ports()
2000 !xhci_hub_ports_suspended(&xhci->usb3_rhub)) in tegra_xusb_check_ports()
2001 err = -EBUSY; in tegra_xusb_check_ports()
2003 spin_unlock_irqrestore(&xhci->lock, flags); in tegra_xusb_check_ports()
2010 const struct tegra_xusb_context_soc *soc = tegra->soc->context; in tegra_xusb_save_context()
2011 struct tegra_xusb_context *ctx = &tegra->context; in tegra_xusb_save_context()
2014 if (soc->ipfs.num_offsets > 0) { in tegra_xusb_save_context()
2015 for (i = 0; i < soc->ipfs.num_offsets; i++) in tegra_xusb_save_context()
2016 ctx->ipfs[i] = ipfs_readl(tegra, soc->ipfs.offsets[i]); in tegra_xusb_save_context()
2019 if (soc->fpci.num_offsets > 0) { in tegra_xusb_save_context()
2020 for (i = 0; i < soc->fpci.num_offsets; i++) in tegra_xusb_save_context()
2021 ctx->fpci[i] = fpci_readl(tegra, soc->fpci.offsets[i]); in tegra_xusb_save_context()
2027 const struct tegra_xusb_context_soc *soc = tegra->soc->context; in tegra_xusb_restore_context()
2028 struct tegra_xusb_context *ctx = &tegra->context; in tegra_xusb_restore_context()
2031 if (soc->fpci.num_offsets > 0) { in tegra_xusb_restore_context()
2032 for (i = 0; i < soc->fpci.num_offsets; i++) in tegra_xusb_restore_context()
2033 fpci_writel(tegra, ctx->fpci[i], soc->fpci.offsets[i]); in tegra_xusb_restore_context()
2036 if (soc->ipfs.num_offsets > 0) { in tegra_xusb_restore_context()
2037 for (i = 0; i < soc->ipfs.num_offsets; i++) in tegra_xusb_restore_context()
2038 ipfs_writel(tegra, ctx->ipfs[i], soc->ipfs.offsets[i]); in tegra_xusb_restore_context()
2061 struct tegra_xusb_padctl *padctl = tegra->padctl; in tegra_xhci_enable_phy_sleepwalk_wake()
2062 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xhci_enable_phy_sleepwalk_wake()
2070 for (i = 0, k = 0; i < tegra->soc->num_types; i++) { in tegra_xhci_enable_phy_sleepwalk_wake()
2071 if (strcmp(tegra->soc->phy_types[i].name, "usb3") == 0) in tegra_xhci_enable_phy_sleepwalk_wake()
2072 rhub = &xhci->usb3_rhub; in tegra_xhci_enable_phy_sleepwalk_wake()
2074 rhub = &xhci->usb2_rhub; in tegra_xhci_enable_phy_sleepwalk_wake()
2076 if (strcmp(tegra->soc->phy_types[i].name, "hsic") == 0) in tegra_xhci_enable_phy_sleepwalk_wake()
2077 offset = tegra->soc->ports.usb2.count; in tegra_xhci_enable_phy_sleepwalk_wake()
2081 for (j = 0; j < tegra->soc->phy_types[i].num; j++) { in tegra_xhci_enable_phy_sleepwalk_wake()
2082 phy = tegra->phys[k++]; in tegra_xhci_enable_phy_sleepwalk_wake()
2089 if (index >= rhub->num_ports) in tegra_xhci_enable_phy_sleepwalk_wake()
2095 portsc = readl(rhub->ports[index]->addr); in tegra_xhci_enable_phy_sleepwalk_wake()
2105 struct tegra_xusb_padctl *padctl = tegra->padctl; in tegra_xhci_disable_phy_wake()
2108 for (i = 0; i < tegra->num_usb_phys; i++) { in tegra_xhci_disable_phy_wake()
2118 for (i = 0; i < tegra->num_phys; i++) { in tegra_xhci_disable_phy_wake()
2119 if (!tegra->phys[i]) in tegra_xhci_disable_phy_wake()
2122 if (tegra_xusb_padctl_remote_wake_detected(padctl, tegra->phys[i])) in tegra_xhci_disable_phy_wake()
2123 dev_dbg(tegra->dev, "%pOF remote wake detected\n", in tegra_xhci_disable_phy_wake()
2124 tegra->phys[i]->dev.of_node); in tegra_xhci_disable_phy_wake()
2126 tegra_xusb_padctl_disable_phy_wake(padctl, tegra->phys[i]); in tegra_xhci_disable_phy_wake()
2132 struct tegra_xusb_padctl *padctl = tegra->padctl; in tegra_xhci_disable_phy_sleepwalk()
2135 for (i = 0; i < tegra->num_phys; i++) { in tegra_xhci_disable_phy_sleepwalk()
2136 if (!tegra->phys[i]) in tegra_xhci_disable_phy_sleepwalk()
2139 tegra_xusb_padctl_disable_phy_sleepwalk(padctl, tegra->phys[i]); in tegra_xhci_disable_phy_sleepwalk()
2148 for (i = 0; i < tegra->soc->num_types; i++) { in tegra_xhci_program_utmi_power_lp0_exit()
2149 if (strcmp(tegra->soc->phy_types[i].name, "usb2") == 0) in tegra_xhci_program_utmi_power_lp0_exit()
2153 for (i = 0; i < tegra->num_usb_phys; i++) { in tegra_xhci_program_utmi_power_lp0_exit()
2158 if (tegra->lp0_utmi_pad_mask & BIT(i)) in tegra_xhci_program_utmi_power_lp0_exit()
2167 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xusb_enter_elpg()
2168 struct device *dev = tegra->dev; in tegra_xusb_enter_elpg()
2177 usbcmd = readl(&xhci->op_regs->command); in tegra_xusb_enter_elpg()
2179 writel(usbcmd, &xhci->op_regs->command); in tegra_xusb_enter_elpg()
2183 dev_err(tegra->dev, "not all ports suspended: %d\n", err); in tegra_xusb_enter_elpg()
2187 for (i = 0; i < xhci->usb2_rhub.num_ports; i++) { in tegra_xusb_enter_elpg()
2188 if (!xhci->usb2_rhub.ports[i]) in tegra_xusb_enter_elpg()
2190 portsc = readl(xhci->usb2_rhub.ports[i]->addr); in tegra_xusb_enter_elpg()
2191 tegra->lp0_utmi_pad_mask &= ~BIT(i); in tegra_xusb_enter_elpg()
2193 tegra->lp0_utmi_pad_mask |= BIT(i); in tegra_xusb_enter_elpg()
2198 dev_err(tegra->dev, "failed to suspend XHCI: %d\n", err); in tegra_xusb_enter_elpg()
2209 for (i = 0; i < tegra->num_phys; i++) { in tegra_xusb_enter_elpg()
2210 if (!tegra->phys[i]) in tegra_xusb_enter_elpg()
2213 phy_power_off(tegra->phys[i]); in tegra_xusb_enter_elpg()
2215 phy_exit(tegra->phys[i]); in tegra_xusb_enter_elpg()
2222 dev_dbg(tegra->dev, "entering ELPG done\n"); in tegra_xusb_enter_elpg()
2224 usbcmd = readl(&xhci->op_regs->command); in tegra_xusb_enter_elpg()
2226 writel(usbcmd, &xhci->op_regs->command); in tegra_xusb_enter_elpg()
2228 dev_dbg(tegra->dev, "entering ELPG failed\n"); in tegra_xusb_enter_elpg()
2229 pm_runtime_mark_last_busy(tegra->dev); in tegra_xusb_enter_elpg()
2237 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xusb_exit_elpg()
2238 struct device *dev = tegra->dev; in tegra_xusb_exit_elpg()
2245 pm_runtime_mark_last_busy(tegra->dev); in tegra_xusb_exit_elpg()
2249 dev_err(tegra->dev, "failed to enable clocks: %d\n", err); in tegra_xusb_exit_elpg()
2260 for (i = 0; i < tegra->num_phys; i++) { in tegra_xusb_exit_elpg()
2261 if (!tegra->phys[i]) in tegra_xusb_exit_elpg()
2265 phy_init(tegra->phys[i]); in tegra_xusb_exit_elpg()
2267 phy_power_on(tegra->phys[i]); in tegra_xusb_exit_elpg()
2269 if (tegra->suspended) in tegra_xusb_exit_elpg()
2277 dev_err(tegra->dev, "failed to load firmware: %d\n", err); in tegra_xusb_exit_elpg()
2283 dev_err(tegra->dev, "failed to enable messages: %d\n", err); in tegra_xusb_exit_elpg()
2292 dev_err(tegra->dev, "failed to resume XHCI: %d\n", err); in tegra_xusb_exit_elpg()
2296 usbcmd = readl(&xhci->op_regs->command); in tegra_xusb_exit_elpg()
2298 writel(usbcmd, &xhci->op_regs->command); in tegra_xusb_exit_elpg()
2303 for (i = 0; i < tegra->num_phys; i++) { in tegra_xusb_exit_elpg()
2304 if (!tegra->phys[i]) in tegra_xusb_exit_elpg()
2307 phy_power_off(tegra->phys[i]); in tegra_xusb_exit_elpg()
2309 phy_exit(tegra->phys[i]); in tegra_xusb_exit_elpg()
2328 synchronize_irq(tegra->mbox_irq); in tegra_xusb_suspend()
2330 mutex_lock(&tegra->lock); in tegra_xusb_suspend()
2351 tegra->suspended = true; in tegra_xusb_suspend()
2355 if (enable_irq_wake(tegra->padctl_irq)) in tegra_xusb_suspend()
2360 mutex_unlock(&tegra->lock); in tegra_xusb_suspend()
2370 mutex_lock(&tegra->lock); in tegra_xusb_resume()
2372 if (!tegra->suspended) { in tegra_xusb_resume()
2373 mutex_unlock(&tegra->lock); in tegra_xusb_resume()
2379 mutex_unlock(&tegra->lock); in tegra_xusb_resume()
2384 if (disable_irq_wake(tegra->padctl_irq)) in tegra_xusb_resume()
2387 tegra->suspended = false; in tegra_xusb_resume()
2388 mutex_unlock(&tegra->lock); in tegra_xusb_resume()
2401 synchronize_irq(tegra->mbox_irq); in tegra_xusb_runtime_suspend()
2402 mutex_lock(&tegra->lock); in tegra_xusb_runtime_suspend()
2404 mutex_unlock(&tegra->lock); in tegra_xusb_runtime_suspend()
2414 mutex_lock(&tegra->lock); in tegra_xusb_runtime_resume()
2416 mutex_unlock(&tegra->lock); in tegra_xusb_runtime_resume()
2428 "avddio-pex",
2429 "dvddio-pex",
2430 "avdd-usb",
2431 "hvdd-usb-ss",
2435 { .name = "usb3", .num = 2, },
2436 { .name = "usb2", .num = 3, },
2437 { .name = "hsic", .num = 2, },
2510 "dvddio-pex",
2511 "hvddio-pex",
2512 "avdd-usb",
2516 { .name = "usb3", .num = 4, },
2517 { .name = "usb2", .num = 4, },
2518 { .name = "hsic", .num = 1, },
2552 { .name = "usb3", .num = 3, },
2553 { .name = "usb2", .num = 3, },
2554 { .name = "hsic", .num = 1, },
2594 { .name = "usb3", .num = 4, },
2595 { .name = "usb2", .num = 4, },
2657 { .compatible = "nvidia,tegra124-xusb", .data = &tegra124_soc },
2658 { .compatible = "nvidia,tegra210-xusb", .data = &tegra210_soc },
2659 { .compatible = "nvidia,tegra186-xusb", .data = &tegra186_soc },
2660 { .compatible = "nvidia,tegra194-xusb", .data = &tegra194_soc },
2661 { .compatible = "nvidia,tegra234-xusb", .data = &tegra234_soc },
2671 .name = "tegra-xusb",
2681 if (tegra && tegra->soc->lpm_support) in tegra_xhci_quirks()
2682 xhci->quirks |= XHCI_LPM_SUPPORT; in tegra_xhci_quirks()
2693 struct tegra_xusb *tegra = dev_get_drvdata(hcd->self.controller); in tegra_xhci_hub_control()
2697 int port = (index & 0xff) - 1; in tegra_xhci_hub_control()
2704 rhub = &xhci->usb2_rhub; in tegra_xhci_hub_control()
2705 bus_state = &rhub->bus_state; in tegra_xhci_hub_control()
2706 if (bus_state->resuming_ports && hcd->speed == HCD_USB2) { in tegra_xhci_hub_control()
2707 ports = rhub->ports; in tegra_xhci_hub_control()
2708 i = rhub->num_ports; in tegra_xhci_hub_control()
2709 while (i--) { in tegra_xhci_hub_control()
2710 if (!test_bit(i, &bus_state->resuming_ports)) in tegra_xhci_hub_control()
2712 portsc = readl(ports[i]->addr); in tegra_xhci_hub_control()
2719 if (hcd->speed == HCD_USB2) { in tegra_xhci_hub_control()
2722 if (!index || index > rhub->num_ports) in tegra_xhci_hub_control()
2723 return -EPIPE; in tegra_xhci_hub_control()
2727 if (!index || index > rhub->num_ports) in tegra_xhci_hub_control()
2728 return -EPIPE; in tegra_xhci_hub_control()
2729 ports = rhub->ports; in tegra_xhci_hub_control()
2730 portsc = readl(ports[port]->addr); in tegra_xhci_hub_control()
2740 if (hcd->speed == HCD_USB2) { in tegra_xhci_hub_control()
2744 if (!((hcd->self.otg_port == (port + 1)) && hcd->self.b_hnp_enable)) in tegra_xhci_hub_control()
2748 ports = rhub->ports; in tegra_xhci_hub_control()
2749 portsc = readl(ports[port]->addr); in tegra_xhci_hub_control()
2754 if (!((hcd->self.otg_port == (port + 1)) && hcd->self.b_hnp_enable)) in tegra_xhci_hub_control()
2785 MODULE_DESCRIPTION("NVIDIA Tegra XUSB xHCI host-controller driver");