xref: /openbmc/linux/drivers/net/wireless/ath/ath11k/pci.h (revision babb0ced)
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 
27*babb0cedSCarl Huang #define PCIE_PCIE_PARF_LTSSM			0x1e081b0
28*babb0cedSCarl Huang #define PARM_LTSSM_VALUE			0x111
29*babb0cedSCarl Huang 
30*babb0cedSCarl Huang #define GCC_GCC_PCIE_HOT_RST			0x1e402bc
31*babb0cedSCarl Huang #define GCC_GCC_PCIE_HOT_RST_VAL		0x10
32*babb0cedSCarl Huang 
33*babb0cedSCarl Huang #define PCIE_PCIE_INT_ALL_CLEAR			0x1e08228
34*babb0cedSCarl Huang #define PCIE_SMLH_REQ_RST_LINK_DOWN		0x2
35*babb0cedSCarl Huang #define PCIE_INT_CLEAR_ALL			0xffffffff
36*babb0cedSCarl Huang 
375697a564SGovind Singh struct ath11k_msi_user {
385697a564SGovind Singh 	char *name;
395697a564SGovind Singh 	int num_vectors;
405697a564SGovind Singh 	u32 base_vector;
415697a564SGovind Singh };
425697a564SGovind Singh 
435697a564SGovind Singh struct ath11k_msi_config {
445697a564SGovind Singh 	int total_vectors;
455697a564SGovind Singh 	int total_users;
465697a564SGovind Singh 	struct ath11k_msi_user *users;
475697a564SGovind Singh };
485697a564SGovind Singh 
49a05bd851SCarl Huang enum ath11k_pci_flags {
50a05bd851SCarl Huang 	ATH11K_PCI_FLAG_INIT_DONE,
51e8e55d89SAnilkumar Kolli 	ATH11K_PCI_FLAG_IS_MSI_64,
52a05bd851SCarl Huang };
53a05bd851SCarl Huang 
545762613eSGovind Singh struct ath11k_pci {
555762613eSGovind Singh 	struct pci_dev *pdev;
565762613eSGovind Singh 	struct ath11k_base *ab;
575762613eSGovind Singh 	u16 dev_id;
581399fb87SGovind Singh 	char amss_path[100];
595697a564SGovind Singh 	u32 msi_ep_base_data;
601399fb87SGovind Singh 	struct mhi_controller *mhi_ctrl;
611399fb87SGovind Singh 	unsigned long mhi_state;
62654e959aSGovind Singh 	u32 register_window;
63654e959aSGovind Singh 
64654e959aSGovind Singh 	/* protects register_window above */
65654e959aSGovind Singh 	spinlock_t window_lock;
66a05bd851SCarl Huang 
67a05bd851SCarl Huang 	/* enum ath11k_pci_flags */
68a05bd851SCarl Huang 	unsigned long flags;
695762613eSGovind Singh };
705762613eSGovind Singh 
715762613eSGovind Singh static inline struct ath11k_pci *ath11k_pci_priv(struct ath11k_base *ab)
725762613eSGovind Singh {
735762613eSGovind Singh 	return (struct ath11k_pci *)ab->drv_priv;
745762613eSGovind Singh }
751399fb87SGovind Singh 
761399fb87SGovind Singh int ath11k_pci_get_user_msi_assignment(struct ath11k_pci *ar_pci, char *user_name,
771399fb87SGovind Singh 				       int *num_vectors, u32 *user_base_data,
781399fb87SGovind Singh 				       u32 *base_vector);
791399fb87SGovind Singh int ath11k_pci_get_msi_irq(struct device *dev, unsigned int vector);
80f3c603d4SCarl Huang void ath11k_pci_write32(struct ath11k_base *ab, u32 offset, u32 value);
81f3c603d4SCarl Huang u32 ath11k_pci_read32(struct ath11k_base *ab, u32 offset);
821399fb87SGovind Singh 
831399fb87SGovind Singh #endif
84