Lines Matching full:bus
2 * Linux DHD Bus Module for PCIE
96 dhd_bus_t *bus; member
169 static int dhdpcie_set_suspend_resume(dhd_bus_t *bus, bool state);
171 static int dhdpcie_resume_host_dev(dhd_bus_t *bus);
172 static int dhdpcie_suspend_host_dev(dhd_bus_t *bus);
197 static void dhdpcie_config_save_restore_coherent(dhd_bus_t *bus, bool state);
372 dhd_bus_get_tpoweron(dhd_bus_t *bus) in dhd_bus_get_tpoweron() argument
378 tpoweron_rc = dhdpcie_rc_access_cap(bus, PCIE_EXTCAP_ID_L1SS, in dhd_bus_get_tpoweron()
380 tpoweron_ep = dhdpcie_ep_access_cap(bus, PCIE_EXTCAP_ID_L1SS, in dhd_bus_get_tpoweron()
387 dhd_bus_set_tpoweron(dhd_bus_t *bus, uint16 tpoweron) in dhd_bus_set_tpoweron() argument
390 dhd_bus_get_tpoweron(bus); in dhd_bus_set_tpoweron()
393 dhdpcie_rc_access_cap(bus, PCIE_EXTCAP_ID_L1SS, in dhd_bus_set_tpoweron()
395 dhdpcie_ep_access_cap(bus, PCIE_EXTCAP_ID_L1SS, in dhd_bus_set_tpoweron()
398 dhd_bus_get_tpoweron(bus); in dhd_bus_set_tpoweron()
403 dhdpcie_chip_req_forced_tpoweron(dhd_bus_t *bus) in dhdpcie_chip_req_forced_tpoweron() argument
413 if (si_chipid(bus->sih) == BCM4377_CHIP_ID) { in dhdpcie_chip_req_forced_tpoweron()
421 dhd_bus_aspm_enable_dev(dhd_bus_t *bus, struct pci_dev *dev, bool enable) in dhd_bus_aspm_enable_dev() argument
428 device = (dev == bus->dev) ? "EP" : "RC"; in dhd_bus_aspm_enable_dev()
464 dhd_bus_is_rc_ep_aspm_capable(dhd_bus_t *bus) in dhd_bus_is_rc_ep_aspm_capable() argument
470 rc_aspm_cap = dhdpcie_access_cap(bus->rc_dev, PCIE_CAP_ID_EXP, PCIE_CAP_LINKCTRL_OFFSET, in dhd_bus_is_rc_ep_aspm_capable()
478 ep_aspm_cap = dhdpcie_access_cap(bus->dev, PCIE_CAP_ID_EXP, PCIE_CAP_LINKCTRL_OFFSET, in dhd_bus_is_rc_ep_aspm_capable()
489 dhd_bus_aspm_enable_rc_ep(dhd_bus_t *bus, bool enable) in dhd_bus_aspm_enable_rc_ep() argument
493 if (!bus->rc_ep_aspm_cap) { in dhd_bus_aspm_enable_rc_ep()
495 __FUNCTION__, bus->rc_ep_aspm_cap)); in dhd_bus_aspm_enable_rc_ep()
501 ret = dhd_bus_aspm_enable_dev(bus, bus->rc_dev, enable); in dhd_bus_aspm_enable_rc_ep()
502 ret = dhd_bus_aspm_enable_dev(bus, bus->dev, enable); in dhd_bus_aspm_enable_rc_ep()
505 ret = dhd_bus_aspm_enable_dev(bus, bus->dev, enable); in dhd_bus_aspm_enable_rc_ep()
506 ret = dhd_bus_aspm_enable_dev(bus, bus->rc_dev, enable); in dhd_bus_aspm_enable_rc_ep()
513 dhd_bus_l1ss_enable_dev(dhd_bus_t *bus, struct pci_dev *dev, bool enable) in dhd_bus_l1ss_enable_dev() argument
520 device = (dev == bus->dev) ? "EP" : "RC"; in dhd_bus_l1ss_enable_dev()
553 dhd_bus_is_rc_ep_l1ss_capable(dhd_bus_t *bus) in dhd_bus_is_rc_ep_l1ss_capable() argument
559 rc_l1ss_cap = dhdpcie_access_cap(bus->rc_dev, PCIE_EXTCAP_ID_L1SS, in dhd_bus_is_rc_ep_l1ss_capable()
567 ep_l1ss_cap = dhdpcie_access_cap(bus->dev, PCIE_EXTCAP_ID_L1SS, in dhd_bus_is_rc_ep_l1ss_capable()
578 dhd_bus_l1ss_enable_rc_ep(dhd_bus_t *bus, bool enable) in dhd_bus_l1ss_enable_rc_ep() argument
582 if ((!bus->rc_ep_aspm_cap) || (!bus->rc_ep_l1ss_cap)) { in dhd_bus_l1ss_enable_rc_ep()
584 __FUNCTION__, bus->rc_ep_aspm_cap, bus->rc_ep_l1ss_cap)); in dhd_bus_l1ss_enable_rc_ep()
589 ret = dhd_bus_aspm_enable_rc_ep(bus, FALSE); in dhd_bus_l1ss_enable_rc_ep()
593 dhd_bus_l1ss_enable_dev(bus, bus->rc_dev, enable); in dhd_bus_l1ss_enable_rc_ep()
594 dhd_bus_l1ss_enable_dev(bus, bus->dev, enable); in dhd_bus_l1ss_enable_rc_ep()
597 dhd_bus_l1ss_enable_dev(bus, bus->dev, enable); in dhd_bus_l1ss_enable_rc_ep()
598 dhd_bus_l1ss_enable_dev(bus, bus->rc_dev, enable); in dhd_bus_l1ss_enable_rc_ep()
603 dhd_bus_aspm_enable_rc_ep(bus, TRUE); in dhd_bus_l1ss_enable_rc_ep()
608 dhd_bus_aer_config(dhd_bus_t *bus) in dhd_bus_aer_config() argument
613 val = dhdpcie_ep_access_cap(bus, PCIE_ADVERRREP_CAPID, in dhd_bus_aer_config()
617 dhdpcie_ep_access_cap(bus, PCIE_ADVERRREP_CAPID, in dhd_bus_aer_config()
625 val = dhdpcie_rc_access_cap(bus, PCIE_ADVERRREP_CAPID, in dhd_bus_aer_config()
629 dhdpcie_rc_access_cap(bus, PCIE_ADVERRREP_CAPID, in dhd_bus_aer_config()
643 dhd_bus_t *bus = NULL; in dhdpcie_pm_suspend() local
647 bus = pch->bus; in dhdpcie_pm_suspend()
649 if (!bus) { in dhdpcie_pm_suspend()
653 DHD_GENERAL_LOCK(bus->dhd, flags); in dhdpcie_pm_suspend()
654 if (!DHD_BUS_BUSY_CHECK_IDLE(bus->dhd)) { in dhdpcie_pm_suspend()
655 DHD_ERROR(("%s: Bus not IDLE!! dhd_bus_busy_state = 0x%x\n", in dhdpcie_pm_suspend()
656 __FUNCTION__, bus->dhd->dhd_bus_busy_state)); in dhdpcie_pm_suspend()
657 DHD_GENERAL_UNLOCK(bus->dhd, flags); in dhdpcie_pm_suspend()
660 DHD_BUS_BUSY_SET_SUSPEND_IN_PROGRESS(bus->dhd); in dhdpcie_pm_suspend()
661 DHD_GENERAL_UNLOCK(bus->dhd, flags); in dhdpcie_pm_suspend()
663 if (!bus->dhd->dongle_reset) in dhdpcie_pm_suspend()
664 ret = dhdpcie_set_suspend_resume(bus, TRUE); in dhdpcie_pm_suspend()
666 DHD_GENERAL_LOCK(bus->dhd, flags); in dhdpcie_pm_suspend()
667 DHD_BUS_BUSY_CLEAR_SUSPEND_IN_PROGRESS(bus->dhd); in dhdpcie_pm_suspend()
668 dhd_os_busbusy_wake(bus->dhd); in dhdpcie_pm_suspend()
669 DHD_GENERAL_UNLOCK(bus->dhd, flags); in dhdpcie_pm_suspend()
679 dhd_bus_t *bus = NULL; in dhdpcie_pm_prepare() local
681 if (!pch || !pch->bus) { in dhdpcie_pm_prepare()
685 bus = pch->bus; in dhdpcie_pm_prepare()
686 DHD_DISABLE_RUNTIME_PM(bus->dhd); in dhdpcie_pm_prepare()
687 bus->chk_pm = TRUE; in dhdpcie_pm_prepare()
697 dhd_bus_t *bus = NULL; in dhdpcie_pm_resume() local
701 bus = pch->bus; in dhdpcie_pm_resume()
703 if (!bus) { in dhdpcie_pm_resume()
707 DHD_GENERAL_LOCK(bus->dhd, flags); in dhdpcie_pm_resume()
708 DHD_BUS_BUSY_SET_RESUME_IN_PROGRESS(bus->dhd); in dhdpcie_pm_resume()
709 DHD_GENERAL_UNLOCK(bus->dhd, flags); in dhdpcie_pm_resume()
711 if (!bus->dhd->dongle_reset) in dhdpcie_pm_resume()
712 ret = dhdpcie_set_suspend_resume(bus, FALSE); in dhdpcie_pm_resume()
714 DHD_GENERAL_LOCK(bus->dhd, flags); in dhdpcie_pm_resume()
715 DHD_BUS_BUSY_CLEAR_RESUME_IN_PROGRESS(bus->dhd); in dhdpcie_pm_resume()
716 dhd_os_busbusy_wake(bus->dhd); in dhdpcie_pm_resume()
717 DHD_GENERAL_UNLOCK(bus->dhd, flags); in dhdpcie_pm_resume()
726 dhd_bus_t *bus = NULL; in dhdpcie_pm_complete() local
728 if (!pch || !pch->bus) { in dhdpcie_pm_complete()
732 bus = pch->bus; in dhdpcie_pm_complete()
733 DHD_ENABLE_RUNTIME_PM(bus->dhd); in dhdpcie_pm_complete()
734 bus->chk_pm = FALSE; in dhdpcie_pm_complete()
743 dhd_bus_t *bus = NULL; in dhdpcie_pci_suspend() local
747 bus = pch->bus; in dhdpcie_pci_suspend()
749 if (!bus) { in dhdpcie_pci_suspend()
755 DHD_GENERAL_LOCK(bus->dhd, flags); in dhdpcie_pci_suspend()
756 if (!DHD_BUS_BUSY_CHECK_IDLE(bus->dhd)) { in dhdpcie_pci_suspend()
757 DHD_ERROR(("%s: Bus not IDLE!! dhd_bus_busy_state = 0x%x\n", in dhdpcie_pci_suspend()
758 __FUNCTION__, bus->dhd->dhd_bus_busy_state)); in dhdpcie_pci_suspend()
759 DHD_GENERAL_UNLOCK(bus->dhd, flags); in dhdpcie_pci_suspend()
762 DHD_BUS_BUSY_SET_SUSPEND_IN_PROGRESS(bus->dhd); in dhdpcie_pci_suspend()
763 DHD_GENERAL_UNLOCK(bus->dhd, flags); in dhdpcie_pci_suspend()
765 if (!bus->dhd->dongle_reset) in dhdpcie_pci_suspend()
766 ret = dhdpcie_set_suspend_resume(bus, TRUE); in dhdpcie_pci_suspend()
768 DHD_GENERAL_LOCK(bus->dhd, flags); in dhdpcie_pci_suspend()
769 DHD_BUS_BUSY_CLEAR_SUSPEND_IN_PROGRESS(bus->dhd); in dhdpcie_pci_suspend()
770 dhd_os_busbusy_wake(bus->dhd); in dhdpcie_pci_suspend()
771 DHD_GENERAL_UNLOCK(bus->dhd, flags); in dhdpcie_pci_suspend()
780 dhd_bus_t *bus = NULL; in dhdpcie_pci_resume() local
784 bus = pch->bus; in dhdpcie_pci_resume()
786 if (!bus) { in dhdpcie_pci_resume()
790 DHD_GENERAL_LOCK(bus->dhd, flags); in dhdpcie_pci_resume()
791 DHD_BUS_BUSY_SET_RESUME_IN_PROGRESS(bus->dhd); in dhdpcie_pci_resume()
792 DHD_GENERAL_UNLOCK(bus->dhd, flags); in dhdpcie_pci_resume()
794 if (!bus->dhd->dongle_reset) in dhdpcie_pci_resume()
795 ret = dhdpcie_set_suspend_resume(bus, FALSE); in dhdpcie_pci_resume()
797 DHD_GENERAL_LOCK(bus->dhd, flags); in dhdpcie_pci_resume()
798 DHD_BUS_BUSY_CLEAR_RESUME_IN_PROGRESS(bus->dhd); in dhdpcie_pci_resume()
799 dhd_os_busbusy_wake(bus->dhd); in dhdpcie_pci_resume()
800 DHD_GENERAL_UNLOCK(bus->dhd, flags); in dhdpcie_pci_resume()
807 static int dhdpcie_set_suspend_resume(dhd_bus_t *bus, bool state, bool byint) in dhdpcie_set_suspend_resume() argument
809 static int dhdpcie_set_suspend_resume(dhd_bus_t *bus, bool state) in dhdpcie_set_suspend_resume()
814 ASSERT(bus && !bus->dhd->dongle_reset); in dhdpcie_set_suspend_resume()
818 if (state == TRUE && dhd_os_check_wakelock_all(bus->dhd)) { in dhdpcie_set_suspend_resume()
821 mutex_lock(&bus->pm_lock); in dhdpcie_set_suspend_resume()
824 /* When firmware is not loaded do the PCI bus */ in dhdpcie_set_suspend_resume()
826 if (bus->dhd->busstate == DHD_BUS_DOWN) { in dhdpcie_set_suspend_resume()
827 ret = dhdpcie_pci_suspend_resume(bus, state); in dhdpcie_set_suspend_resume()
829 mutex_unlock(&bus->pm_lock); in dhdpcie_set_suspend_resume()
834 ret = dhdpcie_bus_suspend(bus, state, byint); in dhdpcie_set_suspend_resume()
836 ret = dhdpcie_bus_suspend(bus, state); in dhdpcie_set_suspend_resume()
840 mutex_unlock(&bus->pm_lock); in dhdpcie_set_suspend_resume()
851 dhd_bus_t *bus = NULL; in dhdpcie_pm_runtime_suspend() local
857 bus = pch->bus; in dhdpcie_pm_runtime_suspend()
861 if (atomic_read(&bus->dhd->block_bus)) in dhdpcie_pm_runtime_suspend()
864 dhd_netif_stop_queue(bus); in dhdpcie_pm_runtime_suspend()
865 atomic_set(&bus->dhd->block_bus, TRUE); in dhdpcie_pm_runtime_suspend()
872 atomic_set(&bus->dhd->block_bus, FALSE); in dhdpcie_pm_runtime_suspend()
873 dhd_bus_start_queue(bus); in dhdpcie_pm_runtime_suspend()
882 dhd_bus_t *bus = pch->bus; in dhdpcie_pm_runtime_resume() local
886 if (atomic_read(&bus->dhd->block_bus)) in dhdpcie_pm_runtime_resume()
899 dhd_bus_t *bus = NULL; in dhdpcie_pm_system_suspend_noirq() local
907 bus = pch->bus; in dhdpcie_pm_system_suspend_noirq()
909 if (atomic_read(&bus->dhd->block_bus)) in dhdpcie_pm_system_suspend_noirq()
912 dhd_netif_stop_queue(bus); in dhdpcie_pm_system_suspend_noirq()
913 atomic_set(&bus->dhd->block_bus, TRUE); in dhdpcie_pm_system_suspend_noirq()
918 dhd_bus_start_queue(bus); in dhdpcie_pm_system_suspend_noirq()
919 atomic_set(&bus->dhd->block_bus, FALSE); in dhdpcie_pm_system_suspend_noirq()
929 dhd_bus_t *bus = NULL; in dhdpcie_pm_system_resume_noirq() local
935 bus = pch->bus; in dhdpcie_pm_system_resume_noirq()
941 atomic_set(&bus->dhd->block_bus, FALSE); in dhdpcie_pm_system_resume_noirq()
942 dhd_bus_start_queue(bus); in dhdpcie_pm_system_resume_noirq()
943 pm_runtime_mark_last_busy(dhd_bus_to_dev(bus)); in dhdpcie_pm_system_resume_noirq()
954 dhdpcie_suspend_dump_cfgregs(struct dhd_bus *bus, char *suspend_state) in dhdpcie_suspend_dump_cfgregs() argument
960 dhd_pcie_config_read(bus->osh, in dhdpcie_suspend_dump_cfgregs()
963 dhd_pcie_config_read(bus->osh, in dhdpcie_suspend_dump_cfgregs()
966 dhd_pcie_config_read(bus->osh, in dhdpcie_suspend_dump_cfgregs()
974 dhd_bus_t *bus = pch->bus; in dhdpcie_suspend_dev() local
977 if (bus->is_linkdown) { in dhdpcie_suspend_dev()
983 dhdpcie_suspend_dump_cfgregs(bus, "BEFORE_EP_SUSPEND"); in dhdpcie_suspend_dev()
985 dhd_dpc_tasklet_kill(bus->dhd); in dhdpcie_suspend_dev()
1003 dhdpcie_suspend_dump_cfgregs(bus, "AFTER_EP_SUSPEND"); in dhdpcie_suspend_dev()
1008 int bcmpcie_get_total_wake(struct dhd_bus *bus) in bcmpcie_get_total_wake() argument
1010 dhdpcie_info_t *pch = pci_get_drvdata(bus->dev); in bcmpcie_get_total_wake()
1015 int bcmpcie_set_get_wake(struct dhd_bus *bus, int flag) in bcmpcie_set_get_wake() argument
1017 dhdpcie_info_t *pch = pci_get_drvdata(bus->dev); in bcmpcie_set_get_wake()
1045 if (dhdpcie_chip_req_forced_tpoweron(pch->bus)) { in dhdpcie_resume_dev()
1046 dhd_bus_set_tpoweron(pch->bus, tpoweron_scale); in dhdpcie_resume_dev()
1061 dhdpcie_suspend_dump_cfgregs(pch->bus, "AFTER_EP_RESUME"); in dhdpcie_resume_dev()
1066 static int dhdpcie_resume_host_dev(dhd_bus_t *bus) in dhdpcie_resume_host_dev() argument
1073 bcmerror = dhdpcie_start_host_pcieclock(bus); in dhdpcie_resume_host_dev()
1083 bus->is_linkdown = 1; in dhdpcie_resume_host_dev()
1086 bus->no_cfg_restore = 1; in dhdpcie_resume_host_dev()
1094 static int dhdpcie_suspend_host_dev(dhd_bus_t *bus) in dhdpcie_suspend_host_dev() argument
1098 if (bus->rc_dev) { in dhdpcie_suspend_host_dev()
1099 pci_save_state(bus->rc_dev); in dhdpcie_suspend_host_dev()
1107 bcmerror = dhdpcie_stop_host_pcieclock(bus); in dhdpcie_suspend_host_dev()
1123 * @bus: dhd bus context
1127 dhdpcie_os_setbar1win(dhd_bus_t *bus, uint32 addr) in dhdpcie_os_setbar1win() argument
1129 dhdpcie_info_t *pch = pci_get_drvdata(bus->dev); in dhdpcie_os_setbar1win()
1131 osl_pci_write_config(bus->osh, PCI_BAR1_WIN, 4, addr); in dhdpcie_os_setbar1win()
1141 * @bus: dhd bus context
1156 dhdpcie_os_setbar1win(pch->bus, bpwin); in dhdpcie_os_chkbpoffset()
1166 dhdpcie_os_wtcm8(dhd_bus_t *bus, ulong offset, uint8 data) in dhdpcie_os_wtcm8() argument
1168 dhdpcie_info_t *pch = pci_get_drvdata(bus->dev); in dhdpcie_os_wtcm8()
1171 W_REG(bus->dhd->osh, (volatile uint8 *)(bus->tcm + offset), data); in dhdpcie_os_wtcm8()
1175 dhdpcie_os_rtcm8(dhd_bus_t *bus, ulong offset) in dhdpcie_os_rtcm8() argument
1178 dhdpcie_info_t *pch = pci_get_drvdata(bus->dev); in dhdpcie_os_rtcm8()
1181 data = R_REG(bus->dhd->osh, (volatile uint8 *)(bus->tcm + offset)); in dhdpcie_os_rtcm8()
1186 dhdpcie_os_wtcm16(dhd_bus_t *bus, ulong offset, uint16 data) in dhdpcie_os_wtcm16() argument
1188 dhdpcie_info_t *pch = pci_get_drvdata(bus->dev); in dhdpcie_os_wtcm16()
1191 W_REG(bus->dhd->osh, (volatile uint16 *)(bus->tcm + offset), data); in dhdpcie_os_wtcm16()
1195 dhdpcie_os_rtcm16(dhd_bus_t *bus, ulong offset) in dhdpcie_os_rtcm16() argument
1198 dhdpcie_info_t *pch = pci_get_drvdata(bus->dev); in dhdpcie_os_rtcm16()
1201 data = R_REG(bus->dhd->osh, (volatile uint16 *)(bus->tcm + offset)); in dhdpcie_os_rtcm16()
1206 dhdpcie_os_wtcm32(dhd_bus_t *bus, ulong offset, uint32 data) in dhdpcie_os_wtcm32() argument
1208 dhdpcie_info_t *pch = pci_get_drvdata(bus->dev); in dhdpcie_os_wtcm32()
1211 W_REG(bus->dhd->osh, (volatile uint32 *)(bus->tcm + offset), data); in dhdpcie_os_wtcm32()
1215 dhdpcie_os_rtcm32(dhd_bus_t *bus, ulong offset) in dhdpcie_os_rtcm32() argument
1218 dhdpcie_info_t *pch = pci_get_drvdata(bus->dev); in dhdpcie_os_rtcm32()
1221 data = R_REG(bus->dhd->osh, (volatile uint32 *)(bus->tcm + offset)); in dhdpcie_os_rtcm32()
1227 dhdpcie_os_wtcm64(dhd_bus_t *bus, ulong offset, uint64 data) in dhdpcie_os_wtcm64() argument
1229 dhdpcie_info_t *pch = pci_get_drvdata(bus->dev); in dhdpcie_os_wtcm64()
1232 W_REG(bus->dhd->osh, (volatile uint64 *)(bus->tcm + offset), data); in dhdpcie_os_wtcm64()
1236 dhdpcie_os_rtcm64(dhd_bus_t *bus, ulong offset) in dhdpcie_os_rtcm64() argument
1239 dhdpcie_info_t *pch = pci_get_drvdata(bus->dev); in dhdpcie_os_rtcm64()
1242 data = R_REG(bus->dhd->osh, (volatile uint64 *)(bus->tcm + offset)); in dhdpcie_os_rtcm64()
1248 dhdpcie_rc_config_read(dhd_bus_t *bus, uint offset) in dhdpcie_rc_config_read() argument
1251 if (bus->rc_dev) { in dhdpcie_rc_config_read()
1252 pci_read_config_dword(bus->rc_dev, offset, &val); in dhdpcie_rc_config_read()
1268 * @bus current dhd_bus_t pointer
1330 dhdpcie_rc_access_cap(dhd_bus_t *bus, int cap, uint offset, bool is_ext, bool is_write, in dhdpcie_rc_access_cap() argument
1333 if (!(bus->rc_dev)) { in dhdpcie_rc_access_cap()
1339 return dhdpcie_access_cap(bus->rc_dev, cap, offset, is_ext, is_write, writeval); in dhdpcie_rc_access_cap()
1343 dhdpcie_ep_access_cap(dhd_bus_t *bus, int cap, uint offset, bool is_ext, bool is_write, in dhdpcie_ep_access_cap() argument
1346 if (!(bus->dev)) { in dhdpcie_ep_access_cap()
1351 return dhdpcie_access_cap(bus->dev, cap, offset, is_ext, is_write, writeval); in dhdpcie_ep_access_cap()
1358 uint32 dhd_debug_get_rc_linkcap(dhd_bus_t *bus) in dhd_debug_get_rc_linkcap() argument
1361 linkcap = dhdpcie_rc_access_cap(bus, PCIE_CAP_ID_EXP, in dhd_debug_get_rc_linkcap()
1367 static void dhdpcie_config_save_restore_coherent(dhd_bus_t *bus, bool state) in dhdpcie_config_save_restore_coherent() argument
1369 if (bus->coreid == ARMCA7_CORE_ID) { in dhdpcie_config_save_restore_coherent()
1372 bus->coherent_state = dhdpcie_bus_cfg_read_dword(bus, in dhdpcie_config_save_restore_coherent()
1375 uint32 val = (dhdpcie_bus_cfg_read_dword(bus, PCIE_CFG_SUBSYSTEM_CONTROL, in dhdpcie_config_save_restore_coherent()
1376 4) & ~PCIE_BARCOHERENTACCEN_MASK) | bus->coherent_state; in dhdpcie_config_save_restore_coherent()
1377 dhdpcie_bus_cfg_write_dword(bus, PCIE_CFG_SUBSYSTEM_CONTROL, 4, val); in dhdpcie_config_save_restore_coherent()
1382 int dhdpcie_pci_suspend_resume(dhd_bus_t *bus, bool state) argument
1386 struct pci_dev *dev = bus->dev;
1389 dhdpcie_config_save_restore_coherent(bus, state);
1391 dhdpcie_pme_active(bus->osh, state);
1395 dhdpcie_suspend_host_dev(bus);
1398 rc = dhdpcie_resume_host_dev(bus);
1401 if (PCIECTO_ENAB(bus)) {
1405 dhdpcie_cto_cfg_init(bus, TRUE);
1407 if (PCIE_ENUM_RESET_WAR_ENAB(bus->sih->buscorerev)) {
1408 dhdpcie_ssreset_dis_enum_rst(bus);
1411 dhdpcie_pme_active(bus->osh, state);
1414 dhdpcie_config_save_restore_coherent(bus, state);
1417 if (bus->is_linkdown ||
1418 bus->dhd->req_hang_type == HANG_REASON_PCIE_RC_LINK_UP_FAIL) {
1420 if (bus->is_linkdown) {
1422 bus->dhd->hang_reason = HANG_REASON_PCIE_RC_LINK_UP_FAIL;
1423 dhd_os_send_hang_message(bus->dhd);
1465 bus_for_each_dev(dhdpcie_driver.driver.bus, NULL, &error, dhdpcie_device_scan);
1504 printf("PCI_PROBE: bus %X, slot %X,vendor %X, device %X"
1505 "(good PCI location)\n", pdev->bus->number,
1559 dhd_bus_t *bus = NULL; local
1563 bus = pch->bus;
1571 if (bus) {
1574 msm_pcie_deregister_event(&bus->pcie_event);
1579 exynos_pcie_deregister_event(&bus->pcie_event);
1586 bus->rc_dev = NULL;
1588 dhdpcie_bus_release(bus);
1594 msm_pcie_pm_control(MSM_PCIE_SUSPEND, pdev->bus->number, pdev, NULL, 0);
1654 dhd_bus_t *bus = dhdpcie_info->bus; local
1655 struct pci_dev *pdev = dhdpcie_info->bus->dev;
1658 if (!bus->irq_registered) {
1662 if (bus->d2h_intr_method == PCIE_MSI) {
1666 bus->d2h_intr_method = PCIE_INTX;
1671 dhdpcie_info->pciname, bus) < 0) {
1673 if (bus->d2h_intr_method == PCIE_MSI) {
1679 bus->irq_registered = TRUE;
1685 host_irq_disabled = dhdpcie_irq_disabled(bus);
1689 dhdpcie_enable_irq(bus);
1701 dhdpcie_get_pcieirq(struct dhd_bus *bus, unsigned int *irq) argument
1703 struct pci_dev *pdev = bus->dev;
1706 DHD_ERROR(("%s : bus->dev is NULL\n", __FUNCTION__));
1752 ret = msm_pcie_pm_control(MSM_PCIE_RESUME, pdev->bus->number,
1859 void dhdpcie_dump_resource(dhd_bus_t *bus) argument
1863 if (bus == NULL) {
1864 DHD_ERROR(("%s: bus is NULL\n", __FUNCTION__));
1868 if (bus->dev == NULL) {
1869 DHD_ERROR(("%s: bus->dev is NULL\n", __FUNCTION__));
1873 pch = pci_get_drvdata(bus->dev);
1881 __FUNCTION__, pch->regs, pci_resource_start(bus->dev, 0),
1886 __FUNCTION__, pch->tcm, pci_resource_start(bus->dev, 2),
1902 dhd_bus_t *bus = pch->bus; local
1903 if (bus) {
1904 dhd_pub_t *dhd = bus->dhd;
1910 bus->no_cfg_restore = 1;
1912 bus->is_linkdown = 1;
1932 dhd_bus_t *bus = NULL; local
1951 adapter = dhd_wifi_platform_get_adapter(PCI_BUS, pdev->bus->number,
2025 /* Bus initialization */
2026 ret = dhdpcie_bus_attach(osh, &bus, dhdpcie_info->regs, dhdpcie_info->tcm, pdev);
2032 dhdpcie_info->bus = bus;
2033 bus->is_linkdown = 0;
2034 bus->no_bus_init = FALSE;
2035 bus->cto_triggered = 0;
2037 bus->rc_dev = NULL;
2040 if (bus->dev->bus) {
2042 bus->rc_dev = bus->dev->bus->self;
2043 DHD_ERROR(("%s: rc_dev from dev->bus->self (%x:%x) is %pK\n", __FUNCTION__,
2044 bus->rc_dev->vendor, bus->rc_dev->device, bus->rc_dev));
2046 DHD_ERROR(("%s: unable to get rc_dev as dev->bus is NULL\n", __FUNCTION__));
2050 if (bus->rc_dev == NULL) {
2051 bus->rc_dev = pci_get_device(PCIE_RC_VENDOR_ID, PCIE_RC_DEVICE_ID, NULL);
2053 PCIE_RC_VENDOR_ID, PCIE_RC_DEVICE_ID, bus->rc_dev));
2056 bus->rc_ep_aspm_cap = dhd_bus_is_rc_ep_aspm_capable(bus);
2057 bus->rc_ep_l1ss_cap = dhd_bus_is_rc_ep_l1ss_capable(bus);
2059 __FUNCTION__, bus->rc_ep_aspm_cap, bus->rc_ep_l1ss_cap));
2061 dhd_bus_aspm_enable_rc_ep(bus, FALSE);
2065 if (dhdpcie_chip_req_forced_tpoweron(bus)) {
2066 dhd_bus_set_tpoweron(bus, tpoweron_scale);
2073 brcm_pcie_wake.data = bus;
2077 bus->dhd->dongle_isolation = TRUE;
2081 bus->pcie_event.events = MSM_PCIE_EVENT_LINKDOWN;
2082 bus->pcie_event.user = pdev;
2083 bus->pcie_event.mode = MSM_PCIE_TRIGGER_CALLBACK;
2084 bus->pcie_event.callback = dhdpcie_linkdown_cb;
2085 bus->pcie_event.options = MSM_PCIE_CONFIG_NO_RECOVERY;
2086 msm_pcie_register_event(&bus->pcie_event);
2087 bus->no_cfg_restore = FALSE;
2092 bus->pcie_event.events = EXYNOS_PCIE_EVENT_LINKDOWN;
2093 bus->pcie_event.user = pdev;
2094 bus->pcie_event.mode = EXYNOS_PCIE_TRIGGER_CALLBACK;
2095 bus->pcie_event.callback = dhdpcie_linkdown_cb;
2096 exynos_pcie_register_event(&bus->pcie_event);
2101 bus->read_shm_fail = FALSE;
2104 if (bus->intr) {
2107 dhdpcie_bus_intr_disable(bus);
2114 bus->pollrate = 1;
2120 if (dhd_bus_download_firmware(bus, osh, NULL, NULL) < 0) {
2123 bus->nv_path = NULL;
2124 bus->fw_path = NULL;
2131 if (dhd_bus_start(bus->dhd)) {
2138 get_random_bytes(&bus->dhd->mac.octet[3], 3);
2140 bus->dhd->mac.octet[0] = 0;
2141 bus->dhd->mac.octet[1] = 0x90;
2142 bus->dhd->mac.octet[2] = 0x4C;
2147 if (dhd_attach_net(bus->dhd, TRUE)) {
2154 if (dhd_register_vif(bus->dhd) != 0) {
2164 atomic_set(&bus->dhd->block_bus, FALSE);
2173 if (bus)
2174 dhdpcie_bus_release(bus);
2204 dhdpcie_free_irq(dhd_bus_t *bus) argument
2209 if (bus) {
2210 pdev = bus->dev;
2211 if (bus->irq_registered) {
2212 free_irq(pdev->irq, bus);
2213 bus->irq_registered = FALSE;
2214 if (bus->d2h_intr_method == PCIE_MSI) {
2246 dhd_bus_t *bus = (dhd_bus_t*)arg; local
2247 bus->isr_entry_time = OSL_LOCALTIME_NS();
2248 if (!dhdpcie_bus_isr(bus)) {
2251 bus->isr_exit_time = OSL_LOCALTIME_NS();
2256 dhdpcie_disable_irq_nosync(dhd_bus_t *bus) argument
2259 if ((bus == NULL) || (bus->dev == NULL)) {
2260 DHD_ERROR(("%s: bus or bus->dev is NULL\n", __FUNCTION__));
2264 dev = bus->dev;
2270 dhdpcie_disable_irq(dhd_bus_t *bus) argument
2273 if ((bus == NULL) || (bus->dev == NULL)) {
2274 DHD_ERROR(("%s: bus or bus->dev is NULL\n", __FUNCTION__));
2278 dev = bus->dev;
2284 dhdpcie_enable_irq(dhd_bus_t *bus) argument
2287 if ((bus == NULL) || (bus->dev == NULL)) {
2288 DHD_ERROR(("%s: bus or bus->dev is NULL\n", __FUNCTION__));
2292 dev = bus->dev;
2298 dhdpcie_irq_disabled(dhd_bus_t *bus) argument
2300 struct irq_desc *desc = irq_to_desc(bus->dev->irq);
2306 dhdpcie_start_host_pcieclock(dhd_bus_t *bus) argument
2316 if (bus == NULL) {
2320 if (bus->dev == NULL) {
2326 if (bus->no_cfg_restore) {
2329 ret = msm_pcie_pm_control(MSM_PCIE_RESUME, bus->dev->bus->number,
2330 bus->dev, NULL, options);
2331 if (bus->no_cfg_restore && !ret) {
2332 msm_pcie_recover_config(bus->dev);
2333 bus->no_cfg_restore = 0;
2336 ret = msm_pcie_pm_control(MSM_PCIE_RESUME, bus->dev->bus->number,
2337 bus->dev, NULL, 0);
2351 dhdpcie_stop_host_pcieclock(dhd_bus_t *bus) argument
2362 if (bus == NULL) {
2366 if (bus->dev == NULL) {
2372 if (bus->no_cfg_restore) {
2376 ret = msm_pcie_pm_control(MSM_PCIE_SUSPEND, bus->dev->bus->number,
2377 bus->dev, NULL, options);
2379 ret = msm_pcie_pm_control(MSM_PCIE_SUSPEND, bus->dev->bus->number,
2380 bus->dev, NULL, 0);
2393 dhdpcie_disable_device(dhd_bus_t *bus) argument
2397 if (bus == NULL) {
2401 if (bus->dev == NULL) {
2405 if (pci_is_enabled(bus->dev))
2406 pci_disable_device(bus->dev);
2412 dhdpcie_enable_device(dhd_bus_t *bus) argument
2421 if (bus == NULL) {
2425 if (bus->dev == NULL) {
2430 pch = pci_get_drvdata(bus->dev);
2440 pci_load_and_free_saved_state(bus->dev, &pch->default_state);
2441 pch->default_state = pci_store_saved_state(bus->dev);
2443 pci_load_saved_state(bus->dev, pch->default_state);
2447 if (bus->dev->state_saved) {
2449 pci_read_config_dword(bus->dev, PCI_CFG_VID, &vid);
2450 saved_vid = bus->dev->saved_config_space[PCI_CFG_VID];
2453 "Skip the bus init\n", __FUNCTION__, vid, saved_vid));
2454 bus->no_bus_init = TRUE;
2457 bus->is_linkdown = 1;
2460 bus->no_cfg_restore = TRUE;
2468 pci_restore_state(bus->dev);
2471 ret = pci_enable_device(bus->dev);
2473 pci_disable_device(bus->dev);
2475 pci_set_master(bus->dev);
2482 dhdpcie_alloc_resource(dhd_bus_t *bus) argument
2489 if (bus == NULL) {
2490 DHD_ERROR(("%s: bus is NULL\n", __FUNCTION__));
2494 if (bus->dev == NULL) {
2495 DHD_ERROR(("%s: bus->dev is NULL\n", __FUNCTION__));
2499 dhdpcie_info = pci_get_drvdata(bus->dev);
2505 bar0_addr = pci_resource_start(bus->dev, 0); /* Bar-0 mapped address */
2506 bar1_addr = pci_resource_start(bus->dev, 2); /* Bar-1 mapped address */
2509 bar1_size = pci_resource_len(bus->dev, 2);
2524 bus->regs = dhdpcie_info->regs;
2531 bus->regs = NULL;
2535 bus->tcm = dhdpcie_info->tcm;
2549 dhdpcie_free_resource(dhd_bus_t *bus) argument
2553 if (bus == NULL) {
2554 DHD_ERROR(("%s: bus is NULL\n", __FUNCTION__));
2558 if (bus->dev == NULL) {
2559 DHD_ERROR(("%s: bus->dev is NULL\n", __FUNCTION__));
2563 dhdpcie_info = pci_get_drvdata(bus->dev);
2569 if (bus->regs) {
2571 bus->regs = NULL;
2574 if (bus->tcm) {
2576 bus->tcm = NULL;
2581 dhdpcie_bus_request_irq(struct dhd_bus *bus) argument
2586 if (bus == NULL) {
2587 DHD_ERROR(("%s: bus is NULL\n", __FUNCTION__));
2591 if (bus->dev == NULL) {
2592 DHD_ERROR(("%s: bus->dev is NULL\n", __FUNCTION__));
2596 dhdpcie_info = pci_get_drvdata(bus->dev);
2602 if (bus->intr) {
2605 dhdpcie_bus_intr_disable(bus);
2634 int dhdpcie_get_oob_irq_status(struct dhd_bus *bus) argument
2639 if (bus == NULL) {
2640 DHD_ERROR(("%s: bus is NULL\n", __FUNCTION__));
2644 if (bus->dev == NULL) {
2645 DHD_ERROR(("%s: bus->dev is NULL\n", __FUNCTION__));
2649 pch = pci_get_drvdata(bus->dev);
2660 int dhdpcie_get_oob_irq_num(struct dhd_bus *bus) argument
2665 if (bus == NULL) {
2666 DHD_ERROR(("%s: bus is NULL\n", __FUNCTION__));
2670 if (bus->dev == NULL) {
2671 DHD_ERROR(("%s: bus->dev is NULL\n", __FUNCTION__));
2675 pch = pci_get_drvdata(bus->dev);
2686 void dhdpcie_oob_intr_set(dhd_bus_t *bus, bool enable) argument
2692 if (bus == NULL) {
2693 DHD_ERROR(("%s: bus is NULL\n", __FUNCTION__));
2697 if (bus->dev == NULL) {
2698 DHD_ERROR(("%s: bus->dev is NULL\n", __FUNCTION__));
2702 pch = pci_get_drvdata(bus->dev);
2714 bus->oob_intr_enable_count++;
2715 bus->last_oob_irq_enable_time = OSL_LOCALTIME_NS();
2718 bus->oob_intr_disable_count++;
2719 bus->last_oob_irq_disable_time = OSL_LOCALTIME_NS();
2728 dhd_bus_t *bus; local
2731 bus = (dhd_bus_t *)data;
2732 dhdpcie_oob_intr_set(bus, FALSE);
2733 bus->last_oob_irq_time = OSL_LOCALTIME_NS();
2734 bus->oob_intr_count++;
2738 if (bus->chk_pm)
2741 bcmpcie_set_get_wake(bus, 1);
2745 dhdpcie_runtime_bus_wake(bus->dhd, FALSE, wlan_oob_irq);
2748 dhd_bus_wakeup_work(bus->dhd);
2750 DHD_BUS_LOCK(bus->bus_lock, flags_bus);
2754 if (bus->dhd->up && bus->bus_low_power_state != DHD_BUS_NO_LOW_POWER_STATE) {
2755 DHD_OS_OOB_IRQ_WAKE_LOCK_TIMEOUT(bus->dhd, OOB_WAKE_LOCK_TIMEOUT);
2757 DHD_BUS_UNLOCK(bus->bus_lock, flags_bus);
2761 int dhdpcie_oob_intr_register(dhd_bus_t *bus) argument
2768 if (bus == NULL) {
2769 DHD_ERROR(("%s: bus is NULL\n", __FUNCTION__));
2773 if (bus->dev == NULL) {
2774 DHD_ERROR(("%s: bus->dev is NULL\n", __FUNCTION__));
2778 pch = pci_get_drvdata(bus->dev);
2796 bus);
2824 void dhdpcie_oob_intr_unregister(dhd_bus_t *bus) argument
2831 if (bus == NULL) {
2832 DHD_ERROR(("%s: bus is NULL\n", __FUNCTION__));
2836 if (bus->dev == NULL) {
2837 DHD_ERROR(("%s: bus->dev is NULL\n", __FUNCTION__));
2841 pch = pci_get_drvdata(bus->dev);
2863 free_irq(dhdpcie_osinfo->oob_irq_num, bus);
2872 dhd_bus_t *bus; local
2874 bus = dhd->bus;
2877 bus->idlecount++;
2880 if ((bus->idletime > 0) && (bus->idlecount >= bus->idletime)) {
2881 bus->idlecount = 0;
2883 bus->bus_wake = 0;
2885 bus->runtime_resume_done = FALSE;
2887 dhd_bus_stop_queue(bus);
2890 __FUNCTION__, bus->idletime, dhd_runtimepm_ms));
2892 if (dhdpcie_set_suspend_resume(bus, TRUE)) {
2896 dhd_os_busbusy_wake(bus->dhd);
2897 bus->runtime_resume_done = TRUE;
2899 dhd_bus_start_queue(bus);
2902 wake_up_interruptible(&bus->rpm_queue);
2910 dhd_bus_start_queue(bus);
2913 wait_event_interruptible(bus->rpm_queue, bus->bus_wake);
2920 dhdpcie_set_suspend_resume(bus, FALSE);
2924 dhd_os_busbusy_wake(bus->dhd);
2926 bus->runtime_resume_done = TRUE;
2928 dhd_bus_start_queue(bus);
2932 wake_up_interruptible(&bus->rpm_queue);
2940 DHD_ERROR(("%s : bus is active with dhd_bus_busy_state = 0x%x\n",
2955 bool dhd_runtime_bus_wake(dhd_bus_t *bus, bool wait, void *func_addr) argument
2958 bus->idlecount = 0;
2960 if (bus->dhd->up == FALSE) {
2965 DHD_GENERAL_LOCK(bus->dhd, flags);
2966 if (DHD_BUS_BUSY_CHECK_RPM_ALL(bus->dhd)) {
2968 if (DHD_BUS_BUSY_CHECK_RPM_SUSPEND_IN_PROGRESS(bus->dhd) ||
2969 DHD_BUS_BUSY_CHECK_RPM_SUSPEND_DONE(bus->dhd)) {
2970 bus->bus_wake = 1;
2972 DHD_GENERAL_UNLOCK(bus->dhd, flags);
2976 wake_up_interruptible(&bus->rpm_queue);
2978 } else if (DHD_BUS_BUSY_CHECK_RPM_RESUME_IN_PROGRESS(bus->dhd)) {
2979 DHD_GENERAL_UNLOCK(bus->dhd, flags);
2984 wait_event_interruptible(bus->rpm_queue, bus->runtime_resume_done);
2986 DHD_INFO(("%s: bus wakeup but no wait until resume done\n", __FUNCTION__));
2992 DHD_GENERAL_UNLOCK(bus->dhd, flags);
2999 dhd_bus_t *bus = dhdp->bus; local
3000 return dhd_runtime_bus_wake(bus, wait, func_addr);
3005 dhd_bus_t *bus = dhdp->bus; local
3006 bus->idletime = 0;
3011 dhd_bus_t *bus = dhdp->bus; local
3012 return bus->runtime_resume_done;
3016 struct device * dhd_bus_to_dev(dhd_bus_t *bus) argument
3019 pdev = bus->dev;
3077 dhdpcie_get_pcieirq(dhd->bus, &irq);
3092 irq = dhdpcie_get_oob_irq_num(dhd->bus);
3106 DHD_ERROR(("%s: Bus is NULL\n", __FUNCTION__));
3128 DHD_ERROR(("%s: Bus is NULL\n", __FUNCTION__));
3152 dhd_bus_t *bus; local
3156 bus = (dhd_bus_t *)g_dhd_bus;
3157 if (!bus) {
3158 DHD_ERROR(("%s: bus is NULL\n", __FUNCTION__));
3162 dhdp = bus->dhd;
3173 dhd_bus_t *bus; local
3177 bus = (dhd_bus_t *)g_dhd_bus;
3178 if (!bus) {
3179 DHD_ERROR(("%s: bus is NULL\n", __FUNCTION__));
3183 dhdp = bus->dhd;