]> Git Repo - linux.git/blob - drivers/staging/fsl-mc/include/mc-private.h
xprtrdma: Prevent inline overflow
[linux.git] / drivers / staging / fsl-mc / include / mc-private.h
1 /*
2  * Freescale Management Complex (MC) bus private declarations
3  *
4  * Copyright (C) 2014 Freescale Semiconductor, Inc.
5  * Author: German Rivera <[email protected]>
6  *
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.
10  */
11 #ifndef _FSL_MC_PRIVATE_H_
12 #define _FSL_MC_PRIVATE_H_
13
14 #include "../include/mc.h"
15 #include <linux/mutex.h>
16 #include <linux/stringify.h>
17
18 #define FSL_MC_DPRC_DRIVER_NAME    "fsl_mc_dprc"
19
20 #define FSL_MC_DEVICE_MATCH(_mc_dev, _obj_desc) \
21         (strcmp((_mc_dev)->obj_desc.type, (_obj_desc)->type) == 0 && \
22          (_mc_dev)->obj_desc.id == (_obj_desc)->id)
23
24 #define FSL_MC_IS_ALLOCATABLE(_obj_type) \
25         (strcmp(_obj_type, "dpbp") == 0 || \
26          strcmp(_obj_type, "dpmcp") == 0 || \
27          strcmp(_obj_type, "dpcon") == 0)
28
29 struct irq_domain;
30 struct msi_domain_info;
31
32 /**
33  * Maximum number of total IRQs that can be pre-allocated for an MC bus'
34  * IRQ pool
35  */
36 #define FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS  256
37
38 struct device_node;
39 struct irq_domain;
40 struct msi_domain_info;
41
42 /**
43  * struct fsl_mc - Private data of a "fsl,qoriq-mc" platform device
44  * @root_mc_bus_dev: MC object device representing the root DPRC
45  * @num_translation_ranges: number of entries in addr_translation_ranges
46  * @translation_ranges: array of bus to system address translation ranges
47  */
48 struct fsl_mc {
49         struct fsl_mc_device *root_mc_bus_dev;
50         u8 num_translation_ranges;
51         struct fsl_mc_addr_translation_range *translation_ranges;
52 };
53
54 /**
55  * struct fsl_mc_addr_translation_range - bus to system address translation
56  * range
57  * @mc_region_type: Type of MC region for the range being translated
58  * @start_mc_offset: Start MC offset of the range being translated
59  * @end_mc_offset: MC offset of the first byte after the range (last MC
60  * offset of the range is end_mc_offset - 1)
61  * @start_phys_addr: system physical address corresponding to start_mc_addr
62  */
63 struct fsl_mc_addr_translation_range {
64         enum dprc_region_type mc_region_type;
65         u64 start_mc_offset;
66         u64 end_mc_offset;
67         phys_addr_t start_phys_addr;
68 };
69
70 /**
71  * struct fsl_mc_resource_pool - Pool of MC resources of a given
72  * type
73  * @type: type of resources in the pool
74  * @max_count: maximum number of resources in the pool
75  * @free_count: number of free resources in the pool
76  * @mutex: mutex to serialize access to the pool's free list
77  * @free_list: anchor node of list of free resources in the pool
78  * @mc_bus: pointer to the MC bus that owns this resource pool
79  */
80 struct fsl_mc_resource_pool {
81         enum fsl_mc_pool_type type;
82         int16_t max_count;
83         int16_t free_count;
84         struct mutex mutex;     /* serializes access to free_list */
85         struct list_head free_list;
86         struct fsl_mc_bus *mc_bus;
87 };
88
89 /**
90  * struct fsl_mc_bus - logical bus that corresponds to a physical DPRC
91  * @mc_dev: fsl-mc device for the bus device itself.
92  * @resource_pools: array of resource pools (one pool per resource type)
93  * for this MC bus. These resources represent allocatable entities
94  * from the physical DPRC.
95  * @irq_resources: Pointer to array of IRQ objects for the IRQ pool
96  * @scan_mutex: Serializes bus scanning
97  */
98 struct fsl_mc_bus {
99         struct fsl_mc_device mc_dev;
100         struct fsl_mc_resource_pool resource_pools[FSL_MC_NUM_POOL_TYPES];
101         struct fsl_mc_device_irq *irq_resources;
102         struct mutex scan_mutex;    /* serializes bus scanning */
103 };
104
105 #define to_fsl_mc_bus(_mc_dev) \
106         container_of(_mc_dev, struct fsl_mc_bus, mc_dev)
107
108 int __must_check fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
109                                    struct fsl_mc_io *mc_io,
110                                    struct device *parent_dev,
111                                    struct fsl_mc_device **new_mc_dev);
112
113 void fsl_mc_device_remove(struct fsl_mc_device *mc_dev);
114
115 int dprc_scan_container(struct fsl_mc_device *mc_bus_dev);
116
117 int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
118                       unsigned int *total_irq_count);
119
120 int __init dprc_driver_init(void);
121
122 void dprc_driver_exit(void);
123
124 int __init fsl_mc_allocator_driver_init(void);
125
126 void fsl_mc_allocator_driver_exit(void);
127
128 int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus,
129                                           enum fsl_mc_pool_type pool_type,
130                                           struct fsl_mc_resource
131                                                           **new_resource);
132
133 void fsl_mc_resource_free(struct fsl_mc_resource *resource);
134
135 struct irq_domain *fsl_mc_msi_create_irq_domain(struct fwnode_handle *fwnode,
136                                                 struct msi_domain_info *info,
137                                                 struct irq_domain *parent);
138
139 int fsl_mc_find_msi_domain(struct device *mc_platform_dev,
140                            struct irq_domain **mc_msi_domain);
141
142 int fsl_mc_msi_domain_alloc_irqs(struct device *dev,
143                                  unsigned int irq_count);
144
145 void fsl_mc_msi_domain_free_irqs(struct device *dev);
146
147 int __init its_fsl_mc_msi_init(void);
148
149 void its_fsl_mc_msi_cleanup(void);
150
151 int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus,
152                              unsigned int irq_count);
153
154 void fsl_mc_cleanup_irq_pool(struct fsl_mc_bus *mc_bus);
155
156 #endif /* _FSL_MC_PRIVATE_H_ */
This page took 0.036938 seconds and 4 git commands to generate.