diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2009-01-28 08:06:20 -0500 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2009-03-13 05:34:13 -0400 |
commit | b8b19b0d1c2d9ede8a3f8b9f609fd66cf5ede057 (patch) | |
tree | 72c5f213fd1c7488de88e3d9b4a18e173dd7c7dc | |
parent | a4e9a65a1f90e94eca3af1a69b42d039054ef9de (diff) |
[ARM] mx1ads: add I2C support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | arch/arm/mach-mx1/mx1ads.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/arch/arm/mach-mx1/mx1ads.c b/arch/arm/mach-mx1/mx1ads.c index 09dc77bb4812..89738fe576b1 100644 --- a/arch/arm/mach-mx1/mx1ads.c +++ b/arch/arm/mach-mx1/mx1ads.c | |||
@@ -16,6 +16,8 @@ | |||
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/mtd/physmap.h> | 18 | #include <linux/mtd/physmap.h> |
19 | #include <linux/i2c.h> | ||
20 | #include <linux/i2c/pcf857x.h> | ||
19 | 21 | ||
20 | #include <asm/mach-types.h> | 22 | #include <asm/mach-types.h> |
21 | #include <asm/mach/arch.h> | 23 | #include <asm/mach/arch.h> |
@@ -24,6 +26,10 @@ | |||
24 | #include <mach/hardware.h> | 26 | #include <mach/hardware.h> |
25 | #include <mach/common.h> | 27 | #include <mach/common.h> |
26 | #include <mach/imx-uart.h> | 28 | #include <mach/imx-uart.h> |
29 | #include <mach/irqs.h> | ||
30 | #ifdef CONFIG_I2C_IMX | ||
31 | #include <mach/i2c.h> | ||
32 | #endif | ||
27 | #include <mach/iomux.h> | 33 | #include <mach/iomux.h> |
28 | #include "devices.h" | 34 | #include "devices.h" |
29 | 35 | ||
@@ -104,6 +110,55 @@ static struct platform_device flash_device = { | |||
104 | }; | 110 | }; |
105 | 111 | ||
106 | /* | 112 | /* |
113 | * I2C | ||
114 | */ | ||
115 | |||
116 | #ifdef CONFIG_I2C_IMX | ||
117 | static int i2c_pins[] = { | ||
118 | PA15_PF_I2C_SDA, | ||
119 | PA16_PF_I2C_SCL, | ||
120 | }; | ||
121 | |||
122 | static int i2c_init(struct device *dev) | ||
123 | { | ||
124 | return mxc_gpio_setup_multiple_pins(i2c_pins, | ||
125 | ARRAY_SIZE(i2c_pins), "I2C"); | ||
126 | } | ||
127 | |||
128 | static void i2c_exit(struct device *dev) | ||
129 | { | ||
130 | mxc_gpio_release_multiple_pins(i2c_pins, | ||
131 | ARRAY_SIZE(i2c_pins)); | ||
132 | } | ||
133 | |||
134 | static struct pcf857x_platform_data pcf857x_data[] = { | ||
135 | { | ||
136 | .gpio_base = 4 * 32, | ||
137 | }, { | ||
138 | .gpio_base = 4 * 32 + 16, | ||
139 | } | ||
140 | }; | ||
141 | |||
142 | static struct imxi2c_platform_data mx1ads_i2c_data = { | ||
143 | .bitrate = 100000, | ||
144 | .init = i2c_init, | ||
145 | .exit = i2c_exit, | ||
146 | }; | ||
147 | |||
148 | static struct i2c_board_info mx1ads_i2c_devices[] = { | ||
149 | { | ||
150 | I2C_BOARD_INFO("pcf857x", 0x22), | ||
151 | .type = "pcf8575", | ||
152 | .platform_data = &pcf857x_data[0], | ||
153 | }, { | ||
154 | I2C_BOARD_INFO("pcf857x", 0x24), | ||
155 | .type = "pcf8575", | ||
156 | .platform_data = &pcf857x_data[1], | ||
157 | }, | ||
158 | }; | ||
159 | #endif | ||
160 | |||
161 | /* | ||
107 | * Board init | 162 | * Board init |
108 | */ | 163 | */ |
109 | static void __init mx1ads_init(void) | 164 | static void __init mx1ads_init(void) |
@@ -114,6 +169,14 @@ static void __init mx1ads_init(void) | |||
114 | 169 | ||
115 | /* Physmap flash */ | 170 | /* Physmap flash */ |
116 | mxc_register_device(&flash_device, &mx1ads_flash_data); | 171 | mxc_register_device(&flash_device, &mx1ads_flash_data); |
172 | |||
173 | /* I2C */ | ||
174 | #ifdef CONFIG_I2C_IMX | ||
175 | i2c_register_board_info(0, mx1ads_i2c_devices, | ||
176 | ARRAY_SIZE(mx1ads_i2c_devices)); | ||
177 | |||
178 | mxc_register_device(&imx_i2c_device, &mx1ads_i2c_data); | ||
179 | #endif | ||
117 | } | 180 | } |
118 | 181 | ||
119 | static void __init mx1ads_timer_init(void) | 182 | static void __init mx1ads_timer_init(void) |