Lines Matching full:tegra
3 * NVIDIA Tegra xHCI host controller driver
20 #include <linux/phy/tegra/xusb.h>
32 #include <soc/tegra/pmc.h>
281 static inline u32 fpci_readl(struct tegra_xusb *tegra, unsigned int offset) in fpci_readl() argument
283 return readl(tegra->fpci_base + offset); in fpci_readl()
286 static inline void fpci_writel(struct tegra_xusb *tegra, u32 value, in fpci_writel() argument
289 writel(value, tegra->fpci_base + offset); in fpci_writel()
292 static inline u32 ipfs_readl(struct tegra_xusb *tegra, unsigned int offset) in ipfs_readl() argument
294 return readl(tegra->ipfs_base + offset); in ipfs_readl()
297 static inline void ipfs_writel(struct tegra_xusb *tegra, u32 value, in ipfs_writel() argument
300 writel(value, tegra->ipfs_base + offset); in ipfs_writel()
303 static u32 csb_readl(struct tegra_xusb *tegra, unsigned int offset) in csb_readl() argument
308 fpci_writel(tegra, page, XUSB_CFG_ARU_C11_CSBRANGE); in csb_readl()
310 return fpci_readl(tegra, XUSB_CFG_CSB_BASE_ADDR + ofs); in csb_readl()
313 static void csb_writel(struct tegra_xusb *tegra, u32 value, in csb_writel() argument
319 fpci_writel(tegra, page, XUSB_CFG_ARU_C11_CSBRANGE); in csb_writel()
320 fpci_writel(tegra, value, XUSB_CFG_CSB_BASE_ADDR + ofs); in csb_writel()
323 static int tegra_xusb_set_ss_clk(struct tegra_xusb *tegra, in tegra_xusb_set_ss_clk() argument
327 struct clk *clk = tegra->ss_src_clk; in tegra_xusb_set_ss_clk()
341 new_parent_rate = clk_get_rate(tegra->pll_u_480m); in tegra_xusb_set_ss_clk()
348 err = clk_set_parent(clk, tegra->pll_u_480m); in tegra_xusb_set_ss_clk()
364 err = clk_set_parent(clk, tegra->clk_m); in tegra_xusb_set_ss_clk()
375 dev_err(tegra->dev, "Invalid SS rate: %lu Hz\n", rate); in tegra_xusb_set_ss_clk()
380 dev_err(tegra->dev, "SS clock doesn't match requested rate\n"); in tegra_xusb_set_ss_clk()
451 static int tegra_xusb_mbox_send(struct tegra_xusb *tegra, in tegra_xusb_mbox_send() argument
462 value = fpci_readl(tegra, tegra->soc->mbox.owner); in tegra_xusb_mbox_send()
464 dev_err(tegra->dev, "mailbox is busy\n"); in tegra_xusb_mbox_send()
468 fpci_writel(tegra, MBOX_OWNER_SW, tegra->soc->mbox.owner); in tegra_xusb_mbox_send()
470 value = fpci_readl(tegra, tegra->soc->mbox.owner); in tegra_xusb_mbox_send()
472 dev_err(tegra->dev, "failed to acquire mailbox\n"); in tegra_xusb_mbox_send()
480 fpci_writel(tegra, value, tegra->soc->mbox.data_in); in tegra_xusb_mbox_send()
482 value = fpci_readl(tegra, tegra->soc->mbox.cmd); in tegra_xusb_mbox_send()
484 fpci_writel(tegra, value, tegra->soc->mbox.cmd); in tegra_xusb_mbox_send()
490 value = fpci_readl(tegra, tegra->soc->mbox.owner); in tegra_xusb_mbox_send()
498 value = fpci_readl(tegra, tegra->soc->mbox.owner); in tegra_xusb_mbox_send()
509 struct tegra_xusb *tegra = data; in tegra_xusb_mbox_irq() local
513 value = fpci_readl(tegra, XUSB_CFG_ARU_SMI_INTR); in tegra_xusb_mbox_irq()
514 fpci_writel(tegra, value, XUSB_CFG_ARU_SMI_INTR); in tegra_xusb_mbox_irq()
517 dev_err(tegra->dev, "controller firmware hang\n"); in tegra_xusb_mbox_irq()
522 static void tegra_xusb_mbox_handle(struct tegra_xusb *tegra, in tegra_xusb_mbox_handle() argument
525 struct tegra_xusb_padctl *padctl = tegra->padctl; in tegra_xusb_mbox_handle()
526 const struct tegra_xusb_soc *soc = tegra->soc; in tegra_xusb_mbox_handle()
527 struct device *dev = tegra->dev; in tegra_xusb_mbox_handle()
539 rsp.data = clk_get_rate(tegra->falcon_clk) / 1000; in tegra_xusb_mbox_handle()
549 if (tegra->soc->scale_ss_clock) { in tegra_xusb_mbox_handle()
550 err = tegra_xusb_set_ss_clk(tegra, msg->data * 1000); in tegra_xusb_mbox_handle()
556 rsp.data = clk_get_rate(tegra->ss_src_clk) / 1000; in tegra_xusb_mbox_handle()
658 err = tegra_xusb_mbox_send(tegra, &rsp); in tegra_xusb_mbox_handle()
666 struct tegra_xusb *tegra = data; in tegra_xusb_mbox_thread() local
670 mutex_lock(&tegra->lock); in tegra_xusb_mbox_thread()
672 if (pm_runtime_suspended(tegra->dev) || tegra->suspended) in tegra_xusb_mbox_thread()
675 value = fpci_readl(tegra, tegra->soc->mbox.data_out); in tegra_xusb_mbox_thread()
678 value = fpci_readl(tegra, tegra->soc->mbox.cmd); in tegra_xusb_mbox_thread()
680 fpci_writel(tegra, value, tegra->soc->mbox.cmd); in tegra_xusb_mbox_thread()
684 fpci_writel(tegra, MBOX_OWNER_NONE, tegra->soc->mbox.owner); in tegra_xusb_mbox_thread()
686 tegra_xusb_mbox_handle(tegra, &msg); in tegra_xusb_mbox_thread()
689 mutex_unlock(&tegra->lock); in tegra_xusb_mbox_thread()
693 static void tegra_xusb_config(struct tegra_xusb *tegra) in tegra_xusb_config() argument
695 u32 regs = tegra->hcd->rsrc_start; in tegra_xusb_config()
698 if (tegra->soc->has_ipfs) { in tegra_xusb_config()
699 value = ipfs_readl(tegra, IPFS_XUSB_HOST_CONFIGURATION_0); in tegra_xusb_config()
701 ipfs_writel(tegra, value, IPFS_XUSB_HOST_CONFIGURATION_0); in tegra_xusb_config()
707 value = fpci_readl(tegra, XUSB_CFG_4); in tegra_xusb_config()
710 fpci_writel(tegra, value, XUSB_CFG_4); in tegra_xusb_config()
715 value = fpci_readl(tegra, XUSB_CFG_1); in tegra_xusb_config()
717 fpci_writel(tegra, value, XUSB_CFG_1); in tegra_xusb_config()
719 if (tegra->soc->has_ipfs) { in tegra_xusb_config()
721 value = ipfs_readl(tegra, IPFS_XUSB_HOST_INTR_MASK_0); in tegra_xusb_config()
723 ipfs_writel(tegra, value, IPFS_XUSB_HOST_INTR_MASK_0); in tegra_xusb_config()
726 ipfs_writel(tegra, 0x80, IPFS_XUSB_HOST_CLKGATE_HYSTERESIS_0); in tegra_xusb_config()
730 static int tegra_xusb_clk_enable(struct tegra_xusb *tegra) in tegra_xusb_clk_enable() argument
734 err = clk_prepare_enable(tegra->pll_e); in tegra_xusb_clk_enable()
738 err = clk_prepare_enable(tegra->host_clk); in tegra_xusb_clk_enable()
742 err = clk_prepare_enable(tegra->ss_clk); in tegra_xusb_clk_enable()
746 err = clk_prepare_enable(tegra->falcon_clk); in tegra_xusb_clk_enable()
750 err = clk_prepare_enable(tegra->fs_src_clk); in tegra_xusb_clk_enable()
754 err = clk_prepare_enable(tegra->hs_src_clk); in tegra_xusb_clk_enable()
758 if (tegra->soc->scale_ss_clock) { in tegra_xusb_clk_enable()
759 err = tegra_xusb_set_ss_clk(tegra, TEGRA_XHCI_SS_HIGH_SPEED); in tegra_xusb_clk_enable()
767 clk_disable_unprepare(tegra->hs_src_clk); in tegra_xusb_clk_enable()
769 clk_disable_unprepare(tegra->fs_src_clk); in tegra_xusb_clk_enable()
771 clk_disable_unprepare(tegra->falcon_clk); in tegra_xusb_clk_enable()
773 clk_disable_unprepare(tegra->ss_clk); in tegra_xusb_clk_enable()
775 clk_disable_unprepare(tegra->host_clk); in tegra_xusb_clk_enable()
777 clk_disable_unprepare(tegra->pll_e); in tegra_xusb_clk_enable()
781 static void tegra_xusb_clk_disable(struct tegra_xusb *tegra) in tegra_xusb_clk_disable() argument
783 clk_disable_unprepare(tegra->pll_e); in tegra_xusb_clk_disable()
784 clk_disable_unprepare(tegra->host_clk); in tegra_xusb_clk_disable()
785 clk_disable_unprepare(tegra->ss_clk); in tegra_xusb_clk_disable()
786 clk_disable_unprepare(tegra->falcon_clk); in tegra_xusb_clk_disable()
787 clk_disable_unprepare(tegra->fs_src_clk); in tegra_xusb_clk_disable()
788 clk_disable_unprepare(tegra->hs_src_clk); in tegra_xusb_clk_disable()
791 static int tegra_xusb_phy_enable(struct tegra_xusb *tegra) in tegra_xusb_phy_enable() argument
796 for (i = 0; i < tegra->num_phys; i++) { in tegra_xusb_phy_enable()
797 err = phy_init(tegra->phys[i]); in tegra_xusb_phy_enable()
801 err = phy_power_on(tegra->phys[i]); in tegra_xusb_phy_enable()
803 phy_exit(tegra->phys[i]); in tegra_xusb_phy_enable()
812 phy_power_off(tegra->phys[i]); in tegra_xusb_phy_enable()
813 phy_exit(tegra->phys[i]); in tegra_xusb_phy_enable()
819 static void tegra_xusb_phy_disable(struct tegra_xusb *tegra) in tegra_xusb_phy_disable() argument
823 for (i = 0; i < tegra->num_phys; i++) { in tegra_xusb_phy_disable()
824 phy_power_off(tegra->phys[i]); in tegra_xusb_phy_disable()
825 phy_exit(tegra->phys[i]); in tegra_xusb_phy_disable()
830 static int tegra_xusb_init_context(struct tegra_xusb *tegra) in tegra_xusb_init_context() argument
832 const struct tegra_xusb_context_soc *soc = tegra->soc->context; in tegra_xusb_init_context()
834 tegra->context.ipfs = devm_kcalloc(tegra->dev, soc->ipfs.num_offsets, in tegra_xusb_init_context()
836 if (!tegra->context.ipfs) in tegra_xusb_init_context()
839 tegra->context.fpci = devm_kcalloc(tegra->dev, soc->fpci.num_offsets, in tegra_xusb_init_context()
841 if (!tegra->context.fpci) in tegra_xusb_init_context()
847 static inline int tegra_xusb_init_context(struct tegra_xusb *tegra) in tegra_xusb_init_context() argument
853 static int tegra_xusb_request_firmware(struct tegra_xusb *tegra) in tegra_xusb_request_firmware() argument
859 err = request_firmware(&fw, tegra->soc->firmware, tegra->dev); in tegra_xusb_request_firmware()
861 dev_err(tegra->dev, "failed to request firmware: %d\n", err); in tegra_xusb_request_firmware()
867 tegra->fw.size = le32_to_cpu(header->fwimg_len); in tegra_xusb_request_firmware()
869 tegra->fw.virt = dma_alloc_coherent(tegra->dev, tegra->fw.size, in tegra_xusb_request_firmware()
870 &tegra->fw.phys, GFP_KERNEL); in tegra_xusb_request_firmware()
871 if (!tegra->fw.virt) { in tegra_xusb_request_firmware()
872 dev_err(tegra->dev, "failed to allocate memory for firmware\n"); in tegra_xusb_request_firmware()
877 header = (struct tegra_xusb_fw_header *)tegra->fw.virt; in tegra_xusb_request_firmware()
878 memcpy(tegra->fw.virt, fw->data, tegra->fw.size); in tegra_xusb_request_firmware()
884 static int tegra_xusb_load_firmware(struct tegra_xusb *tegra) in tegra_xusb_load_firmware() argument
887 struct xhci_cap_regs __iomem *cap = tegra->regs; in tegra_xusb_load_firmware()
889 struct device *dev = tegra->dev; in tegra_xusb_load_firmware()
897 header = (struct tegra_xusb_fw_header *)tegra->fw.virt; in tegra_xusb_load_firmware()
898 op = tegra->regs + HC_LENGTH(readl(&cap->hc_capbase)); in tegra_xusb_load_firmware()
900 if (csb_readl(tegra, XUSB_CSB_MP_ILOAD_BASE_LO) != 0) { in tegra_xusb_load_firmware()
902 csb_readl(tegra, XUSB_FALC_CPUCTL)); in tegra_xusb_load_firmware()
907 csb_writel(tegra, tegra->fw.size, XUSB_CSB_MP_ILOAD_ATTR); in tegra_xusb_load_firmware()
913 address = tegra->fw.phys + sizeof(*header); in tegra_xusb_load_firmware()
914 csb_writel(tegra, address >> 32, XUSB_CSB_MP_ILOAD_BASE_HI); in tegra_xusb_load_firmware()
915 csb_writel(tegra, address, XUSB_CSB_MP_ILOAD_BASE_LO); in tegra_xusb_load_firmware()
918 csb_writel(tegra, APMAP_BOOTPATH, XUSB_CSB_MP_APMAP); in tegra_xusb_load_firmware()
921 csb_writel(tegra, L2IMEMOP_INVALIDATE_ALL, XUSB_CSB_MP_L2IMEMOP_TRIG); in tegra_xusb_load_firmware()
937 csb_writel(tegra, value, XUSB_CSB_MP_L2IMEMOP_SIZE); in tegra_xusb_load_firmware()
940 csb_writel(tegra, L2IMEMOP_LOAD_LOCKED_RESULT, in tegra_xusb_load_firmware()
944 csb_writel(tegra, code_size_blocks, XUSB_FALC_IMFILLCTL); in tegra_xusb_load_firmware()
950 csb_writel(tegra, value, XUSB_FALC_IMFILLRNG1); in tegra_xusb_load_firmware()
952 csb_writel(tegra, 0, XUSB_FALC_DMACTL); in tegra_xusb_load_firmware()
955 #define tegra_csb_readl(offset) csb_readl(tegra, offset) in tegra_xusb_load_firmware()
965 csb_writel(tegra, le32_to_cpu(header->boot_codetag), in tegra_xusb_load_firmware()
969 csb_writel(tegra, CPUCTL_STARTCPU, XUSB_FALC_CPUCTL); in tegra_xusb_load_firmware()
983 value = csb_readl(tegra, XUSB_FALC_CPUCTL); in tegra_xusb_load_firmware()
996 struct tegra_xusb *tegra) in tegra_xusb_powerdomain_remove() argument
998 if (!tegra->use_genpd) in tegra_xusb_powerdomain_remove()
1001 if (!IS_ERR_OR_NULL(tegra->genpd_dev_ss)) in tegra_xusb_powerdomain_remove()
1002 dev_pm_domain_detach(tegra->genpd_dev_ss, true); in tegra_xusb_powerdomain_remove()
1003 if (!IS_ERR_OR_NULL(tegra->genpd_dev_host)) in tegra_xusb_powerdomain_remove()
1004 dev_pm_domain_detach(tegra->genpd_dev_host, true); in tegra_xusb_powerdomain_remove()
1008 struct tegra_xusb *tegra) in tegra_xusb_powerdomain_init() argument
1012 tegra->genpd_dev_host = dev_pm_domain_attach_by_name(dev, "xusb_host"); in tegra_xusb_powerdomain_init()
1013 if (IS_ERR(tegra->genpd_dev_host)) { in tegra_xusb_powerdomain_init()
1014 err = PTR_ERR(tegra->genpd_dev_host); in tegra_xusb_powerdomain_init()
1019 tegra->genpd_dev_ss = dev_pm_domain_attach_by_name(dev, "xusb_ss"); in tegra_xusb_powerdomain_init()
1020 if (IS_ERR(tegra->genpd_dev_ss)) { in tegra_xusb_powerdomain_init()
1021 err = PTR_ERR(tegra->genpd_dev_ss); in tegra_xusb_powerdomain_init()
1026 tegra->use_genpd = true; in tegra_xusb_powerdomain_init()
1031 static int tegra_xusb_unpowergate_partitions(struct tegra_xusb *tegra) in tegra_xusb_unpowergate_partitions() argument
1033 struct device *dev = tegra->dev; in tegra_xusb_unpowergate_partitions()
1036 if (tegra->use_genpd) { in tegra_xusb_unpowergate_partitions()
1037 rc = pm_runtime_get_sync(tegra->genpd_dev_ss); in tegra_xusb_unpowergate_partitions()
1043 rc = pm_runtime_get_sync(tegra->genpd_dev_host); in tegra_xusb_unpowergate_partitions()
1046 pm_runtime_put_sync(tegra->genpd_dev_ss); in tegra_xusb_unpowergate_partitions()
1051 tegra->ss_clk, in tegra_xusb_unpowergate_partitions()
1052 tegra->ss_rst); in tegra_xusb_unpowergate_partitions()
1059 tegra->host_clk, in tegra_xusb_unpowergate_partitions()
1060 tegra->host_rst); in tegra_xusb_unpowergate_partitions()
1071 static int tegra_xusb_powergate_partitions(struct tegra_xusb *tegra) in tegra_xusb_powergate_partitions() argument
1073 struct device *dev = tegra->dev; in tegra_xusb_powergate_partitions()
1076 if (tegra->use_genpd) { in tegra_xusb_powergate_partitions()
1077 rc = pm_runtime_put_sync(tegra->genpd_dev_host); in tegra_xusb_powergate_partitions()
1083 rc = pm_runtime_put_sync(tegra->genpd_dev_ss); in tegra_xusb_powergate_partitions()
1086 pm_runtime_get_sync(tegra->genpd_dev_host); in tegra_xusb_powergate_partitions()
1100 tegra->host_clk, in tegra_xusb_powergate_partitions()
1101 tegra->host_rst); in tegra_xusb_powergate_partitions()
1109 static int __tegra_xusb_enable_firmware_messages(struct tegra_xusb *tegra) in __tegra_xusb_enable_firmware_messages() argument
1118 err = tegra_xusb_mbox_send(tegra, &msg); in __tegra_xusb_enable_firmware_messages()
1120 dev_err(tegra->dev, "failed to enable messages: %d\n", err); in __tegra_xusb_enable_firmware_messages()
1127 struct tegra_xusb *tegra = data; in tegra_xusb_padctl_irq() local
1129 mutex_lock(&tegra->lock); in tegra_xusb_padctl_irq()
1131 if (tegra->suspended) { in tegra_xusb_padctl_irq()
1132 mutex_unlock(&tegra->lock); in tegra_xusb_padctl_irq()
1136 mutex_unlock(&tegra->lock); in tegra_xusb_padctl_irq()
1138 pm_runtime_resume(tegra->dev); in tegra_xusb_padctl_irq()
1143 static int tegra_xusb_enable_firmware_messages(struct tegra_xusb *tegra) in tegra_xusb_enable_firmware_messages() argument
1147 mutex_lock(&tegra->lock); in tegra_xusb_enable_firmware_messages()
1148 err = __tegra_xusb_enable_firmware_messages(tegra); in tegra_xusb_enable_firmware_messages()
1149 mutex_unlock(&tegra->lock); in tegra_xusb_enable_firmware_messages()
1154 static void tegra_xhci_set_port_power(struct tegra_xusb *tegra, bool main, in tegra_xhci_set_port_power() argument
1157 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xhci_set_port_power()
1161 u16 wIndex = main ? tegra->otg_usb2_port + 1 : tegra->otg_usb3_port + 1; in tegra_xhci_set_port_power()
1166 dev_dbg(tegra->dev, "%s():%s %s port power\n", __func__, in tegra_xhci_set_port_power()
1185 dev_info(tegra->dev, "failed to %s %s PP %d\n", in tegra_xhci_set_port_power()
1190 static struct phy *tegra_xusb_get_phy(struct tegra_xusb *tegra, char *name, in tegra_xusb_get_phy() argument
1195 for (i = 0; i < tegra->soc->num_types; i++) { in tegra_xusb_get_phy()
1196 if (!strncmp(tegra->soc->phy_types[i].name, name, in tegra_xusb_get_phy()
1198 return tegra->phys[phy_count+port]; in tegra_xusb_get_phy()
1200 phy_count += tegra->soc->phy_types[i].num; in tegra_xusb_get_phy()
1208 struct tegra_xusb *tegra = container_of(work, struct tegra_xusb, in tegra_xhci_id_work() local
1210 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xhci_id_work()
1212 struct phy *phy = tegra_xusb_get_phy(tegra, "usb2", in tegra_xhci_id_work()
1213 tegra->otg_usb2_port); in tegra_xhci_id_work()
1217 dev_dbg(tegra->dev, "host mode %s\n", tegra->host_mode ? "on" : "off"); in tegra_xhci_id_work()
1219 mutex_lock(&tegra->lock); in tegra_xhci_id_work()
1221 if (tegra->host_mode) in tegra_xhci_id_work()
1226 mutex_unlock(&tegra->lock); in tegra_xhci_id_work()
1228 if (tegra->host_mode) { in tegra_xhci_id_work()
1230 if (tegra->otg_usb3_port >= 0) { in tegra_xhci_id_work()
1231 if (tegra->soc->otg_reset_sspi) { in tegra_xhci_id_work()
1235 0, tegra->otg_usb3_port+1, in tegra_xhci_id_work()
1238 tegra_xhci_set_port_power(tegra, false, in tegra_xhci_id_work()
1243 msg.data = tegra->otg_usb3_port+1; in tegra_xhci_id_work()
1245 ret = tegra_xusb_mbox_send(tegra, &msg); in tegra_xhci_id_work()
1247 dev_info(tegra->dev, in tegra_xhci_id_work()
1253 tegra_xhci_set_port_power(tegra, false, true); in tegra_xhci_id_work()
1256 tegra_xhci_set_port_power(tegra, true, true); in tegra_xhci_id_work()
1259 if (tegra->otg_usb3_port >= 0) in tegra_xhci_id_work()
1260 tegra_xhci_set_port_power(tegra, false, false); in tegra_xhci_id_work()
1262 tegra_xhci_set_port_power(tegra, true, false); in tegra_xhci_id_work()
1267 static bool is_usb2_otg_phy(struct tegra_xusb *tegra, unsigned int index) in is_usb2_otg_phy() argument
1269 return (tegra->usbphy[index] != NULL); in is_usb2_otg_phy()
1272 static bool is_usb3_otg_phy(struct tegra_xusb *tegra, unsigned int index) in is_usb3_otg_phy() argument
1274 struct tegra_xusb_padctl *padctl = tegra->padctl; in is_usb3_otg_phy()
1278 for (i = 0; i < tegra->num_usb_phys; i++) { in is_usb3_otg_phy()
1279 if (is_usb2_otg_phy(tegra, i)) { in is_usb3_otg_phy()
1289 static bool is_host_mode_phy(struct tegra_xusb *tegra, unsigned int phy_type, unsigned int index) in is_host_mode_phy() argument
1291 if (strcmp(tegra->soc->phy_types[phy_type].name, "hsic") == 0) in is_host_mode_phy()
1294 if (strcmp(tegra->soc->phy_types[phy_type].name, "usb2") == 0) { in is_host_mode_phy()
1295 if (is_usb2_otg_phy(tegra, index)) in is_host_mode_phy()
1296 return ((index == tegra->otg_usb2_port) && tegra->host_mode); in is_host_mode_phy()
1301 if (strcmp(tegra->soc->phy_types[phy_type].name, "usb3") == 0) { in is_host_mode_phy()
1302 if (is_usb3_otg_phy(tegra, index)) in is_host_mode_phy()
1303 return ((index == tegra->otg_usb3_port) && tegra->host_mode); in is_host_mode_phy()
1312 static int tegra_xusb_get_usb2_port(struct tegra_xusb *tegra, in tegra_xusb_get_usb2_port() argument
1317 for (i = 0; i < tegra->num_usb_phys; i++) { in tegra_xusb_get_usb2_port()
1318 if (tegra->usbphy[i] && usbphy == tegra->usbphy[i]) in tegra_xusb_get_usb2_port()
1328 struct tegra_xusb *tegra = container_of(nb, struct tegra_xusb, in tegra_xhci_id_notify() local
1332 dev_dbg(tegra->dev, "%s(): action is %d", __func__, usbphy->last_event); in tegra_xhci_id_notify()
1334 if ((tegra->host_mode && usbphy->last_event == USB_EVENT_ID) || in tegra_xhci_id_notify()
1335 (!tegra->host_mode && usbphy->last_event != USB_EVENT_ID)) { in tegra_xhci_id_notify()
1336 dev_dbg(tegra->dev, "Same role(%d) received. Ignore", in tegra_xhci_id_notify()
1337 tegra->host_mode); in tegra_xhci_id_notify()
1341 tegra->otg_usb2_port = tegra_xusb_get_usb2_port(tegra, usbphy); in tegra_xhci_id_notify()
1342 tegra->otg_usb3_port = tegra_xusb_padctl_get_usb3_companion( in tegra_xhci_id_notify()
1343 tegra->padctl, in tegra_xhci_id_notify()
1344 tegra->otg_usb2_port); in tegra_xhci_id_notify()
1346 tegra->host_mode = (usbphy->last_event == USB_EVENT_ID) ? true : false; in tegra_xhci_id_notify()
1348 schedule_work(&tegra->id_work); in tegra_xhci_id_notify()
1353 static int tegra_xusb_init_usb_phy(struct tegra_xusb *tegra) in tegra_xusb_init_usb_phy() argument
1357 tegra->usbphy = devm_kcalloc(tegra->dev, tegra->num_usb_phys, in tegra_xusb_init_usb_phy()
1358 sizeof(*tegra->usbphy), GFP_KERNEL); in tegra_xusb_init_usb_phy()
1359 if (!tegra->usbphy) in tegra_xusb_init_usb_phy()
1362 INIT_WORK(&tegra->id_work, tegra_xhci_id_work); in tegra_xusb_init_usb_phy()
1363 tegra->id_nb.notifier_call = tegra_xhci_id_notify; in tegra_xusb_init_usb_phy()
1364 tegra->otg_usb2_port = -EINVAL; in tegra_xusb_init_usb_phy()
1365 tegra->otg_usb3_port = -EINVAL; in tegra_xusb_init_usb_phy()
1367 for (i = 0; i < tegra->num_usb_phys; i++) { in tegra_xusb_init_usb_phy()
1368 struct phy *phy = tegra_xusb_get_phy(tegra, "usb2", i); in tegra_xusb_init_usb_phy()
1373 tegra->usbphy[i] = devm_usb_get_phy_by_node(tegra->dev, in tegra_xusb_init_usb_phy()
1375 &tegra->id_nb); in tegra_xusb_init_usb_phy()
1376 if (!IS_ERR(tegra->usbphy[i])) { in tegra_xusb_init_usb_phy()
1377 dev_dbg(tegra->dev, "usbphy-%d registered", i); in tegra_xusb_init_usb_phy()
1378 otg_set_host(tegra->usbphy[i]->otg, &tegra->hcd->self); in tegra_xusb_init_usb_phy()
1383 tegra->usbphy[i] = NULL; in tegra_xusb_init_usb_phy()
1390 static void tegra_xusb_deinit_usb_phy(struct tegra_xusb *tegra) in tegra_xusb_deinit_usb_phy() argument
1394 cancel_work_sync(&tegra->id_work); in tegra_xusb_deinit_usb_phy()
1396 for (i = 0; i < tegra->num_usb_phys; i++) in tegra_xusb_deinit_usb_phy()
1397 if (tegra->usbphy[i]) in tegra_xusb_deinit_usb_phy()
1398 otg_set_host(tegra->usbphy[i]->otg, NULL); in tegra_xusb_deinit_usb_phy()
1403 struct tegra_xusb *tegra; in tegra_xusb_probe() local
1413 tegra = devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL); in tegra_xusb_probe()
1414 if (!tegra) in tegra_xusb_probe()
1417 tegra->soc = of_device_get_match_data(&pdev->dev); in tegra_xusb_probe()
1418 mutex_init(&tegra->lock); in tegra_xusb_probe()
1419 tegra->dev = &pdev->dev; in tegra_xusb_probe()
1421 err = tegra_xusb_init_context(tegra); in tegra_xusb_probe()
1425 tegra->regs = devm_platform_get_and_ioremap_resource(pdev, 0, ®s); in tegra_xusb_probe()
1426 if (IS_ERR(tegra->regs)) in tegra_xusb_probe()
1427 return PTR_ERR(tegra->regs); in tegra_xusb_probe()
1429 tegra->fpci_base = devm_platform_ioremap_resource(pdev, 1); in tegra_xusb_probe()
1430 if (IS_ERR(tegra->fpci_base)) in tegra_xusb_probe()
1431 return PTR_ERR(tegra->fpci_base); in tegra_xusb_probe()
1433 if (tegra->soc->has_ipfs) { in tegra_xusb_probe()
1434 tegra->ipfs_base = devm_platform_ioremap_resource(pdev, 2); in tegra_xusb_probe()
1435 if (IS_ERR(tegra->ipfs_base)) in tegra_xusb_probe()
1436 return PTR_ERR(tegra->ipfs_base); in tegra_xusb_probe()
1439 tegra->xhci_irq = platform_get_irq(pdev, 0); in tegra_xusb_probe()
1440 if (tegra->xhci_irq < 0) in tegra_xusb_probe()
1441 return tegra->xhci_irq; in tegra_xusb_probe()
1443 tegra->mbox_irq = platform_get_irq(pdev, 1); in tegra_xusb_probe()
1444 if (tegra->mbox_irq < 0) in tegra_xusb_probe()
1445 return tegra->mbox_irq; in tegra_xusb_probe()
1447 tegra->padctl = tegra_xusb_padctl_get(&pdev->dev); in tegra_xusb_probe()
1448 if (IS_ERR(tegra->padctl)) in tegra_xusb_probe()
1449 return PTR_ERR(tegra->padctl); in tegra_xusb_probe()
1457 tegra->padctl_irq = of_irq_get(np, 0); in tegra_xusb_probe()
1458 if (tegra->padctl_irq <= 0) { in tegra_xusb_probe()
1459 err = (tegra->padctl_irq == 0) ? -ENODEV : tegra->padctl_irq; in tegra_xusb_probe()
1463 tegra->host_clk = devm_clk_get(&pdev->dev, "xusb_host"); in tegra_xusb_probe()
1464 if (IS_ERR(tegra->host_clk)) { in tegra_xusb_probe()
1465 err = PTR_ERR(tegra->host_clk); in tegra_xusb_probe()
1470 tegra->falcon_clk = devm_clk_get(&pdev->dev, "xusb_falcon_src"); in tegra_xusb_probe()
1471 if (IS_ERR(tegra->falcon_clk)) { in tegra_xusb_probe()
1472 err = PTR_ERR(tegra->falcon_clk); in tegra_xusb_probe()
1477 tegra->ss_clk = devm_clk_get(&pdev->dev, "xusb_ss"); in tegra_xusb_probe()
1478 if (IS_ERR(tegra->ss_clk)) { in tegra_xusb_probe()
1479 err = PTR_ERR(tegra->ss_clk); in tegra_xusb_probe()
1484 tegra->ss_src_clk = devm_clk_get(&pdev->dev, "xusb_ss_src"); in tegra_xusb_probe()
1485 if (IS_ERR(tegra->ss_src_clk)) { in tegra_xusb_probe()
1486 err = PTR_ERR(tegra->ss_src_clk); in tegra_xusb_probe()
1491 tegra->hs_src_clk = devm_clk_get(&pdev->dev, "xusb_hs_src"); in tegra_xusb_probe()
1492 if (IS_ERR(tegra->hs_src_clk)) { in tegra_xusb_probe()
1493 err = PTR_ERR(tegra->hs_src_clk); in tegra_xusb_probe()
1498 tegra->fs_src_clk = devm_clk_get(&pdev->dev, "xusb_fs_src"); in tegra_xusb_probe()
1499 if (IS_ERR(tegra->fs_src_clk)) { in tegra_xusb_probe()
1500 err = PTR_ERR(tegra->fs_src_clk); in tegra_xusb_probe()
1505 tegra->pll_u_480m = devm_clk_get(&pdev->dev, "pll_u_480m"); in tegra_xusb_probe()
1506 if (IS_ERR(tegra->pll_u_480m)) { in tegra_xusb_probe()
1507 err = PTR_ERR(tegra->pll_u_480m); in tegra_xusb_probe()
1512 tegra->clk_m = devm_clk_get(&pdev->dev, "clk_m"); in tegra_xusb_probe()
1513 if (IS_ERR(tegra->clk_m)) { in tegra_xusb_probe()
1514 err = PTR_ERR(tegra->clk_m); in tegra_xusb_probe()
1519 tegra->pll_e = devm_clk_get(&pdev->dev, "pll_e"); in tegra_xusb_probe()
1520 if (IS_ERR(tegra->pll_e)) { in tegra_xusb_probe()
1521 err = PTR_ERR(tegra->pll_e); in tegra_xusb_probe()
1527 tegra->host_rst = devm_reset_control_get(&pdev->dev, in tegra_xusb_probe()
1529 if (IS_ERR(tegra->host_rst)) { in tegra_xusb_probe()
1530 err = PTR_ERR(tegra->host_rst); in tegra_xusb_probe()
1536 tegra->ss_rst = devm_reset_control_get(&pdev->dev, "xusb_ss"); in tegra_xusb_probe()
1537 if (IS_ERR(tegra->ss_rst)) { in tegra_xusb_probe()
1538 err = PTR_ERR(tegra->ss_rst); in tegra_xusb_probe()
1544 err = tegra_xusb_powerdomain_init(&pdev->dev, tegra); in tegra_xusb_probe()
1549 tegra->supplies = devm_kcalloc(&pdev->dev, tegra->soc->num_supplies, in tegra_xusb_probe()
1550 sizeof(*tegra->supplies), GFP_KERNEL); in tegra_xusb_probe()
1551 if (!tegra->supplies) { in tegra_xusb_probe()
1556 regulator_bulk_set_supply_names(tegra->supplies, in tegra_xusb_probe()
1557 tegra->soc->supply_names, in tegra_xusb_probe()
1558 tegra->soc->num_supplies); in tegra_xusb_probe()
1560 err = devm_regulator_bulk_get(&pdev->dev, tegra->soc->num_supplies, in tegra_xusb_probe()
1561 tegra->supplies); in tegra_xusb_probe()
1567 for (i = 0; i < tegra->soc->num_types; i++) { in tegra_xusb_probe()
1568 if (!strncmp(tegra->soc->phy_types[i].name, "usb2", 4)) in tegra_xusb_probe()
1569 tegra->num_usb_phys = tegra->soc->phy_types[i].num; in tegra_xusb_probe()
1570 tegra->num_phys += tegra->soc->phy_types[i].num; in tegra_xusb_probe()
1573 tegra->phys = devm_kcalloc(&pdev->dev, tegra->num_phys, in tegra_xusb_probe()
1574 sizeof(*tegra->phys), GFP_KERNEL); in tegra_xusb_probe()
1575 if (!tegra->phys) { in tegra_xusb_probe()
1580 for (i = 0, k = 0; i < tegra->soc->num_types; i++) { in tegra_xusb_probe()
1583 for (j = 0; j < tegra->soc->phy_types[i].num; j++) { in tegra_xusb_probe()
1585 tegra->soc->phy_types[i].name, j); in tegra_xusb_probe()
1596 tegra->phys[k++] = phy; in tegra_xusb_probe()
1600 tegra->hcd = usb_create_hcd(&tegra_xhci_hc_driver, &pdev->dev, in tegra_xusb_probe()
1602 if (!tegra->hcd) { in tegra_xusb_probe()
1607 tegra->hcd->skip_phy_initialization = 1; in tegra_xusb_probe()
1608 tegra->hcd->regs = tegra->regs; in tegra_xusb_probe()
1609 tegra->hcd->rsrc_start = regs->start; in tegra_xusb_probe()
1610 tegra->hcd->rsrc_len = resource_size(regs); in tegra_xusb_probe()
1616 platform_set_drvdata(pdev, tegra); in tegra_xusb_probe()
1618 err = tegra_xusb_clk_enable(tegra); in tegra_xusb_probe()
1620 dev_err(tegra->dev, "failed to enable clocks: %d\n", err); in tegra_xusb_probe()
1624 err = regulator_bulk_enable(tegra->soc->num_supplies, tegra->supplies); in tegra_xusb_probe()
1626 dev_err(tegra->dev, "failed to enable regulators: %d\n", err); in tegra_xusb_probe()
1630 err = tegra_xusb_phy_enable(tegra); in tegra_xusb_probe()
1640 err = dma_set_mask_and_coherent(tegra->dev, DMA_BIT_MASK(40)); in tegra_xusb_probe()
1646 err = tegra_xusb_request_firmware(tegra); in tegra_xusb_probe()
1652 err = tegra_xusb_unpowergate_partitions(tegra); in tegra_xusb_probe()
1656 tegra_xusb_config(tegra); in tegra_xusb_probe()
1658 err = tegra_xusb_load_firmware(tegra); in tegra_xusb_probe()
1664 err = usb_add_hcd(tegra->hcd, tegra->xhci_irq, IRQF_SHARED); in tegra_xusb_probe()
1670 device_wakeup_enable(tegra->hcd->self.controller); in tegra_xusb_probe()
1672 xhci = hcd_to_xhci(tegra->hcd); in tegra_xusb_probe()
1677 tegra->hcd); in tegra_xusb_probe()
1684 err = usb_add_hcd(xhci->shared_hcd, tegra->xhci_irq, IRQF_SHARED); in tegra_xusb_probe()
1690 err = devm_request_threaded_irq(&pdev->dev, tegra->mbox_irq, in tegra_xusb_probe()
1693 dev_name(&pdev->dev), tegra); in tegra_xusb_probe()
1699 err = devm_request_threaded_irq(&pdev->dev, tegra->padctl_irq, NULL, tegra_xusb_padctl_irq, in tegra_xusb_probe()
1700 IRQF_ONESHOT, dev_name(&pdev->dev), tegra); in tegra_xusb_probe()
1706 err = tegra_xusb_enable_firmware_messages(tegra); in tegra_xusb_probe()
1712 err = tegra_xusb_init_usb_phy(tegra); in tegra_xusb_probe()
1719 device_init_wakeup(&tegra->hcd->self.root_hub->dev, true); in tegra_xusb_probe()
1721 device_init_wakeup(tegra->dev, true); in tegra_xusb_probe()
1723 pm_runtime_use_autosuspend(tegra->dev); in tegra_xusb_probe()
1724 pm_runtime_set_autosuspend_delay(tegra->dev, 2000); in tegra_xusb_probe()
1725 pm_runtime_mark_last_busy(tegra->dev); in tegra_xusb_probe()
1726 pm_runtime_set_active(tegra->dev); in tegra_xusb_probe()
1727 pm_runtime_enable(tegra->dev); in tegra_xusb_probe()
1736 usb_remove_hcd(tegra->hcd); in tegra_xusb_probe()
1738 tegra_xusb_powergate_partitions(tegra); in tegra_xusb_probe()
1740 dma_free_coherent(&pdev->dev, tegra->fw.size, tegra->fw.virt, in tegra_xusb_probe()
1741 tegra->fw.phys); in tegra_xusb_probe()
1743 tegra_xusb_phy_disable(tegra); in tegra_xusb_probe()
1745 regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies); in tegra_xusb_probe()
1747 tegra_xusb_clk_disable(tegra); in tegra_xusb_probe()
1749 usb_put_hcd(tegra->hcd); in tegra_xusb_probe()
1751 tegra_xusb_powerdomain_remove(&pdev->dev, tegra); in tegra_xusb_probe()
1754 tegra_xusb_padctl_put(tegra->padctl); in tegra_xusb_probe()
1760 struct tegra_xusb *tegra = platform_get_drvdata(pdev); in tegra_xusb_remove() local
1761 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xusb_remove()
1763 tegra_xusb_deinit_usb_phy(tegra); in tegra_xusb_remove()
1769 usb_remove_hcd(tegra->hcd); in tegra_xusb_remove()
1770 usb_put_hcd(tegra->hcd); in tegra_xusb_remove()
1772 dma_free_coherent(&pdev->dev, tegra->fw.size, tegra->fw.virt, in tegra_xusb_remove()
1773 tegra->fw.phys); in tegra_xusb_remove()
1778 tegra_xusb_powergate_partitions(tegra); in tegra_xusb_remove()
1780 tegra_xusb_powerdomain_remove(&pdev->dev, tegra); in tegra_xusb_remove()
1782 tegra_xusb_phy_disable(tegra); in tegra_xusb_remove()
1783 tegra_xusb_clk_disable(tegra); in tegra_xusb_remove()
1784 regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies); in tegra_xusb_remove()
1785 tegra_xusb_padctl_put(tegra->padctl); in tegra_xusb_remove()
1812 static int tegra_xusb_check_ports(struct tegra_xusb *tegra) in tegra_xusb_check_ports() argument
1814 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xusb_check_ports()
1837 static void tegra_xusb_save_context(struct tegra_xusb *tegra) in tegra_xusb_save_context() argument
1839 const struct tegra_xusb_context_soc *soc = tegra->soc->context; in tegra_xusb_save_context()
1840 struct tegra_xusb_context *ctx = &tegra->context; in tegra_xusb_save_context()
1845 ctx->ipfs[i] = ipfs_readl(tegra, soc->ipfs.offsets[i]); in tegra_xusb_save_context()
1850 ctx->fpci[i] = fpci_readl(tegra, soc->fpci.offsets[i]); in tegra_xusb_save_context()
1854 static void tegra_xusb_restore_context(struct tegra_xusb *tegra) in tegra_xusb_restore_context() argument
1856 const struct tegra_xusb_context_soc *soc = tegra->soc->context; in tegra_xusb_restore_context()
1857 struct tegra_xusb_context *ctx = &tegra->context; in tegra_xusb_restore_context()
1862 fpci_writel(tegra, ctx->fpci[i], soc->fpci.offsets[i]); in tegra_xusb_restore_context()
1867 ipfs_writel(tegra, ctx->ipfs[i], soc->ipfs.offsets[i]); in tegra_xusb_restore_context()
1871 static enum usb_device_speed tegra_xhci_portsc_to_speed(struct tegra_xusb *tegra, u32 portsc) in tegra_xhci_portsc_to_speed() argument
1888 static void tegra_xhci_enable_phy_sleepwalk_wake(struct tegra_xusb *tegra) in tegra_xhci_enable_phy_sleepwalk_wake() argument
1890 struct tegra_xusb_padctl *padctl = tegra->padctl; in tegra_xhci_enable_phy_sleepwalk_wake()
1891 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xhci_enable_phy_sleepwalk_wake()
1899 for (i = 0, k = 0; i < tegra->soc->num_types; i++) { in tegra_xhci_enable_phy_sleepwalk_wake()
1900 if (strcmp(tegra->soc->phy_types[i].name, "usb3") == 0) in tegra_xhci_enable_phy_sleepwalk_wake()
1905 if (strcmp(tegra->soc->phy_types[i].name, "hsic") == 0) in tegra_xhci_enable_phy_sleepwalk_wake()
1906 offset = tegra->soc->ports.usb2.count; in tegra_xhci_enable_phy_sleepwalk_wake()
1910 for (j = 0; j < tegra->soc->phy_types[i].num; j++) { in tegra_xhci_enable_phy_sleepwalk_wake()
1911 phy = tegra->phys[k++]; in tegra_xhci_enable_phy_sleepwalk_wake()
1921 if (!is_host_mode_phy(tegra, i, j)) in tegra_xhci_enable_phy_sleepwalk_wake()
1925 speed = tegra_xhci_portsc_to_speed(tegra, portsc); in tegra_xhci_enable_phy_sleepwalk_wake()
1932 static void tegra_xhci_disable_phy_wake(struct tegra_xusb *tegra) in tegra_xhci_disable_phy_wake() argument
1934 struct tegra_xusb_padctl *padctl = tegra->padctl; in tegra_xhci_disable_phy_wake()
1937 for (i = 0; i < tegra->num_phys; i++) { in tegra_xhci_disable_phy_wake()
1938 if (!tegra->phys[i]) in tegra_xhci_disable_phy_wake()
1941 tegra_xusb_padctl_disable_phy_wake(padctl, tegra->phys[i]); in tegra_xhci_disable_phy_wake()
1945 static void tegra_xhci_disable_phy_sleepwalk(struct tegra_xusb *tegra) in tegra_xhci_disable_phy_sleepwalk() argument
1947 struct tegra_xusb_padctl *padctl = tegra->padctl; in tegra_xhci_disable_phy_sleepwalk()
1950 for (i = 0; i < tegra->num_phys; i++) { in tegra_xhci_disable_phy_sleepwalk()
1951 if (!tegra->phys[i]) in tegra_xhci_disable_phy_sleepwalk()
1954 tegra_xusb_padctl_disable_phy_sleepwalk(padctl, tegra->phys[i]); in tegra_xhci_disable_phy_sleepwalk()
1958 static int tegra_xusb_enter_elpg(struct tegra_xusb *tegra, bool runtime) in tegra_xusb_enter_elpg() argument
1960 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xusb_enter_elpg()
1961 struct device *dev = tegra->dev; in tegra_xusb_enter_elpg()
1973 err = tegra_xusb_check_ports(tegra); in tegra_xusb_enter_elpg()
1975 dev_err(tegra->dev, "not all ports suspended: %d\n", err); in tegra_xusb_enter_elpg()
1981 dev_err(tegra->dev, "failed to suspend XHCI: %d\n", err); in tegra_xusb_enter_elpg()
1985 tegra_xusb_save_context(tegra); in tegra_xusb_enter_elpg()
1988 tegra_xhci_enable_phy_sleepwalk_wake(tegra); in tegra_xusb_enter_elpg()
1990 tegra_xusb_powergate_partitions(tegra); in tegra_xusb_enter_elpg()
1992 for (i = 0; i < tegra->num_phys; i++) { in tegra_xusb_enter_elpg()
1993 if (!tegra->phys[i]) in tegra_xusb_enter_elpg()
1996 phy_power_off(tegra->phys[i]); in tegra_xusb_enter_elpg()
1998 phy_exit(tegra->phys[i]); in tegra_xusb_enter_elpg()
2001 tegra_xusb_clk_disable(tegra); in tegra_xusb_enter_elpg()
2005 dev_dbg(tegra->dev, "entering ELPG done\n"); in tegra_xusb_enter_elpg()
2011 dev_dbg(tegra->dev, "entering ELPG failed\n"); in tegra_xusb_enter_elpg()
2012 pm_runtime_mark_last_busy(tegra->dev); in tegra_xusb_enter_elpg()
2018 static int tegra_xusb_exit_elpg(struct tegra_xusb *tegra, bool runtime) in tegra_xusb_exit_elpg() argument
2020 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); in tegra_xusb_exit_elpg()
2021 struct device *dev = tegra->dev; in tegra_xusb_exit_elpg()
2028 pm_runtime_mark_last_busy(tegra->dev); in tegra_xusb_exit_elpg()
2030 err = tegra_xusb_clk_enable(tegra); in tegra_xusb_exit_elpg()
2032 dev_err(tegra->dev, "failed to enable clocks: %d\n", err); in tegra_xusb_exit_elpg()
2036 err = tegra_xusb_unpowergate_partitions(tegra); in tegra_xusb_exit_elpg()
2041 tegra_xhci_disable_phy_wake(tegra); in tegra_xusb_exit_elpg()
2043 for (i = 0; i < tegra->num_phys; i++) { in tegra_xusb_exit_elpg()
2044 if (!tegra->phys[i]) in tegra_xusb_exit_elpg()
2048 phy_init(tegra->phys[i]); in tegra_xusb_exit_elpg()
2050 phy_power_on(tegra->phys[i]); in tegra_xusb_exit_elpg()
2053 tegra_xusb_config(tegra); in tegra_xusb_exit_elpg()
2054 tegra_xusb_restore_context(tegra); in tegra_xusb_exit_elpg()
2056 err = tegra_xusb_load_firmware(tegra); in tegra_xusb_exit_elpg()
2058 dev_err(tegra->dev, "failed to load firmware: %d\n", err); in tegra_xusb_exit_elpg()
2062 err = __tegra_xusb_enable_firmware_messages(tegra); in tegra_xusb_exit_elpg()
2064 dev_err(tegra->dev, "failed to enable messages: %d\n", err); in tegra_xusb_exit_elpg()
2069 tegra_xhci_disable_phy_sleepwalk(tegra); in tegra_xusb_exit_elpg()
2073 dev_err(tegra->dev, "failed to resume XHCI: %d\n", err); in tegra_xusb_exit_elpg()
2084 for (i = 0; i < tegra->num_phys; i++) { in tegra_xusb_exit_elpg()
2085 if (!tegra->phys[i]) in tegra_xusb_exit_elpg()
2088 phy_power_off(tegra->phys[i]); in tegra_xusb_exit_elpg()
2090 phy_exit(tegra->phys[i]); in tegra_xusb_exit_elpg()
2092 tegra_xusb_powergate_partitions(tegra); in tegra_xusb_exit_elpg()
2094 tegra_xusb_clk_disable(tegra); in tegra_xusb_exit_elpg()
2106 struct tegra_xusb *tegra = dev_get_drvdata(dev); in tegra_xusb_suspend() local
2109 synchronize_irq(tegra->mbox_irq); in tegra_xusb_suspend()
2111 mutex_lock(&tegra->lock); in tegra_xusb_suspend()
2114 err = tegra_xusb_exit_elpg(tegra, true); in tegra_xusb_suspend()
2119 err = tegra_xusb_enter_elpg(tegra, false); in tegra_xusb_suspend()
2132 tegra->suspended = true; in tegra_xusb_suspend()
2136 if (enable_irq_wake(tegra->padctl_irq)) in tegra_xusb_suspend()
2141 mutex_unlock(&tegra->lock); in tegra_xusb_suspend()
2148 struct tegra_xusb *tegra = dev_get_drvdata(dev); in tegra_xusb_resume() local
2151 mutex_lock(&tegra->lock); in tegra_xusb_resume()
2153 if (!tegra->suspended) { in tegra_xusb_resume()
2154 mutex_unlock(&tegra->lock); in tegra_xusb_resume()
2158 err = tegra_xusb_exit_elpg(tegra, false); in tegra_xusb_resume()
2160 mutex_unlock(&tegra->lock); in tegra_xusb_resume()
2165 if (disable_irq_wake(tegra->padctl_irq)) in tegra_xusb_resume()
2168 tegra->suspended = false; in tegra_xusb_resume()
2169 mutex_unlock(&tegra->lock); in tegra_xusb_resume()
2179 struct tegra_xusb *tegra = dev_get_drvdata(dev); in tegra_xusb_runtime_suspend() local
2182 synchronize_irq(tegra->mbox_irq); in tegra_xusb_runtime_suspend()
2183 mutex_lock(&tegra->lock); in tegra_xusb_runtime_suspend()
2184 ret = tegra_xusb_enter_elpg(tegra, true); in tegra_xusb_runtime_suspend()
2185 mutex_unlock(&tegra->lock); in tegra_xusb_runtime_suspend()
2192 struct tegra_xusb *tegra = dev_get_drvdata(dev); in tegra_xusb_runtime_resume() local
2195 mutex_lock(&tegra->lock); in tegra_xusb_runtime_resume()
2196 err = tegra_xusb_exit_elpg(tegra, true); in tegra_xusb_runtime_resume()
2197 mutex_unlock(&tegra->lock); in tegra_xusb_runtime_resume()
2403 .name = "tegra-xusb",
2411 struct tegra_xusb *tegra = dev_get_drvdata(dev); in tegra_xhci_quirks() local
2414 if (tegra && tegra->soc->lpm_support) in tegra_xhci_quirks()
2442 MODULE_DESCRIPTION("NVIDIA Tegra XUSB xHCI host-controller driver");