Path: blob/main/sys/contrib/dev/athk/ath12k/pci.h
107763 views
/* SPDX-License-Identifier: BSD-3-Clause-Clear */1/*2* Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.3* Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.4*/5#ifndef ATH12K_PCI_H6#define ATH12K_PCI_H78#include <linux/mhi.h>910#include "core.h"1112#define PCIE_SOC_GLOBAL_RESET 0x300813#define PCIE_SOC_GLOBAL_RESET_V 11415#define WLAON_WARM_SW_ENTRY 0x1f8050416#define WLAON_SOC_RESET_CAUSE_REG 0x01f8060c1718#define PCIE_Q6_COOKIE_ADDR 0x01f8050019#define PCIE_Q6_COOKIE_DATA 0xc00000002021/* register to wake the UMAC from power collapse */22#define PCIE_SCRATCH_0_SOC_PCIE_REG 0x40402324/* register used for handshake mechanism to validate UMAC is awake */25#define PCIE_SOC_WAKE_PCIE_LOCAL_REG 0x30042627#define PCIE_PCIE_PARF_LTSSM 0x1e081b028#define PARM_LTSSM_VALUE 0x1112930#define GCC_GCC_PCIE_HOT_RST 0x1e3833831#define GCC_GCC_PCIE_HOT_RST_VAL 0x103233#define PCIE_PCIE_INT_ALL_CLEAR 0x1e0822834#define PCIE_SMLH_REQ_RST_LINK_DOWN 0x235#define PCIE_INT_CLEAR_ALL 0xffffffff3637#define PCIE_QSERDES_COM_SYSCLK_EN_SEL_REG(ab) \38((ab)->hw_params->regs->pcie_qserdes_sysclk_en_sel)39#define PCIE_QSERDES_COM_SYSCLK_EN_SEL_VAL 0x1040#define PCIE_QSERDES_COM_SYSCLK_EN_SEL_MSK 0xffffffff41#define PCIE_PCS_OSC_DTCT_CONFIG1_REG(ab) \42((ab)->hw_params->regs->pcie_pcs_osc_dtct_config_base)43#define PCIE_PCS_OSC_DTCT_CONFIG1_VAL 0x0244#define PCIE_PCS_OSC_DTCT_CONFIG2_REG(ab) \45((ab)->hw_params->regs->pcie_pcs_osc_dtct_config_base + 0x4)46#define PCIE_PCS_OSC_DTCT_CONFIG2_VAL 0x5247#define PCIE_PCS_OSC_DTCT_CONFIG4_REG(ab) \48((ab)->hw_params->regs->pcie_pcs_osc_dtct_config_base + 0xc)49#define PCIE_PCS_OSC_DTCT_CONFIG4_VAL 0xff50#define PCIE_PCS_OSC_DTCT_CONFIG_MSK 0x000000ff5152#define WLAON_QFPROM_PWR_CTRL_REG 0x01f8031c53#define QFPROM_PWR_CTRL_VDD4BLOW_MASK 0x45455#define PCI_BAR_WINDOW0_BASE 0x1E0000056#define PCI_BAR_WINDOW0_END 0x1E7FFFC57#define PCI_SOC_RANGE_MASK 0x3FFF58#define PCI_SOC_PCI_REG_BASE 0x1E0400059#define PCI_SOC_PCI_REG_END 0x1E07FFC60#define PCI_PARF_BASE 0x1E0800061#define PCI_PARF_END 0x1E0BFFC62#define PCI_MHIREGLEN_REG 0x1E0E10063#define PCI_MHI_REGION_END 0x1E0EFFC64#define QRTR_PCI_DOMAIN_NR_MASK GENMASK(7, 4)65#define QRTR_PCI_BUS_NUMBER_MASK GENMASK(3, 0)6667#define ATH12K_PCI_SOC_HW_VERSION_1 168#define ATH12K_PCI_SOC_HW_VERSION_2 26970struct ath12k_msi_user {71const char *name;72int num_vectors;73u32 base_vector;74};7576struct ath12k_msi_config {77int total_vectors;78int total_users;79const struct ath12k_msi_user *users;80};8182enum ath12k_pci_flags {83ATH12K_PCI_FLAG_INIT_DONE,84ATH12K_PCI_FLAG_IS_MSI_64,85ATH12K_PCI_ASPM_RESTORE,86};8788struct ath12k_pci_ops {89int (*wakeup)(struct ath12k_base *ab);90void (*release)(struct ath12k_base *ab);91};9293struct ath12k_pci {94struct pci_dev *pdev;95struct ath12k_base *ab;96u16 dev_id;97char amss_path[100];98u32 msi_ep_base_data;99struct mhi_controller *mhi_ctrl;100const struct ath12k_msi_config *msi_config;101unsigned long mhi_state;102u32 register_window;103104/* protects register_window above */105spinlock_t window_lock;106107/* enum ath12k_pci_flags */108unsigned long flags;109u16 link_ctl;110const struct ath12k_pci_ops *pci_ops;111};112113static inline struct ath12k_pci *ath12k_pci_priv(struct ath12k_base *ab)114{115return (struct ath12k_pci *)ab->drv_priv;116}117118int ath12k_pci_get_user_msi_assignment(struct ath12k_base *ab, char *user_name,119int *num_vectors, u32 *user_base_data,120u32 *base_vector);121int ath12k_pci_get_msi_irq(struct device *dev, unsigned int vector);122void ath12k_pci_write32(struct ath12k_base *ab, u32 offset, u32 value);123u32 ath12k_pci_read32(struct ath12k_base *ab, u32 offset);124int ath12k_pci_map_service_to_pipe(struct ath12k_base *ab, u16 service_id,125u8 *ul_pipe, u8 *dl_pipe);126void ath12k_pci_get_msi_address(struct ath12k_base *ab, u32 *msi_addr_lo,127u32 *msi_addr_hi);128void ath12k_pci_get_ce_msi_idx(struct ath12k_base *ab, u32 ce_id,129u32 *msi_idx);130void ath12k_pci_hif_ce_irq_enable(struct ath12k_base *ab);131void ath12k_pci_hif_ce_irq_disable(struct ath12k_base *ab);132void ath12k_pci_ext_irq_enable(struct ath12k_base *ab);133void ath12k_pci_ext_irq_disable(struct ath12k_base *ab);134int ath12k_pci_hif_suspend(struct ath12k_base *ab);135int ath12k_pci_hif_resume(struct ath12k_base *ab);136void ath12k_pci_stop(struct ath12k_base *ab);137int ath12k_pci_start(struct ath12k_base *ab);138int ath12k_pci_power_up(struct ath12k_base *ab);139void ath12k_pci_power_down(struct ath12k_base *ab);140#endif /* ATH12K_PCI_H */141142143