1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Interconnect framework driver for i.MX8MN SoC
4  *
5  * Copyright (c) 2019-2020, NXP
6  */
7 
8 #include <linux/module.h>
9 #include <linux/platform_device.h>
10 #include <dt-bindings/interconnect/imx8mn.h>
11 
12 #include "imx.h"
13 
14 static const struct imx_icc_node_adj_desc imx8mn_dram_adj = {
15 	.bw_mul = 1,
16 	.bw_div = 4,
17 	.phandle_name = "fsl,ddrc",
18 };
19 
20 static const struct imx_icc_node_adj_desc imx8mn_noc_adj = {
21 	.bw_mul = 1,
22 	.bw_div = 4,
23 	.main_noc = true,
24 };
25 
26 /*
27  * Describe bus masters, slaves and connections between them
28  *
29  * This is a simplified subset of the bus diagram, there are several other
30  * PL301 nics which are skipped/merged into PL301_MAIN
31  */
32 static struct imx_icc_node_desc nodes[] = {
33 	DEFINE_BUS_INTERCONNECT("NOC", IMX8MN_ICN_NOC, &imx8mn_noc_adj,
34 			IMX8MN_ICS_DRAM, IMX8MN_ICN_MAIN),
35 
36 	DEFINE_BUS_SLAVE("DRAM", IMX8MN_ICS_DRAM, &imx8mn_dram_adj),
37 	DEFINE_BUS_SLAVE("OCRAM", IMX8MN_ICS_OCRAM, NULL),
38 	DEFINE_BUS_MASTER("A53", IMX8MN_ICM_A53, IMX8MN_ICN_NOC),
39 
40 	/* GPUMIX */
41 	DEFINE_BUS_MASTER("GPU", IMX8MN_ICM_GPU, IMX8MN_ICN_GPU),
42 	DEFINE_BUS_INTERCONNECT("PL301_GPU", IMX8MN_ICN_GPU, NULL, IMX8MN_ICN_NOC),
43 
44 	/* DISPLAYMIX */
45 	DEFINE_BUS_MASTER("CSI1", IMX8MN_ICM_CSI1, IMX8MN_ICN_MIPI),
46 	DEFINE_BUS_MASTER("CSI2", IMX8MN_ICM_CSI2, IMX8MN_ICN_MIPI),
47 	DEFINE_BUS_MASTER("ISI", IMX8MN_ICM_ISI, IMX8MN_ICN_MIPI),
48 	DEFINE_BUS_MASTER("LCDIF", IMX8MN_ICM_LCDIF, IMX8MN_ICN_MIPI),
49 	DEFINE_BUS_INTERCONNECT("PL301_MIPI", IMX8MN_ICN_MIPI, NULL, IMX8MN_ICN_NOC),
50 
51 	/* USB goes straight to NOC */
52 	DEFINE_BUS_MASTER("USB", IMX8MN_ICM_USB, IMX8MN_ICN_NOC),
53 
54 	/* Audio */
55 	DEFINE_BUS_MASTER("SDMA2", IMX8MN_ICM_SDMA2, IMX8MN_ICN_AUDIO),
56 	DEFINE_BUS_MASTER("SDMA3", IMX8MN_ICM_SDMA3, IMX8MN_ICN_AUDIO),
57 	DEFINE_BUS_INTERCONNECT("PL301_AUDIO", IMX8MN_ICN_AUDIO, NULL, IMX8MN_ICN_MAIN),
58 
59 	/* Ethernet */
60 	DEFINE_BUS_MASTER("ENET", IMX8MN_ICM_ENET, IMX8MN_ICN_ENET),
61 	DEFINE_BUS_INTERCONNECT("PL301_ENET", IMX8MN_ICN_ENET, NULL, IMX8MN_ICN_MAIN),
62 
63 	/* Other */
64 	DEFINE_BUS_MASTER("SDMA1", IMX8MN_ICM_SDMA1, IMX8MN_ICN_MAIN),
65 	DEFINE_BUS_MASTER("NAND", IMX8MN_ICM_NAND, IMX8MN_ICN_MAIN),
66 	DEFINE_BUS_MASTER("USDHC1", IMX8MN_ICM_USDHC1, IMX8MN_ICN_MAIN),
67 	DEFINE_BUS_MASTER("USDHC2", IMX8MN_ICM_USDHC2, IMX8MN_ICN_MAIN),
68 	DEFINE_BUS_MASTER("USDHC3", IMX8MN_ICM_USDHC3, IMX8MN_ICN_MAIN),
69 	DEFINE_BUS_INTERCONNECT("PL301_MAIN", IMX8MN_ICN_MAIN, NULL,
70 			IMX8MN_ICN_NOC, IMX8MN_ICS_OCRAM),
71 };
72 
73 static int imx8mn_icc_probe(struct platform_device *pdev)
74 {
75 	return imx_icc_register(pdev, nodes, ARRAY_SIZE(nodes), NULL);
76 }
77 
78 static int imx8mn_icc_remove(struct platform_device *pdev)
79 {
80 	imx_icc_unregister(pdev);
81 
82 	return 0;
83 }
84 
85 static struct platform_driver imx8mn_icc_driver = {
86 	.probe = imx8mn_icc_probe,
87 	.remove = imx8mn_icc_remove,
88 	.driver = {
89 		.name = "imx8mn-interconnect",
90 	},
91 };
92 
93 module_platform_driver(imx8mn_icc_driver);
94 MODULE_ALIAS("platform:imx8mn-interconnect");
95 MODULE_AUTHOR("Leonard Crestez <leonard.crestez@nxp.com>");
96 MODULE_LICENSE("GPL v2");
97