Linux Audio

Check our new training course

Loading...
v6.8
  1/* SPDX-License-Identifier: BSD-3-Clause-Clear */
  2/*
  3 * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved.
  4 * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5 */
  6
  7#ifndef _HIF_H_
  8#define _HIF_H_
  9
 10#include "core.h"
 11
 12struct ath11k_hif_ops {
 13	u32 (*read32)(struct ath11k_base *ab, u32 address);
 14	void (*write32)(struct ath11k_base *ab, u32 address, u32 data);
 15	int (*read)(struct ath11k_base *ab, void *buf, u32 start, u32 end);
 16	void (*irq_enable)(struct ath11k_base *ab);
 17	void (*irq_disable)(struct ath11k_base *ab);
 18	int (*start)(struct ath11k_base *ab);
 19	void (*stop)(struct ath11k_base *ab);
 20	int (*power_up)(struct ath11k_base *ab);
 21	void (*power_down)(struct ath11k_base *ab);
 22	int (*suspend)(struct ath11k_base *ab);
 23	int (*resume)(struct ath11k_base *ab);
 24	int (*map_service_to_pipe)(struct ath11k_base *ab, u16 service_id,
 25				   u8 *ul_pipe, u8 *dl_pipe);
 26	int (*get_user_msi_vector)(struct ath11k_base *ab, char *user_name,
 27				   int *num_vectors, u32 *user_base_data,
 28				   u32 *base_vector);
 29	void (*get_msi_address)(struct ath11k_base *ab, u32 *msi_addr_lo,
 30				u32 *msi_addr_hi);
 31	void (*ce_irq_enable)(struct ath11k_base *ab);
 32	void (*ce_irq_disable)(struct ath11k_base *ab);
 33	void (*get_ce_msi_idx)(struct ath11k_base *ab, u32 ce_id, u32 *msi_idx);
 34};
 35
 36static inline void ath11k_hif_ce_irq_enable(struct ath11k_base *ab)
 37{
 38	if (ab->hif.ops->ce_irq_enable)
 39		ab->hif.ops->ce_irq_enable(ab);
 40}
 41
 42static inline void ath11k_hif_ce_irq_disable(struct ath11k_base *ab)
 43{
 44	if (ab->hif.ops->ce_irq_disable)
 45		ab->hif.ops->ce_irq_disable(ab);
 46}
 47
 48static inline int ath11k_hif_start(struct ath11k_base *ab)
 49{
 50	return ab->hif.ops->start(ab);
 51}
 52
 53static inline void ath11k_hif_stop(struct ath11k_base *ab)
 54{
 55	ab->hif.ops->stop(ab);
 56}
 57
 58static inline void ath11k_hif_irq_enable(struct ath11k_base *ab)
 59{
 60	ab->hif.ops->irq_enable(ab);
 61}
 62
 63static inline void ath11k_hif_irq_disable(struct ath11k_base *ab)
 64{
 65	ab->hif.ops->irq_disable(ab);
 66}
 67
 68static inline int ath11k_hif_power_up(struct ath11k_base *ab)
 69{
 70	return ab->hif.ops->power_up(ab);
 71}
 72
 73static inline void ath11k_hif_power_down(struct ath11k_base *ab)
 74{
 75	ab->hif.ops->power_down(ab);
 76}
 77
 78static inline int ath11k_hif_suspend(struct ath11k_base *ab)
 79{
 80	if (ab->hif.ops->suspend)
 81		return ab->hif.ops->suspend(ab);
 82
 83	return 0;
 84}
 85
 86static inline int ath11k_hif_resume(struct ath11k_base *ab)
 87{
 88	if (ab->hif.ops->resume)
 89		return ab->hif.ops->resume(ab);
 90
 91	return 0;
 92}
 93
 94static inline u32 ath11k_hif_read32(struct ath11k_base *ab, u32 address)
 95{
 96	return ab->hif.ops->read32(ab, address);
 97}
 98
 99static inline void ath11k_hif_write32(struct ath11k_base *ab, u32 address, u32 data)
