aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/wireless/morsemicro/mm81x/hif.h
blob: e3d23423049ae5031a37333c88c5f718f83fb5cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2017-2026 Morse Micro
 */

#ifndef _MM81X_HIF_H_
#define _MM81X_HIF_H_

#include "core.h"

struct mm81x_skbq;

#define MM81X_HIF_BYPASS_TX_STATUS_IRQ_NUM (15)
#define MM81X_HIF_BYPASS_CMD_RESP_IRQ_NUM (29)
#define MM81X_HIF_IRQ_BYPASS_TX_STATUS_AVAILABLE \
	BIT(MM81X_HIF_BYPASS_TX_STATUS_IRQ_NUM)
#define MM81X_HIF_IRQ_BYPASS_CMD_RESP_AVAILABLE \
	BIT(MM81X_HIF_BYPASS_CMD_RESP_IRQ_NUM)

/* Hardware IF interrupt mask. We may use any interrupts in this range */
#define MM81X_HIF_IRQ_MASK_ALL                                       \
	(GENMASK(13, 0) | MM81X_HIF_IRQ_BYPASS_TX_STATUS_AVAILABLE | \
	 MM81X_HIF_IRQ_BYPASS_CMD_RESP_AVAILABLE)

enum mm81x_hif_flags {
	MM81X_HIF_FLAGS_DIR_TO_HOST = BIT(0),
	MM81X_HIF_FLAGS_DIR_TO_CHIP = BIT(1),
	MM81X_HIF_FLAGS_COMMAND = BIT(2),
	MM81X_HIF_FLAGS_BEACON = BIT(3),
	MM81X_HIF_FLAGS_DATA = BIT(4)
};

struct mm81x_hif_ops {
	int (*init)(struct mm81x *mors);
	void (*flush_tx_data)(struct mm81x *mors);
	void (*flush_cmds)(struct mm81x *mors);
	void (*finish)(struct mm81x *mors);
	void (*skbq_get_tx_qs)(struct mm81x *mors, struct mm81x_skbq **qs,
			       int *num_qs);
	struct mm81x_skbq *(*get_tx_cmd_queue)(struct mm81x *mors);
	struct mm81x_skbq *(*get_tx_beacon_queue)(struct mm81x *mors);
	struct mm81x_skbq *(*get_tx_mgmt_queue)(struct mm81x *mors);
	struct mm81x_skbq *(*get_tx_data_queue)(struct mm81x *mors, int aci);
	int (*handle_irq)(struct mm81x *mors, u32 status);
	int (*get_tx_buffered_count)(struct mm81x *mors);
	int (*get_tx_status_pending_count)(struct mm81x *mors);
};

static inline void mm81x_hif_clear_events(struct mm81x *mors)
{
	mors->hif.event_flags = 0;
}

static inline int mm81x_hif_init(struct mm81x *mors)
{
	return mors->hif.ops->init(mors);
}

static inline void mm81x_hif_flush_tx_data(struct mm81x *mors)
{
	mors->hif.ops->flush_tx_data(mors);
}

static inline void mm81x_hif_flush_cmds(struct mm81x *mors)
{
	mors->hif.ops->flush_cmds(mors);
}

static inline void mm81x_hif_finish(struct mm81x *mors)
{
	mors->hif.ops->finish(mors);
}

static inline void mm81x_hif_skbq_get_tx_qs(struct mm81x *mors,
					    struct mm81x_skbq **qs, int *num_qs)
{
	mors->hif.ops->skbq_get_tx_qs(mors, qs, num_qs);
}

static inline struct mm81x_skbq *mm81x_hif_get_tx_cmd_queue(struct mm81x *mors)
{
	return mors->hif.ops->get_tx_cmd_queue(mors);
}

static inline struct mm81x_skbq *
mm81x_hif_get_tx_beacon_queue(struct mm81x *mors)
{
	return mors->hif.ops->get_tx_beacon_queue(mors);
}

static inline struct mm81x_skbq *mm81x_hif_get_tx_mgmt_queue(struct mm81x *mors)
{
	return mors->hif.ops->get_tx_mgmt_queue(mors);
}

static inline struct mm81x_skbq *mm81x_hif_get_tx_data_queue(struct mm81x *mors,
							     int aci)
{
	return mors->hif.ops->get_tx_data_queue(mors, aci);
}

static inline int mm81x_hif_handle_irq(struct mm81x *mors, u32 status)
{
	return mors->hif.ops->handle_irq(mors, status);
}

static inline int mm81x_hif_get_tx_buffered_count(struct mm81x *mors)
{
	return mors->hif.ops->get_tx_buffered_count(mors);
}

static inline int mm81x_hif_get_tx_status_pending_count(struct mm81x *mors)
{
	return mors->hif.ops->get_tx_status_pending_count(mors);
}

#endif /* _MM81X_HIF_H_ */