blob: ab9670b96c8a7b7e921e64be46e3d3aa4fa0da18 [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
33#ifdef CONFIG_ARCH_MX25
34const 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};
41#endif /* ifdef CONFIG_ARCH_MX25 */
42
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
52#ifdef CONFIG_ARCH_MX31
53const 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};
60#endif /* ifdef CONFIG_ARCH_MX31 */
61
62#ifdef CONFIG_ARCH_MX35
63const 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),
68};
69#endif /* ifdef CONFIG_ARCH_MX35 */
70
71struct platform_device *__init imx_add_imx_i2c(
72 const struct imx_imx_i2c_data *data,
Uwe Kleine-König99a754d2010-06-16 14:37:51 +020073 const struct imxi2c_platform_data *pdata)
74{
75 struct resource res[] = {
76 {
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020077 .start = data->iobase,
78 .end = data->iobase + data->iosize - 1,
Uwe Kleine-König99a754d2010-06-16 14:37:51 +020079 .flags = IORESOURCE_MEM,
80 }, {
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020081 .start = data->irq,
82 .end = data->irq,
Uwe Kleine-König99a754d2010-06-16 14:37:51 +020083 .flags = IORESOURCE_IRQ,
84 },
85 };
86
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020087 return imx_add_platform_device("imx-i2c", data->id,
88 res, ARRAY_SIZE(res),
Uwe Kleine-König99a754d2010-06-16 14:37:51 +020089 pdata, sizeof(*pdata));
90}