xref: /linux/drivers/net/wireless/ath/ath11k/hif.h (revision 1a371190a375f98c9b106f758ea41558c3f92556)
131858805SGovind Singh /* SPDX-License-Identifier: BSD-3-Clause-Clear */
231858805SGovind Singh /*
331858805SGovind Singh  * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved.
4166a490fSBaochen Qiang  * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
531858805SGovind Singh  */
631858805SGovind Singh 
76e0355afSGovind Singh #ifndef _HIF_H_
86e0355afSGovind Singh #define _HIF_H_
96e0355afSGovind Singh 
1031858805SGovind Singh #include "core.h"
1131858805SGovind Singh 
1231858805SGovind Singh struct ath11k_hif_ops {
132e66190eSKarthikeyan Periyasamy 	u32 (*read32)(struct ath11k_base *ab, u32 address);
142e66190eSKarthikeyan Periyasamy 	void (*write32)(struct ath11k_base *ab, u32 address, u32 data);
15876eb848SBaochen Qiang 	int (*read)(struct ath11k_base *ab, void *buf, u32 start, u32 end);
162e66190eSKarthikeyan Periyasamy 	void (*irq_enable)(struct ath11k_base *ab);
172e66190eSKarthikeyan Periyasamy 	void (*irq_disable)(struct ath11k_base *ab);
182e66190eSKarthikeyan Periyasamy 	int (*start)(struct ath11k_base *ab);
192e66190eSKarthikeyan Periyasamy 	void (*stop)(struct ath11k_base *ab);
202e66190eSKarthikeyan Periyasamy 	int (*power_up)(struct ath11k_base *ab);
21*2f833e89SBaochen Qiang 	void (*power_down)(struct ath11k_base *ab);
22fa5917e4SCarl Huang 	int (*suspend)(struct ath11k_base *ab);
23fa5917e4SCarl Huang 	int (*resume)(struct ath11k_base *ab);
242e66190eSKarthikeyan Periyasamy 	int (*map_service_to_pipe)(struct ath11k_base *ab, u16 service_id,
2531858805SGovind Singh 				   u8 *ul_pipe, u8 *dl_pipe);
26c4eacabeSGovind Singh 	int (*get_user_msi_vector)(struct ath11k_base *ab, char *user_name,
27c4eacabeSGovind Singh 				   int *num_vectors, u32 *user_base_data,
28c4eacabeSGovind Singh 				   u32 *base_vector);
29c4eacabeSGovind Singh 	void (*get_msi_address)(struct ath11k_base *ab, u32 *msi_addr_lo,
30c4eacabeSGovind Singh 				u32 *msi_addr_hi);
31d578ec2aSCarl Huang 	void (*ce_irq_enable)(struct ath11k_base *ab);
32d578ec2aSCarl Huang 	void (*ce_irq_disable)(struct ath11k_base *ab);
336289ac2bSKarthikeyan Periyasamy 	void (*get_ce_msi_idx)(struct ath11k_base *ab, u32 ce_id, u32 *msi_idx);
3431858805SGovind Singh };
3531858805SGovind Singh 
ath11k_hif_ce_irq_enable(struct ath11k_base * ab)36d578ec2aSCarl Huang static inline void ath11k_hif_ce_irq_enable(struct ath11k_base *ab)
37d578ec2aSCarl Huang {
38d578ec2aSCarl Huang 	if (ab->hif.ops->ce_irq_enable)
39d578ec2aSCarl Huang 		ab->hif.ops->ce_irq_enable(ab);
40d578ec2aSCarl Huang }
41d578ec2aSCarl Huang 
ath11k_hif_ce_irq_disable(struct ath11k_base * ab)42d578ec2aSCarl Huang static inline void ath11k_hif_ce_irq_disable(struct ath11k_base *ab)
43d578ec2aSCarl Huang {
44d578ec2aSCarl Huang 	if (ab->hif.ops->ce_irq_disable)
45d578ec2aSCarl Huang 		ab->hif.ops->ce_irq_disable(ab);
46d578ec2aSCarl Huang }
47d578ec2aSCarl Huang 
ath11k_hif_start(struct ath11k_base * ab)482e66190eSKarthikeyan Periyasamy static inline int ath11k_hif_start(struct ath11k_base *ab)
4931858805SGovind Singh {
502e66190eSKarthikeyan Periyasamy 	return ab->hif.ops->start(ab);
5131858805SGovind Singh }
5231858805SGovind Singh 
ath11k_hif_stop(struct ath11k_base * ab)532e66190eSKarthikeyan Periyasamy static inline void ath11k_hif_stop(struct ath11k_base *ab)
5431858805SGovind Singh {
552e66190eSKarthikeyan Periyasamy 	ab->hif.ops->stop(ab);
5631858805SGovind Singh }
5731858805SGovind Singh 
ath11k_hif_irq_enable(struct ath11k_base * ab)582e66190eSKarthikeyan Periyasamy static inline void ath11k_hif_irq_enable(struct ath11k_base *ab)
5931858805SGovind Singh {
602e66190eSKarthikeyan Periyasamy 	ab->hif.ops->irq_enable(ab);
6131858805SGovind Singh }
6231858805SGovind Singh 
ath11k_hif_irq_disable(struct ath11k_base * ab)632e66190eSKarthikeyan Periyasamy static inline void ath11k_hif_irq_disable(struct ath11k_base *ab)
6431858805SGovind Singh {
652e66190eSKarthikeyan Periyasamy 	ab->hif.ops->irq_disable(ab);
6631858805SGovind Singh }
6731858805SGovind Singh 
ath11k_hif_power_up(struct ath11k_base * ab)682e66190eSKarthikeyan Periyasamy static inline int ath11k_hif_power_up(struct ath11k_base *ab)
6931858805SGovind Singh {
702e66190eSKarthikeyan Periyasamy 	return ab->hif.ops->power_up(ab);
7131858805SGovind Singh }
7231858805SGovind Singh 
ath11k_hif_power_down(struct ath11k_base * ab)73*2f833e89SBaochen Qiang static inline void ath11k_hif_power_down(struct ath11k_base *ab)
7431858805SGovind Singh {
75*2f833e89SBaochen Qiang 	ab->hif.ops->power_down(ab);
7631858805SGovind Singh }
7731858805SGovind Singh 
ath11k_hif_suspend(struct ath11k_base * ab)78fa5917e4SCarl Huang static inline int ath11k_hif_suspend(struct ath11k_base *ab)
79fa5917e4SCarl Huang {
80fa5917e4SCarl Huang 	if (ab->hif.ops->suspend)
81fa5917e4SCarl Huang 		return ab->hif.ops->suspend(ab);
82fa5917e4SCarl Huang 
83fa5917e4SCarl Huang 	return 0;
84fa5917e4SCarl Huang }
85fa5917e4SCarl Huang 
ath11k_hif_resume(struct ath11k_base * ab)86fa5917e4SCarl Huang static inline int ath11k_hif_resume(struct ath11k_base *ab)
87fa5917e4SCarl Huang {
88fa5917e4SCarl Huang 	if (ab->hif.ops->resume)
89fa5917e4SCarl Huang 		return ab->hif.ops->resume(ab);
90fa5917e4SCarl Huang 
91fa5917e4SCarl Huang 	return 0;
92fa5917e4SCarl Huang }
93fa5917e4SCarl Huang 
ath11k_hif_read32(struct ath11k_base * ab,u32 address)942e66190eSKarthikeyan Periyasamy static inline u32 ath11k_hif_read32(struct ath11k_base *ab, u32 address)
9531858805SGovind Singh {
962e66190eSKarthikeyan Periyasamy 	return ab->hif.ops->read32(ab, address);
9731858805SGovind Singh }
9831858805SGovind Singh 
ath11k_hif_write32(struct ath11k_base * ab,u32 address,u32 data)992e66190eSKarthikeyan Periyasamy static inline void ath11k_hif_write32(struct ath11k_base *ab, u32 address, u32 data)
10031858805SGovind Singh {
1012e66190eSKarthikeyan Periyasamy 	ab->hif.ops->write32(ab, address, data);
10231858805SGovind Singh }
10331858805SGovind Singh 
ath11k_hif_read(struct ath11k_base * ab,void * buf,u32 start,u32 end)104876eb848SBaochen Qiang static inline int ath11k_hif_read(struct ath11k_base *ab, void *buf,
105876eb848SBaochen Qiang 				  u32 start, u32 end)
106876eb848SBaochen Qiang {
107876eb848SBaochen Qiang 	if (!ab->hif.ops->read)
108876eb848SBaochen Qiang 		return -EOPNOTSUPP;
109876eb848SBaochen Qiang 
110876eb848SBaochen Qiang 	return ab->hif.ops->read(ab, buf, start, end);
111876eb848SBaochen Qiang }
112876eb848SBaochen Qiang 
ath11k_hif_map_service_to_pipe(struct ath11k_base * ab,u16 service_id,u8 * ul_pipe,u8 * dl_pipe)1132e66190eSKarthikeyan Periyasamy static inline int ath11k_hif_map_service_to_pipe(struct ath11k_base *ab, u16 service_id,
11431858805SGovind Singh 						 u8 *ul_pipe, u8 *dl_pipe)
11531858805SGovind Singh {
1162e66190eSKarthikeyan Periyasamy 	return ab->hif.ops->map_service_to_pipe(ab, service_id, ul_pipe, dl_pipe);
11731858805SGovind Singh }
118c4eacabeSGovind Singh 
ath11k_get_user_msi_vector(struct ath11k_base * ab,char * user_name,int * num_vectors,u32 * user_base_data,u32 * base_vector)119c4eacabeSGovind Singh static inline int ath11k_get_user_msi_vector(struct ath11k_base *ab, char *user_name,
120c4eacabeSGovind Singh 					     int *num_vectors, u32 *user_base_data,
121c4eacabeSGovind Singh 					     u32 *base_vector)
122c4eacabeSGovind Singh {
123c4eacabeSGovind Singh 	if (!ab->hif.ops->get_user_msi_vector)
124c4eacabeSGovind Singh 		return -EOPNOTSUPP;
125c4eacabeSGovind Singh 
126c4eacabeSGovind Singh 	return ab->hif.ops->get_user_msi_vector(ab, user_name, num_vectors,
127c4eacabeSGovind Singh 						user_base_data,
128c4eacabeSGovind Singh 						base_vector);
129c4eacabeSGovind Singh }
130c4eacabeSGovind Singh 
ath11k_get_msi_address(struct ath11k_base * ab,u32 * msi_addr_lo,u32 * msi_addr_hi)131c4eacabeSGovind Singh static inline void ath11k_get_msi_address(struct ath11k_base *ab, u32 *msi_addr_lo,
132c4eacabeSGovind Singh 					  u32 *msi_addr_hi)
133c4eacabeSGovind Singh {
134c4eacabeSGovind Singh 	if (!ab->hif.ops->get_msi_address)
135c4eacabeSGovind Singh 		return;
136c4eacabeSGovind Singh 
137c4eacabeSGovind Singh 	ab->hif.ops->get_msi_address(ab, msi_addr_lo, msi_addr_hi);
138c4eacabeSGovind Singh }
1396289ac2bSKarthikeyan Periyasamy 
ath11k_get_ce_msi_idx(struct ath11k_base * ab,u32 ce_id,u32 * msi_data_idx)1406289ac2bSKarthikeyan Periyasamy static inline void ath11k_get_ce_msi_idx(struct ath11k_base *ab, u32 ce_id,
1416289ac2bSKarthikeyan Periyasamy 					 u32 *msi_data_idx)
1426289ac2bSKarthikeyan Periyasamy {
1436289ac2bSKarthikeyan Periyasamy 	if (ab->hif.ops->get_ce_msi_idx)
1446289ac2bSKarthikeyan Periyasamy 		ab->hif.ops->get_ce_msi_idx(ab, ce_id, msi_data_idx);
1456289ac2bSKarthikeyan Periyasamy 	else
1466289ac2bSKarthikeyan Periyasamy 		*msi_data_idx = ce_id;
1476289ac2bSKarthikeyan Periyasamy }
148876eb848SBaochen Qiang 
1496e0355afSGovind Singh #endif /* _HIF_H_ */
150