xref: /linux/drivers/net/wireless/ath/ath12k/ahb.h (revision 91ec2035134982b98fab0609a9fd8480e8217dc1)
1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
2 /*
3  * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4  * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5  */
6 #ifndef ATH12K_AHB_H
7 #define ATH12K_AHB_H
8 
9 #include <linux/clk.h>
10 #include <linux/remoteproc/qcom_rproc.h>
11 #include <linux/platform_device.h>
12 #include "core.h"
13 
14 #define ATH12K_AHB_RECOVERY_TIMEOUT (3 * HZ)
15 
16 #define ATH12K_AHB_SMP2P_SMEM_MSG		GENMASK(15, 0)
17 #define ATH12K_AHB_SMP2P_SMEM_SEQ_NO		GENMASK(31, 16)
18 #define ATH12K_AHB_SMP2P_SMEM_VALUE_MASK	0xFFFFFFFF
19 #define ATH12K_PCI_CE_WAKE_IRQ			2
20 #define ATH12K_PCI_IRQ_CE0_OFFSET		3
21 #define ATH12K_ROOTPD_READY_TIMEOUT		(5 * HZ)
22 #define ATH12K_RPROC_AFTER_POWERUP		QCOM_SSR_AFTER_POWERUP
23 #define ATH12K_AHB_FW_PREFIX			"q6_fw"
24 #define ATH12K_AHB_FW_SUFFIX			".mbn"
25 #define ATH12K_AHB_FW2				"iu_fw.mbn"
26 #define ATH12K_AHB_UPD_SWID			0x12
27 #define ATH12K_USERPD_SPAWN_TIMEOUT		(5 * HZ)
28 #define ATH12K_USERPD_READY_TIMEOUT		(10 * HZ)
29 #define ATH12K_USERPD_STOP_TIMEOUT		(5 * HZ)
30 #define ATH12K_USERPD_ID_MASK			GENMASK(10, 8)
31 #define ATH12K_USERPD_FW_NAME_LEN		35
32 
33 enum ath12k_ahb_userpd_id {
34 	ATH12K_AHB_USERPD_ID_0 = 1,
35 	ATH12K_AHB_USERPD_ID_1,
36 	ATH12K_AHB_USERPD_ID_2,
37 };
38 
39 struct ath12k_ahb_userpd_map {
40 	phys_addr_t io_start;
41 	const char *node_name;
42 	u32 upd_id;
43 };
44 
45 struct ath12k_ahb_desc {
46 	enum ath12k_hw_rev hw_rev;
47 	bool auth_enabled;
48 	const struct ath12k_hif_ops *ops;
49 };
50 
51 enum ath12k_ahb_smp2p_msg_id {
52 	ATH12K_AHB_POWER_SAVE_ENTER = 1,
53 	ATH12K_AHB_POWER_SAVE_EXIT,
54 };
55 
56 enum ath12k_ahb_userpd_irq {
57 	ATH12K_USERPD_SPAWN_IRQ,
58 	ATH12K_USERPD_READY_IRQ,
59 	ATH12K_USERPD_STOP_ACK_IRQ,
60 	ATH12K_USERPD_MAX_IRQ,
61 };
62 
63 struct ath12k_base;
64 extern const struct ath12k_hif_ops ath12k_ahb_hif_ops;
65 
66 struct ath12k_ahb_device_family_ops {
67 	int (*probe)(struct platform_device *pdev);
68 	int (*arch_init)(struct ath12k_base *ab);
69 	void (*arch_deinit)(struct ath12k_base *ab);
70 };
71 
72 struct ath12k_ahb_rproc_info {
73 	struct rproc *tgt_rproc;
74 	struct notifier_block root_pd_nb;
75 	void *root_pd_notifier;
76 	struct completion rootpd_ready;
77 	u8 num_userpd;
78 	bool rootpd_booted_by_driver;
79 	struct ath12k_ahb *userpd[ATH12K_MAX_DEVICES];
80 };
81 
82 struct ath12k_ahb {
83 	struct ath12k_base *ab;
84 	struct clk *xo_clk;
85 	struct qcom_smem_state *spawn_state;
86 	struct qcom_smem_state *stop_state;
87 	struct completion userpd_spawned;
88 	struct completion userpd_ready;
89 	struct completion userpd_stopped;
90 	u32 userpd_id;
91 	u32 spawn_bit;
92 	u32 stop_bit;
93 	int userpd_irq_num[ATH12K_USERPD_MAX_IRQ];
94 	const struct ath12k_ahb_ops *ahb_ops;
95 	const struct ath12k_ahb_device_family_ops *device_family_ops;
96 	bool scm_auth_enabled;
97 	struct ath12k_ahb_rproc_info *rproc_info;
98 };
99 
100 struct ath12k_ahb_driver {
101 	const char *name;
102 	const struct of_device_id *id_table;
103 	struct ath12k_ahb_device_family_ops ops;
104 	struct platform_driver driver;
105 };
106 
ath12k_ab_to_ahb(struct ath12k_base * ab)107 static inline struct ath12k_ahb *ath12k_ab_to_ahb(struct ath12k_base *ab)
108 {
109 	return (struct ath12k_ahb *)ab->drv_priv;
110 }
111 
112 int ath12k_ahb_register_driver(const enum ath12k_device_family device_id,
113 			       struct ath12k_ahb_driver *driver);
114 void ath12k_ahb_unregister_driver(const enum ath12k_device_family device_id);
115 
116 #endif
117