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