Uwe Kleine-König | 99a754d | 2010-06-16 14:37:51 +0200 | [diff] [blame] | 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 | */ |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 9 | #include <mach/hardware.h> |
Uwe Kleine-König | 99a754d | 2010-06-16 14:37:51 +0200 | [diff] [blame] | 10 | #include <mach/devices-common.h> |
| 11 | |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 12 | #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 |
| 24 | const 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 |
| 29 | const 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önig | 972cc48 | 2010-11-11 18:35:01 +0100 | [diff] [blame] | 33 | #ifdef CONFIG_SOC_IMX25 |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 34 | const 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önig | 972cc48 | 2010-11-11 18:35:01 +0100 | [diff] [blame] | 41 | #endif /* ifdef CONFIG_SOC_IMX25 */ |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 42 | |
| 43 | #ifdef CONFIG_SOC_IMX27 |
| 44 | const 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önig | a528bc8 | 2010-11-12 10:11:42 +0100 | [diff] [blame] | 52 | #ifdef CONFIG_SOC_IMX31 |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 53 | const 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önig | a528bc8 | 2010-11-12 10:11:42 +0100 | [diff] [blame] | 60 | #endif /* ifdef CONFIG_SOC_IMX31 */ |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 61 | |
Uwe Kleine-König | a528bc8 | 2010-11-12 10:11:42 +0100 | [diff] [blame] | 62 | #ifdef CONFIG_SOC_IMX35 |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 63 | const 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-Budde | 6136a6d | 2010-10-13 10:00:10 +0200 | [diff] [blame] | 68 | imx35_imx_i2c_data_entry(2, 3), |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 69 | }; |
Uwe Kleine-König | a528bc8 | 2010-11-12 10:11:42 +0100 | [diff] [blame] | 70 | #endif /* ifdef CONFIG_SOC_IMX35 */ |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 71 | |
Richard Zhao | 98b7d55 | 2011-01-14 17:48:04 +0800 | [diff] [blame] | 72 | #ifdef CONFIG_SOC_IMX50 |
| 73 | const 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 Estevam | d94ed12 | 2010-11-26 12:25:58 -0200 | [diff] [blame] | 82 | #ifdef CONFIG_SOC_IMX51 |
Uwe Kleine-König | 44505c0 | 2010-09-30 16:44:53 +0200 | [diff] [blame] | 83 | const 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), |
| 88 | }; |
Fabio Estevam | d94ed12 | 2010-11-26 12:25:58 -0200 | [diff] [blame] | 89 | #endif /* ifdef CONFIG_SOC_IMX51 */ |
Uwe Kleine-König | 44505c0 | 2010-09-30 16:44:53 +0200 | [diff] [blame] | 90 | |
Yong Shen | 0d7671e | 2011-01-07 12:25:33 +0800 | [diff] [blame] | 91 | #ifdef CONFIG_SOC_IMX53 |
| 92 | const struct imx_imx_i2c_data imx53_imx_i2c_data[] __initconst = { |
| 93 | #define imx53_imx_i2c_data_entry(_id, _hwid) \ |
| 94 | imx_imx_i2c_data_entry(MX53, _id, _hwid, SZ_4K) |
| 95 | imx53_imx_i2c_data_entry(0, 1), |
| 96 | imx53_imx_i2c_data_entry(1, 2), |
Andre Silva | b6a1447 | 2011-06-22 16:33:04 -0300 | [diff] [blame] | 97 | imx53_imx_i2c_data_entry(2, 3), |
Yong Shen | 0d7671e | 2011-01-07 12:25:33 +0800 | [diff] [blame] | 98 | }; |
Andre Silva | b6a1447 | 2011-06-22 16:33:04 -0300 | [diff] [blame] | 99 | #endif /* ifdef CONFIG_SOC_IMX53 */ |
Yong Shen | 0d7671e | 2011-01-07 12:25:33 +0800 | [diff] [blame] | 100 | |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 101 | struct platform_device *__init imx_add_imx_i2c( |
| 102 | const struct imx_imx_i2c_data *data, |
Uwe Kleine-König | 99a754d | 2010-06-16 14:37:51 +0200 | [diff] [blame] | 103 | const struct imxi2c_platform_data *pdata) |
| 104 | { |
| 105 | struct resource res[] = { |
| 106 | { |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 107 | .start = data->iobase, |
| 108 | .end = data->iobase + data->iosize - 1, |
Uwe Kleine-König | 99a754d | 2010-06-16 14:37:51 +0200 | [diff] [blame] | 109 | .flags = IORESOURCE_MEM, |
| 110 | }, { |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 111 | .start = data->irq, |
| 112 | .end = data->irq, |
Uwe Kleine-König | 99a754d | 2010-06-16 14:37:51 +0200 | [diff] [blame] | 113 | .flags = IORESOURCE_IRQ, |
| 114 | }, |
| 115 | }; |
| 116 | |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 117 | return imx_add_platform_device("imx-i2c", data->id, |
| 118 | res, ARRAY_SIZE(res), |
Uwe Kleine-König | 99a754d | 2010-06-16 14:37:51 +0200 | [diff] [blame] | 119 | pdata, sizeof(*pdata)); |
| 120 | } |