1
2
3
4
5
6
7
8#ifndef _FSL_MC_PRIVATE_H_
9#define _FSL_MC_PRIVATE_H_
10
11#include <linux/fsl/mc.h>
12#include <linux/mutex.h>
13
14
15
16
17
18
19#define DPMNG_CMD_BASE_VERSION 1
20#define DPMNG_CMD_ID_OFFSET 4
21
22#define DPMNG_CMD(id) (((id) << DPMNG_CMD_ID_OFFSET) | DPMNG_CMD_BASE_VERSION)
23
24
25#define DPMNG_CMDID_GET_VERSION DPMNG_CMD(0x831)
26
27struct dpmng_rsp_get_version {
28 __le32 revision;
29 __le32 version_major;
30 __le32 version_minor;
31};
32
33
34
35
36
37
38#define DPMCP_MIN_VER_MAJOR 3
39#define DPMCP_MIN_VER_MINOR 0
40
41
42#define DPMCP_CMD_BASE_VERSION 1
43#define DPMCP_CMD_ID_OFFSET 4
44
45#define DPMCP_CMD(id) (((id) << DPMCP_CMD_ID_OFFSET) | DPMCP_CMD_BASE_VERSION)
46
47
48#define DPMCP_CMDID_CLOSE DPMCP_CMD(0x800)
49#define DPMCP_CMDID_OPEN DPMCP_CMD(0x80b)
50#define DPMCP_CMDID_RESET DPMCP_CMD(0x005)
51
52struct dpmcp_cmd_open {
53 __le32 dpmcp_id;
54};
55
56
57
58
59int dpmcp_open(struct fsl_mc_io *mc_io,
60 u32 cmd_flags,
61 int dpmcp_id,
62 u16 *token);
63
64int dpmcp_close(struct fsl_mc_io *mc_io,
65 u32 cmd_flags,
66 u16 token);
67
68int dpmcp_reset(struct fsl_mc_io *mc_io,
69 u32 cmd_flags,
70 u16 token);
71
72
73
74
75
76
77#define DPRC_MIN_VER_MAJOR 6
78#define DPRC_MIN_VER_MINOR 0
79
80
81#define DPRC_CMD_BASE_VERSION 1
82#define DPRC_CMD_2ND_VERSION 2
83#define DPRC_CMD_3RD_VERSION 3
84#define DPRC_CMD_ID_OFFSET 4
85
86#define DPRC_CMD(id) (((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_BASE_VERSION)
87#define DPRC_CMD_V2(id) (((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_2ND_VERSION)
88#define DPRC_CMD_V3(id) (((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_3RD_VERSION)
89
90
91#define DPRC_CMDID_CLOSE DPRC_CMD(0x800)
92#define DPRC_CMDID_OPEN DPRC_CMD(0x805)
93#define DPRC_CMDID_GET_API_VERSION DPRC_CMD(0xa05)
94
95#define DPRC_CMDID_GET_ATTR DPRC_CMD(0x004)
96#define DPRC_CMDID_RESET_CONT DPRC_CMD(0x005)
97#define DPRC_CMDID_RESET_CONT_V2 DPRC_CMD_V2(0x005)
98
99#define DPRC_CMDID_SET_IRQ DPRC_CMD(0x010)
100#define DPRC_CMDID_SET_IRQ_ENABLE DPRC_CMD(0x012)
101#define DPRC_CMDID_SET_IRQ_MASK DPRC_CMD(0x014)
102#define DPRC_CMDID_GET_IRQ_STATUS DPRC_CMD(0x016)
103#define DPRC_CMDID_CLEAR_IRQ_STATUS DPRC_CMD(0x017)
104
105#define DPRC_CMDID_GET_CONT_ID DPRC_CMD(0x830)
106#define DPRC_CMDID_GET_OBJ_COUNT DPRC_CMD(0x159)
107#define DPRC_CMDID_GET_OBJ DPRC_CMD(0x15A)
108#define DPRC_CMDID_GET_OBJ_REG DPRC_CMD(0x15E)
109#define DPRC_CMDID_GET_OBJ_REG_V2 DPRC_CMD_V2(0x15E)
110#define DPRC_CMDID_GET_OBJ_REG_V3 DPRC_CMD_V3(0x15E)
111#define DPRC_CMDID_SET_OBJ_IRQ DPRC_CMD(0x15F)
112
113#define DPRC_CMDID_GET_CONNECTION DPRC_CMD(0x16C)
114
115struct dprc_cmd_open {
116 __le32 container_id;
117};
118
119struct dprc_cmd_reset_container {
120 __le32 child_container_id;
121 __le32 options;
122};
123
124struct dprc_cmd_set_irq {
125
126 __le32 irq_val;
127 u8 irq_index;
128 u8 pad[3];
129
130 __le64 irq_addr;
131
132 __le32 irq_num;
133};
134
135#define DPRC_ENABLE 0x1
136
137struct dprc_cmd_set_irq_enable {
138 u8 enable;
139 u8 pad[3];
140 u8 irq_index;
141};
142
143struct dprc_cmd_set_irq_mask {
144 __le32 mask;
145 u8 irq_index;
146};
147
148struct dprc_cmd_get_irq_status {
149 __le32 status;
150 u8 irq_index;
151};
152
153struct dprc_rsp_get_irq_status {
154 __le32 status;
155};
156
157struct dprc_cmd_clear_irq_status {
158 __le32 status;
159 u8 irq_index;
160};
161
162struct dprc_rsp_get_attributes {
163
164 __le32 container_id;
165 __le32 icid;
166
167 __le32 options;
168 __le32 portal_id;
169};
170
171struct dprc_rsp_get_obj_count {
172 __le32 pad;
173 __le32 obj_count;
174};
175
176struct dprc_cmd_get_obj {
177 __le32 obj_index;
178};
179
180struct dprc_rsp_get_obj {
181
182 __le32 pad0;
183 __le32 id;
184
185 __le16 vendor;
186 u8 irq_count;
187 u8 region_count;
188 __le32 state;
189
190 __le16 version_major;
191 __le16 version_minor;
192 __le16 flags;
193 __le16 pad1;
194
195 u8 type[16];
196
197 u8 label[16];
198};
199
200struct dprc_cmd_get_obj_region {
201
202 __le32 obj_id;
203 __le16 pad0;
204 u8 region_index;
205 u8 pad1;
206
207 __le64 pad2[2];
208
209 u8 obj_type[16];
210};
211
212struct dprc_rsp_get_obj_region {
213
214 __le64 pad;
215
216 __le64 base_offset;
217
218 __le32 size;
219 __le32 pad2;
220
221 __le32 flags;
222 __le32 pad3;
223
224
225 __le64 base_addr;
226};
227
228struct dprc_cmd_set_obj_irq {
229
230 __le32 irq_val;
231 u8 irq_index;
232 u8 pad[3];
233
234 __le64 irq_addr;
235
236 __le32 irq_num;
237 __le32 obj_id;
238
239 u8 obj_type[16];
240};
241
242struct dprc_cmd_get_connection {
243 __le32 ep1_id;
244 __le16 ep1_interface_id;
245 u8 pad[2];
246 u8 ep1_type[16];
247};
248
249struct dprc_rsp_get_connection {
250 __le64 pad[3];
251 __le32 ep2_id;
252 __le16 ep2_interface_id;
253 __le16 pad1;
254 u8 ep2_type[16];
255 __le32 state;
256};
257
258
259
260
261int dprc_open(struct fsl_mc_io *mc_io,
262 u32 cmd_flags,
263 int container_id,
264 u16 *token);
265
266int dprc_close(struct fsl_mc_io *mc_io,
267 u32 cmd_flags,
268 u16 token);
269
270
271
272
273#define DPRC_IRQ_EVENT_OBJ_ADDED 0x00000001
274
275#define DPRC_IRQ_EVENT_OBJ_REMOVED 0x00000002
276
277
278
279
280#define DPRC_IRQ_EVENT_CONTAINER_DESTROYED 0x00000010
281
282
283
284
285
286#define DPRC_IRQ_EVENT_OBJ_DESTROYED 0x00000020
287
288
289#define DPRC_IRQ_EVENT_OBJ_CREATED 0x00000040
290
291
292
293
294
295
296
297struct dprc_irq_cfg {
298 phys_addr_t paddr;
299 u32 val;
300 int irq_num;
301};
302
303int dprc_set_irq(struct fsl_mc_io *mc_io,
304 u32 cmd_flags,
305 u16 token,
306 u8 irq_index,
307 struct dprc_irq_cfg *irq_cfg);
308
309int dprc_set_irq_enable(struct fsl_mc_io *mc_io,
310 u32 cmd_flags,
311 u16 token,
312 u8 irq_index,
313 u8 en);
314
315int dprc_set_irq_mask(struct fsl_mc_io *mc_io,
316 u32 cmd_flags,
317 u16 token,
318 u8 irq_index,
319 u32 mask);
320
321int dprc_get_irq_status(struct fsl_mc_io *mc_io,
322 u32 cmd_flags,
323 u16 token,
324 u8 irq_index,
325 u32 *status);
326
327int dprc_clear_irq_status(struct fsl_mc_io *mc_io,
328 u32 cmd_flags,
329 u16 token,
330 u8 irq_index,
331 u32 status);
332
333
334
335
336
337
338
339
340struct dprc_attributes {
341 int container_id;
342 u32 icid;
343 int portal_id;
344 u64 options;
345};
346
347int dprc_get_attributes(struct fsl_mc_io *mc_io,
348 u32 cmd_flags,
349 u16 token,
350 struct dprc_attributes *attributes);
351
352int dprc_get_obj_count(struct fsl_mc_io *mc_io,
353 u32 cmd_flags,
354 u16 token,
355 int *obj_count);
356
357int dprc_get_obj(struct fsl_mc_io *mc_io,
358 u32 cmd_flags,
359 u16 token,
360 int obj_index,
361 struct fsl_mc_obj_desc *obj_desc);
362
363int dprc_set_obj_irq(struct fsl_mc_io *mc_io,
364 u32 cmd_flags,
365 u16 token,
366 char *obj_type,
367 int obj_id,
368 u8 irq_index,
369 struct dprc_irq_cfg *irq_cfg);
370
371
372
373
374
375enum dprc_region_type {
376 DPRC_REGION_TYPE_MC_PORTAL,
377 DPRC_REGION_TYPE_QBMAN_PORTAL,
378 DPRC_REGION_TYPE_QBMAN_MEM_BACKED_PORTAL
379};
380
381
382
383
384
385
386
387
388
389
390
391struct dprc_region_desc {
392 u32 base_offset;
393 u32 size;
394 u32 flags;
395 enum dprc_region_type type;
396 u64 base_address;
397};
398
399int dprc_get_obj_region(struct fsl_mc_io *mc_io,
400 u32 cmd_flags,
401 u16 token,
402 char *obj_type,
403 int obj_id,
404 u8 region_index,
405 struct dprc_region_desc *region_desc);
406
407int dprc_get_api_version(struct fsl_mc_io *mc_io,
408 u32 cmd_flags,
409 u16 *major_ver,
410 u16 *minor_ver);
411
412int dprc_get_container_id(struct fsl_mc_io *mc_io,
413 u32 cmd_flags,
414 int *container_id);
415
416
417
418
419
420
421
422
423
424struct dprc_endpoint {
425 char type[16];
426 int id;
427 u16 if_id;
428};
429
430int dprc_get_connection(struct fsl_mc_io *mc_io,
431 u32 cmd_flags,
432 u16 token,
433 const struct dprc_endpoint *endpoint1,
434 struct dprc_endpoint *endpoint2,
435 int *state);
436
437
438
439
440
441
442#define DPBP_VER_MAJOR 3
443#define DPBP_VER_MINOR 2
444
445
446#define DPBP_CMD_BASE_VERSION 1
447#define DPBP_CMD_ID_OFFSET 4
448
449#define DPBP_CMD(id) (((id) << DPBP_CMD_ID_OFFSET) | DPBP_CMD_BASE_VERSION)
450
451
452#define DPBP_CMDID_CLOSE DPBP_CMD(0x800)
453#define DPBP_CMDID_OPEN DPBP_CMD(0x804)
454
455#define DPBP_CMDID_ENABLE DPBP_CMD(0x002)
456#define DPBP_CMDID_DISABLE DPBP_CMD(0x003)
457#define DPBP_CMDID_GET_ATTR DPBP_CMD(0x004)
458#define DPBP_CMDID_RESET DPBP_CMD(0x005)
459
460struct dpbp_cmd_open {
461 __le32 dpbp_id;
462};
463
464#define DPBP_ENABLE 0x1
465
466struct dpbp_rsp_get_attributes {
467
468 __le16 pad;
469 __le16 bpid;
470 __le32 id;
471
472 __le16 version_major;
473 __le16 version_minor;
474};
475
476
477
478
479
480
481#define DPCON_VER_MAJOR 3
482#define DPCON_VER_MINOR 2
483
484
485#define DPCON_CMD_BASE_VERSION 1
486#define DPCON_CMD_ID_OFFSET 4
487
488#define DPCON_CMD(id) (((id) << DPCON_CMD_ID_OFFSET) | DPCON_CMD_BASE_VERSION)
489
490
491#define DPCON_CMDID_CLOSE DPCON_CMD(0x800)
492#define DPCON_CMDID_OPEN DPCON_CMD(0x808)
493
494#define DPCON_CMDID_ENABLE DPCON_CMD(0x002)
495#define DPCON_CMDID_DISABLE DPCON_CMD(0x003)
496#define DPCON_CMDID_GET_ATTR DPCON_CMD(0x004)
497#define DPCON_CMDID_RESET DPCON_CMD(0x005)
498
499#define DPCON_CMDID_SET_NOTIFICATION DPCON_CMD(0x100)
500
501struct dpcon_cmd_open {
502 __le32 dpcon_id;
503};
504
505#define DPCON_ENABLE 1
506
507struct dpcon_rsp_get_attr {
508
509 __le32 id;
510 __le16 qbman_ch_id;
511 u8 num_priorities;
512 u8 pad;
513};
514
515struct dpcon_cmd_set_notification {
516
517 __le32 dpio_id;
518 u8 priority;
519 u8 pad[3];
520
521 __le64 user_ctx;
522};
523
524
525
526
527
528
529
530
531
532
533
534
535struct fsl_mc_resource_pool {
536 enum fsl_mc_pool_type type;
537 int max_count;
538 int free_count;
539 struct mutex mutex;
540 struct list_head free_list;
541 struct fsl_mc_bus *mc_bus;
542};
543
544
545
546
547
548
549
550
551
552
553
554struct fsl_mc_bus {
555 struct fsl_mc_device mc_dev;
556 struct fsl_mc_resource_pool resource_pools[FSL_MC_NUM_POOL_TYPES];
557 struct fsl_mc_device_irq *irq_resources;
558 struct mutex scan_mutex;
559 struct dprc_attributes dprc_attr;
560};
561
562#define to_fsl_mc_bus(_mc_dev) \
563 container_of(_mc_dev, struct fsl_mc_bus, mc_dev)
564
565int __must_check fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
566 struct fsl_mc_io *mc_io,
567 struct device *parent_dev,
568 struct fsl_mc_device **new_mc_dev);
569
570void fsl_mc_device_remove(struct fsl_mc_device *mc_dev);
571
572int __init dprc_driver_init(void);
573
574void dprc_driver_exit(void);
575
576int __init fsl_mc_allocator_driver_init(void);
577
578void fsl_mc_allocator_driver_exit(void);
579
580void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
581
582void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
583
584int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus,
585 enum fsl_mc_pool_type pool_type,
586 struct fsl_mc_resource
587 **new_resource);
588
589void fsl_mc_resource_free(struct fsl_mc_resource *resource);
590
591int fsl_mc_msi_domain_alloc_irqs(struct device *dev,
592 unsigned int irq_count);
593
594void fsl_mc_msi_domain_free_irqs(struct device *dev);
595
596struct irq_domain *fsl_mc_find_msi_domain(struct device *dev);
597
598int __must_check fsl_create_mc_io(struct device *dev,
599 phys_addr_t mc_portal_phys_addr,
600 u32 mc_portal_size,
601 struct fsl_mc_device *dpmcp_dev,
602 u32 flags, struct fsl_mc_io **new_mc_io);
603
604void fsl_destroy_mc_io(struct fsl_mc_io *mc_io);
605
606bool fsl_mc_is_root_dprc(struct device *dev);
607
608void fsl_mc_get_root_dprc(struct device *dev,
609 struct device **root_dprc_dev);
610
611struct fsl_mc_device *fsl_mc_device_lookup(struct fsl_mc_obj_desc *obj_desc,
612 struct fsl_mc_device *mc_bus_dev);
613
614#endif
615