J. German Rivera | bbf9d17 | 2015-03-05 19:29:10 -0600 | [diff] [blame] | 1 | /* |
Stuart Yoder | c37ebf8 | 2016-08-23 17:13:04 -0500 | [diff] [blame] | 2 | * Freescale Management Complex (MC) bus declarations |
J. German Rivera | bbf9d17 | 2015-03-05 19:29:10 -0600 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2014 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 | */ |
Stuart Yoder | c37ebf8 | 2016-08-23 17:13:04 -0500 | [diff] [blame] | 11 | #ifndef _FSL_MC_MCBUS_H_ |
| 12 | #define _FSL_MC_MCBUS_H_ |
J. German Rivera | bbf9d17 | 2015-03-05 19:29:10 -0600 | [diff] [blame] | 13 | |
| 14 | #include "../include/mc.h" |
| 15 | #include <linux/mutex.h> |
J. German Rivera | bbf9d17 | 2015-03-05 19:29:10 -0600 | [diff] [blame] | 16 | |
J. German Rivera | 679c2c7 | 2016-01-06 16:03:21 -0600 | [diff] [blame] | 17 | struct irq_domain; |
| 18 | struct msi_domain_info; |
| 19 | |
J. German Rivera | bbf9d17 | 2015-03-05 19:29:10 -0600 | [diff] [blame] | 20 | /** |
J. German Rivera | 89f067df | 2016-01-06 16:03:23 -0600 | [diff] [blame] | 21 | * Maximum number of total IRQs that can be pre-allocated for an MC bus' |
| 22 | * IRQ pool |
| 23 | */ |
| 24 | #define FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS 256 |
| 25 | |
Stuart Yoder | e744e45 | 2016-08-23 17:13:59 -0500 | [diff] [blame] | 26 | #ifdef CONFIG_FSL_MC_BUS |
| 27 | #define dev_is_fsl_mc(_dev) ((_dev)->bus == &fsl_mc_bus_type) |
| 28 | #else |
| 29 | /* If fsl-mc bus is not present device cannot belong to fsl-mc bus */ |
| 30 | #define dev_is_fsl_mc(_dev) (0) |
| 31 | #endif |
| 32 | |
J. German Rivera | 89f067df | 2016-01-06 16:03:23 -0600 | [diff] [blame] | 33 | /** |
J. German Rivera | 197f4d6 | 2015-03-05 19:35:25 -0600 | [diff] [blame] | 34 | * struct fsl_mc_resource_pool - Pool of MC resources of a given |
| 35 | * type |
| 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 |
| 42 | */ |
| 43 | struct fsl_mc_resource_pool { |
| 44 | enum fsl_mc_pool_type type; |
| 45 | int16_t max_count; |
| 46 | int16_t free_count; |
| 47 | struct mutex mutex; /* serializes access to free_list */ |
| 48 | struct list_head free_list; |
| 49 | struct fsl_mc_bus *mc_bus; |
| 50 | }; |
| 51 | |
| 52 | /** |
| 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. |
J. German Rivera | 679c2c7 | 2016-01-06 16:03:21 -0600 | [diff] [blame] | 58 | * @irq_resources: Pointer to array of IRQ objects for the IRQ pool |
J. German Rivera | 197f4d6 | 2015-03-05 19:35:25 -0600 | [diff] [blame] | 59 | * @scan_mutex: Serializes bus scanning |
Itai Katz | 1716cb4 | 2016-04-11 11:56:05 -0500 | [diff] [blame] | 60 | * @dprc_attr: DPRC attributes |
J. German Rivera | 197f4d6 | 2015-03-05 19:35:25 -0600 | [diff] [blame] | 61 | */ |
| 62 | struct fsl_mc_bus { |
| 63 | struct fsl_mc_device mc_dev; |
| 64 | struct fsl_mc_resource_pool resource_pools[FSL_MC_NUM_POOL_TYPES]; |
J. German Rivera | 679c2c7 | 2016-01-06 16:03:21 -0600 | [diff] [blame] | 65 | struct fsl_mc_device_irq *irq_resources; |
J. German Rivera | 197f4d6 | 2015-03-05 19:35:25 -0600 | [diff] [blame] | 66 | struct mutex scan_mutex; /* serializes bus scanning */ |
Itai Katz | 1716cb4 | 2016-04-11 11:56:05 -0500 | [diff] [blame] | 67 | struct dprc_attributes dprc_attr; |
J. German Rivera | 197f4d6 | 2015-03-05 19:35:25 -0600 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | #define to_fsl_mc_bus(_mc_dev) \ |
| 71 | container_of(_mc_dev, struct fsl_mc_bus, mc_dev) |
| 72 | |
J. German Rivera | f2f2726 | 2015-03-05 19:29:11 -0600 | [diff] [blame] | 73 | int dprc_scan_container(struct fsl_mc_device *mc_bus_dev); |
| 74 | |
J. German Rivera | 1e4aa42 | 2016-01-06 16:03:25 -0600 | [diff] [blame] | 75 | int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev, |
| 76 | unsigned int *total_irq_count); |
J. German Rivera | f2f2726 | 2015-03-05 19:29:11 -0600 | [diff] [blame] | 77 | |
| 78 | int __init dprc_driver_init(void); |
| 79 | |
Lijun Pan | 3c7b67f | 2015-10-25 17:41:19 -0500 | [diff] [blame] | 80 | void dprc_driver_exit(void); |
J. German Rivera | f2f2726 | 2015-03-05 19:29:11 -0600 | [diff] [blame] | 81 | |
J. German Rivera | e91ffa9 | 2015-03-27 16:01:08 -0500 | [diff] [blame] | 82 | int __init fsl_mc_allocator_driver_init(void); |
| 83 | |
Thierry Reding | 5336060 | 2016-02-15 14:22:23 +0100 | [diff] [blame] | 84 | void fsl_mc_allocator_driver_exit(void); |
J. German Rivera | e91ffa9 | 2015-03-27 16:01:08 -0500 | [diff] [blame] | 85 | |
J. German Rivera | 679c2c7 | 2016-01-06 16:03:21 -0600 | [diff] [blame] | 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); |
| 89 | |
| 90 | int fsl_mc_find_msi_domain(struct device *mc_platform_dev, |
| 91 | struct irq_domain **mc_msi_domain); |
| 92 | |
J. German Rivera | 89f067df | 2016-01-06 16:03:23 -0600 | [diff] [blame] | 93 | int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus, |
| 94 | unsigned int irq_count); |
| 95 | |
| 96 | void fsl_mc_cleanup_irq_pool(struct fsl_mc_bus *mc_bus); |
| 97 | |
Stuart Yoder | 3640695 | 2016-08-23 17:13:24 -0500 | [diff] [blame] | 98 | void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev); |
| 99 | |
| 100 | void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev); |
| 101 | |
Stuart Yoder | e744e45 | 2016-08-23 17:13:59 -0500 | [diff] [blame] | 102 | bool fsl_mc_bus_exists(void); |
| 103 | |
| 104 | void fsl_mc_get_root_dprc(struct device *dev, |
| 105 | struct device **root_dprc_dev); |
| 106 | |
| 107 | bool fsl_mc_is_root_dprc(struct device *dev); |
| 108 | |
| 109 | extern struct bus_type fsl_mc_bus_type; |
| 110 | |
Stuart Yoder | c37ebf8 | 2016-08-23 17:13:04 -0500 | [diff] [blame] | 111 | #endif /* _FSL_MC_MCBUS_H_ */ |