xref: /openbmc/linux/drivers/interconnect/imx/imx.h (revision 3a35093a)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Interconnect framework driver for i.MX SoC
4  *
5  * Copyright (c) 2019, BayLibre
6  * Copyright (c) 2019-2020, NXP
7  * Author: Alexandre Bailon <abailon@baylibre.com>
8  * Author: Leonard Crestez <leonard.crestez@nxp.com>
9  */
10 #ifndef __DRIVERS_INTERCONNECT_IMX_H
11 #define __DRIVERS_INTERCONNECT_IMX_H
12 
13 #include <linux/kernel.h>
14 
15 #define IMX_ICC_MAX_LINKS	4
16 
17 /*
18  * struct imx_icc_node_adj - Describe a dynamic adjustable node
19  */
20 struct imx_icc_node_adj_desc {
21 	unsigned int bw_mul, bw_div;
22 	const char *phandle_name;
23 	bool main_noc;
24 };
25 
26 /*
27  * struct imx_icc_node - Describe an interconnect node
28  * @name: name of the node
29  * @id: an unique id to identify the node
30  * @links: an array of slaves' node id
31  * @num_links: number of id defined in links
32  */
33 struct imx_icc_node_desc {
34 	const char *name;
35 	u16 id;
36 	u16 links[IMX_ICC_MAX_LINKS];
37 	u16 num_links;
38 	const struct imx_icc_node_adj_desc *adj;
39 };
40 
41 #define DEFINE_BUS_INTERCONNECT(_name, _id, _adj, ...)			\
42 	{								\
43 		.id = _id,						\
44 		.name = _name,						\
45 		.adj = _adj,						\
46 		.num_links = ARRAY_SIZE(((int[]){ __VA_ARGS__ })),	\
47 		.links = { __VA_ARGS__ },				\
48 	}
49 
50 #define DEFINE_BUS_MASTER(_name, _id, _dest_id)				\
51 	DEFINE_BUS_INTERCONNECT(_name, _id, NULL, _dest_id)
52 
53 #define DEFINE_BUS_SLAVE(_name, _id, _adj)				\
54 	DEFINE_BUS_INTERCONNECT(_name, _id, _adj)
55 
56 int imx_icc_register(struct platform_device *pdev,
57 		     struct imx_icc_node_desc *nodes,
58 		     int nodes_count);
59 int imx_icc_unregister(struct platform_device *pdev);
60 
61 #endif /* __DRIVERS_INTERCONNECT_IMX_H */
62