]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/staging/fsl-mc/include/mc-bus.h
Revert "staging: fsl-mc: turn several exported functions static"
[mirror_ubuntu-artful-kernel.git] / drivers / staging / fsl-mc / include / mc-bus.h
CommitLineData
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
3943749b
GKH
17struct irq_domain;
18struct msi_domain_info;
19
8a325e9f
GKH
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
2f81d686
GKH
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
8a325e9f
GKH
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 int max_count;
46 int 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
ae74754d
GKH
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
3943749b
GKH
78struct irq_domain *fsl_mc_msi_create_irq_domain(struct fwnode_handle *fwnode,
79 struct msi_domain_info *info,
80 struct irq_domain *parent);
81
8a325e9f
GKH
82int fsl_mc_find_msi_domain(struct device *mc_platform_dev,
83 struct irq_domain **mc_msi_domain);
84
85int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus,
86 unsigned int irq_count);
87
88void fsl_mc_cleanup_irq_pool(struct fsl_mc_bus *mc_bus);
89
90void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
91
92void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
93
ae74754d
GKH
94void fsl_mc_get_root_dprc(struct device *dev,
95 struct device **root_dprc_dev);
96
8a325e9f
GKH
97bool fsl_mc_is_root_dprc(struct device *dev);
98
2f81d686
GKH
99extern struct bus_type fsl_mc_bus_type;
100
8a325e9f 101#endif /* _FSL_MC_MCBUS_H_ */