diff options
author | David Daney <ddaney@caviumnetworks.com> | 2010-01-07 16:23:41 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2010-02-27 06:53:04 -0500 |
commit | f41c3c1b3ed53440b37445712f8e1048a39d7001 (patch) | |
tree | c737d70385a32aea9de6a2d1e3b9a088c4bbe63f | |
parent | d38760ccdf879a8648be53488227bf7fe597792d (diff) |
MIPS: Octeon: Add I2C platform device.
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
To: linux-mips@linux-mips.org
To: linux-i2c@vger.kernel.org
To: ben-linux@fluff.org
To: khali@linux-fr.org
Cc: Rade Bozic <rade.bozic.ext@nsn.com>
Patchwork: http://patchwork.linux-mips.org/patch/847/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/cavium-octeon/octeon-platform.c | 72 | ||||
-rw-r--r-- | arch/mips/include/asm/octeon/octeon.h | 5 |
2 files changed, 77 insertions, 0 deletions
diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c index cfdb4c2ac5c3..784c1c874018 100644 --- a/arch/mips/cavium-octeon/octeon-platform.c +++ b/arch/mips/cavium-octeon/octeon-platform.c | |||
@@ -159,6 +159,78 @@ out: | |||
159 | } | 159 | } |
160 | device_initcall(octeon_rng_device_init); | 160 | device_initcall(octeon_rng_device_init); |
161 | 161 | ||
162 | |||
163 | #define OCTEON_I2C_IO_BASE 0x1180000001000ull | ||
164 | #define OCTEON_I2C_IO_UNIT_OFFSET 0x200 | ||
165 | |||
166 | static struct octeon_i2c_data octeon_i2c_data[2]; | ||
167 | |||
168 | static int __init octeon_i2c_device_init(void) | ||
169 | { | ||
170 | struct platform_device *pd; | ||
171 | int ret = 0; | ||
172 | int port, num_ports; | ||
173 | |||
174 | struct resource i2c_resources[] = { | ||
175 | { | ||
176 | .flags = IORESOURCE_MEM, | ||
177 | }, { | ||
178 | .flags = IORESOURCE_IRQ, | ||
179 | } | ||
180 | }; | ||
181 | |||
182 | if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX)) | ||
183 | num_ports = 2; | ||
184 | else | ||
185 | num_ports = 1; | ||
186 | |||
187 | for (port = 0; port < num_ports; port++) { | ||
188 | octeon_i2c_data[port].sys_freq = octeon_get_clock_rate(); | ||
189 | /*FIXME: should be examined. At the moment is set for 100Khz */ | ||
190 | octeon_i2c_data[port].i2c_freq = 100000; | ||
191 | |||
192 | pd = platform_device_alloc("i2c-octeon", port); | ||
193 | if (!pd) { | ||
194 | ret = -ENOMEM; | ||
195 | goto out; | ||
196 | } | ||
197 | |||
198 | pd->dev.platform_data = octeon_i2c_data + port; | ||
199 | |||
200 | i2c_resources[0].start = | ||
201 | OCTEON_I2C_IO_BASE + (port * OCTEON_I2C_IO_UNIT_OFFSET); | ||
202 | i2c_resources[0].end = i2c_resources[0].start + 0x1f; | ||
203 | switch (port) { | ||
204 | case 0: | ||
205 | i2c_resources[1].start = OCTEON_IRQ_TWSI; | ||
206 | i2c_resources[1].end = OCTEON_IRQ_TWSI; | ||
207 | break; | ||
208 | case 1: | ||
209 | i2c_resources[1].start = OCTEON_IRQ_TWSI2; | ||
210 | i2c_resources[1].end = OCTEON_IRQ_TWSI2; | ||
211 | break; | ||
212 | default: | ||
213 | BUG(); | ||
214 | } | ||
215 | |||
216 | ret = platform_device_add_resources(pd, | ||
217 | i2c_resources, | ||
218 | ARRAY_SIZE(i2c_resources)); | ||
219 | if (ret) | ||
220 | goto fail; | ||
221 | |||
222 | ret = platform_device_add(pd); | ||
223 | if (ret) | ||
224 | goto fail; | ||
225 | } | ||
226 | return ret; | ||
227 | fail: | ||
228 | platform_device_put(pd); | ||
229 | out: | ||
230 | return ret; | ||
231 | } | ||
232 | device_initcall(octeon_i2c_device_init); | ||
233 | |||
162 | /* Octeon SMI/MDIO interface. */ | 234 | /* Octeon SMI/MDIO interface. */ |
163 | static int __init octeon_mdiobus_device_init(void) | 235 | static int __init octeon_mdiobus_device_init(void) |
164 | { | 236 | { |
diff --git a/arch/mips/include/asm/octeon/octeon.h b/arch/mips/include/asm/octeon/octeon.h index 4d0a8c61fc3e..ca6214b5ccb9 100644 --- a/arch/mips/include/asm/octeon/octeon.h +++ b/arch/mips/include/asm/octeon/octeon.h | |||
@@ -213,6 +213,11 @@ struct octeon_cf_data { | |||
213 | int dma_engine; /* -1 for no DMA */ | 213 | int dma_engine; /* -1 for no DMA */ |
214 | }; | 214 | }; |
215 | 215 | ||
216 | struct octeon_i2c_data { | ||
217 | unsigned int sys_freq; | ||
218 | unsigned int i2c_freq; | ||
219 | }; | ||
220 | |||
216 | extern void octeon_write_lcd(const char *s); | 221 | extern void octeon_write_lcd(const char *s); |
217 | extern void octeon_check_cpu_bist(void); | 222 | extern void octeon_check_cpu_bist(void); |
218 | extern int octeon_get_boot_debug_flag(void); | 223 | extern int octeon_get_boot_debug_flag(void); |