1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (c) 2017-2026 Morse Micro 4 */ 5 6 #ifndef _MM81X_HIF_H_ 7 #define _MM81X_HIF_H_ 8 9 #include "core.h" 10 11 struct mm81x_skbq; 12 13 #define MM81X_HIF_BYPASS_TX_STATUS_IRQ_NUM (15) 14 #define MM81X_HIF_BYPASS_CMD_RESP_IRQ_NUM (29) 15 #define MM81X_HIF_IRQ_BYPASS_TX_STATUS_AVAILABLE \ 16 BIT(MM81X_HIF_BYPASS_TX_STATUS_IRQ_NUM) 17 #define MM81X_HIF_IRQ_BYPASS_CMD_RESP_AVAILABLE \ 18 BIT(MM81X_HIF_BYPASS_CMD_RESP_IRQ_NUM) 19 20 /* Hardware IF interrupt mask. We may use any interrupts in this range */ 21 #define MM81X_HIF_IRQ_MASK_ALL \ 22 (GENMASK(13, 0) | MM81X_HIF_IRQ_BYPASS_TX_STATUS_AVAILABLE | \ 23 MM81X_HIF_IRQ_BYPASS_CMD_RESP_AVAILABLE) 24 25 enum mm81x_hif_flags { 26 MM81X_HIF_FLAGS_DIR_TO_HOST = BIT(0), 27 MM81X_HIF_FLAGS_DIR_TO_CHIP = BIT(1), 28 MM81X_HIF_FLAGS_COMMAND = BIT(2), 29 MM81X_HIF_FLAGS_BEACON = BIT(3), 30 MM81X_HIF_FLAGS_DATA = BIT(4) 31 }; 32 33 struct mm81x_hif_ops { 34 int (*init)(struct mm81x *mors); 35 void (*flush_tx_data)(struct mm81x *mors); 36 void (*flush_cmds)(struct mm81x *mors); 37 void (*finish)(struct mm81x *mors); 38 void (*skbq_get_tx_qs)(struct mm81x *mors, struct mm81x_skbq **qs, 39 int *num_qs); 40 struct mm81x_skbq *(*get_tx_cmd_queue)(struct mm81x *mors); 41 struct mm81x_skbq *(*get_tx_beacon_queue)(struct mm81x *mors); 42 struct mm81x_skbq *(*get_tx_mgmt_queue)(struct mm81x *mors); 43 struct mm81x_skbq *(*get_tx_data_queue)(struct mm81x *mors, int aci); 44 int (*handle_irq)(struct mm81x *mors, u32 status); 45 int (*get_tx_buffered_count)(struct mm81x *mors); 46 int (*get_tx_status_pending_count)(struct mm81x *mors); 47 }; 48 49 static inline void mm81x_hif_clear_events(struct mm81x *mors) 50 { 51 mors->hif.event_flags = 0; 52 } 53 54 static inline int mm81x_hif_init(struct mm81x *mors) 55 { 56 return mors->hif.ops->init(mors); 57 } 58 59 static inline void mm81x_hif_flush_tx_data(struct mm81x *mors) 60 { 61 mors->hif.ops->flush_tx_data(mors); 62 } 63 64 static inline void mm81x_hif_flush_cmds(struct mm81x *mors) 65 { 66 mors->hif.ops->flush_cmds(mors); 67 } 68 69 static inline void mm81x_hif_finish(struct mm81x *mors) 70 { 71 mors->hif.ops->finish(mors); 72 } 73 74 static inline void mm81x_hif_skbq_get_tx_qs(struct mm81x *mors, 75 struct mm81x_skbq **qs, int *num_qs) 76 { 77 mors->hif.ops->skbq_get_tx_qs(mors, qs, num_qs); 78 } 79 80 static inline struct mm81x_skbq *mm81x_hif_get_tx_cmd_queue(struct mm81x *mors) 81 { 82 return mors->hif.ops->get_tx_cmd_queue(mors); 83 } 84 85 static inline struct mm81x_skbq * 86 mm81x_hif_get_tx_beacon_queue(struct mm81x *mors) 87 { 88 return mors->hif.ops->get_tx_beacon_queue(mors); 89 } 90 91 static inline struct mm81x_skbq *mm81x_hif_get_tx_mgmt_queue(struct mm81x *mors) 92 { 93 return mors->hif.ops->get_tx_mgmt_queue(mors); 94 } 95 96 static inline struct mm81x_skbq *mm81x_hif_get_tx_data_queue(struct mm81x *mors, 97 int aci) 98 { 99 return mors->hif.ops->get_tx_data_queue(mors, aci); 100 } 101 102 static inline int mm81x_hif_handle_irq(struct mm81x *mors, u32 status) 103 { 104 return mors->hif.ops->handle_irq(mors, status); 105 } 106 107 static inline int mm81x_hif_get_tx_buffered_count(struct mm81x *mors) 108 { 109 return mors->hif.ops->get_tx_buffered_count(mors); 110 } 111 112 static inline int mm81x_hif_get_tx_status_pending_count(struct mm81x *mors) 113 { 114 return mors->hif.ops->get_tx_status_pending_count(mors); 115 } 116 117 #endif /* _MM81X_HIF_H_ */ 118