100{
101	ab->hif.ops->write32(ab, address, data);
102}
103
104static inline int ath11k_hif_read(struct ath11k_base *ab, void *buf,
105				  u32 start, u32 end)
106{
107	if (!ab->hif.ops->read)
108		return -EOPNOTSUPP;
109
110	return ab->hif.ops->read(ab, buf, start, end);
111}
112
113static inline int ath11k_hif_map_service_to_pipe(struct ath11k_base *ab, u16 service_id,
114						 u8 *ul_pipe, u8 *dl_pipe)
115{
116	return ab->hif.ops->map_service_to_pipe(ab, service_id, ul_pipe, dl_pipe);
117}
118
119static inline int ath11k_get_user_msi_vector(struct ath11k_base *ab, char *user_name,
120					     int *num_vectors, u32 *user_base_data,
121					     u32 *base_vector)
122{
123	if (!ab->hif.ops->get_user_msi_vector)
124		return -EOPNOTSUPP;
125
126	return ab->hif.ops->get_user_msi_vector(ab, user_name, num_vectors,
127						user_base_data,
128						base_vector);
129}
130
131static inline void ath11k_get_msi_address(struct ath11k_base *ab, u32 *msi_addr_lo,
132					  u32 *msi_addr_hi)
133{
134	if (!ab->hif.ops->get_msi_address)
135		return;
136
137	ab->hif.ops->get_msi_address(ab, msi_addr_lo, msi_addr_hi);
138}
139
140static inline void ath11k_get_ce_msi_idx(struct ath11k_base *ab, u32 ce_id,
141					 u32 *msi_data_idx)
142{
143	if (ab->hif.ops->get_ce_msi_idx)
144		ab->hif.ops->get_ce_msi_idx(ab, ce_id, msi_data_idx);
145	else
146		*msi_data_idx = ce_id;
147}
148
149#endif /* _HIF_H_ */
v6.2
  1/* SPDX-License-Identifier: BSD-3-Clause-Clear */
  2/*
  3 * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved.
 
  4 */
  5
  6#ifndef _HIF_H_
  7#define _HIF_H_
  8
  9#include "core.h"
 10
 11struct ath11k_hif_ops {
 12	u32 (*read32)(struct ath11k_base *sc, u32 address);
 13	void (*write32)(struct ath11k_base *sc, u32 address, u32 data);
 14	int (*read)(struct ath11k_base *ab, void *buf, u32 start, u32 end);
 15	void (*irq_enable)(struct ath11k_base *sc);
 16	void (*irq_disable)(struct ath11k_base *sc);
 17	int (*start)(struct ath11k_base *sc);
 18	void (*stop)(struct ath11k_base *sc);
 19	int (*power_up)(struct ath11k_base *sc);
 20	void (*power_down)(struct ath11k_base *sc);
 21	int (*suspend)(struct ath11k_base *ab);
 22	int (*resume)(struct ath11k_base *ab);
 23	int (*map_service_to_pipe)(struct ath11k_base *sc, u16 service_id,
 24				   u8 *ul_pipe, u8 *dl_pipe);
 25	int (*get_user_msi_vector)(struct ath11k_base *ab, char *user_name,
 26				   int *num_vectors, u32 *user_base_data,
 27				   u32 *base_vector);
 28	void (*get_msi_address)(struct ath11k_base *ab, u32 *msi_addr_lo,
 29				u32 *msi_addr_hi);
 30	void (*ce_irq_enable)(struct ath11k_base *ab);
 31	void (*ce_irq_disable)(struct ath11k_base *ab);
 32	void (*get_ce_msi_idx)(struct ath11k_base *ab, u32 ce_id, u32 *msi_idx);
 33};
 34
 35static inline void ath11k_hif_ce_irq_enable(struct ath11k_base *ab)
 36{
 37	if (ab->hif.ops->ce_irq_enable)
 38		ab->hif.ops->ce_irq_enable(ab);
 39}
 40
 41static inline void ath11k_hif_ce_irq_disable(struct ath11k_base *ab)
 42{
 43	if (ab->hif.ops->ce_irq_disable)
 44		ab->hif.ops->ce_irq_disable(ab);
 45}
 46
 47static inline int ath11k_hif_start(struct ath11k_base *sc)
 48{
 49	return sc->hif.ops->start(sc);
 50}
 51
 52static inline void ath11k_hif_stop(struct ath11k_base *sc)
 53{
 54	sc->hif.ops->stop(sc);
 55}
 56
 57static inline void ath11k_hif_irq_enable(struct ath11k_base *sc)
 58{
 59	sc->hif.ops->irq_enable(sc);
 60}
 61
 62static inline void ath11k_hif_irq_disable(struct ath11k_base *sc)
 63{
 64	sc->hif.ops->irq_disable(sc);
 65}
 66
 67static inline int ath11k_hif_power_up(struct ath11k_base *sc)
 68{
 69	return sc->hif.ops->power_up(sc);
 70}
 71
 72static inline void ath11k_hif_power_down(struct ath11k_base *sc)
 73{
 74	sc->hif.ops->power_down(sc);
 75}
 76
 77static inline int ath11k_hif_suspend(struct ath11k_base *ab)
 78{
 79	if (ab->hif.ops->suspend)
 80		return ab->hif.ops->suspend(ab);
 81
 82	return 0;
 83}
 84
 85static inline int ath11k_hif_resume(struct ath11k_base *ab)
 86{
 87	if (ab->hif.ops->resume)
 88		return ab->hif.ops->resume(ab);
 89
 90	return 0;
 91}
 92
 93static inline u32 ath11k_hif_read32(struct ath11k_base *sc, u32 address)
 94{
 95	return sc->hif.ops->read32(sc, address);
 96}
 97
 98static inline void ath11k_hif_write32(struct ath11k_base *sc, u32 address, u32 data)
 99{
100	sc->hif.ops->write32(sc, address, data);
101}
102
103static inline int ath11k_hif_read(struct ath11k_base *ab, void *buf,
104				  u32 start, u32 end)
105{
106	if (!ab->hif.ops->read)
107		return -EOPNOTSUPP;
108
109	return ab->hif.ops->read(ab, buf, start, end);
110}
111
112static inline int ath11k_hif_map_service_to_pipe(struct ath11k_base *sc, u16 service_id,
113						 u8 *ul_pipe, u8 *dl_pipe)
114{
115	return sc->hif.ops->map_service_to_pipe(sc, service_id, ul_pipe, dl_pipe);
116}
117
118static inline int ath11k_get_user_msi_vector(struct ath11k_base *ab, char *user_name,
119					     int *num_vectors, u32 *user_base_data,
120					     u32 *base_vector)
121{
122	if (!ab->hif.ops->get_user_msi_vector)
123		return -EOPNOTSUPP;
124
125	return ab->hif.ops->get_user_msi_vector(ab, user_name, num_vectors,
126						user_base_data,
127						base_vector);
128}
129
130static inline void ath11k_get_msi_address(struct ath11k_base *ab, u32 *msi_addr_lo,
131					  u32 *msi_addr_hi)
132{
133	if (!ab->hif.ops->get_msi_address)
134		return;
135
136	ab->hif.ops->get_msi_address(ab, msi_addr_lo, msi_addr_hi);
137}
138
139static inline void ath11k_get_ce_msi_idx(struct ath11k_base *ab, u32 ce_id,
140					 u32 *msi_data_idx)
141{
142	if (ab->hif.ops->get_ce_msi_idx)
143		ab->hif.ops->get_ce_msi_idx(ab, ce_id, msi_data_idx);
144	else
145		*msi_data_idx = ce_id;
146}
147
148#endif /* _HIF_H_ */