1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Freescale Management Complex (MC) bus public interface
4  *
5  * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
6  * Copyright 2019-2020 NXP
7  * Author: German Rivera <German.Rivera@freescale.com>
8  *
9  */
10 #ifndef _FSL_MC_H_
11 #define _FSL_MC_H_
12 
13 #include <linux/device.h>
14 #include <linux/mod_devicetable.h>
15 #include <linux/interrupt.h>
16 #include <uapi/linux/fsl_mc.h>
17 
18 #define FSL_MC_VENDOR_FREESCALE	0x1957
19 
20 struct irq_domain;
21 struct msi_domain_info;
22 
23 struct fsl_mc_device;
24 struct fsl_mc_io;
25 
26 /**
27  * struct fsl_mc_driver - MC object device driver object
28  * @driver: Generic device driver
29  * @match_id_table: table of supported device matching Ids
30  * @probe: Function called when a device is added
31  * @remove: Function called when a device is removed
32  * @shutdown: Function called at shutdown time to quiesce the device
33  * @suspend: Function called when a device is stopped
34  * @resume: Function called when a device is resumed
35  *
36  * Generic DPAA device driver object for device drivers that are registered
37  * with a DPRC bus. This structure is to be embedded in each device-specific
38  * driver structure.
39  */
40 struct fsl_mc_driver {
41 	struct device_driver driver;
42 	const struct fsl_mc_device_id *match_id_table;
43 	int (*probe)(struct fsl_mc_device *dev);
44 	int (*remove)(struct fsl_mc_device *dev);
45 	void (*shutdown)(struct fsl_mc_device *dev);
46 	int (*suspend)(struct fsl_mc_device *dev, pm_message_t state);
47 	int (*resume)(struct fsl_mc_device *dev);
48 };
49 
50 #define to_fsl_mc_driver(_drv) \
51 	container_of(_drv, struct fsl_mc_driver, driver)
52 
53 /**
54  * enum fsl_mc_pool_type - Types of allocatable MC bus resources
55  *
56  * Entries in these enum are used as indices in the array of resource
57  * pools of an fsl_mc_bus object.
58  */
59 enum fsl_mc_pool_type {
60 	FSL_MC_POOL_DPMCP = 0x0,    /* corresponds to "dpmcp" in the MC */
61 	FSL_MC_POOL_DPBP,	    /* corresponds to "dpbp" in the MC */
62 	FSL_MC_POOL_DPCON,	    /* corresponds to "dpcon" in the MC */
63 	FSL_MC_POOL_IRQ,
64 
65 	/*
66 	 * NOTE: New resource pool types must be added before this entry
67 	 */
68 	FSL_MC_NUM_POOL_TYPES
69 };
70 
71 /**
72  * struct fsl_mc_resource - MC generic resource
73  * @type: type of resource
74  * @id: unique MC resource Id within the resources of the same type
75  * @data: pointer to resource-specific data if the resource is currently
76  * allocated, or NULL if the resource is not currently allocated.
77  * @parent_pool: pointer to the parent resource pool from which this
78  * resource is allocated from.
79  * @node: Node in the free list of the corresponding resource pool
80  *
81  * NOTE: This structure is to be embedded as a field of specific
82  * MC resource structures.
83  */
84 struct fsl_mc_resource {
85 	enum fsl_mc_pool_type type;
86 	s32 id;
87 	void *data;
88 	struct fsl_mc_resource_pool *parent_pool;
89 	struct list_head node;
90 };
91 
92 /**
93  * struct fsl_mc_device_irq - MC object device message-based interrupt
94  * @msi_desc: pointer to MSI descriptor allocated by fsl_mc_msi_alloc_descs()
95  * @mc_dev: MC object device that owns this interrupt
96  * @dev_irq_index: device-relative IRQ index
97  * @resource: MC generic resource associated with the interrupt
98  */
99 struct fsl_mc_device_irq {
100 	struct msi_desc *msi_desc;
101 	struct fsl_mc_device *mc_dev;
102 	u8 dev_irq_index;
103 	struct fsl_mc_resource resource;
104 };
105 
106 #define to_fsl_mc_irq(_mc_resource) \
107 	container_of(_mc_resource, struct fsl_mc_device_irq, resource)
108 
109 /* Opened state - Indicates that an object is open by at least one owner */
110 #define FSL_MC_OBJ_STATE_OPEN		0x00000001
111 /* Plugged state - Indicates that the object is plugged */
112 #define FSL_MC_OBJ_STATE_PLUGGED	0x00000002
113 
114 /**
115  * Shareability flag - Object flag indicating no memory shareability.
116  * the object generates memory accesses that are non coherent with other
117  * masters;
118  * user is responsible for proper memory handling through IOMMU configuration.
119  */
120 #define FSL_MC_OBJ_FLAG_NO_MEM_SHAREABILITY	0x0001
121 
122 /**
123  * struct fsl_mc_obj_desc - Object descriptor
124  * @type: Type of object: NULL terminated string
125  * @id: ID of logical object resource
126  * @vendor: Object vendor identifier
127  * @ver_major: Major version number
128  * @ver_minor:  Minor version number
129  * @irq_count: Number of interrupts supported by the object
130  * @region_count: Number of mappable regions supported by the object
131  * @state: Object state: combination of FSL_MC_OBJ_STATE_ states
132  * @label: Object label: NULL terminated string
133  * @flags: Object's flags
134  */
135 struct fsl_mc_obj_desc {
136 	char type[16];
137 	int id;
138 	u16 vendor;
139 	u16 ver_major;
140 	u16 ver_minor;
141 	u8 irq_count;
142 	u8 region_count;
143 	u32 state;
144 	char label[16];
145 	u16 flags;
146 };
147 
148 /**
149  * Bit masks for a MC object device (struct fsl_mc_device) flags
150  */
151 #define FSL_MC_IS_DPRC	0x0001
152 
153 /* Region flags */
154 /* Indicates that region can be mapped as cacheable */
155 #define FSL_MC_REGION_CACHEABLE	0x00000001
156 
157 /* Indicates that region can be mapped as shareable */
158 #define FSL_MC_REGION_SHAREABLE	0x00000002
159 
160 /**
161  * struct fsl_mc_device - MC object device object
162  * @dev: Linux driver model device object
163  * @dma_mask: Default DMA mask
164  * @flags: MC object device flags
165  * @icid: Isolation context ID for the device
166  * @mc_handle: MC handle for the corresponding MC object opened
167  * @mc_io: Pointer to MC IO object assigned to this device or
168  * NULL if none.
169  * @obj_desc: MC description of the DPAA device
170  * @regions: pointer to array of MMIO region entries
171  * @irqs: pointer to array of pointers to interrupts allocated to this device
172  * @resource: generic resource associated with this MC object device, if any.
173  * @driver_override: driver name to force a match
174  *
175  * Generic device object for MC object devices that are "attached" to a
176  * MC bus.
177  *
178  * NOTES:
179  * - For a non-DPRC object its icid is the same as its parent DPRC's icid.
180  * - The SMMU notifier callback gets invoked after device_add() has been
181  *   called for an MC object device, but before the device-specific probe
182  *   callback gets called.
183  * - DP_OBJ_DPRC objects are the only MC objects that have built-in MC
184  *   portals. For all other MC objects, their device drivers are responsible for
185  *   allocating MC portals for them by calling fsl_mc_portal_allocate().
186  * - Some types of MC objects (e.g., DP_OBJ_DPBP, DP_OBJ_DPCON) are
187  *   treated as resources that can be allocated/deallocated from the
188  *   corresponding resource pool in the object's parent DPRC, using the
189  *   fsl_mc_object_allocate()/fsl_mc_object_free() functions. These MC objects
190  *   are known as "allocatable" objects. For them, the corresponding
191  *   fsl_mc_device's 'resource' points to the associated resource object.
192  *   For MC objects that are not allocatable (e.g., DP_OBJ_DPRC, DP_OBJ_DPNI),
193  *   'resource' is NULL.
194  */
195 struct fsl_mc_device {
196 	struct device dev;
197 	u64 dma_mask;
198 	u16 flags;
199 	u32 icid;
200 	u16 mc_handle;
201 	struct fsl_mc_io *mc_io;
202 	struct fsl_mc_obj_desc obj_desc;
203 	struct resource *regions;
204 	struct fsl_mc_device_irq **irqs;
205 	struct fsl_mc_resource *resource;
206 	struct device_link *consumer_link;
207 	char   *driver_override;
208 };
209 
210 #define to_fsl_mc_device(_dev) \
211 	container_of(_dev, struct fsl_mc_device, dev)
212 
213 struct mc_cmd_header {
214 	u8 src_id;
215 	u8 flags_hw;
216 	u8 status;
217 	u8 flags_sw;
218 	__le16 token;
219 	__le16 cmd_id;
220 };
221 
222 enum mc_cmd_status {
223 	MC_CMD_STATUS_OK = 0x0, /* Completed successfully */
224 	MC_CMD_STATUS_READY = 0x1, /* Ready to be processed */
225 	MC_CMD_STATUS_AUTH_ERR = 0x3, /* Authentication error */
226 	MC_CMD_STATUS_NO_PRIVILEGE = 0x4, /* No privilege */
227 	MC_CMD_STATUS_DMA_ERR = 0x5, /* DMA or I/O error */
228 	MC_CMD_STATUS_CONFIG_ERR = 0x6, /* Configuration error */
229 	MC_CMD_STATUS_TIMEOUT = 0x7, /* Operation timed out */
230 	MC_CMD_STATUS_NO_RESOURCE = 0x8, /* No resources */
231 	MC_CMD_STATUS_NO_MEMORY = 0x9, /* No memory available */
232 	MC_CMD_STATUS_BUSY = 0xA, /* Device is busy */
233 	MC_CMD_STATUS_UNSUPPORTED_OP = 0xB, /* Unsupported operation */
234 	MC_CMD_STATUS_INVALID_STATE = 0xC /* Invalid state */
235 };
236 
237 /*
238  * MC command flags
239  */
240 
241 /* High priority flag */
242 #define MC_CMD_FLAG_PRI		0x80
243 /* Command completion flag */
244 #define MC_CMD_FLAG_INTR_DIS	0x01
245 
mc_encode_cmd_header(u16 cmd_id,u32 cmd_flags,u16 token)246 static inline __le64 mc_encode_cmd_header(u16 cmd_id,
247 					  u32 cmd_flags,
248 					  u16 token)
249 {
250 	__le64 header = 0;
251 	struct mc_cmd_header *hdr = (struct mc_cmd_header *)&header;
252 
253 	hdr->cmd_id = cpu_to_le16(cmd_id);
254 	hdr->token  = cpu_to_le16(token);
255 	hdr->status = MC_CMD_STATUS_READY;
256 	if (cmd_flags & MC_CMD_FLAG_PRI)
257 		hdr->flags_hw = MC_CMD_FLAG_PRI;
258 	if (cmd_flags & MC_CMD_FLAG_INTR_DIS)
259 		hdr->flags_sw = MC_CMD_FLAG_INTR_DIS;
260 
261 	return header;
262 }
263 
mc_cmd_hdr_read_token(struct fsl_mc_command * cmd)264 static inline u16 mc_cmd_hdr_read_token(struct fsl_mc_command *cmd)
265 {
266 	struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header;
267 	u16 token = le16_to_cpu(hdr->token);
268 
269 	return token;
270 }
271 
272 struct mc_rsp_create {
273 	__le32 object_id;
274 };
275 
276 struct mc_rsp_api_ver {
277 	__le16 major_ver;
278 	__le16 minor_ver;
279 };
280 
mc_cmd_read_object_id(struct fsl_mc_command * cmd)281 static inline u32 mc_cmd_read_object_id(struct fsl_mc_command *cmd)
282 {
283 	struct mc_rsp_create *rsp_params;
284 
285 	rsp_params = (struct mc_rsp_create *)cmd->params;
286 	return le32_to_cpu(rsp_params->object_id);
287 }
288 
mc_cmd_read_api_version(struct fsl_mc_command * cmd,u16 * major_ver,u16 * minor_ver)289 static inline void mc_cmd_read_api_version(struct fsl_mc_command *cmd,
290 					   u16 *major_ver,
291 					   u16 *minor_ver)
292 {
293 	struct mc_rsp_api_ver *rsp_params;
294 
295 	rsp_params = (struct mc_rsp_api_ver *)cmd->params;
296 	*major_ver = le16_to_cpu(rsp_params->major_ver);
297 	*minor_ver = le16_to_cpu(rsp_params->minor_ver);
298 }
299 
300 /**
301  * Bit masks for a MC I/O object (struct fsl_mc_io) flags
302  */
303 #define FSL_MC_IO_ATOMIC_CONTEXT_PORTAL	0x0001
304 
305 /**
306  * struct fsl_mc_io - MC I/O object to be passed-in to mc_send_command()
307  * @dev: device associated with this Mc I/O object
308  * @flags: flags for mc_send_command()
309  * @portal_size: MC command portal size in bytes
310  * @portal_phys_addr: MC command portal physical address
311  * @portal_virt_addr: MC command portal virtual address
312  * @dpmcp_dev: pointer to the DPMCP device associated with the MC portal.
313  *
314  * Fields are only meaningful if the FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag is not
315  * set:
316  * @mutex: Mutex to serialize mc_send_command() calls that use the same MC
317  * portal, if the fsl_mc_io object was created with the
318  * FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag off. mc_send_command() calls for this
319  * fsl_mc_io object must be made only from non-atomic context.
320  *
321  * Fields are only meaningful if the FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag is
322  * set:
323  * @spinlock: Spinlock to serialize mc_send_command() calls that use the same MC
324  * portal, if the fsl_mc_io object was created with the
325  * FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag on. mc_send_command() calls for this
326  * fsl_mc_io object can be made from atomic or non-atomic context.
327  */
328 struct fsl_mc_io {
329 	struct device *dev;
330 	u16 flags;
331 	u32 portal_size;
332 	phys_addr_t portal_phys_addr;
333 	void __iomem *portal_virt_addr;
334 	struct fsl_mc_device *dpmcp_dev;
335 	union {
336 		/*
337 		 * This field is only meaningful if the
338 		 * FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag is not set
339 		 */
340 		struct mutex mutex; /* serializes mc_send_command() */
341 
342 		/*
343 		 * This field is only meaningful if the
344 		 * FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag is set
345 		 */
346 		raw_spinlock_t spinlock; /* serializes mc_send_command() */
347 	};
348 };
349 
350 int mc_send_command(struct fsl_mc_io *mc_io, struct fsl_mc_command *cmd);
351 
352 #ifdef CONFIG_FSL_MC_BUS
353 #define dev_is_fsl_mc(_dev) ((_dev)->bus == &fsl_mc_bus_type)
354 #else
355 /* If fsl-mc bus is not present device cannot belong to fsl-mc bus */
356 #define dev_is_fsl_mc(_dev) (0)
357 #endif
358 
359 /* Macro to check if a device is a container device */
360 #define fsl_mc_is_cont_dev(_dev) (to_fsl_mc_device(_dev)->flags & \
361 	FSL_MC_IS_DPRC)
362 
363 /* Macro to get the container device of a MC device */
364 #define fsl_mc_cont_dev(_dev) (fsl_mc_is_cont_dev(_dev) ? \
365 	(_dev) : (_dev)->parent)
366 
367 /*
368  * module_fsl_mc_driver() - Helper macro for drivers that don't do
369  * anything special in module init/exit.  This eliminates a lot of
370  * boilerplate.  Each module may only use this macro once, and
371  * calling it replaces module_init() and module_exit()
372  */
373 #define module_fsl_mc_driver(__fsl_mc_driver) \
374 	module_driver(__fsl_mc_driver, fsl_mc_driver_register, \
375 		      fsl_mc_driver_unregister)
376 
377 /*
378  * Macro to avoid include chaining to get THIS_MODULE
379  */
380 #define fsl_mc_driver_register(drv) \
381 	__fsl_mc_driver_register(drv, THIS_MODULE)
382 
383 int __must_check __fsl_mc_driver_register(struct fsl_mc_driver *fsl_mc_driver,
384 					  struct module *owner);
385 
386 void fsl_mc_driver_unregister(struct fsl_mc_driver *driver);
387 
388 /**
389  * struct fsl_mc_version
390  * @major: Major version number: incremented on API compatibility changes
391  * @minor: Minor version number: incremented on API additions (that are
392  *		backward compatible); reset when major version is incremented
393  * @revision: Internal revision number: incremented on implementation changes
394  *		and/or bug fixes that have no impact on API
395  */
396 struct fsl_mc_version {
397 	u32 major;
398 	u32 minor;
399 	u32 revision;
400 };
401 
402 struct fsl_mc_version *fsl_mc_get_version(void);
403 
404 int __must_check fsl_mc_portal_allocate(struct fsl_mc_device *mc_dev,
405 					u16 mc_io_flags,
406 					struct fsl_mc_io **new_mc_io);
407 
408 void fsl_mc_portal_free(struct fsl_mc_io *mc_io);
409 
410 int fsl_mc_portal_reset(struct fsl_mc_io *mc_io);
411 
412 int __must_check fsl_mc_object_allocate(struct fsl_mc_device *mc_dev,
413 					enum fsl_mc_pool_type pool_type,
414 					struct fsl_mc_device **new_mc_adev);
415 
416 void fsl_mc_object_free(struct fsl_mc_device *mc_adev);
417 
418 struct irq_domain *fsl_mc_msi_create_irq_domain(struct fwnode_handle *fwnode,
419 						struct msi_domain_info *info,
420 						struct irq_domain *parent);
421 
422 int __must_check fsl_mc_allocate_irqs(struct fsl_mc_device *mc_dev);
423 
424 void fsl_mc_free_irqs(struct fsl_mc_device *mc_dev);
425 
426 struct fsl_mc_device *fsl_mc_get_endpoint(struct fsl_mc_device *mc_dev);
427 
428 extern struct bus_type fsl_mc_bus_type;
429 
430 extern struct device_type fsl_mc_bus_dprc_type;
431 extern struct device_type fsl_mc_bus_dpni_type;
432 extern struct device_type fsl_mc_bus_dpio_type;
433 extern struct device_type fsl_mc_bus_dpsw_type;
434 extern struct device_type fsl_mc_bus_dpbp_type;
435 extern struct device_type fsl_mc_bus_dpcon_type;
436 extern struct device_type fsl_mc_bus_dpmcp_type;
437 extern struct device_type fsl_mc_bus_dpmac_type;
438 extern struct device_type fsl_mc_bus_dprtc_type;
439 extern struct device_type fsl_mc_bus_dpseci_type;
440 extern struct device_type fsl_mc_bus_dpdmux_type;
441 extern struct device_type fsl_mc_bus_dpdcei_type;
442 extern struct device_type fsl_mc_bus_dpaiop_type;
443 extern struct device_type fsl_mc_bus_dpci_type;
444 extern struct device_type fsl_mc_bus_dpdmai_type;
445 
is_fsl_mc_bus_dprc(const struct fsl_mc_device * mc_dev)446 static inline bool is_fsl_mc_bus_dprc(const struct fsl_mc_device *mc_dev)
447 {
448 	return mc_dev->dev.type == &fsl_mc_bus_dprc_type;
449 }
450 
is_fsl_mc_bus_dpni(const struct fsl_mc_device * mc_dev)451 static inline bool is_fsl_mc_bus_dpni(const struct fsl_mc_device *mc_dev)
452 {
453 	return mc_dev->dev.type == &fsl_mc_bus_dpni_type;
454 }
455 
is_fsl_mc_bus_dpio(const struct fsl_mc_device * mc_dev)456 static inline bool is_fsl_mc_bus_dpio(const struct fsl_mc_device *mc_dev)
457 {
458 	return mc_dev->dev.type == &fsl_mc_bus_dpio_type;
459 }
460 
is_fsl_mc_bus_dpsw(const struct fsl_mc_device * mc_dev)461 static inline bool is_fsl_mc_bus_dpsw(const struct fsl_mc_device *mc_dev)
462 {
463 	return mc_dev->dev.type == &fsl_mc_bus_dpsw_type;
464 }
465 
is_fsl_mc_bus_dpdmux(const struct fsl_mc_device * mc_dev)466 static inline bool is_fsl_mc_bus_dpdmux(const struct fsl_mc_device *mc_dev)
467 {
468 	return mc_dev->dev.type == &fsl_mc_bus_dpdmux_type;
469 }
470 
is_fsl_mc_bus_dpbp(const struct fsl_mc_device * mc_dev)471 static inline bool is_fsl_mc_bus_dpbp(const struct fsl_mc_device *mc_dev)
472 {
473 	return mc_dev->dev.type == &fsl_mc_bus_dpbp_type;
474 }
475 
is_fsl_mc_bus_dpcon(const struct fsl_mc_device * mc_dev)476 static inline bool is_fsl_mc_bus_dpcon(const struct fsl_mc_device *mc_dev)
477 {
478 	return mc_dev->dev.type == &fsl_mc_bus_dpcon_type;
479 }
480 
is_fsl_mc_bus_dpmcp(const struct fsl_mc_device * mc_dev)481 static inline bool is_fsl_mc_bus_dpmcp(const struct fsl_mc_device *mc_dev)
482 {
483 	return mc_dev->dev.type == &fsl_mc_bus_dpmcp_type;
484 }
485 
is_fsl_mc_bus_dpmac(const struct fsl_mc_device * mc_dev)486 static inline bool is_fsl_mc_bus_dpmac(const struct fsl_mc_device *mc_dev)
487 {
488 	return mc_dev->dev.type == &fsl_mc_bus_dpmac_type;
489 }
490 
is_fsl_mc_bus_dprtc(const struct fsl_mc_device * mc_dev)491 static inline bool is_fsl_mc_bus_dprtc(const struct fsl_mc_device *mc_dev)
492 {
493 	return mc_dev->dev.type == &fsl_mc_bus_dprtc_type;
494 }
495 
is_fsl_mc_bus_dpseci(const struct fsl_mc_device * mc_dev)496 static inline bool is_fsl_mc_bus_dpseci(const struct fsl_mc_device *mc_dev)
497 {
498 	return mc_dev->dev.type == &fsl_mc_bus_dpseci_type;
499 }
500 
is_fsl_mc_bus_dpdcei(const struct fsl_mc_device * mc_dev)501 static inline bool is_fsl_mc_bus_dpdcei(const struct fsl_mc_device *mc_dev)
502 {
503 	return mc_dev->dev.type == &fsl_mc_bus_dpdcei_type;
504 }
505 
is_fsl_mc_bus_dpaiop(const struct fsl_mc_device * mc_dev)506 static inline bool is_fsl_mc_bus_dpaiop(const struct fsl_mc_device *mc_dev)
507 {
508 	return mc_dev->dev.type == &fsl_mc_bus_dpaiop_type;
509 }
510 
is_fsl_mc_bus_dpci(const struct fsl_mc_device * mc_dev)511 static inline bool is_fsl_mc_bus_dpci(const struct fsl_mc_device *mc_dev)
512 {
513 	return mc_dev->dev.type == &fsl_mc_bus_dpci_type;
514 }
515 
is_fsl_mc_bus_dpdmai(const struct fsl_mc_device * mc_dev)516 static inline bool is_fsl_mc_bus_dpdmai(const struct fsl_mc_device *mc_dev)
517 {
518 	return mc_dev->dev.type == &fsl_mc_bus_dpdmai_type;
519 }
520 
521 #define DPRC_RESET_OPTION_NON_RECURSIVE                0x00000001
522 int dprc_reset_container(struct fsl_mc_io *mc_io,
523 			 u32 cmd_flags,
524 			 u16 token,
525 			 int child_container_id,
526 			 u32 options);
527 
528 int dprc_scan_container(struct fsl_mc_device *mc_bus_dev,
529 			bool alloc_interrupts);
530 
531 void dprc_remove_devices(struct fsl_mc_device *mc_bus_dev,
532 			 struct fsl_mc_obj_desc *obj_desc_array,
533 			 int num_child_objects_in_mc);
534 
535 int dprc_cleanup(struct fsl_mc_device *mc_dev);
536 
537 int dprc_setup(struct fsl_mc_device *mc_dev);
538 
539 /**
540  * Maximum number of total IRQs that can be pre-allocated for an MC bus'
541  * IRQ pool
542  */
543 #define FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS	256
544 
545 int fsl_mc_populate_irq_pool(struct fsl_mc_device *mc_bus_dev,
546 			     unsigned int irq_count);
547 
548 void fsl_mc_cleanup_irq_pool(struct fsl_mc_device *mc_bus_dev);
549 
550 /*
551  * Data Path Buffer Pool (DPBP) API
552  * Contains initialization APIs and runtime control APIs for DPBP
553  */
554 
555 int dpbp_open(struct fsl_mc_io *mc_io,
556 	      u32 cmd_flags,
557 	      int dpbp_id,
558 	      u16 *token);
559 
560 int dpbp_close(struct fsl_mc_io *mc_io,
561 	       u32 cmd_flags,
562 	       u16 token);
563 
564 int dpbp_enable(struct fsl_mc_io *mc_io,
565 		u32 cmd_flags,
566 		u16 token);
567 
568 int dpbp_disable(struct fsl_mc_io *mc_io,
569 		 u32 cmd_flags,
570 		 u16 token);
571 
572 int dpbp_reset(struct fsl_mc_io *mc_io,
573 	       u32 cmd_flags,
574 	       u16 token);
575 
576 /**
577  * struct dpbp_attr - Structure representing DPBP attributes
578  * @id:		DPBP object ID
579  * @bpid:	Hardware buffer pool ID; should be used as an argument in
580  *		acquire/release operations on buffers
581  */
582 struct dpbp_attr {
583 	int id;
584 	u16 bpid;
585 };
586 
587 int dpbp_get_attributes(struct fsl_mc_io *mc_io,
588 			u32 cmd_flags,
589 			u16 token,
590 			struct dpbp_attr *attr);
591 
592 /* Data Path Concentrator (DPCON) API
593  * Contains initialization APIs and runtime control APIs for DPCON
594  */
595 
596 /**
597  * Use it to disable notifications; see dpcon_set_notification()
598  */
599 #define DPCON_INVALID_DPIO_ID		(int)(-1)
600 
601 int dpcon_open(struct fsl_mc_io *mc_io,
602 	       u32 cmd_flags,
603 	       int dpcon_id,
604 	       u16 *token);
605 
606 int dpcon_close(struct fsl_mc_io *mc_io,
607 		u32 cmd_flags,
608 		u16 token);
609 
610 int dpcon_enable(struct fsl_mc_io *mc_io,
611 		 u32 cmd_flags,
612 		 u16 token);
613 
614 int dpcon_disable(struct fsl_mc_io *mc_io,
615 		  u32 cmd_flags,
616 		  u16 token);
617 
618 int dpcon_reset(struct fsl_mc_io *mc_io,
619 		u32 cmd_flags,
620 		u16 token);
621 
622 /**
623  * struct dpcon_attr - Structure representing DPCON attributes
624  * @id: DPCON object ID
625  * @qbman_ch_id: Channel ID to be used by dequeue operation
626  * @num_priorities: Number of priorities for the DPCON channel (1-8)
627  */
628 struct dpcon_attr {
629 	int id;
630 	u16 qbman_ch_id;
631 	u8 num_priorities;
632 };
633 
634 int dpcon_get_attributes(struct fsl_mc_io *mc_io,
635 			 u32 cmd_flags,
636 			 u16 token,
637 			 struct dpcon_attr *attr);
638 
639 /**
640  * struct dpcon_notification_cfg - Structure representing notification params
641  * @dpio_id:	DPIO object ID; must be configured with a notification channel;
642  *	to disable notifications set it to 'DPCON_INVALID_DPIO_ID';
643  * @priority:	Priority selection within the DPIO channel; valid values
644  *		are 0-7, depending on the number of priorities in that channel
645  * @user_ctx:	User context value provided with each CDAN message
646  */
647 struct dpcon_notification_cfg {
648 	int dpio_id;
649 	u8 priority;
650 	u64 user_ctx;
651 };
652 
653 int dpcon_set_notification(struct fsl_mc_io *mc_io,
654 			   u32 cmd_flags,
655 			   u16 token,
656 			   struct dpcon_notification_cfg *cfg);
657 
658 #endif /* _FSL_MC_H_ */
659