Lines Matching refs:tegra
19 #include <linux/phy/tegra/xusb.h>
30 #include <soc/tegra/pmc.h>
278 static inline u32 fpci_readl(struct tegra_xusb *tegra, unsigned int offset)
280 return readl(tegra->fpci_base + offset);
283 static inline void fpci_writel(struct tegra_xusb *tegra, u32 value,
286 writel(value, tegra->fpci_base + offset);
289 static inline u32 ipfs_readl(struct tegra_xusb *tegra, unsigned int offset)
291 return readl(tegra->ipfs_base + offset);
294 static inline void ipfs_writel(struct tegra_xusb *tegra, u32 value,
297 writel(value, tegra->ipfs_base + offset);
300 static u32 csb_readl(struct tegra_xusb *tegra, unsigned int offset)
305 fpci_writel(tegra, page, XUSB_CFG_ARU_C11_CSBRANGE);
307 return fpci_readl(tegra, XUSB_CFG_CSB_BASE_ADDR + ofs);
310 static void csb_writel(struct tegra_xusb *tegra, u32 value,
316 fpci_writel(tegra, page, XUSB_CFG_ARU_C11_CSBRANGE);
317 fpci_writel(tegra, value, XUSB_CFG_CSB_BASE_ADDR + ofs);
320 static int tegra_xusb_set_ss_clk(struct tegra_xusb *tegra,
324 struct clk *clk = tegra->ss_src_clk;
338 new_parent_rate = clk_get_rate(tegra->pll_u_480m);
345 err = clk_set_parent(clk, tegra->pll_u_480m);
361 err = clk_set_parent(clk, tegra->clk_m);
372 dev_err(tegra->dev, "Invalid SS rate: %lu Hz\n", rate);
377 dev_err(tegra->dev, "SS clock doesn't match requested rate\n");
448 static int tegra_xusb_mbox_send(struct tegra_xusb *tegra,
459 value = fpci_readl(tegra, tegra->soc->mbox.owner);
461 dev_err(tegra->dev, "mailbox is busy\n");
465 fpci_writel(tegra, MBOX_OWNER_SW, tegra->soc->mbox.owner);
467 value = fpci_readl(tegra, tegra->soc->mbox.owner);
469 dev_err(tegra->dev, "failed to acquire mailbox\n");
477 fpci_writel(tegra, value, tegra->soc->mbox.data_in);
479 value = fpci_readl(tegra, tegra->soc->mbox.cmd);
481 fpci_writel(tegra, value, tegra->soc->mbox.cmd);
487 value = fpci_readl(tegra, tegra->soc->mbox.owner);
495 value = fpci_readl(tegra, tegra->soc->mbox.owner);
506 struct tegra_xusb *tegra = data;
510 value = fpci_readl(tegra, XUSB_CFG_ARU_SMI_INTR);
511 fpci_writel(tegra, value, XUSB_CFG_ARU_SMI_INTR);
514 dev_err(tegra->dev, "controller firmware hang\n");
519 static void tegra_xusb_mbox_handle(struct tegra_xusb *tegra,
522 struct tegra_xusb_padctl *padctl = tegra->padctl;
523 const struct tegra_xusb_soc *soc = tegra->soc;
524 struct device *dev = tegra->dev;
536 rsp.data = clk_get_rate(tegra->falcon_clk) / 1000;
546 if (tegra->soc->scale_ss_clock) {
547 err = tegra_xusb_set_ss_clk(tegra, msg->data * 1000);
553 rsp.data = clk_get_rate(tegra->ss_src_clk) / 1000;
655 err = tegra_xusb_mbox_send(tegra, &rsp);
663 struct tegra_xusb *tegra = data;
667 mutex_lock(&tegra->lock);
669 value = fpci_readl(tegra, tegra->soc->mbox.data_out);
672 value = fpci_readl(tegra, tegra->soc->mbox.cmd);
674 fpci_writel(tegra, value, tegra->soc->mbox.cmd);
678 fpci_writel(tegra, MBOX_OWNER_NONE, tegra->soc->mbox.owner);
680 tegra_xusb_mbox_handle(tegra, &msg);
682 mutex_unlock(&tegra->lock);
686 static void tegra_xusb_config(struct tegra_xusb *tegra)
688 u32 regs = tegra->hcd->rsrc_start;
691 if (tegra->soc->has_ipfs) {
692 value = ipfs_readl(tegra, IPFS_XUSB_HOST_CONFIGURATION_0);
694 ipfs_writel(tegra, value, IPFS_XUSB_HOST_CONFIGURATION_0);
700 value = fpci_readl(tegra, XUSB_CFG_4);
703 fpci_writel(tegra, value, XUSB_CFG_4);
708 value = fpci_readl(tegra, XUSB_CFG_1);
710 fpci_writel(tegra, value, XUSB_CFG_1);
712 if (tegra->soc->has_ipfs) {
714 value = ipfs_readl(tegra, IPFS_XUSB_HOST_INTR_MASK_0);
716 ipfs_writel(tegra, value, IPFS_XUSB_HOST_INTR_MASK_0);
719 ipfs_writel(tegra, 0x80, IPFS_XUSB_HOST_CLKGATE_HYSTERESIS_0);
723 static int tegra_xusb_clk_enable(struct tegra_xusb *tegra)
727 err = clk_prepare_enable(tegra->pll_e);
731 err = clk_prepare_enable(tegra->host_clk);
735 err = clk_prepare_enable(tegra->ss_clk);
739 err = clk_prepare_enable(tegra->falcon_clk);
743 err = clk_prepare_enable(tegra->fs_src_clk);
747 err = clk_prepare_enable(tegra->hs_src_clk);
751 if (tegra->soc->scale_ss_clock) {
752 err = tegra_xusb_set_ss_clk(tegra, TEGRA_XHCI_SS_HIGH_SPEED);
760 clk_disable_unprepare(tegra->hs_src_clk);
762 clk_disable_unprepare(tegra->fs_src_clk);
764 clk_disable_unprepare(tegra->falcon_clk);
766 clk_disable_unprepare(tegra->ss_clk);
768 clk_disable_unprepare(tegra->host_clk);
770 clk_disable_unprepare(tegra->pll_e);
774 static void tegra_xusb_clk_disable(struct tegra_xusb *tegra)
776 clk_disable_unprepare(tegra->pll_e);
777 clk_disable_unprepare(tegra->host_clk);
778 clk_disable_unprepare(tegra->ss_clk);
779 clk_disable_unprepare(tegra->falcon_clk);
780 clk_disable_unprepare(tegra->fs_src_clk);
781 clk_disable_unprepare(tegra->hs_src_clk);
784 static int tegra_xusb_phy_enable(struct tegra_xusb *tegra)
789 for (i = 0; i < tegra->num_phys; i++) {
790 err = phy_init(tegra->phys[i]);
794 err = phy_power_on(tegra->phys[i]);
796 phy_exit(tegra->phys[i]);
805 phy_power_off(tegra->phys[i]);
806 phy_exit(tegra->phys[i]);
812 static void tegra_xusb_phy_disable(struct tegra_xusb *tegra)
816 for (i = 0; i < tegra->num_phys; i++) {
817 phy_power_off(tegra->phys[i]);
818 phy_exit(tegra->phys[i]);
824 struct tegra_xusb *tegra = dev_get_drvdata(dev);
826 regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies);
827 tegra_xusb_clk_disable(tegra);
834 struct tegra_xusb *tegra = dev_get_drvdata(dev);
837 err = tegra_xusb_clk_enable(tegra);
843 err = regulator_bulk_enable(tegra->soc->num_supplies, tegra->supplies);
852 tegra_xusb_clk_disable(tegra);
857 static int tegra_xusb_init_context(struct tegra_xusb *tegra)
859 const struct tegra_xusb_context_soc *soc = tegra->soc->context;
861 tegra->context.ipfs = devm_kcalloc(tegra->dev, soc->ipfs.num_offsets,
863 if (!tegra->context.ipfs)
866 tegra->context.fpci = devm_kcalloc(tegra->dev, soc->fpci.num_offsets,
868 if (!tegra->context.fpci)
874 static inline int tegra_xusb_init_context(struct tegra_xusb *tegra)
880 static int tegra_xusb_request_firmware(struct tegra_xusb *tegra)
886 err = request_firmware(&fw, tegra->soc->firmware, tegra->dev);
888 dev_err(tegra->dev, "failed to request firmware: %d\n", err);
894 tegra->fw.size = le32_to_cpu(header->fwimg_len);
896 tegra->fw.virt = dma_alloc_coherent(tegra->dev, tegra->fw.size,
897 &tegra->fw.phys, GFP_KERNEL);
898 if (!tegra->fw.virt) {
899 dev_err(tegra->dev, "failed to allocate memory for firmware\n");
904 header = (struct tegra_xusb_fw_header *)tegra->fw.virt;
905 memcpy(tegra->fw.virt, fw->data, tegra->fw.size);
911 static int tegra_xusb_load_firmware(struct tegra_xusb *tegra)
914 struct xhci_cap_regs __iomem *cap = tegra->regs;
916 struct device *dev = tegra->dev;
925 header = (struct tegra_xusb_fw_header *)tegra->fw.virt;
926 op = tegra->regs + HC_LENGTH(readl(&cap->hc_capbase));
928 if (csb_readl(tegra, XUSB_CSB_MP_ILOAD_BASE_LO) != 0) {
930 csb_readl(tegra, XUSB_FALC_CPUCTL));
935 csb_writel(tegra, tegra->fw.size, XUSB_CSB_MP_ILOAD_ATTR);
941 address = tegra->fw.phys + sizeof(*header);
942 csb_writel(tegra, address >> 32, XUSB_CSB_MP_ILOAD_BASE_HI);
943 csb_writel(tegra, address, XUSB_CSB_MP_ILOAD_BASE_LO);
946 csb_writel(tegra, APMAP_BOOTPATH, XUSB_CSB_MP_APMAP);
949 csb_writel(tegra, L2IMEMOP_INVALIDATE_ALL, XUSB_CSB_MP_L2IMEMOP_TRIG);
965 csb_writel(tegra, value, XUSB_CSB_MP_L2IMEMOP_SIZE);
968 csb_writel(tegra, L2IMEMOP_LOAD_LOCKED_RESULT,
972 csb_writel(tegra, code_size_blocks, XUSB_FALC_IMFILLCTL);
978 csb_writel(tegra, value, XUSB_FALC_IMFILLRNG1);
980 csb_writel(tegra, 0, XUSB_FALC_DMACTL);
983 #define tegra_csb_readl(offset) csb_readl(tegra, offset)
993 csb_writel(tegra, le32_to_cpu(header->boot_codetag),
997 csb_writel(tegra, CPUCTL_STARTCPU, XUSB_FALC_CPUCTL);
1011 value = csb_readl(tegra, XUSB_FALC_CPUCTL);
1027 struct tegra_xusb *tegra)
1029 if (tegra->genpd_dl_ss)
1030 device_link_del(tegra->genpd_dl_ss);
1031 if (tegra->genpd_dl_host)
1032 device_link_del(tegra->genpd_dl_host);
1033 if (!IS_ERR_OR_NULL(tegra->genpd_dev_ss))
1034 dev_pm_domain_detach(tegra->genpd_dev_ss, true);
1035 if (!IS_ERR_OR_NULL(tegra->genpd_dev_host))
1036 dev_pm_domain_detach(tegra->genpd_dev_host, true);
1040 struct tegra_xusb *tegra)
1044 tegra->genpd_dev_host = dev_pm_domain_attach_by_name(dev, "xusb_host");
1045 if (IS_ERR(tegra->genpd_dev_host)) {
1046 err = PTR_ERR(tegra->genpd_dev_host);
1051 tegra->genpd_dev_ss = dev_pm_domain_attach_by_name(dev, "xusb_ss");
1052 if (IS_ERR(tegra->genpd_dev_ss)) {
1053 err = PTR_ERR(tegra->genpd_dev_ss);
1058 tegra->genpd_dl_host = device_link_add(dev, tegra->genpd_dev_host,
1061 if (!tegra->genpd_dl_host) {
1066 tegra->genpd_dl_ss = device_link_add(dev, tegra->genpd_dev_ss,
1069 if (!tegra->genpd_dl_ss) {
1077 static int __tegra_xusb_enable_firmware_messages(struct tegra_xusb *tegra)
1086 err = tegra_xusb_mbox_send(tegra, &msg);
1088 dev_err(tegra->dev, "failed to enable messages: %d\n", err);
1093 static int tegra_xusb_enable_firmware_messages(struct tegra_xusb *tegra)
1097 mutex_lock(&tegra->lock);
1098 err = __tegra_xusb_enable_firmware_messages(tegra);
1099 mutex_unlock(&tegra->lock);
1104 static void tegra_xhci_set_port_power(struct tegra_xusb *tegra, bool main,
1107 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd);
1111 u16 wIndex = main ? tegra->otg_usb2_port + 1 : tegra->otg_usb3_port + 1;
1116 dev_dbg(tegra->dev, "%s():%s %s port power\n", __func__,
1135 dev_info(tegra->dev, "failed to %s %s PP %d\n",
1140 static struct phy *tegra_xusb_get_phy(struct tegra_xusb *tegra, char *name,
1145 for (i = 0; i < tegra->soc->num_types; i++) {
1146 if (!strncmp(tegra->soc->phy_types[i].name, name,
1148 return tegra->phys[phy_count+port];
1150 phy_count += tegra->soc->phy_types[i].num;
1158 struct tegra_xusb *tegra = container_of(work, struct tegra_xusb,
1160 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd);
1162 struct phy *phy = tegra_xusb_get_phy(tegra, "usb2",
1163 tegra->otg_usb2_port);
1167 dev_dbg(tegra->dev, "host mode %s\n", tegra->host_mode ? "on" : "off");
1169 mutex_lock(&tegra->lock);
1171 if (tegra->host_mode)
1176 mutex_unlock(&tegra->lock);
1178 tegra->otg_usb3_port = tegra_xusb_padctl_get_usb3_companion(tegra->padctl,
1179 tegra->otg_usb2_port);
1181 if (tegra->host_mode) {
1183 if (tegra->otg_usb3_port >= 0) {
1184 if (tegra->soc->otg_reset_sspi) {
1188 0, tegra->otg_usb3_port+1,
1191 tegra_xhci_set_port_power(tegra, false,
1196 msg.data = tegra->otg_usb3_port+1;
1198 ret = tegra_xusb_mbox_send(tegra, &msg);
1200 dev_info(tegra->dev,
1206 tegra_xhci_set_port_power(tegra, false, true);
1209 tegra_xhci_set_port_power(tegra, true, true);
1212 if (tegra->otg_usb3_port >= 0)
1213 tegra_xhci_set_port_power(tegra, false, false);
1215 tegra_xhci_set_port_power(tegra, true, false);
1219 static int tegra_xusb_get_usb2_port(struct tegra_xusb *tegra,
1224 for (i = 0; i < tegra->num_usb_phys; i++) {
1225 if (tegra->usbphy[i] && usbphy == tegra->usbphy[i])
1235 struct tegra_xusb *tegra = container_of(nb, struct tegra_xusb,
1239 dev_dbg(tegra->dev, "%s(): action is %d", __func__, usbphy->last_event);
1241 if ((tegra->host_mode && usbphy->last_event == USB_EVENT_ID) ||
1242 (!tegra->host_mode && usbphy->last_event != USB_EVENT_ID)) {
1243 dev_dbg(tegra->dev, "Same role(%d) received. Ignore",
1244 tegra->host_mode);
1248 tegra->otg_usb2_port = tegra_xusb_get_usb2_port(tegra, usbphy);
1250 tegra->host_mode = (usbphy->last_event == USB_EVENT_ID) ? true : false;
1252 schedule_work(&tegra->id_work);
1257 static int tegra_xusb_init_usb_phy(struct tegra_xusb *tegra)
1261 tegra->usbphy = devm_kcalloc(tegra->dev, tegra->num_usb_phys,
1262 sizeof(*tegra->usbphy), GFP_KERNEL);
1263 if (!tegra->usbphy)
1266 INIT_WORK(&tegra->id_work, tegra_xhci_id_work);
1267 tegra->id_nb.notifier_call = tegra_xhci_id_notify;
1268 tegra->otg_usb2_port = -EINVAL;
1269 tegra->otg_usb3_port = -EINVAL;
1271 for (i = 0; i < tegra->num_usb_phys; i++) {
1272 struct phy *phy = tegra_xusb_get_phy(tegra, "usb2", i);
1277 tegra->usbphy[i] = devm_usb_get_phy_by_node(tegra->dev,
1279 &tegra->id_nb);
1280 if (!IS_ERR(tegra->usbphy[i])) {
1281 dev_dbg(tegra->dev, "usbphy-%d registered", i);
1282 otg_set_host(tegra->usbphy[i]->otg, &tegra->hcd->self);
1287 tegra->usbphy[i] = NULL;
1294 static void tegra_xusb_deinit_usb_phy(struct tegra_xusb *tegra)
1298 cancel_work_sync(&tegra->id_work);
1300 for (i = 0; i < tegra->num_usb_phys; i++)
1301 if (tegra->usbphy[i])
1302 otg_set_host(tegra->usbphy[i]->otg, NULL);
1307 struct tegra_xusb *tegra;
1316 tegra = devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL);
1317 if (!tegra)
1320 tegra->soc = of_device_get_match_data(&pdev->dev);
1321 mutex_init(&tegra->lock);
1322 tegra->dev = &pdev->dev;
1324 err = tegra_xusb_init_context(tegra);
1329 tegra->regs = devm_ioremap_resource(&pdev->dev, regs);
1330 if (IS_ERR(tegra->regs))
1331 return PTR_ERR(tegra->regs);
1333 tegra->fpci_base = devm_platform_ioremap_resource(pdev, 1);
1334 if (IS_ERR(tegra->fpci_base))
1335 return PTR_ERR(tegra->fpci_base);
1337 if (tegra->soc->has_ipfs) {
1338 tegra->ipfs_base = devm_platform_ioremap_resource(pdev, 2);
1339 if (IS_ERR(tegra->ipfs_base))
1340 return PTR_ERR(tegra->ipfs_base);
1343 tegra->xhci_irq = platform_get_irq(pdev, 0);
1344 if (tegra->xhci_irq < 0)
1345 return tegra->xhci_irq;
1347 tegra->mbox_irq = platform_get_irq(pdev, 1);
1348 if (tegra->mbox_irq < 0)
1349 return tegra->mbox_irq;
1351 tegra->padctl = tegra_xusb_padctl_get(&pdev->dev);
1352 if (IS_ERR(tegra->padctl))
1353 return PTR_ERR(tegra->padctl);
1355 tegra->host_clk = devm_clk_get(&pdev->dev, "xusb_host");
1356 if (IS_ERR(tegra->host_clk)) {
1357 err = PTR_ERR(tegra->host_clk);
1362 tegra->falcon_clk = devm_clk_get(&pdev->dev, "xusb_falcon_src");
1363 if (IS_ERR(tegra->falcon_clk)) {
1364 err = PTR_ERR(tegra->falcon_clk);
1369 tegra->ss_clk = devm_clk_get(&pdev->dev, "xusb_ss");
1370 if (IS_ERR(tegra->ss_clk)) {
1371 err = PTR_ERR(tegra->ss_clk);
1376 tegra->ss_src_clk = devm_clk_get(&pdev->dev, "xusb_ss_src");
1377 if (IS_ERR(tegra->ss_src_clk)) {
1378 err = PTR_ERR(tegra->ss_src_clk);
1383 tegra->hs_src_clk = devm_clk_get(&pdev->dev, "xusb_hs_src");
1384 if (IS_ERR(tegra->hs_src_clk)) {
1385 err = PTR_ERR(tegra->hs_src_clk);
1390 tegra->fs_src_clk = devm_clk_get(&pdev->dev, "xusb_fs_src");
1391 if (IS_ERR(tegra->fs_src_clk)) {
1392 err = PTR_ERR(tegra->fs_src_clk);
1397 tegra->pll_u_480m = devm_clk_get(&pdev->dev, "pll_u_480m");
1398 if (IS_ERR(tegra->pll_u_480m)) {
1399 err = PTR_ERR(tegra->pll_u_480m);
1404 tegra->clk_m = devm_clk_get(&pdev->dev, "clk_m");
1405 if (IS_ERR(tegra->clk_m)) {
1406 err = PTR_ERR(tegra->clk_m);
1411 tegra->pll_e = devm_clk_get(&pdev->dev, "pll_e");
1412 if (IS_ERR(tegra->pll_e)) {
1413 err = PTR_ERR(tegra->pll_e);
1419 tegra->host_rst = devm_reset_control_get(&pdev->dev,
1421 if (IS_ERR(tegra->host_rst)) {
1422 err = PTR_ERR(tegra->host_rst);
1428 tegra->ss_rst = devm_reset_control_get(&pdev->dev, "xusb_ss");
1429 if (IS_ERR(tegra->ss_rst)) {
1430 err = PTR_ERR(tegra->ss_rst);
1437 tegra->ss_clk,
1438 tegra->ss_rst);
1446 tegra->host_clk,
1447 tegra->host_rst);
1455 err = tegra_xusb_powerdomain_init(&pdev->dev, tegra);
1460 tegra->supplies = devm_kcalloc(&pdev->dev, tegra->soc->num_supplies,
1461 sizeof(*tegra->supplies), GFP_KERNEL);
1462 if (!tegra->supplies) {
1467 regulator_bulk_set_supply_names(tegra->supplies,
1468 tegra->soc->supply_names,
1469 tegra->soc->num_supplies);
1471 err = devm_regulator_bulk_get(&pdev->dev, tegra->soc->num_supplies,
1472 tegra->supplies);
1478 for (i = 0; i < tegra->soc->num_types; i++) {
1479 if (!strncmp(tegra->soc->phy_types[i].name, "usb2", 4))
1480 tegra->num_usb_phys = tegra->soc->phy_types[i].num;
1481 tegra->num_phys += tegra->soc->phy_types[i].num;
1484 tegra->phys = devm_kcalloc(&pdev->dev, tegra->num_phys,
1485 sizeof(*tegra->phys), GFP_KERNEL);
1486 if (!tegra->phys) {
1491 for (i = 0, k = 0; i < tegra->soc->num_types; i++) {
1494 for (j = 0; j < tegra->soc->phy_types[i].num; j++) {
1496 tegra->soc->phy_types[i].name, j);
1507 tegra->phys[k++] = phy;
1511 tegra->hcd = usb_create_hcd(&tegra_xhci_hc_driver, &pdev->dev,
1513 if (!tegra->hcd) {
1518 tegra->hcd->regs = tegra->regs;
1519 tegra->hcd->rsrc_start = regs->start;
1520 tegra->hcd->rsrc_len = resource_size(regs);
1526 platform_set_drvdata(pdev, tegra);
1528 err = tegra_xusb_phy_enable(tegra);
1538 err = dma_set_mask_and_coherent(tegra->dev, DMA_BIT_MASK(40));
1544 err = tegra_xusb_request_firmware(tegra);
1562 tegra_xusb_config(tegra);
1564 err = tegra_xusb_load_firmware(tegra);
1570 err = usb_add_hcd(tegra->hcd, tegra->xhci_irq, IRQF_SHARED);
1576 device_wakeup_enable(tegra->hcd->self.controller);
1578 xhci = hcd_to_xhci(tegra->hcd);
1583 tegra->hcd);
1590 err = usb_add_hcd(xhci->shared_hcd, tegra->xhci_irq, IRQF_SHARED);
1596 err = tegra_xusb_enable_firmware_messages(tegra);
1602 err = devm_request_threaded_irq(&pdev->dev, tegra->mbox_irq,
1605 dev_name(&pdev->dev), tegra);
1611 err = tegra_xusb_init_usb_phy(tegra);
1624 usb_remove_hcd(tegra->hcd);
1629 usb_put_hcd(tegra->hcd);
1631 dma_free_coherent(&pdev->dev, tegra->fw.size, tegra->fw.virt,
1632 tegra->fw.phys);
1634 tegra_xusb_phy_disable(tegra);
1641 tegra_xusb_powerdomain_remove(&pdev->dev, tegra);
1644 tegra_xusb_padctl_put(tegra->padctl);
1650 struct tegra_xusb *tegra = platform_get_drvdata(pdev);
1651 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd);
1653 tegra_xusb_deinit_usb_phy(tegra);
1658 usb_remove_hcd(tegra->hcd);
1659 usb_put_hcd(tegra->hcd);
1661 dma_free_coherent(&pdev->dev, tegra->fw.size, tegra->fw.virt,
1662 tegra->fw.phys);
1671 tegra_xusb_powerdomain_remove(&pdev->dev, tegra);
1674 tegra_xusb_phy_disable(tegra);
1676 tegra_xusb_padctl_put(tegra->padctl);
1704 static int tegra_xusb_check_ports(struct tegra_xusb *tegra)
1706 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd);
1721 static void tegra_xusb_save_context(struct tegra_xusb *tegra)
1723 const struct tegra_xusb_context_soc *soc = tegra->soc->context;
1724 struct tegra_xusb_context *ctx = &tegra->context;
1729 ctx->ipfs[i] = ipfs_readl(tegra, soc->ipfs.offsets[i]);
1734 ctx->fpci[i] = fpci_readl(tegra, soc->fpci.offsets[i]);
1738 static void tegra_xusb_restore_context(struct tegra_xusb *tegra)
1740 const struct tegra_xusb_context_soc *soc = tegra->soc->context;
1741 struct tegra_xusb_context *ctx = &tegra->context;
1746 fpci_writel(tegra, ctx->fpci[i], soc->fpci.offsets[i]);
1751 ipfs_writel(tegra, ctx->ipfs[i], soc->ipfs.offsets[i]);
1755 static int tegra_xusb_enter_elpg(struct tegra_xusb *tegra, bool wakeup)
1757 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd);
1760 err = tegra_xusb_check_ports(tegra);
1762 dev_err(tegra->dev, "not all ports suspended: %d\n", err);
1768 dev_err(tegra->dev, "failed to suspend XHCI: %d\n", err);
1772 tegra_xusb_save_context(tegra);
1773 tegra_xusb_phy_disable(tegra);
1774 tegra_xusb_clk_disable(tegra);
1779 static int tegra_xusb_exit_elpg(struct tegra_xusb *tegra, bool wakeup)
1781 struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd);
1784 err = tegra_xusb_clk_enable(tegra);
1786 dev_err(tegra->dev, "failed to enable clocks: %d\n", err);
1790 err = tegra_xusb_phy_enable(tegra);
1792 dev_err(tegra->dev, "failed to enable PHYs: %d\n", err);
1796 tegra_xusb_config(tegra);
1797 tegra_xusb_restore_context(tegra);
1799 err = tegra_xusb_load_firmware(tegra);
1801 dev_err(tegra->dev, "failed to load firmware: %d\n", err);
1805 err = __tegra_xusb_enable_firmware_messages(tegra);
1807 dev_err(tegra->dev, "failed to enable messages: %d\n", err);
1813 dev_err(tegra->dev, "failed to resume XHCI: %d\n", err);
1820 tegra_xusb_phy_disable(tegra);
1822 tegra_xusb_clk_disable(tegra);
1828 struct tegra_xusb *tegra = dev_get_drvdata(dev);
1832 synchronize_irq(tegra->mbox_irq);
1834 mutex_lock(&tegra->lock);
1835 err = tegra_xusb_enter_elpg(tegra, wakeup);
1836 mutex_unlock(&tegra->lock);
1843 struct tegra_xusb *tegra = dev_get_drvdata(dev);
1847 mutex_lock(&tegra->lock);
1848 err = tegra_xusb_exit_elpg(tegra, wakeup);
1849 mutex_unlock(&tegra->lock);
2056 .name = "tegra-xusb",
2064 struct tegra_xusb *tegra = dev_get_drvdata(dev);
2067 if (tegra && tegra->soc->lpm_support)