blob: 57d342e85c2fa5621f334c26d667beacb286f9a6 [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 */
Shawn Guo50f2de62012-09-14 14:14:45 +08009#include "../hardware.h"
Shawn Guoe0557c02012-09-13 15:51:15 +080010#include "devices-common.h"
Uwe Kleine-König99a754d2010-06-16 14:37:51 +020011
Shawn Guo5bdfba22012-09-14 15:19:00 +080012#define imx_imx_i2c_data_entry_single(soc, _devid, _id, _hwid, _size) \
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020013 { \
Shawn Guo5bdfba22012-09-14 15:19:00 +080014 .devid = _devid, \
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020015 .id = _id, \
16 .iobase = soc ## _I2C ## _hwid ## _BASE_ADDR, \
17 .iosize = _size, \
18 .irq = soc ## _INT_I2C ## _hwid, \
19 }
20
Shawn Guo5bdfba22012-09-14 15:19:00 +080021#define imx_imx_i2c_data_entry(soc, _devid, _id, _hwid, _size) \
22 [_id] = imx_imx_i2c_data_entry_single(soc, _devid, _id, _hwid, _size)
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020023
24#ifdef CONFIG_SOC_IMX1
25const struct imx_imx_i2c_data imx1_imx_i2c_data __initconst =
Shawn Guo5bdfba22012-09-14 15:19:00 +080026 imx_imx_i2c_data_entry_single(MX1, "imx1-i2c", 0, , SZ_4K);
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020027#endif /* ifdef CONFIG_SOC_IMX1 */
28
29#ifdef CONFIG_SOC_IMX21
30const struct imx_imx_i2c_data imx21_imx_i2c_data __initconst =
Shawn Guo5bdfba22012-09-14 15:19:00 +080031 imx_imx_i2c_data_entry_single(MX21, "imx21-i2c", 0, , SZ_4K);
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020032#endif /* ifdef CONFIG_SOC_IMX21 */
33
Uwe Kleine-König972cc482010-11-11 18:35:01 +010034#ifdef CONFIG_SOC_IMX25
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020035const struct imx_imx_i2c_data imx25_imx_i2c_data[] __initconst = {
36#define imx25_imx_i2c_data_entry(_id, _hwid) \
Shawn Guo5bdfba22012-09-14 15:19:00 +080037 imx_imx_i2c_data_entry(MX25, "imx21-i2c", _id, _hwid, SZ_16K)
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020038 imx25_imx_i2c_data_entry(0, 1),
39 imx25_imx_i2c_data_entry(1, 2),
40 imx25_imx_i2c_data_entry(2, 3),
41};
Uwe Kleine-König972cc482010-11-11 18:35:01 +010042#endif /* ifdef CONFIG_SOC_IMX25 */
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020043
44#ifdef CONFIG_SOC_IMX27
45const struct imx_imx_i2c_data imx27_imx_i2c_data[] __initconst = {
46#define imx27_imx_i2c_data_entry(_id, _hwid) \
Shawn Guo5bdfba22012-09-14 15:19:00 +080047 imx_imx_i2c_data_entry(MX27, "imx21-i2c", _id, _hwid, SZ_4K)
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020048 imx27_imx_i2c_data_entry(0, 1),
49 imx27_imx_i2c_data_entry(1, 2),
50};
51#endif /* ifdef CONFIG_SOC_IMX27 */
52
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +010053#ifdef CONFIG_SOC_IMX31
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020054const struct imx_imx_i2c_data imx31_imx_i2c_data[] __initconst = {
55#define imx31_imx_i2c_data_entry(_id, _hwid) \
Shawn Guo5bdfba22012-09-14 15:19:00 +080056 imx_imx_i2c_data_entry(MX31, "imx21-i2c", _id, _hwid, SZ_4K)
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020057 imx31_imx_i2c_data_entry(0, 1),
58 imx31_imx_i2c_data_entry(1, 2),
59 imx31_imx_i2c_data_entry(2, 3),
60};
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +010061#endif /* ifdef CONFIG_SOC_IMX31 */
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020062
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +010063#ifdef CONFIG_SOC_IMX35
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020064const struct imx_imx_i2c_data imx35_imx_i2c_data[] __initconst = {
65#define imx35_imx_i2c_data_entry(_id, _hwid) \
Shawn Guo5bdfba22012-09-14 15:19:00 +080066 imx_imx_i2c_data_entry(MX35, "imx21-i2c", _id, _hwid, SZ_4K)
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020067 imx35_imx_i2c_data_entry(0, 1),
68 imx35_imx_i2c_data_entry(1, 2),
Marc Kleine-Budde6136a6d2010-10-13 10:00:10 +020069 imx35_imx_i2c_data_entry(2, 3),
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020070};
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +010071#endif /* ifdef CONFIG_SOC_IMX35 */
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020072
Fabio Estevamd94ed122010-11-26 12:25:58 -020073#ifdef CONFIG_SOC_IMX51
Uwe Kleine-König44505c02010-09-30 16:44:53 +020074const struct imx_imx_i2c_data imx51_imx_i2c_data[] __initconst = {
75#define imx51_imx_i2c_data_entry(_id, _hwid) \
Shawn Guo5bdfba22012-09-14 15:19:00 +080076 imx_imx_i2c_data_entry(MX51, "imx21-i2c", _id, _hwid, SZ_4K)
Uwe Kleine-König44505c02010-09-30 16:44:53 +020077 imx51_imx_i2c_data_entry(0, 1),
78 imx51_imx_i2c_data_entry(1, 2),
Uwe Kleine-Königf2688852011-08-01 09:07:54 +020079 {
Shawn Guo5bdfba22012-09-14 15:19:00 +080080 .devid = "imx21-i2c",
Uwe Kleine-Königf2688852011-08-01 09:07:54 +020081 .id = 2,
82 .iobase = MX51_HSI2C_DMA_BASE_ADDR,
83 .iosize = SZ_16K,
84 .irq = MX51_INT_HS_I2C,
85 },
Uwe Kleine-König44505c02010-09-30 16:44:53 +020086};
Fabio Estevamd94ed122010-11-26 12:25:58 -020087#endif /* ifdef CONFIG_SOC_IMX51 */
Uwe Kleine-König44505c02010-09-30 16:44:53 +020088
Yong Shen0d7671e2011-01-07 12:25:33 +080089#ifdef CONFIG_SOC_IMX53
90const struct imx_imx_i2c_data imx53_imx_i2c_data[] __initconst = {
91#define imx53_imx_i2c_data_entry(_id, _hwid) \
Shawn Guo5bdfba22012-09-14 15:19:00 +080092 imx_imx_i2c_data_entry(MX53, "imx21-i2c", _id, _hwid, SZ_4K)
Yong Shen0d7671e2011-01-07 12:25:33 +080093 imx53_imx_i2c_data_entry(0, 1),
94 imx53_imx_i2c_data_entry(1, 2),
Andre Silvab6a14472011-06-22 16:33:04 -030095 imx53_imx_i2c_data_entry(2, 3),
Yong Shen0d7671e2011-01-07 12:25:33 +080096};
Andre Silvab6a14472011-06-22 16:33:04 -030097#endif /* ifdef CONFIG_SOC_IMX53 */
Yong Shen0d7671e2011-01-07 12:25:33 +080098
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +020099struct platform_device *__init imx_add_imx_i2c(
100 const struct imx_imx_i2c_data *data,
Uwe Kleine-König99a754d2010-06-16 14:37:51 +0200101 const struct imxi2c_platform_data *pdata)
102{
103 struct resource res[] = {
104 {
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +0200105 .start = data->iobase,
106 .end = data->iobase + data->iosize - 1,
Uwe Kleine-König99a754d2010-06-16 14:37:51 +0200107 .flags = IORESOURCE_MEM,
108 }, {
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +0200109 .start = data->irq,
110 .end = data->irq,
Uwe Kleine-König99a754d2010-06-16 14:37:51 +0200111 .flags = IORESOURCE_IRQ,
112 },
113 };
114
Shawn Guo5bdfba22012-09-14 15:19:00 +0800115 return imx_add_platform_device(data->devid, data->id,
Uwe Kleine-König64de5ec2010-09-21 12:13:34 +0200116 res, ARRAY_SIZE(res),
Uwe Kleine-König99a754d2010-06-16 14:37:51 +0200117 pdata, sizeof(*pdata));
118}