0001
0002
0003
0004
0005
0006
0007
0008 #ifndef _FSL_MC_PRIVATE_H_
0009 #define _FSL_MC_PRIVATE_H_
0010
0011 #include <linux/fsl/mc.h>
0012 #include <linux/mutex.h>
0013 #include <linux/ioctl.h>
0014 #include <linux/miscdevice.h>
0015
0016
0017
0018
0019
0020
0021 #define DPMNG_CMD_BASE_VERSION 1
0022 #define DPMNG_CMD_ID_OFFSET 4
0023
0024 #define DPMNG_CMD(id) (((id) << DPMNG_CMD_ID_OFFSET) | DPMNG_CMD_BASE_VERSION)
0025
0026
0027 #define DPMNG_CMDID_GET_VERSION DPMNG_CMD(0x831)
0028
0029 struct dpmng_rsp_get_version {
0030 __le32 revision;
0031 __le32 version_major;
0032 __le32 version_minor;
0033 };
0034
0035
0036
0037
0038
0039
0040 #define DPMCP_MIN_VER_MAJOR 3
0041 #define DPMCP_MIN_VER_MINOR 0
0042
0043
0044 #define DPMCP_CMD_BASE_VERSION 1
0045 #define DPMCP_CMD_ID_OFFSET 4
0046
0047 #define DPMCP_CMD(id) (((id) << DPMCP_CMD_ID_OFFSET) | DPMCP_CMD_BASE_VERSION)
0048
0049
0050 #define DPMCP_CMDID_CLOSE DPMCP_CMD(0x800)
0051 #define DPMCP_CMDID_RESET DPMCP_CMD(0x005)
0052
0053 struct dpmcp_cmd_open {
0054 __le32 dpmcp_id;
0055 };
0056
0057
0058
0059
0060 int dpmcp_open(struct fsl_mc_io *mc_io,
0061 u32 cmd_flags,
0062 int dpmcp_id,
0063 u16 *token);
0064
0065 int dpmcp_close(struct fsl_mc_io *mc_io,
0066 u32 cmd_flags,
0067 u16 token);
0068
0069 int dpmcp_reset(struct fsl_mc_io *mc_io,
0070 u32 cmd_flags,
0071 u16 token);
0072
0073
0074
0075
0076
0077
0078 #define DPRC_MIN_VER_MAJOR 6
0079 #define DPRC_MIN_VER_MINOR 0
0080
0081
0082 #define DPRC_CMD_BASE_VERSION 1
0083 #define DPRC_CMD_2ND_VERSION 2
0084 #define DPRC_CMD_3RD_VERSION 3
0085 #define DPRC_CMD_ID_OFFSET 4
0086
0087 #define DPRC_CMD(id) (((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_BASE_VERSION)
0088 #define DPRC_CMD_V2(id) (((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_2ND_VERSION)
0089 #define DPRC_CMD_V3(id) (((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_3RD_VERSION)
0090
0091
0092 #define DPRC_CMDID_CLOSE DPRC_CMD(0x800)
0093 #define DPRC_CMDID_GET_API_VERSION DPRC_CMD(0xa05)
0094
0095 #define DPRC_CMDID_GET_ATTR DPRC_CMD(0x004)
0096 #define DPRC_CMDID_RESET_CONT DPRC_CMD(0x005)
0097 #define DPRC_CMDID_RESET_CONT_V2 DPRC_CMD_V2(0x005)
0098
0099 #define DPRC_CMDID_SET_IRQ DPRC_CMD(0x010)
0100 #define DPRC_CMDID_SET_IRQ_ENABLE DPRC_CMD(0x012)
0101 #define DPRC_CMDID_SET_IRQ_MASK DPRC_CMD(0x014)
0102 #define DPRC_CMDID_GET_IRQ_STATUS DPRC_CMD(0x016)
0103 #define DPRC_CMDID_CLEAR_IRQ_STATUS DPRC_CMD(0x017)
0104
0105 #define DPRC_CMDID_GET_CONT_ID DPRC_CMD(0x830)
0106 #define DPRC_CMDID_GET_OBJ_COUNT DPRC_CMD(0x159)
0107 #define DPRC_CMDID_GET_OBJ DPRC_CMD(0x15A)
0108 #define DPRC_CMDID_GET_OBJ_REG DPRC_CMD(0x15E)
0109 #define DPRC_CMDID_GET_OBJ_REG_V2 DPRC_CMD_V2(0x15E)
0110 #define DPRC_CMDID_GET_OBJ_REG_V3 DPRC_CMD_V3(0x15E)
0111 #define DPRC_CMDID_SET_OBJ_IRQ DPRC_CMD(0x15F)
0112
0113 #define DPRC_CMDID_GET_CONNECTION DPRC_CMD(0x16C)
0114
0115 struct dprc_cmd_open {
0116 __le32 container_id;
0117 };
0118
0119 struct dprc_cmd_reset_container {
0120 __le32 child_container_id;
0121 __le32 options;
0122 };
0123
0124 struct dprc_cmd_set_irq {
0125
0126 __le32 irq_val;
0127 u8 irq_index;
0128 u8 pad[3];
0129
0130 __le64 irq_addr;
0131
0132 __le32 irq_num;
0133 };
0134
0135 #define DPRC_ENABLE 0x1
0136
0137 struct dprc_cmd_set_irq_enable {
0138 u8 enable;
0139 u8 pad[3];
0140 u8 irq_index;
0141 };
0142
0143 struct dprc_cmd_set_irq_mask {
0144 __le32 mask;
0145 u8 irq_index;
0146 };
0147
0148 struct dprc_cmd_get_irq_status {
0149 __le32 status;
0150 u8 irq_index;
0151 };
0152
0153 struct dprc_rsp_get_irq_status {
0154 __le32 status;
0155 };
0156
0157 struct dprc_cmd_clear_irq_status {
0158 __le32 status;
0159 u8 irq_index;
0160 };
0161
0162 struct dprc_rsp_get_attributes {
0163
0164 __le32 container_id;
0165 __le32 icid;
0166
0167 __le32 options;
0168 __le32 portal_id;
0169 };
0170
0171 struct dprc_rsp_get_obj_count {
0172 __le32 pad;
0173 __le32 obj_count;
0174 };
0175
0176 struct dprc_cmd_get_obj {
0177 __le32 obj_index;
0178 };
0179
0180 struct dprc_rsp_get_obj {
0181
0182 __le32 pad0;
0183 __le32 id;
0184
0185 __le16 vendor;
0186 u8 irq_count;
0187 u8 region_count;
0188 __le32 state;
0189
0190 __le16 version_major;
0191 __le16 version_minor;
0192 __le16 flags;
0193 __le16 pad1;
0194
0195 u8 type[16];
0196
0197 u8 label[16];
0198 };
0199
0200 struct dprc_cmd_get_obj_region {
0201
0202 __le32 obj_id;
0203 __le16 pad0;
0204 u8 region_index;
0205 u8 pad1;
0206
0207 __le64 pad2[2];
0208
0209 u8 obj_type[16];
0210 };
0211
0212 struct dprc_rsp_get_obj_region {
0213
0214 __le64 pad0;
0215
0216 __le64 base_offset;
0217
0218 __le32 size;
0219 u8 type;
0220 u8 pad2[3];
0221
0222 __le32 flags;
0223 __le32 pad3;
0224
0225
0226 __le64 base_addr;
0227 };
0228
0229 struct dprc_cmd_set_obj_irq {
0230
0231 __le32 irq_val;
0232 u8 irq_index;
0233 u8 pad[3];
0234
0235 __le64 irq_addr;
0236
0237 __le32 irq_num;
0238 __le32 obj_id;
0239
0240 u8 obj_type[16];
0241 };
0242
0243 struct dprc_cmd_get_connection {
0244 __le32 ep1_id;
0245 __le16 ep1_interface_id;
0246 u8 pad[2];
0247 u8 ep1_type[16];
0248 };
0249
0250 struct dprc_rsp_get_connection {
0251 __le64 pad[3];
0252 __le32 ep2_id;
0253 __le16 ep2_interface_id;
0254 __le16 pad1;
0255 u8 ep2_type[16];
0256 __le32 state;
0257 };
0258
0259
0260
0261
0262 int dprc_open(struct fsl_mc_io *mc_io,
0263 u32 cmd_flags,
0264 int container_id,
0265 u16 *token);
0266
0267 int dprc_close(struct fsl_mc_io *mc_io,
0268 u32 cmd_flags,
0269 u16 token);
0270
0271
0272
0273
0274 #define DPRC_IRQ_EVENT_OBJ_ADDED 0x00000001
0275
0276 #define DPRC_IRQ_EVENT_OBJ_REMOVED 0x00000002
0277
0278
0279
0280
0281 #define DPRC_IRQ_EVENT_CONTAINER_DESTROYED 0x00000010
0282
0283
0284
0285
0286
0287 #define DPRC_IRQ_EVENT_OBJ_DESTROYED 0x00000020
0288
0289
0290 #define DPRC_IRQ_EVENT_OBJ_CREATED 0x00000040
0291
0292
0293
0294
0295
0296
0297
0298 struct dprc_irq_cfg {
0299 phys_addr_t paddr;
0300 u32 val;
0301 int irq_num;
0302 };
0303
0304 int dprc_set_irq(struct fsl_mc_io *mc_io,
0305 u32 cmd_flags,
0306 u16 token,
0307 u8 irq_index,
0308 struct dprc_irq_cfg *irq_cfg);
0309
0310 int dprc_set_irq_enable(struct fsl_mc_io *mc_io,
0311 u32 cmd_flags,
0312 u16 token,
0313 u8 irq_index,
0314 u8 en);
0315
0316 int dprc_set_irq_mask(struct fsl_mc_io *mc_io,
0317 u32 cmd_flags,
0318 u16 token,
0319 u8 irq_index,
0320 u32 mask);
0321
0322 int dprc_get_irq_status(struct fsl_mc_io *mc_io,
0323 u32 cmd_flags,
0324 u16 token,
0325 u8 irq_index,
0326 u32 *status);
0327
0328 int dprc_clear_irq_status(struct fsl_mc_io *mc_io,
0329 u32 cmd_flags,
0330 u16 token,
0331 u8 irq_index,
0332 u32 status);
0333
0334
0335
0336
0337
0338
0339
0340
0341 struct dprc_attributes {
0342 int container_id;
0343 u32 icid;
0344 int portal_id;
0345 u64 options;
0346 };
0347
0348 int dprc_get_attributes(struct fsl_mc_io *mc_io,
0349 u32 cmd_flags,
0350 u16 token,
0351 struct dprc_attributes *attributes);
0352
0353 int dprc_get_obj_count(struct fsl_mc_io *mc_io,
0354 u32 cmd_flags,
0355 u16 token,
0356 int *obj_count);
0357
0358 int dprc_get_obj(struct fsl_mc_io *mc_io,
0359 u32 cmd_flags,
0360 u16 token,
0361 int obj_index,
0362 struct fsl_mc_obj_desc *obj_desc);
0363
0364 int dprc_set_obj_irq(struct fsl_mc_io *mc_io,
0365 u32 cmd_flags,
0366 u16 token,
0367 char *obj_type,
0368 int obj_id,
0369 u8 irq_index,
0370 struct dprc_irq_cfg *irq_cfg);
0371
0372
0373
0374
0375
0376 enum dprc_region_type {
0377 DPRC_REGION_TYPE_MC_PORTAL,
0378 DPRC_REGION_TYPE_QBMAN_PORTAL,
0379 DPRC_REGION_TYPE_QBMAN_MEM_BACKED_PORTAL
0380 };
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392 struct dprc_region_desc {
0393 u32 base_offset;
0394 u32 size;
0395 u32 flags;
0396 enum dprc_region_type type;
0397 u64 base_address;
0398 };
0399
0400 int dprc_get_obj_region(struct fsl_mc_io *mc_io,
0401 u32 cmd_flags,
0402 u16 token,
0403 char *obj_type,
0404 int obj_id,
0405 u8 region_index,
0406 struct dprc_region_desc *region_desc);
0407
0408 int dprc_get_api_version(struct fsl_mc_io *mc_io,
0409 u32 cmd_flags,
0410 u16 *major_ver,
0411 u16 *minor_ver);
0412
0413 int dprc_get_container_id(struct fsl_mc_io *mc_io,
0414 u32 cmd_flags,
0415 int *container_id);
0416
0417
0418
0419
0420
0421
0422
0423
0424
0425 struct dprc_endpoint {
0426 char type[16];
0427 int id;
0428 u16 if_id;
0429 };
0430
0431 int dprc_get_connection(struct fsl_mc_io *mc_io,
0432 u32 cmd_flags,
0433 u16 token,
0434 const struct dprc_endpoint *endpoint1,
0435 struct dprc_endpoint *endpoint2,
0436 int *state);
0437
0438
0439
0440
0441
0442
0443 #define DPBP_VER_MAJOR 3
0444 #define DPBP_VER_MINOR 2
0445
0446
0447 #define DPBP_CMD_BASE_VERSION 1
0448 #define DPBP_CMD_ID_OFFSET 4
0449
0450 #define DPBP_CMD(id) (((id) << DPBP_CMD_ID_OFFSET) | DPBP_CMD_BASE_VERSION)
0451
0452
0453 #define DPBP_CMDID_CLOSE DPBP_CMD(0x800)
0454
0455 #define DPBP_CMDID_ENABLE DPBP_CMD(0x002)
0456 #define DPBP_CMDID_DISABLE DPBP_CMD(0x003)
0457 #define DPBP_CMDID_GET_ATTR DPBP_CMD(0x004)
0458 #define DPBP_CMDID_RESET DPBP_CMD(0x005)
0459
0460 struct dpbp_cmd_open {
0461 __le32 dpbp_id;
0462 };
0463
0464 #define DPBP_ENABLE 0x1
0465
0466 struct dpbp_rsp_get_attributes {
0467
0468 __le16 pad;
0469 __le16 bpid;
0470 __le32 id;
0471
0472 __le16 version_major;
0473 __le16 version_minor;
0474 };
0475
0476
0477
0478
0479
0480
0481 #define DPCON_VER_MAJOR 3
0482 #define DPCON_VER_MINOR 2
0483
0484
0485 #define DPCON_CMD_BASE_VERSION 1
0486 #define DPCON_CMD_ID_OFFSET 4
0487
0488 #define DPCON_CMD(id) (((id) << DPCON_CMD_ID_OFFSET) | DPCON_CMD_BASE_VERSION)
0489
0490
0491 #define DPCON_CMDID_CLOSE DPCON_CMD(0x800)
0492
0493 #define DPCON_CMDID_ENABLE DPCON_CMD(0x002)
0494 #define DPCON_CMDID_DISABLE DPCON_CMD(0x003)
0495 #define DPCON_CMDID_GET_ATTR DPCON_CMD(0x004)
0496 #define DPCON_CMDID_RESET DPCON_CMD(0x005)
0497
0498 #define DPCON_CMDID_SET_NOTIFICATION DPCON_CMD(0x100)
0499
0500 struct dpcon_cmd_open {
0501 __le32 dpcon_id;
0502 };
0503
0504 #define DPCON_ENABLE 1
0505
0506 struct dpcon_rsp_get_attr {
0507
0508 __le32 id;
0509 __le16 qbman_ch_id;
0510 u8 num_priorities;
0511 u8 pad;
0512 };
0513
0514 struct dpcon_cmd_set_notification {
0515
0516 __le32 dpio_id;
0517 u8 priority;
0518 u8 pad[3];
0519
0520 __le64 user_ctx;
0521 };
0522
0523
0524
0525
0526
0527
0528 #define OBJ_CMD_BASE_VERSION 1
0529 #define OBJ_CMD_ID_OFFSET 4
0530
0531 #define OBJ_CMD(id) (((id) << OBJ_CMD_ID_OFFSET) | OBJ_CMD_BASE_VERSION)
0532
0533
0534 #define DPRTC_CMDID_OPEN OBJ_CMD(0x810)
0535 #define DPNI_CMDID_OPEN OBJ_CMD(0x801)
0536 #define DPSW_CMDID_OPEN OBJ_CMD(0x802)
0537 #define DPIO_CMDID_OPEN OBJ_CMD(0x803)
0538 #define DPBP_CMDID_OPEN OBJ_CMD(0x804)
0539 #define DPRC_CMDID_OPEN OBJ_CMD(0x805)
0540 #define DPDMUX_CMDID_OPEN OBJ_CMD(0x806)
0541 #define DPCI_CMDID_OPEN OBJ_CMD(0x807)
0542 #define DPCON_CMDID_OPEN OBJ_CMD(0x808)
0543 #define DPSECI_CMDID_OPEN OBJ_CMD(0x809)
0544 #define DPAIOP_CMDID_OPEN OBJ_CMD(0x80a)
0545 #define DPMCP_CMDID_OPEN OBJ_CMD(0x80b)
0546 #define DPMAC_CMDID_OPEN OBJ_CMD(0x80c)
0547 #define DPDCEI_CMDID_OPEN OBJ_CMD(0x80d)
0548 #define DPDMAI_CMDID_OPEN OBJ_CMD(0x80e)
0549 #define DPDBG_CMDID_OPEN OBJ_CMD(0x80f)
0550
0551
0552 #define OBJ_CMDID_CLOSE OBJ_CMD(0x800)
0553 #define OBJ_CMDID_RESET OBJ_CMD(0x005)
0554
0555 struct fsl_mc_obj_cmd_open {
0556 __le32 obj_id;
0557 };
0558
0559
0560
0561
0562
0563
0564
0565
0566
0567
0568
0569 struct fsl_mc_resource_pool {
0570 enum fsl_mc_pool_type type;
0571 int max_count;
0572 int free_count;
0573 struct mutex mutex;
0574 struct list_head free_list;
0575 struct fsl_mc_bus *mc_bus;
0576 };
0577
0578
0579
0580
0581
0582
0583
0584
0585
0586 struct fsl_mc_uapi {
0587 struct miscdevice misc;
0588 struct device *device;
0589 struct mutex mutex;
0590 u32 local_instance_in_use;
0591 struct fsl_mc_io *static_mc_io;
0592 };
0593
0594
0595
0596
0597
0598
0599
0600
0601
0602
0603
0604
0605 struct fsl_mc_bus {
0606 struct fsl_mc_device mc_dev;
0607 struct fsl_mc_resource_pool resource_pools[FSL_MC_NUM_POOL_TYPES];
0608 struct fsl_mc_device_irq *irq_resources;
0609 struct mutex scan_mutex;
0610 struct dprc_attributes dprc_attr;
0611 struct fsl_mc_uapi uapi_misc;
0612 int irq_enabled;
0613 };
0614
0615 #define to_fsl_mc_bus(_mc_dev) \
0616 container_of(_mc_dev, struct fsl_mc_bus, mc_dev)
0617
0618 int __must_check fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
0619 struct fsl_mc_io *mc_io,
0620 struct device *parent_dev,
0621 struct fsl_mc_device **new_mc_dev);
0622
0623 void fsl_mc_device_remove(struct fsl_mc_device *mc_dev);
0624
0625 int __init dprc_driver_init(void);
0626
0627 void dprc_driver_exit(void);
0628
0629 int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
0630 bool alloc_interrupts);
0631
0632 int __init fsl_mc_allocator_driver_init(void);
0633
0634 void fsl_mc_allocator_driver_exit(void);
0635
0636 void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
0637
0638 void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
0639
0640 int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus,
0641 enum fsl_mc_pool_type pool_type,
0642 struct fsl_mc_resource
0643 **new_resource);
0644
0645 void fsl_mc_resource_free(struct fsl_mc_resource *resource);
0646
0647 int fsl_mc_msi_domain_alloc_irqs(struct device *dev,
0648 unsigned int irq_count);
0649
0650 void fsl_mc_msi_domain_free_irqs(struct device *dev);
0651
0652 struct irq_domain *fsl_mc_find_msi_domain(struct device *dev);
0653
0654 int __must_check fsl_create_mc_io(struct device *dev,
0655 phys_addr_t mc_portal_phys_addr,
0656 u32 mc_portal_size,
0657 struct fsl_mc_device *dpmcp_dev,
0658 u32 flags, struct fsl_mc_io **new_mc_io);
0659
0660 void fsl_destroy_mc_io(struct fsl_mc_io *mc_io);
0661
0662 bool fsl_mc_is_root_dprc(struct device *dev);
0663
0664 void fsl_mc_get_root_dprc(struct device *dev,
0665 struct device **root_dprc_dev);
0666
0667 struct fsl_mc_device *fsl_mc_device_lookup(struct fsl_mc_obj_desc *obj_desc,
0668 struct fsl_mc_device *mc_bus_dev);
0669
0670 u16 mc_cmd_hdr_read_cmdid(struct fsl_mc_command *cmd);
0671
0672 #ifdef CONFIG_FSL_MC_UAPI_SUPPORT
0673
0674 int fsl_mc_uapi_create_device_file(struct fsl_mc_bus *mc_bus);
0675
0676 void fsl_mc_uapi_remove_device_file(struct fsl_mc_bus *mc_bus);
0677
0678 #else
0679
0680 static inline int fsl_mc_uapi_create_device_file(struct fsl_mc_bus *mc_bus)
0681 {
0682 return 0;
0683 }
0684
0685 static inline void fsl_mc_uapi_remove_device_file(struct fsl_mc_bus *mc_bus)
0686 {
0687 }
0688
0689 #endif
0690
0691 int disable_dprc_irq(struct fsl_mc_device *mc_dev);
0692 int enable_dprc_irq(struct fsl_mc_device *mc_dev);
0693 int get_dprc_irq_state(struct fsl_mc_device *mc_dev);
0694
0695 #endif