2 * Freescale Management Complex (MC) bus declarations
4 * Copyright (C) 2014 Freescale Semiconductor, Inc.
5 * Author: German Rivera <German.Rivera@freescale.com>
7 * This file is licensed under the terms of the GNU General Public
8 * License version 2. This program is licensed "as is" without any
9 * warranty of any kind, whether express or implied.
11 #ifndef _FSL_MC_MCBUS_H_
12 #define _FSL_MC_MCBUS_H_
14 #include "../include/mc.h"
15 #include <linux/mutex.h>
18 struct msi_domain_info;
21 * Maximum number of total IRQs that can be pre-allocated for an MC bus'
24 #define FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS 256
26 #ifdef CONFIG_FSL_MC_BUS
27 #define dev_is_fsl_mc(_dev) ((_dev)->bus == &fsl_mc_bus_type)
29 /* If fsl-mc bus is not present device cannot belong to fsl-mc bus */
30 #define dev_is_fsl_mc(_dev) (0)
34 * struct fsl_mc_resource_pool - Pool of MC resources of a given
36 * @type: type of resources in the pool
37 * @max_count: maximum number of resources in the pool
38 * @free_count: number of free resources in the pool
39 * @mutex: mutex to serialize access to the pool's free list
40 * @free_list: anchor node of list of free resources in the pool
41 * @mc_bus: pointer to the MC bus that owns this resource pool
43 struct fsl_mc_resource_pool {
44 enum fsl_mc_pool_type type;
47 struct mutex mutex; /* serializes access to free_list */
48 struct list_head free_list;
49 struct fsl_mc_bus *mc_bus;
53 * struct fsl_mc_bus - logical bus that corresponds to a physical DPRC
54 * @mc_dev: fsl-mc device for the bus device itself.
55 * @resource_pools: array of resource pools (one pool per resource type)
56 * for this MC bus. These resources represent allocatable entities
57 * from the physical DPRC.
58 * @irq_resources: Pointer to array of IRQ objects for the IRQ pool
59 * @scan_mutex: Serializes bus scanning
60 * @dprc_attr: DPRC attributes
63 struct fsl_mc_device mc_dev;
64 struct fsl_mc_resource_pool resource_pools[FSL_MC_NUM_POOL_TYPES];
65 struct fsl_mc_device_irq *irq_resources;
66 struct mutex scan_mutex; /* serializes bus scanning */
67 struct dprc_attributes dprc_attr;
70 #define to_fsl_mc_bus(_mc_dev) \
71 container_of(_mc_dev, struct fsl_mc_bus, mc_dev)
73 int dprc_scan_container(struct fsl_mc_device *mc_bus_dev);
75 int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
76 unsigned int *total_irq_count);
78 int __init dprc_driver_init(void);
80 void dprc_driver_exit(void);
82 int __init fsl_mc_allocator_driver_init(void);
84 void fsl_mc_allocator_driver_exit(void);
86 struct irq_domain *fsl_mc_msi_create_irq_domain(struct fwnode_handle *fwnode,
87 struct msi_domain_info *info,
88 struct irq_domain *parent);
90 int fsl_mc_find_msi_domain(struct device *mc_platform_dev,
91 struct irq_domain **mc_msi_domain);
93 int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus,
94 unsigned int irq_count);
96 void fsl_mc_cleanup_irq_pool(struct fsl_mc_bus *mc_bus);
98 void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
100 void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
102 bool fsl_mc_bus_exists(void);
104 void fsl_mc_get_root_dprc(struct device *dev,
105 struct device **root_dprc_dev);
107 bool fsl_mc_is_root_dprc(struct device *dev);
109 extern struct bus_type fsl_mc_bus_type;
111 #endif /* _FSL_MC_MCBUS_H_ */