diff options
author | Andrew Lunn <andrew@lunn.ch> | 2011-05-15 07:32:45 -0400 |
---|---|---|
committer | Nicolas Pitre <nico@fluxnic.net> | 2011-05-16 15:08:36 -0400 |
commit | aac7ffa3ed121846b61347028828617c5dd1ce46 (patch) | |
tree | ec2590692fef62fe4df9dc772e2552bb17e50892 | |
parent | 7e3819d820c9aa3536d15fe7310c054bef1f5f04 (diff) |
ARM: orion: Consolidate I2C initialization.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
-rw-r--r-- | arch/arm/mach-dove/common.c | 33 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/common.c | 31 | ||||
-rw-r--r-- | arch/arm/mach-mv78xx0/common.c | 70 | ||||
-rw-r--r-- | arch/arm/mach-orion5x/common.c | 31 | ||||
-rw-r--r-- | arch/arm/plat-orion/common.c | 54 | ||||
-rw-r--r-- | arch/arm/plat-orion/include/plat/common.h | 6 |
6 files changed, 67 insertions, 158 deletions
diff --git a/arch/arm/mach-dove/common.c b/arch/arm/mach-dove/common.c index 1d878ce69d93..198760b1b17d 100644 --- a/arch/arm/mach-dove/common.c +++ b/arch/arm/mach-dove/common.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/serial_8250.h> | 16 | #include <linux/serial_8250.h> |
17 | #include <linux/clk.h> | 17 | #include <linux/clk.h> |
18 | #include <linux/mbus.h> | 18 | #include <linux/mbus.h> |
19 | #include <linux/mv643xx_i2c.h> | ||
20 | #include <linux/ata_platform.h> | 19 | #include <linux/ata_platform.h> |
21 | #include <linux/serial_8250.h> | 20 | #include <linux/serial_8250.h> |
22 | #include <linux/spi/orion_spi.h> | 21 | #include <linux/spi/orion_spi.h> |
@@ -305,39 +304,9 @@ void __init dove_spi1_init(void) | |||
305 | /***************************************************************************** | 304 | /***************************************************************************** |
306 | * I2C | 305 | * I2C |
307 | ****************************************************************************/ | 306 | ****************************************************************************/ |
308 | static struct mv64xxx_i2c_pdata dove_i2c_data = { | ||
309 | .freq_m = 10, /* assumes 166 MHz TCLK gets 94.3kHz */ | ||
310 | .freq_n = 3, | ||
311 | .timeout = 1000, /* Default timeout of 1 second */ | ||
312 | }; | ||
313 | |||
314 | static struct resource dove_i2c_resources[] = { | ||
315 | { | ||
316 | .name = "i2c base", | ||
317 | .start = DOVE_I2C_PHYS_BASE, | ||
318 | .end = DOVE_I2C_PHYS_BASE + 0x20 - 1, | ||
319 | .flags = IORESOURCE_MEM, | ||
320 | }, { | ||
321 | .name = "i2c irq", | ||
322 | .start = IRQ_DOVE_I2C, | ||
323 | .end = IRQ_DOVE_I2C, | ||
324 | .flags = IORESOURCE_IRQ, | ||
325 | }, | ||
326 | }; | ||
327 | |||
328 | static struct platform_device dove_i2c = { | ||
329 | .name = MV64XXX_I2C_CTLR_NAME, | ||
330 | .id = 0, | ||
331 | .num_resources = ARRAY_SIZE(dove_i2c_resources), | ||
332 | .resource = dove_i2c_resources, | ||
333 | .dev = { | ||
334 | .platform_data = &dove_i2c_data, | ||
335 | }, | ||
336 | }; | ||
337 | |||
338 | void __init dove_i2c_init(void) | 307 | void __init dove_i2c_init(void) |
339 | { | 308 | { |
340 | platform_device_register(&dove_i2c); | 309 | orion_i2c_init(DOVE_I2C_PHYS_BASE, IRQ_DOVE_I2C, 10); |
341 | } | 310 | } |
342 | 311 | ||
343 | /***************************************************************************** | 312 | /***************************************************************************** |
diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c index 485f3b9ba4e2..fc86a80ef565 100644 --- a/arch/arm/mach-kirkwood/common.c +++ b/arch/arm/mach-kirkwood/common.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/platform_device.h> | 13 | #include <linux/platform_device.h> |
14 | #include <linux/serial_8250.h> | 14 | #include <linux/serial_8250.h> |
15 | #include <linux/mbus.h> | 15 | #include <linux/mbus.h> |
16 | #include <linux/mv643xx_i2c.h> | ||
17 | #include <linux/ata_platform.h> | 16 | #include <linux/ata_platform.h> |
18 | #include <linux/mtd/nand.h> | 17 | #include <linux/mtd/nand.h> |
19 | #include <linux/spi/orion_spi.h> | 18 | #include <linux/spi/orion_spi.h> |
@@ -324,37 +323,9 @@ void __init kirkwood_spi_init() | |||
324 | /***************************************************************************** | 323 | /***************************************************************************** |
325 | * I2C | 324 | * I2C |
326 | ****************************************************************************/ | 325 | ****************************************************************************/ |
327 | static struct mv64xxx_i2c_pdata kirkwood_i2c_pdata = { | ||
328 | .freq_m = 8, /* assumes 166 MHz TCLK */ | ||
329 | .freq_n = 3, | ||
330 | .timeout = 1000, /* Default timeout of 1 second */ | ||
331 | }; | ||
332 | |||
333 | static struct resource kirkwood_i2c_resources[] = { | ||
334 | { | ||
335 | .start = I2C_PHYS_BASE, | ||
336 | .end = I2C_PHYS_BASE + 0x1f, | ||
337 | .flags = IORESOURCE_MEM, | ||
338 | }, { | ||
339 | .start = IRQ_KIRKWOOD_TWSI, | ||
340 | .end = IRQ_KIRKWOOD_TWSI, | ||
341 | .flags = IORESOURCE_IRQ, | ||
342 | }, | ||
343 | }; | ||
344 | |||
345 | static struct platform_device kirkwood_i2c = { | ||
346 | .name = MV64XXX_I2C_CTLR_NAME, | ||
347 | .id = 0, | ||
348 | .num_resources = ARRAY_SIZE(kirkwood_i2c_resources), | ||
349 | .resource = kirkwood_i2c_resources, | ||
350 | .dev = { | ||
351 | .platform_data = &kirkwood_i2c_pdata, | ||
352 | }, | ||
353 | }; | ||
354 | |||
355 | void __init kirkwood_i2c_init(void) | 326 | void __init kirkwood_i2c_init(void) |
356 | { | 327 | { |
357 | platform_device_register(&kirkwood_i2c); | 328 | orion_i2c_init(I2C_PHYS_BASE, IRQ_KIRKWOOD_TWSI, 8); |
358 | } | 329 | } |
359 | 330 | ||
360 | 331 | ||
diff --git a/arch/arm/mach-mv78xx0/common.c b/arch/arm/mach-mv78xx0/common.c index 0fd9a8329910..aa27c154cd0d 100644 --- a/arch/arm/mach-mv78xx0/common.c +++ b/arch/arm/mach-mv78xx0/common.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/platform_device.h> | 13 | #include <linux/platform_device.h> |
14 | #include <linux/serial_8250.h> | 14 | #include <linux/serial_8250.h> |
15 | #include <linux/mbus.h> | 15 | #include <linux/mbus.h> |
16 | #include <linux/mv643xx_i2c.h> | ||
17 | #include <linux/ata_platform.h> | 16 | #include <linux/ata_platform.h> |
18 | #include <linux/ethtool.h> | 17 | #include <linux/ethtool.h> |
19 | #include <asm/mach/map.h> | 18 | #include <asm/mach/map.h> |
@@ -346,75 +345,12 @@ void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data) | |||
346 | } | 345 | } |
347 | 346 | ||
348 | /***************************************************************************** | 347 | /***************************************************************************** |
349 | * I2C bus 0 | 348 | * I2C |
350 | ****************************************************************************/ | 349 | ****************************************************************************/ |
351 | |||
352 | static struct mv64xxx_i2c_pdata mv78xx0_i2c_0_pdata = { | ||
353 | .freq_m = 8, /* assumes 166 MHz TCLK */ | ||
354 | .freq_n = 3, | ||
355 | .timeout = 1000, /* Default timeout of 1 second */ | ||
356 | }; | ||
357 | |||
358 | static struct resource mv78xx0_i2c_0_resources[] = { | ||
359 | { | ||
360 | .start = I2C_0_PHYS_BASE, | ||
361 | .end = I2C_0_PHYS_BASE + 0x1f, | ||
362 | .flags = IORESOURCE_MEM, | ||
363 | }, { | ||
364 | .start = IRQ_MV78XX0_I2C_0, | ||
365 | .end = IRQ_MV78XX0_I2C_0, | ||
366 | .flags = IORESOURCE_IRQ, | ||
367 | }, | ||
368 | }; | ||
369 | |||
370 | |||
371 | static struct platform_device mv78xx0_i2c_0 = { | ||
372 | .name = MV64XXX_I2C_CTLR_NAME, | ||
373 | .id = 0, | ||
374 | .num_resources = ARRAY_SIZE(mv78xx0_i2c_0_resources), | ||
375 | .resource = mv78xx0_i2c_0_resources, | ||
376 | .dev = { | ||
377 | .platform_data = &mv78xx0_i2c_0_pdata, | ||
378 | }, | ||
379 | }; | ||
380 | |||
381 | /***************************************************************************** | ||
382 | * I2C bus 1 | ||
383 | ****************************************************************************/ | ||
384 | |||
385 | static struct mv64xxx_i2c_pdata mv78xx0_i2c_1_pdata = { | ||
386 | .freq_m = 8, /* assumes 166 MHz TCLK */ | ||
387 | .freq_n = 3, | ||
388 | .timeout = 1000, /* Default timeout of 1 second */ | ||
389 | }; | ||
390 | |||
391 | static struct resource mv78xx0_i2c_1_resources[] = { | ||
392 | { | ||
393 | .start = I2C_1_PHYS_BASE, | ||
394 | .end = I2C_1_PHYS_BASE + 0x1f, | ||
395 | .flags = IORESOURCE_MEM, | ||
396 | }, { | ||
397 | .start = IRQ_MV78XX0_I2C_1, | ||
398 | .end = IRQ_MV78XX0_I2C_1, | ||
399 | .flags = IORESOURCE_IRQ, | ||
400 | }, | ||
401 | }; | ||
402 | |||
403 | |||
404 | static struct platform_device mv78xx0_i2c_1 = { | ||
405 | .name = MV64XXX_I2C_CTLR_NAME, | ||
406 | .id = 1, | ||
407 | .num_resources = ARRAY_SIZE(mv78xx0_i2c_1_resources), | ||
408 | .resource = mv78xx0_i2c_1_resources, | ||
409 | .dev = { | ||
410 | .platform_data = &mv78xx0_i2c_1_pdata, | ||
411 | }, | ||
412 | }; | ||
413 | |||
414 | void __init mv78xx0_i2c_init(void) | 350 | void __init mv78xx0_i2c_init(void) |
415 | { | 351 | { |
416 | platform_device_register(&mv78xx0_i2c_0); | 352 | orion_i2c_init(I2C_0_PHYS_BASE, IRQ_MV78XX0_I2C_0, 8); |
417 | platform_device_register(&mv78xx0_i2c_1); | 353 | orion_i2c_1_init(I2C_1_PHYS_BASE, IRQ_MV78XX0_I2C_1, 8); |
418 | } | 354 | } |
419 | 355 | ||
420 | /***************************************************************************** | 356 | /***************************************************************************** |
diff --git a/arch/arm/mach-orion5x/common.c b/arch/arm/mach-orion5x/common.c index 0a1c7600004e..9af0b88573ae 100644 --- a/arch/arm/mach-orion5x/common.c +++ b/arch/arm/mach-orion5x/common.c | |||
@@ -169,37 +169,10 @@ void __init orion5x_eth_switch_init(struct dsa_platform_data *d, int irq) | |||
169 | /***************************************************************************** | 169 | /***************************************************************************** |
170 | * I2C | 170 | * I2C |
171 | ****************************************************************************/ | 171 | ****************************************************************************/ |
172 | static struct mv64xxx_i2c_pdata orion5x_i2c_pdata = { | ||
173 | .freq_m = 8, /* assumes 166 MHz TCLK */ | ||
174 | .freq_n = 3, | ||
175 | .timeout = 1000, /* Default timeout of 1 second */ | ||
176 | }; | ||
177 | |||
178 | static struct resource orion5x_i2c_resources[] = { | ||
179 | { | ||
180 | .start = I2C_PHYS_BASE, | ||
181 | .end = I2C_PHYS_BASE + 0x1f, | ||
182 | .flags = IORESOURCE_MEM, | ||
183 | }, { | ||
184 | .start = IRQ_ORION5X_I2C, | ||
185 | .end = IRQ_ORION5X_I2C, | ||
186 | .flags = IORESOURCE_IRQ, | ||
187 | }, | ||
188 | }; | ||
189 | |||
190 | static struct platform_device orion5x_i2c = { | ||
191 | .name = MV64XXX_I2C_CTLR_NAME, | ||
192 | .id = 0, | ||
193 | .num_resources = ARRAY_SIZE(orion5x_i2c_resources), | ||
194 | .resource = orion5x_i2c_resources, | ||
195 | .dev = { | ||
196 | .platform_data = &orion5x_i2c_pdata, | ||
197 | }, | ||
198 | }; | ||
199 | |||
200 | void __init orion5x_i2c_init(void) | 172 | void __init orion5x_i2c_init(void) |
201 | { | 173 | { |
202 | platform_device_register(&orion5x_i2c); | 174 | orion_i2c_init(I2C_PHYS_BASE, IRQ_ORION5X_I2C, 8); |
175 | |||
203 | } | 176 | } |
204 | 177 | ||
205 | 178 | ||
diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c index 15c3f353a9b5..bcc1734c91a8 100644 --- a/arch/arm/plat-orion/common.c +++ b/arch/arm/plat-orion/common.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/serial_8250.h> | 15 | #include <linux/serial_8250.h> |
16 | #include <linux/mbus.h> | 16 | #include <linux/mbus.h> |
17 | #include <linux/mv643xx_eth.h> | 17 | #include <linux/mv643xx_eth.h> |
18 | #include <linux/mv643xx_i2c.h> | ||
18 | #include <net/dsa.h> | 19 | #include <net/dsa.h> |
19 | 20 | ||
20 | /* Fill in the resources structure and link it into the platform | 21 | /* Fill in the resources structure and link it into the platform |
@@ -463,3 +464,56 @@ void __init orion_ge00_switch_init(struct dsa_platform_data *d, int irq) | |||
463 | 464 | ||
464 | platform_device_register(&orion_switch_device); | 465 | platform_device_register(&orion_switch_device); |
465 | } | 466 | } |
467 | |||
468 | /***************************************************************************** | ||
469 | * I2C | ||
470 | ****************************************************************************/ | ||
471 | static struct mv64xxx_i2c_pdata orion_i2c_pdata = { | ||
472 | .freq_n = 3, | ||
473 | .timeout = 1000, /* Default timeout of 1 second */ | ||
474 | }; | ||
475 | |||
476 | static struct resource orion_i2c_resources[2]; | ||
477 | |||
478 | static struct platform_device orion_i2c = { | ||
479 | .name = MV64XXX_I2C_CTLR_NAME, | ||
480 | .id = 0, | ||
481 | .dev = { | ||
482 | .platform_data = &orion_i2c_pdata, | ||
483 | }, | ||
484 | }; | ||
485 | |||
486 | static struct mv64xxx_i2c_pdata orion_i2c_1_pdata = { | ||
487 | .freq_n = 3, | ||
488 | .timeout = 1000, /* Default timeout of 1 second */ | ||
489 | }; | ||
490 | |||
491 | static struct resource orion_i2c_1_resources[2]; | ||
492 | |||
493 | static struct platform_device orion_i2c_1 = { | ||
494 | .name = MV64XXX_I2C_CTLR_NAME, | ||
495 | .id = 1, | ||
496 | .dev = { | ||
497 | .platform_data = &orion_i2c_1_pdata, | ||
498 | }, | ||
499 | }; | ||
500 | |||
501 | void __init orion_i2c_init(unsigned long mapbase, | ||
502 | unsigned long irq, | ||
503 | unsigned long freq_m) | ||
504 | { | ||
505 | orion_i2c_pdata.freq_m = freq_m; | ||
506 | fill_resources(&orion_i2c, orion_i2c_resources, mapbase, | ||
507 | SZ_32 - 1, irq); | ||
508 | platform_device_register(&orion_i2c); | ||
509 | } | ||
510 | |||
511 | void __init orion_i2c_1_init(unsigned long mapbase, | ||
512 | unsigned long irq, | ||
513 | unsigned long freq_m) | ||
514 | { | ||
515 | orion_i2c_1_pdata.freq_m = freq_m; | ||
516 | fill_resources(&orion_i2c_1, orion_i2c_1_resources, mapbase, | ||
517 | SZ_32 - 1, irq); | ||
518 | platform_device_register(&orion_i2c_1); | ||
519 | } | ||
diff --git a/arch/arm/plat-orion/include/plat/common.h b/arch/arm/plat-orion/include/plat/common.h index 3f23258daa61..d107c62d3912 100644 --- a/arch/arm/plat-orion/include/plat/common.h +++ b/arch/arm/plat-orion/include/plat/common.h | |||
@@ -66,5 +66,11 @@ void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data, | |||
66 | 66 | ||
67 | void __init orion_ge00_switch_init(struct dsa_platform_data *d, | 67 | void __init orion_ge00_switch_init(struct dsa_platform_data *d, |
68 | int irq); | 68 | int irq); |
69 | void __init orion_i2c_init(unsigned long mapbase, | ||
70 | unsigned long irq, | ||
71 | unsigned long freq_m); | ||
69 | 72 | ||
73 | void __init orion_i2c_1_init(unsigned long mapbase, | ||
74 | unsigned long irq, | ||
75 | unsigned long freq_m); | ||
70 | #endif | 76 | #endif |