xref: /openbmc/linux/drivers/net/wireless/ath/ath11k/pci.h (revision e9603f4b)
15762613eSGovind Singh /* SPDX-License-Identifier: BSD-3-Clause-Clear */
25762613eSGovind Singh /*
35762613eSGovind Singh  * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved.
45762613eSGovind Singh  */
51399fb87SGovind Singh #ifndef _ATH11K_PCI_H
61399fb87SGovind Singh #define _ATH11K_PCI_H
71399fb87SGovind Singh 
81399fb87SGovind Singh #include <linux/mhi.h>
95762613eSGovind Singh 
105762613eSGovind Singh #include "core.h"
115762613eSGovind Singh 
12f3c603d4SCarl Huang #define PCIE_SOC_GLOBAL_RESET			0x3008
13f3c603d4SCarl Huang #define PCIE_SOC_GLOBAL_RESET_V			1
14f3c603d4SCarl Huang 
15f3c603d4SCarl Huang #define WLAON_WARM_SW_ENTRY			0x1f80504
16f3c603d4SCarl Huang #define WLAON_SOC_RESET_CAUSE_REG		0x01f8060c
17f3c603d4SCarl Huang 
18f3c603d4SCarl Huang #define PCIE_Q6_COOKIE_ADDR			0x01f80500
19f3c603d4SCarl Huang #define PCIE_Q6_COOKIE_DATA			0xc0000000
20f3c603d4SCarl Huang 
21f3c603d4SCarl Huang /* register to wake the UMAC from power collapse */
22f3c603d4SCarl Huang #define PCIE_SCRATCH_0_SOC_PCIE_REG		0x4040
23f3c603d4SCarl Huang 
24f3c603d4SCarl Huang /* register used for handshake mechanism to validate UMAC is awake */
25f3c603d4SCarl Huang #define PCIE_SOC_WAKE_PCIE_LOCAL_REG		0x3004
26f3c603d4SCarl Huang 
27babb0cedSCarl Huang #define PCIE_PCIE_PARF_LTSSM			0x1e081b0
28babb0cedSCarl Huang #define PARM_LTSSM_VALUE			0x111
29babb0cedSCarl Huang 
30babb0cedSCarl Huang #define GCC_GCC_PCIE_HOT_RST			0x1e402bc
31babb0cedSCarl Huang #define GCC_GCC_PCIE_HOT_RST_VAL		0x10
32babb0cedSCarl Huang 
33babb0cedSCarl Huang #define PCIE_PCIE_INT_ALL_CLEAR			0x1e08228
34babb0cedSCarl Huang #define PCIE_SMLH_REQ_RST_LINK_DOWN		0x2
35babb0cedSCarl Huang #define PCIE_INT_CLEAR_ALL			0xffffffff
36babb0cedSCarl Huang 
3706999407SCarl Huang #define PCIE_QSERDES_COM_SYSCLK_EN_SEL_REG	0x01e0c0ac
3806999407SCarl Huang #define PCIE_QSERDES_COM_SYSCLK_EN_SEL_VAL	0x10
3906999407SCarl Huang #define PCIE_QSERDES_COM_SYSCLK_EN_SEL_MSK	0xffffffff
4006999407SCarl Huang #define PCIE_USB3_PCS_MISC_OSC_DTCT_CONFIG1_REG	0x01e0c628
4106999407SCarl Huang #define PCIE_USB3_PCS_MISC_OSC_DTCT_CONFIG1_VAL	0x02
4206999407SCarl Huang #define PCIE_USB3_PCS_MISC_OSC_DTCT_CONFIG2_REG	0x01e0c62c
4306999407SCarl Huang #define PCIE_USB3_PCS_MISC_OSC_DTCT_CONFIG2_VAL	0x52
4406999407SCarl Huang #define PCIE_USB3_PCS_MISC_OSC_DTCT_CONFIG4_REG	0x01e0c634
4506999407SCarl Huang #define PCIE_USB3_PCS_MISC_OSC_DTCT_CONFIG4_VAL	0xff
4606999407SCarl Huang #define PCIE_USB3_PCS_MISC_OSC_DTCT_CONFIG_MSK	0x000000ff
4706999407SCarl Huang 
480ccdf439SCarl Huang #define WLAON_QFPROM_PWR_CTRL_REG		0x01f8031c
490ccdf439SCarl Huang #define QFPROM_PWR_CTRL_VDD4BLOW_MASK		0x4
500ccdf439SCarl Huang 
515697a564SGovind Singh struct ath11k_msi_user {
525697a564SGovind Singh 	char *name;
535697a564SGovind Singh 	int num_vectors;
545697a564SGovind Singh 	u32 base_vector;
555697a564SGovind Singh };
565697a564SGovind Singh 
575697a564SGovind Singh struct ath11k_msi_config {
585697a564SGovind Singh 	int total_vectors;
595697a564SGovind Singh 	int total_users;
605697a564SGovind Singh 	struct ath11k_msi_user *users;
615697a564SGovind Singh };
625697a564SGovind Singh 
63a05bd851SCarl Huang enum ath11k_pci_flags {
64a05bd851SCarl Huang 	ATH11K_PCI_FLAG_INIT_DONE,
65e8e55d89SAnilkumar Kolli 	ATH11K_PCI_FLAG_IS_MSI_64,
66*e9603f4bSCarl Huang 	ATH11K_PCI_ASPM_RESTORE,
67a05bd851SCarl Huang };
68a05bd851SCarl Huang 
695762613eSGovind Singh struct ath11k_pci {
705762613eSGovind Singh 	struct pci_dev *pdev;
715762613eSGovind Singh 	struct ath11k_base *ab;
725762613eSGovind Singh 	u16 dev_id;
731399fb87SGovind Singh 	char amss_path[100];
745697a564SGovind Singh 	u32 msi_ep_base_data;
751399fb87SGovind Singh 	struct mhi_controller *mhi_ctrl;
761399fb87SGovind Singh 	unsigned long mhi_state;
77654e959aSGovind Singh 	u32 register_window;
78654e959aSGovind Singh 
79654e959aSGovind Singh 	/* protects register_window above */
80654e959aSGovind Singh 	spinlock_t window_lock;
81a05bd851SCarl Huang 
82a05bd851SCarl Huang 	/* enum ath11k_pci_flags */
83a05bd851SCarl Huang 	unsigned long flags;
84*e9603f4bSCarl Huang 	u16 link_ctl;
855762613eSGovind Singh };
865762613eSGovind Singh 
875762613eSGovind Singh static inline struct ath11k_pci *ath11k_pci_priv(struct ath11k_base *ab)
885762613eSGovind Singh {
895762613eSGovind Singh 	return (struct ath11k_pci *)ab->drv_priv;
905762613eSGovind Singh }
911399fb87SGovind Singh 
921399fb87SGovind Singh int ath11k_pci_get_user_msi_assignment(struct ath11k_pci *ar_pci, char *user_name,
931399fb87SGovind Singh 				       int *num_vectors, u32 *user_base_data,
941399fb87SGovind Singh 				       u32 *base_vector);
951399fb87SGovind Singh int ath11k_pci_get_msi_irq(struct device *dev, unsigned int vector);
96f3c603d4SCarl Huang void ath11k_pci_write32(struct ath11k_base *ab, u32 offset, u32 value);
97f3c603d4SCarl Huang u32 ath11k_pci_read32(struct ath11k_base *ab, u32 offset);
981399fb87SGovind Singh 
991399fb87SGovind Singh #endif
100