2 * Freescale Management Complex (MC) bus private declarations
4 * Copyright (C) 2016 Freescale Semiconductor, Inc.
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
10 #ifndef _FSL_MC_PRIVATE_H_
11 #define _FSL_MC_PRIVATE_H_
13 #include "../include/mc.h"
15 #include <linux/mutex.h>
18 * Maximum number of total IRQs that can be pre-allocated for an MC bus'
21 #define FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS 256
24 * struct fsl_mc_resource_pool - Pool of MC resources of a given
26 * @type: type of resources in the pool
27 * @max_count: maximum number of resources in the pool
28 * @free_count: number of free resources in the pool
29 * @mutex: mutex to serialize access to the pool's free list
30 * @free_list: anchor node of list of free resources in the pool
31 * @mc_bus: pointer to the MC bus that owns this resource pool
33 struct fsl_mc_resource_pool {
34 enum fsl_mc_pool_type type;
37 struct mutex mutex; /* serializes access to free_list */
38 struct list_head free_list;
39 struct fsl_mc_bus *mc_bus;
43 * struct fsl_mc_bus - logical bus that corresponds to a physical DPRC
44 * @mc_dev: fsl-mc device for the bus device itself.
45 * @resource_pools: array of resource pools (one pool per resource type)
46 * for this MC bus. These resources represent allocatable entities
47 * from the physical DPRC.
48 * @irq_resources: Pointer to array of IRQ objects for the IRQ pool
49 * @scan_mutex: Serializes bus scanning
50 * @dprc_attr: DPRC attributes
53 struct fsl_mc_device mc_dev;
54 struct fsl_mc_resource_pool resource_pools[FSL_MC_NUM_POOL_TYPES];
55 struct fsl_mc_device_irq *irq_resources;
56 struct mutex scan_mutex; /* serializes bus scanning */
57 struct dprc_attributes dprc_attr;
60 #define to_fsl_mc_bus(_mc_dev) \
61 container_of(_mc_dev, struct fsl_mc_bus, mc_dev)
63 int __must_check fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
64 struct fsl_mc_io *mc_io,
65 struct device *parent_dev,
66 struct fsl_mc_device **new_mc_dev);
68 void fsl_mc_device_remove(struct fsl_mc_device *mc_dev);
70 int __init dprc_driver_init(void);
72 void dprc_driver_exit(void);
74 int __init fsl_mc_allocator_driver_init(void);
76 void fsl_mc_allocator_driver_exit(void);
78 void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
80 void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
82 int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus,
83 enum fsl_mc_pool_type pool_type,
84 struct fsl_mc_resource
87 void fsl_mc_resource_free(struct fsl_mc_resource *resource);
89 int fsl_mc_msi_domain_alloc_irqs(struct device *dev,
90 unsigned int irq_count);
92 void fsl_mc_msi_domain_free_irqs(struct device *dev);
94 int __init its_fsl_mc_msi_init(void);
96 void its_fsl_mc_msi_cleanup(void);
98 int fsl_mc_find_msi_domain(struct device *mc_platform_dev,
99 struct irq_domain **mc_msi_domain);
101 int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus,
102 unsigned int irq_count);
104 void fsl_mc_cleanup_irq_pool(struct fsl_mc_bus *mc_bus);
106 int __must_check fsl_create_mc_io(struct device *dev,
107 phys_addr_t mc_portal_phys_addr,
109 struct fsl_mc_device *dpmcp_dev,
110 u32 flags, struct fsl_mc_io **new_mc_io);
112 void fsl_destroy_mc_io(struct fsl_mc_io *mc_io);
114 bool fsl_mc_is_root_dprc(struct device *dev);
116 #endif /* _FSL_MC_PRIVATE_H_ */