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 | */ |
Shawn Guo | 50f2de6 | 2012-09-14 14:14:45 +0800 | [diff] [blame] | 9 | #include "../hardware.h" |
Shawn Guo | e0557c0 | 2012-09-13 15:51:15 +0800 | [diff] [blame] | 10 | #include "devices-common.h" |
Uwe Kleine-König | 99a754d | 2010-06-16 14:37:51 +0200 | [diff] [blame] | 11 | |
Shawn Guo | 5bdfba2 | 2012-09-14 15:19:00 +0800 | [diff] [blame] | 12 | #define imx_imx_i2c_data_entry_single(soc, _devid, _id, _hwid, _size) \ |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 13 | { \ |
Shawn Guo | 5bdfba2 | 2012-09-14 15:19:00 +0800 | [diff] [blame] | 14 | .devid = _devid, \ |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 15 | .id = _id, \ |
| 16 | .iobase = soc ## _I2C ## _hwid ## _BASE_ADDR, \ |
| 17 | .iosize = _size, \ |
| 18 | .irq = soc ## _INT_I2C ## _hwid, \ |
| 19 | } |
| 20 | |
Shawn Guo | 5bdfba2 | 2012-09-14 15:19:00 +0800 | [diff] [blame] | 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) |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 23 | |
| 24 | #ifdef CONFIG_SOC_IMX1 |
| 25 | const struct imx_imx_i2c_data imx1_imx_i2c_data __initconst = |
Shawn Guo | 5bdfba2 | 2012-09-14 15:19:00 +0800 | [diff] [blame] | 26 | imx_imx_i2c_data_entry_single(MX1, "imx1-i2c", 0, , SZ_4K); |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 27 | #endif /* ifdef CONFIG_SOC_IMX1 */ |
| 28 | |
| 29 | #ifdef CONFIG_SOC_IMX21 |
| 30 | const struct imx_imx_i2c_data imx21_imx_i2c_data __initconst = |
Shawn Guo | 5bdfba2 | 2012-09-14 15:19:00 +0800 | [diff] [blame] | 31 | imx_imx_i2c_data_entry_single(MX21, "imx21-i2c", 0, , SZ_4K); |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 32 | #endif /* ifdef CONFIG_SOC_IMX21 */ |
| 33 | |
Uwe Kleine-König | 972cc48 | 2010-11-11 18:35:01 +0100 | [diff] [blame] | 34 | #ifdef CONFIG_SOC_IMX25 |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 35 | const struct imx_imx_i2c_data imx25_imx_i2c_data[] __initconst = { |
| 36 | #define imx25_imx_i2c_data_entry(_id, _hwid) \ |
Shawn Guo | 5bdfba2 | 2012-09-14 15:19:00 +0800 | [diff] [blame] | 37 | imx_imx_i2c_data_entry(MX25, "imx21-i2c", _id, _hwid, SZ_16K) |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 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 | }; |
Uwe Kleine-König | 972cc48 | 2010-11-11 18:35:01 +0100 | [diff] [blame] | 42 | #endif /* ifdef CONFIG_SOC_IMX25 */ |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 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) \ |
Shawn Guo | 5bdfba2 | 2012-09-14 15:19:00 +0800 | [diff] [blame] | 47 | imx_imx_i2c_data_entry(MX27, "imx21-i2c", _id, _hwid, SZ_4K) |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 48 | 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önig | a528bc8 | 2010-11-12 10:11:42 +0100 | [diff] [blame] | 53 | #ifdef CONFIG_SOC_IMX31 |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 54 | const struct imx_imx_i2c_data imx31_imx_i2c_data[] __initconst = { |
| 55 | #define imx31_imx_i2c_data_entry(_id, _hwid) \ |
Shawn Guo | 5bdfba2 | 2012-09-14 15:19:00 +0800 | [diff] [blame] | 56 | imx_imx_i2c_data_entry(MX31, "imx21-i2c", _id, _hwid, SZ_4K) |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 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 | }; |
Uwe Kleine-König | a528bc8 | 2010-11-12 10:11:42 +0100 | [diff] [blame] | 61 | #endif /* ifdef CONFIG_SOC_IMX31 */ |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 62 | |
Uwe Kleine-König | a528bc8 | 2010-11-12 10:11:42 +0100 | [diff] [blame] | 63 | #ifdef CONFIG_SOC_IMX35 |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 64 | const struct imx_imx_i2c_data imx35_imx_i2c_data[] __initconst = { |
| 65 | #define imx35_imx_i2c_data_entry(_id, _hwid) \ |
Shawn Guo | 5bdfba2 | 2012-09-14 15:19:00 +0800 | [diff] [blame] | 66 | imx_imx_i2c_data_entry(MX35, "imx21-i2c", _id, _hwid, SZ_4K) |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 67 | imx35_imx_i2c_data_entry(0, 1), |
| 68 | imx35_imx_i2c_data_entry(1, 2), |
Marc Kleine-Budde | 6136a6d | 2010-10-13 10:00:10 +0200 | [diff] [blame] | 69 | imx35_imx_i2c_data_entry(2, 3), |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 70 | }; |
Uwe Kleine-König | a528bc8 | 2010-11-12 10:11:42 +0100 | [diff] [blame] | 71 | #endif /* ifdef CONFIG_SOC_IMX35 */ |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 72 | |
Fabio Estevam | d94ed12 | 2010-11-26 12:25:58 -0200 | [diff] [blame] | 73 | #ifdef CONFIG_SOC_IMX51 |
Uwe Kleine-König | 44505c0 | 2010-09-30 16:44:53 +0200 | [diff] [blame] | 74 | const struct imx_imx_i2c_data imx51_imx_i2c_data[] __initconst = { |
| 75 | #define imx51_imx_i2c_data_entry(_id, _hwid) \ |
Shawn Guo | 5bdfba2 | 2012-09-14 15:19:00 +0800 | [diff] [blame] | 76 | imx_imx_i2c_data_entry(MX51, "imx21-i2c", _id, _hwid, SZ_4K) |
Uwe Kleine-König | 44505c0 | 2010-09-30 16:44:53 +0200 | [diff] [blame] | 77 | imx51_imx_i2c_data_entry(0, 1), |
| 78 | imx51_imx_i2c_data_entry(1, 2), |
Uwe Kleine-König | f268885 | 2011-08-01 09:07:54 +0200 | [diff] [blame] | 79 | { |
Shawn Guo | 5bdfba2 | 2012-09-14 15:19:00 +0800 | [diff] [blame] | 80 | .devid = "imx21-i2c", |
Uwe Kleine-König | f268885 | 2011-08-01 09:07:54 +0200 | [diff] [blame] | 81 | .id = 2, |
| 82 | .iobase = MX51_HSI2C_DMA_BASE_ADDR, |
| 83 | .iosize = SZ_16K, |
| 84 | .irq = MX51_INT_HS_I2C, |
| 85 | }, |
Uwe Kleine-König | 44505c0 | 2010-09-30 16:44:53 +0200 | [diff] [blame] | 86 | }; |
Fabio Estevam | d94ed12 | 2010-11-26 12:25:58 -0200 | [diff] [blame] | 87 | #endif /* ifdef CONFIG_SOC_IMX51 */ |
Uwe Kleine-König | 44505c0 | 2010-09-30 16:44:53 +0200 | [diff] [blame] | 88 | |
Yong Shen | 0d7671e | 2011-01-07 12:25:33 +0800 | [diff] [blame] | 89 | #ifdef CONFIG_SOC_IMX53 |
| 90 | const struct imx_imx_i2c_data imx53_imx_i2c_data[] __initconst = { |
| 91 | #define imx53_imx_i2c_data_entry(_id, _hwid) \ |
Shawn Guo | 5bdfba2 | 2012-09-14 15:19:00 +0800 | [diff] [blame] | 92 | imx_imx_i2c_data_entry(MX53, "imx21-i2c", _id, _hwid, SZ_4K) |
Yong Shen | 0d7671e | 2011-01-07 12:25:33 +0800 | [diff] [blame] | 93 | imx53_imx_i2c_data_entry(0, 1), |
| 94 | imx53_imx_i2c_data_entry(1, 2), |
Andre Silva | b6a1447 | 2011-06-22 16:33:04 -0300 | [diff] [blame] | 95 | imx53_imx_i2c_data_entry(2, 3), |
Yong Shen | 0d7671e | 2011-01-07 12:25:33 +0800 | [diff] [blame] | 96 | }; |
Andre Silva | b6a1447 | 2011-06-22 16:33:04 -0300 | [diff] [blame] | 97 | #endif /* ifdef CONFIG_SOC_IMX53 */ |
Yong Shen | 0d7671e | 2011-01-07 12:25:33 +0800 | [diff] [blame] | 98 | |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 99 | struct platform_device *__init imx_add_imx_i2c( |
| 100 | const struct imx_imx_i2c_data *data, |
Uwe Kleine-König | 99a754d | 2010-06-16 14:37:51 +0200 | [diff] [blame] | 101 | const struct imxi2c_platform_data *pdata) |
| 102 | { |
| 103 | struct resource res[] = { |
| 104 | { |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 105 | .start = data->iobase, |
| 106 | .end = data->iobase + data->iosize - 1, |
Uwe Kleine-König | 99a754d | 2010-06-16 14:37:51 +0200 | [diff] [blame] | 107 | .flags = IORESOURCE_MEM, |
| 108 | }, { |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 109 | .start = data->irq, |
| 110 | .end = data->irq, |
Uwe Kleine-König | 99a754d | 2010-06-16 14:37:51 +0200 | [diff] [blame] | 111 | .flags = IORESOURCE_IRQ, |
| 112 | }, |
| 113 | }; |
| 114 | |
Shawn Guo | 5bdfba2 | 2012-09-14 15:19:00 +0800 | [diff] [blame] | 115 | return imx_add_platform_device(data->devid, data->id, |
Uwe Kleine-König | 64de5ec | 2010-09-21 12:13:34 +0200 | [diff] [blame] | 116 | res, ARRAY_SIZE(res), |
Uwe Kleine-König | 99a754d | 2010-06-16 14:37:51 +0200 | [diff] [blame] | 117 | pdata, sizeof(*pdata)); |
| 118 | } |