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", &timestamp); 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 pm_runtime_get_sync(tegra->dev); in tegra_xhci_id_work()
1368 if (tegra->host_mode) { in tegra_xhci_id_work()
1370 if (tegra->otg_usb3_port >= 0) { in tegra_xhci_id_work()
1371 if (tegra->soc->otg_reset_sspi) { in tegra_xhci_id_work()
1374 xhci->shared_hcd, GetPortStatus, in tegra_xhci_id_work()
1375 0, tegra->otg_usb3_port+1, in tegra_xhci_id_work()
1383 msg.data = tegra->otg_usb3_port+1; in tegra_xhci_id_work()
1387 dev_info(tegra->dev, in tegra_xhci_id_work()
1397 pm_runtime_mark_last_busy(tegra->dev); in tegra_xhci_id_work()
1400 if (tegra->otg_usb3_port >= 0) in tegra_xhci_id_work()
1405 pm_runtime_put_autosuspend(tegra->dev); in tegra_xhci_id_work()
1411 return (tegra->usbphy[index] != NULL); in is_usb2_otg_phy()
1416 struct tegra_xusb_padctl *padctl = tegra->padctl; in is_usb3_otg_phy()
1420 for (i = 0; i < tegra->num_usb_phys; i++) { in is_usb3_otg_phy()
1433 if (strcmp(tegra->soc->phy_types[phy_type].name, "hsic") == 0) in is_host_mode_phy()
1436 if (strcmp(tegra->soc->phy_types[phy_type].name, "usb2") == 0) { in is_host_mode_phy()
1438 return ((index == tegra->otg_usb2_port) && tegra->host_mode); in is_host_mode_phy()
1443 if (strcmp(tegra->soc->phy_types[phy_type].name, "usb3") == 0) { in is_host_mode_phy()
1445 return ((index == tegra->otg_usb3_port) && tegra->host_mode); in is_host_mode_phy()
1459 for (i = 0; i < tegra->num_usb_phys; i++) { in tegra_xusb_get_usb2_port()
1460 if (tegra->usbphy[i] && usbphy == tegra->usbphy[i]) in tegra_xusb_get_usb2_port()
1464 return -1; in tegra_xusb_get_usb2_port()
1474 dev_dbg(tegra->dev, "%s(): action is %d", __func__, usbphy->last_event); in tegra_xhci_id_notify()
1476 if ((tegra->host_mode && usbphy->last_event == USB_EVENT_ID) || in tegra_xhci_id_notify()
1477 (!tegra->host_mode && usbphy->last_event != USB_EVENT_ID)) { in tegra_xhci_id_notify()
1478 dev_dbg(tegra->dev, "Same role(%d) received. Ignore", in tegra_xhci_id_notify()
1479 tegra->host_mode); in tegra_xhci_id_notify()
1483 tegra->otg_usb2_port = tegra_xusb_get_usb2_port(tegra, usbphy); in tegra_xhci_id_notify()
1485 tegra->host_mode = (usbphy->last_event == USB_EVENT_ID) ? true : false; in tegra_xhci_id_notify()
1487 schedule_work(&tegra->id_work); in tegra_xhci_id_notify()
1496 tegra->usbphy = devm_kcalloc(tegra->dev, tegra->num_usb_phys, in tegra_xusb_init_usb_phy()
1497 sizeof(*tegra->usbphy), GFP_KERNEL); in tegra_xusb_init_usb_phy()
1498 if (!tegra->usbphy) in tegra_xusb_init_usb_phy()
1499 return -ENOMEM; in tegra_xusb_init_usb_phy()
1501 INIT_WORK(&tegra->id_work, tegra_xhci_id_work); in tegra_xusb_init_usb_phy()
1502 tegra->id_nb.notifier_call = tegra_xhci_id_notify; in tegra_xusb_init_usb_phy()
1503 tegra->otg_usb2_port = -EINVAL; in tegra_xusb_init_usb_phy()
1504 tegra->otg_usb3_port = -EINVAL; in tegra_xusb_init_usb_phy()
1506 for (i = 0; i < tegra->num_usb_phys; i++) { in tegra_xusb_init_usb_phy()
1512 tegra->usbphy[i] = devm_usb_get_phy_by_node(tegra->dev, in tegra_xusb_init_usb_phy()
1513 phy->dev.of_node, in tegra_xusb_init_usb_phy()
1514 &tegra->id_nb); in tegra_xusb_init_usb_phy()
1515 if (!IS_ERR(tegra->usbphy[i])) { in tegra_xusb_init_usb_phy()
1516 dev_dbg(tegra->dev, "usbphy-%d registered", i); in tegra_xusb_init_usb_phy()
1517 otg_set_host(tegra->usbphy[i]->otg, &tegra->hcd->self); in tegra_xusb_init_usb_phy()
1520 * usb-phy is optional, continue if its not available. in tegra_xusb_init_usb_phy()
1522 tegra->usbphy[i] = NULL; in tegra_xusb_init_usb_phy()
1533 cancel_work_sync(&tegra->id_work); in tegra_xusb_deinit_usb_phy()
1535 for (i = 0; i < tegra->num_usb_phys; i++) in tegra_xusb_deinit_usb_phy()
1536 if (tegra->usbphy[i]) in tegra_xusb_deinit_usb_phy()
1537 otg_set_host(tegra->usbphy[i]->otg, NULL); in tegra_xusb_deinit_usb_phy()
1552 tegra = devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL); in tegra_xusb_probe()
1554 return -ENOMEM; in tegra_xusb_probe()
1556 tegra->soc = of_device_get_match_data(&pdev->dev); in tegra_xusb_probe()
1557 mutex_init(&tegra->lock); in tegra_xusb_probe()
1558 tegra->dev = &pdev->dev; in tegra_xusb_probe()
1564 tegra->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &regs); in tegra_xusb_probe()
1565 if (IS_ERR(tegra->regs)) in tegra_xusb_probe()
1566 return PTR_ERR(tegra->regs); in tegra_xusb_probe()
1568 tegra->fpci_base = devm_platform_ioremap_resource(pdev, 1); in tegra_xusb_probe()
1569 if (IS_ERR(tegra->fpci_base)) in tegra_xusb_probe()
1570 return PTR_ERR(tegra->fpci_base); in tegra_xusb_probe()
1572 if (tegra->soc->has_ipfs) { in tegra_xusb_probe()
1573 tegra->ipfs_base = devm_platform_ioremap_resource(pdev, 2); in tegra_xusb_probe()
1574 if (IS_ERR(tegra->ipfs_base)) in tegra_xusb_probe()
1575 return PTR_ERR(tegra->ipfs_base); in tegra_xusb_probe()
1576 } else if (tegra->soc->has_bar2) { in tegra_xusb_probe()
1577 tegra->bar2_base = devm_platform_get_and_ioremap_resource(pdev, 2, &tegra->bar2); in tegra_xusb_probe()
1578 if (IS_ERR(tegra->bar2_base)) in tegra_xusb_probe()
1579 return PTR_ERR(tegra->bar2_base); in tegra_xusb_probe()
1582 tegra->xhci_irq = platform_get_irq(pdev, 0); in tegra_xusb_probe()
1583 if (tegra->xhci_irq < 0) in tegra_xusb_probe()
1584 return tegra->xhci_irq; in tegra_xusb_probe()
1586 tegra->mbox_irq = platform_get_irq(pdev, 1); in tegra_xusb_probe()
1587 if (tegra->mbox_irq < 0) in tegra_xusb_probe()
1588 return tegra->mbox_irq; in tegra_xusb_probe()
1590 tegra->padctl = tegra_xusb_padctl_get(&pdev->dev); in tegra_xusb_probe()
1591 if (IS_ERR(tegra->padctl)) in tegra_xusb_probe()
1592 return PTR_ERR(tegra->padctl); in tegra_xusb_probe()
1594 np = of_parse_phandle(pdev->dev.of_node, "nvidia,xusb-padctl", 0); in tegra_xusb_probe()
1596 err = -ENODEV; in tegra_xusb_probe()
1600 tegra->padctl_irq = of_irq_get(np, 0); in tegra_xusb_probe()
1601 if (tegra->padctl_irq == -EPROBE_DEFER) { in tegra_xusb_probe()
1602 err = tegra->padctl_irq; in tegra_xusb_probe()
1604 } else if (tegra->padctl_irq <= 0) { in tegra_xusb_probe()
1605 /* Older device-trees don't have padctrl interrupt */ in tegra_xusb_probe()
1606 tegra->padctl_irq = 0; in tegra_xusb_probe()
1607 dev_dbg(&pdev->dev, in tegra_xusb_probe()
1611 tegra->host_clk = devm_clk_get(&pdev->dev, "xusb_host"); in tegra_xusb_probe()
1612 if (IS_ERR(tegra->host_clk)) { in tegra_xusb_probe()
1613 err = PTR_ERR(tegra->host_clk); in tegra_xusb_probe()
1614 dev_err(&pdev->dev, "failed to get xusb_host: %d\n", err); in tegra_xusb_probe()
1618 tegra->falcon_clk = devm_clk_get(&pdev->dev, "xusb_falcon_src"); in tegra_xusb_probe()
1619 if (IS_ERR(tegra->falcon_clk)) { in tegra_xusb_probe()
1620 err = PTR_ERR(tegra->falcon_clk); in tegra_xusb_probe()
1621 dev_err(&pdev->dev, "failed to get xusb_falcon_src: %d\n", err); in tegra_xusb_probe()
1625 tegra->ss_clk = devm_clk_get(&pdev->dev, "xusb_ss"); in tegra_xusb_probe()
1626 if (IS_ERR(tegra->ss_clk)) { in tegra_xusb_probe()
1627 err = PTR_ERR(tegra->ss_clk); in tegra_xusb_probe()
1628 dev_err(&pdev->dev, "failed to get xusb_ss: %d\n", err); in tegra_xusb_probe()
1632 tegra->ss_src_clk = devm_clk_get(&pdev->dev, "xusb_ss_src"); in tegra_xusb_probe()
1633 if (IS_ERR(tegra->ss_src_clk)) { in tegra_xusb_probe()
1634 err = PTR_ERR(tegra->ss_src_clk); in tegra_xusb_probe()
1635 dev_err(&pdev->dev, "failed to get xusb_ss_src: %d\n", err); in tegra_xusb_probe()
1639 tegra->hs_src_clk = devm_clk_get(&pdev->dev, "xusb_hs_src"); in tegra_xusb_probe()
1640 if (IS_ERR(tegra->hs_src_clk)) { in tegra_xusb_probe()
1641 err = PTR_ERR(tegra->hs_src_clk); in tegra_xusb_probe()
1642 dev_err(&pdev->dev, "failed to get xusb_hs_src: %d\n", err); in tegra_xusb_probe()
1646 tegra->fs_src_clk = devm_clk_get(&pdev->dev, "xusb_fs_src"); in tegra_xusb_probe()
1647 if (IS_ERR(tegra->fs_src_clk)) { in tegra_xusb_probe()
1648 err = PTR_ERR(tegra->fs_src_clk); in tegra_xusb_probe()
1649 dev_err(&pdev->dev, "failed to get xusb_fs_src: %d\n", err); in tegra_xusb_probe()
1653 tegra->pll_u_480m = devm_clk_get(&pdev->dev, "pll_u_480m"); in tegra_xusb_probe()
1654 if (IS_ERR(tegra->pll_u_480m)) { in tegra_xusb_probe()
1655 err = PTR_ERR(tegra->pll_u_480m); in tegra_xusb_probe()
1656 dev_err(&pdev->dev, "failed to get pll_u_480m: %d\n", err); in tegra_xusb_probe()
1660 tegra->clk_m = devm_clk_get(&pdev->dev, "clk_m"); in tegra_xusb_probe()
1661 if (IS_ERR(tegra->clk_m)) { in tegra_xusb_probe()
1662 err = PTR_ERR(tegra->clk_m); in tegra_xusb_probe()
1663 dev_err(&pdev->dev, "failed to get clk_m: %d\n", err); in tegra_xusb_probe()
1667 tegra->pll_e = devm_clk_get(&pdev->dev, "pll_e"); in tegra_xusb_probe()
1668 if (IS_ERR(tegra->pll_e)) { in tegra_xusb_probe()
1669 err = PTR_ERR(tegra->pll_e); in tegra_xusb_probe()
1670 dev_err(&pdev->dev, "failed to get pll_e: %d\n", err); in tegra_xusb_probe()
1674 if (!of_property_present(pdev->dev.of_node, "power-domains")) { in tegra_xusb_probe()
1675 tegra->host_rst = devm_reset_control_get(&pdev->dev, in tegra_xusb_probe()
1677 if (IS_ERR(tegra->host_rst)) { in tegra_xusb_probe()
1678 err = PTR_ERR(tegra->host_rst); in tegra_xusb_probe()
1679 dev_err(&pdev->dev, in tegra_xusb_probe()
1684 tegra->ss_rst = devm_reset_control_get(&pdev->dev, "xusb_ss"); in tegra_xusb_probe()
1685 if (IS_ERR(tegra->ss_rst)) { in tegra_xusb_probe()
1686 err = PTR_ERR(tegra->ss_rst); in tegra_xusb_probe()
1687 dev_err(&pdev->dev, "failed to get xusb_ss reset: %d\n", in tegra_xusb_probe()
1692 err = tegra_xusb_powerdomain_init(&pdev->dev, tegra); in tegra_xusb_probe()
1697 tegra->supplies = devm_kcalloc(&pdev->dev, tegra->soc->num_supplies, in tegra_xusb_probe()
1698 sizeof(*tegra->supplies), GFP_KERNEL); in tegra_xusb_probe()
1699 if (!tegra->supplies) { in tegra_xusb_probe()
1700 err = -ENOMEM; in tegra_xusb_probe()
1704 regulator_bulk_set_supply_names(tegra->supplies, in tegra_xusb_probe()
1705 tegra->soc->supply_names, in tegra_xusb_probe()
1706 tegra->soc->num_supplies); in tegra_xusb_probe()
1708 err = devm_regulator_bulk_get(&pdev->dev, tegra->soc->num_supplies, in tegra_xusb_probe()
1709 tegra->supplies); in tegra_xusb_probe()
1711 dev_err(&pdev->dev, "failed to get regulators: %d\n", err); in tegra_xusb_probe()
1715 for (i = 0; i < tegra->soc->num_types; i++) { in tegra_xusb_probe()
1716 if (!strncmp(tegra->soc->phy_types[i].name, "usb2", 4)) in tegra_xusb_probe()
1717 tegra->num_usb_phys = tegra->soc->phy_types[i].num; in tegra_xusb_probe()
1718 tegra->num_phys += tegra->soc->phy_types[i].num; in tegra_xusb_probe()
1721 tegra->phys = devm_kcalloc(&pdev->dev, tegra->num_phys, in tegra_xusb_probe()
1722 sizeof(*tegra->phys), GFP_KERNEL); in tegra_xusb_probe()
1723 if (!tegra->phys) { in tegra_xusb_probe()
1724 err = -ENOMEM; in tegra_xusb_probe()
1728 for (i = 0, k = 0; i < tegra->soc->num_types; i++) { in tegra_xusb_probe()
1731 for (j = 0; j < tegra->soc->phy_types[i].num; j++) { in tegra_xusb_probe()
1732 snprintf(prop, sizeof(prop), "%s-%d", in tegra_xusb_probe()
1733 tegra->soc->phy_types[i].name, j); in tegra_xusb_probe()
1735 phy = devm_phy_optional_get(&pdev->dev, prop); in tegra_xusb_probe()
1737 dev_err(&pdev->dev, in tegra_xusb_probe()
1744 tegra->phys[k++] = phy; in tegra_xusb_probe()
1748 tegra->hcd = usb_create_hcd(&tegra_xhci_hc_driver, &pdev->dev, in tegra_xusb_probe()
1749 dev_name(&pdev->dev)); in tegra_xusb_probe()
1750 if (!tegra->hcd) { in tegra_xusb_probe()
1751 err = -ENOMEM; in tegra_xusb_probe()
1755 tegra->hcd->skip_phy_initialization = 1; in tegra_xusb_probe()
1756 tegra->hcd->regs = tegra->regs; in tegra_xusb_probe()
1757 tegra->hcd->rsrc_start = regs->start; in tegra_xusb_probe()
1758 tegra->hcd->rsrc_len = resource_size(regs); in tegra_xusb_probe()
1768 dev_err(tegra->dev, "failed to enable clocks: %d\n", err); in tegra_xusb_probe()
1772 err = regulator_bulk_enable(tegra->soc->num_supplies, tegra->supplies); in tegra_xusb_probe()
1774 dev_err(tegra->dev, "failed to enable regulators: %d\n", err); in tegra_xusb_probe()
1780 dev_err(&pdev->dev, "failed to enable PHYs: %d\n", err); in tegra_xusb_probe()
1785 * The XUSB Falcon microcontroller can only address 40 bits, so set in tegra_xusb_probe()
1788 err = dma_set_mask_and_coherent(tegra->dev, DMA_BIT_MASK(40)); in tegra_xusb_probe()
1790 dev_err(&pdev->dev, "failed to set DMA mask: %d\n", err); in tegra_xusb_probe()
1794 if (tegra->soc->firmware) { in tegra_xusb_probe()
1797 dev_err(&pdev->dev, in tegra_xusb_probe()
1811 dev_err(&pdev->dev, "failed to load firmware: %d\n", err); in tegra_xusb_probe()
1815 err = usb_add_hcd(tegra->hcd, tegra->xhci_irq, IRQF_SHARED); in tegra_xusb_probe()
1817 dev_err(&pdev->dev, "failed to add USB HCD: %d\n", err); in tegra_xusb_probe()
1821 device_wakeup_enable(tegra->hcd->self.controller); in tegra_xusb_probe()
1823 xhci = hcd_to_xhci(tegra->hcd); in tegra_xusb_probe()
1825 xhci->shared_hcd = usb_create_shared_hcd(&tegra_xhci_hc_driver, in tegra_xusb_probe()
1826 &pdev->dev, in tegra_xusb_probe()
1827 dev_name(&pdev->dev), in tegra_xusb_probe()
1828 tegra->hcd); in tegra_xusb_probe()
1829 if (!xhci->shared_hcd) { in tegra_xusb_probe()
1830 dev_err(&pdev->dev, "failed to create shared HCD\n"); in tegra_xusb_probe()
1831 err = -ENOMEM; in tegra_xusb_probe()
1835 if (HCC_MAX_PSA(xhci->hcc_params) >= 4) in tegra_xusb_probe()
1836 xhci->shared_hcd->can_do_streams = 1; in tegra_xusb_probe()
1838 err = usb_add_hcd(xhci->shared_hcd, tegra->xhci_irq, IRQF_SHARED); in tegra_xusb_probe()
1840 dev_err(&pdev->dev, "failed to add shared HCD: %d\n", err); in tegra_xusb_probe()
1844 err = devm_request_threaded_irq(&pdev->dev, tegra->mbox_irq, in tegra_xusb_probe()
1847 dev_name(&pdev->dev), tegra); in tegra_xusb_probe()
1849 dev_err(&pdev->dev, "failed to request IRQ: %d\n", err); in tegra_xusb_probe()
1853 if (tegra->padctl_irq) { in tegra_xusb_probe()
1854 err = devm_request_threaded_irq(&pdev->dev, tegra->padctl_irq, in tegra_xusb_probe()
1856 IRQF_ONESHOT, dev_name(&pdev->dev), in tegra_xusb_probe()
1859 dev_err(&pdev->dev, "failed to request padctl IRQ: %d\n", err); in tegra_xusb_probe()
1866 dev_err(&pdev->dev, "failed to enable messages: %d\n", err); in tegra_xusb_probe()
1872 dev_err(&pdev->dev, "failed to init USB PHY: %d\n", err); in tegra_xusb_probe()
1877 device_init_wakeup(&tegra->hcd->self.root_hub->dev, true); in tegra_xusb_probe()
1878 device_init_wakeup(&xhci->shared_hcd->self.root_hub->dev, true); in tegra_xusb_probe()
1880 pm_runtime_use_autosuspend(tegra->dev); in tegra_xusb_probe()
1881 pm_runtime_set_autosuspend_delay(tegra->dev, 2000); in tegra_xusb_probe()
1882 pm_runtime_mark_last_busy(tegra->dev); in tegra_xusb_probe()
1883 pm_runtime_set_active(tegra->dev); in tegra_xusb_probe()
1885 if (tegra->padctl_irq) { in tegra_xusb_probe()
1886 device_init_wakeup(tegra->dev, true); in tegra_xusb_probe()
1887 pm_runtime_enable(tegra->dev); in tegra_xusb_probe()
1893 usb_remove_hcd(xhci->shared_hcd); in tegra_xusb_probe()
1895 usb_put_hcd(xhci->shared_hcd); in tegra_xusb_probe()
1897 usb_remove_hcd(tegra->hcd); in tegra_xusb_probe()
1901 dma_free_coherent(&pdev->dev, tegra->fw.size, tegra->fw.virt, in tegra_xusb_probe()
1902 tegra->fw.phys); in tegra_xusb_probe()
1906 regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies); in tegra_xusb_probe()
1910 usb_put_hcd(tegra->hcd); in tegra_xusb_probe()
1912 tegra_xusb_powerdomain_remove(&pdev->dev, tegra); in tegra_xusb_probe()
1915 tegra_xusb_padctl_put(tegra->padctl); in tegra_xusb_probe()
1922 tegra_xusb_powerdomain_remove(tegra->dev, tegra); in tegra_xusb_disable()
1925 regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies); in tegra_xusb_disable()
1931 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xusb_remove()
1935 pm_runtime_get_sync(&pdev->dev); in tegra_xusb_remove()
1936 usb_remove_hcd(xhci->shared_hcd); in tegra_xusb_remove()
1937 usb_put_hcd(xhci->shared_hcd); in tegra_xusb_remove()
1938 xhci->shared_hcd = NULL; in tegra_xusb_remove()
1939 usb_remove_hcd(tegra->hcd); in tegra_xusb_remove()
1940 usb_put_hcd(tegra->hcd); in tegra_xusb_remove()
1942 dma_free_coherent(&pdev->dev, tegra->fw.size, tegra->fw.virt, in tegra_xusb_remove()
1943 tegra->fw.phys); in tegra_xusb_remove()
1945 if (tegra->padctl_irq) in tegra_xusb_remove()
1946 pm_runtime_disable(&pdev->dev); in tegra_xusb_remove()
1948 pm_runtime_put(&pdev->dev); in tegra_xusb_remove()
1951 tegra_xusb_padctl_put(tegra->padctl); in tegra_xusb_remove()
1958 pm_runtime_get_sync(&pdev->dev); in tegra_xusb_shutdown()
1959 disable_irq(tegra->xhci_irq); in tegra_xusb_shutdown()
1960 xhci_shutdown(tegra->hcd); in tegra_xusb_shutdown()
1966 struct device *dev = hub->hcd->self.controller; in xhci_hub_ports_suspended()
1971 for (i = 0; i < hub->num_ports; i++) { in xhci_hub_ports_suspended()
1972 value = readl(hub->ports[i]->addr); in xhci_hub_ports_suspended()
1977 dev_info(dev, "%u-%u isn't suspended: %#010x\n", in xhci_hub_ports_suspended()
1978 hub->hcd->self.busnum, i + 1, value); in xhci_hub_ports_suspended()
1988 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xusb_check_ports()
1989 struct xhci_bus_state *bus_state = &xhci->usb2_rhub.bus_state; in tegra_xusb_check_ports()
1993 if (bus_state->bus_suspended) { in tegra_xusb_check_ports()
2000 spin_lock_irqsave(&xhci->lock, flags); in tegra_xusb_check_ports()
2002 if (!xhci_hub_ports_suspended(&xhci->usb2_rhub) || in tegra_xusb_check_ports()
2003 !xhci_hub_ports_suspended(&xhci->usb3_rhub)) in tegra_xusb_check_ports()
2004 err = -EBUSY; in tegra_xusb_check_ports()
2006 spin_unlock_irqrestore(&xhci->lock, flags); in tegra_xusb_check_ports()
2013 const struct tegra_xusb_context_soc *soc = tegra->soc->context; in tegra_xusb_save_context()
2014 struct tegra_xusb_context *ctx = &tegra->context; in tegra_xusb_save_context()
2017 if (soc->ipfs.num_offsets > 0) { in tegra_xusb_save_context()
2018 for (i = 0; i < soc->ipfs.num_offsets; i++) in tegra_xusb_save_context()
2019 ctx->ipfs[i] = ipfs_readl(tegra, soc->ipfs.offsets[i]); in tegra_xusb_save_context()
2022 if (soc->fpci.num_offsets > 0) { in tegra_xusb_save_context()
2023 for (i = 0; i < soc->fpci.num_offsets; i++) in tegra_xusb_save_context()
2024 ctx->fpci[i] = fpci_readl(tegra, soc->fpci.offsets[i]); in tegra_xusb_save_context()
2030 const struct tegra_xusb_context_soc *soc = tegra->soc->context; in tegra_xusb_restore_context()
2031 struct tegra_xusb_context *ctx = &tegra->context; in tegra_xusb_restore_context()
2034 if (soc->fpci.num_offsets > 0) { in tegra_xusb_restore_context()
2035 for (i = 0; i < soc->fpci.num_offsets; i++) in tegra_xusb_restore_context()
2036 fpci_writel(tegra, ctx->fpci[i], soc->fpci.offsets[i]); in tegra_xusb_restore_context()
2039 if (soc->ipfs.num_offsets > 0) { in tegra_xusb_restore_context()
2040 for (i = 0; i < soc->ipfs.num_offsets; i++) in tegra_xusb_restore_context()
2041 ipfs_writel(tegra, ctx->ipfs[i], soc->ipfs.offsets[i]); in tegra_xusb_restore_context()
2064 struct tegra_xusb_padctl *padctl = tegra->padctl; in tegra_xhci_enable_phy_sleepwalk_wake()
2065 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xhci_enable_phy_sleepwalk_wake()
2073 for (i = 0, k = 0; i < tegra->soc->num_types; i++) { in tegra_xhci_enable_phy_sleepwalk_wake()
2074 if (strcmp(tegra->soc->phy_types[i].name, "usb3") == 0) in tegra_xhci_enable_phy_sleepwalk_wake()
2075 rhub = &xhci->usb3_rhub; in tegra_xhci_enable_phy_sleepwalk_wake()
2077 rhub = &xhci->usb2_rhub; in tegra_xhci_enable_phy_sleepwalk_wake()
2079 if (strcmp(tegra->soc->phy_types[i].name, "hsic") == 0) in tegra_xhci_enable_phy_sleepwalk_wake()
2080 offset = tegra->soc->ports.usb2.count; in tegra_xhci_enable_phy_sleepwalk_wake()
2084 for (j = 0; j < tegra->soc->phy_types[i].num; j++) { in tegra_xhci_enable_phy_sleepwalk_wake()
2085 phy = tegra->phys[k++]; in tegra_xhci_enable_phy_sleepwalk_wake()
2092 if (index >= rhub->num_ports) in tegra_xhci_enable_phy_sleepwalk_wake()
2098 portsc = readl(rhub->ports[index]->addr); in tegra_xhci_enable_phy_sleepwalk_wake()
2108 struct tegra_xusb_padctl *padctl = tegra->padctl; in tegra_xhci_disable_phy_wake()
2111 for (i = 0; i < tegra->num_usb_phys; i++) { in tegra_xhci_disable_phy_wake()
2121 for (i = 0; i < tegra->num_phys; i++) { in tegra_xhci_disable_phy_wake()
2122 if (!tegra->phys[i]) in tegra_xhci_disable_phy_wake()
2125 if (tegra_xusb_padctl_remote_wake_detected(padctl, tegra->phys[i])) in tegra_xhci_disable_phy_wake()
2126 dev_dbg(tegra->dev, "%pOF remote wake detected\n", in tegra_xhci_disable_phy_wake()
2127 tegra->phys[i]->dev.of_node); in tegra_xhci_disable_phy_wake()
2129 tegra_xusb_padctl_disable_phy_wake(padctl, tegra->phys[i]); in tegra_xhci_disable_phy_wake()
2135 struct tegra_xusb_padctl *padctl = tegra->padctl; in tegra_xhci_disable_phy_sleepwalk()
2138 for (i = 0; i < tegra->num_phys; i++) { in tegra_xhci_disable_phy_sleepwalk()
2139 if (!tegra->phys[i]) in tegra_xhci_disable_phy_sleepwalk()
2142 tegra_xusb_padctl_disable_phy_sleepwalk(padctl, tegra->phys[i]); in tegra_xhci_disable_phy_sleepwalk()
2151 for (i = 0; i < tegra->soc->num_types; i++) { in tegra_xhci_program_utmi_power_lp0_exit()
2152 if (strcmp(tegra->soc->phy_types[i].name, "usb2") == 0) in tegra_xhci_program_utmi_power_lp0_exit()
2156 for (i = 0; i < tegra->num_usb_phys; i++) { in tegra_xhci_program_utmi_power_lp0_exit()
2161 if (tegra->lp0_utmi_pad_mask & BIT(i)) in tegra_xhci_program_utmi_power_lp0_exit()
2170 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xusb_enter_elpg()
2171 struct device *dev = tegra->dev; in tegra_xusb_enter_elpg()
2180 usbcmd = readl(&xhci->op_regs->command); in tegra_xusb_enter_elpg()
2182 writel(usbcmd, &xhci->op_regs->command); in tegra_xusb_enter_elpg()
2186 dev_err(tegra->dev, "not all ports suspended: %d\n", err); in tegra_xusb_enter_elpg()
2190 for (i = 0; i < xhci->usb2_rhub.num_ports; i++) { in tegra_xusb_enter_elpg()
2191 if (!xhci->usb2_rhub.ports[i]) in tegra_xusb_enter_elpg()
2193 portsc = readl(xhci->usb2_rhub.ports[i]->addr); in tegra_xusb_enter_elpg()
2194 tegra->lp0_utmi_pad_mask &= ~BIT(i); in tegra_xusb_enter_elpg()
2196 tegra->lp0_utmi_pad_mask |= BIT(i); in tegra_xusb_enter_elpg()
2201 dev_err(tegra->dev, "failed to suspend XHCI: %d\n", err); in tegra_xusb_enter_elpg()
2212 for (i = 0; i < tegra->num_phys; i++) { in tegra_xusb_enter_elpg()
2213 if (!tegra->phys[i]) in tegra_xusb_enter_elpg()
2216 phy_power_off(tegra->phys[i]); in tegra_xusb_enter_elpg()
2218 phy_exit(tegra->phys[i]); in tegra_xusb_enter_elpg()
2225 dev_dbg(tegra->dev, "entering ELPG done\n"); in tegra_xusb_enter_elpg()
2227 usbcmd = readl(&xhci->op_regs->command); in tegra_xusb_enter_elpg()
2229 writel(usbcmd, &xhci->op_regs->command); in tegra_xusb_enter_elpg()
2231 dev_dbg(tegra->dev, "entering ELPG failed\n"); in tegra_xusb_enter_elpg()
2232 pm_runtime_mark_last_busy(tegra->dev); in tegra_xusb_enter_elpg()
2240 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xusb_exit_elpg()
2241 struct device *dev = tegra->dev; in tegra_xusb_exit_elpg()
2248 pm_runtime_mark_last_busy(tegra->dev); in tegra_xusb_exit_elpg()
2252 dev_err(tegra->dev, "failed to enable clocks: %d\n", err); in tegra_xusb_exit_elpg()
2263 for (i = 0; i < tegra->num_phys; i++) { in tegra_xusb_exit_elpg()
2264 if (!tegra->phys[i]) in tegra_xusb_exit_elpg()
2268 phy_init(tegra->phys[i]); in tegra_xusb_exit_elpg()
2270 phy_power_on(tegra->phys[i]); in tegra_xusb_exit_elpg()
2272 if (tegra->suspended) in tegra_xusb_exit_elpg()
2280 dev_err(tegra->dev, "failed to load firmware: %d\n", err); in tegra_xusb_exit_elpg()
2286 dev_err(tegra->dev, "failed to enable messages: %d\n", err); in tegra_xusb_exit_elpg()
2295 dev_err(tegra->dev, "failed to resume XHCI: %d\n", err); in tegra_xusb_exit_elpg()
2299 usbcmd = readl(&xhci->op_regs->command); in tegra_xusb_exit_elpg()
2301 writel(usbcmd, &xhci->op_regs->command); in tegra_xusb_exit_elpg()
2306 for (i = 0; i < tegra->num_phys; i++) { in tegra_xusb_exit_elpg()
2307 if (!tegra->phys[i]) in tegra_xusb_exit_elpg()
2310 phy_power_off(tegra->phys[i]); in tegra_xusb_exit_elpg()
2312 phy_exit(tegra->phys[i]); in tegra_xusb_exit_elpg()
2331 synchronize_irq(tegra->mbox_irq); in tegra_xusb_suspend()
2333 mutex_lock(&tegra->lock); in tegra_xusb_suspend()
2354 tegra->suspended = true; in tegra_xusb_suspend()
2358 if (enable_irq_wake(tegra->padctl_irq)) in tegra_xusb_suspend()
2363 mutex_unlock(&tegra->lock); in tegra_xusb_suspend()
2373 mutex_lock(&tegra->lock); in tegra_xusb_resume()
2375 if (!tegra->suspended) { in tegra_xusb_resume()
2376 mutex_unlock(&tegra->lock); in tegra_xusb_resume()
2382 mutex_unlock(&tegra->lock); in tegra_xusb_resume()
2387 if (disable_irq_wake(tegra->padctl_irq)) in tegra_xusb_resume()
2390 tegra->suspended = false; in tegra_xusb_resume()
2391 mutex_unlock(&tegra->lock); in tegra_xusb_resume()
2404 synchronize_irq(tegra->mbox_irq); in tegra_xusb_runtime_suspend()
2405 mutex_lock(&tegra->lock); in tegra_xusb_runtime_suspend()
2407 mutex_unlock(&tegra->lock); in tegra_xusb_runtime_suspend()
2417 mutex_lock(&tegra->lock); in tegra_xusb_runtime_resume()
2419 mutex_unlock(&tegra->lock); in tegra_xusb_runtime_resume()
2431 "avddio-pex",
2432 "dvddio-pex",
2433 "avdd-usb",
2434 "hvdd-usb-ss",
2438 { .name = "usb3", .num = 2, },
2439 { .name = "usb2", .num = 3, },
2440 { .name = "hsic", .num = 2, },
2513 "dvddio-pex",
2514 "hvddio-pex",
2515 "avdd-usb",
2519 { .name = "usb3", .num = 4, },
2520 { .name = "usb2", .num = 4, },
2521 { .name = "hsic", .num = 1, },
2555 { .name = "usb3", .num = 3, },
2556 { .name = "usb2", .num = 3, },
2557 { .name = "hsic", .num = 1, },
2597 { .name = "usb3", .num = 4, },
2598 { .name = "usb2", .num = 4, },
2660 { .compatible = "nvidia,tegra124-xusb", .data = &tegra124_soc },
2661 { .compatible = "nvidia,tegra210-xusb", .data = &tegra210_soc },
2662 { .compatible = "nvidia,tegra186-xusb", .data = &tegra186_soc },
2663 { .compatible = "nvidia,tegra194-xusb", .data = &tegra194_soc },
2664 { .compatible = "nvidia,tegra234-xusb", .data = &tegra234_soc },
2674 .name = "tegra-xusb",
2684 if (tegra && tegra->soc->lpm_support) in tegra_xhci_quirks()
2685 xhci->quirks |= XHCI_LPM_SUPPORT; in tegra_xhci_quirks()
2696 struct tegra_xusb *tegra = dev_get_drvdata(hcd->self.controller); in tegra_xhci_hub_control()
2700 int port = (index & 0xff) - 1; in tegra_xhci_hub_control()
2707 rhub = &xhci->usb2_rhub; in tegra_xhci_hub_control()
2708 bus_state = &rhub->bus_state; in tegra_xhci_hub_control()
2709 if (bus_state->resuming_ports && hcd->speed == HCD_USB2) { in tegra_xhci_hub_control()
2710 ports = rhub->ports; in tegra_xhci_hub_control()
2711 i = rhub->num_ports; in tegra_xhci_hub_control()
2712 while (i--) { in tegra_xhci_hub_control()
2713 if (!test_bit(i, &bus_state->resuming_ports)) in tegra_xhci_hub_control()
2715 portsc = readl(ports[i]->addr); in tegra_xhci_hub_control()
2722 if (hcd->speed == HCD_USB2) { in tegra_xhci_hub_control()
2725 if (!index || index > rhub->num_ports) in tegra_xhci_hub_control()
2726 return -EPIPE; in tegra_xhci_hub_control()
2730 if (!index || index > rhub->num_ports) in tegra_xhci_hub_control()
2731 return -EPIPE; in tegra_xhci_hub_control()
2732 ports = rhub->ports; in tegra_xhci_hub_control()
2733 portsc = readl(ports[port]->addr); in tegra_xhci_hub_control()
2743 if (hcd->speed == HCD_USB2) { in tegra_xhci_hub_control()
2747 if (!((hcd->self.otg_port == (port + 1)) && hcd->self.b_hnp_enable)) in tegra_xhci_hub_control()
2751 ports = rhub->ports; in tegra_xhci_hub_control()
2752 portsc = readl(ports[port]->addr); in tegra_xhci_hub_control()
2757 if (!((hcd->self.otg_port == (port + 1)) && hcd->self.b_hnp_enable)) in tegra_xhci_hub_control()
2788 MODULE_DESCRIPTION("NVIDIA Tegra XUSB xHCI host-controller driver");