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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2022-2023 Bjoern A. Zeeb
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _LINUXKPI_LINUX_MHI_H
#define _LINUXKPI_LINUX_MHI_H
#include <linux/types.h>
/* Modem Host Interface (MHI) */
/* XXX FIXME */
#define MHI_DB_BRST_DISABLE 0
#define MHI_ER_CTRL 0
enum mhi_callback {
MHI_CB_SYS_ERROR,
MHI_CB_BW_REQ,
MHI_CB_EE_MISSION_MODE,
MHI_CB_EE_RDDM,
MHI_CB_FATAL_ERROR,
MHI_CB_IDLE,
MHI_CB_LPM_ENTER,
MHI_CB_LPM_EXIT,
MHI_CB_PENDING_DATA,
};
struct mhi_channel_config {
const char *name;
int auto_queue, dir, doorbell, doorbell_mode_switch, ee_mask, event_ring, lpm_notify, num, num_elements, offload_channel, pollcfg;
};
struct mhi_event_config {
int client_managed, data_type, hardware_event, irq, irq_moderation_ms, mode, num_elements, offload_channel, priority;
};
struct mhi_device {
};
struct mhi_controller_config {
const struct mhi_channel_config *ch_cfg;
struct mhi_event_config *event_cfg;
int buf_len, max_channels, num_channels, num_events, use_bounce_buf;
uint32_t timeout_ms;
};
struct mhi_controller {
struct device *cntrl_dev;
struct mhi_device *mhi_dev;
void *regs;
int *irq;
const char *fw_image;
const u8 *fw_data;
size_t fw_sz;
bool fbc_download;
size_t rddm_size;
size_t sbl_size;
size_t seg_len;
size_t reg_len;
int nr_irqs;
unsigned long irq_flags;
uint32_t timeout_ms;
dma_addr_t iova_start;
dma_addr_t iova_stop;
int (*runtime_get)(struct mhi_controller *);
void (*runtime_put)(struct mhi_controller *);
void (*status_cb)(struct mhi_controller *, enum mhi_callback);
int (*read_reg)(struct mhi_controller *, void __iomem *, uint32_t *);
void (*write_reg)(struct mhi_controller *, void __iomem *, uint32_t);
};
/* -------------------------------------------------------------------------- */
struct mhi_controller *linuxkpi_mhi_alloc_controller(void);
void linuxkpi_mhi_free_controller(struct mhi_controller *);
int linuxkpi_mhi_register_controller(struct mhi_controller *,
const struct mhi_controller_config *);
void linuxkpi_mhi_unregister_controller(struct mhi_controller *);
/* -------------------------------------------------------------------------- */
static inline struct mhi_controller *
mhi_alloc_controller(void)
{
/* Keep allocations internal to our implementation. */
return (linuxkpi_mhi_alloc_controller());
}
static inline void
mhi_free_controller(struct mhi_controller *mhi_ctrl)
{
linuxkpi_mhi_free_controller(mhi_ctrl);
}
static inline int
mhi_register_controller(struct mhi_controller *mhi_ctrl,
const struct mhi_controller_config *cfg)
{
return (linuxkpi_mhi_register_controller(mhi_ctrl, cfg));
}
static inline void
mhi_unregister_controller(struct mhi_controller *mhi_ctrl)
{
linuxkpi_mhi_unregister_controller(mhi_ctrl);
}
/* -------------------------------------------------------------------------- */
static __inline int
mhi_device_get_sync(struct mhi_device *mhi_dev)
{
/* XXX TODO */
return (-1);
}
static __inline void
mhi_device_put(struct mhi_device *mhi_dev)
{
/* XXX TODO */
}
/* -------------------------------------------------------------------------- */
static __inline int
mhi_prepare_for_power_up(struct mhi_controller *mhi_ctrl)
{
/* XXX TODO */
return (0);
}
static __inline int
mhi_sync_power_up(struct mhi_controller *mhi_ctrl)
{
/* XXX TODO */
return (0);
}
static __inline int
mhi_async_power_up(struct mhi_controller *mhi_ctrl)
{
/* XXX TODO */
return (0);
}
static __inline void
mhi_power_down(struct mhi_controller *mhi_ctrl, bool x)
{
/* XXX TODO */
}
static __inline void
mhi_unprepare_after_power_down(struct mhi_controller *mhi_ctrl)
{
/* XXX TODO */
}
/* -------------------------------------------------------------------------- */
static __inline int
mhi_pm_suspend(struct mhi_controller *mhi_ctrl)
{
/* XXX TODO */
return (0);
}
static __inline int
mhi_pm_resume(struct mhi_controller *mhi_ctrl)
{
/* XXX TODO */
return (0);
}
static __inline int
mhi_pm_resume_force(struct mhi_controller *mhi_ctrl)
{
/* XXX TODO */
return (0);
}
/* -------------------------------------------------------------------------- */
static __inline int
mhi_force_rddm_mode(struct mhi_controller *mhi_ctrl)
{
/* XXX TODO */
return (0);
}
#endif /* _LINUXKPI_LINUX_MHI_H */
|