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_ID_OFFSET 4
83
84#define DPRC_CMD(id) (((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_BASE_VERSION)
85
86
87#define DPRC_CMDID_CLOSE DPRC_CMD(0x800)
88#define DPRC_CMDID_OPEN DPRC_CMD(0x805)
89#define DPRC_CMDID_GET_API_VERSION DPRC_CMD(0xa05)
90
91#define DPRC_CMDID_GET_ATTR DPRC_CMD(0x004)
92
93#define DPRC_CMDID_SET_IRQ DPRC_CMD(0x010)
94#define DPRC_CMDID_SET_IRQ_ENABLE DPRC_CMD(0x012)
95#define DPRC_CMDID_SET_IRQ_MASK DPRC_CMD(0x014)
96#define DPRC_CMDID_GET_IRQ_STATUS DPRC_CMD(0x016)
97#define DPRC_CMDID_CLEAR_IRQ_STATUS DPRC_CMD(0x017)
98
99#define DPRC_CMDID_GET_CONT_ID DPRC_CMD(0x830)
100#define DPRC_CMDID_GET_OBJ_COUNT DPRC_CMD(0x159)
101#define DPRC_CMDID_GET_OBJ DPRC_CMD(0x15A)
102#define DPRC_CMDID_GET_OBJ_REG DPRC_CMD(0x15E)
103#define DPRC_CMDID_SET_OBJ_IRQ DPRC_CMD(0x15F)
104
105struct dprc_cmd_open {
106 __le32 container_id;
107};
108
109struct dprc_cmd_set_irq {
110
111 __le32 irq_val;
112 u8 irq_index;
113 u8 pad[3];
114
115 __le64 irq_addr;
116
117 __le32 irq_num;
118};
119
120#define DPRC_ENABLE 0x1
121
122struct dprc_cmd_set_irq_enable {
123 u8 enable;
124 u8 pad[3];
125 u8 irq_index;
126};
127
128struct dprc_cmd_set_irq_mask {
129 __le32 mask;
130 u8 irq_index;
131};
132
133struct dprc_cmd_get_irq_status {
134 __le32 status;
135 u8 irq_index;
136};
137
138struct dprc_rsp_get_irq_status {
139 __le32 status;
140};
141
142struct dprc_cmd_clear_irq_status {
143 __le32 status;
144 u8 irq_index;
145};
146
147struct dprc_rsp_get_attributes {
148
149 __le32 container_id;
150 __le16 icid;
151 __le16 pad;
152
153 __le32 options;
154 __le32 portal_id;
155};
156
157struct dprc_rsp_get_obj_count {
158 __le32 pad;
159 __le32 obj_count;
160};
161
162struct dprc_cmd_get_obj {
163 __le32 obj_index;
164};
165
166struct dprc_rsp_get_obj {
167
168 __le32 pad0;
169 __le32 id;
170
171 __le16 vendor;
172 u8 irq_count;
173 u8 region_count;
174 __le32 state;
175
176 __le16 version_major;
177 __le16 version_minor;
178 __le16 flags;
179 __le16 pad1;
180
181 u8 type[16];
182
183 u8 label[16];
184};
185
186struct dprc_cmd_get_obj_region {
187
188 __le32 obj_id;
189 __le16 pad0;
190 u8 region_index;
191 u8 pad1;
192
193 __le64 pad2[2];
194
195 u8 obj_type[16];
196};
197
198struct dprc_rsp_get_obj_region {
199
200 __le64 pad;
201
202 __le64 base_addr;
203
204 __le32 size;
205};
206
207struct dprc_cmd_set_obj_irq {
208
209 __le32 irq_val;
210 u8 irq_index;
211 u8 pad[3];
212
213 __le64 irq_addr;
214
215 __le32 irq_num;
216 __le32 obj_id;
217
218 u8 obj_type[16];
219};
220
221
222
223
224int dprc_open(struct fsl_mc_io *mc_io,
225 u32 cmd_flags,
226 int container_id,
227 u16 *token);
228
229int dprc_close(struct fsl_mc_io *mc_io,
230 u32 cmd_flags,
231 u16 token);
232
233
234
235
236#define DPRC_IRQ_EVENT_OBJ_ADDED 0x00000001
237
238#define DPRC_IRQ_EVENT_OBJ_REMOVED 0x00000002
239
240
241
242
243#define DPRC_IRQ_EVENT_CONTAINER_DESTROYED 0x00000010
244
245
246
247
248
249#define DPRC_IRQ_EVENT_OBJ_DESTROYED 0x00000020
250
251
252#define DPRC_IRQ_EVENT_OBJ_CREATED 0x00000040
253
254
255
256
257
258
259
260struct dprc_irq_cfg {
261 phys_addr_t paddr;
262 u32 val;
263 int irq_num;
264};
265
266int dprc_set_irq(struct fsl_mc_io *mc_io,
267 u32 cmd_flags,
268 u16 token,
269 u8 irq_index,
270 struct dprc_irq_cfg *irq_cfg);
271
272int dprc_set_irq_enable(struct fsl_mc_io *mc_io,
273 u32 cmd_flags,
274 u16 token,
275 u8 irq_index,
276 u8 en);
277
278int dprc_set_irq_mask(struct fsl_mc_io *mc_io,
279 u32 cmd_flags,
280 u16 token,
281 u8 irq_index,
282 u32 mask);
283
284int dprc_get_irq_status(struct fsl_mc_io *mc_io,
285 u32 cmd_flags,
286 u16 token,
287 u8 irq_index,
288 u32 *status);
289
290int dprc_clear_irq_status(struct fsl_mc_io *mc_io,
291 u32 cmd_flags,
292 u16 token,
293 u8 irq_index,
294 u32 status);
295
296
297
298
299
300
301
302
303struct dprc_attributes {
304 int container_id;
305 u16 icid;
306 int portal_id;
307 u64 options;
308};
309
310int dprc_get_attributes(struct fsl_mc_io *mc_io,
311 u32 cmd_flags,
312 u16 token,
313 struct dprc_attributes *attributes);
314
315int dprc_get_obj_count(struct fsl_mc_io *mc_io,
316 u32 cmd_flags,
317 u16 token,
318 int *obj_count);
319
320int dprc_get_obj(struct fsl_mc_io *mc_io,
321 u32 cmd_flags,
322 u16 token,
323 int obj_index,
324 struct fsl_mc_obj_desc *obj_desc);
325
326int dprc_set_obj_irq(struct fsl_mc_io *mc_io,
327 u32 cmd_flags,
328 u16 token,
329 char *obj_type,
330 int obj_id,
331 u8 irq_index,
332 struct dprc_irq_cfg *irq_cfg);
333
334
335
336#define DPRC_REGION_CACHEABLE 0x00000001
337
338
339
340
341
342
343enum dprc_region_type {
344 DPRC_REGION_TYPE_MC_PORTAL,
345 DPRC_REGION_TYPE_QBMAN_PORTAL
346};
347
348
349
350
351
352
353
354
355
356
357
358struct dprc_region_desc {
359 u32 base_offset;
360 u32 size;
361 u32 flags;
362 enum dprc_region_type type;
363};
364
365int dprc_get_obj_region(struct fsl_mc_io *mc_io,
366 u32 cmd_flags,
367 u16 token,
368 char *obj_type,
369 int obj_id,
370 u8 region_index,
371 struct dprc_region_desc *region_desc);
372
373int dprc_get_api_version(struct fsl_mc_io *mc_io,
374 u32 cmd_flags,
375 u16 *major_ver,
376 u16 *minor_ver);
377
378int dprc_get_container_id(struct fsl_mc_io *mc_io,
379 u32 cmd_flags,
380 int *container_id);
381
382
383
384
385
386
387#define DPBP_VER_MAJOR 3
388#define DPBP_VER_MINOR 2
389
390
391#define DPBP_CMD_BASE_VERSION 1
392#define DPBP_CMD_ID_OFFSET 4
393
394#define DPBP_CMD(id) (((id) << DPBP_CMD_ID_OFFSET) | DPBP_CMD_BASE_VERSION)
395
396
397#define DPBP_CMDID_CLOSE DPBP_CMD(0x800)
398#define DPBP_CMDID_OPEN DPBP_CMD(0x804)
399
400#define DPBP_CMDID_ENABLE DPBP_CMD(0x002)
401#define DPBP_CMDID_DISABLE DPBP_CMD(0x003)
402#define DPBP_CMDID_GET_ATTR DPBP_CMD(0x004)
403#define DPBP_CMDID_RESET DPBP_CMD(0x005)
404
405struct dpbp_cmd_open {
406 __le32 dpbp_id;
407};
408
409#define DPBP_ENABLE 0x1
410
411struct dpbp_rsp_get_attributes {
412
413 __le16 pad;
414 __le16 bpid;
415 __le32 id;
416
417 __le16 version_major;
418 __le16 version_minor;
419};
420
421
422
423
424
425
426#define DPCON_VER_MAJOR 3
427#define DPCON_VER_MINOR 2
428
429
430#define DPCON_CMD_BASE_VERSION 1
431#define DPCON_CMD_ID_OFFSET 4
432
433#define DPCON_CMD(id) (((id) << DPCON_CMD_ID_OFFSET) | DPCON_CMD_BASE_VERSION)
434
435
436#define DPCON_CMDID_CLOSE DPCON_CMD(0x800)
437#define DPCON_CMDID_OPEN DPCON_CMD(0x808)
438
439#define DPCON_CMDID_ENABLE DPCON_CMD(0x002)
440#define DPCON_CMDID_DISABLE DPCON_CMD(0x003)
441#define DPCON_CMDID_GET_ATTR DPCON_CMD(0x004)
442#define DPCON_CMDID_RESET DPCON_CMD(0x005)
443
444#define DPCON_CMDID_SET_NOTIFICATION DPCON_CMD(0x100)
445
446struct dpcon_cmd_open {
447 __le32 dpcon_id;
448};
449
450#define DPCON_ENABLE 1
451
452struct dpcon_rsp_get_attr {
453
454 __le32 id;
455 __le16 qbman_ch_id;
456 u8 num_priorities;
457 u8 pad;
458};
459
460struct dpcon_cmd_set_notification {
461
462 __le32 dpio_id;
463 u8 priority;
464 u8 pad[3];
465
466 __le64 user_ctx;
467};
468
469
470
471
472
473#define FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS 256
474
475
476
477
478
479
480
481
482
483
484
485struct fsl_mc_resource_pool {
486 enum fsl_mc_pool_type type;
487 int max_count;
488 int free_count;
489 struct mutex mutex;
490 struct list_head free_list;
491 struct fsl_mc_bus *mc_bus;
492};
493
494
495
496
497
498
499
500
501
502
503
504struct fsl_mc_bus {
505 struct fsl_mc_device mc_dev;
506 struct fsl_mc_resource_pool resource_pools[FSL_MC_NUM_POOL_TYPES];
507 struct fsl_mc_device_irq *irq_resources;
508 struct mutex scan_mutex;
509 struct dprc_attributes dprc_attr;
510};
511
512#define to_fsl_mc_bus(_mc_dev) \
513 container_of(_mc_dev, struct fsl_mc_bus, mc_dev)
514
515int __must_check fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
516 struct fsl_mc_io *mc_io,
517 struct device *parent_dev,
518 struct fsl_mc_device **new_mc_dev);
519
520void fsl_mc_device_remove(struct fsl_mc_device *mc_dev);
521
522int __init dprc_driver_init(void);
523
524void dprc_driver_exit(void);
525
526int __init fsl_mc_allocator_driver_init(void);
527
528void fsl_mc_allocator_driver_exit(void);
529
530void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
531
532void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
533
534int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus,
535 enum fsl_mc_pool_type pool_type,
536 struct fsl_mc_resource
537 **new_resource);
538
539void fsl_mc_resource_free(struct fsl_mc_resource *resource);
540
541int fsl_mc_msi_domain_alloc_irqs(struct device *dev,
542 unsigned int irq_count);
543
544void fsl_mc_msi_domain_free_irqs(struct device *dev);
545
546int fsl_mc_find_msi_domain(struct device *mc_platform_dev,
547 struct irq_domain **mc_msi_domain);
548
549int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus,
550 unsigned int irq_count);
551
552void fsl_mc_cleanup_irq_pool(struct fsl_mc_bus *mc_bus);
553
554int __must_check fsl_create_mc_io(struct device *dev,
555 phys_addr_t mc_portal_phys_addr,
556 u32 mc_portal_size,
557 struct fsl_mc_device *dpmcp_dev,
558 u32 flags, struct fsl_mc_io **new_mc_io);
559
560void fsl_destroy_mc_io(struct fsl_mc_io *mc_io);
561
562bool fsl_mc_is_root_dprc(struct device *dev);
563
564#endif
565