• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009-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 "../hardware.h"
10 #include "devices-common.h"
11 
12 #define imx_imx_i2c_data_entry_single(soc, _devid, _id, _hwid, _size)	\
13 	{								\
14 		.devid = _devid,					\
15 		.id = _id,						\
16 		.iobase = soc ## _I2C ## _hwid ## _BASE_ADDR,		\
17 		.iosize = _size,					\
18 		.irq = soc ## _INT_I2C ## _hwid,			\
19 	}
20 
21 #define imx_imx_i2c_data_entry(soc, _devid, _id, _hwid, _size)		\
22 	[_id] = imx_imx_i2c_data_entry_single(soc, _devid, _id, _hwid, _size)
23 
24 #ifdef CONFIG_SOC_IMX1
25 const struct imx_imx_i2c_data imx1_imx_i2c_data __initconst =
26 	imx_imx_i2c_data_entry_single(MX1, "imx1-i2c", 0, , SZ_4K);
27 #endif /* ifdef CONFIG_SOC_IMX1 */
28 
29 #ifdef CONFIG_SOC_IMX21
30 const struct imx_imx_i2c_data imx21_imx_i2c_data __initconst =
31 	imx_imx_i2c_data_entry_single(MX21, "imx21-i2c", 0, , SZ_4K);
32 #endif /* ifdef CONFIG_SOC_IMX21 */
33 
34 #ifdef CONFIG_SOC_IMX25
35 const struct imx_imx_i2c_data imx25_imx_i2c_data[] __initconst = {
36 #define imx25_imx_i2c_data_entry(_id, _hwid)				\
37 	imx_imx_i2c_data_entry(MX25, "imx21-i2c", _id, _hwid, SZ_16K)
38 	imx25_imx_i2c_data_entry(0, 1),
39 	imx25_imx_i2c_data_entry(1, 2),
40 	imx25_imx_i2c_data_entry(2, 3),
41 };
42 #endif /* ifdef CONFIG_SOC_IMX25 */
43 
44 #ifdef CONFIG_SOC_IMX27
45 const struct imx_imx_i2c_data imx27_imx_i2c_data[] __initconst = {
46 #define imx27_imx_i2c_data_entry(_id, _hwid)				\
47 	imx_imx_i2c_data_entry(MX27, "imx21-i2c", _id, _hwid, SZ_4K)
48 	imx27_imx_i2c_data_entry(0, 1),
49 	imx27_imx_i2c_data_entry(1, 2),
50 };
51 #endif /* ifdef CONFIG_SOC_IMX27 */
52 
53 #ifdef CONFIG_SOC_IMX31
54 const struct imx_imx_i2c_data imx31_imx_i2c_data[] __initconst = {
55 #define imx31_imx_i2c_data_entry(_id, _hwid)				\
56 	imx_imx_i2c_data_entry(MX31, "imx21-i2c", _id, _hwid, SZ_4K)
57 	imx31_imx_i2c_data_entry(0, 1),
58 	imx31_imx_i2c_data_entry(1, 2),
59 	imx31_imx_i2c_data_entry(2, 3),
60 };
61 #endif /* ifdef CONFIG_SOC_IMX31 */
62 
63 #ifdef CONFIG_SOC_IMX35
64 const struct imx_imx_i2c_data imx35_imx_i2c_data[] __initconst = {
65 #define imx35_imx_i2c_data_entry(_id, _hwid)				\
66 	imx_imx_i2c_data_entry(MX35, "imx21-i2c", _id, _hwid, SZ_4K)
67 	imx35_imx_i2c_data_entry(0, 1),
68 	imx35_imx_i2c_data_entry(1, 2),
69 	imx35_imx_i2c_data_entry(2, 3),
70 };
71 #endif /* ifdef CONFIG_SOC_IMX35 */
72 
73 #ifdef CONFIG_SOC_IMX51
74 const struct imx_imx_i2c_data imx51_imx_i2c_data[] __initconst = {
75 #define imx51_imx_i2c_data_entry(_id, _hwid)				\
76 	imx_imx_i2c_data_entry(MX51, "imx21-i2c", _id, _hwid, SZ_4K)
77 	imx51_imx_i2c_data_entry(0, 1),
78 	imx51_imx_i2c_data_entry(1, 2),
79 	{
80 		.devid = "imx21-i2c",
81 		.id = 2,
82 		.iobase = MX51_HSI2C_DMA_BASE_ADDR,
83 		.iosize = SZ_16K,
84 		.irq = MX51_INT_HS_I2C,
85 	},
86 };
87 #endif /* ifdef CONFIG_SOC_IMX51 */
88 
89 #ifdef CONFIG_SOC_IMX53
90 const struct imx_imx_i2c_data imx53_imx_i2c_data[] __initconst = {
91 #define imx53_imx_i2c_data_entry(_id, _hwid)				\
92 	imx_imx_i2c_data_entry(MX53, "imx21-i2c", _id, _hwid, SZ_4K)
93 	imx53_imx_i2c_data_entry(0, 1),
94 	imx53_imx_i2c_data_entry(1, 2),
95 	imx53_imx_i2c_data_entry(2, 3),
96 };
97 #endif /* ifdef CONFIG_SOC_IMX53 */
98 
imx_add_imx_i2c(const struct imx_imx_i2c_data * data,const struct imxi2c_platform_data * pdata)99 struct platform_device *__init imx_add_imx_i2c(
100 		const struct imx_imx_i2c_data *data,
101 		const struct imxi2c_platform_data *pdata)
102 {
103 	struct resource res[] = {
104 		{
105 			.start = data->iobase,
106 			.end = data->iobase + data->iosize - 1,
107 			.flags = IORESOURCE_MEM,
108 		}, {
109 			.start = data->irq,
110 			.end = data->irq,
111 			.flags = IORESOURCE_IRQ,
112 		},
113 	};
114 
115 	return imx_add_platform_device(data->devid, data->id,
116 			res, ARRAY_SIZE(res),
117 			pdata, sizeof(*pdata));
118 }
119