• 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_IMX27
35 const struct imx_imx_i2c_data imx27_imx_i2c_data[] __initconst = {
36 #define imx27_imx_i2c_data_entry(_id, _hwid)				\
37 	imx_imx_i2c_data_entry(MX27, "imx21-i2c", _id, _hwid, SZ_4K)
38 	imx27_imx_i2c_data_entry(0, 1),
39 	imx27_imx_i2c_data_entry(1, 2),
40 };
41 #endif /* ifdef CONFIG_SOC_IMX27 */
42 
43 #ifdef CONFIG_SOC_IMX31
44 const struct imx_imx_i2c_data imx31_imx_i2c_data[] __initconst = {
45 #define imx31_imx_i2c_data_entry(_id, _hwid)				\
46 	imx_imx_i2c_data_entry(MX31, "imx21-i2c", _id, _hwid, SZ_4K)
47 	imx31_imx_i2c_data_entry(0, 1),
48 	imx31_imx_i2c_data_entry(1, 2),
49 	imx31_imx_i2c_data_entry(2, 3),
50 };
51 #endif /* ifdef CONFIG_SOC_IMX31 */
52 
53 #ifdef CONFIG_SOC_IMX35
54 const struct imx_imx_i2c_data imx35_imx_i2c_data[] __initconst = {
55 #define imx35_imx_i2c_data_entry(_id, _hwid)				\
56 	imx_imx_i2c_data_entry(MX35, "imx21-i2c", _id, _hwid, SZ_4K)
57 	imx35_imx_i2c_data_entry(0, 1),
58 	imx35_imx_i2c_data_entry(1, 2),
59 	imx35_imx_i2c_data_entry(2, 3),
60 };
61 #endif /* ifdef CONFIG_SOC_IMX35 */
62 
imx_add_imx_i2c(const struct imx_imx_i2c_data * data,const struct imxi2c_platform_data * pdata)63 struct platform_device *__init imx_add_imx_i2c(
64 		const struct imx_imx_i2c_data *data,
65 		const struct imxi2c_platform_data *pdata)
66 {
67 	struct resource res[] = {
68 		{
69 			.start = data->iobase,
70 			.end = data->iobase + data->iosize - 1,
71 			.flags = IORESOURCE_MEM,
72 		}, {
73 			.start = data->irq,
74 			.end = data->irq,
75 			.flags = IORESOURCE_IRQ,
76 		},
77 	};
78 
79 	return imx_add_platform_device(data->devid, data->id,
80 			res, ARRAY_SIZE(res),
81 			pdata, sizeof(*pdata));
82 }
83