]>
Commit | Line | Data |
---|---|---|
8a325e9f GKH |
1 | /* |
2 | * Freescale Management Complex (MC) bus declarations | |
3 | * | |
4 | * Copyright (C) 2014-2016 Freescale Semiconductor, Inc. | |
5 | * Author: German Rivera <German.Rivera@freescale.com> | |
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_MCBUS_H_ | |
12 | #define _FSL_MC_MCBUS_H_ | |
13 | ||
14 | #include "../include/mc.h" | |
15 | #include <linux/mutex.h> | |
16 | ||
17 | /** | |
18 | * Maximum number of total IRQs that can be pre-allocated for an MC bus' | |
19 | * IRQ pool | |
20 | */ | |
21 | #define FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS 256 | |
22 | ||
2f81d686 GKH |
23 | #ifdef CONFIG_FSL_MC_BUS |
24 | #define dev_is_fsl_mc(_dev) ((_dev)->bus == &fsl_mc_bus_type) | |
25 | #else | |
26 | /* If fsl-mc bus is not present device cannot belong to fsl-mc bus */ | |
27 | #define dev_is_fsl_mc(_dev) (0) | |
28 | #endif | |
29 | ||
8a325e9f GKH |
30 | /** |
31 | * struct fsl_mc_resource_pool - Pool of MC resources of a given | |
32 | * type | |
33 | * @type: type of resources in the pool | |
34 | * @max_count: maximum number of resources in the pool | |
35 | * @free_count: number of free resources in the pool | |
36 | * @mutex: mutex to serialize access to the pool's free list | |
37 | * @free_list: anchor node of list of free resources in the pool | |
38 | * @mc_bus: pointer to the MC bus that owns this resource pool | |
39 | */ | |
40 | struct fsl_mc_resource_pool { | |
41 | enum fsl_mc_pool_type type; | |
42 | int max_count; | |
43 | int free_count; | |
44 | struct mutex mutex; /* serializes access to free_list */ | |
45 | struct list_head free_list; | |
46 | struct fsl_mc_bus *mc_bus; | |
47 | }; | |
48 | ||
49 | /** | |
50 | * struct fsl_mc_bus - logical bus that corresponds to a physical DPRC | |
51 | * @mc_dev: fsl-mc device for the bus device itself. | |
52 | * @resource_pools: array of resource pools (one pool per resource type) | |
53 | * for this MC bus. These resources represent allocatable entities | |
54 | * from the physical DPRC. | |
55 | * @irq_resources: Pointer to array of IRQ objects for the IRQ pool | |
56 | * @scan_mutex: Serializes bus scanning | |
57 | * @dprc_attr: DPRC attributes | |
58 | */ | |
59 | struct fsl_mc_bus { | |
60 | struct fsl_mc_device mc_dev; | |
61 | struct fsl_mc_resource_pool resource_pools[FSL_MC_NUM_POOL_TYPES]; | |
62 | struct fsl_mc_device_irq *irq_resources; | |
63 | struct mutex scan_mutex; /* serializes bus scanning */ | |
64 | struct dprc_attributes dprc_attr; | |
65 | }; | |
66 | ||
67 | #define to_fsl_mc_bus(_mc_dev) \ | |
68 | container_of(_mc_dev, struct fsl_mc_bus, mc_dev) | |
69 | ||
70 | int fsl_mc_find_msi_domain(struct device *mc_platform_dev, | |
71 | struct irq_domain **mc_msi_domain); | |
72 | ||
73 | int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus, | |
74 | unsigned int irq_count); | |
75 | ||
76 | void fsl_mc_cleanup_irq_pool(struct fsl_mc_bus *mc_bus); | |
77 | ||
78 | void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev); | |
79 | ||
80 | void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev); | |
81 | ||
82 | bool fsl_mc_is_root_dprc(struct device *dev); | |
83 | ||
2f81d686 GKH |
84 | extern struct bus_type fsl_mc_bus_type; |
85 | ||
8a325e9f | 86 | #endif /* _FSL_MC_MCBUS_H_ */ |