Lines Matching +full:aspm +full:- +full:no +full:- +full:l0s

1 // SPDX-License-Identifier: BSD-3-Clause-Clear
3 * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved.
4 * Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
49 return mhi_device_get_sync(ab_pci->mhi_ctrl->mhi_dev);
56 mhi_device_put(ab_pci->mhi_ctrl->mhi_dev);
61 if (!ab->hw_params.static_window_map)
77 struct ath11k_base *ab = ab_pci->ab;
81 lockdep_assert_held(&ab_pci->window_lock);
83 if (window != ab_pci->register_window) {
85 ab->mem + ATH11K_PCI_WINDOW_REG_ADDRESS);
86 ioread32(ab->mem + ATH11K_PCI_WINDOW_REG_ADDRESS);
87 ab_pci->register_window = window;
100 spin_lock_bh(&ab_pci->window_lock);
102 iowrite32(value, ab->mem + window_start +
104 spin_unlock_bh(&ab_pci->window_lock);
106 iowrite32(value, ab->mem + window_start +
119 spin_lock_bh(&ab_pci->window_lock);
121 val = ioread32(ab->mem + window_start +
123 spin_unlock_bh(&ab_pci->window_lock);
125 val = ioread32(ab->mem + window_start +
134 struct pci_dev *pci_dev = to_pci_dev(ab->dev);
177 ab_pci->ab->mem + ATH11K_PCI_WINDOW_REG_ADDRESS);
259 return -ETIMEDOUT;
366 if (ab->hw_params.fix_l1ss)
378 struct ath11k_qmi_ce_cfg *cfg = &ab->qmi.ce_cfg;
380 cfg->tgt_ce = ab->hw_params.target_ce_config;
381 cfg->tgt_ce_len = ab->hw_params.target_ce_count;
383 cfg->svc_to_ce_map = ab->hw_params.svc_to_ce_map;
384 cfg->svc_to_ce_map_len = ab->hw_params.svc_to_ce_map_len;
385 ab->qmi.service_ins_id = ab->hw_params.qmi_service_ins_id;
387 ath11k_ce_get_shadow_config(ab, &cfg->shadow_reg_v2,
388 &cfg->shadow_reg_v2_len);
393 struct pci_dev *dev = ab_pci->pdev;
396 pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &control);
403 pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, control);
418 struct ath11k_base *ab = ab_pci->ab;
419 const struct ath11k_msi_config *msi_config = ab->pci.msi.config;
420 struct pci_dev *pci_dev = ab_pci->pdev;
426 msi_config->total_vectors,
427 msi_config->total_vectors,
429 if (num_vectors == msi_config->total_vectors) {
430 set_bit(ATH11K_FLAG_MULTI_MSI_VECTORS, &ab->dev_flags);
432 num_vectors = pci_alloc_irq_vectors(ab_pci->pdev,
437 ret = -EINVAL;
440 clear_bit(ATH11K_FLAG_MULTI_MSI_VECTORS, &ab->dev_flags);
441 ab->pci.msi.config = &msi_config_one_msi;
448 msi_desc = irq_get_msi_desc(ab_pci->pdev->irq);
451 ret = -EINVAL;
455 ab->pci.msi.ep_base_data = msi_desc->msg.data;
457 pci_read_config_dword(pci_dev, pci_dev->msi_cap + PCI_MSI_ADDRESS_LO,
458 &ab->pci.msi.addr_lo);
460 if (msi_desc->pci.msi_attrib.is_64) {
461 pci_read_config_dword(pci_dev, pci_dev->msi_cap + PCI_MSI_ADDRESS_HI,
462 &ab->pci.msi.addr_hi);
464 ab->pci.msi.addr_hi = 0;
467 ath11k_dbg(ab, ATH11K_DBG_PCI, "msi base data is %d\n", ab->pci.msi.ep_base_data);
472 pci_free_irq_vectors(ab_pci->pdev);
480 pci_free_irq_vectors(ab_pci->pdev);
487 msi_desc = irq_get_msi_desc(ab_pci->pdev->irq);
489 ath11k_err(ab_pci->ab, "msi_desc is NULL!\n");
490 pci_free_irq_vectors(ab_pci->pdev);
491 return -EINVAL;
494 ab_pci->ab->pci.msi.ep_base_data = msi_desc->msg.data;
496 ath11k_dbg(ab_pci->ab, ATH11K_DBG_PCI, "after request_irq msi_ep_base_data %d\n",
497 ab_pci->ab->pci.msi.ep_base_data);
504 struct ath11k_base *ab = ab_pci->ab;
509 if (device_id != ab_pci->dev_id) {
511 device_id, ab_pci->dev_id);
512 ret = -EIO;
534 ret = dma_set_mask(&pdev->dev,
542 ab_pci->dma_mask = DMA_BIT_MASK(ATH11K_PCI_DMA_MASK);
544 ret = dma_set_coherent_mask(&pdev->dev,
554 ab->mem_len = pci_resource_len(pdev, ATH11K_PCI_BAR_NUM);
555 ab->mem = pci_iomap(pdev, ATH11K_PCI_BAR_NUM, 0);
556 if (!ab->mem) {
558 ret = -EIO;
562 ab->mem_ce = ab->mem;
564 ath11k_dbg(ab, ATH11K_DBG_BOOT, "pci_mem 0x%p\n", ab->mem);
577 struct ath11k_base *ab = ab_pci->ab;
578 struct pci_dev *pci_dev = ab_pci->pdev;
580 pci_iounmap(pci_dev, ab->mem);
581 ab->mem = NULL;
589 struct ath11k_base *ab = ab_pci->ab;
591 pcie_capability_read_word(ab_pci->pdev, PCI_EXP_LNKCTL,
592 &ab_pci->link_ctl);
594 ath11k_dbg(ab, ATH11K_DBG_PCI, "link_ctl 0x%04x L0s %d L1 %d\n",
595 ab_pci->link_ctl,
596 u16_get_bits(ab_pci->link_ctl, PCI_EXP_LNKCTL_ASPM_L0S),
597 u16_get_bits(ab_pci->link_ctl, PCI_EXP_LNKCTL_ASPM_L1));
599 /* disable L0s and L1 */
600 pcie_capability_clear_word(ab_pci->pdev, PCI_EXP_LNKCTL,
603 set_bit(ATH11K_PCI_ASPM_RESTORE, &ab_pci->flags);
608 if (test_and_clear_bit(ATH11K_PCI_ASPM_RESTORE, &ab_pci->flags))
609 pcie_capability_clear_and_set_word(ab_pci->pdev, PCI_EXP_LNKCTL,
611 ab_pci->link_ctl &
619 struct mhi_controller *mhi_ctrl = ab_pci->mhi_ctrl;
627 rddm_img = mhi_ctrl->rddm_image;
629 ath11k_err(ab, "No RDDM dump found\n");
633 fw_img = mhi_ctrl->fbc_image;
635 for (i = 0; i < fw_img->entries ; i++) {
636 if (!fw_img->mhi_buf[i].buf)
639 paging_tlv_sz += fw_img->mhi_buf[i].len;
643 for (i = 0; i < rddm_img->entries; i++) {
644 if (!rddm_img->mhi_buf[i].buf)
647 rddm_tlv_sz += rddm_img->mhi_buf[i].len;
651 for (i = 0; i < ab->qmi.mem_seg_count; i++) {
652 mem_type = ath11k_coredump_get_dump_type(ab->qmi.target_mem[i].type);
660 ab->qmi.target_mem[i].type);
664 if (!ab->qmi.target_mem[i].anyaddr)
667 dump_seg_sz[mem_type] += ab->qmi.target_mem[i].size;
686 struct mhi_controller *mhi_ctrl = ab_pci->mhi_ctrl;
701 ath11k_warn(ab, "No crash dump data found for devcoredump");
705 rddm_img = mhi_ctrl->rddm_image;
706 fw_img = mhi_ctrl->fbc_image;
713 ab->dump_data = buf;
714 ab->ath11k_coredump_len = len;
715 file_data = ab->dump_data;
716 strscpy(file_data->df_magic, "ATH11K-FW-DUMP", sizeof(file_data->df_magic));
717 file_data->len = cpu_to_le32(len);
718 file_data->version = cpu_to_le32(ATH11K_FW_CRASH_DUMP_V2);
719 file_data->chip_id = cpu_to_le32(ab_pci->dev_id);
720 file_data->qrtr_id = cpu_to_le32(ab_pci->ab->qmi.service_ins_id);
721 file_data->bus_id = cpu_to_le32(pci_domain_nr(ab_pci->pdev->bus));
722 guid_gen(&file_data->guid);
724 file_data->tv_sec = cpu_to_le64(timestamp.tv_sec);
725 file_data->tv_nsec = cpu_to_le64(timestamp.tv_nsec);
728 dump_tlv->type = cpu_to_le32(FW_CRASH_DUMP_PAGING_DATA);
729 dump_tlv->tlv_len = cpu_to_le32(dump_seg_sz[FW_CRASH_DUMP_PAGING_DATA]);
735 for (i = 0; i < fw_img->entries ; i++) {
736 if (!fw_img->mhi_buf[i].buf)
739 memcpy_fromio(buf, (void const __iomem *)fw_img->mhi_buf[i].buf,
740 fw_img->mhi_buf[i].len);
741 buf += fw_img->mhi_buf[i].len;
745 dump_tlv->type = cpu_to_le32(FW_CRASH_DUMP_RDDM_DATA);
746 dump_tlv->tlv_len = cpu_to_le32(dump_seg_sz[FW_CRASH_DUMP_RDDM_DATA]);
752 for (i = 0; i < rddm_img->entries; i++) {
753 if (!rddm_img->mhi_buf[i].buf)
756 memcpy_fromio(buf, (void const __iomem *)rddm_img->mhi_buf[i].buf,
757 rddm_img->mhi_buf[i].len);
758 buf += rddm_img->mhi_buf[i].len;
766 for (i = 0; i < ab->qmi.mem_seg_count; i++) {
768 (ab->qmi.target_mem[i].type);
773 if (!ab->qmi.target_mem[i].anyaddr) {
776 ab->qmi.target_mem[i].type);
781 dump_tlv->type = cpu_to_le32(mem_idx);
782 dump_tlv->tlv_len = cpu_to_le32(dump_seg_sz[mem_idx]);
785 memcpy_fromio(buf, ab->qmi.target_mem[i].iaddr,
786 ab->qmi.target_mem[i].size);
788 buf += ab->qmi.target_mem[i].size;
792 queue_work(ab->workqueue, &ab->dump_work);
801 ab_pci->register_window = 0;
802 clear_bit(ATH11K_FLAG_DEVICE_INIT_DONE, &ab->dev_flags);
803 ath11k_pci_sw_reset(ab_pci->ab, true);
805 /* Disable ASPM during firmware download due to problems switching
818 if (ab->hw_params.static_window_map)
828 /* restore aspm in case firmware bootup fails */
831 ath11k_pci_force_wake(ab_pci->ab);
836 clear_bit(ATH11K_FLAG_DEVICE_INIT_DONE, &ab->dev_flags);
837 ath11k_pci_sw_reset(ab_pci->ab, false);
868 /* TODO: for now don't restore ASPM in case of single MSI
871 if (test_bit(ATH11K_FLAG_MULTI_MSI_VECTORS, &ab->dev_flags))
874 ath11k_info(ab, "leaving PCI ASPM disabled to avoid MHI M2 problems\n");
921 if (test_bit(ATH11K_FLAG_MULTI_MSI_VECTORS, &ab_pci->ab->dev_flags))
924 return irq_set_affinity_and_hint(ab_pci->pdev->irq, m);
936 ab = ath11k_core_alloc(&pdev->dev, sizeof(*ab_pci), ATH11K_BUS_PCI);
939 dev_err(&pdev->dev, "failed to allocate ath11k base\n");
940 return -ENOMEM;
943 ab->dev = &pdev->dev;
946 ab_pci->dev_id = pci_dev->device;
947 ab_pci->ab = ab;
948 ab_pci->pdev = pdev;
949 ab->hif.ops = &ath11k_pci_hif_ops;
950 ab->fw_mode = ATH11K_FIRMWARE_MODE_NORMAL;
952 spin_lock_init(&ab_pci->window_lock);
958 if (of_property_present(ab->dev->of_node, "memory-region"))
959 set_bit(ATH11K_FLAG_FIXED_MEM_RGN, &ab->dev_flags);
968 pdev->vendor, pdev->device,
969 pdev->subsystem_vendor, pdev->subsystem_device);
971 ab->id.vendor = pdev->vendor;
972 ab->id.device = pdev->device;
973 ab->id.subsystem_vendor = pdev->subsystem_vendor;
974 ab->id.subsystem_device = pdev->subsystem_device;
976 switch (pci_dev->device) {
988 ab->hw_rev = ATH11K_HW_QCA6390_HW20;
991 dev_err(&pdev->dev, "Unsupported QCA6390 SOC hardware version: %d %d\n",
993 ret = -EOPNOTSUPP;
1004 ab->hw_rev = ATH11K_HW_QCN9074_HW10;
1012 ab->id.bdf_search = ATH11K_BDF_SEARCH_BUS_AND_BOARD;
1020 ab->hw_rev = ATH11K_HW_WCN6855_HW20;
1032 ab->hw_rev = ATH11K_HW_QCA2066_HW21;
1035 ab->hw_rev = ATH11K_HW_QCA6698AQ_HW21;
1038 ab->hw_rev = ATH11K_HW_WCN6855_HW21;
1047 dev_err(&pdev->dev, "Unsupported WCN6855 SOC hardware version: %d %d\n",
1049 ret = -EOPNOTSUPP;
1055 dev_err(&pdev->dev, "Unknown PCI device found: 0x%x\n",
1056 pci_dev->device);
1057 ret = -EOPNOTSUPP;
1162 if (test_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags)) {
1170 set_bit(ATH11K_FLAG_UNREGISTERING, &ab->dev_flags);
1172 cancel_work_sync(&ab->reset_work);
1173 cancel_work_sync(&ab->dump_work);
1203 if (test_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags)) {
1220 if (test_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags)) {