• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (C) 2009-2010 Pengutronix
4  * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
5  */
6 #include "../hardware.h"
7 #include "devices-common.h"
8 
9 #define imx_spi_imx_data_entry_single(soc, type, _devid, _id, hwid, _size) \
10 	{								\
11 		.devid = _devid,					\
12 		.id = _id,						\
13 		.iobase = soc ## _ ## type ## hwid ## _BASE_ADDR,	\
14 		.iosize = _size,					\
15 		.irq = soc ## _INT_ ## type ## hwid,			\
16 	}
17 
18 #define imx_spi_imx_data_entry(soc, type, devid, id, hwid, size)	\
19 	[id] = imx_spi_imx_data_entry_single(soc, type, devid, id, hwid, size)
20 
21 #ifdef CONFIG_SOC_IMX21
22 const struct imx_spi_imx_data imx21_cspi_data[] __initconst = {
23 #define imx21_cspi_data_entry(_id, _hwid)                            \
24 	imx_spi_imx_data_entry(MX21, CSPI, "imx21-cspi", _id, _hwid, SZ_4K)
25 	imx21_cspi_data_entry(0, 1),
26 	imx21_cspi_data_entry(1, 2),
27 };
28 #endif
29 
30 #ifdef CONFIG_SOC_IMX27
31 const struct imx_spi_imx_data imx27_cspi_data[] __initconst = {
32 #define imx27_cspi_data_entry(_id, _hwid)				\
33 	imx_spi_imx_data_entry(MX27, CSPI, "imx27-cspi", _id, _hwid, SZ_4K)
34 	imx27_cspi_data_entry(0, 1),
35 	imx27_cspi_data_entry(1, 2),
36 	imx27_cspi_data_entry(2, 3),
37 };
38 #endif /* ifdef CONFIG_SOC_IMX27 */
39 
40 #ifdef CONFIG_SOC_IMX31
41 const struct imx_spi_imx_data imx31_cspi_data[] __initconst = {
42 #define imx31_cspi_data_entry(_id, _hwid)				\
43 	imx_spi_imx_data_entry(MX31, CSPI, "imx31-cspi", _id, _hwid, SZ_4K)
44 	imx31_cspi_data_entry(0, 1),
45 	imx31_cspi_data_entry(1, 2),
46 	imx31_cspi_data_entry(2, 3),
47 };
48 #endif /* ifdef CONFIG_SOC_IMX31 */
49 
50 #ifdef CONFIG_SOC_IMX35
51 const struct imx_spi_imx_data imx35_cspi_data[] __initconst = {
52 #define imx35_cspi_data_entry(_id, _hwid)                           \
53 	imx_spi_imx_data_entry(MX35, CSPI, "imx35-cspi", _id, _hwid, SZ_4K)
54 	imx35_cspi_data_entry(0, 1),
55 	imx35_cspi_data_entry(1, 2),
56 };
57 #endif /* ifdef CONFIG_SOC_IMX35 */
58 
imx_add_spi_imx(const struct imx_spi_imx_data * data,const struct spi_imx_master * pdata)59 struct platform_device *__init imx_add_spi_imx(
60 		const struct imx_spi_imx_data *data,
61 		const struct spi_imx_master *pdata)
62 {
63 	struct resource res[] = {
64 		{
65 			.start = data->iobase,
66 			.end = data->iobase + data->iosize - 1,
67 			.flags = IORESOURCE_MEM,
68 		}, {
69 			.start = data->irq,
70 			.end = data->irq,
71 			.flags = IORESOURCE_IRQ,
72 		},
73 	};
74 
75 	return imx_add_platform_device(data->devid, data->id,
76 			res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
77 }
78