1 /*
2  * Copyright (C) 2010 Pengutronix
3  * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 2 as published by the
7  * Free Software Foundation.
8  */
9 #include <mach/hardware.h>
10 #include <mach/devices-common.h>
11 
12 #define imx_imx_ssi_data_entry(soc, _id, _hwid, _size)			\
13 	[_id] = {							\
14 		.id = _id,						\
15 		.iobase = soc ## _SSI ## _hwid ## _BASE_ADDR,		\
16 		.iosize = _size,					\
17 		.irq = soc ## _INT_SSI ## _hwid,			\
18 		.dmatx0 = soc ## _DMA_REQ_SSI ## _hwid ## _TX0,		\
19 		.dmarx0 = soc ## _DMA_REQ_SSI ## _hwid ## _RX0,		\
20 		.dmatx1 = soc ## _DMA_REQ_SSI ## _hwid ## _TX1,		\
21 		.dmarx1 = soc ## _DMA_REQ_SSI ## _hwid ## _RX1,		\
22 	}
23 
24 #ifdef CONFIG_SOC_IMX21
25 const struct imx_imx_ssi_data imx21_imx_ssi_data[] __initconst = {
26 #define imx21_imx_ssi_data_entry(_id, _hwid)				\
27 	imx_imx_ssi_data_entry(MX21, _id, _hwid, SZ_4K)
28 	imx21_imx_ssi_data_entry(0, 1),
29 	imx21_imx_ssi_data_entry(1, 2),
30 };
31 #endif /* ifdef CONFIG_SOC_IMX21 */
32 
33 #ifdef CONFIG_SOC_IMX25
34 const struct imx_imx_ssi_data imx25_imx_ssi_data[] __initconst = {
35 #define imx25_imx_ssi_data_entry(_id, _hwid)				\
36 	imx_imx_ssi_data_entry(MX25, _id, _hwid, SZ_4K)
37 	imx25_imx_ssi_data_entry(0, 1),
38 	imx25_imx_ssi_data_entry(1, 2),
39 };
40 #endif /* ifdef CONFIG_SOC_IMX25 */
41 
42 #ifdef CONFIG_SOC_IMX27
43 const struct imx_imx_ssi_data imx27_imx_ssi_data[] __initconst = {
44 #define imx27_imx_ssi_data_entry(_id, _hwid)				\
45 	imx_imx_ssi_data_entry(MX27, _id, _hwid, SZ_4K)
46 	imx27_imx_ssi_data_entry(0, 1),
47 	imx27_imx_ssi_data_entry(1, 2),
48 };
49 #endif /* ifdef CONFIG_SOC_IMX27 */
50 
51 #ifdef CONFIG_SOC_IMX31
52 const struct imx_imx_ssi_data imx31_imx_ssi_data[] __initconst = {
53 #define imx31_imx_ssi_data_entry(_id, _hwid)				\
54 	imx_imx_ssi_data_entry(MX31, _id, _hwid, SZ_4K)
55 	imx31_imx_ssi_data_entry(0, 1),
56 	imx31_imx_ssi_data_entry(1, 2),
57 };
58 #endif /* ifdef CONFIG_SOC_IMX31 */
59 
60 #ifdef CONFIG_SOC_IMX35
61 const struct imx_imx_ssi_data imx35_imx_ssi_data[] __initconst = {
62 #define imx35_imx_ssi_data_entry(_id, _hwid)				\
63 	imx_imx_ssi_data_entry(MX35, _id, _hwid, SZ_4K)
64 	imx35_imx_ssi_data_entry(0, 1),
65 	imx35_imx_ssi_data_entry(1, 2),
66 };
67 #endif /* ifdef CONFIG_SOC_IMX35 */
68 
69 #ifdef CONFIG_SOC_IMX51
70 const struct imx_imx_ssi_data imx51_imx_ssi_data[] __initconst = {
71 #define imx51_imx_ssi_data_entry(_id, _hwid)				\
72 	imx_imx_ssi_data_entry(MX51, _id, _hwid, SZ_16K)
73 	imx51_imx_ssi_data_entry(0, 1),
74 	imx51_imx_ssi_data_entry(1, 2),
75 	imx51_imx_ssi_data_entry(2, 3),
76 };
77 #endif /* ifdef CONFIG_SOC_IMX51 */
78 
79 #ifdef CONFIG_SOC_IMX53
80 const struct imx_imx_ssi_data imx53_imx_ssi_data[] __initconst = {
81 #define imx53_imx_ssi_data_entry(_id, _hwid)				\
82 	imx_imx_ssi_data_entry(MX53, _id, _hwid, SZ_16K)
83 	imx53_imx_ssi_data_entry(0, 1),
84 	imx53_imx_ssi_data_entry(1, 2),
85 	imx53_imx_ssi_data_entry(2, 3),
86 };
87 #endif /* ifdef CONFIG_SOC_IMX53 */
88 
imx_add_imx_ssi(const struct imx_imx_ssi_data * data,const struct imx_ssi_platform_data * pdata)89 struct platform_device *__init imx_add_imx_ssi(
90 		const struct imx_imx_ssi_data *data,
91 		const struct imx_ssi_platform_data *pdata)
92 {
93 	struct resource res[] = {
94 		{
95 			.start = data->iobase,
96 			.end = data->iobase + data->iosize - 1,
97 			.flags = IORESOURCE_MEM,
98 		}, {
99 			.start = data->irq,
100 			.end = data->irq,
101 			.flags = IORESOURCE_IRQ,
102 		},
103 #define DMARES(_name) {							\
104 	.name = #_name,							\
105 	.start = data->dma ## _name,					\
106 	.end = data->dma ## _name,					\
107 	.flags = IORESOURCE_DMA,					\
108 }
109 		DMARES(tx0),
110 		DMARES(rx0),
111 		DMARES(tx1),
112 		DMARES(rx1),
113 	};
114 
115 	return imx_add_platform_device("imx-ssi", data->id,
116 			res, ARRAY_SIZE(res),
117 			pdata, sizeof(*pdata));
118 }
119