This source file includes following definitions.
- mc_encode_cmd_header
- mc_cmd_hdr_read_token
- mc_cmd_read_object_id
- mc_cmd_read_api_version
- is_fsl_mc_bus_dprc
- is_fsl_mc_bus_dpni
- is_fsl_mc_bus_dpio
- is_fsl_mc_bus_dpsw
- is_fsl_mc_bus_dpbp
- is_fsl_mc_bus_dpcon
- is_fsl_mc_bus_dpmcp
- is_fsl_mc_bus_dpmac
- is_fsl_mc_bus_dprtc
- is_fsl_mc_bus_dpseci
1
2
3
4
5
6
7
8
9 #ifndef _FSL_MC_H_
10 #define _FSL_MC_H_
11
12 #include <linux/device.h>
13 #include <linux/mod_devicetable.h>
14 #include <linux/interrupt.h>
15
16 #define FSL_MC_VENDOR_FREESCALE 0x1957
17
18 struct irq_domain;
19 struct msi_domain_info;
20
21 struct fsl_mc_device;
22 struct fsl_mc_io;
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 struct fsl_mc_driver {
39 struct device_driver driver;
40 const struct fsl_mc_device_id *match_id_table;
41 int (*probe)(struct fsl_mc_device *dev);
42 int (*remove)(struct fsl_mc_device *dev);
43 void (*shutdown)(struct fsl_mc_device *dev);
44 int (*suspend)(struct fsl_mc_device *dev, pm_message_t state);
45 int (*resume)(struct fsl_mc_device *dev);
46 };
47
48 #define to_fsl_mc_driver(_drv) \
49 container_of(_drv, struct fsl_mc_driver, driver)
50
51
52
53
54
55
56
57 enum fsl_mc_pool_type {
58 FSL_MC_POOL_DPMCP = 0x0,
59 FSL_MC_POOL_DPBP,
60 FSL_MC_POOL_DPCON,
61 FSL_MC_POOL_IRQ,
62
63
64
65
66 FSL_MC_NUM_POOL_TYPES
67 };
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 struct fsl_mc_resource {
83 enum fsl_mc_pool_type type;
84 s32 id;
85 void *data;
86 struct fsl_mc_resource_pool *parent_pool;
87 struct list_head node;
88 };
89
90
91
92
93
94
95
96
97 struct fsl_mc_device_irq {
98 struct msi_desc *msi_desc;
99 struct fsl_mc_device *mc_dev;
100 u8 dev_irq_index;
101 struct fsl_mc_resource resource;
102 };
103
104 #define to_fsl_mc_irq(_mc_resource) \
105 container_of(_mc_resource, struct fsl_mc_device_irq, resource)
106
107
108 #define FSL_MC_OBJ_STATE_OPEN 0x00000001
109
110 #define FSL_MC_OBJ_STATE_PLUGGED 0x00000002
111
112
113
114
115
116
117
118 #define FSL_MC_OBJ_FLAG_NO_MEM_SHAREABILITY 0x0001
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133 struct fsl_mc_obj_desc {
134 char type[16];
135 int id;
136 u16 vendor;
137 u16 ver_major;
138 u16 ver_minor;
139 u8 irq_count;
140 u8 region_count;
141 u32 state;
142 char label[16];
143 u16 flags;
144 };
145
146
147
148
149 #define FSL_MC_IS_DPRC 0x0001
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 struct fsl_mc_device {
186 struct device dev;
187 u64 dma_mask;
188 u16 flags;
189 u16 icid;
190 u16 mc_handle;
191 struct fsl_mc_io *mc_io;
192 struct fsl_mc_obj_desc obj_desc;
193 struct resource *regions;
194 struct fsl_mc_device_irq **irqs;
195 struct fsl_mc_resource *resource;
196 struct device_link *consumer_link;
197 };
198
199 #define to_fsl_mc_device(_dev) \
200 container_of(_dev, struct fsl_mc_device, dev)
201
202 #define MC_CMD_NUM_OF_PARAMS 7
203
204 struct mc_cmd_header {
205 u8 src_id;
206 u8 flags_hw;
207 u8 status;
208 u8 flags_sw;
209 __le16 token;
210 __le16 cmd_id;
211 };
212
213 struct fsl_mc_command {
214 __le64 header;
215 __le64 params[MC_CMD_NUM_OF_PARAMS];
216 };
217
218 enum mc_cmd_status {
219 MC_CMD_STATUS_OK = 0x0,
220 MC_CMD_STATUS_READY = 0x1,
221 MC_CMD_STATUS_AUTH_ERR = 0x3,
222 MC_CMD_STATUS_NO_PRIVILEGE = 0x4,
223 MC_CMD_STATUS_DMA_ERR = 0x5,
224 MC_CMD_STATUS_CONFIG_ERR = 0x6,
225 MC_CMD_STATUS_TIMEOUT = 0x7,
226 MC_CMD_STATUS_NO_RESOURCE = 0x8,
227 MC_CMD_STATUS_NO_MEMORY = 0x9,
228 MC_CMD_STATUS_BUSY = 0xA,
229 MC_CMD_STATUS_UNSUPPORTED_OP = 0xB,
230 MC_CMD_STATUS_INVALID_STATE = 0xC
231 };
232
233
234
235
236
237
238 #define MC_CMD_FLAG_PRI 0x80
239
240 #define MC_CMD_FLAG_INTR_DIS 0x01
241
242 static inline __le64 mc_encode_cmd_header(u16 cmd_id,
243 u32 cmd_flags,
244 u16 token)
245 {
246 __le64 header = 0;
247 struct mc_cmd_header *hdr = (struct mc_cmd_header *)&header;
248
249 hdr->cmd_id = cpu_to_le16(cmd_id);
250 hdr->token = cpu_to_le16(token);
251 hdr->status = MC_CMD_STATUS_READY;
252 if (cmd_flags & MC_CMD_FLAG_PRI)
253 hdr->flags_hw = MC_CMD_FLAG_PRI;
254 if (cmd_flags & MC_CMD_FLAG_INTR_DIS)
255 hdr->flags_sw = MC_CMD_FLAG_INTR_DIS;
256
257 return header;
258 }
259
260 static inline u16 mc_cmd_hdr_read_token(struct fsl_mc_command *cmd)
261 {
262 struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header;
263 u16 token = le16_to_cpu(hdr->token);
264
265 return token;
266 }
267
268 struct mc_rsp_create {
269 __le32 object_id;
270 };
271
272 struct mc_rsp_api_ver {
273 __le16 major_ver;
274 __le16 minor_ver;
275 };
276
277 static inline u32 mc_cmd_read_object_id(struct fsl_mc_command *cmd)
278 {
279 struct mc_rsp_create *rsp_params;
280
281 rsp_params = (struct mc_rsp_create *)cmd->params;
282 return le32_to_cpu(rsp_params->object_id);
283 }
284
285 static inline void mc_cmd_read_api_version(struct fsl_mc_command *cmd,
286 u16 *major_ver,
287 u16 *minor_ver)
288 {
289 struct mc_rsp_api_ver *rsp_params;
290
291 rsp_params = (struct mc_rsp_api_ver *)cmd->params;
292 *major_ver = le16_to_cpu(rsp_params->major_ver);
293 *minor_ver = le16_to_cpu(rsp_params->minor_ver);
294 }
295
296
297
298
299 #define FSL_MC_IO_ATOMIC_CONTEXT_PORTAL 0x0001
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324 struct fsl_mc_io {
325 struct device *dev;
326 u16 flags;
327 u32 portal_size;
328 phys_addr_t portal_phys_addr;
329 void __iomem *portal_virt_addr;
330 struct fsl_mc_device *dpmcp_dev;
331 union {
332
333
334
335
336 struct mutex mutex;
337
338
339
340
341
342 spinlock_t spinlock;
343 };
344 };
345
346 int mc_send_command(struct fsl_mc_io *mc_io, struct fsl_mc_command *cmd);
347
348 #ifdef CONFIG_FSL_MC_BUS
349 #define dev_is_fsl_mc(_dev) ((_dev)->bus == &fsl_mc_bus_type)
350 #else
351
352 #define dev_is_fsl_mc(_dev) (0)
353 #endif
354
355
356 #define fsl_mc_is_cont_dev(_dev) (to_fsl_mc_device(_dev)->flags & \
357 FSL_MC_IS_DPRC)
358
359
360 #define fsl_mc_cont_dev(_dev) (fsl_mc_is_cont_dev(_dev) ? \
361 (_dev) : (_dev)->parent)
362
363
364
365
366
367
368
369 #define module_fsl_mc_driver(__fsl_mc_driver) \
370 module_driver(__fsl_mc_driver, fsl_mc_driver_register, \
371 fsl_mc_driver_unregister)
372
373
374
375
376 #define fsl_mc_driver_register(drv) \
377 __fsl_mc_driver_register(drv, THIS_MODULE)
378
379 int __must_check __fsl_mc_driver_register(struct fsl_mc_driver *fsl_mc_driver,
380 struct module *owner);
381
382 void fsl_mc_driver_unregister(struct fsl_mc_driver *driver);
383
384 int __must_check fsl_mc_portal_allocate(struct fsl_mc_device *mc_dev,
385 u16 mc_io_flags,
386 struct fsl_mc_io **new_mc_io);
387
388 void fsl_mc_portal_free(struct fsl_mc_io *mc_io);
389
390 int fsl_mc_portal_reset(struct fsl_mc_io *mc_io);
391
392 int __must_check fsl_mc_object_allocate(struct fsl_mc_device *mc_dev,
393 enum fsl_mc_pool_type pool_type,
394 struct fsl_mc_device **new_mc_adev);
395
396 void fsl_mc_object_free(struct fsl_mc_device *mc_adev);
397
398 struct irq_domain *fsl_mc_msi_create_irq_domain(struct fwnode_handle *fwnode,
399 struct msi_domain_info *info,
400 struct irq_domain *parent);
401
402 int __must_check fsl_mc_allocate_irqs(struct fsl_mc_device *mc_dev);
403
404 void fsl_mc_free_irqs(struct fsl_mc_device *mc_dev);
405
406 extern struct bus_type fsl_mc_bus_type;
407
408 extern struct device_type fsl_mc_bus_dprc_type;
409 extern struct device_type fsl_mc_bus_dpni_type;
410 extern struct device_type fsl_mc_bus_dpio_type;
411 extern struct device_type fsl_mc_bus_dpsw_type;
412 extern struct device_type fsl_mc_bus_dpbp_type;
413 extern struct device_type fsl_mc_bus_dpcon_type;
414 extern struct device_type fsl_mc_bus_dpmcp_type;
415 extern struct device_type fsl_mc_bus_dpmac_type;
416 extern struct device_type fsl_mc_bus_dprtc_type;
417 extern struct device_type fsl_mc_bus_dpseci_type;
418
419 static inline bool is_fsl_mc_bus_dprc(const struct fsl_mc_device *mc_dev)
420 {
421 return mc_dev->dev.type == &fsl_mc_bus_dprc_type;
422 }
423
424 static inline bool is_fsl_mc_bus_dpni(const struct fsl_mc_device *mc_dev)
425 {
426 return mc_dev->dev.type == &fsl_mc_bus_dpni_type;
427 }
428
429 static inline bool is_fsl_mc_bus_dpio(const struct fsl_mc_device *mc_dev)
430 {
431 return mc_dev->dev.type == &fsl_mc_bus_dpio_type;
432 }
433
434 static inline bool is_fsl_mc_bus_dpsw(const struct fsl_mc_device *mc_dev)
435 {
436 return mc_dev->dev.type == &fsl_mc_bus_dpsw_type;
437 }
438
439 static inline bool is_fsl_mc_bus_dpbp(const struct fsl_mc_device *mc_dev)
440 {
441 return mc_dev->dev.type == &fsl_mc_bus_dpbp_type;
442 }
443
444 static inline bool is_fsl_mc_bus_dpcon(const struct fsl_mc_device *mc_dev)
445 {
446 return mc_dev->dev.type == &fsl_mc_bus_dpcon_type;
447 }
448
449 static inline bool is_fsl_mc_bus_dpmcp(const struct fsl_mc_device *mc_dev)
450 {
451 return mc_dev->dev.type == &fsl_mc_bus_dpmcp_type;
452 }
453
454 static inline bool is_fsl_mc_bus_dpmac(const struct fsl_mc_device *mc_dev)
455 {
456 return mc_dev->dev.type == &fsl_mc_bus_dpmac_type;
457 }
458
459 static inline bool is_fsl_mc_bus_dprtc(const struct fsl_mc_device *mc_dev)
460 {
461 return mc_dev->dev.type == &fsl_mc_bus_dprtc_type;
462 }
463
464 static inline bool is_fsl_mc_bus_dpseci(const struct fsl_mc_device *mc_dev)
465 {
466 return mc_dev->dev.type == &fsl_mc_bus_dpseci_type;
467 }
468
469
470
471
472
473
474 int dpbp_open(struct fsl_mc_io *mc_io,
475 u32 cmd_flags,
476 int dpbp_id,
477 u16 *token);
478
479 int dpbp_close(struct fsl_mc_io *mc_io,
480 u32 cmd_flags,
481 u16 token);
482
483 int dpbp_enable(struct fsl_mc_io *mc_io,
484 u32 cmd_flags,
485 u16 token);
486
487 int dpbp_disable(struct fsl_mc_io *mc_io,
488 u32 cmd_flags,
489 u16 token);
490
491 int dpbp_reset(struct fsl_mc_io *mc_io,
492 u32 cmd_flags,
493 u16 token);
494
495
496
497
498
499
500
501 struct dpbp_attr {
502 int id;
503 u16 bpid;
504 };
505
506 int dpbp_get_attributes(struct fsl_mc_io *mc_io,
507 u32 cmd_flags,
508 u16 token,
509 struct dpbp_attr *attr);
510
511
512
513
514
515
516
517
518 #define DPCON_INVALID_DPIO_ID (int)(-1)
519
520 int dpcon_open(struct fsl_mc_io *mc_io,
521 u32 cmd_flags,
522 int dpcon_id,
523 u16 *token);
524
525 int dpcon_close(struct fsl_mc_io *mc_io,
526 u32 cmd_flags,
527 u16 token);
528
529 int dpcon_enable(struct fsl_mc_io *mc_io,
530 u32 cmd_flags,
531 u16 token);
532
533 int dpcon_disable(struct fsl_mc_io *mc_io,
534 u32 cmd_flags,
535 u16 token);
536
537 int dpcon_reset(struct fsl_mc_io *mc_io,
538 u32 cmd_flags,
539 u16 token);
540
541
542
543
544
545
546
547 struct dpcon_attr {
548 int id;
549 u16 qbman_ch_id;
550 u8 num_priorities;
551 };
552
553 int dpcon_get_attributes(struct fsl_mc_io *mc_io,
554 u32 cmd_flags,
555 u16 token,
556 struct dpcon_attr *attr);
557
558
559
560
561
562
563
564
565
566 struct dpcon_notification_cfg {
567 int dpio_id;
568 u8 priority;
569 u64 user_ctx;
570 };
571
572 int dpcon_set_notification(struct fsl_mc_io *mc_io,
573 u32 cmd_flags,
574 u16 token,
575 struct dpcon_notification_cfg *cfg);
576
577 #endif