blob: 19ad580c0be348fb16d8bf93e3eb664b6ef1d431 [file] [log] [blame]
Uwe Kleine-König99a754d2010-06-16 14:37:51 +02001/*
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 */
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +02009#include <mach/hardware.h>
Uwe Kleine-König99a754d2010-06-16 14:37:51 +020010#include <mach/devices-common.h>
11
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020012#define imx_imx_i2c_data_entry_single(soc, _id, _hwid, _size) \
13 { \
14 .id = _id, \
15 .iobase = soc ## _I2C ## _hwid ## _BASE_ADDR, \
16 .iosize = _size, \
17 .irq = soc ## _INT_I2C ## _hwid, \
18 }
19
20#define imx_imx_i2c_data_entry(soc, _id, _hwid, _size) \
21 [_id] = imx_imx_i2c_data_entry_single(soc, _id, _hwid, _size)
22
23#ifdef CONFIG_SOC_IMX1
24const struct imx_imx_i2c_data imx1_imx_i2c_data __initconst =
25 imx_imx_i2c_data_entry_single(MX1, 0, , SZ_4K);
26#endif /* ifdef CONFIG_SOC_IMX1 */
27
28#ifdef CONFIG_SOC_IMX21
29const struct imx_imx_i2c_data imx21_imx_i2c_data __initconst =
30 imx_imx_i2c_data_entry_single(MX21, 0, , SZ_4K);
31#endif /* ifdef CONFIG_SOC_IMX21 */
32
Uwe Kleine-König972cc482010-11-11 18:35:01 +010033#ifdef CONFIG_SOC_IMX25
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020034const struct imx_imx_i2c_data imx25_imx_i2c_data[] __initconst = {
35#define imx25_imx_i2c_data_entry(_id, _hwid) \
36 imx_imx_i2c_data_entry(MX25, _id, _hwid, SZ_16K)
37 imx25_imx_i2c_data_entry(0, 1),
38 imx25_imx_i2c_data_entry(1, 2),
39 imx25_imx_i2c_data_entry(2, 3),
40};
Uwe Kleine-König972cc482010-11-11 18:35:01 +010041#endif /* ifdef CONFIG_SOC_IMX25 */
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020042
43#ifdef CONFIG_SOC_IMX27
44const struct imx_imx_i2c_data imx27_imx_i2c_data[] __initconst = {
45#define imx27_imx_i2c_data_entry(_id, _hwid) \
46 imx_imx_i2c_data_entry(MX27, _id, _hwid, SZ_4K)
47 imx27_imx_i2c_data_entry(0, 1),
48 imx27_imx_i2c_data_entry(1, 2),
49};
50#endif /* ifdef CONFIG_SOC_IMX27 */
51
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +010052#ifdef CONFIG_SOC_IMX31
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020053const struct imx_imx_i2c_data imx31_imx_i2c_data[] __initconst = {
54#define imx31_imx_i2c_data_entry(_id, _hwid) \
55 imx_imx_i2c_data_entry(MX31, _id, _hwid, SZ_4K)
56 imx31_imx_i2c_data_entry(0, 1),
57 imx31_imx_i2c_data_entry(1, 2),
58 imx31_imx_i2c_data_entry(2, 3),
59};
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +010060#endif /* ifdef CONFIG_SOC_IMX31 */
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020061
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +010062#ifdef CONFIG_SOC_IMX35
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020063const struct imx_imx_i2c_data imx35_imx_i2c_data[] __initconst = {
64#define imx35_imx_i2c_data_entry(_id, _hwid) \
65 imx_imx_i2c_data_entry(MX35, _id, _hwid, SZ_4K)
66 imx35_imx_i2c_data_entry(0, 1),
67 imx35_imx_i2c_data_entry(1, 2),
Marc Kleine-Budde6136a6d2010-10-13 10:00:10 +020068 imx35_imx_i2c_data_entry(2, 3),
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020069};
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +010070#endif /* ifdef CONFIG_SOC_IMX35 */
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020071
Richard Zhao98b7d552011-01-14 17:48:04 +080072#ifdef CONFIG_SOC_IMX50
73const struct imx_imx_i2c_data imx50_imx_i2c_data[] __initconst = {
74#define imx50_imx_i2c_data_entry(_id, _hwid) \
75 imx_imx_i2c_data_entry(MX50, _id, _hwid, SZ_4K)
76 imx50_imx_i2c_data_entry(0, 1),
77 imx50_imx_i2c_data_entry(1, 2),
78 imx50_imx_i2c_data_entry(2, 3),
79};
80#endif /* ifdef CONFIG_SOC_IMX51 */
81
Fabio Estevamd94ed122010-11-26 12:25:58 -020082#ifdef CONFIG_SOC_IMX51
Uwe Kleine-König44505c02010-09-30 16:44:53 +020083const struct imx_imx_i2c_data imx51_imx_i2c_data[] __initconst = {
84#define imx51_imx_i2c_data_entry(_id, _hwid) \
85 imx_imx_i2c_data_entry(MX51, _id, _hwid, SZ_4K)
86 imx51_imx_i2c_data_entry(0, 1),
87 imx51_imx_i2c_data_entry(1, 2),
Uwe Kleine-Königf2688852011-08-01 09:07:54 +020088 {
89 .id = 2,
90 .iobase = MX51_HSI2C_DMA_BASE_ADDR,
91 .iosize = SZ_16K,
92 .irq = MX51_INT_HS_I2C,
93 },
Uwe Kleine-König44505c02010-09-30 16:44:53 +020094};
Fabio Estevamd94ed122010-11-26 12:25:58 -020095#endif /* ifdef CONFIG_SOC_IMX51 */
Uwe Kleine-König44505c02010-09-30 16:44:53 +020096
Yong Shen0d7671e2011-01-07 12:25:33 +080097#ifdef CONFIG_SOC_IMX53
98const struct imx_imx_i2c_data imx53_imx_i2c_data[] __initconst = {
99#define imx53_imx_i2c_data_entry(_id, _hwid) \
100 imx_imx_i2c_data_entry(MX53, _id, _hwid, SZ_4K)
101 imx53_imx_i2c_data_entry(0, 1),
102 imx53_imx_i2c_data_entry(1, 2),
Andre Silvab6a14472011-06-22 16:33:04 -0300103 imx53_imx_i2c_data_entry(2, 3),
Yong Shen0d7671e2011-01-07 12:25:33 +0800104};
Andre Silvab6a14472011-06-22 16:33:04 -0300105#endif /* ifdef CONFIG_SOC_IMX53 */
Yong Shen0d7671e2011-01-07 12:25:33 +0800106
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +0200107struct platform_device *__init imx_add_imx_i2c(
108 const struct imx_imx_i2c_data *data,
Uwe Kleine-König99a754d2010-06-16 14:37:51 +0200109 const struct imxi2c_platform_data *pdata)
110{
111 struct resource res[] = {
112 {
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +0200113 .start = data->iobase,
114 .end = data->iobase + data->iosize - 1,
Uwe Kleine-König99a754d2010-06-16 14:37:51 +0200115 .flags = IORESOURCE_MEM,
116 }, {
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +0200117 .start = data->irq,
118 .end = data->irq,
Uwe Kleine-König99a754d2010-06-16 14:37:51 +0200119 .flags = IORESOURCE_IRQ,
120 },
121 };
122
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +0200123 return imx_add_platform_device("imx-i2c", data->id,
124 res, ARRAY_SIZE(res),
Uwe Kleine-König99a754d2010-06-16 14:37:51 +0200125 pdata, sizeof(*pdata));
126}