| 1 |
/* SPDX-License-Identifier: BSD-3-Clause-Clear */ |
| 2 |
/* |
| 3 |
* Copyright (c) 2019-2021 The Linux Foundation. All rights reserved. |
| 4 |
* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved. |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef ATH12K_HIF_H |
| 8 |
#define ATH12K_HIF_H |
| 9 |
|
| 10 |
#include "core.h" |
| 11 |
|
| 12 |
struct ath12k_hif_ops { |
| 13 |
u32 (*read32)(struct ath12k_base *ab, u32 address); |
| 14 |
void (*write32)(struct ath12k_base *ab, u32 address, u32 data); |
| 15 |
void (*irq_enable)(struct ath12k_base *ab); |
| 16 |
void (*irq_disable)(struct ath12k_base *ab); |
| 17 |
int (*start)(struct ath12k_base *ab); |
| 18 |
void (*stop)(struct ath12k_base *ab); |
| 19 |
int (*power_up)(struct ath12k_base *ab); |
| 20 |
void (*power_down)(struct ath12k_base *ab, bool is_suspend); |
| 21 |
int (*suspend)(struct ath12k_base *ab); |
| 22 |
int (*resume)(struct ath12k_base *ab); |
| 23 |
int (*map_service_to_pipe)(struct ath12k_base *ab, u16 service_id, |
| 24 |
u8 *ul_pipe, u8 *dl_pipe); |
| 25 |
int (*get_user_msi_vector)(struct ath12k_base *ab, char *user_name, |
| 26 |
int *num_vectors, u32 *user_base_data, |
| 27 |
u32 *base_vector); |
| 28 |
void (*get_msi_address)(struct ath12k_base *ab, u32 *msi_addr_lo, |
| 29 |
u32 *msi_addr_hi); |
| 30 |
void (*ce_irq_enable)(struct ath12k_base *ab); |
| 31 |
void (*ce_irq_disable)(struct ath12k_base *ab); |
| 32 |
void (*get_ce_msi_idx)(struct ath12k_base *ab, u32 ce_id, u32 *msi_idx); |
| 33 |
int (*panic_handler)(struct ath12k_base *ab); |
| 34 |
void (*coredump_download)(struct ath12k_base *ab); |
| 35 |
}; |
| 36 |
|
| 37 |
static inline int ath12k_hif_map_service_to_pipe(struct ath12k_base *ab, u16 service_id, |
| 38 |
u8 *ul_pipe, u8 *dl_pipe) |
| 39 |
{ |
| 40 |
return ab->hif.ops->map_service_to_pipe(ab, service_id, |
| 41 |
ul_pipe, dl_pipe); |
| 42 |
} |
| 43 |
|
| 44 |
static inline int ath12k_hif_get_user_msi_vector(struct ath12k_base *ab, |
| 45 |
char *user_name, |
| 46 |
int *num_vectors, |
| 47 |
u32 *user_base_data, |
| 48 |
u32 *base_vector) |
| 49 |
{ |
| 50 |
if (!ab->hif.ops->get_user_msi_vector) |
| 51 |
return -EOPNOTSUPP; |
| 52 |
|
| 53 |
return ab->hif.ops->get_user_msi_vector(ab, user_name, num_vectors, |
| 54 |
user_base_data, |
| 55 |
base_vector); |
| 56 |
} |
| 57 |
|
| 58 |
static inline void ath12k_hif_get_msi_address(struct ath12k_base *ab, |
| 59 |
u32 *msi_addr_lo, |
| 60 |
u32 *msi_addr_hi) |
| 61 |
{ |
| 62 |
if (!ab->hif.ops->get_msi_address) |
| 63 |
return; |
| 64 |
|
| 65 |
ab->hif.ops->get_msi_address(ab, msi_addr_lo, msi_addr_hi); |
| 66 |
} |
| 67 |
|
| 68 |
static inline void ath12k_hif_get_ce_msi_idx(struct ath12k_base *ab, u32 ce_id, |
| 69 |
u32 *msi_data_idx) |
| 70 |
{ |
| 71 |
if (ab->hif.ops->get_ce_msi_idx) |
| 72 |
ab->hif.ops->get_ce_msi_idx(ab, ce_id, msi_data_idx); |
| 73 |
else |
| 74 |
*msi_data_idx = ce_id; |
| 75 |
} |
| 76 |
|
| 77 |
static inline void ath12k_hif_ce_irq_enable(struct ath12k_base *ab) |
| 78 |
{ |
| 79 |
if (ab->hif.ops->ce_irq_enable) |
| 80 |
ab->hif.ops->ce_irq_enable(ab); |
| 81 |
} |
| 82 |
|
| 83 |
static inline void ath12k_hif_ce_irq_disable(struct ath12k_base *ab) |
| 84 |
{ |
| 85 |
if (ab->hif.ops->ce_irq_disable) |
| 86 |
ab->hif.ops->ce_irq_disable(ab); |
| 87 |
} |
| 88 |
|
| 89 |
static inline void ath12k_hif_irq_enable(struct ath12k_base *ab) |
| 90 |
{ |
| 91 |
ab->hif.ops->irq_enable(ab); |
| 92 |
} |
| 93 |
|
| 94 |
static inline void ath12k_hif_irq_disable(struct ath12k_base *ab) |
| 95 |
{ |
| 96 |
ab->hif.ops->irq_disable(ab); |
| 97 |
} |
| 98 |
|
| 99 |
static inline int ath12k_hif_suspend(struct ath12k_base *ab) |
| 100 |
{ |
| 101 |
if (ab->hif.ops->suspend) |
| 102 |
return ab->hif.ops->suspend(ab); |
| 103 |
|
| 104 |
return 0; |
| 105 |
} |
| 106 |
|
| 107 |
static inline int ath12k_hif_resume(struct ath12k_base *ab) |
| 108 |
{ |
| 109 |
if (ab->hif.ops->resume) |
| 110 |
return ab->hif.ops->resume(ab); |
| 111 |
|
| 112 |
return 0; |
| 113 |
} |
| 114 |
|
| 115 |
static inline int ath12k_hif_start(struct ath12k_base *ab) |
| 116 |
{ |
| 117 |
return ab->hif.ops->start(ab); |
| 118 |
} |
| 119 |
|
| 120 |
static inline void ath12k_hif_stop(struct ath12k_base *ab) |
| 121 |
{ |
| 122 |
ab->hif.ops->stop(ab); |
| 123 |
} |
| 124 |
|
| 125 |
static inline u32 ath12k_hif_read32(struct ath12k_base *ab, u32 address) |
| 126 |
{ |
| 127 |
return ab->hif.ops->read32(ab, address); |
| 128 |
} |
| 129 |
|
| 130 |
static inline void ath12k_hif_write32(struct ath12k_base *ab, u32 address, |
| 131 |
u32 data) |
| 132 |
{ |
| 133 |
ab->hif.ops->write32(ab, address, data); |
| 134 |
} |
| 135 |
|
| 136 |
static inline int ath12k_hif_power_up(struct ath12k_base *ab) |
| 137 |
{ |
| 138 |
if (!ab->hif.ops->power_up) |
| 139 |
return -EOPNOTSUPP; |
| 140 |
|
| 141 |
return ab->hif.ops->power_up(ab); |
| 142 |
} |
| 143 |
|
| 144 |
static inline void ath12k_hif_power_down(struct ath12k_base *ab, bool is_suspend) |
| 145 |
{ |
| 146 |
if (!ab->hif.ops->power_down) |
| 147 |
return; |
| 148 |
|
| 149 |
ab->hif.ops->power_down(ab, is_suspend); |
| 150 |
} |
| 151 |
|
| 152 |
static inline int ath12k_hif_panic_handler(struct ath12k_base *ab) |
| 153 |
{ |
| 154 |
if (!ab->hif.ops->panic_handler) |
| 155 |
return NOTIFY_DONE; |
| 156 |
|
| 157 |
return ab->hif.ops->panic_handler(ab); |
| 158 |
} |
| 159 |
|
| 160 |
static inline void ath12k_hif_coredump_download(struct ath12k_base *ab) |
| 161 |
{ |
| 162 |
if (ab->hif.ops->coredump_download) |
| 163 |
ab->hif.ops->coredump_download(ab); |
| 164 |
} |
| 165 |
#endif /* ATH12K_HIF_H */ |