mc.h 20 KB

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