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
imx_add_imx_i2c(const struct imx_imx_i2c_data * data,const struct imxi2c_platform_data * pdata)73 struct platform_device *__init imx_add_imx_i2c(
74 const struct imx_imx_i2c_data *data,
75 const struct imxi2c_platform_data *pdata)
76 {
77 struct resource res[] = {
78 {
79 .start = data->iobase,
80 .end = data->iobase + data->iosize - 1,
81 .flags = IORESOURCE_MEM,
82 }, {
83 .start = data->irq,
84 .end = data->irq,
85 .flags = IORESOURCE_IRQ,
86 },
87 };
88
89 return imx_add_platform_device(data->devid, data->id,
90 res, ARRAY_SIZE(res),
91 pdata, sizeof(*pdata));
92 }
93