xref: /linux/drivers/net/wireless/ath/ath12k/ahb.h (revision a34b0e4e21d6be3c3d620aa7f9dfbf0e9550c19e)
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			".mdt"
25 #define ATH12K_AHB_FW2				"iu_fw.mdt"
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(9, 8)
31 #define ATH12K_USERPD_FW_NAME_LEN		35
32 
33 enum ath12k_ahb_smp2p_msg_id {
34 	ATH12K_AHB_POWER_SAVE_ENTER = 1,
35 	ATH12K_AHB_POWER_SAVE_EXIT,
36 };
37 
38 enum ath12k_ahb_userpd_irq {
39 	ATH12K_USERPD_SPAWN_IRQ,
40 	ATH12K_USERPD_READY_IRQ,
41 	ATH12K_USERPD_STOP_ACK_IRQ,
42 	ATH12K_USERPD_MAX_IRQ,
43 };
44 
45 struct ath12k_base;
46 
47 struct ath12k_ahb_device_family_ops {
48 	int (*probe)(struct platform_device *pdev);
49 	int (*arch_init)(struct ath12k_base *ab);
50 	void (*arch_deinit)(struct ath12k_base *ab);
51 };
52 
53 struct ath12k_ahb {
54 	struct ath12k_base *ab;
55 	struct rproc *tgt_rproc;
56 	struct clk *xo_clk;
57 	struct completion rootpd_ready;
58 	struct notifier_block root_pd_nb;
59 	void *root_pd_notifier;
60 	struct qcom_smem_state *spawn_state;
61 	struct qcom_smem_state *stop_state;
62 	struct completion userpd_spawned;
63 	struct completion userpd_ready;
64 	struct completion userpd_stopped;
65 	u32 userpd_id;
66 	u32 spawn_bit;
67 	u32 stop_bit;
68 	int userpd_irq_num[ATH12K_USERPD_MAX_IRQ];
69 	const struct ath12k_ahb_ops *ahb_ops;
70 	const struct ath12k_ahb_device_family_ops *device_family_ops;
71 };
72 
73 struct ath12k_ahb_driver {
74 	const char *name;
75 	const struct of_device_id *id_table;
76 	struct ath12k_ahb_device_family_ops ops;
77 	struct platform_driver driver;
78 };
79 
80 static inline struct ath12k_ahb *ath12k_ab_to_ahb(struct ath12k_base *ab)
81 {
82 	return (struct ath12k_ahb *)ab->drv_priv;
83 }
84 
85 int ath12k_ahb_register_driver(const enum ath12k_device_family device_id,
86 			       struct ath12k_ahb_driver *driver);
87 void ath12k_ahb_unregister_driver(const enum ath12k_device_family device_id);
88 
89 #endif
90