1/* 2 * Freescale Management Complex (MC) bus declarations 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 */ 11#ifndef _FSL_MC_MCBUS_H_ 12#define _FSL_MC_MCBUS_H_ 13 14#include "../include/mc.h" 15#include <linux/mutex.h> 16 17struct irq_domain; 18struct msi_domain_info; 19 20/** 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 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 33/** 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 */ 43struct 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. 58 * @irq_resources: Pointer to array of IRQ objects for the IRQ pool 59 * @scan_mutex: Serializes bus scanning 60 * @dprc_attr: DPRC attributes 61 */ 62struct fsl_mc_bus { 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; 68}; 69 70#define to_fsl_mc_bus(_mc_dev) \ 71 container_of(_mc_dev, struct fsl_mc_bus, mc_dev) 72 73int dprc_scan_container(struct fsl_mc_device *mc_bus_dev); 74 75int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev, 76 unsigned int *total_irq_count); 77 78int __init dprc_driver_init(void); 79 80void dprc_driver_exit(void); 81 82int __init fsl_mc_allocator_driver_init(void); 83 84void fsl_mc_allocator_driver_exit(void); 85 86struct irq_domain *fsl_mc_msi_create_irq_domain(struct fwnode_handle *fwnode, 87 struct msi_domain_info *info, 88 struct irq_domain *parent); 89 90int fsl_mc_find_msi_domain(struct device *mc_platform_dev, 91 struct irq_domain **mc_msi_domain); 92 93int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus, 94 unsigned int irq_count); 95 96void fsl_mc_cleanup_irq_pool(struct fsl_mc_bus *mc_bus); 97 98void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev); 99 100void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev); 101 102bool fsl_mc_bus_exists(void); 103 104void fsl_mc_get_root_dprc(struct device *dev, 105 struct device **root_dprc_dev); 106 107bool fsl_mc_is_root_dprc(struct device *dev); 108 109extern struct bus_type fsl_mc_bus_type; 110 111#endif /* _FSL_MC_MCBUS_H_ */ 112