aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2009-03-13 17:44:51 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-03-13 17:44:51 -0400
commit97fb44eb6bc01f4ffed4300e475aa15e44877375 (patch)
tree481ed6efd0babe7185cae04f2fd295426b36411d /arch/arm
parente4707dd3e9d0cb57597b6568a5e51fea5d6fca41 (diff)
parent148854c65ea8046b045672fd49f4333aefaa3ab5 (diff)
Merge branch 'for-rmk' of git://git.pengutronix.de/git/imx/linux-2.6 into devel
Conflicts: arch/arm/mach-at91/gpio.c
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/configs/at91sam9260ek_defconfig2
-rw-r--r--arch/arm/configs/at91sam9261ek_defconfig2
-rw-r--r--arch/arm/configs/at91sam9263ek_defconfig2
-rw-r--r--arch/arm/configs/at91sam9rlek_defconfig2
-rw-r--r--arch/arm/configs/qil-a9260_defconfig2
-rw-r--r--arch/arm/kernel/elf.c4
-rw-r--r--arch/arm/kernel/machine_kexec.c4
-rw-r--r--arch/arm/kernel/setup.c13
-rw-r--r--arch/arm/mach-at91/at91cap9_devices.c2
-rw-r--r--arch/arm/mach-at91/at91sam9260_devices.c2
-rw-r--r--arch/arm/mach-at91/at91sam9261_devices.c2
-rw-r--r--arch/arm/mach-at91/at91sam9263_devices.c107
-rw-r--r--arch/arm/mach-at91/at91sam9rl_devices.c2
-rw-r--r--arch/arm/mach-at91/gpio.c69
-rw-r--r--arch/arm/mach-at91/include/mach/board.h4
-rw-r--r--arch/arm/mach-at91/pm.c1
-rw-r--r--arch/arm/mach-davinci/board-evm.c6
-rw-r--r--arch/arm/mach-davinci/clock.c5
-rw-r--r--arch/arm/mach-davinci/usb.c1
-rw-r--r--arch/arm/mach-ep93xx/include/mach/gesbc9312.h3
-rw-r--r--arch/arm/mach-ep93xx/include/mach/hardware.h1
-rw-r--r--arch/arm/mach-kirkwood/irq.c2
-rw-r--r--arch/arm/mach-mv78xx0/irq.c2
-rw-r--r--arch/arm/mach-mx1/Kconfig7
-rw-r--r--arch/arm/mach-mx1/Makefile1
-rw-r--r--arch/arm/mach-mx1/clock.c40
-rw-r--r--arch/arm/mach-mx1/devices.c3
-rw-r--r--arch/arm/mach-mx1/mx1ads.c68
-rw-r--r--arch/arm/mach-mx1/scb9328.c160
-rw-r--r--arch/arm/mach-mx2/Kconfig20
-rw-r--r--arch/arm/mach-mx2/Makefile2
-rw-r--r--arch/arm/mach-mx2/Makefile.boot10
-rw-r--r--arch/arm/mach-mx2/clock_imx21.c984
-rw-r--r--arch/arm/mach-mx2/clock_imx27.c1656
-rw-r--r--arch/arm/mach-mx2/cpu_imx27.c4
-rw-r--r--arch/arm/mach-mx2/crm_regs.h313
-rw-r--r--arch/arm/mach-mx2/devices.c196
-rw-r--r--arch/arm/mach-mx2/devices.h8
-rw-r--r--arch/arm/mach-mx2/generic.c1
-rw-r--r--arch/arm/mach-mx2/mx27ads.c19
-rw-r--r--arch/arm/mach-mx2/pcm038.c82
-rw-r--r--arch/arm/mach-mx2/pcm970-baseboard.c133
-rw-r--r--arch/arm/mach-mx2/serial.c3
-rw-r--r--arch/arm/mach-mx3/Kconfig36
-rw-r--r--arch/arm/mach-mx3/Makefile8
-rw-r--r--arch/arm/mach-mx3/clock-imx35.c487
-rw-r--r--arch/arm/mach-mx3/clock.c959
-rw-r--r--arch/arm/mach-mx3/crm_regs.h153
-rw-r--r--arch/arm/mach-mx3/devices.c193
-rw-r--r--arch/arm/mach-mx3/devices.h8
-rw-r--r--arch/arm/mach-mx3/iomux.c88
-rw-r--r--arch/arm/mach-mx3/mm.c37
-rw-r--r--arch/arm/mach-mx3/mx31ads.c328
-rw-r--r--arch/arm/mach-mx3/mx31lite.c13
-rw-r--r--arch/arm/mach-mx3/mx31moboard-devboard.c48
-rw-r--r--arch/arm/mach-mx3/mx31moboard-marxbot.c37
-rw-r--r--arch/arm/mach-mx3/mx31moboard.c74
-rw-r--r--arch/arm/mach-mx3/mx31pdk.c44
-rw-r--r--arch/arm/mach-mx3/pcm037.c138
-rw-r--r--arch/arm/mach-mx3/qong.c312
-rw-r--r--arch/arm/mach-omap2/board-ldp.c2
-rw-r--r--arch/arm/mach-omap2/clock.c16
-rw-r--r--arch/arm/mach-orion5x/irq.c2
-rw-r--r--arch/arm/mach-rpc/riscpc.c6
-rw-r--r--arch/arm/mm/Kconfig3
-rw-r--r--arch/arm/mm/abort-ev6.S3
-rw-r--r--arch/arm/mm/mmu.c3
-rw-r--r--arch/arm/plat-mxc/Kconfig10
-rw-r--r--arch/arm/plat-mxc/Makefile3
-rw-r--r--arch/arm/plat-mxc/clock.c54
-rw-r--r--arch/arm/plat-mxc/cpu.c11
-rw-r--r--arch/arm/plat-mxc/devices.c1
-rw-r--r--arch/arm/plat-mxc/dma-mx1-mx2.c2
-rw-r--r--arch/arm/plat-mxc/gpio.c2
-rw-r--r--arch/arm/plat-mxc/include/mach/board-mx27ads.h3
-rw-r--r--arch/arm/plat-mxc/include/mach/board-mx31ads.h2
-rw-r--r--arch/arm/plat-mxc/include/mach/board-mx31moboard.h45
-rw-r--r--arch/arm/plat-mxc/include/mach/board-qong.h22
-rw-r--r--arch/arm/plat-mxc/include/mach/clkdev.h7
-rw-r--r--arch/arm/plat-mxc/include/mach/clock.h6
-rw-r--r--arch/arm/plat-mxc/include/mach/common.h10
-rw-r--r--arch/arm/plat-mxc/include/mach/debug-macro.S3
-rw-r--r--arch/arm/plat-mxc/include/mach/hardware.h8
-rw-r--r--arch/arm/plat-mxc/include/mach/imxfb.h (renamed from arch/arm/mach-imx/include/mach/imxfb.h)3
-rw-r--r--arch/arm/plat-mxc/include/mach/iomux-mx1-mx2.h416
-rw-r--r--arch/arm/plat-mxc/include/mach/iomux-mx1.h166
-rw-r--r--arch/arm/plat-mxc/include/mach/iomux-mx21.h126
-rw-r--r--arch/arm/plat-mxc/include/mach/iomux-mx27.h207
-rw-r--r--arch/arm/plat-mxc/include/mach/iomux-mx2x.h237
-rw-r--r--arch/arm/plat-mxc/include/mach/iomux-mx3.h74
-rw-r--r--arch/arm/plat-mxc/include/mach/iomux.h127
-rw-r--r--arch/arm/plat-mxc/include/mach/memory.h5
-rw-r--r--arch/arm/plat-mxc/include/mach/mx21.h78
-rw-r--r--arch/arm/plat-mxc/include/mach/mx27.h200
-rw-r--r--arch/arm/plat-mxc/include/mach/mx2x.h200
-rw-r--r--arch/arm/plat-mxc/include/mach/mx31.h329
-rw-r--r--arch/arm/plat-mxc/include/mach/mx35.h29
-rw-r--r--arch/arm/plat-mxc/include/mach/mx3x.h290
-rw-r--r--arch/arm/plat-mxc/include/mach/mxc.h74
-rw-r--r--arch/arm/plat-mxc/iomux-mx1-mx2.c2
-rw-r--r--arch/arm/plat-mxc/pwm.c300
-rw-r--r--arch/arm/plat-mxc/time.c32
-rw-r--r--arch/arm/plat-orion/gpio.c73
-rw-r--r--arch/arm/plat-orion/include/plat/gpio.h3
-rw-r--r--arch/arm/plat-s3c64xx/irq-eint.c2
105 files changed, 6471 insertions, 3639 deletions
diff --git a/arch/arm/configs/at91sam9260ek_defconfig b/arch/arm/configs/at91sam9260ek_defconfig
index e0ee7060f9aa..98e2f3de4bc5 100644
--- a/arch/arm/configs/at91sam9260ek_defconfig
+++ b/arch/arm/configs/at91sam9260ek_defconfig
@@ -608,7 +608,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
608# Watchdog Device Drivers 608# Watchdog Device Drivers
609# 609#
610# CONFIG_SOFT_WATCHDOG is not set 610# CONFIG_SOFT_WATCHDOG is not set
611CONFIG_AT91SAM9_WATCHDOG=y 611CONFIG_AT91SAM9X_WATCHDOG=y
612 612
613# 613#
614# USB-based Watchdog Cards 614# USB-based Watchdog Cards
diff --git a/arch/arm/configs/at91sam9261ek_defconfig b/arch/arm/configs/at91sam9261ek_defconfig
index 01d1ef97d8be..149456142392 100644
--- a/arch/arm/configs/at91sam9261ek_defconfig
+++ b/arch/arm/configs/at91sam9261ek_defconfig
@@ -700,7 +700,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
700# Watchdog Device Drivers 700# Watchdog Device Drivers
701# 701#
702# CONFIG_SOFT_WATCHDOG is not set 702# CONFIG_SOFT_WATCHDOG is not set
703CONFIG_AT91SAM9_WATCHDOG=y 703CONFIG_AT91SAM9X_WATCHDOG=y
704 704
705# 705#
706# USB-based Watchdog Cards 706# USB-based Watchdog Cards
diff --git a/arch/arm/configs/at91sam9263ek_defconfig b/arch/arm/configs/at91sam9263ek_defconfig
index 036a126725c1..21599f3c6275 100644
--- a/arch/arm/configs/at91sam9263ek_defconfig
+++ b/arch/arm/configs/at91sam9263ek_defconfig
@@ -710,7 +710,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
710# Watchdog Device Drivers 710# Watchdog Device Drivers
711# 711#
712# CONFIG_SOFT_WATCHDOG is not set 712# CONFIG_SOFT_WATCHDOG is not set
713CONFIG_AT91SAM9_WATCHDOG=y 713CONFIG_AT91SAM9X_WATCHDOG=y
714 714
715# 715#
716# USB-based Watchdog Cards 716# USB-based Watchdog Cards
diff --git a/arch/arm/configs/at91sam9rlek_defconfig b/arch/arm/configs/at91sam9rlek_defconfig
index 237a2a6a8517..e2df81a3e804 100644
--- a/arch/arm/configs/at91sam9rlek_defconfig
+++ b/arch/arm/configs/at91sam9rlek_defconfig
@@ -606,7 +606,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
606# Watchdog Device Drivers 606# Watchdog Device Drivers
607# 607#
608# CONFIG_SOFT_WATCHDOG is not set 608# CONFIG_SOFT_WATCHDOG is not set
609CONFIG_AT91SAM9_WATCHDOG=y 609CONFIG_AT91SAM9X_WATCHDOG=y
610 610
611# 611#
612# Sonics Silicon Backplane 612# Sonics Silicon Backplane
diff --git a/arch/arm/configs/qil-a9260_defconfig b/arch/arm/configs/qil-a9260_defconfig
index cd1d717903ac..9b32d0eb89ba 100644
--- a/arch/arm/configs/qil-a9260_defconfig
+++ b/arch/arm/configs/qil-a9260_defconfig
@@ -727,7 +727,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
727# Watchdog Device Drivers 727# Watchdog Device Drivers
728# 728#
729# CONFIG_SOFT_WATCHDOG is not set 729# CONFIG_SOFT_WATCHDOG is not set
730# CONFIG_AT91SAM9_WATCHDOG is not set 730# CONFIG_AT91SAM9X_WATCHDOG is not set
731 731
732# 732#
733# USB-based Watchdog Cards 733# USB-based Watchdog Cards
diff --git a/arch/arm/kernel/elf.c b/arch/arm/kernel/elf.c
index 84849098c8e8..d4a0da1e48f4 100644
--- a/arch/arm/kernel/elf.c
+++ b/arch/arm/kernel/elf.c
@@ -74,9 +74,9 @@ EXPORT_SYMBOL(elf_set_personality);
74 */ 74 */
75int arm_elf_read_implies_exec(const struct elf32_hdr *x, int executable_stack) 75int arm_elf_read_implies_exec(const struct elf32_hdr *x, int executable_stack)
76{ 76{
77 if (executable_stack != EXSTACK_ENABLE_X) 77 if (executable_stack != EXSTACK_DISABLE_X)
78 return 1; 78 return 1;
79 if (cpu_architecture() <= CPU_ARCH_ARMv6) 79 if (cpu_architecture() < CPU_ARCH_ARMv6)
80 return 1; 80 return 1;
81 return 0; 81 return 0;
82} 82}
diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
index 440dc62cdc3a..598ca61e7bca 100644
--- a/arch/arm/kernel/machine_kexec.c
+++ b/arch/arm/kernel/machine_kexec.c
@@ -13,8 +13,8 @@
13#include <asm/cacheflush.h> 13#include <asm/cacheflush.h>
14#include <asm/mach-types.h> 14#include <asm/mach-types.h>
15 15
16const extern unsigned char relocate_new_kernel[]; 16extern const unsigned char relocate_new_kernel[];
17const extern unsigned int relocate_new_kernel_size; 17extern const unsigned int relocate_new_kernel_size;
18 18
19extern void setup_mm_for_reboot(char mode); 19extern void setup_mm_for_reboot(char mode);
20 20
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 8d21427bb679..bc5e4128f9f3 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -234,12 +234,13 @@ static void __init cacheid_init(void)
234 unsigned int cachetype = read_cpuid_cachetype(); 234 unsigned int cachetype = read_cpuid_cachetype();
235 unsigned int arch = cpu_architecture(); 235 unsigned int arch = cpu_architecture();
236 236
237 if (arch >= CPU_ARCH_ARMv7) { 237 if (arch >= CPU_ARCH_ARMv6) {
238 cacheid = CACHEID_VIPT_NONALIASING; 238 if ((cachetype & (7 << 29)) == 4 << 29) {
239 if ((cachetype & (3 << 14)) == 1 << 14) 239 /* ARMv7 register format */
240 cacheid |= CACHEID_ASID_TAGGED; 240 cacheid = CACHEID_VIPT_NONALIASING;
241 } else if (arch >= CPU_ARCH_ARMv6) { 241 if ((cachetype & (3 << 14)) == 1 << 14)
242 if (cachetype & (1 << 23)) 242 cacheid |= CACHEID_ASID_TAGGED;
243 } else if (cachetype & (1 << 23))
243 cacheid = CACHEID_VIPT_ALIASING; 244 cacheid = CACHEID_VIPT_ALIASING;
244 else 245 else
245 cacheid = CACHEID_VIPT_NONALIASING; 246 cacheid = CACHEID_VIPT_NONALIASING;
diff --git a/arch/arm/mach-at91/at91cap9_devices.c b/arch/arm/mach-at91/at91cap9_devices.c
index 9eca2209cde6..412aa49ad2fb 100644
--- a/arch/arm/mach-at91/at91cap9_devices.c
+++ b/arch/arm/mach-at91/at91cap9_devices.c
@@ -697,7 +697,7 @@ static void __init at91_add_device_rtt(void)
697 * Watchdog 697 * Watchdog
698 * -------------------------------------------------------------------- */ 698 * -------------------------------------------------------------------- */
699 699
700#if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE) 700#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
701static struct platform_device at91cap9_wdt_device = { 701static struct platform_device at91cap9_wdt_device = {
702 .name = "at91_wdt", 702 .name = "at91_wdt",
703 .id = -1, 703 .id = -1,
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index fdde1ea21b07..d74c9ac007e7 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -643,7 +643,7 @@ static void __init at91_add_device_rtt(void)
643 * Watchdog 643 * Watchdog
644 * -------------------------------------------------------------------- */ 644 * -------------------------------------------------------------------- */
645 645
646#if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE) 646#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
647static struct platform_device at91sam9260_wdt_device = { 647static struct platform_device at91sam9260_wdt_device = {
648 .name = "at91_wdt", 648 .name = "at91_wdt",
649 .id = -1, 649 .id = -1,
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index 17289756f80f..59fc48311fb0 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -621,7 +621,7 @@ static void __init at91_add_device_rtt(void)
621 * Watchdog 621 * Watchdog
622 * -------------------------------------------------------------------- */ 622 * -------------------------------------------------------------------- */
623 623
624#if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE) 624#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
625static struct platform_device at91sam9261_wdt_device = { 625static struct platform_device at91sam9261_wdt_device = {
626 .name = "at91_wdt", 626 .name = "at91_wdt",
627 .id = -1, 627 .id = -1,
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index b753cb879d8e..b7f233242315 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -347,6 +347,111 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
347void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {} 347void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
348#endif 348#endif
349 349
350/* --------------------------------------------------------------------
351 * Compact Flash (PCMCIA or IDE)
352 * -------------------------------------------------------------------- */
353
354#if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE) || \
355 defined(CONFIG_BLK_DEV_IDE_AT91) || defined(CONFIG_BLK_DEV_IDE_AT91_MODULE)
356
357static struct at91_cf_data cf0_data;
358
359static struct resource cf0_resources[] = {
360 [0] = {
361 .start = AT91_CHIPSELECT_4,
362 .end = AT91_CHIPSELECT_4 + SZ_256M - 1,
363 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
364 }
365};
366
367static struct platform_device cf0_device = {
368 .id = 0,
369 .dev = {
370 .platform_data = &cf0_data,
371 },
372 .resource = cf0_resources,
373 .num_resources = ARRAY_SIZE(cf0_resources),
374};
375
376static struct at91_cf_data cf1_data;
377
378static struct resource cf1_resources[] = {
379 [0] = {
380 .start = AT91_CHIPSELECT_5,
381 .end = AT91_CHIPSELECT_5 + SZ_256M - 1,
382 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
383 }
384};
385
386static struct platform_device cf1_device = {
387 .id = 1,
388 .dev = {
389 .platform_data = &cf1_data,
390 },
391 .resource = cf1_resources,
392 .num_resources = ARRAY_SIZE(cf1_resources),
393};
394
395void __init at91_add_device_cf(struct at91_cf_data *data)
396{
397 unsigned long ebi0_csa;
398 struct platform_device *pdev;
399
400 if (!data)
401 return;
402
403 /*
404 * assign CS4 or CS5 to SMC with Compact Flash logic support,
405 * we assume SMC timings are configured by board code,
406 * except True IDE where timings are controlled by driver
407 */
408 ebi0_csa = at91_sys_read(AT91_MATRIX_EBI0CSA);
409 switch (data->chipselect) {
410 case 4:
411 at91_set_A_periph(AT91_PIN_PD6, 0); /* EBI0_NCS4/CFCS0 */
412 ebi0_csa |= AT91_MATRIX_EBI0_CS4A_SMC_CF1;
413 cf0_data = *data;
414 pdev = &cf0_device;
415 break;
416 case 5:
417 at91_set_A_periph(AT91_PIN_PD7, 0); /* EBI0_NCS5/CFCS1 */
418 ebi0_csa |= AT91_MATRIX_EBI0_CS5A_SMC_CF2;
419 cf1_data = *data;
420 pdev = &cf1_device;
421 break;
422 default:
423 printk(KERN_ERR "AT91 CF: bad chip-select requested (%u)\n",
424 data->chipselect);
425 return;
426 }
427 at91_sys_write(AT91_MATRIX_EBI0CSA, ebi0_csa);
428
429 if (data->det_pin) {
430 at91_set_gpio_input(data->det_pin, 1);
431 at91_set_deglitch(data->det_pin, 1);
432 }
433
434 if (data->irq_pin) {
435 at91_set_gpio_input(data->irq_pin, 1);
436 at91_set_deglitch(data->irq_pin, 1);
437 }
438
439 if (data->vcc_pin)
440 /* initially off */
441 at91_set_gpio_output(data->vcc_pin, 0);
442
443 /* enable EBI controlled pins */
444 at91_set_A_periph(AT91_PIN_PD5, 1); /* NWAIT */
445 at91_set_A_periph(AT91_PIN_PD8, 0); /* CFCE1 */
446 at91_set_A_periph(AT91_PIN_PD9, 0); /* CFCE2 */
447 at91_set_A_periph(AT91_PIN_PD14, 0); /* CFNRW */
448
449 pdev->name = (data->flags & AT91_CF_TRUE_IDE) ? "at91_ide" : "at91_cf";
450 platform_device_register(pdev);
451}
452#else
453void __init at91_add_device_cf(struct at91_cf_data *data) {}
454#endif
350 455
351/* -------------------------------------------------------------------- 456/* --------------------------------------------------------------------
352 * NAND / SmartMedia 457 * NAND / SmartMedia
@@ -854,7 +959,7 @@ static void __init at91_add_device_rtt(void)
854 * Watchdog 959 * Watchdog
855 * -------------------------------------------------------------------- */ 960 * -------------------------------------------------------------------- */
856 961
857#if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE) 962#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
858static struct platform_device at91sam9263_wdt_device = { 963static struct platform_device at91sam9263_wdt_device = {
859 .name = "at91_wdt", 964 .name = "at91_wdt",
860 .id = -1, 965 .id = -1,
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
index 145324f4ec56..728186515cdf 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -609,7 +609,7 @@ static void __init at91_add_device_rtt(void)
609 * Watchdog 609 * Watchdog
610 * -------------------------------------------------------------------- */ 610 * -------------------------------------------------------------------- */
611 611
612#if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE) 612#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
613static struct platform_device at91sam9rl_wdt_device = { 613static struct platform_device at91sam9rl_wdt_device = {
614 .name = "at91_wdt", 614 .name = "at91_wdt",
615 .id = -1, 615 .id = -1,
diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
index 028e4f7a88be..f2236f0e101f 100644
--- a/arch/arm/mach-at91/gpio.c
+++ b/arch/arm/mach-at91/gpio.c
@@ -437,7 +437,68 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
437 437
438/*--------------------------------------------------------------------------*/ 438/*--------------------------------------------------------------------------*/
439 439
440/* This lock class tells lockdep that GPIO irqs are in a different 440#ifdef CONFIG_DEBUG_FS
441
442static int at91_gpio_show(struct seq_file *s, void *unused)
443{
444 int bank, j;
445
446 /* print heading */
447 seq_printf(s, "Pin\t");
448 for (bank = 0; bank < gpio_banks; bank++) {
449 seq_printf(s, "PIO%c\t", 'A' + bank);
450 };
451 seq_printf(s, "\n\n");
452
453 /* print pin status */
454 for (j = 0; j < 32; j++) {
455 seq_printf(s, "%i:\t", j);
456
457 for (bank = 0; bank < gpio_banks; bank++) {
458 unsigned pin = PIN_BASE + (32 * bank) + j;
459 void __iomem *pio = pin_to_controller(pin);
460 unsigned mask = pin_to_mask(pin);
461
462 if (__raw_readl(pio + PIO_PSR) & mask)
463 seq_printf(s, "GPIO:%s", __raw_readl(pio + PIO_PDSR) & mask ? "1" : "0");
464 else
465 seq_printf(s, "%s", __raw_readl(pio + PIO_ABSR) & mask ? "B" : "A");
466
467 seq_printf(s, "\t");
468 }
469
470 seq_printf(s, "\n");
471 }
472
473 return 0;
474}
475
476static int at91_gpio_open(struct inode *inode, struct file *file)
477{
478 return single_open(file, at91_gpio_show, NULL);
479}
480
481static const struct file_operations at91_gpio_operations = {
482 .open = at91_gpio_open,
483 .read = seq_read,
484 .llseek = seq_lseek,
485 .release = single_release,
486};
487
488static int __init at91_gpio_debugfs_init(void)
489{
490 /* /sys/kernel/debug/at91_gpio */
491 (void) debugfs_create_file("at91_gpio", S_IFREG | S_IRUGO, NULL, NULL, &at91_gpio_operations);
492 return 0;
493}
494postcore_initcall(at91_gpio_debugfs_init);
495
496#endif
497
498/*--------------------------------------------------------------------------*/
499
500/*
501 * This lock class tells lockdep that GPIO irqs are in a different
441 * category than their parents, so it won't report false recursion. 502 * category than their parents, so it won't report false recursion.
442 */ 503 */
443static struct lock_class_key gpio_lock_class; 504static struct lock_class_key gpio_lock_class;
@@ -456,9 +517,6 @@ void __init at91_gpio_irq_setup(void)
456 unsigned id = this->bank->id; 517 unsigned id = this->bank->id;
457 unsigned i; 518 unsigned i;
458 519
459 /* enable PIO controller's clock */
460 clk_enable(this->bank->clock);
461
462 __raw_writel(~0, this->regbase + PIO_IDR); 520 __raw_writel(~0, this->regbase + PIO_IDR);
463 521
464 for (i = 0, pin = this->chip.base; i < 32; i++, pin++) { 522 for (i = 0, pin = this->chip.base; i < 32; i++, pin++) {
@@ -589,6 +647,9 @@ void __init at91_gpio_init(struct at91_gpio_bank *data, int nr_banks)
589 at91_gpio->regbase = at91_gpio->bank->offset + 647 at91_gpio->regbase = at91_gpio->bank->offset +
590 (void __iomem *)AT91_VA_BASE_SYS; 648 (void __iomem *)AT91_VA_BASE_SYS;
591 649
650 /* enable PIO controller's clock */
651 clk_enable(at91_gpio->bank->clock);
652
592 /* AT91SAM9263_ID_PIOCDE groups PIOC, PIOD, PIOE */ 653 /* AT91SAM9263_ID_PIOCDE groups PIOC, PIOD, PIOE */
593 if (last && last->bank->id == at91_gpio->bank->id) 654 if (last && last->bank->id == at91_gpio->bank->id)
594 last->next = at91_gpio; 655 last->next = at91_gpio;
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index fb51f0e0a83f..793fe7b25f36 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -56,6 +56,9 @@ struct at91_cf_data {
56 u8 vcc_pin; /* power switching */ 56 u8 vcc_pin; /* power switching */
57 u8 rst_pin; /* card reset */ 57 u8 rst_pin; /* card reset */
58 u8 chipselect; /* EBI Chip Select number */ 58 u8 chipselect; /* EBI Chip Select number */
59 u8 flags;
60#define AT91_CF_TRUE_IDE 0x01
61#define AT91_IDE_SWAP_A0_A2 0x02
59}; 62};
60extern void __init at91_add_device_cf(struct at91_cf_data *data); 63extern void __init at91_add_device_cf(struct at91_cf_data *data);
61 64
@@ -93,6 +96,7 @@ struct atmel_nand_data {
93 u8 enable_pin; /* chip enable */ 96 u8 enable_pin; /* chip enable */
94 u8 det_pin; /* card detect */ 97 u8 det_pin; /* card detect */
95 u8 rdy_pin; /* ready/busy */ 98 u8 rdy_pin; /* ready/busy */
99 u8 rdy_pin_active_low; /* rdy_pin value is inverted */
96 u8 ale; /* address line number connected to ALE */ 100 u8 ale; /* address line number connected to ALE */
97 u8 cle; /* address line number connected to CLE */ 101 u8 cle; /* address line number connected to CLE */
98 u8 bus_width_16; /* buswidth is 16 bit */ 102 u8 bus_width_16; /* buswidth is 16 bit */
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 9bb4f043aa22..7ac812dc055a 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -332,7 +332,6 @@ static int at91_pm_enter(suspend_state_t state)
332 at91_sys_read(AT91_AIC_IPR) & at91_sys_read(AT91_AIC_IMR)); 332 at91_sys_read(AT91_AIC_IPR) & at91_sys_read(AT91_AIC_IMR));
333 333
334error: 334error:
335 sdram_selfrefresh_disable();
336 target_state = PM_SUSPEND_ON; 335 target_state = PM_SUSPEND_ON;
337 at91_irq_resume(); 336 at91_irq_resume();
338 at91_gpio_resume(); 337 at91_gpio_resume();
diff --git a/arch/arm/mach-davinci/board-evm.c b/arch/arm/mach-davinci/board-evm.c
index a957d239a683..38b6a9ce2a93 100644
--- a/arch/arm/mach-davinci/board-evm.c
+++ b/arch/arm/mach-davinci/board-evm.c
@@ -311,6 +311,9 @@ evm_u35_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
311 gpio_request(gpio + 7, "nCF_SEL"); 311 gpio_request(gpio + 7, "nCF_SEL");
312 gpio_direction_output(gpio + 7, 1); 312 gpio_direction_output(gpio + 7, 1);
313 313
314 /* irlml6401 sustains over 3A, switches 5V in under 8 msec */
315 setup_usb(500, 8);
316
314 return 0; 317 return 0;
315} 318}
316 319
@@ -417,9 +420,6 @@ static __init void davinci_evm_init(void)
417 platform_add_devices(davinci_evm_devices, 420 platform_add_devices(davinci_evm_devices,
418 ARRAY_SIZE(davinci_evm_devices)); 421 ARRAY_SIZE(davinci_evm_devices));
419 evm_init_i2c(); 422 evm_init_i2c();
420
421 /* irlml6401 sustains over 3A, switches 5V in under 8 msec */
422 setup_usb(500, 8);
423} 423}
424 424
425static __init void davinci_evm_irq_init(void) 425static __init void davinci_evm_irq_init(void)
diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index 28f6dbc95bd7..abb92b7eca0c 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -231,6 +231,11 @@ static struct clk davinci_clks[] = {
231 .lpsc = DAVINCI_LPSC_GPIO, 231 .lpsc = DAVINCI_LPSC_GPIO,
232 }, 232 },
233 { 233 {
234 .name = "usb",
235 .rate = &commonrate,
236 .lpsc = DAVINCI_LPSC_USB,
237 },
238 {
234 .name = "AEMIFCLK", 239 .name = "AEMIFCLK",
235 .rate = &commonrate, 240 .rate = &commonrate,
236 .lpsc = DAVINCI_LPSC_AEMIF, 241 .lpsc = DAVINCI_LPSC_AEMIF,
diff --git a/arch/arm/mach-davinci/usb.c b/arch/arm/mach-davinci/usb.c
index 867ead2559ad..69680784448a 100644
--- a/arch/arm/mach-davinci/usb.c
+++ b/arch/arm/mach-davinci/usb.c
@@ -47,6 +47,7 @@ static struct musb_hdrc_platform_data usb_data = {
47#elif defined(CONFIG_USB_MUSB_HOST) 47#elif defined(CONFIG_USB_MUSB_HOST)
48 .mode = MUSB_HOST, 48 .mode = MUSB_HOST,
49#endif 49#endif
50 .clock = "usb",
50 .config = &musb_config, 51 .config = &musb_config,
51}; 52};
52 53
diff --git a/arch/arm/mach-ep93xx/include/mach/gesbc9312.h b/arch/arm/mach-ep93xx/include/mach/gesbc9312.h
deleted file mode 100644
index 21fe2b922aa5..000000000000
--- a/arch/arm/mach-ep93xx/include/mach/gesbc9312.h
+++ /dev/null
@@ -1,3 +0,0 @@
1/*
2 * arch/arm/mach-ep93xx/include/mach/gesbc9312.h
3 */
diff --git a/arch/arm/mach-ep93xx/include/mach/hardware.h b/arch/arm/mach-ep93xx/include/mach/hardware.h
index 529807d182bf..2866297310b7 100644
--- a/arch/arm/mach-ep93xx/include/mach/hardware.h
+++ b/arch/arm/mach-ep93xx/include/mach/hardware.h
@@ -10,7 +10,6 @@
10 10
11#include "platform.h" 11#include "platform.h"
12 12
13#include "gesbc9312.h"
14#include "ts72xx.h" 13#include "ts72xx.h"
15 14
16#endif 15#endif
diff --git a/arch/arm/mach-kirkwood/irq.c b/arch/arm/mach-kirkwood/irq.c
index efb86b700276..06083b23bb44 100644
--- a/arch/arm/mach-kirkwood/irq.c
+++ b/arch/arm/mach-kirkwood/irq.c
@@ -42,7 +42,7 @@ void __init kirkwood_init_irq(void)
42 writel(0, GPIO_EDGE_CAUSE(32)); 42 writel(0, GPIO_EDGE_CAUSE(32));
43 43
44 for (i = IRQ_KIRKWOOD_GPIO_START; i < NR_IRQS; i++) { 44 for (i = IRQ_KIRKWOOD_GPIO_START; i < NR_IRQS; i++) {
45 set_irq_chip(i, &orion_gpio_irq_level_chip); 45 set_irq_chip(i, &orion_gpio_irq_chip);
46 set_irq_handler(i, handle_level_irq); 46 set_irq_handler(i, handle_level_irq);
47 irq_desc[i].status |= IRQ_LEVEL; 47 irq_desc[i].status |= IRQ_LEVEL;
48 set_irq_flags(i, IRQF_VALID); 48 set_irq_flags(i, IRQF_VALID);
diff --git a/arch/arm/mach-mv78xx0/irq.c b/arch/arm/mach-mv78xx0/irq.c
index e273418797b4..30b7e4bcdbc7 100644
--- a/arch/arm/mach-mv78xx0/irq.c
+++ b/arch/arm/mach-mv78xx0/irq.c
@@ -40,7 +40,7 @@ void __init mv78xx0_init_irq(void)
40 writel(0, GPIO_EDGE_CAUSE(0)); 40 writel(0, GPIO_EDGE_CAUSE(0));
41 41
42 for (i = IRQ_MV78XX0_GPIO_START; i < NR_IRQS; i++) { 42 for (i = IRQ_MV78XX0_GPIO_START; i < NR_IRQS; i++) {
43 set_irq_chip(i, &orion_gpio_irq_level_chip); 43 set_irq_chip(i, &orion_gpio_irq_chip);
44 set_irq_handler(i, handle_level_irq); 44 set_irq_handler(i, handle_level_irq);
45 irq_desc[i].status |= IRQ_LEVEL; 45 irq_desc[i].status |= IRQ_LEVEL;
46 set_irq_flags(i, IRQF_VALID); 46 set_irq_flags(i, IRQF_VALID);
diff --git a/arch/arm/mach-mx1/Kconfig b/arch/arm/mach-mx1/Kconfig
index 2b59fc74784f..eb7660f5d4b7 100644
--- a/arch/arm/mach-mx1/Kconfig
+++ b/arch/arm/mach-mx1/Kconfig
@@ -1,6 +1,6 @@
1if ARCH_MX1 1if ARCH_MX1
2 2
3comment "MX1 Platforms" 3comment "MX1 platforms:"
4 4
5config MACH_MXLADS 5config MACH_MXLADS
6 bool 6 bool
@@ -11,4 +11,9 @@ config ARCH_MX1ADS
11 help 11 help
12 Say Y here if you are using Motorola MX1ADS/MXLADS boards 12 Say Y here if you are using Motorola MX1ADS/MXLADS boards
13 13
14config MACH_SCB9328
15 bool "Synertronixx scb9328"
16 help
17 Say Y here if you are using a Synertronixx scb9328 board
18
14endif 19endif
diff --git a/arch/arm/mach-mx1/Makefile b/arch/arm/mach-mx1/Makefile
index b969719011fa..82f1309568ef 100644
--- a/arch/arm/mach-mx1/Makefile
+++ b/arch/arm/mach-mx1/Makefile
@@ -8,3 +8,4 @@ obj-y += generic.o clock.o devices.o
8 8
9# Specific board support 9# Specific board support
10obj-$(CONFIG_ARCH_MX1ADS) += mx1ads.o 10obj-$(CONFIG_ARCH_MX1ADS) += mx1ads.o
11obj-$(CONFIG_MACH_SCB9328) += scb9328.o \ No newline at end of file
diff --git a/arch/arm/mach-mx1/clock.c b/arch/arm/mach-mx1/clock.c
index 4bcd1ece55f5..0d0f306851d0 100644
--- a/arch/arm/mach-mx1/clock.c
+++ b/arch/arm/mach-mx1/clock.c
@@ -25,6 +25,7 @@
25 25
26#include <mach/clock.h> 26#include <mach/clock.h>
27#include <mach/hardware.h> 27#include <mach/hardware.h>
28#include <mach/common.h>
28#include "crm_regs.h" 29#include "crm_regs.h"
29 30
30static int _clk_enable(struct clk *clk) 31static int _clk_enable(struct clk *clk)
@@ -87,33 +88,6 @@ static int _clk_parent_set_rate(struct clk *clk, unsigned long rate)
87 return clk->parent->set_rate(clk->parent, rate); 88 return clk->parent->set_rate(clk->parent, rate);
88} 89}
89 90
90/*
91 * get the system pll clock in Hz
92 *
93 * mfi + mfn / (mfd +1)
94 * f = 2 * f_ref * --------------------
95 * pd + 1
96 */
97static unsigned long mx1_decode_pll(unsigned int pll, u32 f_ref)
98{
99 unsigned long long ll;
100 unsigned long quot;
101
102 u32 mfi = (pll >> 10) & 0xf;
103 u32 mfn = pll & 0x3ff;
104 u32 mfd = (pll >> 16) & 0x3ff;
105 u32 pd = (pll >> 26) & 0xf;
106
107 mfi = mfi <= 5 ? 5 : mfi;
108
109 ll = 2 * (unsigned long long)f_ref *
110 ((mfi << 16) + (mfn << 16) / (mfd + 1));
111 quot = (pd + 1) * (1 << 16);
112 ll += quot / 2;
113 do_div(ll, quot);
114 return (unsigned long)ll;
115}
116
117static unsigned long clk16m_get_rate(struct clk *clk) 91static unsigned long clk16m_get_rate(struct clk *clk)
118{ 92{
119 return 16000000; 93 return 16000000;
@@ -188,7 +162,7 @@ static struct clk prem_clk = {
188 162
189static unsigned long system_clk_get_rate(struct clk *clk) 163static unsigned long system_clk_get_rate(struct clk *clk)
190{ 164{
191 return mx1_decode_pll(__raw_readl(CCM_SPCTL0), 165 return mxc_decode_pll(__raw_readl(CCM_SPCTL0),
192 clk_get_rate(clk->parent)); 166 clk_get_rate(clk->parent));
193} 167}
194 168
@@ -200,7 +174,7 @@ static struct clk system_clk = {
200 174
201static unsigned long mcu_clk_get_rate(struct clk *clk) 175static unsigned long mcu_clk_get_rate(struct clk *clk)
202{ 176{
203 return mx1_decode_pll(__raw_readl(CCM_MPCTL0), 177 return mxc_decode_pll(__raw_readl(CCM_MPCTL0),
204 clk_get_rate(clk->parent)); 178 clk_get_rate(clk->parent));
205} 179}
206 180
@@ -488,7 +462,7 @@ static struct clk clko_clk = {
488}; 462};
489 463
490static struct clk dma_clk = { 464static struct clk dma_clk = {
491 .name = "dma_clk", 465 .name = "dma",
492 .parent = &hclk, 466 .parent = &hclk,
493 .round_rate = _clk_parent_round_rate, 467 .round_rate = _clk_parent_round_rate,
494 .set_rate = _clk_parent_set_rate, 468 .set_rate = _clk_parent_set_rate,
@@ -539,7 +513,7 @@ static struct clk gpt_clk = {
539}; 513};
540 514
541static struct clk uart_clk = { 515static struct clk uart_clk = {
542 .name = "uart_clk", 516 .name = "uart",
543 .parent = &perclk[0], 517 .parent = &perclk[0],
544 .round_rate = _clk_parent_round_rate, 518 .round_rate = _clk_parent_round_rate,
545 .set_rate = _clk_parent_set_rate, 519 .set_rate = _clk_parent_set_rate,
@@ -621,7 +595,7 @@ static struct clk *mxc_clks[] = {
621 &rtc_clk, 595 &rtc_clk,
622}; 596};
623 597
624int __init mxc_clocks_init(unsigned long fref) 598int __init mx1_clocks_init(unsigned long fref)
625{ 599{
626 struct clk **clkp; 600 struct clk **clkp;
627 unsigned int reg; 601 unsigned int reg;
@@ -652,5 +626,7 @@ int __init mxc_clocks_init(unsigned long fref)
652 clk_enable(&hclk); 626 clk_enable(&hclk);
653 clk_enable(&fclk); 627 clk_enable(&fclk);
654 628
629 mxc_timer_init(&gpt_clk);
630
655 return 0; 631 return 0;
656} 632}
diff --git a/arch/arm/mach-mx1/devices.c b/arch/arm/mach-mx1/devices.c
index 686d8d2dbb24..97f42d96d7a1 100644
--- a/arch/arm/mach-mx1/devices.c
+++ b/arch/arm/mach-mx1/devices.c
@@ -23,8 +23,11 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/gpio.h> 25#include <linux/gpio.h>
26#include <mach/irqs.h>
26#include <mach/hardware.h> 27#include <mach/hardware.h>
27 28
29#include "devices.h"
30
28static struct resource imx_csi_resources[] = { 31static struct resource imx_csi_resources[] = {
29 [0] = { 32 [0] = {
30 .start = 0x00224000, 33 .start = 0x00224000,
diff --git a/arch/arm/mach-mx1/mx1ads.c b/arch/arm/mach-mx1/mx1ads.c
index 2e4b185fe4a9..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,7 +26,11 @@
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>
27#include <mach/iomux-mx1-mx2.h> 29#include <mach/irqs.h>
30#ifdef CONFIG_I2C_IMX
31#include <mach/i2c.h>
32#endif
33#include <mach/iomux.h>
28#include "devices.h" 34#include "devices.h"
29 35
30/* 36/*
@@ -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
117static int i2c_pins[] = {
118 PA15_PF_I2C_SDA,
119 PA16_PF_I2C_SCL,
120};
121
122static int i2c_init(struct device *dev)
123{
124 return mxc_gpio_setup_multiple_pins(i2c_pins,
125 ARRAY_SIZE(i2c_pins), "I2C");
126}
127
128static void i2c_exit(struct device *dev)
129{
130 mxc_gpio_release_multiple_pins(i2c_pins,
131 ARRAY_SIZE(i2c_pins));
132}
133
134static struct pcf857x_platform_data pcf857x_data[] = {
135 {
136 .gpio_base = 4 * 32,
137 }, {
138 .gpio_base = 4 * 32 + 16,
139 }
140};
141
142static struct imxi2c_platform_data mx1ads_i2c_data = {
143 .bitrate = 100000,
144 .init = i2c_init,
145 .exit = i2c_exit,
146};
147
148static 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 */
109static void __init mx1ads_init(void) 164static void __init mx1ads_init(void)
@@ -114,12 +169,19 @@ 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
119static void __init mx1ads_timer_init(void) 182static void __init mx1ads_timer_init(void)
120{ 183{
121 mxc_clocks_init(32000); 184 mx1_clocks_init(32000);
122 mxc_timer_init("gpt_clk");
123} 185}
124 186
125struct sys_timer mx1ads_timer = { 187struct sys_timer mx1ads_timer = {
diff --git a/arch/arm/mach-mx1/scb9328.c b/arch/arm/mach-mx1/scb9328.c
new file mode 100644
index 000000000000..0e71f3fa28bf
--- /dev/null
+++ b/arch/arm/mach-mx1/scb9328.c
@@ -0,0 +1,160 @@
1/*
2 * linux/arch/arm/mach-mx1/scb9328.c
3 *
4 * Copyright (c) 2004 Sascha Hauer <saschahauer@web.de>
5 * Copyright (c) 2006-2008 Juergen Beisert <jbeisert@netscape.net>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 */
12
13#include <linux/platform_device.h>
14#include <linux/mtd/physmap.h>
15#include <linux/interrupt.h>
16#include <linux/dm9000.h>
17
18#include <asm/mach-types.h>
19#include <asm/mach/arch.h>
20#include <asm/mach/time.h>
21
22#include <mach/common.h>
23#include <mach/hardware.h>
24#include <mach/irqs.h>
25#include <mach/imx-uart.h>
26#include <mach/iomux.h>
27
28#include "devices.h"
29
30/*
31 * This scb9328 has a 32MiB flash
32 */
33static struct resource flash_resource = {
34 .start = IMX_CS0_PHYS,
35 .end = IMX_CS0_PHYS + (32 * 1024 * 1024) - 1,
36 .flags = IORESOURCE_MEM,
37};
38
39static struct physmap_flash_data scb_flash_data = {
40 .width = 2,
41};
42
43static struct platform_device scb_flash_device = {
44 .name = "physmap-flash",
45 .id = 0,
46 .dev = {
47 .platform_data = &scb_flash_data,
48 },
49 .resource = &flash_resource,
50 .num_resources = 1,
51};
52
53/*
54 * scb9328 has a DM9000 network controller
55 * connected to CS5, with 16 bit data path
56 * and interrupt connected to GPIO 3
57 */
58
59/*
60 * internal datapath is fixed 16 bit
61 */
62static struct dm9000_plat_data dm9000_platdata = {
63 .flags = DM9000_PLATF_16BITONLY,
64};
65
66/*
67 * the DM9000 drivers wants two defined address spaces
68 * to gain access to address latch registers and the data path.
69 */
70static struct resource dm9000x_resources[] = {
71 [0] = {
72 .name = "address area",
73 .start = IMX_CS5_PHYS,
74 .end = IMX_CS5_PHYS + 1,
75 .flags = IORESOURCE_MEM /* address access */
76 },
77 [1] = {
78 .name = "data area",
79 .start = IMX_CS5_PHYS + 4,
80 .end = IMX_CS5_PHYS + 5,
81 .flags = IORESOURCE_MEM /* data access */
82 },
83 [2] = {
84 .start = IRQ_GPIOC(3),
85 .end = IRQ_GPIOC(3),
86 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL
87 },
88};
89
90static struct platform_device dm9000x_device = {
91 .name = "dm9000",
92 .id = 0,
93 .num_resources = ARRAY_SIZE(dm9000x_resources),
94 .resource = dm9000x_resources,
95 .dev = {
96 .platform_data = &dm9000_platdata,
97 }
98};
99
100static int mxc_uart1_pins[] = {
101 PC9_PF_UART1_CTS,
102 PC10_PF_UART1_RTS,
103 PC11_PF_UART1_TXD,
104 PC12_PF_UART1_RXD,
105};
106
107static int uart1_mxc_init(struct platform_device *pdev)
108{
109 return mxc_gpio_setup_multiple_pins(mxc_uart1_pins,
110 ARRAY_SIZE(mxc_uart1_pins), "UART1");
111}
112
113static int uart1_mxc_exit(struct platform_device *pdev)
114{
115 mxc_gpio_release_multiple_pins(mxc_uart1_pins,
116 ARRAY_SIZE(mxc_uart1_pins));
117 return 0;
118}
119
120static struct imxuart_platform_data uart_pdata = {
121 .init = uart1_mxc_init,
122 .exit = uart1_mxc_exit,
123 .flags = IMXUART_HAVE_RTSCTS,
124};
125
126static struct platform_device *devices[] __initdata = {
127 &scb_flash_device,
128 &dm9000x_device,
129};
130
131/*
132 * scb9328_init - Init the CPU card itself
133 */
134static void __init scb9328_init(void)
135{
136 mxc_register_device(&imx_uart1_device, &uart_pdata);
137
138 printk(KERN_INFO"Scb9328: Adding devices\n");
139 platform_add_devices(devices, ARRAY_SIZE(devices));
140}
141
142static void __init scb9328_timer_init(void)
143{
144 mx1_clocks_init(32000);
145}
146
147static struct sys_timer scb9328_timer = {
148 .init = scb9328_timer_init,
149};
150
151MACHINE_START(SCB9328, "Synertronixx scb9328")
152 /* Sascha Hauer */
153 .phys_io = 0x00200000,
154 .io_pg_offst = ((0xe0200000) >> 18) & 0xfffc,
155 .boot_params = 0x08000100,
156 .map_io = mxc_map_io,
157 .init_irq = mxc_init_irq,
158 .timer = &scb9328_timer,
159 .init_machine = scb9328_init,
160MACHINE_END
diff --git a/arch/arm/mach-mx2/Kconfig b/arch/arm/mach-mx2/Kconfig
index 1eaa97cb716d..42a788842f49 100644
--- a/arch/arm/mach-mx2/Kconfig
+++ b/arch/arm/mach-mx2/Kconfig
@@ -1,14 +1,22 @@
1comment "MX2 family CPU support" 1if ARCH_MX2
2 depends on ARCH_MX2 2
3choice
4 prompt "CPUs:"
5 default MACH_MX21
6
7config MACH_MX21
8 bool "i.MX21 support"
9 help
10 This enables support for Freescale's MX2 based i.MX21 processor.
3 11
4config MACH_MX27 12config MACH_MX27
5 bool "i.MX27 support" 13 bool "i.MX27 support"
6 depends on ARCH_MX2
7 help 14 help
8 This enables support for Freescale's MX2 based i.MX27 processor. 15 This enables support for Freescale's MX2 based i.MX27 processor.
9 16
10comment "MX2 Platforms" 17endchoice
11 depends on ARCH_MX2 18
19comment "MX2 platforms:"
12 20
13config MACH_MX27ADS 21config MACH_MX27ADS
14 bool "MX27ADS platform" 22 bool "MX27ADS platform"
@@ -37,3 +45,5 @@ config MACH_PCM970_BASEBOARD
37 PCM970 evaluation board. 45 PCM970 evaluation board.
38 46
39endchoice 47endchoice
48
49endif
diff --git a/arch/arm/mach-mx2/Makefile b/arch/arm/mach-mx2/Makefile
index 382d86080e86..6e1a2bffc812 100644
--- a/arch/arm/mach-mx2/Makefile
+++ b/arch/arm/mach-mx2/Makefile
@@ -6,6 +6,8 @@
6 6
7obj-y := system.o generic.o devices.o serial.o 7obj-y := system.o generic.o devices.o serial.o
8 8
9obj-$(CONFIG_MACH_MX21) += clock_imx21.o
10
9obj-$(CONFIG_MACH_MX27) += cpu_imx27.o 11obj-$(CONFIG_MACH_MX27) += cpu_imx27.o
10obj-$(CONFIG_MACH_MX27) += clock_imx27.o 12obj-$(CONFIG_MACH_MX27) += clock_imx27.o
11 13
diff --git a/arch/arm/mach-mx2/Makefile.boot b/arch/arm/mach-mx2/Makefile.boot
index 696831dcd485..e867398a8fdb 100644
--- a/arch/arm/mach-mx2/Makefile.boot
+++ b/arch/arm/mach-mx2/Makefile.boot
@@ -1,3 +1,7 @@
1 zreladdr-y := 0xA0008000 1zreladdr-$(CONFIG_MACH_MX21) := 0xC0008000
2params_phys-y := 0xA0000100 2params_phys-$(CONFIG_MACH_MX21) := 0xC0000100
3initrd_phys-y := 0xA0800000 3initrd_phys-$(CONFIG_MACH_MX21) := 0xC0800000
4
5zreladdr-$(CONFIG_MACH_MX27) := 0xA0008000
6params_phys-$(CONFIG_MACH_MX27) := 0xA0000100
7initrd_phys-$(CONFIG_MACH_MX27) := 0xA0800000
diff --git a/arch/arm/mach-mx2/clock_imx21.c b/arch/arm/mach-mx2/clock_imx21.c
new file mode 100644
index 000000000000..2dee5c87614c
--- /dev/null
+++ b/arch/arm/mach-mx2/clock_imx21.c
@@ -0,0 +1,984 @@
1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
4 * Copyright 2008 Martin Fuzzey, mfuzzey@gmail.com
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 * MA 02110-1301, USA.
19 */
20
21#include <linux/clk.h>
22#include <linux/io.h>
23#include <linux/module.h>
24
25#include <mach/clock.h>
26#include <mach/common.h>
27#include <asm/clkdev.h>
28#include <asm/div64.h>
29
30#include "crm_regs.h"
31
32static int _clk_enable(struct clk *clk)
33{
34 u32 reg;
35
36 reg = __raw_readl(clk->enable_reg);
37 reg |= 1 << clk->enable_shift;
38 __raw_writel(reg, clk->enable_reg);
39 return 0;
40}
41
42static void _clk_disable(struct clk *clk)
43{
44 u32 reg;
45
46 reg = __raw_readl(clk->enable_reg);
47 reg &= ~(1 << clk->enable_shift);
48 __raw_writel(reg, clk->enable_reg);
49}
50
51static int _clk_spll_enable(struct clk *clk)
52{
53 u32 reg;
54
55 reg = __raw_readl(CCM_CSCR);
56 reg |= CCM_CSCR_SPEN;
57 __raw_writel(reg, CCM_CSCR);
58
59 while ((__raw_readl(CCM_SPCTL1) & CCM_SPCTL1_LF) == 0)
60 ;
61 return 0;
62}
63
64static void _clk_spll_disable(struct clk *clk)
65{
66 u32 reg;
67
68 reg = __raw_readl(CCM_CSCR);
69 reg &= ~CCM_CSCR_SPEN;
70 __raw_writel(reg, CCM_CSCR);
71}
72
73
74#define CSCR() (__raw_readl(CCM_CSCR))
75#define PCDR0() (__raw_readl(CCM_PCDR0))
76#define PCDR1() (__raw_readl(CCM_PCDR1))
77
78static unsigned long _clk_perclkx_round_rate(struct clk *clk,
79 unsigned long rate)
80{
81 u32 div;
82 unsigned long parent_rate;
83
84 parent_rate = clk_get_rate(clk->parent);
85
86 div = parent_rate / rate;
87 if (parent_rate % rate)
88 div++;
89
90 if (div > 64)
91 div = 64;
92
93 return parent_rate / div;
94}
95
96static int _clk_perclkx_set_rate(struct clk *clk, unsigned long rate)
97{
98 u32 reg;
99 u32 div;
100 unsigned long parent_rate;
101
102 parent_rate = clk_get_rate(clk->parent);
103
104 if (clk->id < 0 || clk->id > 3)
105 return -EINVAL;
106
107 div = parent_rate / rate;
108 if (div > 64 || div < 1 || ((parent_rate / div) != rate))
109 return -EINVAL;
110 div--;
111
112 reg =
113 __raw_readl(CCM_PCDR1) & ~(CCM_PCDR1_PERDIV1_MASK <<
114 (clk->id << 3));
115 reg |= div << (clk->id << 3);
116 __raw_writel(reg, CCM_PCDR1);
117
118 return 0;
119}
120
121static unsigned long _clk_usb_recalc(struct clk *clk)
122{
123 unsigned long usb_pdf;
124 unsigned long parent_rate;
125
126 parent_rate = clk_get_rate(clk->parent);
127
128 usb_pdf = (CSCR() & CCM_CSCR_USB_MASK) >> CCM_CSCR_USB_OFFSET;
129
130 return parent_rate / (usb_pdf + 1U);
131}
132
133static unsigned long _clk_ssix_recalc(struct clk *clk, unsigned long pdf)
134{
135 unsigned long parent_rate;
136
137 parent_rate = clk_get_rate(clk->parent);
138
139 pdf = (pdf < 2) ? 124UL : pdf; /* MX21 & MX27 TO1 */
140
141 return 2UL * parent_rate / pdf;
142}
143
144static unsigned long _clk_ssi1_recalc(struct clk *clk)
145{
146 return _clk_ssix_recalc(clk,
147 (PCDR0() & CCM_PCDR0_SSI1BAUDDIV_MASK)
148 >> CCM_PCDR0_SSI1BAUDDIV_OFFSET);
149}
150
151static unsigned long _clk_ssi2_recalc(struct clk *clk)
152{
153 return _clk_ssix_recalc(clk,
154 (PCDR0() & CCM_PCDR0_SSI2BAUDDIV_MASK) >>
155 CCM_PCDR0_SSI2BAUDDIV_OFFSET);
156}
157
158static unsigned long _clk_nfc_recalc(struct clk *clk)
159{
160 unsigned long nfc_pdf;
161 unsigned long parent_rate;
162
163 parent_rate = clk_get_rate(clk->parent);
164
165 nfc_pdf = (PCDR0() & CCM_PCDR0_NFCDIV_MASK)
166 >> CCM_PCDR0_NFCDIV_OFFSET;
167
168 return parent_rate / (nfc_pdf + 1);
169}
170
171static unsigned long _clk_parent_round_rate(struct clk *clk, unsigned long rate)
172{
173 return clk->parent->round_rate(clk->parent, rate);
174}
175
176static int _clk_parent_set_rate(struct clk *clk, unsigned long rate)
177{
178 return clk->parent->set_rate(clk->parent, rate);
179}
180
181static unsigned long external_high_reference; /* in Hz */
182
183static unsigned long get_high_reference_clock_rate(struct clk *clk)
184{
185 return external_high_reference;
186}
187
188/*
189 * the high frequency external clock reference
190 * Default case is 26MHz.
191 */
192static struct clk ckih_clk = {
193 .get_rate = get_high_reference_clock_rate,
194};
195
196static unsigned long external_low_reference; /* in Hz */
197
198static unsigned long get_low_reference_clock_rate(struct clk *clk)
199{
200 return external_low_reference;
201}
202
203/*
204 * the low frequency external clock reference
205 * Default case is 32.768kHz.
206 */
207static struct clk ckil_clk = {
208 .get_rate = get_low_reference_clock_rate,
209};
210
211
212static unsigned long _clk_fpm_recalc(struct clk *clk)
213{
214 return clk_get_rate(clk->parent) * 512;
215}
216
217/* Output of frequency pre multiplier */
218static struct clk fpm_clk = {
219 .parent = &ckil_clk,
220 .get_rate = _clk_fpm_recalc,
221};
222
223static unsigned long get_mpll_clk(struct clk *clk)
224{
225 uint32_t reg;
226 unsigned long ref_clk;
227 unsigned long mfi = 0, mfn = 0, mfd = 0, pdf = 0;
228 unsigned long long temp;
229
230 ref_clk = clk_get_rate(clk->parent);
231
232 reg = __raw_readl(CCM_MPCTL0);
233 pdf = (reg & CCM_MPCTL0_PD_MASK) >> CCM_MPCTL0_PD_OFFSET;
234 mfd = (reg & CCM_MPCTL0_MFD_MASK) >> CCM_MPCTL0_MFD_OFFSET;
235 mfi = (reg & CCM_MPCTL0_MFI_MASK) >> CCM_MPCTL0_MFI_OFFSET;
236 mfn = (reg & CCM_MPCTL0_MFN_MASK) >> CCM_MPCTL0_MFN_OFFSET;
237
238 mfi = (mfi <= 5) ? 5 : mfi;
239 temp = 2LL * ref_clk * mfn;
240 do_div(temp, mfd + 1);
241 temp = 2LL * ref_clk * mfi + temp;
242 do_div(temp, pdf + 1);
243
244 return (unsigned long)temp;
245}
246
247static struct clk mpll_clk = {
248 .parent = &ckih_clk,
249 .get_rate = get_mpll_clk,
250};
251
252static unsigned long _clk_fclk_get_rate(struct clk *clk)
253{
254 unsigned long parent_rate;
255 u32 div;
256
257 div = (CSCR() & CCM_CSCR_PRESC_MASK) >> CCM_CSCR_PRESC_OFFSET;
258 parent_rate = clk_get_rate(clk->parent);
259
260 return parent_rate / (div+1);
261}
262
263static struct clk fclk_clk = {
264 .parent = &mpll_clk,
265 .get_rate = _clk_fclk_get_rate
266};
267
268static unsigned long get_spll_clk(struct clk *clk)
269{
270 uint32_t reg;
271 unsigned long ref_clk;
272 unsigned long mfi = 0, mfn = 0, mfd = 0, pdf = 0;
273 unsigned long long temp;
274
275 ref_clk = clk_get_rate(clk->parent);
276
277 reg = __raw_readl(CCM_SPCTL0);
278 pdf = (reg & CCM_SPCTL0_PD_MASK) >> CCM_SPCTL0_PD_OFFSET;
279 mfd = (reg & CCM_SPCTL0_MFD_MASK) >> CCM_SPCTL0_MFD_OFFSET;
280 mfi = (reg & CCM_SPCTL0_MFI_MASK) >> CCM_SPCTL0_MFI_OFFSET;
281 mfn = (reg & CCM_SPCTL0_MFN_MASK) >> CCM_SPCTL0_MFN_OFFSET;
282
283 mfi = (mfi <= 5) ? 5 : mfi;
284 temp = 2LL * ref_clk * mfn;
285 do_div(temp, mfd + 1);
286 temp = 2LL * ref_clk * mfi + temp;
287 do_div(temp, pdf + 1);
288
289 return (unsigned long)temp;
290}
291
292static struct clk spll_clk = {
293 .parent = &ckih_clk,
294 .get_rate = get_spll_clk,
295 .enable = _clk_spll_enable,
296 .disable = _clk_spll_disable,
297};
298
299static unsigned long get_hclk_clk(struct clk *clk)
300{
301 unsigned long rate;
302 unsigned long bclk_pdf;
303
304 bclk_pdf = (CSCR() & CCM_CSCR_BCLK_MASK)
305 >> CCM_CSCR_BCLK_OFFSET;
306
307 rate = clk_get_rate(clk->parent);
308 return rate / (bclk_pdf + 1);
309}
310
311static struct clk hclk_clk = {
312 .parent = &fclk_clk,
313 .get_rate = get_hclk_clk,
314};
315
316static unsigned long get_ipg_clk(struct clk *clk)
317{
318 unsigned long rate;
319 unsigned long ipg_pdf;
320
321 ipg_pdf = (CSCR() & CCM_CSCR_IPDIV) >> CCM_CSCR_IPDIV_OFFSET;
322
323 rate = clk_get_rate(clk->parent);
324 return rate / (ipg_pdf + 1);
325}
326
327static struct clk ipg_clk = {
328 .parent = &hclk_clk,
329 .get_rate = get_ipg_clk,
330};
331
332static unsigned long _clk_perclkx_recalc(struct clk *clk)
333{
334 unsigned long perclk_pdf;
335 unsigned long parent_rate;
336
337 parent_rate = clk_get_rate(clk->parent);
338
339 if (clk->id < 0 || clk->id > 3)
340 return 0;
341
342 perclk_pdf = (PCDR1() >> (clk->id << 3)) & CCM_PCDR1_PERDIV1_MASK;
343
344 return parent_rate / (perclk_pdf + 1);
345}
346
347static struct clk per_clk[] = {
348 {
349 .id = 0,
350 .parent = &mpll_clk,
351 .get_rate = _clk_perclkx_recalc,
352 }, {
353 .id = 1,
354 .parent = &mpll_clk,
355 .get_rate = _clk_perclkx_recalc,
356 }, {
357 .id = 2,
358 .parent = &mpll_clk,
359 .round_rate = _clk_perclkx_round_rate,
360 .set_rate = _clk_perclkx_set_rate,
361 .get_rate = _clk_perclkx_recalc,
362 /* Enable/Disable done via lcd_clkc[1] */
363 }, {
364 .id = 3,
365 .parent = &mpll_clk,
366 .round_rate = _clk_perclkx_round_rate,
367 .set_rate = _clk_perclkx_set_rate,
368 .get_rate = _clk_perclkx_recalc,
369 /* Enable/Disable done via csi_clk[1] */
370 },
371};
372
373static struct clk uart_ipg_clk[];
374
375static struct clk uart_clk[] = {
376 {
377 .id = 0,
378 .parent = &per_clk[0],
379 .secondary = &uart_ipg_clk[0],
380 }, {
381 .id = 1,
382 .parent = &per_clk[0],
383 .secondary = &uart_ipg_clk[1],
384 }, {
385 .id = 2,
386 .parent = &per_clk[0],
387 .secondary = &uart_ipg_clk[2],
388 }, {
389 .id = 3,
390 .parent = &per_clk[0],
391 .secondary = &uart_ipg_clk[3],
392 },
393};
394
395static struct clk uart_ipg_clk[] = {
396 {
397 .id = 0,
398 .parent = &ipg_clk,
399 .enable = _clk_enable,
400 .enable_reg = CCM_PCCR_UART1_REG,
401 .enable_shift = CCM_PCCR_UART1_OFFSET,
402 .disable = _clk_disable,
403 }, {
404 .id = 1,
405 .parent = &ipg_clk,
406 .enable = _clk_enable,
407 .enable_reg = CCM_PCCR_UART2_REG,
408 .enable_shift = CCM_PCCR_UART2_OFFSET,
409 .disable = _clk_disable,
410 }, {
411 .id = 2,
412 .parent = &ipg_clk,
413 .enable = _clk_enable,
414 .enable_reg = CCM_PCCR_UART3_REG,
415 .enable_shift = CCM_PCCR_UART3_OFFSET,
416 .disable = _clk_disable,
417 }, {
418 .id = 3,
419 .parent = &ipg_clk,
420 .enable = _clk_enable,
421 .enable_reg = CCM_PCCR_UART4_REG,
422 .enable_shift = CCM_PCCR_UART4_OFFSET,
423 .disable = _clk_disable,
424 },
425};
426
427static struct clk gpt_ipg_clk[];
428
429static struct clk gpt_clk[] = {
430 {
431 .id = 0,
432 .parent = &per_clk[0],
433 .secondary = &gpt_ipg_clk[0],
434 }, {
435 .id = 1,
436 .parent = &per_clk[0],
437 .secondary = &gpt_ipg_clk[1],
438 }, {
439 .id = 2,
440 .parent = &per_clk[0],
441 .secondary = &gpt_ipg_clk[2],
442 },
443};
444
445static struct clk gpt_ipg_clk[] = {
446 {
447 .id = 0,
448 .parent = &ipg_clk,
449 .enable = _clk_enable,
450 .enable_reg = CCM_PCCR_GPT1_REG,
451 .enable_shift = CCM_PCCR_GPT1_OFFSET,
452 .disable = _clk_disable,
453 }, {
454 .id = 1,
455 .parent = &ipg_clk,
456 .enable = _clk_enable,
457 .enable_reg = CCM_PCCR_GPT2_REG,
458 .enable_shift = CCM_PCCR_GPT2_OFFSET,
459 .disable = _clk_disable,
460 }, {
461 .id = 2,
462 .parent = &ipg_clk,
463 .enable = _clk_enable,
464 .enable_reg = CCM_PCCR_GPT3_REG,
465 .enable_shift = CCM_PCCR_GPT3_OFFSET,
466 .disable = _clk_disable,
467 },
468};
469
470static struct clk pwm_clk[] = {
471 {
472 .parent = &per_clk[0],
473 .secondary = &pwm_clk[1],
474 }, {
475 .parent = &ipg_clk,
476 .enable = _clk_enable,
477 .enable_reg = CCM_PCCR_PWM_REG,
478 .enable_shift = CCM_PCCR_PWM_OFFSET,
479 .disable = _clk_disable,
480 },
481};
482
483static struct clk sdhc_ipg_clk[];
484
485static struct clk sdhc_clk[] = {
486 {
487 .id = 0,
488 .parent = &per_clk[1],
489 .secondary = &sdhc_ipg_clk[0],
490 }, {
491 .id = 1,
492 .parent = &per_clk[1],
493 .secondary = &sdhc_ipg_clk[1],
494 },
495};
496
497static struct clk sdhc_ipg_clk[] = {
498 {
499 .id = 0,
500 .parent = &ipg_clk,
501 .enable = _clk_enable,
502 .enable_reg = CCM_PCCR_SDHC1_REG,
503 .enable_shift = CCM_PCCR_SDHC1_OFFSET,
504 .disable = _clk_disable,
505 }, {
506 .id = 1,
507 .parent = &ipg_clk,
508 .enable = _clk_enable,
509 .enable_reg = CCM_PCCR_SDHC2_REG,
510 .enable_shift = CCM_PCCR_SDHC2_OFFSET,
511 .disable = _clk_disable,
512 },
513};
514
515static struct clk cspi_ipg_clk[];
516
517static struct clk cspi_clk[] = {
518 {
519 .id = 0,
520 .parent = &per_clk[1],
521 .secondary = &cspi_ipg_clk[0],
522 }, {
523 .id = 1,
524 .parent = &per_clk[1],
525 .secondary = &cspi_ipg_clk[1],
526 }, {
527 .id = 2,
528 .parent = &per_clk[1],
529 .secondary = &cspi_ipg_clk[2],
530 },
531};
532
533static struct clk cspi_ipg_clk[] = {
534 {
535 .id = 0,
536 .parent = &ipg_clk,
537 .enable = _clk_enable,
538 .enable_reg = CCM_PCCR_CSPI1_REG,
539 .enable_shift = CCM_PCCR_CSPI1_OFFSET,
540 .disable = _clk_disable,
541 }, {
542 .id = 1,
543 .parent = &ipg_clk,
544 .enable = _clk_enable,
545 .enable_reg = CCM_PCCR_CSPI2_REG,
546 .enable_shift = CCM_PCCR_CSPI2_OFFSET,
547 .disable = _clk_disable,
548 }, {
549 .id = 3,
550 .parent = &ipg_clk,
551 .enable = _clk_enable,
552 .enable_reg = CCM_PCCR_CSPI3_REG,
553 .enable_shift = CCM_PCCR_CSPI3_OFFSET,
554 .disable = _clk_disable,
555 },
556};
557
558static struct clk lcdc_clk[] = {
559 {
560 .parent = &per_clk[2],
561 .secondary = &lcdc_clk[1],
562 .round_rate = _clk_parent_round_rate,
563 .set_rate = _clk_parent_set_rate,
564 }, {
565 .parent = &ipg_clk,
566 .secondary = &lcdc_clk[2],
567 .enable = _clk_enable,
568 .enable_reg = CCM_PCCR_LCDC_REG,
569 .enable_shift = CCM_PCCR_LCDC_OFFSET,
570 .disable = _clk_disable,
571 }, {
572 .parent = &hclk_clk,
573 .enable = _clk_enable,
574 .enable_reg = CCM_PCCR_HCLK_LCDC_REG,
575 .enable_shift = CCM_PCCR_HCLK_LCDC_OFFSET,
576 .disable = _clk_disable,
577 },
578};
579
580static struct clk csi_clk[] = {
581 {
582 .parent = &per_clk[3],
583 .secondary = &csi_clk[1],
584 .round_rate = _clk_parent_round_rate,
585 .set_rate = _clk_parent_set_rate,
586 }, {
587 .parent = &hclk_clk,
588 .enable = _clk_enable,
589 .enable_reg = CCM_PCCR_HCLK_CSI_REG,
590 .enable_shift = CCM_PCCR_HCLK_CSI_OFFSET,
591 .disable = _clk_disable,
592 },
593};
594
595static struct clk usb_clk[] = {
596 {
597 .parent = &spll_clk,
598 .get_rate = _clk_usb_recalc,
599 .enable = _clk_enable,
600 .enable_reg = CCM_PCCR_USBOTG_REG,
601 .enable_shift = CCM_PCCR_USBOTG_OFFSET,
602 .disable = _clk_disable,
603 }, {
604 .parent = &hclk_clk,
605 .enable = _clk_enable,
606 .enable_reg = CCM_PCCR_HCLK_USBOTG_REG,
607 .enable_shift = CCM_PCCR_HCLK_USBOTG_OFFSET,
608 .disable = _clk_disable,
609 }
610};
611
612static struct clk ssi_ipg_clk[];
613
614static struct clk ssi_clk[] = {
615 {
616 .id = 0,
617 .parent = &mpll_clk,
618 .secondary = &ssi_ipg_clk[0],
619 .get_rate = _clk_ssi1_recalc,
620 .enable = _clk_enable,
621 .enable_reg = CCM_PCCR_SSI1_BAUD_REG,
622 .enable_shift = CCM_PCCR_SSI1_BAUD_OFFSET,
623 .disable = _clk_disable,
624 }, {
625 .id = 1,
626 .parent = &mpll_clk,
627 .secondary = &ssi_ipg_clk[1],
628 .get_rate = _clk_ssi2_recalc,
629 .enable = _clk_enable,
630 .enable_reg = CCM_PCCR_SSI2_BAUD_REG,
631 .enable_shift = CCM_PCCR_SSI2_BAUD_OFFSET,
632 .disable = _clk_disable,
633 },
634};
635
636static struct clk ssi_ipg_clk[] = {
637 {
638 .id = 0,
639 .parent = &ipg_clk,
640 .enable = _clk_enable,
641 .enable_reg = CCM_PCCR_SSI1_REG,
642 .enable_shift = CCM_PCCR_SSI1_IPG_OFFSET,
643 .disable = _clk_disable,
644 }, {
645 .id = 1,
646 .parent = &ipg_clk,
647 .enable = _clk_enable,
648 .enable_reg = CCM_PCCR_SSI2_REG,
649 .enable_shift = CCM_PCCR_SSI2_IPG_OFFSET,
650 .disable = _clk_disable,
651 },
652};
653
654
655static struct clk nfc_clk = {
656 .parent = &fclk_clk,
657 .get_rate = _clk_nfc_recalc,
658 .enable = _clk_enable,
659 .enable_reg = CCM_PCCR_NFC_REG,
660 .enable_shift = CCM_PCCR_NFC_OFFSET,
661 .disable = _clk_disable,
662};
663
664static struct clk dma_clk[] = {
665 {
666 .parent = &hclk_clk,
667 .enable = _clk_enable,
668 .enable_reg = CCM_PCCR_DMA_REG,
669 .enable_shift = CCM_PCCR_DMA_OFFSET,
670 .disable = _clk_disable,
671 .secondary = &dma_clk[1],
672 }, {
673 .enable = _clk_enable,
674 .enable_reg = CCM_PCCR_HCLK_DMA_REG,
675 .enable_shift = CCM_PCCR_HCLK_DMA_OFFSET,
676 .disable = _clk_disable,
677 },
678};
679
680static struct clk brom_clk = {
681 .parent = &hclk_clk,
682 .enable = _clk_enable,
683 .enable_reg = CCM_PCCR_HCLK_BROM_REG,
684 .enable_shift = CCM_PCCR_HCLK_BROM_OFFSET,
685 .disable = _clk_disable,
686};
687
688static struct clk emma_clk[] = {
689 {
690 .parent = &hclk_clk,
691 .enable = _clk_enable,
692 .enable_reg = CCM_PCCR_EMMA_REG,
693 .enable_shift = CCM_PCCR_EMMA_OFFSET,
694 .disable = _clk_disable,
695 .secondary = &emma_clk[1],
696 }, {
697 .enable = _clk_enable,
698 .enable_reg = CCM_PCCR_HCLK_EMMA_REG,
699 .enable_shift = CCM_PCCR_HCLK_EMMA_OFFSET,
700 .disable = _clk_disable,
701 }
702};
703
704static struct clk slcdc_clk[] = {
705 {
706 .parent = &hclk_clk,
707 .enable = _clk_enable,
708 .enable_reg = CCM_PCCR_SLCDC_REG,
709 .enable_shift = CCM_PCCR_SLCDC_OFFSET,
710 .disable = _clk_disable,
711 .secondary = &slcdc_clk[1],
712 }, {
713 .enable = _clk_enable,
714 .enable_reg = CCM_PCCR_HCLK_SLCDC_REG,
715 .enable_shift = CCM_PCCR_HCLK_SLCDC_OFFSET,
716 .disable = _clk_disable,
717 }
718};
719
720static struct clk wdog_clk = {
721 .parent = &ipg_clk,
722 .enable = _clk_enable,
723 .enable_reg = CCM_PCCR_WDT_REG,
724 .enable_shift = CCM_PCCR_WDT_OFFSET,
725 .disable = _clk_disable,
726};
727
728static struct clk gpio_clk = {
729 .parent = &ipg_clk,
730 .enable = _clk_enable,
731 .enable_reg = CCM_PCCR_GPIO_REG,
732 .enable_shift = CCM_PCCR_GPIO_OFFSET,
733 .disable = _clk_disable,
734};
735
736static struct clk i2c_clk = {
737 .id = 0,
738 .parent = &ipg_clk,
739 .enable = _clk_enable,
740 .enable_reg = CCM_PCCR_I2C1_REG,
741 .enable_shift = CCM_PCCR_I2C1_OFFSET,
742 .disable = _clk_disable,
743};
744
745static struct clk kpp_clk = {
746 .parent = &ipg_clk,
747 .enable = _clk_enable,
748 .enable_reg = CCM_PCCR_KPP_REG,
749 .enable_shift = CCM_PCCR_KPP_OFFSET,
750 .disable = _clk_disable,
751};
752
753static struct clk owire_clk = {
754 .parent = &ipg_clk,
755 .enable = _clk_enable,
756 .enable_reg = CCM_PCCR_OWIRE_REG,
757 .enable_shift = CCM_PCCR_OWIRE_OFFSET,
758 .disable = _clk_disable,
759};
760
761static struct clk rtc_clk = {
762 .parent = &ipg_clk,
763 .enable = _clk_enable,
764 .enable_reg = CCM_PCCR_RTC_REG,
765 .enable_shift = CCM_PCCR_RTC_OFFSET,
766 .disable = _clk_disable,
767};
768
769static unsigned long _clk_clko_round_rate(struct clk *clk, unsigned long rate)
770{
771 u32 div;
772 unsigned long parent_rate;
773
774 parent_rate = clk_get_rate(clk->parent);
775 div = parent_rate / rate;
776 if (parent_rate % rate)
777 div++;
778
779 if (div > 8)
780 div = 8;
781
782 return parent_rate / div;
783}
784
785static int _clk_clko_set_rate(struct clk *clk, unsigned long rate)
786{
787 u32 reg;
788 u32 div;
789 unsigned long parent_rate;
790
791 parent_rate = clk_get_rate(clk->parent);
792
793 div = parent_rate / rate;
794
795 if (div > 8 || div < 1 || ((parent_rate / div) != rate))
796 return -EINVAL;
797 div--;
798
799 reg = __raw_readl(CCM_PCDR0);
800
801 if (clk->parent == &usb_clk[0]) {
802 reg &= ~CCM_PCDR0_48MDIV_MASK;
803 reg |= div << CCM_PCDR0_48MDIV_OFFSET;
804 }
805 __raw_writel(reg, CCM_PCDR0);
806
807 return 0;
808}
809
810static unsigned long _clk_clko_recalc(struct clk *clk)
811{
812 u32 div = 0;
813 unsigned long parent_rate;
814
815 parent_rate = clk_get_rate(clk->parent);
816
817 if (clk->parent == &usb_clk[0]) /* 48M */
818 div = __raw_readl(CCM_PCDR0) & CCM_PCDR0_48MDIV_MASK
819 >> CCM_PCDR0_48MDIV_OFFSET;
820 div++;
821
822 return parent_rate / div;
823}
824
825static struct clk clko_clk;
826
827static int _clk_clko_set_parent(struct clk *clk, struct clk *parent)
828{
829 u32 reg;
830
831 reg = __raw_readl(CCM_CCSR) & ~CCM_CCSR_CLKOSEL_MASK;
832
833 if (parent == &ckil_clk)
834 reg |= 0 << CCM_CCSR_CLKOSEL_OFFSET;
835 else if (parent == &fpm_clk)
836 reg |= 1 << CCM_CCSR_CLKOSEL_OFFSET;
837 else if (parent == &ckih_clk)
838 reg |= 2 << CCM_CCSR_CLKOSEL_OFFSET;
839 else if (parent == mpll_clk.parent)
840 reg |= 3 << CCM_CCSR_CLKOSEL_OFFSET;
841 else if (parent == spll_clk.parent)
842 reg |= 4 << CCM_CCSR_CLKOSEL_OFFSET;
843 else if (parent == &mpll_clk)
844 reg |= 5 << CCM_CCSR_CLKOSEL_OFFSET;
845 else if (parent == &spll_clk)
846 reg |= 6 << CCM_CCSR_CLKOSEL_OFFSET;
847 else if (parent == &fclk_clk)
848 reg |= 7 << CCM_CCSR_CLKOSEL_OFFSET;
849 else if (parent == &hclk_clk)
850 reg |= 8 << CCM_CCSR_CLKOSEL_OFFSET;
851 else if (parent == &ipg_clk)
852 reg |= 9 << CCM_CCSR_CLKOSEL_OFFSET;
853 else if (parent == &per_clk[0])
854 reg |= 0xA << CCM_CCSR_CLKOSEL_OFFSET;
855 else if (parent == &per_clk[1])
856 reg |= 0xB << CCM_CCSR_CLKOSEL_OFFSET;
857 else if (parent == &per_clk[2])
858 reg |= 0xC << CCM_CCSR_CLKOSEL_OFFSET;
859 else if (parent == &per_clk[3])
860 reg |= 0xD << CCM_CCSR_CLKOSEL_OFFSET;
861 else if (parent == &ssi_clk[0])
862 reg |= 0xE << CCM_CCSR_CLKOSEL_OFFSET;
863 else if (parent == &ssi_clk[1])
864 reg |= 0xF << CCM_CCSR_CLKOSEL_OFFSET;
865 else if (parent == &nfc_clk)
866 reg |= 0x10 << CCM_CCSR_CLKOSEL_OFFSET;
867 else if (parent == &usb_clk[0])
868 reg |= 0x14 << CCM_CCSR_CLKOSEL_OFFSET;
869 else if (parent == &clko_clk)
870 reg |= 0x15 << CCM_CCSR_CLKOSEL_OFFSET;
871 else
872 return -EINVAL;
873
874 __raw_writel(reg, CCM_CCSR);
875
876 return 0;
877}
878
879static struct clk clko_clk = {
880 .get_rate = _clk_clko_recalc,
881 .set_rate = _clk_clko_set_rate,
882 .round_rate = _clk_clko_round_rate,
883 .set_parent = _clk_clko_set_parent,
884};
885
886
887#define _REGISTER_CLOCK(d, n, c) \
888 { \
889 .dev_id = d, \
890 .con_id = n, \
891 .clk = &c, \
892 },
893static struct clk_lookup lookups[] __initdata = {
894/* It's unlikely that any driver wants one of them directly:
895 _REGISTER_CLOCK(NULL, "ckih", ckih_clk)
896 _REGISTER_CLOCK(NULL, "ckil", ckil_clk)
897 _REGISTER_CLOCK(NULL, "fpm", fpm_clk)
898 _REGISTER_CLOCK(NULL, "mpll", mpll_clk)
899 _REGISTER_CLOCK(NULL, "spll", spll_clk)
900 _REGISTER_CLOCK(NULL, "fclk", fclk_clk)
901 _REGISTER_CLOCK(NULL, "hclk", hclk_clk)
902 _REGISTER_CLOCK(NULL, "ipg", ipg_clk)
903*/
904 _REGISTER_CLOCK(NULL, "perclk1", per_clk[0])
905 _REGISTER_CLOCK(NULL, "perclk2", per_clk[1])
906 _REGISTER_CLOCK(NULL, "perclk3", per_clk[2])
907 _REGISTER_CLOCK(NULL, "perclk4", per_clk[3])
908 _REGISTER_CLOCK(NULL, "clko", clko_clk)
909 _REGISTER_CLOCK("imx-uart.0", NULL, uart_clk[0])
910 _REGISTER_CLOCK("imx-uart.1", NULL, uart_clk[1])
911 _REGISTER_CLOCK("imx-uart.2", NULL, uart_clk[2])
912 _REGISTER_CLOCK("imx-uart.3", NULL, uart_clk[3])
913 _REGISTER_CLOCK(NULL, "gpt1", gpt_clk[0])
914 _REGISTER_CLOCK(NULL, "gpt1", gpt_clk[1])
915 _REGISTER_CLOCK(NULL, "gpt1", gpt_clk[2])
916 _REGISTER_CLOCK(NULL, "pwm", pwm_clk[0])
917 _REGISTER_CLOCK(NULL, "sdhc1", sdhc_clk[0])
918 _REGISTER_CLOCK(NULL, "sdhc2", sdhc_clk[1])
919 _REGISTER_CLOCK(NULL, "cspi1", cspi_clk[0])
920 _REGISTER_CLOCK(NULL, "cspi2", cspi_clk[1])
921 _REGISTER_CLOCK(NULL, "cspi3", cspi_clk[2])
922 _REGISTER_CLOCK(NULL, "lcdc", lcdc_clk[0])
923 _REGISTER_CLOCK(NULL, "csi", csi_clk[0])
924 _REGISTER_CLOCK(NULL, "usb", usb_clk[0])
925 _REGISTER_CLOCK(NULL, "ssi1", ssi_clk[0])
926 _REGISTER_CLOCK(NULL, "ssi2", ssi_clk[1])
927 _REGISTER_CLOCK(NULL, "nfc", nfc_clk)
928 _REGISTER_CLOCK(NULL, "dma", dma_clk[0])
929 _REGISTER_CLOCK(NULL, "brom", brom_clk)
930 _REGISTER_CLOCK(NULL, "emma", emma_clk[0])
931 _REGISTER_CLOCK(NULL, "slcdc", slcdc_clk[0])
932 _REGISTER_CLOCK(NULL, "wdog", wdog_clk)
933 _REGISTER_CLOCK(NULL, "gpio", gpio_clk)
934 _REGISTER_CLOCK(NULL, "i2c", i2c_clk)
935 _REGISTER_CLOCK("mxc-keypad", NULL, kpp_clk)
936 _REGISTER_CLOCK(NULL, "owire", owire_clk)
937 _REGISTER_CLOCK(NULL, "rtc", rtc_clk)
938};
939
940/*
941 * must be called very early to get information about the
942 * available clock rate when the timer framework starts
943 */
944int __init mx21_clocks_init(unsigned long lref, unsigned long href)
945{
946 int i;
947 u32 cscr;
948
949 external_low_reference = lref;
950 external_high_reference = href;
951
952 /* detect clock reference for both system PLL */
953 cscr = CSCR();
954 if (cscr & CCM_CSCR_MCU)
955 mpll_clk.parent = &ckih_clk;
956 else
957 mpll_clk.parent = &fpm_clk;
958
959 if (cscr & CCM_CSCR_SP)
960 spll_clk.parent = &ckih_clk;
961 else
962 spll_clk.parent = &fpm_clk;
963
964 for (i = 0; i < ARRAY_SIZE(lookups); i++)
965 clkdev_add(&lookups[i]);
966
967 /* Turn off all clock gates */
968 __raw_writel(0, CCM_PCCR0);
969 __raw_writel(CCM_PCCR_GPT1_MASK, CCM_PCCR1);
970
971 /* This turns of the serial PLL as well */
972 spll_clk.disable(&spll_clk);
973
974 /* This will propagate to all children and init all the clock rates. */
975 clk_enable(&per_clk[0]);
976 clk_enable(&gpio_clk);
977
978#ifdef CONFIG_DEBUG_LL_CONSOLE
979 clk_enable(&uart_clk[0]);
980#endif
981
982 mxc_timer_init(&gpt_clk[0]);
983 return 0;
984}
diff --git a/arch/arm/mach-mx2/clock_imx27.c b/arch/arm/mach-mx2/clock_imx27.c
index c69896d011a1..3f7280c490f0 100644
--- a/arch/arm/mach-mx2/clock_imx27.c
+++ b/arch/arm/mach-mx2/clock_imx27.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. 2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de 3 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
4 * Copyright 2008 Martin Fuzzey, mfuzzey@gmail.com
4 * 5 *
5 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
@@ -20,23 +21,60 @@
20#include <linux/clk.h> 21#include <linux/clk.h>
21#include <linux/io.h> 22#include <linux/io.h>
22#include <linux/module.h> 23#include <linux/module.h>
23#include <linux/spinlock.h>
24 24
25#include <mach/clock.h> 25#include <asm/clkdev.h>
26#include <mach/common.h>
27#include <asm/div64.h> 26#include <asm/div64.h>
28 27
29#include "crm_regs.h" 28#include <mach/clock.h>
30 29#include <mach/common.h>
31static struct clk ckil_clk; 30#include <mach/hardware.h>
32static struct clk mpll_clk; 31
33static struct clk mpll_main_clk[]; 32/* Register offsets */
34static struct clk spll_clk; 33#define CCM_CSCR (IO_ADDRESS(CCM_BASE_ADDR) + 0x0)
35 34#define CCM_MPCTL0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x4)
36static int _clk_enable(struct clk *clk) 35#define CCM_MPCTL1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x8)
36#define CCM_SPCTL0 (IO_ADDRESS(CCM_BASE_ADDR) + 0xC)
37#define CCM_SPCTL1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x10)
38#define CCM_OSC26MCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x14)
39#define CCM_PCDR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x18)
40#define CCM_PCDR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x1c)
41#define CCM_PCCR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x20)
42#define CCM_PCCR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x24)
43#define CCM_CCSR (IO_ADDRESS(CCM_BASE_ADDR) + 0x28)
44#define CCM_PMCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x2c)
45#define CCM_PMCOUNT (IO_ADDRESS(CCM_BASE_ADDR) + 0x30)
46#define CCM_WKGDCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x34)
47
48#define CCM_CSCR_UPDATE_DIS (1 << 31)
49#define CCM_CSCR_SSI2 (1 << 23)
50#define CCM_CSCR_SSI1 (1 << 22)
51#define CCM_CSCR_VPU (1 << 21)
52#define CCM_CSCR_MSHC (1 << 20)
53#define CCM_CSCR_SPLLRES (1 << 19)
54#define CCM_CSCR_MPLLRES (1 << 18)
55#define CCM_CSCR_SP (1 << 17)
56#define CCM_CSCR_MCU (1 << 16)
57#define CCM_CSCR_OSC26MDIV (1 << 4)
58#define CCM_CSCR_OSC26M (1 << 3)
59#define CCM_CSCR_FPM (1 << 2)
60#define CCM_CSCR_SPEN (1 << 1)
61#define CCM_CSCR_MPEN (1 << 0)
62
63/* i.MX27 TO 2+ */
64#define CCM_CSCR_ARM_SRC (1 << 15)
65
66#define CCM_SPCTL1_LF (1 << 15)
67#define CCM_SPCTL1_BRMO (1 << 6)
68
69static struct clk mpll_main1_clk, mpll_main2_clk;
70
71static int clk_pccr_enable(struct clk *clk)
37{ 72{
38 unsigned long reg; 73 unsigned long reg;
39 74
75 if (!clk->enable_reg)
76 return 0;
77
40 reg = __raw_readl(clk->enable_reg); 78 reg = __raw_readl(clk->enable_reg);
41 reg |= 1 << clk->enable_shift; 79 reg |= 1 << clk->enable_shift;
42 __raw_writel(reg, clk->enable_reg); 80 __raw_writel(reg, clk->enable_reg);
@@ -44,16 +82,19 @@ static int _clk_enable(struct clk *clk)
44 return 0; 82 return 0;
45} 83}
46 84
47static void _clk_disable(struct clk *clk) 85static void clk_pccr_disable(struct clk *clk)
48{ 86{
49 unsigned long reg; 87 unsigned long reg;
50 88
89 if (!clk->enable_reg)
90 return;
91
51 reg = __raw_readl(clk->enable_reg); 92 reg = __raw_readl(clk->enable_reg);
52 reg &= ~(1 << clk->enable_shift); 93 reg &= ~(1 << clk->enable_shift);
53 __raw_writel(reg, clk->enable_reg); 94 __raw_writel(reg, clk->enable_reg);
54} 95}
55 96
56static int _clk_spll_enable(struct clk *clk) 97static int clk_spll_enable(struct clk *clk)
57{ 98{
58 unsigned long reg; 99 unsigned long reg;
59 100
@@ -61,13 +102,12 @@ static int _clk_spll_enable(struct clk *clk)
61 reg |= CCM_CSCR_SPEN; 102 reg |= CCM_CSCR_SPEN;
62 __raw_writel(reg, CCM_CSCR); 103 __raw_writel(reg, CCM_CSCR);
63 104
64 while ((__raw_readl(CCM_SPCTL1) & CCM_SPCTL1_LF) == 0) 105 while (!(__raw_readl(CCM_SPCTL1) & CCM_SPCTL1_LF));
65 ;
66 106
67 return 0; 107 return 0;
68} 108}
69 109
70static void _clk_spll_disable(struct clk *clk) 110static void clk_spll_disable(struct clk *clk)
71{ 111{
72 unsigned long reg; 112 unsigned long reg;
73 113
@@ -76,192 +116,30 @@ static void _clk_spll_disable(struct clk *clk)
76 __raw_writel(reg, CCM_CSCR); 116 __raw_writel(reg, CCM_CSCR);
77} 117}
78 118
79static void _clk_pccr01_enable(unsigned long mask0, unsigned long mask1) 119static int clk_cpu_set_parent(struct clk *clk, struct clk *parent)
80{
81 unsigned long reg;
82
83 reg = __raw_readl(CCM_PCCR0);
84 reg |= mask0;
85 __raw_writel(reg, CCM_PCCR0);
86
87 reg = __raw_readl(CCM_PCCR1);
88 reg |= mask1;
89 __raw_writel(reg, CCM_PCCR1);
90
91}
92
93static void _clk_pccr01_disable(unsigned long mask0, unsigned long mask1)
94{
95 unsigned long reg;
96
97 reg = __raw_readl(CCM_PCCR0);
98 reg &= ~mask0;
99 __raw_writel(reg, CCM_PCCR0);
100
101 reg = __raw_readl(CCM_PCCR1);
102 reg &= ~mask1;
103 __raw_writel(reg, CCM_PCCR1);
104}
105
106static void _clk_pccr10_enable(unsigned long mask1, unsigned long mask0)
107{
108 unsigned long reg;
109
110 reg = __raw_readl(CCM_PCCR1);
111 reg |= mask1;
112 __raw_writel(reg, CCM_PCCR1);
113
114 reg = __raw_readl(CCM_PCCR0);
115 reg |= mask0;
116 __raw_writel(reg, CCM_PCCR0);
117}
118
119static void _clk_pccr10_disable(unsigned long mask1, unsigned long mask0)
120{
121 unsigned long reg;
122
123 reg = __raw_readl(CCM_PCCR1);
124 reg &= ~mask1;
125 __raw_writel(reg, CCM_PCCR1);
126
127 reg = __raw_readl(CCM_PCCR0);
128 reg &= ~mask0;
129 __raw_writel(reg, CCM_PCCR0);
130}
131
132static int _clk_dma_enable(struct clk *clk)
133{
134 _clk_pccr01_enable(CCM_PCCR0_DMA_MASK, CCM_PCCR1_HCLK_DMA_MASK);
135
136 return 0;
137}
138
139static void _clk_dma_disable(struct clk *clk)
140{
141 _clk_pccr01_disable(CCM_PCCR0_DMA_MASK, CCM_PCCR1_HCLK_DMA_MASK);
142}
143
144static int _clk_rtic_enable(struct clk *clk)
145{
146 _clk_pccr01_enable(CCM_PCCR0_RTIC_MASK, CCM_PCCR1_HCLK_RTIC_MASK);
147
148 return 0;
149}
150
151static void _clk_rtic_disable(struct clk *clk)
152{
153 _clk_pccr01_disable(CCM_PCCR0_RTIC_MASK, CCM_PCCR1_HCLK_RTIC_MASK);
154}
155
156static int _clk_emma_enable(struct clk *clk)
157{
158 _clk_pccr01_enable(CCM_PCCR0_EMMA_MASK, CCM_PCCR1_HCLK_EMMA_MASK);
159
160 return 0;
161}
162
163static void _clk_emma_disable(struct clk *clk)
164{
165 _clk_pccr01_disable(CCM_PCCR0_EMMA_MASK, CCM_PCCR1_HCLK_EMMA_MASK);
166}
167
168static int _clk_slcdc_enable(struct clk *clk)
169{
170 _clk_pccr01_enable(CCM_PCCR0_SLCDC_MASK, CCM_PCCR1_HCLK_SLCDC_MASK);
171
172 return 0;
173}
174
175static void _clk_slcdc_disable(struct clk *clk)
176{
177 _clk_pccr01_disable(CCM_PCCR0_SLCDC_MASK, CCM_PCCR1_HCLK_SLCDC_MASK);
178}
179
180static int _clk_fec_enable(struct clk *clk)
181{
182 _clk_pccr01_enable(CCM_PCCR0_FEC_MASK, CCM_PCCR1_HCLK_FEC_MASK);
183
184 return 0;
185}
186
187static void _clk_fec_disable(struct clk *clk)
188{
189 _clk_pccr01_disable(CCM_PCCR0_FEC_MASK, CCM_PCCR1_HCLK_FEC_MASK);
190}
191
192static int _clk_vpu_enable(struct clk *clk)
193{
194 unsigned long reg;
195
196 reg = __raw_readl(CCM_PCCR1);
197 reg |= CCM_PCCR1_VPU_BAUD_MASK | CCM_PCCR1_HCLK_VPU_MASK;
198 __raw_writel(reg, CCM_PCCR1);
199
200 return 0;
201}
202
203static void _clk_vpu_disable(struct clk *clk)
204{ 120{
205 unsigned long reg; 121 int cscr = __raw_readl(CCM_CSCR);
206
207 reg = __raw_readl(CCM_PCCR1);
208 reg &= ~(CCM_PCCR1_VPU_BAUD_MASK | CCM_PCCR1_HCLK_VPU_MASK);
209 __raw_writel(reg, CCM_PCCR1);
210}
211
212static int _clk_sahara2_enable(struct clk *clk)
213{
214 _clk_pccr01_enable(CCM_PCCR0_SAHARA_MASK, CCM_PCCR1_HCLK_SAHARA_MASK);
215
216 return 0;
217}
218
219static void _clk_sahara2_disable(struct clk *clk)
220{
221 _clk_pccr01_disable(CCM_PCCR0_SAHARA_MASK, CCM_PCCR1_HCLK_SAHARA_MASK);
222}
223
224static int _clk_mstick1_enable(struct clk *clk)
225{
226 _clk_pccr10_enable(CCM_PCCR1_MSHC_BAUD_MASK, CCM_PCCR0_MSHC_MASK);
227
228 return 0;
229}
230
231static void _clk_mstick1_disable(struct clk *clk)
232{
233 _clk_pccr10_disable(CCM_PCCR1_MSHC_BAUD_MASK, CCM_PCCR0_MSHC_MASK);
234}
235
236#define CSCR() (__raw_readl(CCM_CSCR))
237#define PCDR0() (__raw_readl(CCM_PCDR0))
238#define PCDR1() (__raw_readl(CCM_PCDR1))
239
240static int _clk_cpu_set_parent(struct clk *clk, struct clk *parent)
241{
242 int cscr = CSCR();
243 122
244 if (clk->parent == parent) 123 if (clk->parent == parent)
245 return 0; 124 return 0;
246 125
247 if (mx27_revision() >= CHIP_REV_2_0) { 126 if (mx27_revision() >= CHIP_REV_2_0) {
248 if (parent == &mpll_main_clk[0]) { 127 if (parent == &mpll_main1_clk) {
249 cscr |= CCM_CSCR_ARM_SRC; 128 cscr |= CCM_CSCR_ARM_SRC;
250 } else { 129 } else {
251 if (parent == &mpll_main_clk[1]) 130 if (parent == &mpll_main2_clk)
252 cscr &= ~CCM_CSCR_ARM_SRC; 131 cscr &= ~CCM_CSCR_ARM_SRC;
253 else 132 else
254 return -EINVAL; 133 return -EINVAL;
255 } 134 }
256 __raw_writel(cscr, CCM_CSCR); 135 __raw_writel(cscr, CCM_CSCR);
257 } else 136 clk->parent = parent;
258 return -ENODEV; 137 return 0;
259 138 }
260 clk->parent = parent; 139 return -ENODEV;
261 return 0;
262} 140}
263 141
264static unsigned long _clk_cpu_round_rate(struct clk *clk, unsigned long rate) 142static unsigned long round_rate_cpu(struct clk *clk, unsigned long rate)
265{ 143{
266 int div; 144 int div;
267 unsigned long parent_rate; 145 unsigned long parent_rate;
@@ -278,7 +156,7 @@ static unsigned long _clk_cpu_round_rate(struct clk *clk, unsigned long rate)
278 return parent_rate / div; 156 return parent_rate / div;
279} 157}
280 158
281static int _clk_cpu_set_rate(struct clk *clk, unsigned long rate) 159static int set_rate_cpu(struct clk *clk, unsigned long rate)
282{ 160{
283 unsigned int div; 161 unsigned int div;
284 uint32_t reg; 162 uint32_t reg;
@@ -295,19 +173,18 @@ static int _clk_cpu_set_rate(struct clk *clk, unsigned long rate)
295 173
296 reg = __raw_readl(CCM_CSCR); 174 reg = __raw_readl(CCM_CSCR);
297 if (mx27_revision() >= CHIP_REV_2_0) { 175 if (mx27_revision() >= CHIP_REV_2_0) {
298 reg &= ~CCM_CSCR_ARM_MASK; 176 reg &= ~(3 << 12);
299 reg |= div << CCM_CSCR_ARM_OFFSET; 177 reg |= div << 12;
300 reg &= ~0x06; 178 reg &= ~(CCM_CSCR_FPM | CCM_CSCR_SPEN);
301 __raw_writel(reg | 0x80000000, CCM_CSCR); 179 __raw_writel(reg | CCM_CSCR_UPDATE_DIS, CCM_CSCR);
302 } else { 180 } else {
303 printk(KERN_ERR "Cant set CPU frequency!\n"); 181 printk(KERN_ERR "Can't set CPU frequency!\n");
304 } 182 }
305 183
306 return 0; 184 return 0;
307} 185}
308 186
309static unsigned long _clk_perclkx_round_rate(struct clk *clk, 187static unsigned long round_rate_per(struct clk *clk, unsigned long rate)
310 unsigned long rate)
311{ 188{
312 u32 div; 189 u32 div;
313 unsigned long parent_rate; 190 unsigned long parent_rate;
@@ -324,7 +201,7 @@ static unsigned long _clk_perclkx_round_rate(struct clk *clk,
324 return parent_rate / div; 201 return parent_rate / div;
325} 202}
326 203
327static int _clk_perclkx_set_rate(struct clk *clk, unsigned long rate) 204static int set_rate_per(struct clk *clk, unsigned long rate)
328{ 205{
329 u32 reg; 206 u32 reg;
330 u32 div; 207 u32 div;
@@ -340,84 +217,65 @@ static int _clk_perclkx_set_rate(struct clk *clk, unsigned long rate)
340 return -EINVAL; 217 return -EINVAL;
341 div--; 218 div--;
342 219
343 reg = 220 reg = __raw_readl(CCM_PCDR1) & ~(0x3f << (clk->id << 3));
344 __raw_readl(CCM_PCDR1) & ~(CCM_PCDR1_PERDIV1_MASK <<
345 (clk->id << 3));
346 reg |= div << (clk->id << 3); 221 reg |= div << (clk->id << 3);
347 __raw_writel(reg, CCM_PCDR1); 222 __raw_writel(reg, CCM_PCDR1);
348 223
349 return 0; 224 return 0;
350} 225}
351 226
352static unsigned long _clk_usb_recalc(struct clk *clk) 227static unsigned long get_rate_usb(struct clk *clk)
353{ 228{
354 unsigned long usb_pdf; 229 unsigned long usb_pdf;
355 unsigned long parent_rate; 230 unsigned long parent_rate;
356 231
357 parent_rate = clk_get_rate(clk->parent); 232 parent_rate = clk_get_rate(clk->parent);
358 233
359 usb_pdf = (CSCR() & CCM_CSCR_USB_MASK) >> CCM_CSCR_USB_OFFSET; 234 usb_pdf = (__raw_readl(CCM_CSCR) >> 28) & 0x7;
360 235
361 return parent_rate / (usb_pdf + 1U); 236 return parent_rate / (usb_pdf + 1U);
362} 237}
363 238
364static unsigned long _clk_ssi1_recalc(struct clk *clk) 239static unsigned long get_rate_ssix(struct clk *clk, unsigned long pdf)
365{ 240{
366 unsigned long ssi1_pdf;
367 unsigned long parent_rate; 241 unsigned long parent_rate;
368 242
369 parent_rate = clk_get_rate(clk->parent); 243 parent_rate = clk_get_rate(clk->parent);
370 244
371 ssi1_pdf = (PCDR0() & CCM_PCDR0_SSI1BAUDDIV_MASK) >>
372 CCM_PCDR0_SSI1BAUDDIV_OFFSET;
373
374 if (mx27_revision() >= CHIP_REV_2_0) 245 if (mx27_revision() >= CHIP_REV_2_0)
375 ssi1_pdf += 4; 246 pdf += 4; /* MX27 TO2+ */
376 else 247 else
377 ssi1_pdf = (ssi1_pdf < 2) ? 124UL : ssi1_pdf; 248 pdf = (pdf < 2) ? 124UL : pdf; /* MX21 & MX27 TO1 */
378 249
379 return 2UL * parent_rate / ssi1_pdf; 250 return 2UL * parent_rate / pdf;
380} 251}
381 252
382static unsigned long _clk_ssi2_recalc(struct clk *clk) 253static unsigned long get_rate_ssi1(struct clk *clk)
383{ 254{
384 unsigned long ssi2_pdf; 255 return get_rate_ssix(clk, (__raw_readl(CCM_PCDR0) >> 16) & 0x3f);
385 unsigned long parent_rate; 256}
386
387 parent_rate = clk_get_rate(clk->parent);
388
389 ssi2_pdf = (PCDR0() & CCM_PCDR0_SSI2BAUDDIV_MASK) >>
390 CCM_PCDR0_SSI2BAUDDIV_OFFSET;
391
392 if (mx27_revision() >= CHIP_REV_2_0)
393 ssi2_pdf += 4;
394 else
395 ssi2_pdf = (ssi2_pdf < 2) ? 124UL : ssi2_pdf;
396 257
397 return 2UL * parent_rate / ssi2_pdf; 258static unsigned long get_rate_ssi2(struct clk *clk)
259{
260 return get_rate_ssix(clk, (__raw_readl(CCM_PCDR0) >> 26) & 0x3f);
398} 261}
399 262
400static unsigned long _clk_nfc_recalc(struct clk *clk) 263static unsigned long get_rate_nfc(struct clk *clk)
401{ 264{
402 unsigned long nfc_pdf; 265 unsigned long nfc_pdf;
403 unsigned long parent_rate; 266 unsigned long parent_rate;
404 267
405 parent_rate = clk_get_rate(clk->parent); 268 parent_rate = clk_get_rate(clk->parent);
406 269
407 if (mx27_revision() >= CHIP_REV_2_0) { 270 if (mx27_revision() >= CHIP_REV_2_0)
408 nfc_pdf = 271 nfc_pdf = (__raw_readl(CCM_PCDR0) >> 6) & 0xf;
409 (PCDR0() & CCM_PCDR0_NFCDIV2_MASK) >> 272 else
410 CCM_PCDR0_NFCDIV2_OFFSET; 273 nfc_pdf = (__raw_readl(CCM_PCDR0) >> 12) & 0xf;
411 } else {
412 nfc_pdf =
413 (PCDR0() & CCM_PCDR0_NFCDIV_MASK) >>
414 CCM_PCDR0_NFCDIV_OFFSET;
415 }
416 274
417 return parent_rate / (nfc_pdf + 1); 275 return parent_rate / (nfc_pdf + 1);
418} 276}
419 277
420static unsigned long _clk_vpu_recalc(struct clk *clk) 278static unsigned long get_rate_vpu(struct clk *clk)
421{ 279{
422 unsigned long vpu_pdf; 280 unsigned long vpu_pdf;
423 unsigned long parent_rate; 281 unsigned long parent_rate;
@@ -425,25 +283,27 @@ static unsigned long _clk_vpu_recalc(struct clk *clk)
425 parent_rate = clk_get_rate(clk->parent); 283 parent_rate = clk_get_rate(clk->parent);
426 284
427 if (mx27_revision() >= CHIP_REV_2_0) { 285 if (mx27_revision() >= CHIP_REV_2_0) {
428 vpu_pdf = 286 vpu_pdf = (__raw_readl(CCM_PCDR0) >> 10) & 0x3f;
429 (PCDR0() & CCM_PCDR0_VPUDIV2_MASK) >>
430 CCM_PCDR0_VPUDIV2_OFFSET;
431 vpu_pdf += 4; 287 vpu_pdf += 4;
432 } else { 288 } else {
433 vpu_pdf = 289 vpu_pdf = (__raw_readl(CCM_PCDR0) >> 8) & 0xf;
434 (PCDR0() & CCM_PCDR0_VPUDIV_MASK) >>
435 CCM_PCDR0_VPUDIV_OFFSET;
436 vpu_pdf = (vpu_pdf < 2) ? 124 : vpu_pdf; 290 vpu_pdf = (vpu_pdf < 2) ? 124 : vpu_pdf;
437 } 291 }
292
438 return 2UL * parent_rate / vpu_pdf; 293 return 2UL * parent_rate / vpu_pdf;
439} 294}
440 295
441static unsigned long _clk_parent_round_rate(struct clk *clk, unsigned long rate) 296static unsigned long round_rate_parent(struct clk *clk, unsigned long rate)
442{ 297{
443 return clk->parent->round_rate(clk->parent, rate); 298 return clk->parent->round_rate(clk->parent, rate);
444} 299}
445 300
446static int _clk_parent_set_rate(struct clk *clk, unsigned long rate) 301static unsigned long get_rate_parent(struct clk *clk)
302{
303 return clk_get_rate(clk->parent);
304}
305
306static int set_rate_parent(struct clk *clk, unsigned long rate)
447{ 307{
448 return clk->parent->set_rate(clk->parent, rate); 308 return clk->parent->set_rate(clk->parent, rate);
449} 309}
@@ -451,1112 +311,380 @@ static int _clk_parent_set_rate(struct clk *clk, unsigned long rate)
451/* in Hz */ 311/* in Hz */
452static unsigned long external_high_reference = 26000000; 312static unsigned long external_high_reference = 26000000;
453 313
454static unsigned long get_high_reference_clock_rate(struct clk *clk) 314static unsigned long get_rate_high_reference(struct clk *clk)
455{ 315{
456 return external_high_reference; 316 return external_high_reference;
457} 317}
458 318
459/*
460 * the high frequency external clock reference
461 * Default case is 26MHz. Could be changed at runtime
462 * with a call to change_external_high_reference()
463 */
464static struct clk ckih_clk = {
465 .name = "ckih",
466 .get_rate = get_high_reference_clock_rate,
467};
468
469/* in Hz */ 319/* in Hz */
470static unsigned long external_low_reference = 32768; 320static unsigned long external_low_reference = 32768;
471 321
472static unsigned long get_low_reference_clock_rate(struct clk *clk) 322static unsigned long get_rate_low_reference(struct clk *clk)
473{ 323{
474 return external_low_reference; 324 return external_low_reference;
475} 325}
476 326
477/* 327static unsigned long get_rate_fpm(struct clk *clk)
478 * the low frequency external clock reference
479 * Default case is 32.768kHz Could be changed at runtime
480 * with a call to change_external_low_reference()
481 */
482static struct clk ckil_clk = {
483 .name = "ckil",
484 .get_rate = get_low_reference_clock_rate,
485};
486
487static unsigned long get_mpll_clk(struct clk *clk)
488{ 328{
489 uint32_t reg; 329 return clk_get_rate(clk->parent) * 1024;
490 unsigned long ref_clk;
491 unsigned long mfi = 0, mfn = 0, mfd = 0, pdf = 0;
492 unsigned long long temp;
493
494 ref_clk = clk_get_rate(clk->parent);
495
496 reg = __raw_readl(CCM_MPCTL0);
497 pdf = (reg & CCM_MPCTL0_PD_MASK) >> CCM_MPCTL0_PD_OFFSET;
498 mfd = (reg & CCM_MPCTL0_MFD_MASK) >> CCM_MPCTL0_MFD_OFFSET;
499 mfi = (reg & CCM_MPCTL0_MFI_MASK) >> CCM_MPCTL0_MFI_OFFSET;
500 mfn = (reg & CCM_MPCTL0_MFN_MASK) >> CCM_MPCTL0_MFN_OFFSET;
501
502 mfi = (mfi <= 5) ? 5 : mfi;
503 temp = 2LL * ref_clk * mfn;
504 do_div(temp, mfd + 1);
505 temp = 2LL * ref_clk * mfi + temp;
506 do_div(temp, pdf + 1);
507
508 return (unsigned long)temp;
509} 330}
510 331
511static struct clk mpll_clk = { 332static unsigned long get_rate_mpll(struct clk *clk)
512 .name = "mpll", 333{
513 .parent = &ckih_clk, 334 return mxc_decode_pll(__raw_readl(CCM_MPCTL0),
514 .get_rate = get_mpll_clk, 335 clk_get_rate(clk->parent));
515}; 336}
516 337
517static unsigned long _clk_mpll_main_get_rate(struct clk *clk) 338static unsigned long get_rate_mpll_main(struct clk *clk)
518{ 339{
519 unsigned long parent_rate; 340 unsigned long parent_rate;
520 341
521 parent_rate = clk_get_rate(clk->parent); 342 parent_rate = clk_get_rate(clk->parent);
522 343
523 /* i.MX27 TO2: 344 /* i.MX27 TO2:
524 * clk->id == 0: arm clock source path 1 which is from 2*MPLL/DIV_2 345 * clk->id == 0: arm clock source path 1 which is from 2 * MPLL / 2
525 * clk->id == 1: arm clock source path 2 which is from 2*MPLL/DIV_3 346 * clk->id == 1: arm clock source path 2 which is from 2 * MPLL / 3
526 */ 347 */
527
528 if (mx27_revision() >= CHIP_REV_2_0 && clk->id == 1) 348 if (mx27_revision() >= CHIP_REV_2_0 && clk->id == 1)
529 return 2UL * parent_rate / 3UL; 349 return 2UL * parent_rate / 3UL;
530 350
531 return parent_rate; 351 return parent_rate;
532} 352}
533 353
534static struct clk mpll_main_clk[] = { 354static unsigned long get_rate_spll(struct clk *clk)
535 {
536 /* For i.MX27 TO2, it is the MPLL path 1 of ARM core
537 * It provide the clock source whose rate is same as MPLL
538 */
539 .name = "mpll_main",
540 .id = 0,
541 .parent = &mpll_clk,
542 .get_rate = _clk_mpll_main_get_rate
543 }, {
544 /* For i.MX27 TO2, it is the MPLL path 2 of ARM core
545 * It provide the clock source whose rate is same MPLL * 2/3
546 */
547 .name = "mpll_main",
548 .id = 1,
549 .parent = &mpll_clk,
550 .get_rate = _clk_mpll_main_get_rate
551 }
552};
553
554static unsigned long get_spll_clk(struct clk *clk)
555{ 355{
556 uint32_t reg; 356 uint32_t reg;
557 unsigned long ref_clk; 357 unsigned long rate;
558 unsigned long mfi = 0, mfn = 0, mfd = 0, pdf = 0;
559 unsigned long long temp;
560 358
561 ref_clk = clk_get_rate(clk->parent); 359 rate = clk_get_rate(clk->parent);
562 360
563 reg = __raw_readl(CCM_SPCTL0); 361 reg = __raw_readl(CCM_SPCTL0);
564 /*TODO: This is TO2 Bug */ 362
363 /* On TO2 we have to write the value back. Otherwise we
364 * read 0 from this register the next time.
365 */
565 if (mx27_revision() >= CHIP_REV_2_0) 366 if (mx27_revision() >= CHIP_REV_2_0)
566 __raw_writel(reg, CCM_SPCTL0); 367 __raw_writel(reg, CCM_SPCTL0);
567 368
568 pdf = (reg & CCM_SPCTL0_PD_MASK) >> CCM_SPCTL0_PD_OFFSET; 369 return mxc_decode_pll(reg, rate);
569 mfd = (reg & CCM_SPCTL0_MFD_MASK) >> CCM_SPCTL0_MFD_OFFSET;
570 mfi = (reg & CCM_SPCTL0_MFI_MASK) >> CCM_SPCTL0_MFI_OFFSET;
571 mfn = (reg & CCM_SPCTL0_MFN_MASK) >> CCM_SPCTL0_MFN_OFFSET;
572
573 mfi = (mfi <= 5) ? 5 : mfi;
574 temp = 2LL * ref_clk * mfn;
575 do_div(temp, mfd + 1);
576 temp = 2LL * ref_clk * mfi + temp;
577 do_div(temp, pdf + 1);
578
579 return (unsigned long)temp;
580} 370}
581 371
582static struct clk spll_clk = { 372static unsigned long get_rate_cpu(struct clk *clk)
583 .name = "spll",
584 .parent = &ckih_clk,
585 .get_rate = get_spll_clk,
586 .enable = _clk_spll_enable,
587 .disable = _clk_spll_disable,
588};
589
590static unsigned long get_cpu_clk(struct clk *clk)
591{ 373{
592 u32 div; 374 u32 div;
593 unsigned long rate; 375 unsigned long rate;
594 376
595 if (mx27_revision() >= CHIP_REV_2_0) 377 if (mx27_revision() >= CHIP_REV_2_0)
596 div = (CSCR() & CCM_CSCR_ARM_MASK) >> CCM_CSCR_ARM_OFFSET; 378 div = (__raw_readl(CCM_CSCR) >> 12) & 0x3;
597 else 379 else
598 div = (CSCR() & CCM_CSCR_PRESC_MASK) >> CCM_CSCR_PRESC_OFFSET; 380 div = (__raw_readl(CCM_CSCR) >> 13) & 0x7;
599 381
600 rate = clk_get_rate(clk->parent); 382 rate = clk_get_rate(clk->parent);
601 return rate / (div + 1); 383 return rate / (div + 1);
602} 384}
603 385
604static struct clk cpu_clk = { 386static unsigned long get_rate_ahb(struct clk *clk)
605 .name = "cpu_clk",
606 .parent = &mpll_main_clk[1],
607 .set_parent = _clk_cpu_set_parent,
608 .round_rate = _clk_cpu_round_rate,
609 .get_rate = get_cpu_clk,
610 .set_rate = _clk_cpu_set_rate,
611};
612
613static unsigned long get_ahb_clk(struct clk *clk)
614{ 387{
615 unsigned long rate; 388 unsigned long rate, bclk_pdf;
616 unsigned long bclk_pdf;
617 389
618 if (mx27_revision() >= CHIP_REV_2_0) 390 if (mx27_revision() >= CHIP_REV_2_0)
619 bclk_pdf = (CSCR() & CCM_CSCR_AHB_MASK) 391 bclk_pdf = (__raw_readl(CCM_CSCR) >> 8) & 0x3;
620 >> CCM_CSCR_AHB_OFFSET;
621 else 392 else
622 bclk_pdf = (CSCR() & CCM_CSCR_BCLK_MASK) 393 bclk_pdf = (__raw_readl(CCM_CSCR) >> 9) & 0xf;
623 >> CCM_CSCR_BCLK_OFFSET;
624 394
625 rate = clk_get_rate(clk->parent); 395 rate = clk_get_rate(clk->parent);
626 return rate / (bclk_pdf + 1); 396 return rate / (bclk_pdf + 1);
627} 397}
628 398
629static struct clk ahb_clk = { 399static unsigned long get_rate_ipg(struct clk *clk)
630 .name = "ahb_clk",
631 .parent = &mpll_main_clk[1],
632 .get_rate = get_ahb_clk,
633};
634
635static unsigned long get_ipg_clk(struct clk *clk)
636{ 400{
637 unsigned long rate; 401 unsigned long rate, ipg_pdf;
638 unsigned long ipg_pdf;
639 402
640 if (mx27_revision() >= CHIP_REV_2_0) 403 if (mx27_revision() >= CHIP_REV_2_0)
641 return clk_get_rate(clk->parent); 404 return clk_get_rate(clk->parent);
642 else 405 else
643 ipg_pdf = (CSCR() & CCM_CSCR_IPDIV) >> CCM_CSCR_IPDIV_OFFSET; 406 ipg_pdf = (__raw_readl(CCM_CSCR) >> 8) & 1;
644 407
645 rate = clk_get_rate(clk->parent); 408 rate = clk_get_rate(clk->parent);
646 return rate / (ipg_pdf + 1); 409 return rate / (ipg_pdf + 1);
647} 410}
648 411
649static struct clk ipg_clk = { 412static unsigned long get_rate_per(struct clk *clk)
650 .name = "ipg_clk",
651 .parent = &ahb_clk,
652 .get_rate = get_ipg_clk,
653};
654
655static unsigned long _clk_perclkx_recalc(struct clk *clk)
656{ 413{
657 unsigned long perclk_pdf; 414 unsigned long perclk_pdf, parent_rate;
658 unsigned long parent_rate;
659 415
660 parent_rate = clk_get_rate(clk->parent); 416 parent_rate = clk_get_rate(clk->parent);
661 417
662 if (clk->id < 0 || clk->id > 3) 418 if (clk->id < 0 || clk->id > 3)
663 return 0; 419 return 0;
664 420
665 perclk_pdf = (PCDR1() >> (clk->id << 3)) & CCM_PCDR1_PERDIV1_MASK; 421 perclk_pdf = (__raw_readl(CCM_PCDR1) >> (clk->id << 3)) & 0x3f;
666 422
667 return parent_rate / (perclk_pdf + 1); 423 return parent_rate / (perclk_pdf + 1);
668} 424}
669 425
670static struct clk per_clk[] = { 426/*
671 { 427 * the high frequency external clock reference
672 .name = "per_clk", 428 * Default case is 26MHz. Could be changed at runtime
673 .id = 0, 429 * with a call to change_external_high_reference()
674 .parent = &mpll_main_clk[1], 430 */
675 .get_rate = _clk_perclkx_recalc, 431static struct clk ckih_clk = {
676 .enable = _clk_enable, 432 .get_rate = get_rate_high_reference,
677 .enable_reg = CCM_PCCR1,
678 .enable_shift = CCM_PCCR1_PERCLK1_OFFSET,
679 .disable = _clk_disable,
680 }, {
681 .name = "per_clk",
682 .id = 1,
683 .parent = &mpll_main_clk[1],
684 .get_rate = _clk_perclkx_recalc,
685 .enable = _clk_enable,
686 .enable_reg = CCM_PCCR1,
687 .enable_shift = CCM_PCCR1_PERCLK2_OFFSET,
688 .disable = _clk_disable,
689 }, {
690 .name = "per_clk",
691 .id = 2,
692 .parent = &mpll_main_clk[1],
693 .round_rate = _clk_perclkx_round_rate,
694 .set_rate = _clk_perclkx_set_rate,
695 .get_rate = _clk_perclkx_recalc,
696 .enable = _clk_enable,
697 .enable_reg = CCM_PCCR1,
698 .enable_shift = CCM_PCCR1_PERCLK3_OFFSET,
699 .disable = _clk_disable,
700 }, {
701 .name = "per_clk",
702 .id = 3,
703 .parent = &mpll_main_clk[1],
704 .round_rate = _clk_perclkx_round_rate,
705 .set_rate = _clk_perclkx_set_rate,
706 .get_rate = _clk_perclkx_recalc,
707 .enable = _clk_enable,
708 .enable_reg = CCM_PCCR1,
709 .enable_shift = CCM_PCCR1_PERCLK4_OFFSET,
710 .disable = _clk_disable,
711 },
712};
713
714struct clk uart1_clk[] = {
715 {
716 .name = "uart_clk",
717 .id = 0,
718 .parent = &per_clk[0],
719 .secondary = &uart1_clk[1],
720 }, {
721 .name = "uart_ipg_clk",
722 .id = 0,
723 .parent = &ipg_clk,
724 .enable = _clk_enable,
725 .enable_reg = CCM_PCCR1,
726 .enable_shift = CCM_PCCR1_UART1_OFFSET,
727 .disable = _clk_disable,
728 },
729};
730
731struct clk uart2_clk[] = {
732 {
733 .name = "uart_clk",
734 .id = 1,
735 .parent = &per_clk[0],
736 .secondary = &uart2_clk[1],
737 }, {
738 .name = "uart_ipg_clk",
739 .id = 1,
740 .parent = &ipg_clk,
741 .enable = _clk_enable,
742 .enable_reg = CCM_PCCR1,
743 .enable_shift = CCM_PCCR1_UART2_OFFSET,
744 .disable = _clk_disable,
745 },
746};
747
748struct clk uart3_clk[] = {
749 {
750 .name = "uart_clk",
751 .id = 2,
752 .parent = &per_clk[0],
753 .secondary = &uart3_clk[1],
754 }, {
755 .name = "uart_ipg_clk",
756 .id = 2,
757 .parent = &ipg_clk,
758 .enable = _clk_enable,
759 .enable_reg = CCM_PCCR1,
760 .enable_shift = CCM_PCCR1_UART3_OFFSET,
761 .disable = _clk_disable,
762 },
763};
764
765struct clk uart4_clk[] = {
766 {
767 .name = "uart_clk",
768 .id = 3,
769 .parent = &per_clk[0],
770 .secondary = &uart4_clk[1],
771 }, {
772 .name = "uart_ipg_clk",
773 .id = 3,
774 .parent = &ipg_clk,
775 .enable = _clk_enable,
776 .enable_reg = CCM_PCCR1,
777 .enable_shift = CCM_PCCR1_UART4_OFFSET,
778 .disable = _clk_disable,
779 },
780};
781
782struct clk uart5_clk[] = {
783 {
784 .name = "uart_clk",
785 .id = 4,
786 .parent = &per_clk[0],
787 .secondary = &uart5_clk[1],
788 }, {
789 .name = "uart_ipg_clk",
790 .id = 4,
791 .parent = &ipg_clk,
792 .enable = _clk_enable,
793 .enable_reg = CCM_PCCR1,
794 .enable_shift = CCM_PCCR1_UART5_OFFSET,
795 .disable = _clk_disable,
796 },
797};
798
799struct clk uart6_clk[] = {
800 {
801 .name = "uart_clk",
802 .id = 5,
803 .parent = &per_clk[0],
804 .secondary = &uart6_clk[1],
805 }, {
806 .name = "uart_ipg_clk",
807 .id = 5,
808 .parent = &ipg_clk,
809 .enable = _clk_enable,
810 .enable_reg = CCM_PCCR1,
811 .enable_shift = CCM_PCCR1_UART6_OFFSET,
812 .disable = _clk_disable,
813 },
814};
815
816static struct clk gpt1_clk[] = {
817 {
818 .name = "gpt_clk",
819 .id = 0,
820 .parent = &per_clk[0],
821 .secondary = &gpt1_clk[1],
822 }, {
823 .name = "gpt_ipg_clk",
824 .id = 0,
825 .parent = &ipg_clk,
826 .enable = _clk_enable,
827 .enable_reg = CCM_PCCR0,
828 .enable_shift = CCM_PCCR0_GPT1_OFFSET,
829 .disable = _clk_disable,
830 },
831};
832
833static struct clk gpt2_clk[] = {
834 {
835 .name = "gpt_clk",
836 .id = 1,
837 .parent = &per_clk[0],
838 .secondary = &gpt2_clk[1],
839 }, {
840 .name = "gpt_ipg_clk",
841 .id = 1,
842 .parent = &ipg_clk,
843 .enable = _clk_enable,
844 .enable_reg = CCM_PCCR0,
845 .enable_shift = CCM_PCCR0_GPT2_OFFSET,
846 .disable = _clk_disable,
847 },
848};
849
850static struct clk gpt3_clk[] = {
851 {
852 .name = "gpt_clk",
853 .id = 2,
854 .parent = &per_clk[0],
855 .secondary = &gpt3_clk[1],
856 }, {
857 .name = "gpt_ipg_clk",
858 .id = 2,
859 .parent = &ipg_clk,
860 .enable = _clk_enable,
861 .enable_reg = CCM_PCCR0,
862 .enable_shift = CCM_PCCR0_GPT3_OFFSET,
863 .disable = _clk_disable,
864 },
865};
866
867static struct clk gpt4_clk[] = {
868 {
869 .name = "gpt_clk",
870 .id = 3,
871 .parent = &per_clk[0],
872 .secondary = &gpt4_clk[1],
873 }, {
874 .name = "gpt_ipg_clk",
875 .id = 3,
876 .parent = &ipg_clk,
877 .enable = _clk_enable,
878 .enable_reg = CCM_PCCR0,
879 .enable_shift = CCM_PCCR0_GPT4_OFFSET,
880 .disable = _clk_disable,
881 },
882};
883
884static struct clk gpt5_clk[] = {
885 {
886 .name = "gpt_clk",
887 .id = 4,
888 .parent = &per_clk[0],
889 .secondary = &gpt5_clk[1],
890 }, {
891 .name = "gpt_ipg_clk",
892 .id = 4,
893 .parent = &ipg_clk,
894 .enable = _clk_enable,
895 .enable_reg = CCM_PCCR0,
896 .enable_shift = CCM_PCCR0_GPT5_OFFSET,
897 .disable = _clk_disable,
898 },
899}; 433};
900 434
901static struct clk gpt6_clk[] = { 435static struct clk mpll_clk = {
902 { 436 .parent = &ckih_clk,
903 .name = "gpt_clk", 437 .get_rate = get_rate_mpll,
904 .id = 5,
905 .parent = &per_clk[0],
906 .secondary = &gpt6_clk[1],
907 }, {
908 .name = "gpt_ipg_clk",
909 .id = 5,
910 .parent = &ipg_clk,
911 .enable = _clk_enable,
912 .enable_reg = CCM_PCCR0,
913 .enable_shift = CCM_PCCR0_GPT6_OFFSET,
914 .disable = _clk_disable,
915 },
916}; 438};
917 439
918static struct clk pwm_clk[] = { 440/* For i.MX27 TO2, it is the MPLL path 1 of ARM core
919 { 441 * It provides the clock source whose rate is same as MPLL
920 .name = "pwm_clk", 442 */
921 .parent = &per_clk[0], 443static struct clk mpll_main1_clk = {
922 .secondary = &pwm_clk[1], 444 .id = 0,
923 }, { 445 .parent = &mpll_clk,
924 .name = "pwm_clk", 446 .get_rate = get_rate_mpll_main,
925 .parent = &ipg_clk,
926 .enable = _clk_enable,
927 .enable_reg = CCM_PCCR0,
928 .enable_shift = CCM_PCCR0_PWM_OFFSET,
929 .disable = _clk_disable,
930 },
931}; 447};
932 448
933static struct clk sdhc1_clk[] = { 449/* For i.MX27 TO2, it is the MPLL path 2 of ARM core
934 { 450 * It provides the clock source whose rate is same MPLL * 2 / 3
935 .name = "sdhc_clk", 451 */
936 .id = 0, 452static struct clk mpll_main2_clk = {
937 .parent = &per_clk[1], 453 .id = 1,
938 .secondary = &sdhc1_clk[1], 454 .parent = &mpll_clk,
939 }, { 455 .get_rate = get_rate_mpll_main,
940 .name = "sdhc_ipg_clk",
941 .id = 0,
942 .parent = &ipg_clk,
943 .enable = _clk_enable,
944 .enable_reg = CCM_PCCR0,
945 .enable_shift = CCM_PCCR0_SDHC1_OFFSET,
946 .disable = _clk_disable,
947 },
948}; 456};
949 457
950static struct clk sdhc2_clk[] = { 458static struct clk ahb_clk = {
951 { 459 .parent = &mpll_main2_clk,
952 .name = "sdhc_clk", 460 .get_rate = get_rate_ahb,
953 .id = 1,
954 .parent = &per_clk[1],
955 .secondary = &sdhc2_clk[1],
956 }, {
957 .name = "sdhc_ipg_clk",
958 .id = 1,
959 .parent = &ipg_clk,
960 .enable = _clk_enable,
961 .enable_reg = CCM_PCCR0,
962 .enable_shift = CCM_PCCR0_SDHC2_OFFSET,
963 .disable = _clk_disable,
964 },
965}; 461};
966 462
967static struct clk sdhc3_clk[] = { 463static struct clk ipg_clk = {
968 { 464 .parent = &ahb_clk,
969 .name = "sdhc_clk", 465 .get_rate = get_rate_ipg,
970 .id = 2,
971 .parent = &per_clk[1],
972 .secondary = &sdhc3_clk[1],
973 }, {
974 .name = "sdhc_ipg_clk",
975 .id = 2,
976 .parent = &ipg_clk,
977 .enable = _clk_enable,
978 .enable_reg = CCM_PCCR0,
979 .enable_shift = CCM_PCCR0_SDHC3_OFFSET,
980 .disable = _clk_disable,
981 },
982}; 466};
983 467
984static struct clk cspi1_clk[] = { 468static struct clk cpu_clk = {
985 { 469 .parent = &mpll_main2_clk,
986 .name = "cspi_clk", 470 .set_parent = clk_cpu_set_parent,
987 .id = 0, 471 .round_rate = round_rate_cpu,
988 .parent = &per_clk[1], 472 .get_rate = get_rate_cpu,
989 .secondary = &cspi1_clk[1], 473 .set_rate = set_rate_cpu,
990 }, {
991 .name = "cspi_ipg_clk",
992 .id = 0,
993 .parent = &ipg_clk,
994 .enable = _clk_enable,
995 .enable_reg = CCM_PCCR0,
996 .enable_shift = CCM_PCCR0_CSPI1_OFFSET,
997 .disable = _clk_disable,
998 },
999}; 474};
1000 475
1001static struct clk cspi2_clk[] = { 476static struct clk spll_clk = {
1002 { 477 .parent = &ckih_clk,
1003 .name = "cspi_clk", 478 .get_rate = get_rate_spll,
1004 .id = 1, 479 .enable = clk_spll_enable,
1005 .parent = &per_clk[1], 480 .disable = clk_spll_disable,
1006 .secondary = &cspi2_clk[1],
1007 }, {
1008 .name = "cspi_ipg_clk",
1009 .id = 1,
1010 .parent = &ipg_clk,
1011 .enable = _clk_enable,
1012 .enable_reg = CCM_PCCR0,
1013 .enable_shift = CCM_PCCR0_CSPI2_OFFSET,
1014 .disable = _clk_disable,
1015 },
1016}; 481};
1017 482
1018static struct clk cspi3_clk[] = { 483/*
1019 { 484 * the low frequency external clock reference
1020 .name = "cspi_clk", 485 * Default case is 32.768kHz.
1021 .id = 2, 486 */
1022 .parent = &per_clk[1], 487static struct clk ckil_clk = {
1023 .secondary = &cspi3_clk[1], 488 .get_rate = get_rate_low_reference,
1024 }, {
1025 .name = "cspi_ipg_clk",
1026 .id = 2,
1027 .parent = &ipg_clk,
1028 .enable = _clk_enable,
1029 .enable_reg = CCM_PCCR0,
1030 .enable_shift = CCM_PCCR0_CSPI3_OFFSET,
1031 .disable = _clk_disable,
1032 },
1033}; 489};
1034 490
1035static struct clk lcdc_clk[] = { 491/* Output of frequency pre multiplier */
1036 { 492static struct clk fpm_clk = {
1037 .name = "lcdc_clk", 493 .parent = &ckil_clk,
1038 .parent = &per_clk[2], 494 .get_rate = get_rate_fpm,
1039 .secondary = &lcdc_clk[1],
1040 .round_rate = _clk_parent_round_rate,
1041 .set_rate = _clk_parent_set_rate,
1042 }, {
1043 .name = "lcdc_ipg_clk",
1044 .parent = &ipg_clk,
1045 .secondary = &lcdc_clk[2],
1046 .enable = _clk_enable,
1047 .enable_reg = CCM_PCCR0,
1048 .enable_shift = CCM_PCCR0_LCDC_OFFSET,
1049 .disable = _clk_disable,
1050 }, {
1051 .name = "lcdc_ahb_clk",
1052 .parent = &ahb_clk,
1053 .enable = _clk_enable,
1054 .enable_reg = CCM_PCCR1,
1055 .enable_shift = CCM_PCCR1_HCLK_LCDC_OFFSET,
1056 .disable = _clk_disable,
1057 },
1058}; 495};
1059 496
1060static struct clk csi_clk[] = { 497#define PCCR0 CCM_PCCR0
1061 { 498#define PCCR1 CCM_PCCR1
1062 .name = "csi_perclk",
1063 .parent = &per_clk[3],
1064 .secondary = &csi_clk[1],
1065 .round_rate = _clk_parent_round_rate,
1066 .set_rate = _clk_parent_set_rate,
1067 }, {
1068 .name = "csi_ahb_clk",
1069 .parent = &ahb_clk,
1070 .enable = _clk_enable,
1071 .enable_reg = CCM_PCCR1,
1072 .enable_shift = CCM_PCCR1_HCLK_CSI_OFFSET,
1073 .disable = _clk_disable,
1074 },
1075};
1076 499
1077static struct clk usb_clk[] = { 500#define DEFINE_CLOCK(name, i, er, es, gr, s, p) \
1078 { 501 static struct clk name = { \
1079 .name = "usb_clk", 502 .id = i, \
1080 .parent = &spll_clk, 503 .enable_reg = er, \
1081 .get_rate = _clk_usb_recalc, 504 .enable_shift = es, \
1082 .enable = _clk_enable, 505 .get_rate = gr, \
1083 .enable_reg = CCM_PCCR1, 506 .enable = clk_pccr_enable, \
1084 .enable_shift = CCM_PCCR1_USBOTG_OFFSET, 507 .disable = clk_pccr_disable, \
1085 .disable = _clk_disable, 508 .secondary = s, \
1086 }, { 509 .parent = p, \
1087 .name = "usb_ahb_clk",
1088 .parent = &ahb_clk,
1089 .enable = _clk_enable,
1090 .enable_reg = CCM_PCCR1,
1091 .enable_shift = CCM_PCCR1_HCLK_USBOTG_OFFSET,
1092 .disable = _clk_disable,
1093 } 510 }
1094};
1095 511
1096static struct clk ssi1_clk[] = { 512#define DEFINE_CLOCK1(name, i, er, es, getsetround, s, p) \
1097 { 513 static struct clk name = { \
1098 .name = "ssi_clk", 514 .id = i, \
1099 .id = 0, 515 .enable_reg = er, \
1100 .parent = &mpll_main_clk[1], 516 .enable_shift = es, \
1101 .secondary = &ssi1_clk[1], 517 .get_rate = get_rate_##getsetround, \
1102 .get_rate = _clk_ssi1_recalc, 518 .set_rate = set_rate_##getsetround, \
1103 .enable = _clk_enable, 519 .round_rate = round_rate_##getsetround, \
1104 .enable_reg = CCM_PCCR1, 520 .enable = clk_pccr_enable, \
1105 .enable_shift = CCM_PCCR1_SSI1_BAUD_OFFSET, 521 .disable = clk_pccr_disable, \
1106 .disable = _clk_disable, 522 .secondary = s, \
1107 }, { 523 .parent = p, \
1108 .name = "ssi_ipg_clk", 524 }
1109 .id = 0,
1110 .parent = &ipg_clk,
1111 .enable = _clk_enable,
1112 .enable_reg = CCM_PCCR0,
1113 .enable_shift = CCM_PCCR0_SSI1_IPG_OFFSET,
1114 .disable = _clk_disable,
1115 },
1116};
1117 525
1118static struct clk ssi2_clk[] = { 526/* Forward declaration to keep the following list in order */
1119 { 527static struct clk slcdc_clk1, sahara2_clk1, rtic_clk1, fec_clk1, emma_clk1,
1120 .name = "ssi_clk", 528 dma_clk1, lcdc_clk2, vpu_clk1;
1121 .id = 1, 529
1122 .parent = &mpll_main_clk[1], 530/* All clocks we can gate through PCCRx in the order of PCCRx bits */
1123 .secondary = &ssi2_clk[1], 531DEFINE_CLOCK(ssi2_clk1, 1, PCCR0, 0, NULL, NULL, &ipg_clk);
1124 .get_rate = _clk_ssi2_recalc, 532DEFINE_CLOCK(ssi1_clk1, 0, PCCR0, 1, NULL, NULL, &ipg_clk);
1125 .enable = _clk_enable, 533DEFINE_CLOCK(slcdc_clk, 0, PCCR0, 2, NULL, &slcdc_clk1, &ahb_clk);
1126 .enable_reg = CCM_PCCR1, 534DEFINE_CLOCK(sdhc3_clk1, 0, PCCR0, 3, NULL, NULL, &ipg_clk);
1127 .enable_shift = CCM_PCCR1_SSI2_BAUD_OFFSET, 535DEFINE_CLOCK(sdhc2_clk1, 0, PCCR0, 4, NULL, NULL, &ipg_clk);
1128 .disable = _clk_disable, 536DEFINE_CLOCK(sdhc1_clk1, 0, PCCR0, 5, NULL, NULL, &ipg_clk);
1129 }, { 537DEFINE_CLOCK(scc_clk, 0, PCCR0, 6, NULL, NULL, &ipg_clk);
1130 .name = "ssi_ipg_clk", 538DEFINE_CLOCK(sahara2_clk, 0, PCCR0, 7, NULL, &sahara2_clk1, &ahb_clk);
1131 .id = 1, 539DEFINE_CLOCK(rtic_clk, 0, PCCR0, 8, NULL, &rtic_clk1, &ahb_clk);
1132 .parent = &ipg_clk, 540DEFINE_CLOCK(rtc_clk, 0, PCCR0, 9, NULL, NULL, &ipg_clk);
1133 .enable = _clk_enable, 541DEFINE_CLOCK(pwm_clk1, 0, PCCR0, 11, NULL, NULL, &ipg_clk);
1134 .enable_reg = CCM_PCCR0, 542DEFINE_CLOCK(owire_clk, 0, PCCR0, 12, NULL, NULL, &ipg_clk);
1135 .enable_shift = CCM_PCCR0_SSI2_IPG_OFFSET, 543DEFINE_CLOCK(mstick_clk1, 0, PCCR0, 13, NULL, NULL, &ipg_clk);
1136 .disable = _clk_disable, 544DEFINE_CLOCK(lcdc_clk1, 0, PCCR0, 14, NULL, &lcdc_clk2, &ipg_clk);
545DEFINE_CLOCK(kpp_clk, 0, PCCR0, 15, NULL, NULL, &ipg_clk);
546DEFINE_CLOCK(iim_clk, 0, PCCR0, 16, NULL, NULL, &ipg_clk);
547DEFINE_CLOCK(i2c2_clk, 1, PCCR0, 17, NULL, NULL, &ipg_clk);
548DEFINE_CLOCK(i2c1_clk, 0, PCCR0, 18, NULL, NULL, &ipg_clk);
549DEFINE_CLOCK(gpt6_clk1, 0, PCCR0, 29, NULL, NULL, &ipg_clk);
550DEFINE_CLOCK(gpt5_clk1, 0, PCCR0, 20, NULL, NULL, &ipg_clk);
551DEFINE_CLOCK(gpt4_clk1, 0, PCCR0, 21, NULL, NULL, &ipg_clk);
552DEFINE_CLOCK(gpt3_clk1, 0, PCCR0, 22, NULL, NULL, &ipg_clk);
553DEFINE_CLOCK(gpt2_clk1, 0, PCCR0, 23, NULL, NULL, &ipg_clk);
554DEFINE_CLOCK(gpt1_clk1, 0, PCCR0, 24, NULL, NULL, &ipg_clk);
555DEFINE_CLOCK(gpio_clk, 0, PCCR0, 25, NULL, NULL, &ipg_clk);
556DEFINE_CLOCK(fec_clk, 0, PCCR0, 26, NULL, &fec_clk1, &ahb_clk);
557DEFINE_CLOCK(emma_clk, 0, PCCR0, 27, NULL, &emma_clk1, &ahb_clk);
558DEFINE_CLOCK(dma_clk, 0, PCCR0, 28, NULL, &dma_clk1, &ahb_clk);
559DEFINE_CLOCK(cspi13_clk1, 0, PCCR0, 29, NULL, NULL, &ipg_clk);
560DEFINE_CLOCK(cspi2_clk1, 0, PCCR0, 30, NULL, NULL, &ipg_clk);
561DEFINE_CLOCK(cspi1_clk1, 0, PCCR0, 31, NULL, NULL, &ipg_clk);
562
563DEFINE_CLOCK(mstick_clk, 0, PCCR1, 2, NULL, &mstick_clk1, &ipg_clk);
564DEFINE_CLOCK(nfc_clk, 0, PCCR1, 3, get_rate_nfc, NULL, &cpu_clk);
565DEFINE_CLOCK(ssi2_clk, 1, PCCR1, 4, get_rate_ssi2, &ssi2_clk1, &mpll_main2_clk);
566DEFINE_CLOCK(ssi1_clk, 0, PCCR1, 5, get_rate_ssi1, &ssi1_clk1, &mpll_main2_clk);
567DEFINE_CLOCK(vpu_clk, 0, PCCR1, 6, get_rate_vpu, &vpu_clk1, &mpll_main2_clk);
568DEFINE_CLOCK1(per4_clk, 3, PCCR1, 7, per, NULL, &mpll_main2_clk);
569DEFINE_CLOCK1(per3_clk, 2, PCCR1, 8, per, NULL, &mpll_main2_clk);
570DEFINE_CLOCK1(per2_clk, 1, PCCR1, 9, per, NULL, &mpll_main2_clk);
571DEFINE_CLOCK1(per1_clk, 0, PCCR1, 10, per, NULL, &mpll_main2_clk);
572DEFINE_CLOCK(usb_clk1, 0, PCCR1, 11, NULL, NULL, &ahb_clk);
573DEFINE_CLOCK(slcdc_clk1, 0, PCCR1, 12, NULL, NULL, &ahb_clk);
574DEFINE_CLOCK(sahara2_clk1, 0, PCCR1, 13, NULL, NULL, &ahb_clk);
575DEFINE_CLOCK(rtic_clk1, 0, PCCR1, 14, NULL, NULL, &ahb_clk);
576DEFINE_CLOCK(lcdc_clk2, 0, PCCR1, 15, NULL, NULL, &ahb_clk);
577DEFINE_CLOCK(vpu_clk1, 0, PCCR1, 16, NULL, NULL, &ahb_clk);
578DEFINE_CLOCK(fec_clk1, 0, PCCR1, 17, NULL, NULL, &ahb_clk);
579DEFINE_CLOCK(emma_clk1, 0, PCCR1, 18, NULL, NULL, &ahb_clk);
580DEFINE_CLOCK(emi_clk, 0, PCCR1, 19, NULL, NULL, &ahb_clk);
581DEFINE_CLOCK(dma_clk1, 0, PCCR1, 20, NULL, NULL, &ahb_clk);
582DEFINE_CLOCK(csi_clk1, 0, PCCR1, 21, NULL, NULL, &ahb_clk);
583DEFINE_CLOCK(brom_clk, 0, PCCR1, 22, NULL, NULL, &ahb_clk);
584DEFINE_CLOCK(ata_clk, 0, PCCR1, 23, NULL, NULL, &ahb_clk);
585DEFINE_CLOCK(wdog_clk, 0, PCCR1, 24, NULL, NULL, &ipg_clk);
586DEFINE_CLOCK(usb_clk, 0, PCCR1, 25, get_rate_usb, &usb_clk1, &spll_clk);
587DEFINE_CLOCK(uart6_clk1, 0, PCCR1, 26, NULL, NULL, &ipg_clk);
588DEFINE_CLOCK(uart5_clk1, 0, PCCR1, 27, NULL, NULL, &ipg_clk);
589DEFINE_CLOCK(uart4_clk1, 0, PCCR1, 28, NULL, NULL, &ipg_clk);
590DEFINE_CLOCK(uart3_clk1, 0, PCCR1, 29, NULL, NULL, &ipg_clk);
591DEFINE_CLOCK(uart2_clk1, 0, PCCR1, 30, NULL, NULL, &ipg_clk);
592DEFINE_CLOCK(uart1_clk1, 0, PCCR1, 31, NULL, NULL, &ipg_clk);
593
594/* Clocks we cannot directly gate, but drivers need their rates */
595DEFINE_CLOCK(cspi1_clk, 0, 0, 0, NULL, &cspi1_clk1, &per2_clk);
596DEFINE_CLOCK(cspi2_clk, 1, 0, 0, NULL, &cspi2_clk1, &per2_clk);
597DEFINE_CLOCK(cspi3_clk, 2, 0, 0, NULL, &cspi13_clk1, &per2_clk);
598DEFINE_CLOCK(sdhc1_clk, 0, 0, 0, NULL, &sdhc1_clk1, &per2_clk);
599DEFINE_CLOCK(sdhc2_clk, 1, 0, 0, NULL, &sdhc2_clk1, &per2_clk);
600DEFINE_CLOCK(sdhc3_clk, 2, 0, 0, NULL, &sdhc3_clk1, &per2_clk);
601DEFINE_CLOCK(pwm_clk, 0, 0, 0, NULL, &pwm_clk1, &per1_clk);
602DEFINE_CLOCK(gpt1_clk, 0, 0, 0, NULL, &gpt1_clk1, &per1_clk);
603DEFINE_CLOCK(gpt2_clk, 1, 0, 0, NULL, &gpt2_clk1, &per1_clk);
604DEFINE_CLOCK(gpt3_clk, 2, 0, 0, NULL, &gpt3_clk1, &per1_clk);
605DEFINE_CLOCK(gpt4_clk, 3, 0, 0, NULL, &gpt4_clk1, &per1_clk);
606DEFINE_CLOCK(gpt5_clk, 4, 0, 0, NULL, &gpt5_clk1, &per1_clk);
607DEFINE_CLOCK(gpt6_clk, 5, 0, 0, NULL, &gpt6_clk1, &per1_clk);
608DEFINE_CLOCK(uart1_clk, 0, 0, 0, NULL, &uart1_clk1, &per1_clk);
609DEFINE_CLOCK(uart2_clk, 1, 0, 0, NULL, &uart2_clk1, &per1_clk);
610DEFINE_CLOCK(uart3_clk, 2, 0, 0, NULL, &uart3_clk1, &per1_clk);
611DEFINE_CLOCK(uart4_clk, 3, 0, 0, NULL, &uart4_clk1, &per1_clk);
612DEFINE_CLOCK(uart5_clk, 4, 0, 0, NULL, &uart5_clk1, &per1_clk);
613DEFINE_CLOCK(uart6_clk, 5, 0, 0, NULL, &uart6_clk1, &per1_clk);
614DEFINE_CLOCK1(lcdc_clk, 0, 0, 0, parent, &lcdc_clk1, &per3_clk);
615DEFINE_CLOCK1(csi_clk, 0, 0, 0, parent, &csi_clk1, &per4_clk);
616
617#define _REGISTER_CLOCK(d, n, c) \
618 { \
619 .dev_id = d, \
620 .con_id = n, \
621 .clk = &c, \
1137 }, 622 },
1138};
1139
1140static struct clk nfc_clk = {
1141 .name = "nfc_clk",
1142 .parent = &cpu_clk,
1143 .get_rate = _clk_nfc_recalc,
1144 .enable = _clk_enable,
1145 .enable_reg = CCM_PCCR1,
1146 .enable_shift = CCM_PCCR1_NFC_BAUD_OFFSET,
1147 .disable = _clk_disable,
1148};
1149
1150static struct clk vpu_clk = {
1151 .name = "vpu_clk",
1152 .parent = &mpll_main_clk[1],
1153 .get_rate = _clk_vpu_recalc,
1154 .enable = _clk_vpu_enable,
1155 .disable = _clk_vpu_disable,
1156};
1157
1158static struct clk dma_clk = {
1159 .name = "dma_clk",
1160 .parent = &ahb_clk,
1161 .enable = _clk_dma_enable,
1162 .disable = _clk_dma_disable,
1163};
1164
1165static struct clk rtic_clk = {
1166 .name = "rtic_clk",
1167 .parent = &ahb_clk,
1168 .enable = _clk_rtic_enable,
1169 .disable = _clk_rtic_disable,
1170};
1171 623
1172static struct clk brom_clk = { 624static struct clk_lookup lookups[] __initdata = {
1173 .name = "brom_clk", 625 _REGISTER_CLOCK("imx-uart.0", NULL, uart1_clk)
1174 .parent = &ahb_clk, 626 _REGISTER_CLOCK("imx-uart.1", NULL, uart2_clk)
1175 .enable = _clk_enable, 627 _REGISTER_CLOCK("imx-uart.2", NULL, uart3_clk)
1176 .enable_reg = CCM_PCCR1, 628 _REGISTER_CLOCK("imx-uart.3", NULL, uart4_clk)
1177 .enable_shift = CCM_PCCR1_HCLK_BROM_OFFSET, 629 _REGISTER_CLOCK("imx-uart.4", NULL, uart5_clk)
1178 .disable = _clk_disable, 630 _REGISTER_CLOCK("imx-uart.5", NULL, uart6_clk)
1179}; 631 _REGISTER_CLOCK(NULL, "gpt1", gpt1_clk)
1180 632 _REGISTER_CLOCK(NULL, "gpt2", gpt2_clk)
1181static struct clk emma_clk = { 633 _REGISTER_CLOCK(NULL, "gpt3", gpt3_clk)
1182 .name = "emma_clk", 634 _REGISTER_CLOCK(NULL, "gpt4", gpt4_clk)
1183 .parent = &ahb_clk, 635 _REGISTER_CLOCK(NULL, "gpt5", gpt5_clk)
1184 .enable = _clk_emma_enable, 636 _REGISTER_CLOCK(NULL, "gpt6", gpt6_clk)
1185 .disable = _clk_emma_disable, 637 _REGISTER_CLOCK("mxc_pwm.0", NULL, pwm_clk)
1186}; 638 _REGISTER_CLOCK("mxc-mmc.0", NULL, sdhc1_clk)
1187 639 _REGISTER_CLOCK("mxc-mmc.1", NULL, sdhc2_clk)
1188static struct clk slcdc_clk = { 640 _REGISTER_CLOCK("mxc-mmc.2", NULL, sdhc3_clk)
1189 .name = "slcdc_clk", 641 _REGISTER_CLOCK(NULL, "cspi1", cspi1_clk)
1190 .parent = &ahb_clk, 642 _REGISTER_CLOCK(NULL, "cspi2", cspi2_clk)
1191 .enable = _clk_slcdc_enable, 643 _REGISTER_CLOCK(NULL, "cspi3", cspi3_clk)
1192 .disable = _clk_slcdc_disable, 644 _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk)
1193}; 645 _REGISTER_CLOCK(NULL, "csi", csi_clk)
1194 646 _REGISTER_CLOCK(NULL, "usb", usb_clk)
1195static struct clk fec_clk = { 647 _REGISTER_CLOCK(NULL, "ssi1", ssi1_clk)
1196 .name = "fec_clk", 648 _REGISTER_CLOCK(NULL, "ssi2", ssi2_clk)
1197 .parent = &ahb_clk, 649 _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk)
1198 .enable = _clk_fec_enable, 650 _REGISTER_CLOCK(NULL, "vpu", vpu_clk)
1199 .disable = _clk_fec_disable, 651 _REGISTER_CLOCK(NULL, "dma", dma_clk)
1200}; 652 _REGISTER_CLOCK(NULL, "rtic", rtic_clk)
1201 653 _REGISTER_CLOCK(NULL, "brom", brom_clk)
1202static struct clk emi_clk = { 654 _REGISTER_CLOCK(NULL, "emma", emma_clk)
1203 .name = "emi_clk", 655 _REGISTER_CLOCK(NULL, "slcdc", slcdc_clk)
1204 .parent = &ahb_clk, 656 _REGISTER_CLOCK("fec.0", NULL, fec_clk)
1205 .enable = _clk_enable, 657 _REGISTER_CLOCK(NULL, "emi", emi_clk)
1206 .enable_reg = CCM_PCCR1, 658 _REGISTER_CLOCK(NULL, "sahara2", sahara2_clk)
1207 .enable_shift = CCM_PCCR1_HCLK_EMI_OFFSET, 659 _REGISTER_CLOCK(NULL, "ata", ata_clk)
1208 .disable = _clk_disable, 660 _REGISTER_CLOCK(NULL, "mstick", mstick_clk)
1209}; 661 _REGISTER_CLOCK(NULL, "wdog", wdog_clk)
1210 662 _REGISTER_CLOCK(NULL, "gpio", gpio_clk)
1211static struct clk sahara2_clk = { 663 _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk)
1212 .name = "sahara_clk", 664 _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk)
1213 .parent = &ahb_clk, 665 _REGISTER_CLOCK(NULL, "iim", iim_clk)
1214 .enable = _clk_sahara2_enable, 666 _REGISTER_CLOCK(NULL, "kpp", kpp_clk)
1215 .disable = _clk_sahara2_disable, 667 _REGISTER_CLOCK("mxc_w1.0", NULL, owire_clk)
1216}; 668 _REGISTER_CLOCK(NULL, "rtc", rtc_clk)
1217 669 _REGISTER_CLOCK(NULL, "scc", scc_clk)
1218static struct clk ata_clk = { 670};
1219 .name = "ata_clk", 671
1220 .parent = &ahb_clk, 672/* Adjust the clock path for TO2 and later */
1221 .enable = _clk_enable, 673static void __init to2_adjust_clocks(void)
1222 .enable_reg = CCM_PCCR1, 674{
1223 .enable_shift = CCM_PCCR1_HCLK_ATA_OFFSET, 675 unsigned long cscr = __raw_readl(CCM_CSCR);
1224 .disable = _clk_disable,
1225};
1226
1227static struct clk mstick1_clk = {
1228 .name = "mstick1_clk",
1229 .parent = &ipg_clk,
1230 .enable = _clk_mstick1_enable,
1231 .disable = _clk_mstick1_disable,
1232};
1233
1234static struct clk wdog_clk = {
1235 .name = "wdog_clk",
1236 .parent = &ipg_clk,
1237 .enable = _clk_enable,
1238 .enable_reg = CCM_PCCR1,
1239 .enable_shift = CCM_PCCR1_WDT_OFFSET,
1240 .disable = _clk_disable,
1241};
1242
1243static struct clk gpio_clk = {
1244 .name = "gpio_clk",
1245 .parent = &ipg_clk,
1246 .enable = _clk_enable,
1247 .enable_reg = CCM_PCCR1,
1248 .enable_shift = CCM_PCCR0_GPIO_OFFSET,
1249 .disable = _clk_disable,
1250};
1251
1252static struct clk i2c_clk[] = {
1253 {
1254 .name = "i2c_clk",
1255 .id = 0,
1256 .parent = &ipg_clk,
1257 .enable = _clk_enable,
1258 .enable_reg = CCM_PCCR0,
1259 .enable_shift = CCM_PCCR0_I2C1_OFFSET,
1260 .disable = _clk_disable,
1261 }, {
1262 .name = "i2c_clk",
1263 .id = 1,
1264 .parent = &ipg_clk,
1265 .enable = _clk_enable,
1266 .enable_reg = CCM_PCCR0,
1267 .enable_shift = CCM_PCCR0_I2C2_OFFSET,
1268 .disable = _clk_disable,
1269 },
1270};
1271
1272static struct clk iim_clk = {
1273 .name = "iim_clk",
1274 .parent = &ipg_clk,
1275 .enable = _clk_enable,
1276 .enable_reg = CCM_PCCR0,
1277 .enable_shift = CCM_PCCR0_IIM_OFFSET,
1278 .disable = _clk_disable,
1279};
1280
1281static struct clk kpp_clk = {
1282 .name = "kpp_clk",
1283 .parent = &ipg_clk,
1284 .enable = _clk_enable,
1285 .enable_reg = CCM_PCCR0,
1286 .enable_shift = CCM_PCCR0_KPP_OFFSET,
1287 .disable = _clk_disable,
1288};
1289
1290static struct clk owire_clk = {
1291 .name = "owire_clk",
1292 .parent = &ipg_clk,
1293 .enable = _clk_enable,
1294 .enable_reg = CCM_PCCR0,
1295 .enable_shift = CCM_PCCR0_OWIRE_OFFSET,
1296 .disable = _clk_disable,
1297};
1298
1299static struct clk rtc_clk = {
1300 .name = "rtc_clk",
1301 .parent = &ipg_clk,
1302 .enable = _clk_enable,
1303 .enable_reg = CCM_PCCR0,
1304 .enable_shift = CCM_PCCR0_RTC_OFFSET,
1305 .disable = _clk_disable,
1306};
1307
1308static struct clk scc_clk = {
1309 .name = "scc_clk",
1310 .parent = &ipg_clk,
1311 .enable = _clk_enable,
1312 .enable_reg = CCM_PCCR0,
1313 .enable_shift = CCM_PCCR0_SCC_OFFSET,
1314 .disable = _clk_disable,
1315};
1316
1317static unsigned long _clk_clko_round_rate(struct clk *clk, unsigned long rate)
1318{
1319 u32 div;
1320 unsigned long parent_rate;
1321
1322 parent_rate = clk_get_rate(clk->parent);
1323 div = parent_rate / rate;
1324 if (parent_rate % rate)
1325 div++;
1326
1327 if (div > 8)
1328 div = 8;
1329
1330 return parent_rate / div;
1331}
1332
1333static int _clk_clko_set_rate(struct clk *clk, unsigned long rate)
1334{
1335 u32 reg;
1336 u32 div;
1337 unsigned long parent_rate;
1338
1339 parent_rate = clk_get_rate(clk->parent);
1340
1341 div = parent_rate / rate;
1342
1343 if (div > 8 || div < 1 || ((parent_rate / div) != rate))
1344 return -EINVAL;
1345 div--;
1346
1347 reg = __raw_readl(CCM_PCDR0) & ~CCM_PCDR0_CLKODIV_MASK;
1348 reg |= div << CCM_PCDR0_CLKODIV_OFFSET;
1349 __raw_writel(reg, CCM_PCDR0);
1350
1351 return 0;
1352}
1353
1354static unsigned long _clk_clko_recalc(struct clk *clk)
1355{
1356 u32 div;
1357 unsigned long parent_rate;
1358
1359 parent_rate = clk_get_rate(clk->parent);
1360
1361 div = __raw_readl(CCM_PCDR0) & CCM_PCDR0_CLKODIV_MASK >>
1362 CCM_PCDR0_CLKODIV_OFFSET;
1363 div++;
1364
1365 return parent_rate / div;
1366}
1367
1368static int _clk_clko_set_parent(struct clk *clk, struct clk *parent)
1369{
1370 u32 reg;
1371
1372 reg = __raw_readl(CCM_CCSR) & ~CCM_CCSR_CLKOSEL_MASK;
1373
1374 if (parent == &ckil_clk)
1375 reg |= 0 << CCM_CCSR_CLKOSEL_OFFSET;
1376 else if (parent == &ckih_clk)
1377 reg |= 2 << CCM_CCSR_CLKOSEL_OFFSET;
1378 else if (parent == mpll_clk.parent)
1379 reg |= 3 << CCM_CCSR_CLKOSEL_OFFSET;
1380 else if (parent == spll_clk.parent)
1381 reg |= 4 << CCM_CCSR_CLKOSEL_OFFSET;
1382 else if (parent == &mpll_clk)
1383 reg |= 5 << CCM_CCSR_CLKOSEL_OFFSET;
1384 else if (parent == &spll_clk)
1385 reg |= 6 << CCM_CCSR_CLKOSEL_OFFSET;
1386 else if (parent == &cpu_clk)
1387 reg |= 7 << CCM_CCSR_CLKOSEL_OFFSET;
1388 else if (parent == &ahb_clk)
1389 reg |= 8 << CCM_CCSR_CLKOSEL_OFFSET;
1390 else if (parent == &ipg_clk)
1391 reg |= 9 << CCM_CCSR_CLKOSEL_OFFSET;
1392 else if (parent == &per_clk[0])
1393 reg |= 0xA << CCM_CCSR_CLKOSEL_OFFSET;
1394 else if (parent == &per_clk[1])
1395 reg |= 0xB << CCM_CCSR_CLKOSEL_OFFSET;
1396 else if (parent == &per_clk[2])
1397 reg |= 0xC << CCM_CCSR_CLKOSEL_OFFSET;
1398 else if (parent == &per_clk[3])
1399 reg |= 0xD << CCM_CCSR_CLKOSEL_OFFSET;
1400 else if (parent == &ssi1_clk[0])
1401 reg |= 0xE << CCM_CCSR_CLKOSEL_OFFSET;
1402 else if (parent == &ssi2_clk[0])
1403 reg |= 0xF << CCM_CCSR_CLKOSEL_OFFSET;
1404 else if (parent == &nfc_clk)
1405 reg |= 0x10 << CCM_CCSR_CLKOSEL_OFFSET;
1406 else if (parent == &mstick1_clk)
1407 reg |= 0x11 << CCM_CCSR_CLKOSEL_OFFSET;
1408 else if (parent == &vpu_clk)
1409 reg |= 0x12 << CCM_CCSR_CLKOSEL_OFFSET;
1410 else if (parent == &usb_clk[0])
1411 reg |= 0x15 << CCM_CCSR_CLKOSEL_OFFSET;
1412 else
1413 return -EINVAL;
1414
1415 __raw_writel(reg, CCM_CCSR);
1416
1417 return 0;
1418}
1419
1420static int _clk_clko_enable(struct clk *clk)
1421{
1422 u32 reg;
1423
1424 reg = __raw_readl(CCM_PCDR0) | CCM_PCDR0_CLKO_EN;
1425 __raw_writel(reg, CCM_PCDR0);
1426
1427 return 0;
1428}
1429
1430static void _clk_clko_disable(struct clk *clk)
1431{
1432 u32 reg;
1433
1434 reg = __raw_readl(CCM_PCDR0) & ~CCM_PCDR0_CLKO_EN;
1435 __raw_writel(reg, CCM_PCDR0);
1436}
1437
1438static struct clk clko_clk = {
1439 .name = "clko_clk",
1440 .get_rate = _clk_clko_recalc,
1441 .set_rate = _clk_clko_set_rate,
1442 .round_rate = _clk_clko_round_rate,
1443 .set_parent = _clk_clko_set_parent,
1444 .enable = _clk_clko_enable,
1445 .disable = _clk_clko_disable,
1446};
1447
1448static struct clk *mxc_clks[] = {
1449 &ckih_clk,
1450 &ckil_clk,
1451 &mpll_clk,
1452 &mpll_main_clk[0],
1453 &mpll_main_clk[1],
1454 &spll_clk,
1455 &cpu_clk,
1456 &ahb_clk,
1457 &ipg_clk,
1458 &per_clk[0],
1459 &per_clk[1],
1460 &per_clk[2],
1461 &per_clk[3],
1462 &clko_clk,
1463 &uart1_clk[0],
1464 &uart1_clk[1],
1465 &uart2_clk[0],
1466 &uart2_clk[1],
1467 &uart3_clk[0],
1468 &uart3_clk[1],
1469 &uart4_clk[0],
1470 &uart4_clk[1],
1471 &uart5_clk[0],
1472 &uart5_clk[1],
1473 &uart6_clk[0],
1474 &uart6_clk[1],
1475 &gpt1_clk[0],
1476 &gpt1_clk[1],
1477 &gpt2_clk[0],
1478 &gpt2_clk[1],
1479 &gpt3_clk[0],
1480 &gpt3_clk[1],
1481 &gpt4_clk[0],
1482 &gpt4_clk[1],
1483 &gpt5_clk[0],
1484 &gpt5_clk[1],
1485 &gpt6_clk[0],
1486 &gpt6_clk[1],
1487 &pwm_clk[0],
1488 &pwm_clk[1],
1489 &sdhc1_clk[0],
1490 &sdhc1_clk[1],
1491 &sdhc2_clk[0],
1492 &sdhc2_clk[1],
1493 &sdhc3_clk[0],
1494 &sdhc3_clk[1],
1495 &cspi1_clk[0],
1496 &cspi1_clk[1],
1497 &cspi2_clk[0],
1498 &cspi2_clk[1],
1499 &cspi3_clk[0],
1500 &cspi3_clk[1],
1501 &lcdc_clk[0],
1502 &lcdc_clk[1],
1503 &lcdc_clk[2],
1504 &csi_clk[0],
1505 &csi_clk[1],
1506 &usb_clk[0],
1507 &usb_clk[1],
1508 &ssi1_clk[0],
1509 &ssi1_clk[1],
1510 &ssi2_clk[0],
1511 &ssi2_clk[1],
1512 &nfc_clk,
1513 &vpu_clk,
1514 &dma_clk,
1515 &rtic_clk,
1516 &brom_clk,
1517 &emma_clk,
1518 &slcdc_clk,
1519 &fec_clk,
1520 &emi_clk,
1521 &sahara2_clk,
1522 &ata_clk,
1523 &mstick1_clk,
1524 &wdog_clk,
1525 &gpio_clk,
1526 &i2c_clk[0],
1527 &i2c_clk[1],
1528 &iim_clk,
1529 &kpp_clk,
1530 &owire_clk,
1531 &rtc_clk,
1532 &scc_clk,
1533};
1534
1535void __init change_external_low_reference(unsigned long new_ref)
1536{
1537 external_low_reference = new_ref;
1538}
1539
1540unsigned long __init clk_early_get_timer_rate(void)
1541{
1542 return clk_get_rate(&per_clk[0]);
1543}
1544
1545static void __init probe_mxc_clocks(void)
1546{
1547 int i;
1548 676
1549 if (mx27_revision() >= CHIP_REV_2_0) { 677 if (mx27_revision() >= CHIP_REV_2_0) {
1550 if (CSCR() & 0x8000) 678 if (cscr & CCM_CSCR_ARM_SRC)
1551 cpu_clk.parent = &mpll_main_clk[0]; 679 cpu_clk.parent = &mpll_main1_clk;
1552 680
1553 if (!(CSCR() & 0x00800000)) 681 if (!(cscr & CCM_CSCR_SSI2))
1554 ssi2_clk[0].parent = &spll_clk; 682 ssi1_clk.parent = &spll_clk;
1555 683
1556 if (!(CSCR() & 0x00400000)) 684 if (!(cscr & CCM_CSCR_SSI1))
1557 ssi1_clk[0].parent = &spll_clk; 685 ssi1_clk.parent = &spll_clk;
1558 686
1559 if (!(CSCR() & 0x00200000)) 687 if (!(cscr & CCM_CSCR_VPU))
1560 vpu_clk.parent = &spll_clk; 688 vpu_clk.parent = &spll_clk;
1561 } else { 689 } else {
1562 cpu_clk.parent = &mpll_clk; 690 cpu_clk.parent = &mpll_clk;
@@ -1565,11 +693,13 @@ static void __init probe_mxc_clocks(void)
1565 cpu_clk.set_rate = NULL; 693 cpu_clk.set_rate = NULL;
1566 ahb_clk.parent = &mpll_clk; 694 ahb_clk.parent = &mpll_clk;
1567 695
1568 for (i = 0; i < sizeof(per_clk) / sizeof(per_clk[0]); i++) 696 per1_clk.parent = &mpll_clk;
1569 per_clk[i].parent = &mpll_clk; 697 per2_clk.parent = &mpll_clk;
698 per3_clk.parent = &mpll_clk;
699 per4_clk.parent = &mpll_clk;
1570 700
1571 ssi1_clk[0].parent = &mpll_clk; 701 ssi1_clk.parent = &mpll_clk;
1572 ssi2_clk[0].parent = &mpll_clk; 702 ssi2_clk.parent = &mpll_clk;
1573 703
1574 vpu_clk.parent = &mpll_clk; 704 vpu_clk.parent = &mpll_clk;
1575 } 705 }
@@ -1579,47 +709,47 @@ static void __init probe_mxc_clocks(void)
1579 * must be called very early to get information about the 709 * must be called very early to get information about the
1580 * available clock rate when the timer framework starts 710 * available clock rate when the timer framework starts
1581 */ 711 */
1582int __init mxc_clocks_init(unsigned long fref) 712int __init mx27_clocks_init(unsigned long fref)
1583{ 713{
1584 u32 cscr; 714 u32 cscr = __raw_readl(CCM_CSCR);
1585 struct clk **clkp; 715 int i;
1586 716
1587 external_high_reference = fref; 717 external_high_reference = fref;
1588 718
1589 /* detect clock reference for both system PLL */ 719 /* detect clock reference for both system PLLs */
1590 cscr = CSCR();
1591 if (cscr & CCM_CSCR_MCU) 720 if (cscr & CCM_CSCR_MCU)
1592 mpll_clk.parent = &ckih_clk; 721 mpll_clk.parent = &ckih_clk;
1593 else 722 else
1594 mpll_clk.parent = &ckil_clk; 723 mpll_clk.parent = &fpm_clk;
1595 724
1596 if (cscr & CCM_CSCR_SP) 725 if (cscr & CCM_CSCR_SP)
1597 spll_clk.parent = &ckih_clk; 726 spll_clk.parent = &ckih_clk;
1598 else 727 else
1599 spll_clk.parent = &ckil_clk; 728 spll_clk.parent = &fpm_clk;
1600 729
1601 probe_mxc_clocks(); 730 to2_adjust_clocks();
1602 731
1603 per_clk[0].enable(&per_clk[0]); 732 for (i = 0; i < ARRAY_SIZE(lookups); i++)
1604 gpt1_clk[1].enable(&gpt1_clk[1]); 733 clkdev_add(&lookups[i]);
1605 734
1606 for (clkp = mxc_clks; clkp < mxc_clks + ARRAY_SIZE(mxc_clks); clkp++) 735 /* Turn off all clocks we do not need */
1607 clk_register(*clkp); 736 __raw_writel(0, CCM_PCCR0);
737 __raw_writel((1 << 10) | (1 << 19), CCM_PCCR1);
1608 738
1609 /* Turn off all possible clocks */
1610 __raw_writel(CCM_PCCR0_GPT1_MASK, CCM_PCCR0);
1611 __raw_writel(CCM_PCCR1_PERCLK1_MASK | CCM_PCCR1_HCLK_EMI_MASK,
1612 CCM_PCCR1);
1613 spll_clk.disable(&spll_clk); 739 spll_clk.disable(&spll_clk);
1614 740
1615 /* This will propagate to all children and init all the clock rates */ 741 /* enable basic clocks */
1616 742 clk_enable(&per1_clk);
1617 clk_enable(&emi_clk);
1618 clk_enable(&gpio_clk); 743 clk_enable(&gpio_clk);
744 clk_enable(&emi_clk);
1619 clk_enable(&iim_clk); 745 clk_enable(&iim_clk);
1620 clk_enable(&gpt1_clk[0]); 746
1621#ifdef CONFIG_DEBUG_LL_CONSOLE 747#ifdef CONFIG_DEBUG_LL_CONSOLE
1622 clk_enable(&uart1_clk[0]); 748 clk_enable(&uart1_clk);
1623#endif 749#endif
750
751 mxc_timer_init(&gpt1_clk);
752
1624 return 0; 753 return 0;
1625} 754}
755
diff --git a/arch/arm/mach-mx2/cpu_imx27.c b/arch/arm/mach-mx2/cpu_imx27.c
index 239308fe6652..d9e3bf9644c9 100644
--- a/arch/arm/mach-mx2/cpu_imx27.c
+++ b/arch/arm/mach-mx2/cpu_imx27.c
@@ -26,11 +26,11 @@
26 26
27#include <mach/hardware.h> 27#include <mach/hardware.h>
28 28
29#include "crm_regs.h"
30
31static int cpu_silicon_rev = -1; 29static int cpu_silicon_rev = -1;
32static int cpu_partnumber; 30static int cpu_partnumber;
33 31
32#define SYS_CHIP_ID 0x00 /* The offset of CHIP ID register */
33
34static void query_silicon_parameter(void) 34static void query_silicon_parameter(void)
35{ 35{
36 u32 val; 36 u32 val;
diff --git a/arch/arm/mach-mx2/crm_regs.h b/arch/arm/mach-mx2/crm_regs.h
index 94644cd0a0fc..749de76b3f95 100644
--- a/arch/arm/mach-mx2/crm_regs.h
+++ b/arch/arm/mach-mx2/crm_regs.h
@@ -38,42 +38,36 @@
38#define CCM_PMCOUNT (IO_ADDRESS(CCM_BASE_ADDR) + 0x30) 38#define CCM_PMCOUNT (IO_ADDRESS(CCM_BASE_ADDR) + 0x30)
39#define CCM_WKGDCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x34) 39#define CCM_WKGDCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x34)
40 40
41#define CCM_CSCR_USB_OFFSET 28 41#define CCM_CSCR_PRESC_OFFSET 29
42#define CCM_CSCR_USB_MASK (0x7 << 28) 42#define CCM_CSCR_PRESC_MASK (0x7 << CCM_CSCR_PRESC_OFFSET)
43
44#define CCM_CSCR_USB_OFFSET 26
45#define CCM_CSCR_USB_MASK (0x7 << CCM_CSCR_USB_OFFSET)
43#define CCM_CSCR_SD_OFFSET 24 46#define CCM_CSCR_SD_OFFSET 24
44#define CCM_CSCR_SD_MASK (0x3 << 24) 47#define CCM_CSCR_SD_MASK (0x3 << CCM_CSCR_SD_OFFSET)
45#define CCM_CSCR_SSI2 (1 << 23) 48#define CCM_CSCR_SPLLRES (1 << 22)
46#define CCM_CSCR_SSI2_OFFSET 23 49#define CCM_CSCR_MPLLRES (1 << 21)
47#define CCM_CSCR_SSI1 (1 << 22) 50#define CCM_CSCR_SSI2_OFFSET 20
48#define CCM_CSCR_SSI1_OFFSET 22 51#define CCM_CSCR_SSI2 (1 << CCM_CSCR_SSI2_OFFSET)
49#define CCM_CSCR_VPU (1 << 21) 52#define CCM_CSCR_SSI1_OFFSET 19
50#define CCM_CSCR_VPU_OFFSET 21 53#define CCM_CSCR_SSI1 (1 << CCM_CSCR_SSI1_OFFSET)
51#define CCM_CSCR_MSHC (1 << 20) 54#define CCM_CSCR_FIR_OFFSET 18
52#define CCM_CSCR_SPLLRES (1 << 19) 55#define CCM_CSCR_FIR (1 << CCM_CSCR_FIR_OFFSET)
53#define CCM_CSCR_MPLLRES (1 << 18)
54#define CCM_CSCR_SP (1 << 17) 56#define CCM_CSCR_SP (1 << 17)
55#define CCM_CSCR_MCU (1 << 16) 57#define CCM_CSCR_MCU (1 << 16)
56/* CCM_CSCR_ARM_xxx just be avaliable on i.MX27 TO2*/ 58#define CCM_CSCR_BCLK_OFFSET 10
57#define CCM_CSCR_ARM_SRC (1 << 15) 59#define CCM_CSCR_BCLK_MASK (0xf << CCM_CSCR_BCLK_OFFSET)
58#define CCM_CSCR_ARM_OFFSET 12 60#define CCM_CSCR_IPDIV_OFFSET 9
59#define CCM_CSCR_ARM_MASK (0x3 << 12) 61#define CCM_CSCR_IPDIV (1 << CCM_CSCR_IPDIV_OFFSET)
60/* CCM_CSCR_ARM_xxx just be avaliable on i.MX27 TO2*/ 62
61#define CCM_CSCR_PRESC_OFFSET 13
62#define CCM_CSCR_PRESC_MASK (0x7 << 13)
63#define CCM_CSCR_BCLK_OFFSET 9
64#define CCM_CSCR_BCLK_MASK (0xf << 9)
65#define CCM_CSCR_IPDIV_OFFSET 8
66#define CCM_CSCR_IPDIV (1 << 8)
67/* CCM_CSCR_AHB_xxx just be avaliable on i.MX27 TO2*/
68#define CCM_CSCR_AHB_OFFSET 8
69#define CCM_CSCR_AHB_MASK (0x3 << 8)
70/* CCM_CSCR_AHB_xxx just be avaliable on i.MX27 TO2*/
71#define CCM_CSCR_OSC26MDIV (1 << 4) 63#define CCM_CSCR_OSC26MDIV (1 << 4)
72#define CCM_CSCR_OSC26M (1 << 3) 64#define CCM_CSCR_OSC26M (1 << 3)
73#define CCM_CSCR_FPM (1 << 2) 65#define CCM_CSCR_FPM (1 << 2)
74#define CCM_CSCR_SPEN (1 << 1) 66#define CCM_CSCR_SPEN (1 << 1)
75#define CCM_CSCR_MPEN 1 67#define CCM_CSCR_MPEN 1
76 68
69
70
77#define CCM_MPCTL0_CPLM (1 << 31) 71#define CCM_MPCTL0_CPLM (1 << 31)
78#define CCM_MPCTL0_PD_OFFSET 26 72#define CCM_MPCTL0_PD_OFFSET 26
79#define CCM_MPCTL0_PD_MASK (0xf << 26) 73#define CCM_MPCTL0_PD_MASK (0xf << 26)
@@ -109,25 +103,14 @@
109 103
110#define CCM_PCDR0_SSI2BAUDDIV_OFFSET 26 104#define CCM_PCDR0_SSI2BAUDDIV_OFFSET 26
111#define CCM_PCDR0_SSI2BAUDDIV_MASK (0x3f << 26) 105#define CCM_PCDR0_SSI2BAUDDIV_MASK (0x3f << 26)
112#define CCM_PCDR0_CLKO_EN 25
113#define CCM_PCDR0_CLKODIV_OFFSET 22
114#define CCM_PCDR0_CLKODIV_MASK (0x7 << 22)
115#define CCM_PCDR0_SSI1BAUDDIV_OFFSET 16 106#define CCM_PCDR0_SSI1BAUDDIV_OFFSET 16
116#define CCM_PCDR0_SSI1BAUDDIV_MASK (0x3f << 16) 107#define CCM_PCDR0_SSI1BAUDDIV_MASK (0x3f << 16)
117/*The difinition for i.MX27 TO2*/
118#define CCM_PCDR0_VPUDIV2_OFFSET 10
119#define CCM_PCDR0_VPUDIV2_MASK (0x3f << 10)
120#define CCM_PCDR0_NFCDIV2_OFFSET 6
121#define CCM_PCDR0_NFCDIV2_MASK (0xf << 6)
122#define CCM_PCDR0_MSHCDIV2_MASK 0x3f
123/*The difinition for i.MX27 TO2*/
124#define CCM_PCDR0_NFCDIV_OFFSET 12 108#define CCM_PCDR0_NFCDIV_OFFSET 12
125#define CCM_PCDR0_NFCDIV_MASK (0xf << 12) 109#define CCM_PCDR0_NFCDIV_MASK (0xf << 12)
126#define CCM_PCDR0_VPUDIV_OFFSET 8 110#define CCM_PCDR0_48MDIV_OFFSET 5
127#define CCM_PCDR0_VPUDIV_MASK (0xf << 8) 111#define CCM_PCDR0_48MDIV_MASK (0x7 << CCM_PCDR0_48MDIV_OFFSET)
128#define CCM_PCDR0_MSHCDIV_OFFSET 0 112#define CCM_PCDR0_FIRIDIV_OFFSET 0
129#define CCM_PCDR0_MSHCDIV_MASK 0x1f 113#define CCM_PCDR0_FIRIDIV_MASK 0x1f
130
131#define CCM_PCDR1_PERDIV4_OFFSET 24 114#define CCM_PCDR1_PERDIV4_OFFSET 24
132#define CCM_PCDR1_PERDIV4_MASK (0x3f << 24) 115#define CCM_PCDR1_PERDIV4_MASK (0x3f << 24)
133#define CCM_PCDR1_PERDIV3_OFFSET 16 116#define CCM_PCDR1_PERDIV3_OFFSET 16
@@ -137,133 +120,135 @@
137#define CCM_PCDR1_PERDIV1_OFFSET 0 120#define CCM_PCDR1_PERDIV1_OFFSET 0
138#define CCM_PCDR1_PERDIV1_MASK 0x3f 121#define CCM_PCDR1_PERDIV1_MASK 0x3f
139 122
140#define CCM_PCCR0_CSPI1_OFFSET 31 123#define CCM_PCCR_HCLK_CSI_OFFSET 31
141#define CCM_PCCR0_CSPI1_MASK (1 << 31) 124#define CCM_PCCR_HCLK_CSI_REG CCM_PCCR0
142#define CCM_PCCR0_CSPI2_OFFSET 30 125#define CCM_PCCR_HCLK_DMA_OFFSET 30
143#define CCM_PCCR0_CSPI2_MASK (1 << 30) 126#define CCM_PCCR_HCLK_DMA_REG CCM_PCCR0
144#define CCM_PCCR0_CSPI3_OFFSET 29 127#define CCM_PCCR_HCLK_BROM_OFFSET 28
145#define CCM_PCCR0_CSPI3_MASK (1 << 29) 128#define CCM_PCCR_HCLK_BROM_REG CCM_PCCR0
146#define CCM_PCCR0_DMA_OFFSET 28 129#define CCM_PCCR_HCLK_EMMA_OFFSET 27
147#define CCM_PCCR0_DMA_MASK (1 << 28) 130#define CCM_PCCR_HCLK_EMMA_REG CCM_PCCR0
148#define CCM_PCCR0_EMMA_OFFSET 27 131#define CCM_PCCR_HCLK_LCDC_OFFSET 26
149#define CCM_PCCR0_EMMA_MASK (1 << 27) 132#define CCM_PCCR_HCLK_LCDC_REG CCM_PCCR0
150#define CCM_PCCR0_FEC_OFFSET 26 133#define CCM_PCCR_HCLK_SLCDC_OFFSET 25
151#define CCM_PCCR0_FEC_MASK (1 << 26) 134#define CCM_PCCR_HCLK_SLCDC_REG CCM_PCCR0
152#define CCM_PCCR0_GPIO_OFFSET 25 135#define CCM_PCCR_HCLK_USBOTG_OFFSET 24
153#define CCM_PCCR0_GPIO_MASK (1 << 25) 136#define CCM_PCCR_HCLK_USBOTG_REG CCM_PCCR0
154#define CCM_PCCR0_GPT1_OFFSET 24 137#define CCM_PCCR_HCLK_BMI_OFFSET 23
155#define CCM_PCCR0_GPT1_MASK (1 << 24) 138#define CCM_PCCR_BMI_MASK (1 << CCM_PCCR_BMI_MASK)
156#define CCM_PCCR0_GPT2_OFFSET 23 139#define CCM_PCCR_HCLK_BMI_REG CCM_PCCR0
157#define CCM_PCCR0_GPT2_MASK (1 << 23) 140#define CCM_PCCR_PERCLK4_OFFSET 22
158#define CCM_PCCR0_GPT3_OFFSET 22 141#define CCM_PCCR_PERCLK4_REG CCM_PCCR0
159#define CCM_PCCR0_GPT3_MASK (1 << 22) 142#define CCM_PCCR_SLCDC_OFFSET 21
160#define CCM_PCCR0_GPT4_OFFSET 21 143#define CCM_PCCR_SLCDC_REG CCM_PCCR0
161#define CCM_PCCR0_GPT4_MASK (1 << 21) 144#define CCM_PCCR_FIRI_BAUD_OFFSET 20
162#define CCM_PCCR0_GPT5_OFFSET 20 145#define CCM_PCCR_FIRI_BAUD_MASK (1 << CCM_PCCR_FIRI_BAUD_MASK)
163#define CCM_PCCR0_GPT5_MASK (1 << 20) 146#define CCM_PCCR_FIRI_BAUD_REG CCM_PCCR0
164#define CCM_PCCR0_GPT6_OFFSET 19 147#define CCM_PCCR_NFC_OFFSET 19
165#define CCM_PCCR0_GPT6_MASK (1 << 19) 148#define CCM_PCCR_NFC_REG CCM_PCCR0
166#define CCM_PCCR0_I2C1_OFFSET 18 149#define CCM_PCCR_LCDC_OFFSET 18
167#define CCM_PCCR0_I2C1_MASK (1 << 18) 150#define CCM_PCCR_LCDC_REG CCM_PCCR0
168#define CCM_PCCR0_I2C2_OFFSET 17 151#define CCM_PCCR_SSI1_BAUD_OFFSET 17
169#define CCM_PCCR0_I2C2_MASK (1 << 17) 152#define CCM_PCCR_SSI1_BAUD_REG CCM_PCCR0
170#define CCM_PCCR0_IIM_OFFSET 16 153#define CCM_PCCR_SSI2_BAUD_OFFSET 16
171#define CCM_PCCR0_IIM_MASK (1 << 16) 154#define CCM_PCCR_SSI2_BAUD_REG CCM_PCCR0
172#define CCM_PCCR0_KPP_OFFSET 15 155#define CCM_PCCR_EMMA_OFFSET 15
173#define CCM_PCCR0_KPP_MASK (1 << 15) 156#define CCM_PCCR_EMMA_REG CCM_PCCR0
174#define CCM_PCCR0_LCDC_OFFSET 14 157#define CCM_PCCR_USBOTG_OFFSET 14
175#define CCM_PCCR0_LCDC_MASK (1 << 14) 158#define CCM_PCCR_USBOTG_REG CCM_PCCR0
176#define CCM_PCCR0_MSHC_OFFSET 13 159#define CCM_PCCR_DMA_OFFSET 13
177#define CCM_PCCR0_MSHC_MASK (1 << 13) 160#define CCM_PCCR_DMA_REG CCM_PCCR0
178#define CCM_PCCR0_OWIRE_OFFSET 12 161#define CCM_PCCR_I2C1_OFFSET 12
179#define CCM_PCCR0_OWIRE_MASK (1 << 12) 162#define CCM_PCCR_I2C1_REG CCM_PCCR0
180#define CCM_PCCR0_PWM_OFFSET 11 163#define CCM_PCCR_GPIO_OFFSET 11
181#define CCM_PCCR0_PWM_MASK (1 << 11) 164#define CCM_PCCR_GPIO_REG CCM_PCCR0
182#define CCM_PCCR0_RTC_OFFSET 9 165#define CCM_PCCR_SDHC2_OFFSET 10
183#define CCM_PCCR0_RTC_MASK (1 << 9) 166#define CCM_PCCR_SDHC2_REG CCM_PCCR0
184#define CCM_PCCR0_RTIC_OFFSET 8 167#define CCM_PCCR_SDHC1_OFFSET 9
185#define CCM_PCCR0_RTIC_MASK (1 << 8) 168#define CCM_PCCR_SDHC1_REG CCM_PCCR0
186#define CCM_PCCR0_SAHARA_OFFSET 7 169#define CCM_PCCR_FIRI_OFFSET 8
187#define CCM_PCCR0_SAHARA_MASK (1 << 7) 170#define CCM_PCCR_FIRI_MASK (1 << CCM_PCCR_BAUD_MASK)
188#define CCM_PCCR0_SCC_OFFSET 6 171#define CCM_PCCR_FIRI_REG CCM_PCCR0
189#define CCM_PCCR0_SCC_MASK (1 << 6) 172#define CCM_PCCR_SSI2_IPG_OFFSET 7
190#define CCM_PCCR0_SDHC1_OFFSET 5 173#define CCM_PCCR_SSI2_REG CCM_PCCR0
191#define CCM_PCCR0_SDHC1_MASK (1 << 5) 174#define CCM_PCCR_SSI1_IPG_OFFSET 6
192#define CCM_PCCR0_SDHC2_OFFSET 4 175#define CCM_PCCR_SSI1_REG CCM_PCCR0
193#define CCM_PCCR0_SDHC2_MASK (1 << 4) 176#define CCM_PCCR_CSPI2_OFFSET 5
194#define CCM_PCCR0_SDHC3_OFFSET 3 177#define CCM_PCCR_CSPI2_REG CCM_PCCR0
195#define CCM_PCCR0_SDHC3_MASK (1 << 3) 178#define CCM_PCCR_CSPI1_OFFSET 4
196#define CCM_PCCR0_SLCDC_OFFSET 2 179#define CCM_PCCR_CSPI1_REG CCM_PCCR0
197#define CCM_PCCR0_SLCDC_MASK (1 << 2) 180#define CCM_PCCR_UART4_OFFSET 3
198#define CCM_PCCR0_SSI1_IPG_OFFSET 1 181#define CCM_PCCR_UART4_REG CCM_PCCR0
199#define CCM_PCCR0_SSI1_IPG_MASK (1 << 1) 182#define CCM_PCCR_UART3_OFFSET 2
200#define CCM_PCCR0_SSI2_IPG_OFFSET 0 183#define CCM_PCCR_UART3_REG CCM_PCCR0
201#define CCM_PCCR0_SSI2_IPG_MASK (1 << 0) 184#define CCM_PCCR_UART2_OFFSET 1
185#define CCM_PCCR_UART2_REG CCM_PCCR0
186#define CCM_PCCR_UART1_OFFSET 0
187#define CCM_PCCR_UART1_REG CCM_PCCR0
188
189#define CCM_PCCR_OWIRE_OFFSET 31
190#define CCM_PCCR_OWIRE_REG CCM_PCCR1
191#define CCM_PCCR_KPP_OFFSET 30
192#define CCM_PCCR_KPP_REG CCM_PCCR1
193#define CCM_PCCR_RTC_OFFSET 29
194#define CCM_PCCR_RTC_REG CCM_PCCR1
195#define CCM_PCCR_PWM_OFFSET 28
196#define CCM_PCCR_PWM_REG CCM_PCCR1
197#define CCM_PCCR_GPT3_OFFSET 27
198#define CCM_PCCR_GPT3_REG CCM_PCCR1
199#define CCM_PCCR_GPT2_OFFSET 26
200#define CCM_PCCR_GPT2_REG CCM_PCCR1
201#define CCM_PCCR_GPT1_OFFSET 25
202#define CCM_PCCR_GPT1_REG CCM_PCCR1
203#define CCM_PCCR_WDT_OFFSET 24
204#define CCM_PCCR_WDT_REG CCM_PCCR1
205#define CCM_PCCR_CSPI3_OFFSET 23
206#define CCM_PCCR_CSPI3_REG CCM_PCCR1
207
208#define CCM_PCCR_CSPI1_MASK (1 << CCM_PCCR_CSPI1_OFFSET)
209#define CCM_PCCR_CSPI2_MASK (1 << CCM_PCCR_CSPI2_OFFSET)
210#define CCM_PCCR_CSPI3_MASK (1 << CCM_PCCR_CSPI3_OFFSET)
211#define CCM_PCCR_DMA_MASK (1 << CCM_PCCR_DMA_OFFSET)
212#define CCM_PCCR_EMMA_MASK (1 << CCM_PCCR_EMMA_OFFSET)
213#define CCM_PCCR_GPIO_MASK (1 << CCM_PCCR_GPIO_OFFSET)
214#define CCM_PCCR_GPT1_MASK (1 << CCM_PCCR_GPT1_OFFSET)
215#define CCM_PCCR_GPT2_MASK (1 << CCM_PCCR_GPT2_OFFSET)
216#define CCM_PCCR_GPT3_MASK (1 << CCM_PCCR_GPT3_OFFSET)
217#define CCM_PCCR_HCLK_BROM_MASK (1 << CCM_PCCR_HCLK_BROM_OFFSET)
218#define CCM_PCCR_HCLK_CSI_MASK (1 << CCM_PCCR_HCLK_CSI_OFFSET)
219#define CCM_PCCR_HCLK_DMA_MASK (1 << CCM_PCCR_HCLK_DMA_OFFSET)
220#define CCM_PCCR_HCLK_EMMA_MASK (1 << CCM_PCCR_HCLK_EMMA_OFFSET)
221#define CCM_PCCR_HCLK_LCDC_MASK (1 << CCM_PCCR_HCLK_LCDC_OFFSET)
222#define CCM_PCCR_HCLK_SLCDC_MASK (1 << CCM_PCCR_HCLK_SLCDC_OFFSET)
223#define CCM_PCCR_HCLK_USBOTG_MASK (1 << CCM_PCCR_HCLK_USBOTG_OFFSET)
224#define CCM_PCCR_I2C1_MASK (1 << CCM_PCCR_I2C1_OFFSET)
225#define CCM_PCCR_KPP_MASK (1 << CCM_PCCR_KPP_OFFSET)
226#define CCM_PCCR_LCDC_MASK (1 << CCM_PCCR_LCDC_OFFSET)
227#define CCM_PCCR_NFC_MASK (1 << CCM_PCCR_NFC_OFFSET)
228#define CCM_PCCR_OWIRE_MASK (1 << CCM_PCCR_OWIRE_OFFSET)
229#define CCM_PCCR_PERCLK4_MASK (1 << CCM_PCCR_PERCLK4_OFFSET)
230#define CCM_PCCR_PWM_MASK (1 << CCM_PCCR_PWM_OFFSET)
231#define CCM_PCCR_RTC_MASK (1 << CCM_PCCR_RTC_OFFSET)
232#define CCM_PCCR_SDHC1_MASK (1 << CCM_PCCR_SDHC1_OFFSET)
233#define CCM_PCCR_SDHC2_MASK (1 << CCM_PCCR_SDHC2_OFFSET)
234#define CCM_PCCR_SLCDC_MASK (1 << CCM_PCCR_SLCDC_OFFSET)
235#define CCM_PCCR_SSI1_BAUD_MASK (1 << CCM_PCCR_SSI1_BAUD_OFFSET)
236#define CCM_PCCR_SSI1_IPG_MASK (1 << CCM_PCCR_SSI1_IPG_OFFSET)
237#define CCM_PCCR_SSI2_BAUD_MASK (1 << CCM_PCCR_SSI2_BAUD_OFFSET)
238#define CCM_PCCR_SSI2_IPG_MASK (1 << CCM_PCCR_SSI2_IPG_OFFSET)
239#define CCM_PCCR_UART1_MASK (1 << CCM_PCCR_UART1_OFFSET)
240#define CCM_PCCR_UART2_MASK (1 << CCM_PCCR_UART2_OFFSET)
241#define CCM_PCCR_UART3_MASK (1 << CCM_PCCR_UART3_OFFSET)
242#define CCM_PCCR_UART4_MASK (1 << CCM_PCCR_UART4_OFFSET)
243#define CCM_PCCR_USBOTG_MASK (1 << CCM_PCCR_USBOTG_OFFSET)
244#define CCM_PCCR_WDT_MASK (1 << CCM_PCCR_WDT_OFFSET)
202 245
203#define CCM_PCCR1_UART1_OFFSET 31
204#define CCM_PCCR1_UART1_MASK (1 << 31)
205#define CCM_PCCR1_UART2_OFFSET 30
206#define CCM_PCCR1_UART2_MASK (1 << 30)
207#define CCM_PCCR1_UART3_OFFSET 29
208#define CCM_PCCR1_UART3_MASK (1 << 29)
209#define CCM_PCCR1_UART4_OFFSET 28
210#define CCM_PCCR1_UART4_MASK (1 << 28)
211#define CCM_PCCR1_UART5_OFFSET 27
212#define CCM_PCCR1_UART5_MASK (1 << 27)
213#define CCM_PCCR1_UART6_OFFSET 26
214#define CCM_PCCR1_UART6_MASK (1 << 26)
215#define CCM_PCCR1_USBOTG_OFFSET 25
216#define CCM_PCCR1_USBOTG_MASK (1 << 25)
217#define CCM_PCCR1_WDT_OFFSET 24
218#define CCM_PCCR1_WDT_MASK (1 << 24)
219#define CCM_PCCR1_HCLK_ATA_OFFSET 23
220#define CCM_PCCR1_HCLK_ATA_MASK (1 << 23)
221#define CCM_PCCR1_HCLK_BROM_OFFSET 22
222#define CCM_PCCR1_HCLK_BROM_MASK (1 << 22)
223#define CCM_PCCR1_HCLK_CSI_OFFSET 21
224#define CCM_PCCR1_HCLK_CSI_MASK (1 << 21)
225#define CCM_PCCR1_HCLK_DMA_OFFSET 20
226#define CCM_PCCR1_HCLK_DMA_MASK (1 << 20)
227#define CCM_PCCR1_HCLK_EMI_OFFSET 19
228#define CCM_PCCR1_HCLK_EMI_MASK (1 << 19)
229#define CCM_PCCR1_HCLK_EMMA_OFFSET 18
230#define CCM_PCCR1_HCLK_EMMA_MASK (1 << 18)
231#define CCM_PCCR1_HCLK_FEC_OFFSET 17
232#define CCM_PCCR1_HCLK_FEC_MASK (1 << 17)
233#define CCM_PCCR1_HCLK_VPU_OFFSET 16
234#define CCM_PCCR1_HCLK_VPU_MASK (1 << 16)
235#define CCM_PCCR1_HCLK_LCDC_OFFSET 15
236#define CCM_PCCR1_HCLK_LCDC_MASK (1 << 15)
237#define CCM_PCCR1_HCLK_RTIC_OFFSET 14
238#define CCM_PCCR1_HCLK_RTIC_MASK (1 << 14)
239#define CCM_PCCR1_HCLK_SAHARA_OFFSET 13
240#define CCM_PCCR1_HCLK_SAHARA_MASK (1 << 13)
241#define CCM_PCCR1_HCLK_SLCDC_OFFSET 12
242#define CCM_PCCR1_HCLK_SLCDC_MASK (1 << 12)
243#define CCM_PCCR1_HCLK_USBOTG_OFFSET 11
244#define CCM_PCCR1_HCLK_USBOTG_MASK (1 << 11)
245#define CCM_PCCR1_PERCLK1_OFFSET 10
246#define CCM_PCCR1_PERCLK1_MASK (1 << 10)
247#define CCM_PCCR1_PERCLK2_OFFSET 9
248#define CCM_PCCR1_PERCLK2_MASK (1 << 9)
249#define CCM_PCCR1_PERCLK3_OFFSET 8
250#define CCM_PCCR1_PERCLK3_MASK (1 << 8)
251#define CCM_PCCR1_PERCLK4_OFFSET 7
252#define CCM_PCCR1_PERCLK4_MASK (1 << 7)
253#define CCM_PCCR1_VPU_BAUD_OFFSET 6
254#define CCM_PCCR1_VPU_BAUD_MASK (1 << 6)
255#define CCM_PCCR1_SSI1_BAUD_OFFSET 5
256#define CCM_PCCR1_SSI1_BAUD_MASK (1 << 5)
257#define CCM_PCCR1_SSI2_BAUD_OFFSET 4
258#define CCM_PCCR1_SSI2_BAUD_MASK (1 << 4)
259#define CCM_PCCR1_NFC_BAUD_OFFSET 3
260#define CCM_PCCR1_NFC_BAUD_MASK (1 << 3)
261#define CCM_PCCR1_MSHC_BAUD_OFFSET 2
262#define CCM_PCCR1_MSHC_BAUD_MASK (1 << 2)
263 246
264#define CCM_CCSR_32KSR (1 << 15) 247#define CCM_CCSR_32KSR (1 << 15)
248
265#define CCM_CCSR_CLKMODE1 (1 << 9) 249#define CCM_CCSR_CLKMODE1 (1 << 9)
266#define CCM_CCSR_CLKMODE0 (1 << 8) 250#define CCM_CCSR_CLKMODE0 (1 << 8)
251
267#define CCM_CCSR_CLKOSEL_OFFSET 0 252#define CCM_CCSR_CLKOSEL_OFFSET 0
268#define CCM_CCSR_CLKOSEL_MASK 0x1f 253#define CCM_CCSR_CLKOSEL_MASK 0x1f
269 254
diff --git a/arch/arm/mach-mx2/devices.c b/arch/arm/mach-mx2/devices.c
index 2f9240be1c76..f81aa8a8fbb4 100644
--- a/arch/arm/mach-mx2/devices.c
+++ b/arch/arm/mach-mx2/devices.c
@@ -34,6 +34,10 @@
34 34
35#include <mach/irqs.h> 35#include <mach/irqs.h>
36#include <mach/hardware.h> 36#include <mach/hardware.h>
37#include <mach/common.h>
38#include <mach/mmc.h>
39
40#include "devices.h"
37 41
38/* 42/*
39 * Resource definition for the MXC IrDA 43 * Resource definition for the MXC IrDA
@@ -225,37 +229,217 @@ struct platform_device mxc_nand_device = {
225 .resource = mxc_nand_resources, 229 .resource = mxc_nand_resources,
226}; 230};
227 231
232#ifdef CONFIG_FB_IMX
233/*
234 * lcdc:
235 * - i.MX1: the basic controller
236 * - i.MX21: to be checked
237 * - i.MX27: like i.MX1, with slightly variations
238 */
239static struct resource mxc_fb[] = {
240 {
241 .start = LCDC_BASE_ADDR,
242 .end = LCDC_BASE_ADDR + 0xFFF,
243 .flags = IORESOURCE_MEM,
244 },
245 {
246 .start = MXC_INT_LCDC,
247 .end = MXC_INT_LCDC,
248 .flags = IORESOURCE_IRQ,
249 }
250};
251
252/* mxc lcd driver */
253struct platform_device mxc_fb_device = {
254 .name = "imx-fb",
255 .id = 0,
256 .num_resources = ARRAY_SIZE(mxc_fb),
257 .resource = mxc_fb,
258 .dev = {
259 .coherent_dma_mask = 0xFFFFFFFF,
260 },
261};
262#endif
263
264#ifdef CONFIG_MACH_MX27
265static struct resource mxc_fec_resources[] = {
266 {
267 .start = FEC_BASE_ADDR,
268 .end = FEC_BASE_ADDR + 0xfff,
269 .flags = IORESOURCE_MEM
270 }, {
271 .start = MXC_INT_FEC,
272 .end = MXC_INT_FEC,
273 .flags = IORESOURCE_IRQ
274 },
275};
276
277struct platform_device mxc_fec_device = {
278 .name = "fec",
279 .id = 0,
280 .num_resources = ARRAY_SIZE(mxc_fec_resources),
281 .resource = mxc_fec_resources,
282};
283#endif
284
285static struct resource mxc_i2c_1_resources[] = {
286 [0] = {
287 .start = I2C_BASE_ADDR,
288 .end = I2C_BASE_ADDR + 0x0fff,
289 .flags = IORESOURCE_MEM
290 },
291 [1] = {
292 .start = MXC_INT_I2C,
293 .end = MXC_INT_I2C,
294 .flags = IORESOURCE_IRQ
295 }
296};
297
298struct platform_device mxc_i2c_device0 = {
299 .name = "imx-i2c",
300 .id = 0,
301 .num_resources = ARRAY_SIZE(mxc_i2c_1_resources),
302 .resource = mxc_i2c_1_resources
303};
304
305#ifdef CONFIG_MACH_MX27
306static struct resource mxc_i2c_2_resources[] = {
307 [0] = {
308 .start = I2C2_BASE_ADDR,
309 .end = I2C2_BASE_ADDR + 0x0fff,
310 .flags = IORESOURCE_MEM
311 },
312 [1] = {
313 .start = MXC_INT_I2C2,
314 .end = MXC_INT_I2C2,
315 .flags = IORESOURCE_IRQ
316 }
317};
318
319struct platform_device mxc_i2c_device1 = {
320 .name = "imx-i2c",
321 .id = 1,
322 .num_resources = ARRAY_SIZE(mxc_i2c_2_resources),
323 .resource = mxc_i2c_2_resources
324};
325#endif
326
327static struct resource mxc_pwm_resources[] = {
328 [0] = {
329 .start = PWM_BASE_ADDR,
330 .end = PWM_BASE_ADDR + 0x0fff,
331 .flags = IORESOURCE_MEM
332 },
333 [1] = {
334 .start = MXC_INT_PWM,
335 .end = MXC_INT_PWM,
336 .flags = IORESOURCE_IRQ,
337 }
338};
339
340struct platform_device mxc_pwm_device = {
341 .name = "mxc_pwm",
342 .id = 0,
343 .num_resources = ARRAY_SIZE(mxc_pwm_resources),
344 .resource = mxc_pwm_resources
345};
346
347/*
348 * Resource definition for the MXC SDHC
349 */
350static struct resource mxc_sdhc1_resources[] = {
351 [0] = {
352 .start = SDHC1_BASE_ADDR,
353 .end = SDHC1_BASE_ADDR + SZ_4K - 1,
354 .flags = IORESOURCE_MEM,
355 },
356 [1] = {
357 .start = MXC_INT_SDHC1,
358 .end = MXC_INT_SDHC1,
359 .flags = IORESOURCE_IRQ,
360 },
361 [2] = {
362 .start = DMA_REQ_SDHC1,
363 .end = DMA_REQ_SDHC1,
364 .flags = IORESOURCE_DMA
365 },
366};
367
368static u64 mxc_sdhc1_dmamask = 0xffffffffUL;
369
370struct platform_device mxc_sdhc_device0 = {
371 .name = "mxc-mmc",
372 .id = 0,
373 .dev = {
374 .dma_mask = &mxc_sdhc1_dmamask,
375 .coherent_dma_mask = 0xffffffff,
376 },
377 .num_resources = ARRAY_SIZE(mxc_sdhc1_resources),
378 .resource = mxc_sdhc1_resources,
379};
380
381static struct resource mxc_sdhc2_resources[] = {
382 [0] = {
383 .start = SDHC2_BASE_ADDR,
384 .end = SDHC2_BASE_ADDR + SZ_4K - 1,
385 .flags = IORESOURCE_MEM,
386 },
387 [1] = {
388 .start = MXC_INT_SDHC2,
389 .end = MXC_INT_SDHC2,
390 .flags = IORESOURCE_IRQ,
391 },
392 [2] = {
393 .start = DMA_REQ_SDHC2,
394 .end = DMA_REQ_SDHC2,
395 .flags = IORESOURCE_DMA
396 },
397};
398
399static u64 mxc_sdhc2_dmamask = 0xffffffffUL;
400
401struct platform_device mxc_sdhc_device1 = {
402 .name = "mxc-mmc",
403 .id = 1,
404 .dev = {
405 .dma_mask = &mxc_sdhc2_dmamask,
406 .coherent_dma_mask = 0xffffffff,
407 },
408 .num_resources = ARRAY_SIZE(mxc_sdhc2_resources),
409 .resource = mxc_sdhc2_resources,
410};
411
228/* GPIO port description */ 412/* GPIO port description */
229static struct mxc_gpio_port imx_gpio_ports[] = { 413static struct mxc_gpio_port imx_gpio_ports[] = {
230 [0] = { 414 [0] = {
231 .chip.label = "gpio-0", 415 .chip.label = "gpio-0",
232 .irq = MXC_INT_GPIO, 416 .irq = MXC_INT_GPIO,
233 .base = (void*)(AIPI_BASE_ADDR_VIRT + 0x15000 + 0x100 * 0), 417 .base = IO_ADDRESS(GPIO_BASE_ADDR),
234 .virtual_irq_start = MXC_GPIO_IRQ_START, 418 .virtual_irq_start = MXC_GPIO_IRQ_START,
235 }, 419 },
236 [1] = { 420 [1] = {
237 .chip.label = "gpio-1", 421 .chip.label = "gpio-1",
238 .base = (void*)(AIPI_BASE_ADDR_VIRT + 0x15000 + 0x100 * 1), 422 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x100),
239 .virtual_irq_start = MXC_GPIO_IRQ_START + 32, 423 .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
240 }, 424 },
241 [2] = { 425 [2] = {
242 .chip.label = "gpio-2", 426 .chip.label = "gpio-2",
243 .base = (void*)(AIPI_BASE_ADDR_VIRT + 0x15000 + 0x100 * 2), 427 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x200),
244 .virtual_irq_start = MXC_GPIO_IRQ_START + 64, 428 .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
245 }, 429 },
246 [3] = { 430 [3] = {
247 .chip.label = "gpio-3", 431 .chip.label = "gpio-3",
248 .base = (void*)(AIPI_BASE_ADDR_VIRT + 0x15000 + 0x100 * 3), 432 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x300),
249 .virtual_irq_start = MXC_GPIO_IRQ_START + 96, 433 .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
250 }, 434 },
251 [4] = { 435 [4] = {
252 .chip.label = "gpio-4", 436 .chip.label = "gpio-4",
253 .base = (void*)(AIPI_BASE_ADDR_VIRT + 0x15000 + 0x100 * 4), 437 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x400),
254 .virtual_irq_start = MXC_GPIO_IRQ_START + 128, 438 .virtual_irq_start = MXC_GPIO_IRQ_START + 128,
255 }, 439 },
256 [5] = { 440 [5] = {
257 .chip.label = "gpio-5", 441 .chip.label = "gpio-5",
258 .base = (void*)(AIPI_BASE_ADDR_VIRT + 0x15000 + 0x100 * 5), 442 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x500),
259 .virtual_irq_start = MXC_GPIO_IRQ_START + 160, 443 .virtual_irq_start = MXC_GPIO_IRQ_START + 160,
260 } 444 }
261}; 445};
diff --git a/arch/arm/mach-mx2/devices.h b/arch/arm/mach-mx2/devices.h
index 1e8cb577a642..049005bb6aa9 100644
--- a/arch/arm/mach-mx2/devices.h
+++ b/arch/arm/mach-mx2/devices.h
@@ -1,4 +1,3 @@
1
2extern struct platform_device mxc_gpt1; 1extern struct platform_device mxc_gpt1;
3extern struct platform_device mxc_gpt2; 2extern struct platform_device mxc_gpt2;
4extern struct platform_device mxc_gpt3; 3extern struct platform_device mxc_gpt3;
@@ -14,3 +13,10 @@ extern struct platform_device mxc_uart_device4;
14extern struct platform_device mxc_uart_device5; 13extern struct platform_device mxc_uart_device5;
15extern struct platform_device mxc_w1_master_device; 14extern struct platform_device mxc_w1_master_device;
16extern struct platform_device mxc_nand_device; 15extern struct platform_device mxc_nand_device;
16extern struct platform_device mxc_fb_device;
17extern struct platform_device mxc_fec_device;
18extern struct platform_device mxc_pwm_device;
19extern struct platform_device mxc_i2c_device0;
20extern struct platform_device mxc_i2c_device1;
21extern struct platform_device mxc_sdhc_device0;
22extern struct platform_device mxc_sdhc_device1;
diff --git a/arch/arm/mach-mx2/generic.c b/arch/arm/mach-mx2/generic.c
index dea6521d4d5c..bd51dd04948e 100644
--- a/arch/arm/mach-mx2/generic.c
+++ b/arch/arm/mach-mx2/generic.c
@@ -21,6 +21,7 @@
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <mach/hardware.h> 23#include <mach/hardware.h>
24#include <mach/common.h>
24#include <asm/pgtable.h> 25#include <asm/pgtable.h>
25#include <asm/mach/map.h> 26#include <asm/mach/map.h>
26 27
diff --git a/arch/arm/mach-mx2/mx27ads.c b/arch/arm/mach-mx2/mx27ads.c
index 2b5c67f54571..4a3b097adc12 100644
--- a/arch/arm/mach-mx2/mx27ads.c
+++ b/arch/arm/mach-mx2/mx27ads.c
@@ -31,7 +31,7 @@
31#include <asm/mach/map.h> 31#include <asm/mach/map.h>
32#include <mach/gpio.h> 32#include <mach/gpio.h>
33#include <mach/imx-uart.h> 33#include <mach/imx-uart.h>
34#include <mach/iomux-mx1-mx2.h> 34#include <mach/iomux.h>
35#include <mach/board-mx27ads.h> 35#include <mach/board-mx27ads.h>
36 36
37#include "devices.h" 37#include "devices.h"
@@ -135,6 +135,7 @@ static int uart_mxc_port3_exit(struct platform_device *pdev)
135{ 135{
136 mxc_gpio_release_multiple_pins(mxc_uart3_pins, 136 mxc_gpio_release_multiple_pins(mxc_uart3_pins,
137 ARRAY_SIZE(mxc_uart3_pins)); 137 ARRAY_SIZE(mxc_uart3_pins));
138 return 0;
138} 139}
139 140
140static int mxc_uart4_pins[] = { 141static int mxc_uart4_pins[] = {
@@ -179,6 +180,7 @@ static int uart_mxc_port5_exit(struct platform_device *pdev)
179 180
180static struct platform_device *platform_devices[] __initdata = { 181static struct platform_device *platform_devices[] __initdata = {
181 &mx27ads_nor_mtd_device, 182 &mx27ads_nor_mtd_device,
183 &mxc_fec_device,
182}; 184};
183 185
184static int mxc_fec_pins[] = { 186static int mxc_fec_pins[] = {
@@ -196,7 +198,7 @@ static int mxc_fec_pins[] = {
196 PD11_AOUT_FEC_TX_CLK, 198 PD11_AOUT_FEC_TX_CLK,
197 PD12_AOUT_FEC_RXD0, 199 PD12_AOUT_FEC_RXD0,
198 PD13_AOUT_FEC_RX_DV, 200 PD13_AOUT_FEC_RX_DV,
199 PD14_AOUT_FEC_CLR, 201 PD14_AOUT_FEC_RX_CLK,
200 PD15_AOUT_FEC_COL, 202 PD15_AOUT_FEC_COL,
201 PD16_AIN_FEC_TX_ER, 203 PD16_AIN_FEC_TX_ER,
202 PF23_AIN_FEC_TX_EN 204 PF23_AIN_FEC_TX_EN
@@ -208,12 +210,6 @@ static void gpio_fec_active(void)
208 ARRAY_SIZE(mxc_fec_pins), "FEC"); 210 ARRAY_SIZE(mxc_fec_pins), "FEC");
209} 211}
210 212
211static void gpio_fec_inactive(void)
212{
213 mxc_gpio_release_multiple_pins(mxc_fec_pins,
214 ARRAY_SIZE(mxc_fec_pins));
215}
216
217static struct imxuart_platform_data uart_pdata[] = { 213static struct imxuart_platform_data uart_pdata[] = {
218 { 214 {
219 .init = uart_mxc_port0_init, 215 .init = uart_mxc_port0_init,
@@ -263,11 +259,10 @@ static void __init mx27ads_timer_init(void)
263 if ((__raw_readw(PBC_VERSION_REG) & CKIH_27MHZ_BIT_SET) == 0) 259 if ((__raw_readw(PBC_VERSION_REG) & CKIH_27MHZ_BIT_SET) == 0)
264 fref = 27000000; 260 fref = 27000000;
265 261
266 mxc_clocks_init(fref); 262 mx27_clocks_init(fref);
267 mxc_timer_init("gpt_clk.0");
268} 263}
269 264
270struct sys_timer mx27ads_timer = { 265static struct sys_timer mx27ads_timer = {
271 .init = mx27ads_timer_init, 266 .init = mx27ads_timer_init,
272}; 267};
273 268
@@ -280,7 +275,7 @@ static struct map_desc mx27ads_io_desc[] __initdata = {
280 }, 275 },
281}; 276};
282 277
283void __init mx27ads_map_io(void) 278static void __init mx27ads_map_io(void)
284{ 279{
285 mxc_map_io(); 280 mxc_map_io();
286 iotable_init(mx27ads_io_desc, ARRAY_SIZE(mx27ads_io_desc)); 281 iotable_init(mx27ads_io_desc, ARRAY_SIZE(mx27ads_io_desc));
diff --git a/arch/arm/mach-mx2/pcm038.c b/arch/arm/mach-mx2/pcm038.c
index dfd4156da7d5..aa4eaa61d1b5 100644
--- a/arch/arm/mach-mx2/pcm038.c
+++ b/arch/arm/mach-mx2/pcm038.c
@@ -20,11 +20,18 @@
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/mtd/physmap.h> 21#include <linux/mtd/physmap.h>
22#include <linux/mtd/plat-ram.h> 22#include <linux/mtd/plat-ram.h>
23#include <linux/io.h>
24#include <linux/i2c.h>
25#include <linux/i2c/at24.h>
26
23#include <asm/mach/arch.h> 27#include <asm/mach/arch.h>
24#include <asm/mach-types.h> 28#include <asm/mach-types.h>
25#include <mach/common.h> 29#include <mach/common.h>
26#include <mach/hardware.h> 30#include <mach/hardware.h>
27#include <mach/iomux-mx1-mx2.h> 31#include <mach/iomux.h>
32#ifdef CONFIG_I2C_IMX
33#include <mach/i2c.h>
34#endif
28#include <asm/mach/time.h> 35#include <asm/mach/time.h>
29#include <mach/imx-uart.h> 36#include <mach/imx-uart.h>
30#include <mach/board-pcm038.h> 37#include <mach/board-pcm038.h>
@@ -121,10 +128,10 @@ static int uart_mxc_port1_exit(struct platform_device *pdev)
121 return 0; 128 return 0;
122} 129}
123 130
124static int mxc_uart2_pins[] = { PE10_PF_UART3_CTS, 131static int mxc_uart2_pins[] = { PE8_PF_UART3_TXD,
125 PE9_PF_UART3_RXD, 132 PE9_PF_UART3_RXD,
126 PE10_PF_UART3_CTS, 133 PE10_PF_UART3_CTS,
127 PE9_PF_UART3_RXD }; 134 PE11_PF_UART3_RTS };
128 135
129static int uart_mxc_port2_init(struct platform_device *pdev) 136static int uart_mxc_port2_init(struct platform_device *pdev)
130{ 137{
@@ -170,7 +177,7 @@ static int mxc_fec_pins[] = {
170 PD11_AOUT_FEC_TX_CLK, 177 PD11_AOUT_FEC_TX_CLK,
171 PD12_AOUT_FEC_RXD0, 178 PD12_AOUT_FEC_RXD0,
172 PD13_AOUT_FEC_RX_DV, 179 PD13_AOUT_FEC_RX_DV,
173 PD14_AOUT_FEC_CLR, 180 PD14_AOUT_FEC_RX_CLK,
174 PD15_AOUT_FEC_COL, 181 PD15_AOUT_FEC_COL,
175 PD16_AIN_FEC_TX_ER, 182 PD16_AIN_FEC_TX_ER,
176 PF23_AIN_FEC_TX_EN 183 PF23_AIN_FEC_TX_EN
@@ -182,12 +189,6 @@ static void gpio_fec_active(void)
182 ARRAY_SIZE(mxc_fec_pins), "FEC"); 189 ARRAY_SIZE(mxc_fec_pins), "FEC");
183} 190}
184 191
185static void gpio_fec_inactive(void)
186{
187 mxc_gpio_release_multiple_pins(mxc_fec_pins,
188 ARRAY_SIZE(mxc_fec_pins));
189}
190
191static struct mxc_nand_platform_data pcm038_nand_board_info = { 192static struct mxc_nand_platform_data pcm038_nand_board_info = {
192 .width = 1, 193 .width = 1,
193 .hw_ecc = 1, 194 .hw_ecc = 1,
@@ -196,6 +197,7 @@ static struct mxc_nand_platform_data pcm038_nand_board_info = {
196static struct platform_device *platform_devices[] __initdata = { 197static struct platform_device *platform_devices[] __initdata = {
197 &pcm038_nor_mtd_device, 198 &pcm038_nor_mtd_device,
198 &mxc_w1_master_device, 199 &mxc_w1_master_device,
200 &mxc_fec_device,
199 &pcm038_sram_mtd_device, 201 &pcm038_sram_mtd_device,
200}; 202};
201 203
@@ -208,6 +210,51 @@ static void __init pcm038_init_sram(void)
208 __raw_writel(0x22220a00, CSCR_A(1)); 210 __raw_writel(0x22220a00, CSCR_A(1));
209} 211}
210 212
213#ifdef CONFIG_I2C_IMX
214static int mxc_i2c1_pins[] = {
215 PC5_PF_I2C2_SDA,
216 PC6_PF_I2C2_SCL
217};
218
219static int pcm038_i2c_1_init(struct device *dev)
220{
221 return mxc_gpio_setup_multiple_pins(mxc_i2c1_pins, ARRAY_SIZE(mxc_i2c1_pins),
222 "I2C1");
223}
224
225static void pcm038_i2c_1_exit(struct device *dev)
226{
227 mxc_gpio_release_multiple_pins(mxc_i2c1_pins, ARRAY_SIZE(mxc_i2c1_pins));
228}
229
230static struct imxi2c_platform_data pcm038_i2c_1_data = {
231 .bitrate = 100000,
232 .init = pcm038_i2c_1_init,
233 .exit = pcm038_i2c_1_exit,
234};
235
236static struct at24_platform_data board_eeprom = {
237 .byte_len = 4096,
238 .page_size = 32,
239 .flags = AT24_FLAG_ADDR16,
240};
241
242static struct i2c_board_info pcm038_i2c_devices[] = {
243 [0] = {
244 I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */
245 .platform_data = &board_eeprom,
246 },
247 [1] = {
248 I2C_BOARD_INFO("rtc-pcf8563", 0x51),
249 .type = "pcf8563"
250 },
251 [2] = {
252 I2C_BOARD_INFO("lm75", 0x4a),
253 .type = "lm75"
254 }
255};
256#endif
257
211static void __init pcm038_init(void) 258static void __init pcm038_init(void)
212{ 259{
213 gpio_fec_active(); 260 gpio_fec_active();
@@ -217,9 +264,17 @@ static void __init pcm038_init(void)
217 mxc_register_device(&mxc_uart_device1, &uart_pdata[1]); 264 mxc_register_device(&mxc_uart_device1, &uart_pdata[1]);
218 mxc_register_device(&mxc_uart_device2, &uart_pdata[2]); 265 mxc_register_device(&mxc_uart_device2, &uart_pdata[2]);
219 266
220 mxc_gpio_mode(PE16_AF_RTCK); /* OWIRE */ 267 mxc_gpio_mode(PE16_AF_OWIRE);
221 mxc_register_device(&mxc_nand_device, &pcm038_nand_board_info); 268 mxc_register_device(&mxc_nand_device, &pcm038_nand_board_info);
222 269
270#ifdef CONFIG_I2C_IMX
271 /* only the i2c master 1 is used on this CPU card */
272 i2c_register_board_info(1, pcm038_i2c_devices,
273 ARRAY_SIZE(pcm038_i2c_devices));
274
275 mxc_register_device(&mxc_i2c_device1, &pcm038_i2c_1_data);
276#endif
277
223 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 278 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
224 279
225#ifdef CONFIG_MACH_PCM970_BASEBOARD 280#ifdef CONFIG_MACH_PCM970_BASEBOARD
@@ -229,11 +284,10 @@ static void __init pcm038_init(void)
229 284
230static void __init pcm038_timer_init(void) 285static void __init pcm038_timer_init(void)
231{ 286{
232 mxc_clocks_init(26000000); 287 mx27_clocks_init(26000000);
233 mxc_timer_init("gpt_clk.0");
234} 288}
235 289
236struct sys_timer pcm038_timer = { 290static struct sys_timer pcm038_timer = {
237 .init = pcm038_timer_init, 291 .init = pcm038_timer_init,
238}; 292};
239 293
diff --git a/arch/arm/mach-mx2/pcm970-baseboard.c b/arch/arm/mach-mx2/pcm970-baseboard.c
index a560cd6ad23d..bf4e520bc1bc 100644
--- a/arch/arm/mach-mx2/pcm970-baseboard.c
+++ b/arch/arm/mach-mx2/pcm970-baseboard.c
@@ -17,9 +17,138 @@
17 */ 17 */
18 18
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <mach/hardware.h> 20#include <linux/gpio.h>
21#include <linux/irq.h>
22
21#include <asm/mach/arch.h> 23#include <asm/mach/arch.h>
22 24
25#include <mach/hardware.h>
26#include <mach/common.h>
27#include <mach/mmc.h>
28#include <mach/imxfb.h>
29#include <mach/iomux.h>
30
31#include "devices.h"
32
33static int pcm970_sdhc2_get_ro(struct device *dev)
34{
35 return gpio_get_value(GPIO_PORTC + 28);
36}
37
38static int pcm970_sdhc2_pins[] = {
39 PB4_PF_SD2_D0,
40 PB5_PF_SD2_D1,
41 PB6_PF_SD2_D2,
42 PB7_PF_SD2_D3,
43 PB8_PF_SD2_CMD,
44 PB9_PF_SD2_CLK,
45};
46
47static int pcm970_sdhc2_init(struct device *dev, irq_handler_t detect_irq, void *data)
48{
49 int ret;
50
51 ret = mxc_gpio_setup_multiple_pins(pcm970_sdhc2_pins,
52 ARRAY_SIZE(pcm970_sdhc2_pins), "sdhc2");
53 if(ret)
54 return ret;
55
56 ret = request_irq(IRQ_GPIOC(29), detect_irq, 0,
57 "imx-mmc-detect", data);
58 if (ret)
59 goto out_release_gpio;
60
61 set_irq_type(IRQ_GPIOC(29), IRQF_TRIGGER_FALLING);
62
63 ret = gpio_request(GPIO_PORTC + 28, "imx-mmc-ro");
64 if (ret)
65 goto out_release_gpio;
66
67 mxc_gpio_mode((GPIO_PORTC | 28) | GPIO_GPIO | GPIO_IN);
68 gpio_direction_input(GPIO_PORTC + 28);
69
70 return 0;
71
72out_release_gpio:
73 mxc_gpio_release_multiple_pins(pcm970_sdhc2_pins,
74 ARRAY_SIZE(pcm970_sdhc2_pins));
75 return ret;
76}
77
78static void pcm970_sdhc2_exit(struct device *dev, void *data)
79{
80 free_irq(IRQ_GPIOC(29), data);
81 gpio_free(GPIO_PORTC + 28);
82 mxc_gpio_release_multiple_pins(pcm970_sdhc2_pins,
83 ARRAY_SIZE(pcm970_sdhc2_pins));
84}
85
86static struct imxmmc_platform_data sdhc_pdata = {
87 .get_ro = pcm970_sdhc2_get_ro,
88 .init = pcm970_sdhc2_init,
89 .exit = pcm970_sdhc2_exit,
90};
91
92static int mxc_fb_pins[] = {
93 PA5_PF_LSCLK, PA6_PF_LD0, PA7_PF_LD1, PA8_PF_LD2,
94 PA9_PF_LD3, PA10_PF_LD4, PA11_PF_LD5, PA12_PF_LD6,
95 PA13_PF_LD7, PA14_PF_LD8, PA15_PF_LD9, PA16_PF_LD10,
96 PA17_PF_LD11, PA18_PF_LD12, PA19_PF_LD13, PA20_PF_LD14,
97 PA21_PF_LD15, PA22_PF_LD16, PA23_PF_LD17, PA24_PF_REV,
98 PA25_PF_CLS, PA26_PF_PS, PA27_PF_SPL_SPR, PA28_PF_HSYNC,
99 PA29_PF_VSYNC, PA30_PF_CONTRAST, PA31_PF_OE_ACD
100};
101
102static int pcm038_fb_init(struct platform_device *pdev)
103{
104 return mxc_gpio_setup_multiple_pins(mxc_fb_pins,
105 ARRAY_SIZE(mxc_fb_pins), "FB");
106}
107
108static int pcm038_fb_exit(struct platform_device *pdev)
109{
110 mxc_gpio_release_multiple_pins(mxc_fb_pins, ARRAY_SIZE(mxc_fb_pins));
111
112 return 0;
113}
114
115/*
116 * Connected is a portrait Sharp-QVGA display
117 * of type: LQ035Q7DH06
118 */
119static struct imx_fb_platform_data pcm038_fb_data = {
120 .pixclock = 188679, /* in ps (5.3MHz) */
121 .xres = 240,
122 .yres = 320,
123
124 .bpp = 16,
125 .hsync_len = 7,
126 .left_margin = 5,
127 .right_margin = 16,
128
129 .vsync_len = 1,
130 .upper_margin = 7,
131 .lower_margin = 9,
132 .fixed_screen_cpu = 0,
133
134 /*
135 * - HSYNC active high
136 * - VSYNC active high
137 * - clk notenabled while idle
138 * - clock not inverted
139 * - data not inverted
140 * - data enable low active
141 * - enable sharp mode
142 */
143 .pcr = 0xFA0080C0,
144 .pwmr = 0x00A903FF,
145 .lscr1 = 0x00120300,
146 .dmacr = 0x00020010,
147
148 .init = pcm038_fb_init,
149 .exit = pcm038_fb_exit,
150};
151
23/* 152/*
24 * system init for baseboard usage. Will be called by pcm038 init. 153 * system init for baseboard usage. Will be called by pcm038 init.
25 * 154 *
@@ -28,4 +157,6 @@
28 */ 157 */
29void __init pcm970_baseboard_init(void) 158void __init pcm970_baseboard_init(void)
30{ 159{
160 mxc_register_device(&mxc_fb_device, &pcm038_fb_data);
161 mxc_register_device(&mxc_sdhc_device1, &sdhc_pdata);
31} 162}
diff --git a/arch/arm/mach-mx2/serial.c b/arch/arm/mach-mx2/serial.c
index 16debc296dad..40a485cdc10e 100644
--- a/arch/arm/mach-mx2/serial.c
+++ b/arch/arm/mach-mx2/serial.c
@@ -22,6 +22,7 @@
22#include <linux/serial.h> 22#include <linux/serial.h>
23#include <mach/hardware.h> 23#include <mach/hardware.h>
24#include <mach/imx-uart.h> 24#include <mach/imx-uart.h>
25#include "devices.h"
25 26
26static struct resource uart0[] = { 27static struct resource uart0[] = {
27 { 28 {
@@ -99,6 +100,7 @@ struct platform_device mxc_uart_device3 = {
99 .num_resources = ARRAY_SIZE(uart3), 100 .num_resources = ARRAY_SIZE(uart3),
100}; 101};
101 102
103#ifdef CONFIG_MACH_MX27
102static struct resource uart4[] = { 104static struct resource uart4[] = {
103 { 105 {
104 .start = UART5_BASE_ADDR, 106 .start = UART5_BASE_ADDR,
@@ -136,3 +138,4 @@ struct platform_device mxc_uart_device5 = {
136 .resource = uart5, 138 .resource = uart5,
137 .num_resources = ARRAY_SIZE(uart5), 139 .num_resources = ARRAY_SIZE(uart5),
138}; 140};
141#endif
diff --git a/arch/arm/mach-mx3/Kconfig b/arch/arm/mach-mx3/Kconfig
index e79659e8176e..d6235583e979 100644
--- a/arch/arm/mach-mx3/Kconfig
+++ b/arch/arm/mach-mx3/Kconfig
@@ -1,21 +1,40 @@
1menu "MX3 Options" 1if ARCH_MX3
2 depends on ARCH_MX3 2
3config ARCH_MX31
4 bool
5
6config ARCH_MX35
7 bool
8
9comment "MX3 platforms:"
3 10
4config MACH_MX31ADS 11config MACH_MX31ADS
5 bool "Support MX31ADS platforms" 12 bool "Support MX31ADS platforms"
13 select ARCH_MX31
6 default y 14 default y
7 help 15 help
8 Include support for MX31ADS platform. This includes specific 16 Include support for MX31ADS platform. This includes specific
9 configurations for the board and its peripherals. 17 configurations for the board and its peripherals.
10 18
19config MACH_MX31ADS_WM1133_EV1
20 bool "Support Wolfson Microelectronics 1133-EV1 module"
21 depends on MACH_MX31ADS
22 select MFD_WM8350_CONFIG_MODE_0
23 select MFD_WM8352_CONFIG_MODE_0
24 help
25 Include support for the Wolfson Microelectronics 1133-EV1 PMU
26 and audio module for the MX31ADS platform.
27
11config MACH_PCM037 28config MACH_PCM037
12 bool "Support Phytec pcm037 platforms" 29 bool "Support Phytec pcm037 (i.MX31) platforms"
30 select ARCH_MX31
13 help 31 help
14 Include support for Phytec pcm037 platform. This includes 32 Include support for Phytec pcm037 platform. This includes
15 specific configurations for the board and its peripherals. 33 specific configurations for the board and its peripherals.
16 34
17config MACH_MX31LITE 35config MACH_MX31LITE
18 bool "Support MX31 LITEKIT (LogicPD)" 36 bool "Support MX31 LITEKIT (LogicPD)"
37 select ARCH_MX31
19 default n 38 default n
20 help 39 help
21 Include support for MX31 LITEKIT platform. This includes specific 40 Include support for MX31 LITEKIT platform. This includes specific
@@ -23,6 +42,7 @@ config MACH_MX31LITE
23 42
24config MACH_MX31_3DS 43config MACH_MX31_3DS
25 bool "Support MX31PDK (3DS)" 44 bool "Support MX31PDK (3DS)"
45 select ARCH_MX31
26 default n 46 default n
27 help 47 help
28 Include support for MX31PDK (3DS) platform. This includes specific 48 Include support for MX31PDK (3DS) platform. This includes specific
@@ -30,10 +50,18 @@ config MACH_MX31_3DS
30 50
31config MACH_MX31MOBOARD 51config MACH_MX31MOBOARD
32 bool "Support mx31moboard platforms (EPFL Mobots group)" 52 bool "Support mx31moboard platforms (EPFL Mobots group)"
53 select ARCH_MX31
33 default n 54 default n
34 help 55 help
35 Include support for mx31moboard platform. This includes specific 56 Include support for mx31moboard platform. This includes specific
36 configurations for the board and its peripherals. 57 configurations for the board and its peripherals.
37 58
38endmenu 59config MACH_QONG
60 bool "Support Dave/DENX QongEVB-LITE platform"
61 select ARCH_MX31
62 default n
63 help
64 Include support for Dave/DENX QongEVB-LITE platform. This includes
65 specific configurations for the board and its peripherals.
39 66
67endif
diff --git a/arch/arm/mach-mx3/Makefile b/arch/arm/mach-mx3/Makefile
index 5a151540fe83..272c8a953b30 100644
--- a/arch/arm/mach-mx3/Makefile
+++ b/arch/arm/mach-mx3/Makefile
@@ -4,9 +4,13 @@
4 4
5# Object file lists. 5# Object file lists.
6 6
7obj-y := mm.o clock.o devices.o iomux.o 7obj-y := mm.o devices.o
8obj-$(CONFIG_ARCH_MX31) += clock.o iomux.o
9obj-$(CONFIG_ARCH_MX35) += clock-imx35.o
8obj-$(CONFIG_MACH_MX31ADS) += mx31ads.o 10obj-$(CONFIG_MACH_MX31ADS) += mx31ads.o
9obj-$(CONFIG_MACH_MX31LITE) += mx31lite.o 11obj-$(CONFIG_MACH_MX31LITE) += mx31lite.o
10obj-$(CONFIG_MACH_PCM037) += pcm037.o 12obj-$(CONFIG_MACH_PCM037) += pcm037.o
11obj-$(CONFIG_MACH_MX31_3DS) += mx31pdk.o 13obj-$(CONFIG_MACH_MX31_3DS) += mx31pdk.o
12obj-$(CONFIG_MACH_MX31MOBOARD) += mx31moboard.o 14obj-$(CONFIG_MACH_MX31MOBOARD) += mx31moboard.o mx31moboard-devboard.o \
15 mx31moboard-marxbot.o
16obj-$(CONFIG_MACH_QONG) += qong.o
diff --git a/arch/arm/mach-mx3/clock-imx35.c b/arch/arm/mach-mx3/clock-imx35.c
new file mode 100644
index 000000000000..53a112d4e04a
--- /dev/null
+++ b/arch/arm/mach-mx3/clock-imx35.c
@@ -0,0 +1,487 @@
1/*
2 * Copyright (C) 2009 by Sascha Hauer, Pengutronix
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16 * MA 02110-1301, USA.
17 */
18
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/list.h>
22#include <linux/clk.h>
23#include <linux/io.h>
24
25#include <asm/clkdev.h>
26
27#include <mach/clock.h>
28#include <mach/hardware.h>
29#include <mach/common.h>
30
31#define CCM_BASE IO_ADDRESS(CCM_BASE_ADDR)
32
33#define CCM_CCMR 0x00
34#define CCM_PDR0 0x04
35#define CCM_PDR1 0x08
36#define CCM_PDR2 0x0C
37#define CCM_PDR3 0x10
38#define CCM_PDR4 0x14
39#define CCM_RCSR 0x18
40#define CCM_MPCTL 0x1C
41#define CCM_PPCTL 0x20
42#define CCM_ACMR 0x24
43#define CCM_COSR 0x28
44#define CCM_CGR0 0x2C
45#define CCM_CGR1 0x30
46#define CCM_CGR2 0x34
47#define CCM_CGR3 0x38
48
49#ifdef HAVE_SET_RATE_SUPPORT
50static void calc_dividers(u32 div, u32 *pre, u32 *post, u32 maxpost)
51{
52 u32 min_pre, temp_pre, old_err, err;
53
54 min_pre = (div - 1) / maxpost + 1;
55 old_err = 8;
56
57 for (temp_pre = 8; temp_pre >= min_pre; temp_pre--) {
58 if (div > (temp_pre * maxpost))
59 break;
60
61 if (div < (temp_pre * temp_pre))
62 continue;
63
64 err = div % temp_pre;
65
66 if (err == 0) {
67 *pre = temp_pre;
68 break;
69 }
70
71 err = temp_pre - err;
72
73 if (err < old_err) {
74 old_err = err;
75 *pre = temp_pre;
76 }
77 }
78
79 *post = (div + *pre - 1) / *pre;
80}
81
82/* get the best values for a 3-bit divider combined with a 6-bit divider */
83static void calc_dividers_3_6(u32 div, u32 *pre, u32 *post)
84{
85 if (div >= 512) {
86 *pre = 8;
87 *post = 64;
88 } else if (div >= 64) {
89 calc_dividers(div, pre, post, 64);
90 } else if (div <= 8) {
91 *pre = div;
92 *post = 1;
93 } else {
94 *pre = 1;
95 *post = div;
96 }
97}
98
99/* get the best values for two cascaded 3-bit dividers */
100static void calc_dividers_3_3(u32 div, u32 *pre, u32 *post)
101{
102 if (div >= 64) {
103 *pre = *post = 8;
104 } else if (div > 8) {
105 calc_dividers(div, pre, post, 8);
106 } else {
107 *pre = 1;
108 *post = div;
109 }
110}
111#endif
112
113static unsigned long get_rate_mpll(void)
114{
115 ulong mpctl = __raw_readl(CCM_BASE + CCM_MPCTL);
116
117 return mxc_decode_pll(mpctl, 24000000);
118}
119
120static unsigned long get_rate_ppll(void)
121{
122 ulong ppctl = __raw_readl(CCM_BASE + CCM_PPCTL);
123
124 return mxc_decode_pll(ppctl, 24000000);
125}
126
127struct arm_ahb_div {
128 unsigned char arm, ahb, sel;
129};
130
131static struct arm_ahb_div clk_consumer[] = {
132 { .arm = 1, .ahb = 4, .sel = 0},
133 { .arm = 1, .ahb = 3, .sel = 1},
134 { .arm = 2, .ahb = 2, .sel = 0},
135 { .arm = 0, .ahb = 0, .sel = 0},
136 { .arm = 0, .ahb = 0, .sel = 0},
137 { .arm = 0, .ahb = 0, .sel = 0},
138 { .arm = 4, .ahb = 1, .sel = 0},
139 { .arm = 1, .ahb = 5, .sel = 0},
140 { .arm = 1, .ahb = 8, .sel = 0},
141 { .arm = 1, .ahb = 6, .sel = 1},
142 { .arm = 2, .ahb = 4, .sel = 0},
143 { .arm = 0, .ahb = 0, .sel = 0},
144 { .arm = 0, .ahb = 0, .sel = 0},
145 { .arm = 0, .ahb = 0, .sel = 0},
146 { .arm = 4, .ahb = 2, .sel = 0},
147 { .arm = 0, .ahb = 0, .sel = 0},
148};
149
150static struct arm_ahb_div clk_automotive[] = {
151 { .arm = 1, .ahb = 3, .sel = 0},
152 { .arm = 1, .ahb = 2, .sel = 1},
153 { .arm = 2, .ahb = 1, .sel = 1},
154 { .arm = 0, .ahb = 0, .sel = 0},
155 { .arm = 1, .ahb = 6, .sel = 0},
156 { .arm = 1, .ahb = 4, .sel = 1},
157 { .arm = 2, .ahb = 2, .sel = 1},
158 { .arm = 0, .ahb = 0, .sel = 0},
159};
160
161static unsigned long get_rate_arm(void)
162{
163 unsigned long pdr0 = __raw_readl(CCM_BASE + CCM_PDR0);
164 struct arm_ahb_div *aad;
165 unsigned long fref = get_rate_mpll();
166
167 if (pdr0 & 1) {
168 /* consumer path */
169 aad = &clk_consumer[(pdr0 >> 16) & 0xf];
170 if (aad->sel)
171 fref = fref * 2 / 3;
172 } else {
173 /* auto path */
174 aad = &clk_automotive[(pdr0 >> 9) & 0x7];
175 if (aad->sel)
176 fref = fref * 3 / 4;
177 }
178 return fref / aad->arm;
179}
180
181static unsigned long get_rate_ahb(struct clk *clk)
182{
183 unsigned long pdr0 = __raw_readl(CCM_BASE + CCM_PDR0);
184 struct arm_ahb_div *aad;
185 unsigned long fref = get_rate_mpll();
186
187 if (pdr0 & 1)
188 /* consumer path */
189 aad = &clk_consumer[(pdr0 >> 16) & 0xf];
190 else
191 /* auto path */
192 aad = &clk_automotive[(pdr0 >> 9) & 0x7];
193
194 return fref / aad->ahb;
195}
196
197static unsigned long get_rate_ipg(struct clk *clk)
198{
199 return get_rate_ahb(NULL) >> 1;
200}
201
202static unsigned long get_3_3_div(unsigned long in)
203{
204 return (((in >> 3) & 0x7) + 1) * ((in & 0x7) + 1);
205}
206
207static unsigned long get_rate_uart(struct clk *clk)
208{
209 unsigned long pdr3 = __raw_readl(CCM_BASE + CCM_PDR3);
210 unsigned long pdr4 = __raw_readl(CCM_BASE + CCM_PDR4);
211 unsigned long div = get_3_3_div(pdr4 >> 10);
212
213 if (pdr3 & (1 << 14))
214 return get_rate_arm() / div;
215 else
216 return get_rate_ppll() / div;
217}
218
219static unsigned long get_rate_sdhc(struct clk *clk)
220{
221 unsigned long pdr3 = __raw_readl(CCM_BASE + CCM_PDR3);
222 unsigned long div, rate;
223
224 if (pdr3 & (1 << 6))
225 rate = get_rate_arm();
226 else
227 rate = get_rate_ppll();
228
229 switch (clk->id) {
230 default:
231 case 0:
232 div = pdr3 & 0x3f;
233 break;
234 case 1:
235 div = (pdr3 >> 8) & 0x3f;
236 break;
237 case 2:
238 div = (pdr3 >> 16) & 0x3f;
239 break;
240 }
241
242 return rate / get_3_3_div(div);
243}
244
245static unsigned long get_rate_mshc(struct clk *clk)
246{
247 unsigned long pdr1 = __raw_readl(CCM_BASE + CCM_PDR1);
248 unsigned long div1, div2, rate;
249
250 if (pdr1 & (1 << 7))
251 rate = get_rate_arm();
252 else
253 rate = get_rate_ppll();
254
255 div1 = (pdr1 >> 29) & 0x7;
256 div2 = (pdr1 >> 22) & 0x3f;
257
258 return rate / ((div1 + 1) * (div2 + 1));
259}
260
261static unsigned long get_rate_ssi(struct clk *clk)
262{
263 unsigned long pdr2 = __raw_readl(CCM_BASE + CCM_PDR2);
264 unsigned long div1, div2, rate;
265
266 if (pdr2 & (1 << 6))
267 rate = get_rate_arm();
268 else
269 rate = get_rate_ppll();
270
271 switch (clk->id) {
272 default:
273 case 0:
274 div1 = pdr2 & 0x3f;
275 div2 = (pdr2 >> 24) & 0x7;
276 break;
277 case 1:
278 div1 = (pdr2 >> 8) & 0x3f;
279 div2 = (pdr2 >> 27) & 0x7;
280 break;
281 }
282
283 return rate / ((div1 + 1) * (div2 + 1));
284}
285
286static unsigned long get_rate_csi(struct clk *clk)
287{
288 unsigned long pdr2 = __raw_readl(CCM_BASE + CCM_PDR2);
289 unsigned long rate;
290
291 if (pdr2 & (1 << 7))
292 rate = get_rate_arm();
293 else
294 rate = get_rate_ppll();
295
296 return rate / get_3_3_div((pdr2 >> 16) & 0x3f);
297}
298
299static unsigned long get_rate_ipg_per(struct clk *clk)
300{
301 unsigned long pdr0 = __raw_readl(CCM_BASE + CCM_PDR0);
302 unsigned long pdr4 = __raw_readl(CCM_BASE + CCM_PDR4);
303 unsigned long div1, div2;
304
305 if (pdr0 & (1 << 26)) {
306 div1 = (pdr4 >> 19) & 0x7;
307 div2 = (pdr4 >> 16) & 0x7;
308 return get_rate_arm() / ((div1 + 1) * (div2 + 1));
309 } else {
310 div1 = (pdr0 >> 12) & 0x7;
311 return get_rate_ahb(NULL) / div1;
312 }
313}
314
315static int clk_cgr_enable(struct clk *clk)
316{
317 u32 reg;
318
319 reg = __raw_readl(clk->enable_reg);
320 reg |= 3 << clk->enable_shift;
321 __raw_writel(reg, clk->enable_reg);
322
323 return 0;
324}
325
326static void clk_cgr_disable(struct clk *clk)
327{
328 u32 reg;
329
330 reg = __raw_readl(clk->enable_reg);
331 reg &= ~(3 << clk->enable_shift);
332 __raw_writel(reg, clk->enable_reg);
333}
334
335#define DEFINE_CLOCK(name, i, er, es, gr, sr) \
336 static struct clk name = { \
337 .id = i, \
338 .enable_reg = CCM_BASE + er, \
339 .enable_shift = es, \
340 .get_rate = gr, \
341 .set_rate = sr, \
342 .enable = clk_cgr_enable, \
343 .disable = clk_cgr_disable, \
344 }
345
346DEFINE_CLOCK(asrc_clk, 0, CCM_CGR0, 0, NULL, NULL);
347DEFINE_CLOCK(ata_clk, 0, CCM_CGR0, 2, get_rate_ipg, NULL);
348DEFINE_CLOCK(audmux_clk, 0, CCM_CGR0, 4, NULL, NULL);
349DEFINE_CLOCK(can1_clk, 0, CCM_CGR0, 6, get_rate_ipg, NULL);
350DEFINE_CLOCK(can2_clk, 1, CCM_CGR0, 8, get_rate_ipg, NULL);
351DEFINE_CLOCK(cspi1_clk, 0, CCM_CGR0, 10, get_rate_ipg, NULL);
352DEFINE_CLOCK(cspi2_clk, 1, CCM_CGR0, 12, get_rate_ipg, NULL);
353DEFINE_CLOCK(ect_clk, 0, CCM_CGR0, 14, get_rate_ipg, NULL);
354DEFINE_CLOCK(edio_clk, 0, CCM_CGR0, 16, NULL, NULL);
355DEFINE_CLOCK(emi_clk, 0, CCM_CGR0, 18, get_rate_ipg, NULL);
356DEFINE_CLOCK(epit1_clk, 0, CCM_CGR0, 20, get_rate_ipg_per, NULL);
357DEFINE_CLOCK(epit2_clk, 1, CCM_CGR0, 22, get_rate_ipg_per, NULL);
358DEFINE_CLOCK(esai_clk, 0, CCM_CGR0, 24, NULL, NULL);
359DEFINE_CLOCK(esdhc1_clk, 0, CCM_CGR0, 26, get_rate_sdhc, NULL);
360DEFINE_CLOCK(esdhc2_clk, 1, CCM_CGR0, 28, get_rate_sdhc, NULL);
361DEFINE_CLOCK(esdhc3_clk, 2, CCM_CGR0, 30, get_rate_sdhc, NULL);
362
363DEFINE_CLOCK(fec_clk, 0, CCM_CGR1, 0, get_rate_ipg, NULL);
364DEFINE_CLOCK(gpio1_clk, 0, CCM_CGR1, 2, NULL, NULL);
365DEFINE_CLOCK(gpio2_clk, 1, CCM_CGR1, 4, NULL, NULL);
366DEFINE_CLOCK(gpio3_clk, 2, CCM_CGR1, 6, NULL, NULL);
367DEFINE_CLOCK(gpt_clk, 0, CCM_CGR1, 8, get_rate_ipg, NULL);
368DEFINE_CLOCK(i2c1_clk, 0, CCM_CGR1, 10, get_rate_ipg_per, NULL);
369DEFINE_CLOCK(i2c2_clk, 1, CCM_CGR1, 12, get_rate_ipg_per, NULL);
370DEFINE_CLOCK(i2c3_clk, 2, CCM_CGR1, 14, get_rate_ipg_per, NULL);
371DEFINE_CLOCK(iomuxc_clk, 0, CCM_CGR1, 16, NULL, NULL);
372DEFINE_CLOCK(ipu_clk, 0, CCM_CGR1, 18, NULL, NULL);
373DEFINE_CLOCK(kpp_clk, 0, CCM_CGR1, 20, get_rate_ipg, NULL);
374DEFINE_CLOCK(mlb_clk, 0, CCM_CGR1, 22, get_rate_ahb, NULL);
375DEFINE_CLOCK(mshc_clk, 0, CCM_CGR1, 24, get_rate_mshc, NULL);
376DEFINE_CLOCK(owire_clk, 0, CCM_CGR1, 26, get_rate_ipg_per, NULL);
377DEFINE_CLOCK(pwm_clk, 0, CCM_CGR1, 28, get_rate_ipg_per, NULL);
378DEFINE_CLOCK(rngc_clk, 0, CCM_CGR1, 30, get_rate_ipg, NULL);
379
380DEFINE_CLOCK(rtc_clk, 0, CCM_CGR2, 0, get_rate_ipg, NULL);
381DEFINE_CLOCK(rtic_clk, 0, CCM_CGR2, 2, get_rate_ahb, NULL);
382DEFINE_CLOCK(scc_clk, 0, CCM_CGR2, 4, get_rate_ipg, NULL);
383DEFINE_CLOCK(sdma_clk, 0, CCM_CGR2, 6, NULL, NULL);
384DEFINE_CLOCK(spba_clk, 0, CCM_CGR2, 8, get_rate_ipg, NULL);
385DEFINE_CLOCK(spdif_clk, 0, CCM_CGR2, 10, NULL, NULL);
386DEFINE_CLOCK(ssi1_clk, 0, CCM_CGR2, 12, get_rate_ssi, NULL);
387DEFINE_CLOCK(ssi2_clk, 1, CCM_CGR2, 14, get_rate_ssi, NULL);
388DEFINE_CLOCK(uart1_clk, 0, CCM_CGR2, 16, get_rate_uart, NULL);
389DEFINE_CLOCK(uart2_clk, 1, CCM_CGR2, 18, get_rate_uart, NULL);
390DEFINE_CLOCK(uart3_clk, 2, CCM_CGR2, 20, get_rate_uart, NULL);
391DEFINE_CLOCK(usbotg_clk, 0, CCM_CGR2, 22, NULL, NULL);
392DEFINE_CLOCK(wdog_clk, 0, CCM_CGR2, 24, NULL, NULL);
393DEFINE_CLOCK(max_clk, 0, CCM_CGR2, 26, NULL, NULL);
394DEFINE_CLOCK(admux_clk, 0, CCM_CGR2, 30, NULL, NULL);
395
396DEFINE_CLOCK(csi_clk, 0, CCM_CGR3, 0, get_rate_csi, NULL);
397DEFINE_CLOCK(iim_clk, 0, CCM_CGR3, 2, NULL, NULL);
398DEFINE_CLOCK(gpu2d_clk, 0, CCM_CGR3, 4, NULL, NULL);
399
400#define _REGISTER_CLOCK(d, n, c) \
401 { \
402 .dev_id = d, \
403 .con_id = n, \
404 .clk = &c, \
405 },
406
407static struct clk_lookup lookups[] __initdata = {
408 _REGISTER_CLOCK(NULL, "asrc", asrc_clk)
409 _REGISTER_CLOCK(NULL, "ata", ata_clk)
410 _REGISTER_CLOCK(NULL, "audmux", audmux_clk)
411 _REGISTER_CLOCK(NULL, "can", can1_clk)
412 _REGISTER_CLOCK(NULL, "can", can2_clk)
413 _REGISTER_CLOCK("spi_imx.0", NULL, cspi1_clk)
414 _REGISTER_CLOCK("spi_imx.1", NULL, cspi2_clk)
415 _REGISTER_CLOCK(NULL, "ect", ect_clk)
416 _REGISTER_CLOCK(NULL, "edio", edio_clk)
417 _REGISTER_CLOCK(NULL, "emi", emi_clk)
418 _REGISTER_CLOCK(NULL, "epit", epit1_clk)
419 _REGISTER_CLOCK(NULL, "epit", epit2_clk)
420 _REGISTER_CLOCK(NULL, "esai", esai_clk)
421 _REGISTER_CLOCK(NULL, "sdhc", esdhc1_clk)
422 _REGISTER_CLOCK(NULL, "sdhc", esdhc2_clk)
423 _REGISTER_CLOCK(NULL, "sdhc", esdhc3_clk)
424 _REGISTER_CLOCK("fec.0", NULL, fec_clk)
425 _REGISTER_CLOCK(NULL, "gpio", gpio1_clk)
426 _REGISTER_CLOCK(NULL, "gpio", gpio2_clk)
427 _REGISTER_CLOCK(NULL, "gpio", gpio3_clk)
428 _REGISTER_CLOCK("gpt.0", NULL, gpt_clk)
429 _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk)
430 _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk)
431 _REGISTER_CLOCK("imx-i2c.2", NULL, i2c3_clk)
432 _REGISTER_CLOCK(NULL, "iomuxc", iomuxc_clk)
433 _REGISTER_CLOCK(NULL, "ipu", ipu_clk)
434 _REGISTER_CLOCK(NULL, "kpp", kpp_clk)
435 _REGISTER_CLOCK(NULL, "mlb", mlb_clk)
436 _REGISTER_CLOCK(NULL, "mshc", mshc_clk)
437 _REGISTER_CLOCK("mxc_w1", NULL, owire_clk)
438 _REGISTER_CLOCK(NULL, "pwm", pwm_clk)
439 _REGISTER_CLOCK(NULL, "rngc", rngc_clk)
440 _REGISTER_CLOCK(NULL, "rtc", rtc_clk)
441 _REGISTER_CLOCK(NULL, "rtic", rtic_clk)
442 _REGISTER_CLOCK(NULL, "scc", scc_clk)
443 _REGISTER_CLOCK(NULL, "sdma", sdma_clk)
444 _REGISTER_CLOCK(NULL, "spba", spba_clk)
445 _REGISTER_CLOCK(NULL, "spdif", spdif_clk)
446 _REGISTER_CLOCK(NULL, "ssi", ssi1_clk)
447 _REGISTER_CLOCK(NULL, "ssi", ssi2_clk)
448 _REGISTER_CLOCK("imx-uart.0", NULL, uart1_clk)
449 _REGISTER_CLOCK("imx-uart.1", NULL, uart2_clk)
450 _REGISTER_CLOCK("imx-uart.2", NULL, uart3_clk)
451 _REGISTER_CLOCK(NULL, "usbotg", usbotg_clk)
452 _REGISTER_CLOCK("mxc_wdt.0", NULL, wdog_clk)
453 _REGISTER_CLOCK(NULL, "max", max_clk)
454 _REGISTER_CLOCK(NULL, "admux", admux_clk)
455 _REGISTER_CLOCK(NULL, "csi", csi_clk)
456 _REGISTER_CLOCK(NULL, "iim", iim_clk)
457 _REGISTER_CLOCK(NULL, "gpu2d", gpu2d_clk)
458};
459
460int __init mx35_clocks_init()
461{
462 int i;
463 unsigned int ll = 0;
464
465 mxc_set_cpu_type(MXC_CPU_MX35);
466
467#ifdef CONFIG_DEBUG_LL_CONSOLE
468 ll = (3 << 16);
469#endif
470
471 for (i = 0; i < ARRAY_SIZE(lookups); i++)
472 clkdev_add(&lookups[i]);
473
474 /* Turn off all clocks except the ones we need to survive, namely:
475 * EMI, GPIO1/2/3, GPT, IOMUX, MAX and eventually uart
476 */
477 __raw_writel((3 << 18), CCM_BASE + CCM_CGR0);
478 __raw_writel((3 << 2) | (3 << 4) | (3 << 6) | (3 << 8) | (3 << 16),
479 CCM_BASE + CCM_CGR1);
480 __raw_writel((3 << 26) | ll, CCM_BASE + CCM_CGR2);
481 __raw_writel(0, CCM_BASE + CCM_CGR3);
482
483 mxc_timer_init(&gpt_clk);
484
485 return 0;
486}
487
diff --git a/arch/arm/mach-mx3/clock.c b/arch/arm/mach-mx3/clock.c
index b1746aae1f89..ca46f4801c3d 100644
--- a/arch/arm/mach-mx3/clock.c
+++ b/arch/arm/mach-mx3/clock.c
@@ -23,9 +23,13 @@
23#include <linux/clk.h> 23#include <linux/clk.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/io.h> 25#include <linux/io.h>
26
27#include <asm/clkdev.h>
28#include <asm/div64.h>
29
26#include <mach/clock.h> 30#include <mach/clock.h>
27#include <mach/hardware.h> 31#include <mach/hardware.h>
28#include <asm/div64.h> 32#include <mach/common.h>
29 33
30#include "crm_regs.h" 34#include "crm_regs.h"
31 35
@@ -64,17 +68,17 @@ static void __calc_pre_post_dividers(u32 div, u32 *pre, u32 *post)
64} 68}
65 69
66static struct clk mcu_pll_clk; 70static struct clk mcu_pll_clk;
67static struct clk mcu_main_clk;
68static struct clk usb_pll_clk;
69static struct clk serial_pll_clk; 71static struct clk serial_pll_clk;
70static struct clk ipg_clk; 72static struct clk ipg_clk;
71static struct clk ckih_clk; 73static struct clk ckih_clk;
72static struct clk ahb_clk;
73 74
74static int _clk_enable(struct clk *clk) 75static int cgr_enable(struct clk *clk)
75{ 76{
76 u32 reg; 77 u32 reg;
77 78
79 if (!clk->enable_reg)
80 return 0;
81
78 reg = __raw_readl(clk->enable_reg); 82 reg = __raw_readl(clk->enable_reg);
79 reg |= 3 << clk->enable_shift; 83 reg |= 3 << clk->enable_shift;
80 __raw_writel(reg, clk->enable_reg); 84 __raw_writel(reg, clk->enable_reg);
@@ -82,133 +86,69 @@ static int _clk_enable(struct clk *clk)
82 return 0; 86 return 0;
83} 87}
84 88
85static void _clk_disable(struct clk *clk) 89static void cgr_disable(struct clk *clk)
86{ 90{
87 u32 reg; 91 u32 reg;
88 92
93 if (!clk->enable_reg)
94 return;
95
89 reg = __raw_readl(clk->enable_reg); 96 reg = __raw_readl(clk->enable_reg);
90 reg &= ~(3 << clk->enable_shift); 97 reg &= ~(3 << clk->enable_shift);
98
99 /* special case for EMI clock */
100 if (clk->enable_reg == MXC_CCM_CGR2 && clk->enable_shift == 8)
101 reg |= (1 << clk->enable_shift);
102
91 __raw_writel(reg, clk->enable_reg); 103 __raw_writel(reg, clk->enable_reg);
92} 104}
93 105
94static void _clk_emi_disable(struct clk *clk) 106static unsigned long pll_ref_get_rate(void)
95{ 107{
96 u32 reg; 108 unsigned long ccmr;
109 unsigned int prcs;
97 110
98 reg = __raw_readl(clk->enable_reg); 111 ccmr = __raw_readl(MXC_CCM_CCMR);
99 reg &= ~(3 << clk->enable_shift); 112 prcs = (ccmr & MXC_CCM_CCMR_PRCS_MASK) >> MXC_CCM_CCMR_PRCS_OFFSET;
100 reg |= (1 << clk->enable_shift); 113 if (prcs == 0x1)
101 __raw_writel(reg, clk->enable_reg); 114 return CKIL_CLK_FREQ * 1024;
115 else
116 return clk_get_rate(&ckih_clk);
102} 117}
103 118
104static int _clk_pll_set_rate(struct clk *clk, unsigned long rate) 119static unsigned long usb_pll_get_rate(struct clk *clk)
105{ 120{
106 u32 reg; 121 unsigned long reg;
107 signed long pd = 1; /* Pre-divider */
108 signed long mfi; /* Multiplication Factor (Integer part) */
109 signed long mfn; /* Multiplication Factor (Integer part) */
110 signed long mfd; /* Multiplication Factor (Denominator Part) */
111 signed long tmp;
112 u32 ref_freq = clk_get_rate(clk->parent);
113 122
114 while (((ref_freq / pd) * 10) > rate) 123 reg = __raw_readl(MXC_CCM_UPCTL);
115 pd++;
116 124
117 if ((ref_freq / pd) < PRE_DIV_MIN_FREQ) 125 return mxc_decode_pll(reg, pll_ref_get_rate());
118 return -EINVAL; 126}
119 127
120 /* the ref_freq/2 in the following is to round up */ 128static unsigned long serial_pll_get_rate(struct clk *clk)
121 mfi = (((rate / 2) * pd) + (ref_freq / 2)) / ref_freq; 129{
122 if (mfi < 5 || mfi > 15) 130 unsigned long reg;
123 return -EINVAL;
124 131
125 /* pick a mfd value that will work 132 reg = __raw_readl(MXC_CCM_SRPCTL);
126 * then solve for mfn */
127 mfd = ref_freq / 50000;
128
129 /*
130 * pll_freq * pd * mfd
131 * mfn = -------------------- - (mfi * mfd)
132 * 2 * ref_freq
133 */
134 /* the tmp/2 is for rounding */
135 tmp = ref_freq / 10000;
136 mfn =
137 ((((((rate / 2) + (tmp / 2)) / tmp) * pd) * mfd) / 10000) -
138 (mfi * mfd);
139
140 mfn = mfn & 0x3ff;
141 pd--;
142 mfd--;
143
144 /* Change the Pll value */
145 reg = (mfi << MXC_CCM_PCTL_MFI_OFFSET) |
146 (mfn << MXC_CCM_PCTL_MFN_OFFSET) |
147 (mfd << MXC_CCM_PCTL_MFD_OFFSET) | (pd << MXC_CCM_PCTL_PD_OFFSET);
148
149 if (clk == &mcu_pll_clk)
150 __raw_writel(reg, MXC_CCM_MPCTL);
151 else if (clk == &usb_pll_clk)
152 __raw_writel(reg, MXC_CCM_UPCTL);
153 else if (clk == &serial_pll_clk)
154 __raw_writel(reg, MXC_CCM_SRPCTL);
155 133
156 return 0; 134 return mxc_decode_pll(reg, pll_ref_get_rate());
157} 135}
158 136
159static unsigned long _clk_pll_get_rate(struct clk *clk) 137static unsigned long mcu_pll_get_rate(struct clk *clk)
160{ 138{
161 long mfi, mfn, mfd, pdf, ref_clk, mfn_abs;
162 unsigned long reg, ccmr; 139 unsigned long reg, ccmr;
163 s64 temp;
164 unsigned int prcs;
165 140
166 ccmr = __raw_readl(MXC_CCM_CCMR); 141 ccmr = __raw_readl(MXC_CCM_CCMR);
167 prcs = (ccmr & MXC_CCM_CCMR_PRCS_MASK) >> MXC_CCM_CCMR_PRCS_OFFSET;
168 if (prcs == 0x1)
169 ref_clk = CKIL_CLK_FREQ * 1024;
170 else
171 ref_clk = clk_get_rate(&ckih_clk);
172
173 if (clk == &mcu_pll_clk) {
174 if ((ccmr & MXC_CCM_CCMR_MPE) == 0)
175 return ref_clk;
176 if ((ccmr & MXC_CCM_CCMR_MDS) != 0)
177 return ref_clk;
178 reg = __raw_readl(MXC_CCM_MPCTL);
179 } else if (clk == &usb_pll_clk)
180 reg = __raw_readl(MXC_CCM_UPCTL);
181 else if (clk == &serial_pll_clk)
182 reg = __raw_readl(MXC_CCM_SRPCTL);
183 else {
184 BUG();
185 return 0;
186 }
187
188 pdf = (reg & MXC_CCM_PCTL_PD_MASK) >> MXC_CCM_PCTL_PD_OFFSET;
189 mfd = (reg & MXC_CCM_PCTL_MFD_MASK) >> MXC_CCM_PCTL_MFD_OFFSET;
190 mfi = (reg & MXC_CCM_PCTL_MFI_MASK) >> MXC_CCM_PCTL_MFI_OFFSET;
191 mfi = (mfi <= 5) ? 5 : mfi;
192 mfn = mfn_abs = reg & MXC_CCM_PCTL_MFN_MASK;
193 142
194 if (mfn >= 0x200) { 143 if (!(ccmr & MXC_CCM_CCMR_MPE) || (ccmr & MXC_CCM_CCMR_MDS))
195 mfn |= 0xFFFFFE00; 144 return clk_get_rate(&ckih_clk);
196 mfn_abs = -mfn;
197 }
198
199 ref_clk *= 2;
200 ref_clk /= pdf + 1;
201 145
202 temp = (u64) ref_clk * mfn_abs; 146 reg = __raw_readl(MXC_CCM_MPCTL);
203 do_div(temp, mfd + 1);
204 if (mfn < 0)
205 temp = -temp;
206 temp = (ref_clk * mfi) + temp;
207 147
208 return temp; 148 return mxc_decode_pll(reg, pll_ref_get_rate());
209} 149}
210 150
211static int _clk_usb_pll_enable(struct clk *clk) 151static int usb_pll_enable(struct clk *clk)
212{ 152{
213 u32 reg; 153 u32 reg;
214 154
@@ -222,7 +162,7 @@ static int _clk_usb_pll_enable(struct clk *clk)
222 return 0; 162 return 0;
223} 163}
224 164
225static void _clk_usb_pll_disable(struct clk *clk) 165static void usb_pll_disable(struct clk *clk)
226{ 166{
227 u32 reg; 167 u32 reg;
228 168
@@ -231,7 +171,7 @@ static void _clk_usb_pll_disable(struct clk *clk)
231 __raw_writel(reg, MXC_CCM_CCMR); 171 __raw_writel(reg, MXC_CCM_CCMR);
232} 172}
233 173
234static int _clk_serial_pll_enable(struct clk *clk) 174static int serial_pll_enable(struct clk *clk)
235{ 175{
236 u32 reg; 176 u32 reg;
237 177
@@ -245,7 +185,7 @@ static int _clk_serial_pll_enable(struct clk *clk)
245 return 0; 185 return 0;
246} 186}
247 187
248static void _clk_serial_pll_disable(struct clk *clk) 188static void serial_pll_disable(struct clk *clk)
249{ 189{
250 u32 reg; 190 u32 reg;
251 191
@@ -258,7 +198,7 @@ static void _clk_serial_pll_disable(struct clk *clk)
258#define PDR1(mask, off) ((__raw_readl(MXC_CCM_PDR1) & mask) >> off) 198#define PDR1(mask, off) ((__raw_readl(MXC_CCM_PDR1) & mask) >> off)
259#define PDR2(mask, off) ((__raw_readl(MXC_CCM_PDR2) & mask) >> off) 199#define PDR2(mask, off) ((__raw_readl(MXC_CCM_PDR2) & mask) >> off)
260 200
261static unsigned long _clk_mcu_main_get_rate(struct clk *clk) 201static unsigned long mcu_main_get_rate(struct clk *clk)
262{ 202{
263 u32 pmcr0 = __raw_readl(MXC_CCM_PMCR0); 203 u32 pmcr0 = __raw_readl(MXC_CCM_PMCR0);
264 204
@@ -268,7 +208,7 @@ static unsigned long _clk_mcu_main_get_rate(struct clk *clk)
268 return clk_get_rate(&mcu_pll_clk); 208 return clk_get_rate(&mcu_pll_clk);
269} 209}
270 210
271static unsigned long _clk_hclk_get_rate(struct clk *clk) 211static unsigned long ahb_get_rate(struct clk *clk)
272{ 212{
273 unsigned long max_pdf; 213 unsigned long max_pdf;
274 214
@@ -277,7 +217,7 @@ static unsigned long _clk_hclk_get_rate(struct clk *clk)
277 return clk_get_rate(clk->parent) / (max_pdf + 1); 217 return clk_get_rate(clk->parent) / (max_pdf + 1);
278} 218}
279 219
280static unsigned long _clk_ipg_get_rate(struct clk *clk) 220static unsigned long ipg_get_rate(struct clk *clk)
281{ 221{
282 unsigned long ipg_pdf; 222 unsigned long ipg_pdf;
283 223
@@ -286,7 +226,7 @@ static unsigned long _clk_ipg_get_rate(struct clk *clk)
286 return clk_get_rate(clk->parent) / (ipg_pdf + 1); 226 return clk_get_rate(clk->parent) / (ipg_pdf + 1);
287} 227}
288 228
289static unsigned long _clk_nfc_get_rate(struct clk *clk) 229static unsigned long nfc_get_rate(struct clk *clk)
290{ 230{
291 unsigned long nfc_pdf; 231 unsigned long nfc_pdf;
292 232
@@ -295,7 +235,7 @@ static unsigned long _clk_nfc_get_rate(struct clk *clk)
295 return clk_get_rate(clk->parent) / (nfc_pdf + 1); 235 return clk_get_rate(clk->parent) / (nfc_pdf + 1);
296} 236}
297 237
298static unsigned long _clk_hsp_get_rate(struct clk *clk) 238static unsigned long hsp_get_rate(struct clk *clk)
299{ 239{
300 unsigned long hsp_pdf; 240 unsigned long hsp_pdf;
301 241
@@ -304,7 +244,7 @@ static unsigned long _clk_hsp_get_rate(struct clk *clk)
304 return clk_get_rate(clk->parent) / (hsp_pdf + 1); 244 return clk_get_rate(clk->parent) / (hsp_pdf + 1);
305} 245}
306 246
307static unsigned long _clk_usb_get_rate(struct clk *clk) 247static unsigned long usb_get_rate(struct clk *clk)
308{ 248{
309 unsigned long usb_pdf, usb_prepdf; 249 unsigned long usb_pdf, usb_prepdf;
310 250
@@ -315,7 +255,7 @@ static unsigned long _clk_usb_get_rate(struct clk *clk)
315 return clk_get_rate(clk->parent) / (usb_prepdf + 1) / (usb_pdf + 1); 255 return clk_get_rate(clk->parent) / (usb_prepdf + 1) / (usb_pdf + 1);
316} 256}
317 257
318static unsigned long _clk_csi_get_rate(struct clk *clk) 258static unsigned long csi_get_rate(struct clk *clk)
319{ 259{
320 u32 reg, pre, post; 260 u32 reg, pre, post;
321 261
@@ -329,7 +269,7 @@ static unsigned long _clk_csi_get_rate(struct clk *clk)
329 return clk_get_rate(clk->parent) / (pre * post); 269 return clk_get_rate(clk->parent) / (pre * post);
330} 270}
331 271
332static unsigned long _clk_csi_round_rate(struct clk *clk, unsigned long rate) 272static unsigned long csi_round_rate(struct clk *clk, unsigned long rate)
333{ 273{
334 u32 pre, post, parent = clk_get_rate(clk->parent); 274 u32 pre, post, parent = clk_get_rate(clk->parent);
335 u32 div = parent / rate; 275 u32 div = parent / rate;
@@ -342,7 +282,7 @@ static unsigned long _clk_csi_round_rate(struct clk *clk, unsigned long rate)
342 return parent / (pre * post); 282 return parent / (pre * post);
343} 283}
344 284
345static int _clk_csi_set_rate(struct clk *clk, unsigned long rate) 285static int csi_set_rate(struct clk *clk, unsigned long rate)
346{ 286{
347 u32 reg, div, pre, post, parent = clk_get_rate(clk->parent); 287 u32 reg, div, pre, post, parent = clk_get_rate(clk->parent);
348 288
@@ -363,16 +303,7 @@ static int _clk_csi_set_rate(struct clk *clk, unsigned long rate)
363 return 0; 303 return 0;
364} 304}
365 305
366static unsigned long _clk_per_get_rate(struct clk *clk) 306static unsigned long ssi1_get_rate(struct clk *clk)
367{
368 unsigned long per_pdf;
369
370 per_pdf = PDR0(MXC_CCM_PDR0_PER_PODF_MASK,
371 MXC_CCM_PDR0_PER_PODF_OFFSET);
372 return clk_get_rate(clk->parent) / (per_pdf + 1);
373}
374
375static unsigned long _clk_ssi1_get_rate(struct clk *clk)
376{ 307{
377 unsigned long ssi1_pdf, ssi1_prepdf; 308 unsigned long ssi1_pdf, ssi1_prepdf;
378 309
@@ -383,7 +314,7 @@ static unsigned long _clk_ssi1_get_rate(struct clk *clk)
383 return clk_get_rate(clk->parent) / (ssi1_prepdf + 1) / (ssi1_pdf + 1); 314 return clk_get_rate(clk->parent) / (ssi1_prepdf + 1) / (ssi1_pdf + 1);
384} 315}
385 316
386static unsigned long _clk_ssi2_get_rate(struct clk *clk) 317static unsigned long ssi2_get_rate(struct clk *clk)
387{ 318{
388 unsigned long ssi2_pdf, ssi2_prepdf; 319 unsigned long ssi2_pdf, ssi2_prepdf;
389 320
@@ -394,7 +325,7 @@ static unsigned long _clk_ssi2_get_rate(struct clk *clk)
394 return clk_get_rate(clk->parent) / (ssi2_prepdf + 1) / (ssi2_pdf + 1); 325 return clk_get_rate(clk->parent) / (ssi2_prepdf + 1) / (ssi2_pdf + 1);
395} 326}
396 327
397static unsigned long _clk_firi_get_rate(struct clk *clk) 328static unsigned long firi_get_rate(struct clk *clk)
398{ 329{
399 unsigned long firi_pdf, firi_prepdf; 330 unsigned long firi_pdf, firi_prepdf;
400 331
@@ -405,7 +336,7 @@ static unsigned long _clk_firi_get_rate(struct clk *clk)
405 return clk_get_rate(clk->parent) / (firi_prepdf + 1) / (firi_pdf + 1); 336 return clk_get_rate(clk->parent) / (firi_prepdf + 1) / (firi_pdf + 1);
406} 337}
407 338
408static unsigned long _clk_firi_round_rate(struct clk *clk, unsigned long rate) 339static unsigned long firi_round_rate(struct clk *clk, unsigned long rate)
409{ 340{
410 u32 pre, post; 341 u32 pre, post;
411 u32 parent = clk_get_rate(clk->parent); 342 u32 parent = clk_get_rate(clk->parent);
@@ -420,7 +351,7 @@ static unsigned long _clk_firi_round_rate(struct clk *clk, unsigned long rate)
420 351
421} 352}
422 353
423static int _clk_firi_set_rate(struct clk *clk, unsigned long rate) 354static int firi_set_rate(struct clk *clk, unsigned long rate)
424{ 355{
425 u32 reg, div, pre, post, parent = clk_get_rate(clk->parent); 356 u32 reg, div, pre, post, parent = clk_get_rate(clk->parent);
426 357
@@ -441,12 +372,12 @@ static int _clk_firi_set_rate(struct clk *clk, unsigned long rate)
441 return 0; 372 return 0;
442} 373}
443 374
444static unsigned long _clk_mbx_get_rate(struct clk *clk) 375static unsigned long mbx_get_rate(struct clk *clk)
445{ 376{
446 return clk_get_rate(clk->parent) / 2; 377 return clk_get_rate(clk->parent) / 2;
447} 378}
448 379
449static unsigned long _clk_mstick1_get_rate(struct clk *clk) 380static unsigned long mstick1_get_rate(struct clk *clk)
450{ 381{
451 unsigned long msti_pdf; 382 unsigned long msti_pdf;
452 383
@@ -455,7 +386,7 @@ static unsigned long _clk_mstick1_get_rate(struct clk *clk)
455 return clk_get_rate(clk->parent) / (msti_pdf + 1); 386 return clk_get_rate(clk->parent) / (msti_pdf + 1);
456} 387}
457 388
458static unsigned long _clk_mstick2_get_rate(struct clk *clk) 389static unsigned long mstick2_get_rate(struct clk *clk)
459{ 390{
460 unsigned long msti_pdf; 391 unsigned long msti_pdf;
461 392
@@ -472,661 +403,185 @@ static unsigned long clk_ckih_get_rate(struct clk *clk)
472} 403}
473 404
474static struct clk ckih_clk = { 405static struct clk ckih_clk = {
475 .name = "ckih",
476 .get_rate = clk_ckih_get_rate, 406 .get_rate = clk_ckih_get_rate,
477}; 407};
478 408
479static unsigned long clk_ckil_get_rate(struct clk *clk)
480{
481 return CKIL_CLK_FREQ;
482}
483
484static struct clk ckil_clk = {
485 .name = "ckil",
486 .get_rate = clk_ckil_get_rate,
487};
488
489static struct clk mcu_pll_clk = { 409static struct clk mcu_pll_clk = {
490 .name = "mcu_pll",
491 .parent = &ckih_clk, 410 .parent = &ckih_clk,
492 .set_rate = _clk_pll_set_rate, 411 .get_rate = mcu_pll_get_rate,
493 .get_rate = _clk_pll_get_rate,
494}; 412};
495 413
496static struct clk mcu_main_clk = { 414static struct clk mcu_main_clk = {
497 .name = "mcu_main_clk",
498 .parent = &mcu_pll_clk, 415 .parent = &mcu_pll_clk,
499 .get_rate = _clk_mcu_main_get_rate, 416 .get_rate = mcu_main_get_rate,
500}; 417};
501 418
502static struct clk serial_pll_clk = { 419static struct clk serial_pll_clk = {
503 .name = "serial_pll",
504 .parent = &ckih_clk, 420 .parent = &ckih_clk,
505 .set_rate = _clk_pll_set_rate, 421 .get_rate = serial_pll_get_rate,
506 .get_rate = _clk_pll_get_rate, 422 .enable = serial_pll_enable,
507 .enable = _clk_serial_pll_enable, 423 .disable = serial_pll_disable,
508 .disable = _clk_serial_pll_disable,
509}; 424};
510 425
511static struct clk usb_pll_clk = { 426static struct clk usb_pll_clk = {
512 .name = "usb_pll",
513 .parent = &ckih_clk, 427 .parent = &ckih_clk,
514 .set_rate = _clk_pll_set_rate, 428 .get_rate = usb_pll_get_rate,
515 .get_rate = _clk_pll_get_rate, 429 .enable = usb_pll_enable,
516 .enable = _clk_usb_pll_enable, 430 .disable = usb_pll_disable,
517 .disable = _clk_usb_pll_disable,
518}; 431};
519 432
520static struct clk ahb_clk = { 433static struct clk ahb_clk = {
521 .name = "ahb_clk",
522 .parent = &mcu_main_clk, 434 .parent = &mcu_main_clk,
523 .get_rate = _clk_hclk_get_rate, 435 .get_rate = ahb_get_rate,
524}; 436};
525 437
526static struct clk per_clk = { 438#define DEFINE_CLOCK(name, i, er, es, gr, s, p) \
527 .name = "per_clk", 439 static struct clk name = { \
528 .parent = &usb_pll_clk, 440 .id = i, \
529 .get_rate = _clk_per_get_rate, 441 .enable_reg = er, \
530}; 442 .enable_shift = es, \
531 443 .get_rate = gr, \
532static struct clk perclk_clk = { 444 .enable = cgr_enable, \
533 .name = "perclk_clk", 445 .disable = cgr_disable, \
534 .parent = &ipg_clk, 446 .secondary = s, \
535}; 447 .parent = p, \
536 448 }
537static struct clk cspi_clk[] = {
538 {
539 .name = "cspi_clk",
540 .id = 0,
541 .parent = &ipg_clk,
542 .enable = _clk_enable,
543 .enable_reg = MXC_CCM_CGR2,
544 .enable_shift = MXC_CCM_CGR2_CSPI1_OFFSET,
545 .disable = _clk_disable,},
546 {
547 .name = "cspi_clk",
548 .id = 1,
549 .parent = &ipg_clk,
550 .enable = _clk_enable,
551 .enable_reg = MXC_CCM_CGR2,
552 .enable_shift = MXC_CCM_CGR2_CSPI2_OFFSET,
553 .disable = _clk_disable,},
554 {
555 .name = "cspi_clk",
556 .id = 2,
557 .parent = &ipg_clk,
558 .enable = _clk_enable,
559 .enable_reg = MXC_CCM_CGR0,
560 .enable_shift = MXC_CCM_CGR0_CSPI3_OFFSET,
561 .disable = _clk_disable,},
562};
563
564static struct clk ipg_clk = {
565 .name = "ipg_clk",
566 .parent = &ahb_clk,
567 .get_rate = _clk_ipg_get_rate,
568};
569
570static struct clk emi_clk = {
571 .name = "emi_clk",
572 .parent = &ahb_clk,
573 .enable = _clk_enable,
574 .enable_reg = MXC_CCM_CGR2,
575 .enable_shift = MXC_CCM_CGR2_EMI_OFFSET,
576 .disable = _clk_emi_disable,
577};
578
579static struct clk gpt_clk = {
580 .name = "gpt_clk",
581 .parent = &perclk_clk,
582 .enable = _clk_enable,
583 .enable_reg = MXC_CCM_CGR0,
584 .enable_shift = MXC_CCM_CGR0_GPT_OFFSET,
585 .disable = _clk_disable,
586};
587
588static struct clk pwm_clk = {
589 .name = "pwm_clk",
590 .parent = &perclk_clk,
591 .enable = _clk_enable,
592 .enable_reg = MXC_CCM_CGR0,
593 .enable_shift = MXC_CCM_CGR1_PWM_OFFSET,
594 .disable = _clk_disable,
595};
596
597static struct clk epit_clk[] = {
598 {
599 .name = "epit_clk",
600 .id = 0,
601 .parent = &perclk_clk,
602 .enable = _clk_enable,
603 .enable_reg = MXC_CCM_CGR0,
604 .enable_shift = MXC_CCM_CGR0_EPIT1_OFFSET,
605 .disable = _clk_disable,},
606 {
607 .name = "epit_clk",
608 .id = 1,
609 .parent = &perclk_clk,
610 .enable = _clk_enable,
611 .enable_reg = MXC_CCM_CGR0,
612 .enable_shift = MXC_CCM_CGR0_EPIT2_OFFSET,
613 .disable = _clk_disable,},
614};
615
616static struct clk nfc_clk = {
617 .name = "nfc_clk",
618 .parent = &ahb_clk,
619 .get_rate = _clk_nfc_get_rate,
620};
621
622static struct clk scc_clk = {
623 .name = "scc_clk",
624 .parent = &ipg_clk,
625};
626
627static struct clk ipu_clk = {
628 .name = "ipu_clk",
629 .parent = &mcu_main_clk,
630 .get_rate = _clk_hsp_get_rate,
631 .enable = _clk_enable,
632 .enable_reg = MXC_CCM_CGR1,
633 .enable_shift = MXC_CCM_CGR1_IPU_OFFSET,
634 .disable = _clk_disable,
635};
636
637static struct clk kpp_clk = {
638 .name = "kpp_clk",
639 .parent = &ipg_clk,
640 .enable = _clk_enable,
641 .enable_reg = MXC_CCM_CGR1,
642 .enable_shift = MXC_CCM_CGR1_KPP_OFFSET,
643 .disable = _clk_disable,
644};
645
646static struct clk wdog_clk = {
647 .name = "wdog_clk",
648 .parent = &ipg_clk,
649 .enable = _clk_enable,
650 .enable_reg = MXC_CCM_CGR1,
651 .enable_shift = MXC_CCM_CGR1_WDOG_OFFSET,
652 .disable = _clk_disable,
653};
654static struct clk rtc_clk = {
655 .name = "rtc_clk",
656 .parent = &ipg_clk,
657 .enable = _clk_enable,
658 .enable_reg = MXC_CCM_CGR1,
659 .enable_shift = MXC_CCM_CGR1_RTC_OFFSET,
660 .disable = _clk_disable,
661};
662
663static struct clk usb_clk[] = {
664 {
665 .name = "usb_clk",
666 .parent = &usb_pll_clk,
667 .get_rate = _clk_usb_get_rate,},
668 {
669 .name = "usb_ahb_clk",
670 .parent = &ahb_clk,
671 .enable = _clk_enable,
672 .enable_reg = MXC_CCM_CGR1,
673 .enable_shift = MXC_CCM_CGR1_USBOTG_OFFSET,
674 .disable = _clk_disable,},
675};
676
677static struct clk csi_clk = {
678 .name = "csi_clk",
679 .parent = &serial_pll_clk,
680 .get_rate = _clk_csi_get_rate,
681 .round_rate = _clk_csi_round_rate,
682 .set_rate = _clk_csi_set_rate,
683 .enable = _clk_enable,
684 .enable_reg = MXC_CCM_CGR1,
685 .enable_shift = MXC_CCM_CGR1_CSI_OFFSET,
686 .disable = _clk_disable,
687};
688
689static struct clk uart_clk[] = {
690 {
691 .name = "uart_clk",
692 .id = 0,
693 .parent = &perclk_clk,
694 .enable = _clk_enable,
695 .enable_reg = MXC_CCM_CGR0,
696 .enable_shift = MXC_CCM_CGR0_UART1_OFFSET,
697 .disable = _clk_disable,},
698 {
699 .name = "uart_clk",
700 .id = 1,
701 .parent = &perclk_clk,
702 .enable = _clk_enable,
703 .enable_reg = MXC_CCM_CGR0,
704 .enable_shift = MXC_CCM_CGR0_UART2_OFFSET,
705 .disable = _clk_disable,},
706 {
707 .name = "uart_clk",
708 .id = 2,
709 .parent = &perclk_clk,
710 .enable = _clk_enable,
711 .enable_reg = MXC_CCM_CGR1,
712 .enable_shift = MXC_CCM_CGR1_UART3_OFFSET,
713 .disable = _clk_disable,},
714 {
715 .name = "uart_clk",
716 .id = 3,
717 .parent = &perclk_clk,
718 .enable = _clk_enable,
719 .enable_reg = MXC_CCM_CGR1,
720 .enable_shift = MXC_CCM_CGR1_UART4_OFFSET,
721 .disable = _clk_disable,},
722 {
723 .name = "uart_clk",
724 .id = 4,
725 .parent = &perclk_clk,
726 .enable = _clk_enable,
727 .enable_reg = MXC_CCM_CGR1,
728 .enable_shift = MXC_CCM_CGR1_UART5_OFFSET,
729 .disable = _clk_disable,},
730};
731
732static struct clk i2c_clk[] = {
733 {
734 .name = "i2c_clk",
735 .id = 0,
736 .parent = &perclk_clk,
737 .enable = _clk_enable,
738 .enable_reg = MXC_CCM_CGR0,
739 .enable_shift = MXC_CCM_CGR0_I2C1_OFFSET,
740 .disable = _clk_disable,},
741 {
742 .name = "i2c_clk",
743 .id = 1,
744 .parent = &perclk_clk,
745 .enable = _clk_enable,
746 .enable_reg = MXC_CCM_CGR0,
747 .enable_shift = MXC_CCM_CGR0_I2C2_OFFSET,
748 .disable = _clk_disable,},
749 {
750 .name = "i2c_clk",
751 .id = 2,
752 .parent = &perclk_clk,
753 .enable = _clk_enable,
754 .enable_reg = MXC_CCM_CGR0,
755 .enable_shift = MXC_CCM_CGR0_I2C3_OFFSET,
756 .disable = _clk_disable,},
757};
758
759static struct clk owire_clk = {
760 .name = "owire_clk",
761 .parent = &perclk_clk,
762 .enable_reg = MXC_CCM_CGR1,
763 .enable_shift = MXC_CCM_CGR1_OWIRE_OFFSET,
764 .enable = _clk_enable,
765 .disable = _clk_disable,
766};
767
768static struct clk sdhc_clk[] = {
769 {
770 .name = "sdhc_clk",
771 .id = 0,
772 .parent = &perclk_clk,
773 .enable = _clk_enable,
774 .enable_reg = MXC_CCM_CGR0,
775 .enable_shift = MXC_CCM_CGR0_SD_MMC1_OFFSET,
776 .disable = _clk_disable,},
777 {
778 .name = "sdhc_clk",
779 .id = 1,
780 .parent = &perclk_clk,
781 .enable = _clk_enable,
782 .enable_reg = MXC_CCM_CGR0,
783 .enable_shift = MXC_CCM_CGR0_SD_MMC2_OFFSET,
784 .disable = _clk_disable,},
785};
786
787static struct clk ssi_clk[] = {
788 {
789 .name = "ssi_clk",
790 .parent = &serial_pll_clk,
791 .get_rate = _clk_ssi1_get_rate,
792 .enable = _clk_enable,
793 .enable_reg = MXC_CCM_CGR0,
794 .enable_shift = MXC_CCM_CGR0_SSI1_OFFSET,
795 .disable = _clk_disable,},
796 {
797 .name = "ssi_clk",
798 .id = 1,
799 .parent = &serial_pll_clk,
800 .get_rate = _clk_ssi2_get_rate,
801 .enable = _clk_enable,
802 .enable_reg = MXC_CCM_CGR2,
803 .enable_shift = MXC_CCM_CGR2_SSI2_OFFSET,
804 .disable = _clk_disable,},
805};
806
807static struct clk firi_clk = {
808 .name = "firi_clk",
809 .parent = &usb_pll_clk,
810 .round_rate = _clk_firi_round_rate,
811 .set_rate = _clk_firi_set_rate,
812 .get_rate = _clk_firi_get_rate,
813 .enable = _clk_enable,
814 .enable_reg = MXC_CCM_CGR2,
815 .enable_shift = MXC_CCM_CGR2_FIRI_OFFSET,
816 .disable = _clk_disable,
817};
818
819static struct clk ata_clk = {
820 .name = "ata_clk",
821 .parent = &ipg_clk,
822 .enable = _clk_enable,
823 .enable_reg = MXC_CCM_CGR0,
824 .enable_shift = MXC_CCM_CGR0_ATA_OFFSET,
825 .disable = _clk_disable,
826};
827
828static struct clk mbx_clk = {
829 .name = "mbx_clk",
830 .parent = &ahb_clk,
831 .enable = _clk_enable,
832 .enable_reg = MXC_CCM_CGR2,
833 .enable_shift = MXC_CCM_CGR2_GACC_OFFSET,
834 .get_rate = _clk_mbx_get_rate,
835};
836
837static struct clk vpu_clk = {
838 .name = "vpu_clk",
839 .parent = &ahb_clk,
840 .enable = _clk_enable,
841 .enable_reg = MXC_CCM_CGR2,
842 .enable_shift = MXC_CCM_CGR2_GACC_OFFSET,
843 .get_rate = _clk_mbx_get_rate,
844};
845
846static struct clk rtic_clk = {
847 .name = "rtic_clk",
848 .parent = &ahb_clk,
849 .enable = _clk_enable,
850 .enable_reg = MXC_CCM_CGR2,
851 .enable_shift = MXC_CCM_CGR2_RTIC_OFFSET,
852 .disable = _clk_disable,
853};
854
855static struct clk rng_clk = {
856 .name = "rng_clk",
857 .parent = &ipg_clk,
858 .enable = _clk_enable,
859 .enable_reg = MXC_CCM_CGR0,
860 .enable_shift = MXC_CCM_CGR0_RNG_OFFSET,
861 .disable = _clk_disable,
862};
863
864static struct clk sdma_clk[] = {
865 {
866 .name = "sdma_ahb_clk",
867 .parent = &ahb_clk,
868 .enable = _clk_enable,
869 .enable_reg = MXC_CCM_CGR0,
870 .enable_shift = MXC_CCM_CGR0_SDMA_OFFSET,
871 .disable = _clk_disable,},
872 {
873 .name = "sdma_ipg_clk",
874 .parent = &ipg_clk,}
875};
876
877static struct clk mpeg4_clk = {
878 .name = "mpeg4_clk",
879 .parent = &ahb_clk,
880 .enable = _clk_enable,
881 .enable_reg = MXC_CCM_CGR1,
882 .enable_shift = MXC_CCM_CGR1_HANTRO_OFFSET,
883 .disable = _clk_disable,
884};
885
886static struct clk vl2cc_clk = {
887 .name = "vl2cc_clk",
888 .parent = &ahb_clk,
889 .enable = _clk_enable,
890 .enable_reg = MXC_CCM_CGR1,
891 .enable_shift = MXC_CCM_CGR1_HANTRO_OFFSET,
892 .disable = _clk_disable,
893};
894
895static struct clk mstick_clk[] = {
896 {
897 .name = "mstick_clk",
898 .id = 0,
899 .parent = &usb_pll_clk,
900 .get_rate = _clk_mstick1_get_rate,
901 .enable = _clk_enable,
902 .enable_reg = MXC_CCM_CGR1,
903 .enable_shift = MXC_CCM_CGR1_MEMSTICK1_OFFSET,
904 .disable = _clk_disable,},
905 {
906 .name = "mstick_clk",
907 .id = 1,
908 .parent = &usb_pll_clk,
909 .get_rate = _clk_mstick2_get_rate,
910 .enable = _clk_enable,
911 .enable_reg = MXC_CCM_CGR1,
912 .enable_shift = MXC_CCM_CGR1_MEMSTICK2_OFFSET,
913 .disable = _clk_disable,},
914};
915
916static struct clk iim_clk = {
917 .name = "iim_clk",
918 .parent = &ipg_clk,
919 .enable = _clk_enable,
920 .enable_reg = MXC_CCM_CGR0,
921 .enable_shift = MXC_CCM_CGR0_IIM_OFFSET,
922 .disable = _clk_disable,
923};
924
925static unsigned long _clk_cko1_round_rate(struct clk *clk, unsigned long rate)
926{
927 u32 div, parent = clk_get_rate(clk->parent);
928
929 div = parent / rate;
930 if (parent % rate)
931 div++;
932
933 if (div > 8)
934 div = 16;
935 else if (div > 4)
936 div = 8;
937 else if (div > 2)
938 div = 4;
939
940 return parent / div;
941}
942
943static int _clk_cko1_set_rate(struct clk *clk, unsigned long rate)
944{
945 u32 reg, div, parent = clk_get_rate(clk->parent);
946
947 div = parent / rate;
948
949 if (div == 16)
950 div = 4;
951 else if (div == 8)
952 div = 3;
953 else if (div == 4)
954 div = 2;
955 else if (div == 2)
956 div = 1;
957 else if (div == 1)
958 div = 0;
959 else
960 return -EINVAL;
961
962 reg = __raw_readl(MXC_CCM_COSR) & ~MXC_CCM_COSR_CLKOUTDIV_MASK;
963 reg |= div << MXC_CCM_COSR_CLKOUTDIV_OFFSET;
964 __raw_writel(reg, MXC_CCM_COSR);
965
966 return 0;
967}
968
969static unsigned long _clk_cko1_get_rate(struct clk *clk)
970{
971 u32 div;
972
973 div = __raw_readl(MXC_CCM_COSR) & MXC_CCM_COSR_CLKOUTDIV_MASK >>
974 MXC_CCM_COSR_CLKOUTDIV_OFFSET;
975
976 return clk_get_rate(clk->parent) / (1 << div);
977}
978
979static int _clk_cko1_set_parent(struct clk *clk, struct clk *parent)
980{
981 u32 reg;
982
983 reg = __raw_readl(MXC_CCM_COSR) & ~MXC_CCM_COSR_CLKOSEL_MASK;
984
985 if (parent == &mcu_main_clk)
986 reg |= 0 << MXC_CCM_COSR_CLKOSEL_OFFSET;
987 else if (parent == &ipg_clk)
988 reg |= 1 << MXC_CCM_COSR_CLKOSEL_OFFSET;
989 else if (parent == &usb_pll_clk)
990 reg |= 2 << MXC_CCM_COSR_CLKOSEL_OFFSET;
991 else if (parent == mcu_main_clk.parent)
992 reg |= 3 << MXC_CCM_COSR_CLKOSEL_OFFSET;
993 else if (parent == &ahb_clk)
994 reg |= 5 << MXC_CCM_COSR_CLKOSEL_OFFSET;
995 else if (parent == &serial_pll_clk)
996 reg |= 7 << MXC_CCM_COSR_CLKOSEL_OFFSET;
997 else if (parent == &ckih_clk)
998 reg |= 8 << MXC_CCM_COSR_CLKOSEL_OFFSET;
999 else if (parent == &emi_clk)
1000 reg |= 9 << MXC_CCM_COSR_CLKOSEL_OFFSET;
1001 else if (parent == &ipu_clk)
1002 reg |= 0xA << MXC_CCM_COSR_CLKOSEL_OFFSET;
1003 else if (parent == &nfc_clk)
1004 reg |= 0xB << MXC_CCM_COSR_CLKOSEL_OFFSET;
1005 else if (parent == &uart_clk[0])
1006 reg |= 0xC << MXC_CCM_COSR_CLKOSEL_OFFSET;
1007 else
1008 return -EINVAL;
1009
1010 __raw_writel(reg, MXC_CCM_COSR);
1011
1012 return 0;
1013}
1014
1015static int _clk_cko1_enable(struct clk *clk)
1016{
1017 u32 reg;
1018
1019 reg = __raw_readl(MXC_CCM_COSR) | MXC_CCM_COSR_CLKOEN;
1020 __raw_writel(reg, MXC_CCM_COSR);
1021 449
1022 return 0; 450#define DEFINE_CLOCK1(name, i, er, es, getsetround, s, p) \
1023} 451 static struct clk name = { \
452 .id = i, \
453 .enable_reg = er, \
454 .enable_shift = es, \
455 .get_rate = getsetround##_get_rate, \
456 .set_rate = getsetround##_set_rate, \
457 .round_rate = getsetround##_round_rate, \
458 .enable = cgr_enable, \
459 .disable = cgr_disable, \
460 .secondary = s, \
461 .parent = p, \
462 }
1024 463
1025static void _clk_cko1_disable(struct clk *clk) 464DEFINE_CLOCK(perclk_clk, 0, NULL, 0, NULL, NULL, &ipg_clk);
465
466DEFINE_CLOCK(sdhc1_clk, 0, MXC_CCM_CGR0, 0, NULL, NULL, &perclk_clk);
467DEFINE_CLOCK(sdhc2_clk, 1, MXC_CCM_CGR0, 2, NULL, NULL, &perclk_clk);
468DEFINE_CLOCK(gpt_clk, 0, MXC_CCM_CGR0, 4, NULL, NULL, &perclk_clk);
469DEFINE_CLOCK(epit1_clk, 0, MXC_CCM_CGR0, 6, NULL, NULL, &perclk_clk);
470DEFINE_CLOCK(epit2_clk, 1, MXC_CCM_CGR0, 8, NULL, NULL, &perclk_clk);
471DEFINE_CLOCK(iim_clk, 0, MXC_CCM_CGR0, 10, NULL, NULL, &ipg_clk);
472DEFINE_CLOCK(ata_clk, 0, MXC_CCM_CGR0, 12, NULL, NULL, &ipg_clk);
473DEFINE_CLOCK(sdma_clk1, 0, MXC_CCM_CGR0, 14, NULL, &sdma_clk1, &ahb_clk);
474DEFINE_CLOCK(cspi3_clk, 2, MXC_CCM_CGR0, 16, NULL, NULL, &ipg_clk);
475DEFINE_CLOCK(rng_clk, 0, MXC_CCM_CGR0, 18, NULL, NULL, &ipg_clk);
476DEFINE_CLOCK(uart1_clk, 0, MXC_CCM_CGR0, 20, NULL, NULL, &perclk_clk);
477DEFINE_CLOCK(uart2_clk, 1, MXC_CCM_CGR0, 22, NULL, NULL, &perclk_clk);
478DEFINE_CLOCK(ssi1_clk, 0, MXC_CCM_CGR0, 24, ssi1_get_rate, NULL, &serial_pll_clk);
479DEFINE_CLOCK(i2c1_clk, 0, MXC_CCM_CGR0, 26, NULL, NULL, &perclk_clk);
480DEFINE_CLOCK(i2c2_clk, 1, MXC_CCM_CGR0, 28, NULL, NULL, &perclk_clk);
481DEFINE_CLOCK(i2c3_clk, 2, MXC_CCM_CGR0, 30, NULL, NULL, &perclk_clk);
482
483DEFINE_CLOCK(mpeg4_clk, 0, MXC_CCM_CGR1, 0, NULL, NULL, &ahb_clk);
484DEFINE_CLOCK(mstick1_clk, 0, MXC_CCM_CGR1, 2, mstick1_get_rate, NULL, &usb_pll_clk);
485DEFINE_CLOCK(mstick2_clk, 1, MXC_CCM_CGR1, 4, mstick2_get_rate, NULL, &usb_pll_clk);
486DEFINE_CLOCK1(csi_clk, 0, MXC_CCM_CGR1, 6, csi, NULL, &ahb_clk);
487DEFINE_CLOCK(rtc_clk, 0, MXC_CCM_CGR1, 8, NULL, NULL, &ipg_clk);
488DEFINE_CLOCK(wdog_clk, 0, MXC_CCM_CGR1, 10, NULL, NULL, &ipg_clk);
489DEFINE_CLOCK(pwm_clk, 0, MXC_CCM_CGR1, 12, NULL, NULL, &perclk_clk);
490DEFINE_CLOCK(usb_clk2, 0, MXC_CCM_CGR1, 18, usb_get_rate, NULL, &ahb_clk);
491DEFINE_CLOCK(kpp_clk, 0, MXC_CCM_CGR1, 20, NULL, NULL, &ipg_clk);
492DEFINE_CLOCK(ipu_clk, 0, MXC_CCM_CGR1, 22, hsp_get_rate, NULL, &mcu_main_clk);
493DEFINE_CLOCK(uart3_clk, 2, MXC_CCM_CGR1, 24, NULL, NULL, &perclk_clk);
494DEFINE_CLOCK(uart4_clk, 3, MXC_CCM_CGR1, 26, NULL, NULL, &perclk_clk);
495DEFINE_CLOCK(uart5_clk, 4, MXC_CCM_CGR1, 28, NULL, NULL, &perclk_clk);
496DEFINE_CLOCK(owire_clk, 0, MXC_CCM_CGR1, 30, NULL, NULL, &perclk_clk);
497
498DEFINE_CLOCK(ssi2_clk, 1, MXC_CCM_CGR2, 0, ssi2_get_rate, NULL, &serial_pll_clk);
499DEFINE_CLOCK(cspi1_clk, 0, MXC_CCM_CGR2, 2, NULL, NULL, &ipg_clk);
500DEFINE_CLOCK(cspi2_clk, 1, MXC_CCM_CGR2, 4, NULL, NULL, &ipg_clk);
501DEFINE_CLOCK(mbx_clk, 0, MXC_CCM_CGR2, 6, mbx_get_rate, NULL, &ahb_clk);
502DEFINE_CLOCK(emi_clk, 0, MXC_CCM_CGR2, 8, NULL, NULL, &ahb_clk);
503DEFINE_CLOCK(rtic_clk, 0, MXC_CCM_CGR2, 10, NULL, NULL, &ahb_clk);
504DEFINE_CLOCK1(firi_clk, 0, MXC_CCM_CGR2, 12, firi, NULL, &usb_pll_clk);
505
506DEFINE_CLOCK(sdma_clk2, 0, NULL, 0, NULL, NULL, &ipg_clk);
507DEFINE_CLOCK(usb_clk1, 0, NULL, 0, usb_get_rate, NULL, &usb_pll_clk);
508DEFINE_CLOCK(nfc_clk, 0, NULL, 0, nfc_get_rate, NULL, &ahb_clk);
509DEFINE_CLOCK(scc_clk, 0, NULL, 0, NULL, NULL, &ipg_clk);
510DEFINE_CLOCK(ipg_clk, 0, NULL, 0, ipg_get_rate, NULL, &ahb_clk);
511
512#define _REGISTER_CLOCK(d, n, c) \
513 { \
514 .dev_id = d, \
515 .con_id = n, \
516 .clk = &c, \
517 },
518
519static struct clk_lookup lookups[] __initdata = {
520 _REGISTER_CLOCK(NULL, "emi", emi_clk)
521 _REGISTER_CLOCK(NULL, "cspi", cspi1_clk)
522 _REGISTER_CLOCK(NULL, "cspi", cspi2_clk)
523 _REGISTER_CLOCK(NULL, "cspi", cspi3_clk)
524 _REGISTER_CLOCK(NULL, "gpt", gpt_clk)
525 _REGISTER_CLOCK(NULL, "pwm", pwm_clk)
526 _REGISTER_CLOCK(NULL, "wdog", wdog_clk)
527 _REGISTER_CLOCK(NULL, "rtc", rtc_clk)
528 _REGISTER_CLOCK(NULL, "epit", epit1_clk)
529 _REGISTER_CLOCK(NULL, "epit", epit2_clk)
530 _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk)
531 _REGISTER_CLOCK("ipu-core", NULL, ipu_clk)
532 _REGISTER_CLOCK("mx3_sdc_fb", NULL, ipu_clk)
533 _REGISTER_CLOCK(NULL, "kpp", kpp_clk)
534 _REGISTER_CLOCK("fsl-usb2-udc", "usb", usb_clk1)
535 _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", usb_clk2)
536 _REGISTER_CLOCK("mx3-camera.0", "csi", csi_clk)
537 _REGISTER_CLOCK("imx-uart.0", NULL, uart1_clk)
538 _REGISTER_CLOCK("imx-uart.1", NULL, uart2_clk)
539 _REGISTER_CLOCK("imx-uart.2", NULL, uart3_clk)
540 _REGISTER_CLOCK("imx-uart.3", NULL, uart4_clk)
541 _REGISTER_CLOCK("imx-uart.4", NULL, uart5_clk)
542 _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk)
543 _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk)
544 _REGISTER_CLOCK("imx-i2c.2", NULL, i2c3_clk)
545 _REGISTER_CLOCK("mxc_w1.0", NULL, owire_clk)
546 _REGISTER_CLOCK("mxc-mmc.0", NULL, sdhc1_clk)
547 _REGISTER_CLOCK("mxc-mmc.1", NULL, sdhc2_clk)
548 _REGISTER_CLOCK(NULL, "ssi", ssi1_clk)
549 _REGISTER_CLOCK(NULL, "ssi", ssi2_clk)
550 _REGISTER_CLOCK(NULL, "firi", firi_clk)
551 _REGISTER_CLOCK(NULL, "ata", ata_clk)
552 _REGISTER_CLOCK(NULL, "rtic", rtic_clk)
553 _REGISTER_CLOCK(NULL, "rng", rng_clk)
554 _REGISTER_CLOCK(NULL, "sdma_ahb", sdma_clk1)
555 _REGISTER_CLOCK(NULL, "sdma_ipg", sdma_clk2)
556 _REGISTER_CLOCK(NULL, "mstick", mstick1_clk)
557 _REGISTER_CLOCK(NULL, "mstick", mstick2_clk)
558 _REGISTER_CLOCK(NULL, "scc", scc_clk)
559 _REGISTER_CLOCK(NULL, "iim", iim_clk)
560 _REGISTER_CLOCK(NULL, "mpeg4", mpeg4_clk)
561 _REGISTER_CLOCK(NULL, "mbx", mbx_clk)
562};
563
564int __init mx31_clocks_init(unsigned long fref)
1026{ 565{
1027 u32 reg; 566 u32 reg;
567 int i;
1028 568
1029 reg = __raw_readl(MXC_CCM_COSR) & ~MXC_CCM_COSR_CLKOEN; 569 mxc_set_cpu_type(MXC_CPU_MX31);
1030 __raw_writel(reg, MXC_CCM_COSR);
1031}
1032
1033static struct clk cko1_clk = {
1034 .name = "cko1_clk",
1035 .get_rate = _clk_cko1_get_rate,
1036 .set_rate = _clk_cko1_set_rate,
1037 .round_rate = _clk_cko1_round_rate,
1038 .set_parent = _clk_cko1_set_parent,
1039 .enable = _clk_cko1_enable,
1040 .disable = _clk_cko1_disable,
1041};
1042
1043static struct clk *mxc_clks[] = {
1044 &ckih_clk,
1045 &ckil_clk,
1046 &mcu_pll_clk,
1047 &usb_pll_clk,
1048 &serial_pll_clk,
1049 &mcu_main_clk,
1050 &ahb_clk,
1051 &per_clk,
1052 &perclk_clk,
1053 &cko1_clk,
1054 &emi_clk,
1055 &cspi_clk[0],
1056 &cspi_clk[1],
1057 &cspi_clk[2],
1058 &ipg_clk,
1059 &gpt_clk,
1060 &pwm_clk,
1061 &wdog_clk,
1062 &rtc_clk,
1063 &epit_clk[0],
1064 &epit_clk[1],
1065 &nfc_clk,
1066 &ipu_clk,
1067 &kpp_clk,
1068 &usb_clk[0],
1069 &usb_clk[1],
1070 &csi_clk,
1071 &uart_clk[0],
1072 &uart_clk[1],
1073 &uart_clk[2],
1074 &uart_clk[3],
1075 &uart_clk[4],
1076 &i2c_clk[0],
1077 &i2c_clk[1],
1078 &i2c_clk[2],
1079 &owire_clk,
1080 &sdhc_clk[0],
1081 &sdhc_clk[1],
1082 &ssi_clk[0],
1083 &ssi_clk[1],
1084 &firi_clk,
1085 &ata_clk,
1086 &rtic_clk,
1087 &rng_clk,
1088 &sdma_clk[0],
1089 &sdma_clk[1],
1090 &mstick_clk[0],
1091 &mstick_clk[1],
1092 &scc_clk,
1093 &iim_clk,
1094};
1095
1096int __init mxc_clocks_init(unsigned long fref)
1097{
1098 u32 reg;
1099 struct clk **clkp;
1100 570
1101 ckih_rate = fref; 571 ckih_rate = fref;
1102 572
1103 for (clkp = mxc_clks; clkp < mxc_clks + ARRAY_SIZE(mxc_clks); clkp++) 573 for (i = 0; i < ARRAY_SIZE(lookups); i++)
1104 clk_register(*clkp); 574 clkdev_add(&lookups[i]);
1105
1106 if (cpu_is_mx31()) {
1107 clk_register(&mpeg4_clk);
1108 clk_register(&mbx_clk);
1109 } else {
1110 clk_register(&vpu_clk);
1111 clk_register(&vl2cc_clk);
1112 }
1113 575
1114 /* Turn off all possible clocks */ 576 /* Turn off all possible clocks */
1115 __raw_writel(MXC_CCM_CGR0_GPT_MASK, MXC_CCM_CGR0); 577 __raw_writel((3 << 4), MXC_CCM_CGR0);
1116 __raw_writel(0, MXC_CCM_CGR1); 578 __raw_writel(0, MXC_CCM_CGR1);
1117 579 __raw_writel((3 << 8) | (3 << 14) | (3 << 16)|
1118 __raw_writel(MXC_CCM_CGR2_EMI_MASK |
1119 MXC_CCM_CGR2_IPMUX1_MASK |
1120 MXC_CCM_CGR2_IPMUX2_MASK |
1121 MXC_CCM_CGR2_MXCCLKENSEL_MASK | /* for MX32 */
1122 MXC_CCM_CGR2_CHIKCAMPEN_MASK | /* for MX32 */
1123 MXC_CCM_CGR2_OVRVPUBUSY_MASK | /* for MX32 */
1124 1 << 27 | 1 << 28, /* Bit 27 and 28 are not defined for 580 1 << 27 | 1 << 28, /* Bit 27 and 28 are not defined for
1125 MX32, but still required to be set */ 581 MX32, but still required to be set */
1126 MXC_CCM_CGR2); 582 MXC_CCM_CGR2);
1127 583
1128 clk_disable(&cko1_clk); 584 usb_pll_disable(&usb_pll_clk);
1129 clk_disable(&usb_pll_clk);
1130 585
1131 pr_info("Clock input source is %ld\n", clk_get_rate(&ckih_clk)); 586 pr_info("Clock input source is %ld\n", clk_get_rate(&ckih_clk));
1132 587
@@ -1143,6 +598,8 @@ int __init mxc_clocks_init(unsigned long fref)
1143 __raw_writel(reg, MXC_CCM_PMCR1); 598 __raw_writel(reg, MXC_CCM_PMCR1);
1144 } 599 }
1145 600
601 mxc_timer_init(&ipg_clk);
602
1146 return 0; 603 return 0;
1147} 604}
1148 605
diff --git a/arch/arm/mach-mx3/crm_regs.h b/arch/arm/mach-mx3/crm_regs.h
index 4a0e0ede23bb..adfa3627ad84 100644
--- a/arch/arm/mach-mx3/crm_regs.h
+++ b/arch/arm/mach-mx3/crm_regs.h
@@ -91,47 +91,6 @@
91#define MXC_CCM_PDR0_MCU_PODF_OFFSET 0 91#define MXC_CCM_PDR0_MCU_PODF_OFFSET 0
92#define MXC_CCM_PDR0_MCU_PODF_MASK 0x7 92#define MXC_CCM_PDR0_MCU_PODF_MASK 0x7
93 93
94#define MXC_CCM_PDR0_HSP_DIV_1 (0x0 << 11)
95#define MXC_CCM_PDR0_HSP_DIV_2 (0x1 << 11)
96#define MXC_CCM_PDR0_HSP_DIV_3 (0x2 << 11)
97#define MXC_CCM_PDR0_HSP_DIV_4 (0x3 << 11)
98#define MXC_CCM_PDR0_HSP_DIV_5 (0x4 << 11)
99#define MXC_CCM_PDR0_HSP_DIV_6 (0x5 << 11)
100#define MXC_CCM_PDR0_HSP_DIV_7 (0x6 << 11)
101#define MXC_CCM_PDR0_HSP_DIV_8 (0x7 << 11)
102
103#define MXC_CCM_PDR0_IPG_DIV_1 (0x0 << 6)
104#define MXC_CCM_PDR0_IPG_DIV_2 (0x1 << 6)
105#define MXC_CCM_PDR0_IPG_DIV_3 (0x2 << 6)
106#define MXC_CCM_PDR0_IPG_DIV_4 (0x3 << 6)
107
108#define MXC_CCM_PDR0_MAX_DIV_1 (0x0 << 3)
109#define MXC_CCM_PDR0_MAX_DIV_2 (0x1 << 3)
110#define MXC_CCM_PDR0_MAX_DIV_3 (0x2 << 3)
111#define MXC_CCM_PDR0_MAX_DIV_4 (0x3 << 3)
112#define MXC_CCM_PDR0_MAX_DIV_5 (0x4 << 3)
113#define MXC_CCM_PDR0_MAX_DIV_6 (0x5 << 3)
114#define MXC_CCM_PDR0_MAX_DIV_7 (0x6 << 3)
115#define MXC_CCM_PDR0_MAX_DIV_8 (0x7 << 3)
116
117#define MXC_CCM_PDR0_NFC_DIV_1 (0x0 << 8)
118#define MXC_CCM_PDR0_NFC_DIV_2 (0x1 << 8)
119#define MXC_CCM_PDR0_NFC_DIV_3 (0x2 << 8)
120#define MXC_CCM_PDR0_NFC_DIV_4 (0x3 << 8)
121#define MXC_CCM_PDR0_NFC_DIV_5 (0x4 << 8)
122#define MXC_CCM_PDR0_NFC_DIV_6 (0x5 << 8)
123#define MXC_CCM_PDR0_NFC_DIV_7 (0x6 << 8)
124#define MXC_CCM_PDR0_NFC_DIV_8 (0x7 << 8)
125
126#define MXC_CCM_PDR0_MCU_DIV_1 0x0
127#define MXC_CCM_PDR0_MCU_DIV_2 0x1
128#define MXC_CCM_PDR0_MCU_DIV_3 0x2
129#define MXC_CCM_PDR0_MCU_DIV_4 0x3
130#define MXC_CCM_PDR0_MCU_DIV_5 0x4
131#define MXC_CCM_PDR0_MCU_DIV_6 0x5
132#define MXC_CCM_PDR0_MCU_DIV_7 0x6
133#define MXC_CCM_PDR0_MCU_DIV_8 0x7
134
135#define MXC_CCM_PDR1_USB_PRDF_OFFSET 30 94#define MXC_CCM_PDR1_USB_PRDF_OFFSET 30
136#define MXC_CCM_PDR1_USB_PRDF_MASK (0x3 << 30) 95#define MXC_CCM_PDR1_USB_PRDF_MASK (0x3 << 30)
137#define MXC_CCM_PDR1_USB_PODF_OFFSET 27 96#define MXC_CCM_PDR1_USB_PODF_OFFSET 27
@@ -152,118 +111,6 @@
152/* Bit definitions for RCSR */ 111/* Bit definitions for RCSR */
153#define MXC_CCM_RCSR_NF16B 0x80000000 112#define MXC_CCM_RCSR_NF16B 0x80000000
154 113
155/* Bit definitions for both MCU, USB and SR PLL control registers */
156#define MXC_CCM_PCTL_BRM 0x80000000
157#define MXC_CCM_PCTL_PD_OFFSET 26
158#define MXC_CCM_PCTL_PD_MASK (0xF << 26)
159#define MXC_CCM_PCTL_MFD_OFFSET 16
160#define MXC_CCM_PCTL_MFD_MASK (0x3FF << 16)
161#define MXC_CCM_PCTL_MFI_OFFSET 10
162#define MXC_CCM_PCTL_MFI_MASK (0xF << 10)
163#define MXC_CCM_PCTL_MFN_OFFSET 0
164#define MXC_CCM_PCTL_MFN_MASK 0x3FF
165
166#define MXC_CCM_CGR0_SD_MMC1_OFFSET 0
167#define MXC_CCM_CGR0_SD_MMC1_MASK (0x3 << 0)
168#define MXC_CCM_CGR0_SD_MMC2_OFFSET 2
169#define MXC_CCM_CGR0_SD_MMC2_MASK (0x3 << 2)
170#define MXC_CCM_CGR0_GPT_OFFSET 4
171#define MXC_CCM_CGR0_GPT_MASK (0x3 << 4)
172#define MXC_CCM_CGR0_EPIT1_OFFSET 6
173#define MXC_CCM_CGR0_EPIT1_MASK (0x3 << 6)
174#define MXC_CCM_CGR0_EPIT2_OFFSET 8
175#define MXC_CCM_CGR0_EPIT2_MASK (0x3 << 8)
176#define MXC_CCM_CGR0_IIM_OFFSET 10
177#define MXC_CCM_CGR0_IIM_MASK (0x3 << 10)
178#define MXC_CCM_CGR0_ATA_OFFSET 12
179#define MXC_CCM_CGR0_ATA_MASK (0x3 << 12)
180#define MXC_CCM_CGR0_SDMA_OFFSET 14
181#define MXC_CCM_CGR0_SDMA_MASK (0x3 << 14)
182#define MXC_CCM_CGR0_CSPI3_OFFSET 16
183#define MXC_CCM_CGR0_CSPI3_MASK (0x3 << 16)
184#define MXC_CCM_CGR0_RNG_OFFSET 18
185#define MXC_CCM_CGR0_RNG_MASK (0x3 << 18)
186#define MXC_CCM_CGR0_UART1_OFFSET 20
187#define MXC_CCM_CGR0_UART1_MASK (0x3 << 20)
188#define MXC_CCM_CGR0_UART2_OFFSET 22
189#define MXC_CCM_CGR0_UART2_MASK (0x3 << 22)
190#define MXC_CCM_CGR0_SSI1_OFFSET 24
191#define MXC_CCM_CGR0_SSI1_MASK (0x3 << 24)
192#define MXC_CCM_CGR0_I2C1_OFFSET 26
193#define MXC_CCM_CGR0_I2C1_MASK (0x3 << 26)
194#define MXC_CCM_CGR0_I2C2_OFFSET 28
195#define MXC_CCM_CGR0_I2C2_MASK (0x3 << 28)
196#define MXC_CCM_CGR0_I2C3_OFFSET 30
197#define MXC_CCM_CGR0_I2C3_MASK (0x3 << 30)
198
199#define MXC_CCM_CGR1_HANTRO_OFFSET 0
200#define MXC_CCM_CGR1_HANTRO_MASK (0x3 << 0)
201#define MXC_CCM_CGR1_MEMSTICK1_OFFSET 2
202#define MXC_CCM_CGR1_MEMSTICK1_MASK (0x3 << 2)
203#define MXC_CCM_CGR1_MEMSTICK2_OFFSET 4
204#define MXC_CCM_CGR1_MEMSTICK2_MASK (0x3 << 4)
205#define MXC_CCM_CGR1_CSI_OFFSET 6
206#define MXC_CCM_CGR1_CSI_MASK (0x3 << 6)
207#define MXC_CCM_CGR1_RTC_OFFSET 8
208#define MXC_CCM_CGR1_RTC_MASK (0x3 << 8)
209#define MXC_CCM_CGR1_WDOG_OFFSET 10
210#define MXC_CCM_CGR1_WDOG_MASK (0x3 << 10)
211#define MXC_CCM_CGR1_PWM_OFFSET 12
212#define MXC_CCM_CGR1_PWM_MASK (0x3 << 12)
213#define MXC_CCM_CGR1_SIM_OFFSET 14
214#define MXC_CCM_CGR1_SIM_MASK (0x3 << 14)
215#define MXC_CCM_CGR1_ECT_OFFSET 16
216#define MXC_CCM_CGR1_ECT_MASK (0x3 << 16)
217#define MXC_CCM_CGR1_USBOTG_OFFSET 18
218#define MXC_CCM_CGR1_USBOTG_MASK (0x3 << 18)
219#define MXC_CCM_CGR1_KPP_OFFSET 20
220#define MXC_CCM_CGR1_KPP_MASK (0x3 << 20)
221#define MXC_CCM_CGR1_IPU_OFFSET 22
222#define MXC_CCM_CGR1_IPU_MASK (0x3 << 22)
223#define MXC_CCM_CGR1_UART3_OFFSET 24
224#define MXC_CCM_CGR1_UART3_MASK (0x3 << 24)
225#define MXC_CCM_CGR1_UART4_OFFSET 26
226#define MXC_CCM_CGR1_UART4_MASK (0x3 << 26)
227#define MXC_CCM_CGR1_UART5_OFFSET 28
228#define MXC_CCM_CGR1_UART5_MASK (0x3 << 28)
229#define MXC_CCM_CGR1_OWIRE_OFFSET 30
230#define MXC_CCM_CGR1_OWIRE_MASK (0x3 << 30)
231
232#define MXC_CCM_CGR2_SSI2_OFFSET 0
233#define MXC_CCM_CGR2_SSI2_MASK (0x3 << 0)
234#define MXC_CCM_CGR2_CSPI1_OFFSET 2
235#define MXC_CCM_CGR2_CSPI1_MASK (0x3 << 2)
236#define MXC_CCM_CGR2_CSPI2_OFFSET 4
237#define MXC_CCM_CGR2_CSPI2_MASK (0x3 << 4)
238#define MXC_CCM_CGR2_GACC_OFFSET 6
239#define MXC_CCM_CGR2_GACC_MASK (0x3 << 6)
240#define MXC_CCM_CGR2_EMI_OFFSET 8
241#define MXC_CCM_CGR2_EMI_MASK (0x3 << 8)
242#define MXC_CCM_CGR2_RTIC_OFFSET 10
243#define MXC_CCM_CGR2_RTIC_MASK (0x3 << 10)
244#define MXC_CCM_CGR2_FIRI_OFFSET 12
245#define MXC_CCM_CGR2_FIRI_MASK (0x3 << 12)
246#define MXC_CCM_CGR2_IPMUX1_OFFSET 14
247#define MXC_CCM_CGR2_IPMUX1_MASK (0x3 << 14)
248#define MXC_CCM_CGR2_IPMUX2_OFFSET 16
249#define MXC_CCM_CGR2_IPMUX2_MASK (0x3 << 16)
250
251/* These new CGR2 bits are added in MX32 */
252#define MXC_CCM_CGR2_APMSYSCLKSEL_OFFSET 18
253#define MXC_CCM_CGR2_APMSYSCLKSEL_MASK (0x3 << 18)
254#define MXC_CCM_CGR2_APMSSICLKSEL_OFFSET 20
255#define MXC_CCM_CGR2_APMSSICLKSEL_MASK (0x3 << 20)
256#define MXC_CCM_CGR2_APMPERCLKSEL_OFFSET 22
257#define MXC_CCM_CGR2_APMPERCLKSEL_MASK (0x3 << 22)
258#define MXC_CCM_CGR2_MXCCLKENSEL_OFFSET 24
259#define MXC_CCM_CGR2_MXCCLKENSEL_MASK (0x1 << 24)
260#define MXC_CCM_CGR2_CHIKCAMPEN_OFFSET 25
261#define MXC_CCM_CGR2_CHIKCAMPEN_MASK (0x1 << 25)
262#define MXC_CCM_CGR2_OVRVPUBUSY_OFFSET 26
263#define MXC_CCM_CGR2_OVRVPUBUSY_MASK (0x1 << 26)
264#define MXC_CCM_CGR2_APMENA_OFFSET 30
265#define MXC_CCM_CGR2_AOMENA_MASK (0x1 << 30)
266
267/* 114/*
268 * LTR0 register offsets 115 * LTR0 register offsets
269 */ 116 */
diff --git a/arch/arm/mach-mx3/devices.c b/arch/arm/mach-mx3/devices.c
index f8428800f286..380be0c9b213 100644
--- a/arch/arm/mach-mx3/devices.c
+++ b/arch/arm/mach-mx3/devices.c
@@ -25,6 +25,8 @@
25#include <mach/irqs.h> 25#include <mach/irqs.h>
26#include <mach/imx-uart.h> 26#include <mach/imx-uart.h>
27 27
28#include "devices.h"
29
28static struct resource uart0[] = { 30static struct resource uart0[] = {
29 { 31 {
30 .start = UART1_BASE_ADDR, 32 .start = UART1_BASE_ADDR,
@@ -82,6 +84,7 @@ struct platform_device mxc_uart_device2 = {
82 .num_resources = ARRAY_SIZE(uart2), 84 .num_resources = ARRAY_SIZE(uart2),
83}; 85};
84 86
87#ifdef CONFIG_ARCH_MX31
85static struct resource uart3[] = { 88static struct resource uart3[] = {
86 { 89 {
87 .start = UART4_BASE_ADDR, 90 .start = UART4_BASE_ADDR,
@@ -119,6 +122,7 @@ struct platform_device mxc_uart_device4 = {
119 .resource = uart4, 122 .resource = uart4,
120 .num_resources = ARRAY_SIZE(uart4), 123 .num_resources = ARRAY_SIZE(uart4),
121}; 124};
125#endif /* CONFIG_ARCH_MX31 */
122 126
123/* GPIO port description */ 127/* GPIO port description */
124static struct mxc_gpio_port imx_gpio_ports[] = { 128static struct mxc_gpio_port imx_gpio_ports[] = {
@@ -164,8 +168,8 @@ struct platform_device mxc_w1_master_device = {
164 168
165static struct resource mxc_nand_resources[] = { 169static struct resource mxc_nand_resources[] = {
166 { 170 {
167 .start = NFC_BASE_ADDR, 171 .start = 0, /* runtime dependent */
168 .end = NFC_BASE_ADDR + 0xfff, 172 .end = 0,
169 .flags = IORESOURCE_MEM 173 .flags = IORESOURCE_MEM
170 }, { 174 }, {
171 .start = MXC_INT_NANDFC, 175 .start = MXC_INT_NANDFC,
@@ -180,3 +184,188 @@ struct platform_device mxc_nand_device = {
180 .num_resources = ARRAY_SIZE(mxc_nand_resources), 184 .num_resources = ARRAY_SIZE(mxc_nand_resources),
181 .resource = mxc_nand_resources, 185 .resource = mxc_nand_resources,
182}; 186};
187
188static struct resource mxc_i2c0_resources[] = {
189 {
190 .start = I2C_BASE_ADDR,
191 .end = I2C_BASE_ADDR + SZ_4K - 1,
192 .flags = IORESOURCE_MEM,
193 },
194 {
195 .start = MXC_INT_I2C,
196 .end = MXC_INT_I2C,
197 .flags = IORESOURCE_IRQ,
198 },
199};
200
201struct platform_device mxc_i2c_device0 = {
202 .name = "imx-i2c",
203 .id = 0,
204 .num_resources = ARRAY_SIZE(mxc_i2c0_resources),
205 .resource = mxc_i2c0_resources,
206};
207
208static struct resource mxc_i2c1_resources[] = {
209 {
210 .start = I2C2_BASE_ADDR,
211 .end = I2C2_BASE_ADDR + SZ_4K - 1,
212 .flags = IORESOURCE_MEM,
213 },
214 {
215 .start = MXC_INT_I2C2,
216 .end = MXC_INT_I2C2,
217 .flags = IORESOURCE_IRQ,
218 },
219};
220
221struct platform_device mxc_i2c_device1 = {
222 .name = "imx-i2c",
223 .id = 1,
224 .num_resources = ARRAY_SIZE(mxc_i2c1_resources),
225 .resource = mxc_i2c1_resources,
226};
227
228static struct resource mxc_i2c2_resources[] = {
229 {
230 .start = I2C3_BASE_ADDR,
231 .end = I2C3_BASE_ADDR + SZ_4K - 1,
232 .flags = IORESOURCE_MEM,
233 },
234 {
235 .start = MXC_INT_I2C3,
236 .end = MXC_INT_I2C3,
237 .flags = IORESOURCE_IRQ,
238 },
239};
240
241struct platform_device mxc_i2c_device2 = {
242 .name = "imx-i2c",
243 .id = 2,
244 .num_resources = ARRAY_SIZE(mxc_i2c2_resources),
245 .resource = mxc_i2c2_resources,
246};
247
248#ifdef CONFIG_ARCH_MX31
249static struct resource mxcsdhc0_resources[] = {
250 {
251 .start = MMC_SDHC1_BASE_ADDR,
252 .end = MMC_SDHC1_BASE_ADDR + SZ_16K - 1,
253 .flags = IORESOURCE_MEM,
254 }, {
255 .start = MXC_INT_MMC_SDHC1,
256 .end = MXC_INT_MMC_SDHC1,
257 .flags = IORESOURCE_IRQ,
258 },
259};
260
261static struct resource mxcsdhc1_resources[] = {
262 {
263 .start = MMC_SDHC2_BASE_ADDR,
264 .end = MMC_SDHC2_BASE_ADDR + SZ_16K - 1,
265 .flags = IORESOURCE_MEM,
266 }, {
267 .start = MXC_INT_MMC_SDHC2,
268 .end = MXC_INT_MMC_SDHC2,
269 .flags = IORESOURCE_IRQ,
270 },
271};
272
273struct platform_device mxcsdhc_device0 = {
274 .name = "mxc-mmc",
275 .id = 0,
276 .num_resources = ARRAY_SIZE(mxcsdhc0_resources),
277 .resource = mxcsdhc0_resources,
278};
279
280struct platform_device mxcsdhc_device1 = {
281 .name = "mxc-mmc",
282 .id = 1,
283 .num_resources = ARRAY_SIZE(mxcsdhc1_resources),
284 .resource = mxcsdhc1_resources,
285};
286#endif /* CONFIG_ARCH_MX31 */
287
288/* i.MX31 Image Processing Unit */
289
290/* The resource order is important! */
291static struct resource mx3_ipu_rsrc[] = {
292 {
293 .start = IPU_CTRL_BASE_ADDR,
294 .end = IPU_CTRL_BASE_ADDR + 0x5F,
295 .flags = IORESOURCE_MEM,
296 }, {
297 .start = IPU_CTRL_BASE_ADDR + 0x88,
298 .end = IPU_CTRL_BASE_ADDR + 0xB3,
299 .flags = IORESOURCE_MEM,
300 }, {
301 .start = MXC_INT_IPU_SYN,
302 .end = MXC_INT_IPU_SYN,
303 .flags = IORESOURCE_IRQ,
304 }, {
305 .start = MXC_INT_IPU_ERR,
306 .end = MXC_INT_IPU_ERR,
307 .flags = IORESOURCE_IRQ,
308 },
309};
310
311struct platform_device mx3_ipu = {
312 .name = "ipu-core",
313 .id = -1,
314 .num_resources = ARRAY_SIZE(mx3_ipu_rsrc),
315 .resource = mx3_ipu_rsrc,
316};
317
318static struct resource fb_resources[] = {
319 {
320 .start = IPU_CTRL_BASE_ADDR + 0xB4,
321 .end = IPU_CTRL_BASE_ADDR + 0x1BF,
322 .flags = IORESOURCE_MEM,
323 },
324};
325
326struct platform_device mx3_fb = {
327 .name = "mx3_sdc_fb",
328 .id = -1,
329 .num_resources = ARRAY_SIZE(fb_resources),
330 .resource = fb_resources,
331 .dev = {
332 .coherent_dma_mask = 0xffffffff,
333 },
334};
335
336#ifdef CONFIG_ARCH_MX35
337static struct resource mxc_fec_resources[] = {
338 {
339 .start = MXC_FEC_BASE_ADDR,
340 .end = MXC_FEC_BASE_ADDR + 0xfff,
341 .flags = IORESOURCE_MEM
342 }, {
343 .start = MXC_INT_FEC,
344 .end = MXC_INT_FEC,
345 .flags = IORESOURCE_IRQ
346 },
347};
348
349struct platform_device mxc_fec_device = {
350 .name = "fec",
351 .id = 0,
352 .num_resources = ARRAY_SIZE(mxc_fec_resources),
353 .resource = mxc_fec_resources,
354};
355#endif
356
357static int mx3_devices_init(void)
358{
359 if (cpu_is_mx31()) {
360 mxc_nand_resources[0].start = MX31_NFC_BASE_ADDR;
361 mxc_nand_resources[0].end = MX31_NFC_BASE_ADDR + 0xfff;
362 }
363 if (cpu_is_mx35()) {
364 mxc_nand_resources[0].start = MX35_NFC_BASE_ADDR;
365 mxc_nand_resources[0].end = MX35_NFC_BASE_ADDR + 0xfff;
366 }
367
368 return 0;
369}
370
371subsys_initcall(mx3_devices_init);
diff --git a/arch/arm/mach-mx3/devices.h b/arch/arm/mach-mx3/devices.h
index 9949ef4e0694..88c04b296fab 100644
--- a/arch/arm/mach-mx3/devices.h
+++ b/arch/arm/mach-mx3/devices.h
@@ -6,3 +6,11 @@ extern struct platform_device mxc_uart_device3;
6extern struct platform_device mxc_uart_device4; 6extern struct platform_device mxc_uart_device4;
7extern struct platform_device mxc_w1_master_device; 7extern struct platform_device mxc_w1_master_device;
8extern struct platform_device mxc_nand_device; 8extern struct platform_device mxc_nand_device;
9extern struct platform_device mxc_i2c_device0;
10extern struct platform_device mxc_i2c_device1;
11extern struct platform_device mxc_i2c_device2;
12extern struct platform_device mx3_ipu;
13extern struct platform_device mx3_fb;
14extern struct platform_device mxc_fec_device;
15extern struct platform_device mxcsdhc_device0;
16extern struct platform_device mxcsdhc_device1;
diff --git a/arch/arm/mach-mx3/iomux.c b/arch/arm/mach-mx3/iomux.c
index 7a5088b519a8..40ffc5a664d9 100644
--- a/arch/arm/mach-mx3/iomux.c
+++ b/arch/arm/mach-mx3/iomux.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * Copyright 2004-2006 Freescale Semiconductor, Inc. All Rights Reserved. 2 * Copyright 2004-2006 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de> 3 * Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de>
4 * Copyright (C) 2009 by Valentin Longchamp <valentin.longchamp@epfl.ch>
4 * 5 *
5 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
@@ -21,6 +22,7 @@
21#include <linux/spinlock.h> 22#include <linux/spinlock.h>
22#include <linux/io.h> 23#include <linux/io.h>
23#include <linux/gpio.h> 24#include <linux/gpio.h>
25#include <linux/kernel.h>
24#include <mach/hardware.h> 26#include <mach/hardware.h>
25#include <mach/gpio.h> 27#include <mach/gpio.h>
26#include <mach/iomux-mx3.h> 28#include <mach/iomux-mx3.h>
@@ -38,6 +40,8 @@
38static DEFINE_SPINLOCK(gpio_mux_lock); 40static DEFINE_SPINLOCK(gpio_mux_lock);
39 41
40#define IOMUX_REG_MASK (IOMUX_PADNUM_MASK & ~0x3) 42#define IOMUX_REG_MASK (IOMUX_PADNUM_MASK & ~0x3)
43
44unsigned long mxc_pin_alloc_map[NB_PORTS * 32 / BITS_PER_LONG];
41/* 45/*
42 * set the mode for a IOMUX pin. 46 * set the mode for a IOMUX pin.
43 */ 47 */
@@ -50,9 +54,6 @@ int mxc_iomux_mode(unsigned int pin_mode)
50 field = pin_mode & 0x3; 54 field = pin_mode & 0x3;
51 mode = (pin_mode & IOMUX_MODE_MASK) >> IOMUX_MODE_SHIFT; 55 mode = (pin_mode & IOMUX_MODE_MASK) >> IOMUX_MODE_SHIFT;
52 56
53 pr_debug("%s: reg offset = 0x%x field = %d mode = 0x%02x\n",
54 __func__, (pin_mode & IOMUX_REG_MASK), field, mode);
55
56 spin_lock(&gpio_mux_lock); 57 spin_lock(&gpio_mux_lock);
57 58
58 l = __raw_readl(reg); 59 l = __raw_readl(reg);
@@ -93,6 +94,86 @@ void mxc_iomux_set_pad(enum iomux_pins pin, u32 config)
93EXPORT_SYMBOL(mxc_iomux_set_pad); 94EXPORT_SYMBOL(mxc_iomux_set_pad);
94 95
95/* 96/*
97 * setups a single pin:
98 * - reserves the pin so that it is not claimed by another driver
99 * - setups the iomux according to the configuration
100 * - if the pin is configured as a GPIO, we claim it through kernel gpiolib
101 */
102int mxc_iomux_setup_pin(const unsigned int pin, const char *label)
103{
104 unsigned pad = pin & IOMUX_PADNUM_MASK;
105 unsigned gpio;
106
107 if (pad >= (PIN_MAX + 1)) {
108 printk(KERN_ERR "mxc_iomux: Attempt to request nonexistant pin %u for \"%s\"\n",
109 pad, label ? label : "?");
110 return -EINVAL;
111 }
112
113 if (test_and_set_bit(pad, mxc_pin_alloc_map)) {
114 printk(KERN_ERR "mxc_iomux: pin %u already used. Allocation for \"%s\" failed\n",
115 pad, label ? label : "?");
116 return -EINVAL;
117 }
118 mxc_iomux_mode(pin);
119
120 /* if we have a gpio, we can allocate it */
121 gpio = (pin & IOMUX_GPIONUM_MASK) >> IOMUX_GPIONUM_SHIFT;
122 if (gpio < (GPIO_PORT_MAX + 1) * 32)
123 if (gpio_request(gpio, label))
124 return -EINVAL;
125
126 return 0;
127}
128EXPORT_SYMBOL(mxc_iomux_setup_pin);
129
130int mxc_iomux_setup_multiple_pins(unsigned int *pin_list, unsigned count,
131 const char *label)
132{
133 unsigned int *p = pin_list;
134 int i;
135 int ret = -EINVAL;
136
137 for (i = 0; i < count; i++) {
138 if (mxc_iomux_setup_pin(*p, label))
139 goto setup_error;
140 p++;
141 }
142 return 0;
143
144setup_error:
145 mxc_iomux_release_multiple_pins(pin_list, i);
146 return ret;
147}
148EXPORT_SYMBOL(mxc_iomux_setup_multiple_pins);
149
150void mxc_iomux_release_pin(const unsigned int pin)
151{
152 unsigned pad = pin & IOMUX_PADNUM_MASK;
153 unsigned gpio;
154
155 if (pad < (PIN_MAX + 1))
156 clear_bit(pad, mxc_pin_alloc_map);
157
158 gpio = (pin & IOMUX_GPIONUM_MASK) >> IOMUX_GPIONUM_SHIFT;
159 if (gpio < (GPIO_PORT_MAX + 1) * 32)
160 gpio_free(gpio);
161}
162EXPORT_SYMBOL(mxc_iomux_release_pin);
163
164void mxc_iomux_release_multiple_pins(unsigned int *pin_list, int count)
165{
166 unsigned int *p = pin_list;
167 int i;
168
169 for (i = 0; i < count; i++) {
170 mxc_iomux_release_pin(*p);
171 p++;
172 }
173}
174EXPORT_SYMBOL(mxc_iomux_release_multiple_pins);
175
176/*
96 * This function enables/disables the general purpose function for a particular 177 * This function enables/disables the general purpose function for a particular
97 * signal. 178 * signal.
98 */ 179 */
@@ -111,4 +192,3 @@ void mxc_iomux_set_gpr(enum iomux_gp_func gp, bool en)
111 spin_unlock(&gpio_mux_lock); 192 spin_unlock(&gpio_mux_lock);
112} 193}
113EXPORT_SYMBOL(mxc_iomux_set_gpr); 194EXPORT_SYMBOL(mxc_iomux_set_gpr);
114
diff --git a/arch/arm/mach-mx3/mm.c b/arch/arm/mach-mx3/mm.c
index 0589b5cd33c7..9e1459cb4b74 100644
--- a/arch/arm/mach-mx3/mm.c
+++ b/arch/arm/mach-mx3/mm.c
@@ -22,10 +22,14 @@
22 22
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <mach/hardware.h> 25#include <linux/err.h>
26
26#include <asm/pgtable.h> 27#include <asm/pgtable.h>
27#include <asm/mach/map.h> 28#include <asm/mach/map.h>
29#include <asm/hardware/cache-l2x0.h>
30
28#include <mach/common.h> 31#include <mach/common.h>
32#include <mach/hardware.h>
29 33
30/*! 34/*!
31 * @file mm.c 35 * @file mm.c
@@ -50,6 +54,16 @@ static struct map_desc mxc_io_desc[] __initdata = {
50 .pfn = __phys_to_pfn(AVIC_BASE_ADDR), 54 .pfn = __phys_to_pfn(AVIC_BASE_ADDR),
51 .length = AVIC_SIZE, 55 .length = AVIC_SIZE,
52 .type = MT_DEVICE_NONSHARED 56 .type = MT_DEVICE_NONSHARED
57 }, {
58 .virtual = AIPS1_BASE_ADDR_VIRT,
59 .pfn = __phys_to_pfn(AIPS1_BASE_ADDR),
60 .length = AIPS1_SIZE,
61 .type = MT_DEVICE_NONSHARED
62 }, {
63 .virtual = AIPS2_BASE_ADDR_VIRT,
64 .pfn = __phys_to_pfn(AIPS2_BASE_ADDR),
65 .length = AIPS2_SIZE,
66 .type = MT_DEVICE_NONSHARED
53 }, 67 },
54}; 68};
55 69
@@ -62,3 +76,24 @@ void __init mxc_map_io(void)
62{ 76{
63 iotable_init(mxc_io_desc, ARRAY_SIZE(mxc_io_desc)); 77 iotable_init(mxc_io_desc, ARRAY_SIZE(mxc_io_desc));
64} 78}
79
80#ifdef CONFIG_CACHE_L2X0
81static int mxc_init_l2x0(void)
82{
83 void __iomem *l2x0_base;
84
85 l2x0_base = ioremap(L2CC_BASE_ADDR, 4096);
86 if (IS_ERR(l2x0_base)) {
87 printk(KERN_ERR "remapping L2 cache area failed with %ld\n",
88 PTR_ERR(l2x0_base));
89 return 0;
90 }
91
92 l2x0_init(l2x0_base, 0x00030024, 0x00000000);
93
94 return 0;
95}
96
97arch_initcall(mxc_init_l2x0);
98#endif
99
diff --git a/arch/arm/mach-mx3/mx31ads.c b/arch/arm/mach-mx3/mx31ads.c
index f902a7c37c31..83e5e8e1276f 100644
--- a/arch/arm/mach-mx3/mx31ads.c
+++ b/arch/arm/mach-mx3/mx31ads.c
@@ -22,6 +22,8 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/clk.h> 23#include <linux/clk.h>
24#include <linux/serial_8250.h> 24#include <linux/serial_8250.h>
25#include <linux/gpio.h>
26#include <linux/i2c.h>
25#include <linux/irq.h> 27#include <linux/irq.h>
26 28
27#include <mach/hardware.h> 29#include <mach/hardware.h>
@@ -35,6 +37,12 @@
35#include <mach/imx-uart.h> 37#include <mach/imx-uart.h>
36#include <mach/iomux-mx3.h> 38#include <mach/iomux-mx3.h>
37 39
40#ifdef CONFIG_MACH_MX31ADS_WM1133_EV1
41#include <linux/mfd/wm8350/audio.h>
42#include <linux/mfd/wm8350/core.h>
43#include <linux/mfd/wm8350/pmic.h>
44#endif
45
38#include "devices.h" 46#include "devices.h"
39 47
40/*! 48/*!
@@ -94,13 +102,16 @@ static struct imxuart_platform_data uart_pdata = {
94 .flags = IMXUART_HAVE_RTSCTS, 102 .flags = IMXUART_HAVE_RTSCTS,
95}; 103};
96 104
105static int uart_pins[] = {
106 MX31_PIN_CTS1__CTS1,
107 MX31_PIN_RTS1__RTS1,
108 MX31_PIN_TXD1__TXD1,
109 MX31_PIN_RXD1__RXD1
110};
111
97static inline void mxc_init_imx_uart(void) 112static inline void mxc_init_imx_uart(void)
98{ 113{
99 mxc_iomux_mode(MX31_PIN_CTS1__CTS1); 114 mxc_iomux_setup_multiple_pins(uart_pins, ARRAY_SIZE(uart_pins), "uart-0");
100 mxc_iomux_mode(MX31_PIN_RTS1__RTS1);
101 mxc_iomux_mode(MX31_PIN_TXD1__TXD1);
102 mxc_iomux_mode(MX31_PIN_RXD1__RXD1);
103
104 mxc_register_device(&mxc_uart_device0, &uart_pdata); 115 mxc_register_device(&mxc_uart_device0, &uart_pdata);
105} 116}
106#else /* !SERIAL_IMX */ 117#else /* !SERIAL_IMX */
@@ -176,7 +187,7 @@ static void __init mx31ads_init_expio(void)
176 /* 187 /*
177 * Configure INT line as GPIO input 188 * Configure INT line as GPIO input
178 */ 189 */
179 mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_4, IOMUX_CONFIG_GPIO)); 190 mxc_iomux_setup_pin(IOMUX_MODE(MX31_PIN_GPIO1_4, IOMUX_CONFIG_GPIO), "expio");
180 191
181 /* disable the interrupt and clear the status */ 192 /* disable the interrupt and clear the status */
182 __raw_writew(0xFFFF, PBC_INTMASK_CLEAR_REG); 193 __raw_writew(0xFFFF, PBC_INTMASK_CLEAR_REG);
@@ -191,26 +202,301 @@ static void __init mx31ads_init_expio(void)
191 set_irq_chained_handler(EXPIO_PARENT_INT, mx31ads_expio_irq_handler); 202 set_irq_chained_handler(EXPIO_PARENT_INT, mx31ads_expio_irq_handler);
192} 203}
193 204
205#ifdef CONFIG_MACH_MX31ADS_WM1133_EV1
206/* This section defines setup for the Wolfson Microelectronics
207 * 1133-EV1 PMU/audio board. When other PMU boards are supported the
208 * regulator definitions may be shared with them, but for now they can
209 * only be used with this board so would generate warnings about
210 * unused statics and some of the configuration is specific to this
211 * module.
212 */
213
214/* CPU */
215static struct regulator_consumer_supply sw1a_consumers[] = {
216 {
217 .supply = "cpu_vcc",
218 }
219};
220
221static struct regulator_init_data sw1a_data = {
222 .constraints = {
223 .name = "SW1A",
224 .min_uV = 1275000,
225 .max_uV = 1600000,
226 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
227 REGULATOR_CHANGE_MODE,
228 .valid_modes_mask = REGULATOR_MODE_NORMAL |
229 REGULATOR_MODE_FAST,
230 .state_mem = {
231 .uV = 1400000,
232 .mode = REGULATOR_MODE_NORMAL,
233 .enabled = 1,
234 },
235 .initial_state = PM_SUSPEND_MEM,
236 .always_on = 1,
237 .boot_on = 1,
238 },
239 .num_consumer_supplies = ARRAY_SIZE(sw1a_consumers),
240 .consumer_supplies = sw1a_consumers,
241};
242
243/* System IO - High */
244static struct regulator_init_data viohi_data = {
245 .constraints = {
246 .name = "VIOHO",
247 .min_uV = 2800000,
248 .max_uV = 2800000,
249 .state_mem = {
250 .uV = 2800000,
251 .mode = REGULATOR_MODE_NORMAL,
252 .enabled = 1,
253 },
254 .initial_state = PM_SUSPEND_MEM,
255 .always_on = 1,
256 .boot_on = 1,
257 },
258};
259
260/* System IO - Low */
261static struct regulator_init_data violo_data = {
262 .constraints = {
263 .name = "VIOLO",
264 .min_uV = 1800000,
265 .max_uV = 1800000,
266 .state_mem = {
267 .uV = 1800000,
268 .mode = REGULATOR_MODE_NORMAL,
269 .enabled = 1,
270 },
271 .initial_state = PM_SUSPEND_MEM,
272 .always_on = 1,
273 .boot_on = 1,
274 },
275};
276
277/* DDR RAM */
278static struct regulator_init_data sw2a_data = {
279 .constraints = {
280 .name = "SW2A",
281 .min_uV = 1800000,
282 .max_uV = 1800000,
283 .valid_modes_mask = REGULATOR_MODE_NORMAL,
284 .state_mem = {
285 .uV = 1800000,
286 .mode = REGULATOR_MODE_NORMAL,
287 .enabled = 1,
288 },
289 .state_disk = {
290 .mode = REGULATOR_MODE_NORMAL,
291 .enabled = 0,
292 },
293 .always_on = 1,
294 .boot_on = 1,
295 .initial_state = PM_SUSPEND_MEM,
296 },
297};
298
299static struct regulator_init_data ldo1_data = {
300 .constraints = {
301 .name = "VCAM/VMMC1/VMMC2",
302 .min_uV = 2800000,
303 .max_uV = 2800000,
304 .valid_modes_mask = REGULATOR_MODE_NORMAL,
305 .apply_uV = 1,
306 },
307};
308
309static struct regulator_consumer_supply ldo2_consumers[] = {
310 {
311 .supply = "AVDD",
312 },
313 {
314 .supply = "HPVDD",
315 },
316};
317
318/* CODEC and SIM */
319static struct regulator_init_data ldo2_data = {
320 .constraints = {
321 .name = "VESIM/VSIM/AVDD",
322 .min_uV = 3300000,
323 .max_uV = 3300000,
324 .valid_modes_mask = REGULATOR_MODE_NORMAL,
325 .apply_uV = 1,
326 },
327 .num_consumer_supplies = ARRAY_SIZE(ldo2_consumers),
328 .consumer_supplies = ldo2_consumers,
329};
330
331/* General */
332static struct regulator_init_data vdig_data = {
333 .constraints = {
334 .name = "VDIG",
335 .min_uV = 1500000,
336 .max_uV = 1500000,
337 .valid_modes_mask = REGULATOR_MODE_NORMAL,
338 .apply_uV = 1,
339 .always_on = 1,
340 .boot_on = 1,
341 },
342};
343
344/* Tranceivers */
345static struct regulator_init_data ldo4_data = {
346 .constraints = {
347 .name = "VRF1/CVDD_2.775",
348 .min_uV = 2500000,
349 .max_uV = 2500000,
350 .valid_modes_mask = REGULATOR_MODE_NORMAL,
351 .apply_uV = 1,
352 .always_on = 1,
353 .boot_on = 1,
354 },
355};
356
357static struct wm8350_led_platform_data wm8350_led_data = {
358 .name = "wm8350:white",
359 .default_trigger = "heartbeat",
360 .max_uA = 27899,
361};
362
363static struct wm8350_audio_platform_data imx32ads_wm8350_setup = {
364 .vmid_discharge_msecs = 1000,
365 .drain_msecs = 30,
366 .cap_discharge_msecs = 700,
367 .vmid_charge_msecs = 700,
368 .vmid_s_curve = WM8350_S_CURVE_SLOW,
369 .dis_out4 = WM8350_DISCHARGE_SLOW,
370 .dis_out3 = WM8350_DISCHARGE_SLOW,
371 .dis_out2 = WM8350_DISCHARGE_SLOW,
372 .dis_out1 = WM8350_DISCHARGE_SLOW,
373 .vroi_out4 = WM8350_TIE_OFF_500R,
374 .vroi_out3 = WM8350_TIE_OFF_500R,
375 .vroi_out2 = WM8350_TIE_OFF_500R,
376 .vroi_out1 = WM8350_TIE_OFF_500R,
377 .vroi_enable = 0,
378 .codec_current_on = WM8350_CODEC_ISEL_1_0,
379 .codec_current_standby = WM8350_CODEC_ISEL_0_5,
380 .codec_current_charge = WM8350_CODEC_ISEL_1_5,
381};
382
383static int mx31_wm8350_init(struct wm8350 *wm8350)
384{
385 int i;
386
387 wm8350_gpio_config(wm8350, 0, WM8350_GPIO_DIR_IN,
388 WM8350_GPIO0_PWR_ON_IN, WM8350_GPIO_ACTIVE_LOW,
389 WM8350_GPIO_PULL_UP, WM8350_GPIO_INVERT_OFF,
390 WM8350_GPIO_DEBOUNCE_ON);
391
392 wm8350_gpio_config(wm8350, 3, WM8350_GPIO_DIR_IN,
393 WM8350_GPIO3_PWR_OFF_IN, WM8350_GPIO_ACTIVE_HIGH,
394 WM8350_GPIO_PULL_DOWN, WM8350_GPIO_INVERT_OFF,
395 WM8350_GPIO_DEBOUNCE_ON);
396
397 wm8350_gpio_config(wm8350, 4, WM8350_GPIO_DIR_IN,
398 WM8350_GPIO4_MR_IN, WM8350_GPIO_ACTIVE_HIGH,
399 WM8350_GPIO_PULL_DOWN, WM8350_GPIO_INVERT_OFF,
400 WM8350_GPIO_DEBOUNCE_OFF);
401
402 wm8350_gpio_config(wm8350, 7, WM8350_GPIO_DIR_IN,
403 WM8350_GPIO7_HIBERNATE_IN, WM8350_GPIO_ACTIVE_HIGH,
404 WM8350_GPIO_PULL_DOWN, WM8350_GPIO_INVERT_OFF,
405 WM8350_GPIO_DEBOUNCE_OFF);
406
407 wm8350_gpio_config(wm8350, 6, WM8350_GPIO_DIR_OUT,
408 WM8350_GPIO6_SDOUT_OUT, WM8350_GPIO_ACTIVE_HIGH,
409 WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,
410 WM8350_GPIO_DEBOUNCE_OFF);
411
412 wm8350_gpio_config(wm8350, 8, WM8350_GPIO_DIR_OUT,
413 WM8350_GPIO8_VCC_FAULT_OUT, WM8350_GPIO_ACTIVE_LOW,
414 WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,
415 WM8350_GPIO_DEBOUNCE_OFF);
416
417 wm8350_gpio_config(wm8350, 9, WM8350_GPIO_DIR_OUT,
418 WM8350_GPIO9_BATT_FAULT_OUT, WM8350_GPIO_ACTIVE_LOW,
419 WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,
420 WM8350_GPIO_DEBOUNCE_OFF);
421
422 /* Fix up for our own supplies. */
423 for (i = 0; i < ARRAY_SIZE(ldo2_consumers); i++)
424 ldo2_consumers[i].dev = wm8350->dev;
425
426 wm8350_register_regulator(wm8350, WM8350_DCDC_1, &sw1a_data);
427 wm8350_register_regulator(wm8350, WM8350_DCDC_3, &viohi_data);
428 wm8350_register_regulator(wm8350, WM8350_DCDC_4, &violo_data);
429 wm8350_register_regulator(wm8350, WM8350_DCDC_6, &sw2a_data);
430 wm8350_register_regulator(wm8350, WM8350_LDO_1, &ldo1_data);
431 wm8350_register_regulator(wm8350, WM8350_LDO_2, &ldo2_data);
432 wm8350_register_regulator(wm8350, WM8350_LDO_3, &vdig_data);
433 wm8350_register_regulator(wm8350, WM8350_LDO_4, &ldo4_data);
434
435 /* LEDs */
436 wm8350_dcdc_set_slot(wm8350, WM8350_DCDC_5, 1, 1,
437 WM8350_DC5_ERRACT_SHUTDOWN_CONV);
438 wm8350_isink_set_flash(wm8350, WM8350_ISINK_A,
439 WM8350_ISINK_FLASH_DISABLE,
440 WM8350_ISINK_FLASH_TRIG_BIT,
441 WM8350_ISINK_FLASH_DUR_32MS,
442 WM8350_ISINK_FLASH_ON_INSTANT,
443 WM8350_ISINK_FLASH_OFF_INSTANT,
444 WM8350_ISINK_FLASH_MODE_EN);
445 wm8350_dcdc25_set_mode(wm8350, WM8350_DCDC_5,
446 WM8350_ISINK_MODE_BOOST,
447 WM8350_ISINK_ILIM_NORMAL,
448 WM8350_DC5_RMP_20V,
449 WM8350_DC5_FBSRC_ISINKA);
450 wm8350_register_led(wm8350, 0, WM8350_DCDC_5, WM8350_ISINK_A,
451 &wm8350_led_data);
452
453 wm8350->codec.platform_data = &imx32ads_wm8350_setup;
454
455 return 0;
456}
457
458static struct wm8350_platform_data __initdata mx31_wm8350_pdata = {
459 .init = mx31_wm8350_init,
460};
461#endif
462
463#if defined(CONFIG_I2C_IMX) || defined(CONFIG_I2C_IMX_MODULE)
464static struct i2c_board_info __initdata mx31ads_i2c1_devices[] = {
465#ifdef CONFIG_MACH_MX31ADS_WM1133_EV1
466 {
467 I2C_BOARD_INFO("wm8350", 0x1a),
468 .platform_data = &mx31_wm8350_pdata,
469 .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3),
470 },
471#endif
472};
473
474static void mxc_init_i2c(void)
475{
476 i2c_register_board_info(1, mx31ads_i2c1_devices,
477 ARRAY_SIZE(mx31ads_i2c1_devices));
478
479 mxc_iomux_mode(IOMUX_MODE(MX31_PIN_CSPI2_MOSI, IOMUX_CONFIG_ALT1));
480 mxc_iomux_mode(IOMUX_MODE(MX31_PIN_CSPI2_MISO, IOMUX_CONFIG_ALT1));
481
482 mxc_register_device(&mxc_i2c_device1, NULL);
483}
484#else
485static void mxc_init_i2c(void)
486{
487}
488#endif
489
194/*! 490/*!
195 * This structure defines static mappings for the i.MX31ADS board. 491 * This structure defines static mappings for the i.MX31ADS board.
196 */ 492 */
197static struct map_desc mx31ads_io_desc[] __initdata = { 493static struct map_desc mx31ads_io_desc[] __initdata = {
198 { 494 {
199 .virtual = AIPS1_BASE_ADDR_VIRT,
200 .pfn = __phys_to_pfn(AIPS1_BASE_ADDR),
201 .length = AIPS1_SIZE,
202 .type = MT_DEVICE_NONSHARED
203 }, {
204 .virtual = SPBA0_BASE_ADDR_VIRT, 495 .virtual = SPBA0_BASE_ADDR_VIRT,
205 .pfn = __phys_to_pfn(SPBA0_BASE_ADDR), 496 .pfn = __phys_to_pfn(SPBA0_BASE_ADDR),
206 .length = SPBA0_SIZE, 497 .length = SPBA0_SIZE,
207 .type = MT_DEVICE_NONSHARED 498 .type = MT_DEVICE_NONSHARED
208 }, { 499 }, {
209 .virtual = AIPS2_BASE_ADDR_VIRT,
210 .pfn = __phys_to_pfn(AIPS2_BASE_ADDR),
211 .length = AIPS2_SIZE,
212 .type = MT_DEVICE_NONSHARED
213 }, {
214 .virtual = CS4_BASE_ADDR_VIRT, 500 .virtual = CS4_BASE_ADDR_VIRT,
215 .pfn = __phys_to_pfn(CS4_BASE_ADDR), 501 .pfn = __phys_to_pfn(CS4_BASE_ADDR),
216 .length = CS4_SIZE / 2, 502 .length = CS4_SIZE / 2,
@@ -221,13 +507,13 @@ static struct map_desc mx31ads_io_desc[] __initdata = {
221/*! 507/*!
222 * Set up static virtual mappings. 508 * Set up static virtual mappings.
223 */ 509 */
224void __init mx31ads_map_io(void) 510static void __init mx31ads_map_io(void)
225{ 511{
226 mxc_map_io(); 512 mxc_map_io();
227 iotable_init(mx31ads_io_desc, ARRAY_SIZE(mx31ads_io_desc)); 513 iotable_init(mx31ads_io_desc, ARRAY_SIZE(mx31ads_io_desc));
228} 514}
229 515
230void __init mx31ads_init_irq(void) 516static void __init mx31ads_init_irq(void)
231{ 517{
232 mxc_init_irq(); 518 mxc_init_irq();
233 mx31ads_init_expio(); 519 mx31ads_init_expio();
@@ -240,15 +526,15 @@ static void __init mxc_board_init(void)
240{ 526{
241 mxc_init_extuart(); 527 mxc_init_extuart();
242 mxc_init_imx_uart(); 528 mxc_init_imx_uart();
529 mxc_init_i2c();
243} 530}
244 531
245static void __init mx31ads_timer_init(void) 532static void __init mx31ads_timer_init(void)
246{ 533{
247 mxc_clocks_init(26000000); 534 mx31_clocks_init(26000000);
248 mxc_timer_init("ipg_clk.0");
249} 535}
250 536
251struct sys_timer mx31ads_timer = { 537static struct sys_timer mx31ads_timer = {
252 .init = mx31ads_timer_init, 538 .init = mx31ads_timer_init,
253}; 539};
254 540
diff --git a/arch/arm/mach-mx3/mx31lite.c b/arch/arm/mach-mx3/mx31lite.c
index c43440070143..894d98cd9941 100644
--- a/arch/arm/mach-mx3/mx31lite.c
+++ b/arch/arm/mach-mx3/mx31lite.c
@@ -42,21 +42,11 @@
42 */ 42 */
43static struct map_desc mx31lite_io_desc[] __initdata = { 43static struct map_desc mx31lite_io_desc[] __initdata = {
44 { 44 {
45 .virtual = AIPS1_BASE_ADDR_VIRT,
46 .pfn = __phys_to_pfn(AIPS1_BASE_ADDR),
47 .length = AIPS1_SIZE,
48 .type = MT_DEVICE_NONSHARED
49 }, {
50 .virtual = SPBA0_BASE_ADDR_VIRT, 45 .virtual = SPBA0_BASE_ADDR_VIRT,
51 .pfn = __phys_to_pfn(SPBA0_BASE_ADDR), 46 .pfn = __phys_to_pfn(SPBA0_BASE_ADDR),
52 .length = SPBA0_SIZE, 47 .length = SPBA0_SIZE,
53 .type = MT_DEVICE_NONSHARED 48 .type = MT_DEVICE_NONSHARED
54 }, { 49 }, {
55 .virtual = AIPS2_BASE_ADDR_VIRT,
56 .pfn = __phys_to_pfn(AIPS2_BASE_ADDR),
57 .length = AIPS2_SIZE,
58 .type = MT_DEVICE_NONSHARED
59 }, {
60 .virtual = CS4_BASE_ADDR_VIRT, 50 .virtual = CS4_BASE_ADDR_VIRT,
61 .pfn = __phys_to_pfn(CS4_BASE_ADDR), 51 .pfn = __phys_to_pfn(CS4_BASE_ADDR),
62 .length = CS4_SIZE, 52 .length = CS4_SIZE,
@@ -82,8 +72,7 @@ static void __init mxc_board_init(void)
82 72
83static void __init mx31lite_timer_init(void) 73static void __init mx31lite_timer_init(void)
84{ 74{
85 mxc_clocks_init(26000000); 75 mx31_clocks_init(26000000);
86 mxc_timer_init("ipg_clk.0");
87} 76}
88 77
89struct sys_timer mx31lite_timer = { 78struct sys_timer mx31lite_timer = {
diff --git a/arch/arm/mach-mx3/mx31moboard-devboard.c b/arch/arm/mach-mx3/mx31moboard-devboard.c
new file mode 100644
index 000000000000..d080b4add79c
--- /dev/null
+++ b/arch/arm/mach-mx3/mx31moboard-devboard.c
@@ -0,0 +1,48 @@
1/*
2 * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19#include <linux/types.h>
20#include <linux/init.h>
21
22#include <linux/platform_device.h>
23
24#include <mach/hardware.h>
25#include <mach/common.h>
26#include <mach/imx-uart.h>
27#include <mach/iomux-mx3.h>
28
29#include "devices.h"
30
31static struct imxuart_platform_data uart_pdata = {
32 .flags = IMXUART_HAVE_RTSCTS,
33};
34
35static int mxc_uart1_pins[] = {
36 MX31_PIN_CTS2__CTS2, MX31_PIN_RTS2__RTS2,
37 MX31_PIN_TXD2__TXD2, MX31_PIN_RXD2__RXD2,
38};
39
40/*
41 * system init for baseboard usage. Will be called by mx31moboard init.
42 */
43void __init mx31moboard_devboard_init(void)
44{
45 printk(KERN_INFO "Initializing mx31devboard peripherals\n");
46 mxc_iomux_setup_multiple_pins(mxc_uart1_pins, ARRAY_SIZE(mxc_uart1_pins), "uart1");
47 mxc_register_device(&mxc_uart_device1, &uart_pdata);
48}
diff --git a/arch/arm/mach-mx3/mx31moboard-marxbot.c b/arch/arm/mach-mx3/mx31moboard-marxbot.c
new file mode 100644
index 000000000000..9ef9566823fb
--- /dev/null
+++ b/arch/arm/mach-mx3/mx31moboard-marxbot.c
@@ -0,0 +1,37 @@
1/*
2 * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19#include <linux/types.h>
20#include <linux/init.h>
21
22#include <linux/platform_device.h>
23
24#include <mach/hardware.h>
25#include <mach/common.h>
26#include <mach/imx-uart.h>
27#include <mach/iomux-mx3.h>
28
29#include "devices.h"
30
31/*
32 * system init for baseboard usage. Will be called by mx31moboard init.
33 */
34void __init mx31moboard_marxbot_init(void)
35{
36 printk(KERN_INFO "Initializing mx31marxbot peripherals\n");
37}
diff --git a/arch/arm/mach-mx3/mx31moboard.c b/arch/arm/mach-mx3/mx31moboard.c
index c29098af7394..34c2a1b99d4f 100644
--- a/arch/arm/mach-mx3/mx31moboard.c
+++ b/arch/arm/mach-mx3/mx31moboard.c
@@ -32,6 +32,7 @@
32#include <mach/common.h> 32#include <mach/common.h>
33#include <mach/imx-uart.h> 33#include <mach/imx-uart.h>
34#include <mach/iomux-mx3.h> 34#include <mach/iomux-mx3.h>
35#include <mach/board-mx31moboard.h>
35 36
36#include "devices.h" 37#include "devices.h"
37 38
@@ -63,6 +64,18 @@ static struct platform_device *devices[] __initdata = {
63 &mx31moboard_flash, 64 &mx31moboard_flash,
64}; 65};
65 66
67static int mxc_uart0_pins[] = {
68 MX31_PIN_CTS1__CTS1, MX31_PIN_RTS1__RTS1,
69 MX31_PIN_TXD1__TXD1, MX31_PIN_RXD1__RXD1,
70};
71static int mxc_uart4_pins[] = {
72 MX31_PIN_PC_RST__CTS5, MX31_PIN_PC_VS2__RTS5,
73 MX31_PIN_PC_BVD2__TXD5, MX31_PIN_PC_BVD1__RXD5,
74};
75
76static int mx31moboard_baseboard;
77core_param(mx31moboard_baseboard, mx31moboard_baseboard, int, 0444);
78
66/* 79/*
67 * Board specific initialization. 80 * Board specific initialization.
68 */ 81 */
@@ -70,58 +83,29 @@ static void __init mxc_board_init(void)
70{ 83{
71 platform_add_devices(devices, ARRAY_SIZE(devices)); 84 platform_add_devices(devices, ARRAY_SIZE(devices));
72 85
73 mxc_iomux_mode(MX31_PIN_CTS1__CTS1); 86 mxc_iomux_setup_multiple_pins(mxc_uart0_pins, ARRAY_SIZE(mxc_uart0_pins), "uart0");
74 mxc_iomux_mode(MX31_PIN_RTS1__RTS1);
75 mxc_iomux_mode(MX31_PIN_TXD1__TXD1);
76 mxc_iomux_mode(MX31_PIN_RXD1__RXD1);
77
78 mxc_register_device(&mxc_uart_device0, &uart_pdata); 87 mxc_register_device(&mxc_uart_device0, &uart_pdata);
79 88
80 mxc_iomux_mode(MX31_PIN_CTS2__CTS2); 89 mxc_iomux_setup_multiple_pins(mxc_uart4_pins, ARRAY_SIZE(mxc_uart4_pins), "uart4");
81 mxc_iomux_mode(MX31_PIN_RTS2__RTS2);
82 mxc_iomux_mode(MX31_PIN_TXD2__TXD2);
83 mxc_iomux_mode(MX31_PIN_RXD2__RXD2);
84
85 mxc_register_device(&mxc_uart_device1, &uart_pdata);
86
87 mxc_iomux_mode(MX31_PIN_PC_RST__CTS5);
88 mxc_iomux_mode(MX31_PIN_PC_VS2__RTS5);
89 mxc_iomux_mode(MX31_PIN_PC_BVD2__TXD5);
90 mxc_iomux_mode(MX31_PIN_PC_BVD1__RXD5);
91
92 mxc_register_device(&mxc_uart_device4, &uart_pdata); 90 mxc_register_device(&mxc_uart_device4, &uart_pdata);
93}
94 91
95/* 92 switch (mx31moboard_baseboard) {
96 * This structure defines static mappings for the mx31moboard. 93 case MX31NOBOARD:
97 */ 94 break;
98static struct map_desc mx31moboard_io_desc[] __initdata = { 95 case MX31DEVBOARD:
99 { 96 mx31moboard_devboard_init();
100 .virtual = AIPS1_BASE_ADDR_VIRT, 97 break;
101 .pfn = __phys_to_pfn(AIPS1_BASE_ADDR), 98 case MX31MARXBOT:
102 .length = AIPS1_SIZE, 99 mx31moboard_marxbot_init();
103 .type = MT_DEVICE_NONSHARED 100 break;
104 }, { 101 default:
105 .virtual = AIPS2_BASE_ADDR_VIRT, 102 printk(KERN_ERR "Illegal mx31moboard_baseboard type %d\n", mx31moboard_baseboard);
106 .pfn = __phys_to_pfn(AIPS2_BASE_ADDR), 103 }
107 .length = AIPS2_SIZE,
108 .type = MT_DEVICE_NONSHARED
109 },
110};
111
112/*
113 * Set up static virtual mappings.
114 */
115void __init mx31moboard_map_io(void)
116{
117 mxc_map_io();
118 iotable_init(mx31moboard_io_desc, ARRAY_SIZE(mx31moboard_io_desc));
119} 104}
120 105
121static void __init mx31moboard_timer_init(void) 106static void __init mx31moboard_timer_init(void)
122{ 107{
123 mxc_clocks_init(26000000); 108 mx31_clocks_init(26000000);
124 mxc_timer_init("ipg_clk.0");
125} 109}
126 110
127struct sys_timer mx31moboard_timer = { 111struct sys_timer mx31moboard_timer = {
@@ -133,7 +117,7 @@ MACHINE_START(MX31MOBOARD, "EPFL Mobots mx31moboard")
133 .phys_io = AIPS1_BASE_ADDR, 117 .phys_io = AIPS1_BASE_ADDR,
134 .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc, 118 .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
135 .boot_params = PHYS_OFFSET + 0x100, 119 .boot_params = PHYS_OFFSET + 0x100,
136 .map_io = mx31moboard_map_io, 120 .map_io = mxc_map_io,
137 .init_irq = mxc_init_irq, 121 .init_irq = mxc_init_irq,
138 .init_machine = mxc_board_init, 122 .init_machine = mxc_board_init,
139 .timer = &mx31moboard_timer, 123 .timer = &mx31moboard_timer,
diff --git a/arch/arm/mach-mx3/mx31pdk.c b/arch/arm/mach-mx3/mx31pdk.c
index d464d068a4a6..bc63f1785691 100644
--- a/arch/arm/mach-mx3/mx31pdk.c
+++ b/arch/arm/mach-mx3/mx31pdk.c
@@ -45,40 +45,17 @@ static struct imxuart_platform_data uart_pdata = {
45 .flags = IMXUART_HAVE_RTSCTS, 45 .flags = IMXUART_HAVE_RTSCTS,
46}; 46};
47 47
48static inline void mxc_init_imx_uart(void) 48static int uart_pins[] = {
49{ 49 MX31_PIN_CTS1__CTS1,
50 mxc_iomux_mode(MX31_PIN_CTS1__CTS1); 50 MX31_PIN_RTS1__RTS1,
51 mxc_iomux_mode(MX31_PIN_RTS1__RTS1); 51 MX31_PIN_TXD1__TXD1,
52 mxc_iomux_mode(MX31_PIN_TXD1__TXD1); 52 MX31_PIN_RXD1__RXD1
53 mxc_iomux_mode(MX31_PIN_RXD1__RXD1);
54
55 mxc_register_device(&mxc_uart_device0, &uart_pdata);
56}
57
58/*!
59 * This structure defines static mappings for the i.MX31PDK board.
60 */
61static struct map_desc mx31pdk_io_desc[] __initdata = {
62 {
63 .virtual = AIPS1_BASE_ADDR_VIRT,
64 .pfn = __phys_to_pfn(AIPS1_BASE_ADDR),
65 .length = AIPS1_SIZE,
66 .type = MT_DEVICE_NONSHARED
67 }, {
68 .virtual = AIPS2_BASE_ADDR_VIRT,
69 .pfn = __phys_to_pfn(AIPS2_BASE_ADDR),
70 .length = AIPS2_SIZE,
71 .type = MT_DEVICE_NONSHARED
72 },
73}; 53};
74 54
75/*! 55static inline void mxc_init_imx_uart(void)
76 * Set up static virtual mappings.
77 */
78static void __init mx31pdk_map_io(void)
79{ 56{
80 mxc_map_io(); 57 mxc_iomux_setup_multiple_pins(uart_pins, ARRAY_SIZE(uart_pins), "uart-0");
81 iotable_init(mx31pdk_io_desc, ARRAY_SIZE(mx31pdk_io_desc)); 58 mxc_register_device(&mxc_uart_device0, &uart_pdata);
82} 59}
83 60
84/*! 61/*!
@@ -91,8 +68,7 @@ static void __init mxc_board_init(void)
91 68
92static void __init mx31pdk_timer_init(void) 69static void __init mx31pdk_timer_init(void)
93{ 70{
94 mxc_clocks_init(26000000); 71 mx31_clocks_init(26000000);
95 mxc_timer_init("ipg_clk.0");
96} 72}
97 73
98static struct sys_timer mx31pdk_timer = { 74static struct sys_timer mx31pdk_timer = {
@@ -108,7 +84,7 @@ MACHINE_START(MX31_3DS, "Freescale MX31PDK (3DS)")
108 .phys_io = AIPS1_BASE_ADDR, 84 .phys_io = AIPS1_BASE_ADDR,
109 .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc, 85 .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
110 .boot_params = PHYS_OFFSET + 0x100, 86 .boot_params = PHYS_OFFSET + 0x100,
111 .map_io = mx31pdk_map_io, 87 .map_io = mxc_map_io,
112 .init_irq = mxc_init_irq, 88 .init_irq = mxc_init_irq,
113 .init_machine = mxc_board_init, 89 .init_machine = mxc_board_init,
114 .timer = &mx31pdk_timer, 90 .timer = &mx31pdk_timer,
diff --git a/arch/arm/mach-mx3/pcm037.c b/arch/arm/mach-mx3/pcm037.c
index 8cea82587222..5fce022114de 100644
--- a/arch/arm/mach-mx3/pcm037.c
+++ b/arch/arm/mach-mx3/pcm037.c
@@ -26,6 +26,8 @@
26#include <linux/gpio.h> 26#include <linux/gpio.h>
27#include <linux/smc911x.h> 27#include <linux/smc911x.h>
28#include <linux/interrupt.h> 28#include <linux/interrupt.h>
29#include <linux/i2c.h>
30#include <linux/i2c/at24.h>
29 31
30#include <mach/hardware.h> 32#include <mach/hardware.h>
31#include <asm/mach-types.h> 33#include <asm/mach-types.h>
@@ -37,6 +39,10 @@
37#include <mach/iomux-mx3.h> 39#include <mach/iomux-mx3.h>
38#include <mach/board-pcm037.h> 40#include <mach/board-pcm037.h>
39#include <mach/mxc_nand.h> 41#include <mach/mxc_nand.h>
42#include <mach/mmc.h>
43#ifdef CONFIG_I2C_IMX
44#include <mach/i2c.h>
45#endif
40 46
41#include "devices.h" 47#include "devices.h"
42 48
@@ -117,12 +123,90 @@ static struct mxc_nand_platform_data pcm037_nand_board_info = {
117 .hw_ecc = 1, 123 .hw_ecc = 1,
118}; 124};
119 125
126#ifdef CONFIG_I2C_IMX
127static int i2c_1_pins[] = {
128 MX31_PIN_CSPI2_MOSI__SCL,
129 MX31_PIN_CSPI2_MISO__SDA,
130};
131
132static int pcm037_i2c_1_init(struct device *dev)
133{
134 return mxc_iomux_setup_multiple_pins(i2c_1_pins, ARRAY_SIZE(i2c_1_pins),
135 "i2c-1");
136}
137
138static void pcm037_i2c_1_exit(struct device *dev)
139{
140 mxc_iomux_release_multiple_pins(i2c_1_pins, ARRAY_SIZE(i2c_1_pins));
141}
142
143static struct imxi2c_platform_data pcm037_i2c_1_data = {
144 .bitrate = 100000,
145 .init = pcm037_i2c_1_init,
146 .exit = pcm037_i2c_1_exit,
147};
148
149static struct at24_platform_data board_eeprom = {
150 .byte_len = 4096,
151 .page_size = 32,
152 .flags = AT24_FLAG_ADDR16,
153};
154
155static struct i2c_board_info pcm037_i2c_devices[] = {
156 {
157 I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */
158 .platform_data = &board_eeprom,
159 }, {
160 I2C_BOARD_INFO("rtc-pcf8563", 0x51),
161 .type = "pcf8563",
162 }
163};
164#endif
165
166static int sdhc1_pins[] = {
167 MX31_PIN_SD1_DATA3__SD1_DATA3,
168 MX31_PIN_SD1_DATA2__SD1_DATA2,
169 MX31_PIN_SD1_DATA1__SD1_DATA1,
170 MX31_PIN_SD1_DATA0__SD1_DATA0,
171 MX31_PIN_SD1_CLK__SD1_CLK,
172 MX31_PIN_SD1_CMD__SD1_CMD,
173};
174
175static int pcm970_sdhc1_init(struct device *dev, irq_handler_t h, void *data)
176{
177 return mxc_iomux_setup_multiple_pins(sdhc1_pins, ARRAY_SIZE(sdhc1_pins),
178 "sdhc-1");
179}
180
181static void pcm970_sdhc1_exit(struct device *dev, void *data)
182{
183 mxc_iomux_release_multiple_pins(sdhc1_pins, ARRAY_SIZE(sdhc1_pins));
184}
185
186/* No card and rw detection at the moment */
187static struct imxmmc_platform_data sdhc_pdata = {
188 .init = pcm970_sdhc1_init,
189 .exit = pcm970_sdhc1_exit,
190};
191
120static struct platform_device *devices[] __initdata = { 192static struct platform_device *devices[] __initdata = {
121 &pcm037_flash, 193 &pcm037_flash,
122 &pcm037_eth, 194 &pcm037_eth,
123 &pcm037_sram_device, 195 &pcm037_sram_device,
124}; 196};
125 197
198static int uart0_pins[] = {
199 MX31_PIN_CTS1__CTS1,
200 MX31_PIN_RTS1__RTS1,
201 MX31_PIN_TXD1__TXD1,
202 MX31_PIN_RXD1__RXD1
203};
204
205static int uart2_pins[] = {
206 MX31_PIN_CSPI3_MOSI__RXD3,
207 MX31_PIN_CSPI3_MISO__TXD3
208};
209
126/* 210/*
127 * Board specific initialization. 211 * Board specific initialization.
128 */ 212 */
@@ -130,59 +214,33 @@ static void __init mxc_board_init(void)
130{ 214{
131 platform_add_devices(devices, ARRAY_SIZE(devices)); 215 platform_add_devices(devices, ARRAY_SIZE(devices));
132 216
133 mxc_iomux_mode(MX31_PIN_CTS1__CTS1); 217 mxc_iomux_setup_multiple_pins(uart0_pins, ARRAY_SIZE(uart0_pins), "uart-0");
134 mxc_iomux_mode(MX31_PIN_RTS1__RTS1);
135 mxc_iomux_mode(MX31_PIN_TXD1__TXD1);
136 mxc_iomux_mode(MX31_PIN_RXD1__RXD1);
137
138 mxc_register_device(&mxc_uart_device0, &uart_pdata); 218 mxc_register_device(&mxc_uart_device0, &uart_pdata);
139 219
140 mxc_iomux_mode(MX31_PIN_CSPI3_MOSI__RXD3); 220 mxc_iomux_setup_multiple_pins(uart2_pins, ARRAY_SIZE(uart2_pins), "uart-2");
141 mxc_iomux_mode(MX31_PIN_CSPI3_MISO__TXD3);
142
143 mxc_register_device(&mxc_uart_device2, &uart_pdata); 221 mxc_register_device(&mxc_uart_device2, &uart_pdata);
144 222
145 mxc_iomux_mode(MX31_PIN_BATT_LINE__OWIRE); 223 mxc_iomux_setup_pin(MX31_PIN_BATT_LINE__OWIRE, "batt-0wire");
146 mxc_register_device(&mxc_w1_master_device, NULL); 224 mxc_register_device(&mxc_w1_master_device, NULL);
147 225
148 /* SMSC9215 IRQ pin */ 226 /* SMSC9215 IRQ pin */
149 mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO3_1, IOMUX_CONFIG_GPIO)); 227 if (!mxc_iomux_setup_pin(IOMUX_MODE(MX31_PIN_GPIO3_1, IOMUX_CONFIG_GPIO),
150 if (!gpio_request(MX31_PIN_GPIO3_1, "pcm037-eth")) 228 "pcm037-eth"))
151 gpio_direction_input(MX31_PIN_GPIO3_1); 229 gpio_direction_input(MX31_PIN_GPIO3_1);
152 230
153 mxc_register_device(&mxc_nand_device, &pcm037_nand_board_info); 231#ifdef CONFIG_I2C_IMX
154} 232 i2c_register_board_info(1, pcm037_i2c_devices,
233 ARRAY_SIZE(pcm037_i2c_devices));
155 234
156/* 235 mxc_register_device(&mxc_i2c_device1, &pcm037_i2c_1_data);
157 * This structure defines static mappings for the pcm037 board. 236#endif
158 */ 237 mxc_register_device(&mxc_nand_device, &pcm037_nand_board_info);
159static struct map_desc pcm037_io_desc[] __initdata = { 238 mxc_register_device(&mxcsdhc_device0, &sdhc_pdata);
160 {
161 .virtual = AIPS1_BASE_ADDR_VIRT,
162 .pfn = __phys_to_pfn(AIPS1_BASE_ADDR),
163 .length = AIPS1_SIZE,
164 .type = MT_DEVICE_NONSHARED
165 }, {
166 .virtual = AIPS2_BASE_ADDR_VIRT,
167 .pfn = __phys_to_pfn(AIPS2_BASE_ADDR),
168 .length = AIPS2_SIZE,
169 .type = MT_DEVICE_NONSHARED
170 },
171};
172
173/*
174 * Set up static virtual mappings.
175 */
176void __init pcm037_map_io(void)
177{
178 mxc_map_io();
179 iotable_init(pcm037_io_desc, ARRAY_SIZE(pcm037_io_desc));
180} 239}
181 240
182static void __init pcm037_timer_init(void) 241static void __init pcm037_timer_init(void)
183{ 242{
184 mxc_clocks_init(26000000); 243 mx31_clocks_init(26000000);
185 mxc_timer_init("ipg_clk.0");
186} 244}
187 245
188struct sys_timer pcm037_timer = { 246struct sys_timer pcm037_timer = {
@@ -194,7 +252,7 @@ MACHINE_START(PCM037, "Phytec Phycore pcm037")
194 .phys_io = AIPS1_BASE_ADDR, 252 .phys_io = AIPS1_BASE_ADDR,
195 .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc, 253 .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
196 .boot_params = PHYS_OFFSET + 0x100, 254 .boot_params = PHYS_OFFSET + 0x100,
197 .map_io = pcm037_map_io, 255 .map_io = mxc_map_io,
198 .init_irq = mxc_init_irq, 256 .init_irq = mxc_init_irq,
199 .init_machine = mxc_board_init, 257 .init_machine = mxc_board_init,
200 .timer = &pcm037_timer, 258 .timer = &pcm037_timer,
diff --git a/arch/arm/mach-mx3/qong.c b/arch/arm/mach-mx3/qong.c
new file mode 100644
index 000000000000..6c4283cec6f4
--- /dev/null
+++ b/arch/arm/mach-mx3/qong.c
@@ -0,0 +1,312 @@
1/*
2 * Copyright (C) 2009 Ilya Yanok, Emcraft Systems Ltd, <yanok@emcraft.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19#include <linux/types.h>
20#include <linux/init.h>
21#include <linux/kernel.h>
22#include <linux/memory.h>
23#include <linux/platform_device.h>
24#include <linux/mtd/physmap.h>
25#include <linux/mtd/nand.h>
26#include <linux/gpio.h>
27
28#include <mach/hardware.h>
29#include <mach/irqs.h>
30#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32#include <asm/mach/time.h>
33#include <asm/mach/map.h>
34#include <mach/common.h>
35#include <asm/page.h>
36#include <asm/setup.h>
37#include <mach/board-qong.h>
38#include <mach/imx-uart.h>
39#include <mach/iomux-mx3.h>
40#include "devices.h"
41
42/* FPGA defines */
43#define QONG_FPGA_VERSION(major, minor, rev) \
44 (((major & 0xF) << 12) | ((minor & 0xF) << 8) | (rev & 0xFF))
45
46#define QONG_FPGA_BASEADDR CS1_BASE_ADDR
47#define QONG_FPGA_PERIPH_SIZE (1 << 24)
48
49#define QONG_FPGA_CTRL_BASEADDR QONG_FPGA_BASEADDR
50#define QONG_FPGA_CTRL_SIZE 0x10
51/* FPGA control registers */
52#define QONG_FPGA_CTRL_VERSION 0x00
53
54#define QONG_DNET_ID 1
55#define QONG_DNET_BASEADDR \
56 (QONG_FPGA_BASEADDR + QONG_DNET_ID * QONG_FPGA_PERIPH_SIZE)
57#define QONG_DNET_SIZE 0x00001000
58
59#define QONG_FPGA_IRQ IOMUX_TO_IRQ(MX31_PIN_DTR_DCE1)
60
61/*
62 * This file contains the board-specific initialization routines.
63 */
64
65static struct imxuart_platform_data uart_pdata = {
66 .flags = IMXUART_HAVE_RTSCTS,
67};
68
69static int uart_pins[] = {
70 MX31_PIN_CTS1__CTS1,
71 MX31_PIN_RTS1__RTS1,
72 MX31_PIN_TXD1__TXD1,
73 MX31_PIN_RXD1__RXD1
74};
75
76static inline void mxc_init_imx_uart(void)
77{
78 mxc_iomux_setup_multiple_pins(uart_pins, ARRAY_SIZE(uart_pins),
79 "uart-0");
80 mxc_register_device(&mxc_uart_device0, &uart_pdata);
81}
82
83static struct resource dnet_resources[] = {
84 [0] = {
85 .name = "dnet-memory",
86 .start = QONG_DNET_BASEADDR,
87 .end = QONG_DNET_BASEADDR + QONG_DNET_SIZE - 1,
88 .flags = IORESOURCE_MEM,
89 },
90 [1] = {
91 .start = QONG_FPGA_IRQ,
92 .end = QONG_FPGA_IRQ,
93 .flags = IORESOURCE_IRQ,
94 },
95};
96
97static struct platform_device dnet_device = {
98 .name = "dnet",
99 .id = -1,
100 .num_resources = ARRAY_SIZE(dnet_resources),
101 .resource = dnet_resources,
102};
103
104static int __init qong_init_dnet(void)
105{
106 int ret;
107
108 ret = platform_device_register(&dnet_device);
109 return ret;
110}
111
112/* MTD NOR flash */
113
114static struct physmap_flash_data qong_flash_data = {
115 .width = 2,
116};
117
118static struct resource qong_flash_resource = {
119 .start = CS0_BASE_ADDR,
120 .end = CS0_BASE_ADDR + QONG_NOR_SIZE - 1,
121 .flags = IORESOURCE_MEM,
122};
123
124static struct platform_device qong_nor_mtd_device = {
125 .name = "physmap-flash",
126 .id = 0,
127 .dev = {
128 .platform_data = &qong_flash_data,
129 },
130 .resource = &qong_flash_resource,
131 .num_resources = 1,
132};
133
134static void qong_init_nor_mtd(void)
135{
136 (void)platform_device_register(&qong_nor_mtd_device);
137}
138
139/*
140 * Hardware specific access to control-lines
141 */
142static void qong_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
143{
144 struct nand_chip *nand_chip = mtd->priv;
145
146 if (cmd == NAND_CMD_NONE)
147 return;
148
149 if (ctrl & NAND_CLE)
150 writeb(cmd, nand_chip->IO_ADDR_W + (1 << 24));
151 else
152 writeb(cmd, nand_chip->IO_ADDR_W + (1 << 23));
153}
154
155/*
156 * Read the Device Ready pin.
157 */
158static int qong_nand_device_ready(struct mtd_info *mtd)
159{
160 return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_NFRB));
161}
162
163static void qong_nand_select_chip(struct mtd_info *mtd, int chip)
164{
165 if (chip >= 0)
166 gpio_set_value(IOMUX_TO_GPIO(MX31_PIN_NFCE_B), 0);
167 else
168 gpio_set_value(IOMUX_TO_GPIO(MX31_PIN_NFCE_B), 1);
169}
170
171static struct platform_nand_data qong_nand_data = {
172 .chip = {
173 .chip_delay = 20,
174 .options = 0,
175 },
176 .ctrl = {
177 .cmd_ctrl = qong_nand_cmd_ctrl,
178 .dev_ready = qong_nand_device_ready,
179 .select_chip = qong_nand_select_chip,
180 }
181};
182
183static struct resource qong_nand_resource = {
184 .start = CS3_BASE_ADDR,
185 .end = CS3_BASE_ADDR + SZ_32M - 1,
186 .flags = IORESOURCE_MEM,
187};
188
189static struct platform_device qong_nand_device = {
190 .name = "gen_nand",
191 .id = -1,
192 .dev = {
193 .platform_data = &qong_nand_data,
194 },
195 .num_resources = 1,
196 .resource = &qong_nand_resource,
197};
198
199static void __init qong_init_nand_mtd(void)
200{
201 /* init CS */
202 __raw_writel(0x00004f00, CSCR_U(3));
203 __raw_writel(0x20013b31, CSCR_L(3));
204 __raw_writel(0x00020800, CSCR_A(3));
205 mxc_iomux_set_gpr(MUX_SDCTL_CSD1_SEL, true);
206
207 /* enable pin */
208 mxc_iomux_mode(IOMUX_MODE(MX31_PIN_NFCE_B, IOMUX_CONFIG_GPIO));
209 if (!gpio_request(IOMUX_TO_GPIO(MX31_PIN_NFCE_B), "nand_enable"))
210 gpio_direction_output(IOMUX_TO_GPIO(MX31_PIN_NFCE_B), 0);
211
212 /* ready/busy pin */
213 mxc_iomux_mode(IOMUX_MODE(MX31_PIN_NFRB, IOMUX_CONFIG_GPIO));
214 if (!gpio_request(IOMUX_TO_GPIO(MX31_PIN_NFRB), "nand_rdy"))
215 gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_NFRB));
216
217 /* write protect pin */
218 mxc_iomux_mode(IOMUX_MODE(MX31_PIN_NFWP_B, IOMUX_CONFIG_GPIO));
219 if (!gpio_request(IOMUX_TO_GPIO(MX31_PIN_NFWP_B), "nand_wp"))
220 gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_NFWP_B));
221
222 platform_device_register(&qong_nand_device);
223}
224
225static void __init qong_init_fpga(void)
226{
227 void __iomem *regs;
228 u32 fpga_ver;
229
230 regs = ioremap(QONG_FPGA_CTRL_BASEADDR, QONG_FPGA_CTRL_SIZE);
231 if (!regs) {
232 printk(KERN_ERR "%s: failed to map registers, aborting.\n",
233 __func__);
234 return;
235 }
236
237 fpga_ver = readl(regs + QONG_FPGA_CTRL_VERSION);
238 iounmap(regs);
239 printk(KERN_INFO "Qong FPGA version %d.%d.%d\n",
240 (fpga_ver & 0xF000) >> 12,
241 (fpga_ver & 0x0F00) >> 8, fpga_ver & 0x00FF);
242 if (fpga_ver < QONG_FPGA_VERSION(0, 8, 7)) {
243 printk(KERN_ERR "qong: Unexpected FPGA version, FPGA-based "
244 "devices won't be registered!\n");
245 return;
246 }
247
248 /* register FPGA-based devices */
249 qong_init_nand_mtd();
250 qong_init_dnet();
251}
252
253/*
254 * This structure defines the MX31 memory map.
255 */
256static struct map_desc qong_io_desc[] __initdata = {
257 {
258 .virtual = AIPS1_BASE_ADDR_VIRT,
259 .pfn = __phys_to_pfn(AIPS1_BASE_ADDR),
260 .length = AIPS1_SIZE,
261 .type = MT_DEVICE_NONSHARED
262 }, {
263 .virtual = AIPS2_BASE_ADDR_VIRT,
264 .pfn = __phys_to_pfn(AIPS2_BASE_ADDR),
265 .length = AIPS2_SIZE,
266 .type = MT_DEVICE_NONSHARED
267 }
268};
269
270/*
271 * Set up static virtual mappings.
272 */
273static void __init qong_map_io(void)
274{
275 mxc_map_io();
276 iotable_init(qong_io_desc, ARRAY_SIZE(qong_io_desc));
277}
278
279/*
280 * Board specific initialization.
281 */
282static void __init mxc_board_init(void)
283{
284 mxc_init_imx_uart();
285 qong_init_nor_mtd();
286 qong_init_fpga();
287}
288
289static void __init qong_timer_init(void)
290{
291 mx31_clocks_init(26000000);
292}
293
294static struct sys_timer qong_timer = {
295 .init = qong_timer_init,
296};
297
298/*
299 * The following uses standard kernel macros defined in arch.h in order to
300 * initialize __mach_desc_QONG data structure.
301 */
302
303MACHINE_START(QONG, "Dave/DENX QongEVB-LITE")
304 /* Maintainer: DENX Software Engineering GmbH */
305 .phys_io = AIPS1_BASE_ADDR,
306 .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
307 .boot_params = PHYS_OFFSET + 0x100,
308 .map_io = qong_map_io,
309 .init_irq = mxc_init_irq,
310 .init_machine = mxc_board_init,
311 .timer = &qong_timer,
312MACHINE_END
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index f6a13451d1fd..6031e179926b 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -81,7 +81,7 @@ static inline void __init ldp_init_smc911x(void)
81 } 81 }
82 82
83 ldp_smc911x_resources[0].start = cs_mem_base + 0x0; 83 ldp_smc911x_resources[0].start = cs_mem_base + 0x0;
84 ldp_smc911x_resources[0].end = cs_mem_base + 0xf; 84 ldp_smc911x_resources[0].end = cs_mem_base + 0xff;
85 udelay(100); 85 udelay(100);
86 86
87 eth_gpio = LDP_SMC911X_GPIO; 87 eth_gpio = LDP_SMC911X_GPIO;
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index ad721e0cbf7a..ce4d46a4a838 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -565,7 +565,7 @@ u32 omap2_clksel_to_divisor(struct clk *clk, u32 field_val)
565 * 565 *
566 * Given a struct clk of a rate-selectable clksel clock, and a clock divisor, 566 * Given a struct clk of a rate-selectable clksel clock, and a clock divisor,
567 * find the corresponding register field value. The return register value is 567 * find the corresponding register field value. The return register value is
568 * the value before left-shifting. Returns 0xffffffff on error 568 * the value before left-shifting. Returns ~0 on error
569 */ 569 */
570u32 omap2_divisor_to_clksel(struct clk *clk, u32 div) 570u32 omap2_divisor_to_clksel(struct clk *clk, u32 div)
571{ 571{
@@ -577,7 +577,7 @@ u32 omap2_divisor_to_clksel(struct clk *clk, u32 div)
577 577
578 clks = omap2_get_clksel_by_parent(clk, clk->parent); 578 clks = omap2_get_clksel_by_parent(clk, clk->parent);
579 if (clks == NULL) 579 if (clks == NULL)
580 return 0; 580 return ~0;
581 581
582 for (clkr = clks->rates; clkr->div; clkr++) { 582 for (clkr = clks->rates; clkr->div; clkr++) {
583 if ((clkr->flags & cpu_mask) && (clkr->div == div)) 583 if ((clkr->flags & cpu_mask) && (clkr->div == div))
@@ -588,7 +588,7 @@ u32 omap2_divisor_to_clksel(struct clk *clk, u32 div)
588 printk(KERN_ERR "clock: Could not find divisor %d for " 588 printk(KERN_ERR "clock: Could not find divisor %d for "
589 "clock %s parent %s\n", div, clk->name, 589 "clock %s parent %s\n", div, clk->name,
590 clk->parent->name); 590 clk->parent->name);
591 return 0; 591 return ~0;
592 } 592 }
593 593
594 return clkr->val; 594 return clkr->val;
@@ -708,7 +708,7 @@ static u32 omap2_clksel_get_src_field(void __iomem **src_addr,
708 return 0; 708 return 0;
709 709
710 for (clkr = clks->rates; clkr->div; clkr++) { 710 for (clkr = clks->rates; clkr->div; clkr++) {
711 if (clkr->flags & (cpu_mask | DEFAULT_RATE)) 711 if (clkr->flags & cpu_mask && clkr->flags & DEFAULT_RATE)
712 break; /* Found the default rate for this platform */ 712 break; /* Found the default rate for this platform */
713 } 713 }
714 714
@@ -746,7 +746,7 @@ int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent)
746 return -EINVAL; 746 return -EINVAL;
747 747
748 if (clk->usecount > 0) 748 if (clk->usecount > 0)
749 _omap2_clk_disable(clk); 749 omap2_clk_disable(clk);
750 750
751 /* Set new source value (previous dividers if any in effect) */ 751 /* Set new source value (previous dividers if any in effect) */
752 reg_val = __raw_readl(src_addr) & ~field_mask; 752 reg_val = __raw_readl(src_addr) & ~field_mask;
@@ -759,11 +759,11 @@ int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent)
759 wmb(); 759 wmb();
760 } 760 }
761 761
762 if (clk->usecount > 0)
763 _omap2_clk_enable(clk);
764
765 clk->parent = new_parent; 762 clk->parent = new_parent;
766 763
764 if (clk->usecount > 0)
765 omap2_clk_enable(clk);
766
767 /* CLKSEL clocks follow their parents' rates, divided by a divisor */ 767 /* CLKSEL clocks follow their parents' rates, divided by a divisor */
768 clk->rate = new_parent->rate; 768 clk->rate = new_parent->rate;
769 769
diff --git a/arch/arm/mach-orion5x/irq.c b/arch/arm/mach-orion5x/irq.c
index 0caae43301e5..e03f7b45cb0d 100644
--- a/arch/arm/mach-orion5x/irq.c
+++ b/arch/arm/mach-orion5x/irq.c
@@ -44,7 +44,7 @@ void __init orion5x_init_irq(void)
44 * User can use set_type() if he wants to use edge types handlers. 44 * User can use set_type() if he wants to use edge types handlers.
45 */ 45 */
46 for (i = IRQ_ORION5X_GPIO_START; i < NR_IRQS; i++) { 46 for (i = IRQ_ORION5X_GPIO_START; i < NR_IRQS; i++) {
47 set_irq_chip(i, &orion_gpio_irq_level_chip); 47 set_irq_chip(i, &orion_gpio_irq_chip);
48 set_irq_handler(i, handle_level_irq); 48 set_irq_handler(i, handle_level_irq);
49 irq_desc[i].status |= IRQ_LEVEL; 49 irq_desc[i].status |= IRQ_LEVEL;
50 set_irq_flags(i, IRQF_VALID); 50 set_irq_flags(i, IRQF_VALID);
diff --git a/arch/arm/mach-rpc/riscpc.c b/arch/arm/mach-rpc/riscpc.c
index e88d417736af..c7fc01e9d1f6 100644
--- a/arch/arm/mach-rpc/riscpc.c
+++ b/arch/arm/mach-rpc/riscpc.c
@@ -19,6 +19,7 @@
19#include <linux/serial_8250.h> 19#include <linux/serial_8250.h>
20#include <linux/ata_platform.h> 20#include <linux/ata_platform.h>
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/i2c.h>
22 23
23#include <asm/elf.h> 24#include <asm/elf.h>
24#include <asm/mach-types.h> 25#include <asm/mach-types.h>
@@ -201,8 +202,13 @@ static struct platform_device *devs[] __initdata = {
201 &pata_device, 202 &pata_device,
202}; 203};
203 204
205static struct i2c_board_info i2c_rtc = {
206 I2C_BOARD_INFO("pcf8583", 0x50)
207};
208
204static int __init rpc_init(void) 209static int __init rpc_init(void)
205{ 210{
211 i2c_register_board_info(0, &i2c_rtc, 1);
206 return platform_add_devices(devs, ARRAY_SIZE(devs)); 212 return platform_add_devices(devs, ARRAY_SIZE(devs));
207} 213}
208 214
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index d490f3773c01..0d8581f11211 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -704,7 +704,8 @@ config CACHE_FEROCEON_L2_WRITETHROUGH
704 704
705config CACHE_L2X0 705config CACHE_L2X0
706 bool "Enable the L2x0 outer cache controller" 706 bool "Enable the L2x0 outer cache controller"
707 depends on REALVIEW_EB_ARM11MP || MACH_REALVIEW_PB11MP || MACH_REALVIEW_PB1176 || REALVIEW_EB_A9MP 707 depends on REALVIEW_EB_ARM11MP || MACH_REALVIEW_PB11MP || MACH_REALVIEW_PB1176 || \
708 REALVIEW_EB_A9MP || ARCH_MX35 || ARCH_MX31
708 default y 709 default y
709 select OUTER_CACHE 710 select OUTER_CACHE
710 help 711 help
diff --git a/arch/arm/mm/abort-ev6.S b/arch/arm/mm/abort-ev6.S
index 8a7f65ba14b7..94077fbd96b7 100644
--- a/arch/arm/mm/abort-ev6.S
+++ b/arch/arm/mm/abort-ev6.S
@@ -23,7 +23,8 @@ ENTRY(v6_early_abort)
23#ifdef CONFIG_CPU_32v6K 23#ifdef CONFIG_CPU_32v6K
24 clrex 24 clrex
25#else 25#else
26 strex r0, r1, [sp] @ Clear the exclusive monitor 26 sub r1, sp, #4 @ Get unused stack location
27 strex r0, r1, [r1] @ Clear the exclusive monitor
27#endif 28#endif
28 mrc p15, 0, r1, c5, c0, 0 @ get FSR 29 mrc p15, 0, r1, c5, c0, 0 @ get FSR
29 mrc p15, 0, r0, c6, c0, 0 @ get FAR 30 mrc p15, 0, r0, c6, c0, 0 @ get FAR
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index aa424e1da8a1..8c6fc5a6237e 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -716,7 +716,8 @@ static void __init sanity_check_meminfo(void)
716 * Check whether this memory bank would entirely overlap 716 * Check whether this memory bank would entirely overlap
717 * the vmalloc area. 717 * the vmalloc area.
718 */ 718 */
719 if (__va(bank->start) >= VMALLOC_MIN) { 719 if (__va(bank->start) >= VMALLOC_MIN ||
720 __va(bank->start) < PAGE_OFFSET) {
720 printk(KERN_NOTICE "Ignoring RAM at %.8lx-%.8lx " 721 printk(KERN_NOTICE "Ignoring RAM at %.8lx-%.8lx "
721 "(vmalloc region overlap).\n", 722 "(vmalloc region overlap).\n",
722 bank->start, bank->start + bank->size - 1); 723 bank->start, bank->start + bank->size - 1);
diff --git a/arch/arm/plat-mxc/Kconfig b/arch/arm/plat-mxc/Kconfig
index 9cc2b16fdf79..17d0e9906d5f 100644
--- a/arch/arm/plat-mxc/Kconfig
+++ b/arch/arm/plat-mxc/Kconfig
@@ -3,7 +3,7 @@ if ARCH_MXC
3menu "Freescale MXC Implementations" 3menu "Freescale MXC Implementations"
4 4
5choice 5choice
6 prompt "MXC/iMX Base Type" 6 prompt "Freescale CPU family:"
7 default ARCH_MX3 7 default ARCH_MX3
8 8
9config ARCH_MX1 9config ARCH_MX1
@@ -15,12 +15,14 @@ config ARCH_MX1
15config ARCH_MX2 15config ARCH_MX2
16 bool "MX2-based" 16 bool "MX2-based"
17 select CPU_ARM926T 17 select CPU_ARM926T
18 select COMMON_CLKDEV
18 help 19 help
19 This enables support for systems based on the Freescale i.MX2 family 20 This enables support for systems based on the Freescale i.MX2 family
20 21
21config ARCH_MX3 22config ARCH_MX3
22 bool "MX3-based" 23 bool "MX3-based"
23 select CPU_V6 24 select CPU_V6
25 select COMMON_CLKDEV
24 help 26 help
25 This enables support for systems based on the Freescale i.MX3 family 27 This enables support for systems based on the Freescale i.MX3 family
26 28
@@ -43,4 +45,10 @@ config MXC_IRQ_PRIOR
43 requirements for timing. 45 requirements for timing.
44 Say N here, unless you have a specialized requirement. 46 Say N here, unless you have a specialized requirement.
45 47
48config MXC_PWM
49 tristate "Enable PWM driver"
50 depends on ARCH_MXC
51 help
52 Enable support for the i.MX PWM controller(s).
53
46endif 54endif
diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile
index db74a929179d..564fd4ebf38a 100644
--- a/arch/arm/plat-mxc/Makefile
+++ b/arch/arm/plat-mxc/Makefile
@@ -3,7 +3,8 @@
3# 3#
4 4
5# Common support 5# Common support
6obj-y := irq.o clock.o gpio.o time.o devices.o 6obj-y := irq.o clock.o gpio.o time.o devices.o cpu.o
7 7
8obj-$(CONFIG_ARCH_MX1) += iomux-mx1-mx2.o dma-mx1-mx2.o 8obj-$(CONFIG_ARCH_MX1) += iomux-mx1-mx2.o dma-mx1-mx2.o
9obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o dma-mx1-mx2.o 9obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o dma-mx1-mx2.o
10obj-$(CONFIG_MXC_PWM) += pwm.o
diff --git a/arch/arm/plat-mxc/clock.c b/arch/arm/plat-mxc/clock.c
index 0a38f0b396eb..92e13566cd4f 100644
--- a/arch/arm/plat-mxc/clock.c
+++ b/arch/arm/plat-mxc/clock.c
@@ -48,6 +48,11 @@ static DEFINE_MUTEX(clocks_mutex);
48 *-------------------------------------------------------------------------*/ 48 *-------------------------------------------------------------------------*/
49 49
50/* 50/*
51 * All the code inside #ifndef CONFIG_COMMON_CLKDEV can be removed once all
52 * MXC architectures have switched to using clkdev.
53 */
54#ifndef CONFIG_COMMON_CLKDEV
55/*
51 * Retrieve a clock by name. 56 * Retrieve a clock by name.
52 * 57 *
53 * Note that we first try to use device id on the bus 58 * Note that we first try to use device id on the bus
@@ -110,6 +115,7 @@ found:
110 return clk; 115 return clk;
111} 116}
112EXPORT_SYMBOL(clk_get); 117EXPORT_SYMBOL(clk_get);
118#endif
113 119
114static void __clk_disable(struct clk *clk) 120static void __clk_disable(struct clk *clk)
115{ 121{
@@ -187,6 +193,7 @@ unsigned long clk_get_rate(struct clk *clk)
187} 193}
188EXPORT_SYMBOL(clk_get_rate); 194EXPORT_SYMBOL(clk_get_rate);
189 195
196#ifndef CONFIG_COMMON_CLKDEV
190/* Decrement the clock's module reference count */ 197/* Decrement the clock's module reference count */
191void clk_put(struct clk *clk) 198void clk_put(struct clk *clk)
192{ 199{
@@ -194,6 +201,7 @@ void clk_put(struct clk *clk)
194 module_put(clk->owner); 201 module_put(clk->owner);
195} 202}
196EXPORT_SYMBOL(clk_put); 203EXPORT_SYMBOL(clk_put);
204#endif
197 205
198/* Round the requested clock rate to the nearest supported 206/* Round the requested clock rate to the nearest supported
199 * rate that is less than or equal to the requested rate. 207 * rate that is less than or equal to the requested rate.
@@ -257,6 +265,7 @@ struct clk *clk_get_parent(struct clk *clk)
257} 265}
258EXPORT_SYMBOL(clk_get_parent); 266EXPORT_SYMBOL(clk_get_parent);
259 267
268#ifndef CONFIG_COMMON_CLKDEV
260/* 269/*
261 * Add a new clock to the clock tree. 270 * Add a new clock to the clock tree.
262 */ 271 */
@@ -327,4 +336,49 @@ static int __init mxc_setup_proc_entry(void)
327} 336}
328 337
329late_initcall(mxc_setup_proc_entry); 338late_initcall(mxc_setup_proc_entry);
339#endif /* CONFIG_PROC_FS */
340#endif
341
342/*
343 * Get the resulting clock rate from a PLL register value and the input
344 * frequency. PLLs with this register layout can at least be found on
345 * MX1, MX21, MX27 and MX31
346 *
347 * mfi + mfn / (mfd + 1)
348 * f = 2 * f_ref * --------------------
349 * pd + 1
350 */
351unsigned long mxc_decode_pll(unsigned int reg_val, u32 freq)
352{
353 long long ll;
354 int mfn_abs;
355 unsigned int mfi, mfn, mfd, pd;
356
357 mfi = (reg_val >> 10) & 0xf;
358 mfn = reg_val & 0x3ff;
359 mfd = (reg_val >> 16) & 0x3ff;
360 pd = (reg_val >> 26) & 0xf;
361
362 mfi = mfi <= 5 ? 5 : mfi;
363
364 mfn_abs = mfn;
365
366#if !defined CONFIG_ARCH_MX1 && !defined CONFIG_ARCH_MX21
367 if (mfn >= 0x200) {
368 mfn |= 0xFFFFFE00;
369 mfn_abs = -mfn;
370 }
330#endif 371#endif
372
373 freq *= 2;
374 freq /= pd + 1;
375
376 ll = (unsigned long long)freq * mfn_abs;
377
378 do_div(ll, mfd + 1);
379 if (mfn < 0)
380 ll = -ll;
381 ll = (freq * mfi) + ll;
382
383 return ll;
384}
diff --git a/arch/arm/plat-mxc/cpu.c b/arch/arm/plat-mxc/cpu.c
new file mode 100644
index 000000000000..386e0d52cf58
--- /dev/null
+++ b/arch/arm/plat-mxc/cpu.c
@@ -0,0 +1,11 @@
1
2#include <linux/module.h>
3
4unsigned int __mxc_cpu_type;
5EXPORT_SYMBOL(__mxc_cpu_type);
6
7void mxc_set_cpu_type(unsigned int type)
8{
9 __mxc_cpu_type = type;
10}
11
diff --git a/arch/arm/plat-mxc/devices.c b/arch/arm/plat-mxc/devices.c
index c66748267c45..56f2fb5cc456 100644
--- a/arch/arm/plat-mxc/devices.c
+++ b/arch/arm/plat-mxc/devices.c
@@ -19,6 +19,7 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <mach/common.h>
22 23
23int __init mxc_register_device(struct platform_device *pdev, void *data) 24int __init mxc_register_device(struct platform_device *pdev, void *data)
24{ 25{
diff --git a/arch/arm/plat-mxc/dma-mx1-mx2.c b/arch/arm/plat-mxc/dma-mx1-mx2.c
index a9bab15f0fd0..e364a5ed10f1 100644
--- a/arch/arm/plat-mxc/dma-mx1-mx2.c
+++ b/arch/arm/plat-mxc/dma-mx1-mx2.c
@@ -802,7 +802,7 @@ static int __init imx_dma_init(void)
802 int ret = 0; 802 int ret = 0;
803 int i; 803 int i;
804 804
805 dma_clk = clk_get(NULL, "dma_clk"); 805 dma_clk = clk_get(NULL, "dma");
806 clk_enable(dma_clk); 806 clk_enable(dma_clk);
807 807
808 /* reset DMA module */ 808 /* reset DMA module */
diff --git a/arch/arm/plat-mxc/gpio.c b/arch/arm/plat-mxc/gpio.c
index ccbd94adc668..c6483bad8a26 100644
--- a/arch/arm/plat-mxc/gpio.c
+++ b/arch/arm/plat-mxc/gpio.c
@@ -200,8 +200,8 @@ static int mxc_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
200static int mxc_gpio_direction_output(struct gpio_chip *chip, 200static int mxc_gpio_direction_output(struct gpio_chip *chip,
201 unsigned offset, int value) 201 unsigned offset, int value)
202{ 202{
203 _set_gpio_direction(chip, offset, 1);
204 mxc_gpio_set(chip, offset, value); 203 mxc_gpio_set(chip, offset, value);
204 _set_gpio_direction(chip, offset, 1);
205 return 0; 205 return 0;
206} 206}
207 207
diff --git a/arch/arm/plat-mxc/include/mach/board-mx27ads.h b/arch/arm/plat-mxc/include/mach/board-mx27ads.h
index 8f34a05afc87..1cac9d1135cd 100644
--- a/arch/arm/plat-mxc/include/mach/board-mx27ads.h
+++ b/arch/arm/plat-mxc/include/mach/board-mx27ads.h
@@ -48,7 +48,8 @@
48 * Base address of PBC controller, CS4 48 * Base address of PBC controller, CS4
49 */ 49 */
50#define PBC_BASE_ADDRESS 0xEB000000 50#define PBC_BASE_ADDRESS 0xEB000000
51#define PBC_REG_ADDR(offset) (PBC_BASE_ADDRESS + (offset)) 51#define PBC_REG_ADDR(offset) (void __force __iomem *) \
52 (PBC_BASE_ADDRESS + (offset))
52 53
53/* 54/*
54 * PBC Interupt name definitions 55 * PBC Interupt name definitions
diff --git a/arch/arm/plat-mxc/include/mach/board-mx31ads.h b/arch/arm/plat-mxc/include/mach/board-mx31ads.h
index 451d510d08c3..318c72ada13d 100644
--- a/arch/arm/plat-mxc/include/mach/board-mx31ads.h
+++ b/arch/arm/plat-mxc/include/mach/board-mx31ads.h
@@ -11,6 +11,8 @@
11#ifndef __ASM_ARCH_MXC_BOARD_MX31ADS_H__ 11#ifndef __ASM_ARCH_MXC_BOARD_MX31ADS_H__
12#define __ASM_ARCH_MXC_BOARD_MX31ADS_H__ 12#define __ASM_ARCH_MXC_BOARD_MX31ADS_H__
13 13
14#include <mach/hardware.h>
15
14/* Base address of PBC controller */ 16/* Base address of PBC controller */
15#define PBC_BASE_ADDRESS IO_ADDRESS(CS4_BASE_ADDR) 17#define PBC_BASE_ADDRESS IO_ADDRESS(CS4_BASE_ADDR)
16/* Offsets for the PBC Controller register */ 18/* Offsets for the PBC Controller register */
diff --git a/arch/arm/plat-mxc/include/mach/board-mx31moboard.h b/arch/arm/plat-mxc/include/mach/board-mx31moboard.h
new file mode 100644
index 000000000000..f8aef1babb75
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/board-mx31moboard.h
@@ -0,0 +1,45 @@
1/*
2 * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16 * MA 02110-1301, USA.
17 */
18
19#ifndef __ASM_ARCH_MXC_BOARD_MX31MOBOARD_H__
20#define __ASM_ARCH_MXC_BOARD_MX31MOBOARD_H__
21
22/* mandatory for CONFIG_LL_DEBUG */
23
24#define MXC_LL_UART_PADDR UART1_BASE_ADDR
25#define MXC_LL_UART_VADDR (AIPI_BASE_ADDR_VIRT + 0x0A000)
26
27#ifndef __ASSEMBLY__
28
29enum mx31moboard_boards {
30 MX31NOBOARD = 0,
31 MX31DEVBOARD = 1,
32 MX31MARXBOT = 2,
33};
34
35/*
36 * This CPU module needs a baseboard to work. After basic initializing
37 * its own devices, it calls baseboard's init function.
38 */
39
40extern void mx31moboard_devboard_init(void);
41extern void mx31moboard_marxbot_init(void);
42
43#endif
44
45#endif /* __ASM_ARCH_MXC_BOARD_MX31MOBOARD_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/board-qong.h b/arch/arm/plat-mxc/include/mach/board-qong.h
new file mode 100644
index 000000000000..4ff762dd45cf
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/board-qong.h
@@ -0,0 +1,22 @@
1/*
2 * Copyright 2009 Ilya Yanok, Emcraft Systems Ltd, <yanok@emcraft.com>
3 */
4
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_MXC_BOARD_QONG_H__
12#define __ASM_ARCH_MXC_BOARD_QONG_H__
13
14/* mandatory for CONFIG_LL_DEBUG */
15
16#define MXC_LL_UART_PADDR UART1_BASE_ADDR
17#define MXC_LL_UART_VADDR AIPS1_IO_ADDRESS(UART1_BASE_ADDR)
18
19/* NOR FLASH */
20#define QONG_NOR_SIZE (128*1024*1024)
21
22#endif /* __ASM_ARCH_MXC_BOARD_QONG_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/clkdev.h b/arch/arm/plat-mxc/include/mach/clkdev.h
new file mode 100644
index 000000000000..04b37a89801c
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/clkdev.h
@@ -0,0 +1,7 @@
1#ifndef __ASM_MACH_CLKDEV_H
2#define __ASM_MACH_CLKDEV_H
3
4#define __clk_get(clk) ({ 1; })
5#define __clk_put(clk) do { } while (0)
6
7#endif
diff --git a/arch/arm/plat-mxc/include/mach/clock.h b/arch/arm/plat-mxc/include/mach/clock.h
index d21f78e78819..43a82d0c534d 100644
--- a/arch/arm/plat-mxc/include/mach/clock.h
+++ b/arch/arm/plat-mxc/include/mach/clock.h
@@ -26,9 +26,13 @@
26struct module; 26struct module;
27 27
28struct clk { 28struct clk {
29#ifndef CONFIG_COMMON_CLKDEV
30 /* As soon as i.MX1 and i.MX31 switched to clkdev, this
31 * block can go away */
29 struct list_head node; 32 struct list_head node;
30 struct module *owner; 33 struct module *owner;
31 const char *name; 34 const char *name;
35#endif
32 int id; 36 int id;
33 /* Source clock this clk depends on */ 37 /* Source clock this clk depends on */
34 struct clk *parent; 38 struct clk *parent;
@@ -63,5 +67,7 @@ struct clk {
63int clk_register(struct clk *clk); 67int clk_register(struct clk *clk);
64void clk_unregister(struct clk *clk); 68void clk_unregister(struct clk *clk);
65 69
70unsigned long mxc_decode_pll(unsigned int pll, u32 f_ref);
71
66#endif /* __ASSEMBLY__ */ 72#endif /* __ASSEMBLY__ */
67#endif /* __ASM_ARCH_MXC_CLOCK_H__ */ 73#endif /* __ASM_ARCH_MXC_CLOCK_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/common.h b/arch/arm/plat-mxc/include/mach/common.h
index 6350287a59b9..b2f9b72644db 100644
--- a/arch/arm/plat-mxc/include/mach/common.h
+++ b/arch/arm/plat-mxc/include/mach/common.h
@@ -12,12 +12,18 @@
12#define __ASM_ARCH_MXC_COMMON_H__ 12#define __ASM_ARCH_MXC_COMMON_H__
13 13
14struct platform_device; 14struct platform_device;
15struct clk;
15 16
16extern void mxc_map_io(void); 17extern void mxc_map_io(void);
17extern void mxc_init_irq(void); 18extern void mxc_init_irq(void);
18extern void mxc_timer_init(const char *clk_timer); 19extern void mxc_timer_init(struct clk *timer_clk);
19extern int mxc_clocks_init(unsigned long fref); 20extern int mx1_clocks_init(unsigned long fref);
21extern int mx21_clocks_init(unsigned long lref, unsigned long fref);
22extern int mx27_clocks_init(unsigned long fref);
23extern int mx31_clocks_init(unsigned long fref);
24extern int mx35_clocks_init(void);
20extern int mxc_register_gpios(void); 25extern int mxc_register_gpios(void);
21extern int mxc_register_device(struct platform_device *pdev, void *data); 26extern int mxc_register_device(struct platform_device *pdev, void *data);
27extern void mxc_set_cpu_type(unsigned int type);
22 28
23#endif 29#endif
diff --git a/arch/arm/plat-mxc/include/mach/debug-macro.S b/arch/arm/plat-mxc/include/mach/debug-macro.S
index 602768b427e2..4f773148bc20 100644
--- a/arch/arm/plat-mxc/include/mach/debug-macro.S
+++ b/arch/arm/plat-mxc/include/mach/debug-macro.S
@@ -31,6 +31,9 @@
31#ifdef CONFIG_MACH_MX31_3DS 31#ifdef CONFIG_MACH_MX31_3DS
32#include <mach/board-mx31pdk.h> 32#include <mach/board-mx31pdk.h>
33#endif 33#endif
34#ifdef CONFIG_MACH_QONG
35#include <mach/board-qong.h>
36#endif
34 .macro addruart,rx 37 .macro addruart,rx
35 mrc p15, 0, \rx, c1, c0 38 mrc p15, 0, \rx, c1, c0
36 tst \rx, #1 @ MMU enabled? 39 tst \rx, #1 @ MMU enabled?
diff --git a/arch/arm/plat-mxc/include/mach/hardware.h b/arch/arm/plat-mxc/include/mach/hardware.h
index a612d8bb73c8..42e4ee37ca1f 100644
--- a/arch/arm/plat-mxc/include/mach/hardware.h
+++ b/arch/arm/plat-mxc/include/mach/hardware.h
@@ -23,10 +23,16 @@
23#include <asm/sizes.h> 23#include <asm/sizes.h>
24 24
25#ifdef CONFIG_ARCH_MX3 25#ifdef CONFIG_ARCH_MX3
26# include <mach/mx31.h> 26#include <mach/mx3x.h>
27#include <mach/mx31.h>
28#include <mach/mx35.h>
27#endif 29#endif
28 30
29#ifdef CONFIG_ARCH_MX2 31#ifdef CONFIG_ARCH_MX2
32# include <mach/mx2x.h>
33# ifdef CONFIG_MACH_MX21
34# include <mach/mx21.h>
35# endif
30# ifdef CONFIG_MACH_MX27 36# ifdef CONFIG_MACH_MX27
31# include <mach/mx27.h> 37# include <mach/mx27.h>
32# endif 38# endif
diff --git a/arch/arm/mach-imx/include/mach/imxfb.h b/arch/arm/plat-mxc/include/mach/imxfb.h
index 870d0d939616..762a7b0430e2 100644
--- a/arch/arm/mach-imx/include/mach/imxfb.h
+++ b/arch/arm/plat-mxc/include/mach/imxfb.h
@@ -76,6 +76,9 @@ struct imx_fb_platform_data {
76 u_char * fixed_screen_cpu; 76 u_char * fixed_screen_cpu;
77 dma_addr_t fixed_screen_dma; 77 dma_addr_t fixed_screen_dma;
78 78
79 int (*init)(struct platform_device*);
80 int (*exit)(struct platform_device*);
81
79 void (*lcd_power)(int); 82 void (*lcd_power)(int);
80 void (*backlight_power)(int); 83 void (*backlight_power)(int);
81}; 84};
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx1-mx2.h b/arch/arm/plat-mxc/include/mach/iomux-mx1-mx2.h
deleted file mode 100644
index 95a383be628e..000000000000
--- a/arch/arm/plat-mxc/include/mach/iomux-mx1-mx2.h
+++ /dev/null
@@ -1,416 +0,0 @@
1/*
2 * Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16 * MA 02110-1301, USA.
17 */
18
19#ifndef _MXC_GPIO_MX1_MX2_H
20#define _MXC_GPIO_MX1_MX2_H
21
22#include <linux/io.h>
23
24/*
25 * GPIO Module and I/O Multiplexer
26 * x = 0..3 for reg_A, reg_B, reg_C, reg_D
27 */
28#define VA_GPIO_BASE IO_ADDRESS(GPIO_BASE_ADDR)
29#define MXC_DDIR(x) (0x00 + ((x) << 8))
30#define MXC_OCR1(x) (0x04 + ((x) << 8))
31#define MXC_OCR2(x) (0x08 + ((x) << 8))
32#define MXC_ICONFA1(x) (0x0c + ((x) << 8))
33#define MXC_ICONFA2(x) (0x10 + ((x) << 8))
34#define MXC_ICONFB1(x) (0x14 + ((x) << 8))
35#define MXC_ICONFB2(x) (0x18 + ((x) << 8))
36#define MXC_DR(x) (0x1c + ((x) << 8))
37#define MXC_GIUS(x) (0x20 + ((x) << 8))
38#define MXC_SSR(x) (0x24 + ((x) << 8))
39#define MXC_ICR1(x) (0x28 + ((x) << 8))
40#define MXC_ICR2(x) (0x2c + ((x) << 8))
41#define MXC_IMR(x) (0x30 + ((x) << 8))
42#define MXC_ISR(x) (0x34 + ((x) << 8))
43#define MXC_GPR(x) (0x38 + ((x) << 8))
44#define MXC_SWR(x) (0x3c + ((x) << 8))
45#define MXC_PUEN(x) (0x40 + ((x) << 8))
46
47#ifdef CONFIG_ARCH_MX1
48# define GPIO_PORT_MAX 3
49#endif
50#ifdef CONFIG_ARCH_MX2
51# define GPIO_PORT_MAX 5
52#endif
53
54#ifndef GPIO_PORT_MAX
55# error "GPIO config port count unknown!"
56#endif
57
58#define GPIO_PIN_MASK 0x1f
59
60#define GPIO_PORT_SHIFT 5
61#define GPIO_PORT_MASK (0x7 << GPIO_PORT_SHIFT)
62
63#define GPIO_PORTA (0 << GPIO_PORT_SHIFT)
64#define GPIO_PORTB (1 << GPIO_PORT_SHIFT)
65#define GPIO_PORTC (2 << GPIO_PORT_SHIFT)
66#define GPIO_PORTD (3 << GPIO_PORT_SHIFT)
67#define GPIO_PORTE (4 << GPIO_PORT_SHIFT)
68#define GPIO_PORTF (5 << GPIO_PORT_SHIFT)
69
70#define GPIO_OUT (1 << 8)
71#define GPIO_IN (0 << 8)
72#define GPIO_PUEN (1 << 9)
73
74#define GPIO_PF (1 << 10)
75#define GPIO_AF (1 << 11)
76
77#define GPIO_OCR_SHIFT 12
78#define GPIO_OCR_MASK (3 << GPIO_OCR_SHIFT)
79#define GPIO_AIN (0 << GPIO_OCR_SHIFT)
80#define GPIO_BIN (1 << GPIO_OCR_SHIFT)
81#define GPIO_CIN (2 << GPIO_OCR_SHIFT)
82#define GPIO_GPIO (3 << GPIO_OCR_SHIFT)
83
84#define GPIO_AOUT_SHIFT 14
85#define GPIO_AOUT_MASK (3 << GPIO_AOUT_SHIFT)
86#define GPIO_AOUT (0 << GPIO_AOUT_SHIFT)
87#define GPIO_AOUT_ISR (1 << GPIO_AOUT_SHIFT)
88#define GPIO_AOUT_0 (2 << GPIO_AOUT_SHIFT)
89#define GPIO_AOUT_1 (3 << GPIO_AOUT_SHIFT)
90
91#define GPIO_BOUT_SHIFT 16
92#define GPIO_BOUT_MASK (3 << GPIO_BOUT_SHIFT)
93#define GPIO_BOUT (0 << GPIO_BOUT_SHIFT)
94#define GPIO_BOUT_ISR (1 << GPIO_BOUT_SHIFT)
95#define GPIO_BOUT_0 (2 << GPIO_BOUT_SHIFT)
96#define GPIO_BOUT_1 (3 << GPIO_BOUT_SHIFT)
97
98extern void mxc_gpio_mode(int gpio_mode);
99extern int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count,
100 const char *label);
101extern void mxc_gpio_release_multiple_pins(const int *pin_list, int count);
102
103/*-------------------------------------------------------------------------*/
104
105/* assignements for GPIO alternate/primary functions */
106
107/* FIXME: This list is not completed. The correct directions are
108 * missing on some (many) pins
109 */
110#ifdef CONFIG_ARCH_MX1
111#define PA0_AIN_SPI2_CLK (GPIO_PORTA | GPIO_OUT | 0)
112#define PA0_AF_ETMTRACESYNC (GPIO_PORTA | GPIO_AF | 0)
113#define PA1_AOUT_SPI2_RXD (GPIO_PORTA | GPIO_IN | 1)
114#define PA1_PF_TIN (GPIO_PORTA | GPIO_PF | 1)
115#define PA2_PF_PWM0 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 2)
116#define PA3_PF_CSI_MCLK (GPIO_PORTA | GPIO_PF | 3)
117#define PA4_PF_CSI_D0 (GPIO_PORTA | GPIO_PF | 4)
118#define PA5_PF_CSI_D1 (GPIO_PORTA | GPIO_PF | 5)
119#define PA6_PF_CSI_D2 (GPIO_PORTA | GPIO_PF | 6)
120#define PA7_PF_CSI_D3 (GPIO_PORTA | GPIO_PF | 7)
121#define PA8_PF_CSI_D4 (GPIO_PORTA | GPIO_PF | 8)
122#define PA9_PF_CSI_D5 (GPIO_PORTA | GPIO_PF | 9)
123#define PA10_PF_CSI_D6 (GPIO_PORTA | GPIO_PF | 10)
124#define PA11_PF_CSI_D7 (GPIO_PORTA | GPIO_PF | 11)
125#define PA12_PF_CSI_VSYNC (GPIO_PORTA | GPIO_PF | 12)
126#define PA13_PF_CSI_HSYNC (GPIO_PORTA | GPIO_PF | 13)
127#define PA14_PF_CSI_PIXCLK (GPIO_PORTA | GPIO_PF | 14)
128#define PA15_PF_I2C_SDA (GPIO_PORTA | GPIO_OUT | GPIO_PF | 15)
129#define PA16_PF_I2C_SCL (GPIO_PORTA | GPIO_OUT | GPIO_PF | 16)
130#define PA17_AF_ETMTRACEPKT4 (GPIO_PORTA | GPIO_AF | 17)
131#define PA17_AIN_SPI2_SS (GPIO_PORTA | GPIO_OUT | 17)
132#define PA18_AF_ETMTRACEPKT5 (GPIO_PORTA | GPIO_AF | 18)
133#define PA19_AF_ETMTRACEPKT6 (GPIO_PORTA | GPIO_AF | 19)
134#define PA20_AF_ETMTRACEPKT7 (GPIO_PORTA | GPIO_AF | 20)
135#define PA21_PF_A0 (GPIO_PORTA | GPIO_PF | 21)
136#define PA22_PF_CS4 (GPIO_PORTA | GPIO_PF | 22)
137#define PA23_PF_CS5 (GPIO_PORTA | GPIO_PF | 23)
138#define PA24_PF_A16 (GPIO_PORTA | GPIO_PF | 24)
139#define PA24_AF_ETMTRACEPKT0 (GPIO_PORTA | GPIO_AF | 24)
140#define PA25_PF_A17 (GPIO_PORTA | GPIO_PF | 25)
141#define PA25_AF_ETMTRACEPKT1 (GPIO_PORTA | GPIO_AF | 25)
142#define PA26_PF_A18 (GPIO_PORTA | GPIO_PF | 26)
143#define PA26_AF_ETMTRACEPKT2 (GPIO_PORTA | GPIO_AF | 26)
144#define PA27_PF_A19 (GPIO_PORTA | GPIO_PF | 27)
145#define PA27_AF_ETMTRACEPKT3 (GPIO_PORTA | GPIO_AF | 27)
146#define PA28_PF_A20 (GPIO_PORTA | GPIO_PF | 28)
147#define PA28_AF_ETMPIPESTAT0 (GPIO_PORTA | GPIO_AF | 28)
148#define PA29_PF_A21 (GPIO_PORTA | GPIO_PF | 29)
149#define PA29_AF_ETMPIPESTAT1 (GPIO_PORTA | GPIO_AF | 29)
150#define PA30_PF_A22 (GPIO_PORTA | GPIO_PF | 30)
151#define PA30_AF_ETMPIPESTAT2 (GPIO_PORTA | GPIO_AF | 30)
152#define PA31_PF_A23 (GPIO_PORTA | GPIO_PF | 31)
153#define PA31_AF_ETMTRACECLK (GPIO_PORTA | GPIO_AF | 31)
154#define PB8_PF_SD_DAT0 (GPIO_PORTB | GPIO_PF | GPIO_PUEN | 8)
155#define PB8_AF_MS_PIO (GPIO_PORTB | GPIO_AF | 8)
156#define PB9_PF_SD_DAT1 (GPIO_PORTB | GPIO_PF | GPIO_PUEN | 9)
157#define PB9_AF_MS_PI1 (GPIO_PORTB | GPIO_AF | 9)
158#define PB10_PF_SD_DAT2 (GPIO_PORTB | GPIO_PF | GPIO_PUEN | 10)
159#define PB10_AF_MS_SCLKI (GPIO_PORTB | GPIO_AF | 10)
160#define PB11_PF_SD_DAT3 (GPIO_PORTB | GPIO_PF | 11)
161#define PB11_AF_MS_SDIO (GPIO_PORTB | GPIO_AF | 11)
162#define PB12_PF_SD_CLK (GPIO_PORTB | GPIO_PF | 12)
163#define PB12_AF_MS_SCLK0 (GPIO_PORTB | GPIO_AF | 12)
164#define PB13_PF_SD_CMD (GPIO_PORTB | GPIO_PF | GPIO_PUEN | 13)
165#define PB13_AF_MS_BS (GPIO_PORTB | GPIO_AF | 13)
166#define PB14_AF_SSI_RXFS (GPIO_PORTB | GPIO_AF | 14)
167#define PB15_AF_SSI_RXCLK (GPIO_PORTB | GPIO_AF | 15)
168#define PB16_AF_SSI_RXDAT (GPIO_PORTB | GPIO_IN | GPIO_AF | 16)
169#define PB17_AF_SSI_TXDAT (GPIO_PORTB | GPIO_OUT | GPIO_AF | 17)
170#define PB18_AF_SSI_TXFS (GPIO_PORTB | GPIO_AF | 18)
171#define PB19_AF_SSI_TXCLK (GPIO_PORTB | GPIO_AF | 19)
172#define PB20_PF_USBD_AFE (GPIO_PORTB | GPIO_PF | 20)
173#define PB21_PF_USBD_OE (GPIO_PORTB | GPIO_PF | 21)
174#define PB22_PFUSBD_RCV (GPIO_PORTB | GPIO_PF | 22)
175#define PB23_PF_USBD_SUSPND (GPIO_PORTB | GPIO_PF | 23)
176#define PB24_PF_USBD_VP (GPIO_PORTB | GPIO_PF | 24)
177#define PB25_PF_USBD_VM (GPIO_PORTB | GPIO_PF | 25)
178#define PB26_PF_USBD_VPO (GPIO_PORTB | GPIO_PF | 26)
179#define PB27_PF_USBD_VMO (GPIO_PORTB | GPIO_PF | 27)
180#define PB28_PF_UART2_CTS (GPIO_PORTB | GPIO_OUT | GPIO_PF | 28)
181#define PB29_PF_UART2_RTS (GPIO_PORTB | GPIO_IN | GPIO_PF | 29)
182#define PB30_PF_UART2_TXD (GPIO_PORTB | GPIO_OUT | GPIO_PF | 30)
183#define PB31_PF_UART2_RXD (GPIO_PORTB | GPIO_IN | GPIO_PF | 31)
184#define PC3_PF_SSI_RXFS (GPIO_PORTC | GPIO_PF | 3)
185#define PC4_PF_SSI_RXCLK (GPIO_PORTC | GPIO_PF | 4)
186#define PC5_PF_SSI_RXDAT (GPIO_PORTC | GPIO_IN | GPIO_PF | 5)
187#define PC6_PF_SSI_TXDAT (GPIO_PORTC | GPIO_OUT | GPIO_PF | 6)
188#define PC7_PF_SSI_TXFS (GPIO_PORTC | GPIO_PF | 7)
189#define PC8_PF_SSI_TXCLK (GPIO_PORTC | GPIO_PF | 8)
190#define PC9_PF_UART1_CTS (GPIO_PORTC | GPIO_OUT | GPIO_PF | 9)
191#define PC10_PF_UART1_RTS (GPIO_PORTC | GPIO_IN | GPIO_PF | 10)
192#define PC11_PF_UART1_TXD (GPIO_PORTC | GPIO_OUT | GPIO_PF | 11)
193#define PC12_PF_UART1_RXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 12)
194#define PC13_PF_SPI1_SPI_RDY (GPIO_PORTC | GPIO_PF | 13)
195#define PC14_PF_SPI1_SCLK (GPIO_PORTC | GPIO_PF | 14)
196#define PC15_PF_SPI1_SS (GPIO_PORTC | GPIO_PF | 15)
197#define PC16_PF_SPI1_MISO (GPIO_PORTC | GPIO_PF | 16)
198#define PC17_PF_SPI1_MOSI (GPIO_PORTC | GPIO_PF | 17)
199#define PC24_BIN_UART3_RI (GPIO_PORTC | GPIO_OUT | GPIO_BIN | 24)
200#define PC25_BIN_UART3_DSR (GPIO_PORTC | GPIO_OUT | GPIO_BIN | 25)
201#define PC26_AOUT_UART3_DTR (GPIO_PORTC | GPIO_IN | 26)
202#define PC27_BIN_UART3_DCD (GPIO_PORTC | GPIO_OUT | GPIO_BIN | 27)
203#define PC28_BIN_UART3_CTS (GPIO_PORTC | GPIO_OUT | GPIO_BIN | 28)
204#define PC29_AOUT_UART3_RTS (GPIO_PORTC | GPIO_IN | 29)
205#define PC30_BIN_UART3_TX (GPIO_PORTC | GPIO_BIN | 30)
206#define PC31_AOUT_UART3_RX (GPIO_PORTC | GPIO_IN | 31)
207#define PD6_PF_LSCLK (GPIO_PORTD | GPIO_OUT | GPIO_PF | 6)
208#define PD7_PF_REV (GPIO_PORTD | GPIO_PF | 7)
209#define PD7_AF_UART2_DTR (GPIO_PORTD | GPIO_IN | GPIO_AF | 7)
210#define PD7_AIN_SPI2_SCLK (GPIO_PORTD | GPIO_AIN | 7)
211#define PD8_PF_CLS (GPIO_PORTD | GPIO_PF | 8)
212#define PD8_AF_UART2_DCD (GPIO_PORTD | GPIO_OUT | GPIO_AF | 8)
213#define PD8_AIN_SPI2_SS (GPIO_PORTD | GPIO_AIN | 8)
214#define PD9_PF_PS (GPIO_PORTD | GPIO_PF | 9)
215#define PD9_AF_UART2_RI (GPIO_PORTD | GPIO_OUT | GPIO_AF | 9)
216#define PD9_AOUT_SPI2_RXD (GPIO_PORTD | GPIO_IN | 9)
217#define PD10_PF_SPL_SPR (GPIO_PORTD | GPIO_OUT | GPIO_PF | 10)
218#define PD10_AF_UART2_DSR (GPIO_PORTD | GPIO_OUT | GPIO_AF | 10)
219#define PD10_AIN_SPI2_TXD (GPIO_PORTD | GPIO_OUT | 10)
220#define PD11_PF_CONTRAST (GPIO_PORTD | GPIO_OUT | GPIO_PF | 11)
221#define PD12_PF_ACD_OE (GPIO_PORTD | GPIO_OUT | GPIO_PF | 12)
222#define PD13_PF_LP_HSYNC (GPIO_PORTD | GPIO_OUT | GPIO_PF | 13)
223#define PD14_PF_FLM_VSYNC (GPIO_PORTD | GPIO_OUT | GPIO_PF | 14)
224#define PD15_PF_LD0 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 15)
225#define PD16_PF_LD1 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 16)
226#define PD17_PF_LD2 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 17)
227#define PD18_PF_LD3 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 18)
228#define PD19_PF_LD4 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 19)
229#define PD20_PF_LD5 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 20)
230#define PD21_PF_LD6 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 21)
231#define PD22_PF_LD7 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 22)
232#define PD23_PF_LD8 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 23)
233#define PD24_PF_LD9 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 24)
234#define PD25_PF_LD10 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 25)
235#define PD26_PF_LD11 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 26)
236#define PD27_PF_LD12 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 27)
237#define PD28_PF_LD13 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 28)
238#define PD29_PF_LD14 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 29)
239#define PD30_PF_LD15 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 30)
240#define PD31_PF_TMR2OUT (GPIO_PORTD | GPIO_PF | 31)
241#define PD31_BIN_SPI2_TXD (GPIO_PORTD | GPIO_BIN | 31)
242#endif
243
244#ifdef CONFIG_ARCH_MX2
245#define PA0_PF_USBH2_CLK (GPIO_PORTA | GPIO_PF | 0)
246#define PA1_PF_USBH2_DIR (GPIO_PORTA | GPIO_PF | 1)
247#define PA2_PF_USBH2_DATA7 (GPIO_PORTA | GPIO_PF | 2)
248#define PA3_PF_USBH2_NXT (GPIO_PORTA | GPIO_PF | 3)
249#define PA4_PF_USBH2_STP (GPIO_PORTA | GPIO_PF | 4)
250#define PA5_PF_LSCLK (GPIO_PORTA | GPIO_OUT | GPIO_PF | 5)
251#define PA6_PF_LD0 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 6)
252#define PA7_PF_LD1 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 7)
253#define PA8_PF_LD2 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 8)
254#define PA9_PF_LD3 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 9)
255#define PA10_PF_LD4 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 10)
256#define PA11_PF_LD5 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 11)
257#define PA12_PF_LD6 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 12)
258#define PA13_PF_LD7 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 13)
259#define PA14_PF_LD8 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 14)
260#define PA15_PF_LD9 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 15)
261#define PA16_PF_LD10 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 16)
262#define PA17_PF_LD11 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 17)
263#define PA18_PF_LD12 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 18)
264#define PA19_PF_LD13 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 19)
265#define PA20_PF_LD14 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 20)
266#define PA21_PF_LD15 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 21)
267#define PA22_PF_LD16 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 22)
268#define PA23_PF_LD17 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 23)
269#define PA24_PF_REV (GPIO_PORTA | GPIO_OUT | GPIO_PF | 24)
270#define PA25_PF_CLS (GPIO_PORTA | GPIO_OUT | GPIO_PF | 25)
271#define PA26_PF_PS (GPIO_PORTA | GPIO_OUT | GPIO_PF | 26)
272#define PA27_PF_SPL_SPR (GPIO_PORTA | GPIO_OUT | GPIO_PF | 27)
273#define PA28_PF_HSYNC (GPIO_PORTA | GPIO_OUT | GPIO_PF | 28)
274#define PA29_PF_VSYNC (GPIO_PORTA | GPIO_OUT | GPIO_PF | 29)
275#define PA30_PF_CONTRAST (GPIO_PORTA | GPIO_OUT | GPIO_PF | 30)
276#define PA31_PF_OE_ACD (GPIO_PORTA | GPIO_OUT | GPIO_PF | 31)
277#define PB4_PF_SD2_D0 (GPIO_PORTB | GPIO_PF | 4)
278#define PB5_PF_SD2_D1 (GPIO_PORTB | GPIO_PF | 5)
279#define PB6_PF_SD2_D2 (GPIO_PORTB | GPIO_PF | 6)
280#define PB7_PF_SD2_D3 (GPIO_PORTB | GPIO_PF | 7)
281#define PB8_PF_SD2_CMD (GPIO_PORTB | GPIO_PF | 8)
282#define PB9_PF_SD2_CLK (GPIO_PORTB | GPIO_PF | 9)
283#define PB10_PF_CSI_D0 (GPIO_PORTB | GPIO_OUT | GPIO_PF | 10)
284#define PB10_AF_UART6_TXD (GPIO_PORTB | GPIO_OUT | GPIO_AF | 10)
285#define PB11_PF_CSI_D1 (GPIO_PORTB | GPIO_OUT | GPIO_PF | 11)
286#define PB11_AF_UART6_RXD (GPIO_PORTB | GPIO_IN | GPIO_AF | 11)
287#define PB12_PF_CSI_D2 (GPIO_PORTB | GPIO_OUT | GPIO_PF | 12)
288#define PB12_AF_UART6_CTS (GPIO_PORTB | GPIO_OUT | GPIO_AF | 12)
289#define PB13_PF_CSI_D3 (GPIO_PORTB | GPIO_OUT | GPIO_PF | 13)
290#define PB13_AF_UART6_RTS (GPIO_PORTB | GPIO_IN | GPIO_AF | 13)
291#define PB14_PF_CSI_D4 (GPIO_PORTB | GPIO_OUT | GPIO_PF | 14)
292#define PB15_PF_CSI_MCLK (GPIO_PORTB | GPIO_OUT | GPIO_PF | 15)
293#define PB16_PF_CSI_PIXCLK (GPIO_PORTB | GPIO_OUT | GPIO_PF | 16)
294#define PB17_PF_CSI_D5 (GPIO_PORTB | GPIO_OUT | GPIO_PF | 17)
295#define PB18_PF_CSI_D6 (GPIO_PORTB | GPIO_OUT | GPIO_PF | 18)
296#define PB18_AF_UART5_TXD (GPIO_PORTB | GPIO_OUT | GPIO_AF | 18)
297#define PB19_PF_CSI_D7 (GPIO_PORTB | GPIO_OUT | GPIO_PF | 19)
298#define PB19_AF_UART5_RXD (GPIO_PORTB | GPIO_IN | GPIO_AF | 19)
299#define PB20_PF_CSI_VSYNC (GPIO_PORTB | GPIO_OUT | GPIO_PF | 20)
300#define PB20_AF_UART5_CTS (GPIO_PORTB | GPIO_OUT | GPIO_AF | 20)
301#define PB21_PF_CSI_HSYNC (GPIO_PORTB | GPIO_OUT | GPIO_PF | 21)
302#define PB21_AF_UART5_RTS (GPIO_PORTB | GPIO_IN | GPIO_AF | 21)
303#define PB22_PF_USBH1_SUSP (GPIO_PORTB | GPIO_PF | 22)
304#define PB23_PF_USB_PWR (GPIO_PORTB | GPIO_PF | 23)
305#define PB24_PF_USB_OC_B (GPIO_PORTB | GPIO_PF | 24)
306#define PB25_PF_USBH1_RCV (GPIO_PORTB | GPIO_PF | 25)
307#define PB26_PF_USBH1_FS (GPIO_PORTB | GPIO_PF | 26)
308#define PB27_PF_USBH1_OE_B (GPIO_PORTB | GPIO_PF | 27)
309#define PB28_PF_USBH1_TXDM (GPIO_PORTB | GPIO_PF | 28)
310#define PB29_PF_USBH1_TXDP (GPIO_PORTB | GPIO_PF | 29)
311#define PB30_PF_USBH1_RXDM (GPIO_PORTB | GPIO_PF | 30)
312#define PB31_PF_USBH1_RXDP (GPIO_PORTB | GPIO_PF | 31)
313#define PB26_AF_UART4_RTS (GPIO_PORTB | GPIO_IN | GPIO_PF | 26)
314#define PB28_AF_UART4_TXD (GPIO_PORTB | GPIO_OUT | GPIO_AF | 28)
315#define PB29_AF_UART4_CTS (GPIO_PORTB | GPIO_OUT | GPIO_AF | 29)
316#define PB31_AF_UART4_RXD (GPIO_PORTB | GPIO_IN | GPIO_AF | 31)
317#define PC5_PF_I2C2_SDA (GPIO_PORTC | GPIO_IN | GPIO_PF | 5)
318#define PC6_PF_I2C2_SCL (GPIO_PORTC | GPIO_IN | GPIO_PF | 6)
319#define PC7_PF_USBOTG_DATA5 (GPIO_PORTC | GPIO_OUT | GPIO_PF | 7)
320#define PC8_PF_USBOTG_DATA6 (GPIO_PORTC | GPIO_OUT | GPIO_PF | 8)
321#define PC9_PF_USBOTG_DATA0 (GPIO_PORTC | GPIO_OUT | GPIO_PF | 9)
322#define PC10_PF_USBOTG_DATA2 (GPIO_PORTC | GPIO_OUT | GPIO_PF | 10)
323#define PC11_PF_USBOTG_DATA1 (GPIO_PORTC | GPIO_OUT | GPIO_PF | 11)
324#define PC12_PF_USBOTG_DATA4 (GPIO_PORTC | GPIO_OUT | GPIO_PF | 12)
325#define PC13_PF_USBOTG_DATA3 (GPIO_PORTC | GPIO_OUT | GPIO_PF | 13)
326#define PC16_PF_SSI4_FS (GPIO_PORTC | GPIO_IN | GPIO_PF | 16)
327#define PC17_PF_SSI4_RXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 17)
328#define PC18_PF_SSI4_TXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 18)
329#define PC19_PF_SSI4_CLK (GPIO_PORTC | GPIO_IN | GPIO_PF | 19)
330#define PC20_PF_SSI1_FS (GPIO_PORTC | GPIO_IN | GPIO_PF | 20)
331#define PC21_PF_SSI1_RXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 21)
332#define PC22_PF_SSI1_TXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 22)
333#define PC23_PF_SSI1_CLK (GPIO_PORTC | GPIO_IN | GPIO_PF | 23)
334#define PC24_PF_SSI2_FS (GPIO_PORTC | GPIO_IN | GPIO_PF | 24)
335#define PC25_PF_SSI2_RXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 25)
336#define PC26_PF_SSI2_TXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 26)
337#define PC27_PF_SSI2_CLK (GPIO_PORTC | GPIO_IN | GPIO_PF | 27)
338#define PC28_PF_SSI3_FS (GPIO_PORTC | GPIO_IN | GPIO_PF | 28)
339#define PC29_PF_SSI3_RXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 29)
340#define PC30_PF_SSI3_TXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 30)
341#define PC31_PF_SSI3_CLK (GPIO_PORTC | GPIO_IN | GPIO_PF | 31)
342#define PD0_AIN_FEC_TXD0 (GPIO_PORTD | GPIO_OUT | GPIO_AIN | 0)
343#define PD1_AIN_FEC_TXD1 (GPIO_PORTD | GPIO_OUT | GPIO_AIN | 1)
344#define PD2_AIN_FEC_TXD2 (GPIO_PORTD | GPIO_OUT | GPIO_AIN | 2)
345#define PD3_AIN_FEC_TXD3 (GPIO_PORTD | GPIO_OUT | GPIO_AIN | 3)
346#define PD4_AOUT_FEC_RX_ER (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 4)
347#define PD5_AOUT_FEC_RXD1 (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 5)
348#define PD6_AOUT_FEC_RXD2 (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 6)
349#define PD7_AOUT_FEC_RXD3 (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 7)
350#define PD8_AF_FEC_MDIO (GPIO_PORTD | GPIO_IN | GPIO_AF | 8)
351#define PD9_AIN_FEC_MDC (GPIO_PORTD | GPIO_OUT | GPIO_AIN | 9)
352#define PD10_AOUT_FEC_CRS (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 10)
353#define PD11_AOUT_FEC_TX_CLK (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 11)
354#define PD12_AOUT_FEC_RXD0 (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 12)
355#define PD13_AOUT_FEC_RX_DV (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 13)
356#define PD14_AOUT_FEC_CLR (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 14)
357#define PD15_AOUT_FEC_COL (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 15)
358#define PD16_AIN_FEC_TX_ER (GPIO_PORTD | GPIO_OUT | GPIO_AIN | 16)
359#define PD17_PF_I2C_DATA (GPIO_PORTD | GPIO_OUT | GPIO_PF | 17)
360#define PD18_PF_I2C_CLK (GPIO_PORTD | GPIO_OUT | GPIO_PF | 18)
361#define PD19_AF_USBH2_DATA4 (GPIO_PORTD | GPIO_AF | 19)
362#define PD20_AF_USBH2_DATA3 (GPIO_PORTD | GPIO_AF | 20)
363#define PD21_AF_USBH2_DATA6 (GPIO_PORTD | GPIO_AF | 21)
364#define PD22_AF_USBH2_DATA0 (GPIO_PORTD | GPIO_AF | 22)
365#define PD23_AF_USBH2_DATA2 (GPIO_PORTD | GPIO_AF | 23)
366#define PD24_AF_USBH2_DATA1 (GPIO_PORTD | GPIO_AF | 24)
367#define PD25_PF_CSPI1_RDY (GPIO_PORTD | GPIO_OUT | GPIO_PF | 25)
368#define PD26_PF_CSPI1_SS2 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 26)
369#define PD26_AF_USBH2_DATA5 (GPIO_PORTD | GPIO_AF | 26)
370#define PD27_PF_CSPI1_SS1 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 27)
371#define PD28_PF_CSPI1_SS0 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 28)
372#define PD29_PF_CSPI1_SCLK (GPIO_PORTD | GPIO_OUT | GPIO_PF | 29)
373#define PD30_PF_CSPI1_MISO (GPIO_PORTD | GPIO_IN | GPIO_PF | 30)
374#define PD31_PF_CSPI1_MOSI (GPIO_PORTD | GPIO_OUT | GPIO_PF | 31)
375#define PF23_AIN_FEC_TX_EN (GPIO_PORTF | GPIO_OUT | GPIO_AIN | 23)
376#define PE0_PF_USBOTG_NXT (GPIO_PORTE | GPIO_OUT | GPIO_PF | 0)
377#define PE1_PF_USBOTG_STP (GPIO_PORTE | GPIO_OUT | GPIO_PF | 1)
378#define PE2_PF_USBOTG_DIR (GPIO_PORTE | GPIO_OUT | GPIO_PF | 2)
379#define PE3_PF_UART2_CTS (GPIO_PORTE | GPIO_OUT | GPIO_PF | 3)
380#define PE4_PF_UART2_RTS (GPIO_PORTE | GPIO_IN | GPIO_PF | 4)
381#define PE6_PF_UART2_TXD (GPIO_PORTE | GPIO_OUT | GPIO_PF | 6)
382#define PE7_PF_UART2_RXD (GPIO_PORTE | GPIO_IN | GPIO_PF | 7)
383#define PE8_PF_UART3_TXD (GPIO_PORTE | GPIO_OUT | GPIO_PF | 8)
384#define PE9_PF_UART3_RXD (GPIO_PORTE | GPIO_IN | GPIO_PF | 9)
385#define PE10_PF_UART3_CTS (GPIO_PORTE | GPIO_OUT | GPIO_PF | 10)
386#define PE11_PF_UART3_RTS (GPIO_PORTE | GPIO_IN | GPIO_PF | 11)
387#define PE12_PF_UART1_TXD (GPIO_PORTE | GPIO_OUT | GPIO_PF | 12)
388#define PE13_PF_UART1_RXD (GPIO_PORTE | GPIO_IN | GPIO_PF | 13)
389#define PE14_PF_UART1_CTS (GPIO_PORTE | GPIO_OUT | GPIO_PF | 14)
390#define PE15_PF_UART1_RTS (GPIO_PORTE | GPIO_IN | GPIO_PF | 15)
391#define PE16_AF_RTCK (GPIO_PORTE | GPIO_OUT | GPIO_AF | 16)
392#define PE16_PF_RTCK (GPIO_PORTE | GPIO_OUT | GPIO_PF | 16)
393#define PE18_PF_SDHC1_D0 (GPIO_PORTE | GPIO_PF | 18)
394#define PE18_AF_CSPI3_MISO (GPIO_PORTE | GPIO_IN | GPIO_AF | 18)
395#define PE19_PF_SDHC1_D1 (GPIO_PORTE | GPIO_PF | 19)
396#define PE20_PF_SDHC1_D2 (GPIO_PORTE | GPIO_PF | 20)
397#define PE21_PF_SDHC1_D3 (GPIO_PORTE | GPIO_PF | 21)
398#define PE21_AF_CSPI3_SS (GPIO_PORTE | GPIO_OUT | GPIO_AF | 21)
399#define PE22_PF_SDHC1_CMD (GPIO_PORTE | GPIO_PF | 22)
400#define PE22_AF_CSPI3_MOSI (GPIO_PORTE | GPIO_OUT | GPIO_AF | 22)
401#define PE22_PF_SDHC1_CLK (GPIO_PORTE | GPIO_PF | 23)
402#define PE23_AF_CSPI3_SCLK (GPIO_PORTE | GPIO_OUT | GPIO_AF | 23)
403#define PE24_PF_USBOTG_CLK (GPIO_PORTE | GPIO_OUT | GPIO_PF | 24)
404#define PE25_PF_USBOTG_DATA7 (GPIO_PORTE | GPIO_OUT | GPIO_PF | 25)
405#endif
406
407/* decode irq number to use with IMR(x), ISR(x) and friends */
408#define IRQ_TO_REG(irq) ((irq - MXC_INTERNAL_IRQS) >> 5)
409
410#define IRQ_GPIOA(x) (MXC_GPIO_IRQ_START + x)
411#define IRQ_GPIOB(x) (IRQ_GPIOA(32) + x)
412#define IRQ_GPIOC(x) (IRQ_GPIOB(32) + x)
413#define IRQ_GPIOD(x) (IRQ_GPIOC(32) + x)
414#define IRQ_GPIOE(x) (IRQ_GPIOD(32) + x)
415
416#endif /* _MXC_GPIO_MX1_MX2_H */
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx1.h b/arch/arm/plat-mxc/include/mach/iomux-mx1.h
new file mode 100644
index 000000000000..bf23305c19cc
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/iomux-mx1.h
@@ -0,0 +1,166 @@
1/*
2* Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de>
3*
4* This program is free software; you can redistribute it and/or
5* modify it under the terms of the GNU General Public License
6* as published by the Free Software Foundation; either version 2
7* of the License, or (at your option) any later version.
8* This program is distributed in the hope that it will be useful,
9* but WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program; if not, write to the Free Software
15* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16* MA 02110-1301, USA.
17*/
18
19#ifndef _MXC_IOMUX_MX1_H
20#define _MXC_IOMUX_MX1_H
21
22#ifndef GPIO_PORTA
23#error Please include mach/iomux.h
24#endif
25
26/* FIXME: This list is not completed. The correct directions are
27* missing on some (many) pins
28*/
29
30
31/* Primary GPIO pin functions */
32
33#define PA0_AIN_SPI2_CLK (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 0)
34#define PA0_AF_ETMTRACESYNC (GPIO_PORTA | GPIO_AF | 0)
35#define PA1_AOUT_SPI2_RXD (GPIO_PORTA | GPIO_AOUT | GPIO_IN | 1)
36#define PA1_PF_TIN (GPIO_PORTA | GPIO_PF | 1)
37#define PA2_PF_PWM0 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 2)
38#define PA3_PF_CSI_MCLK (GPIO_PORTA | GPIO_PF | 3)
39#define PA4_PF_CSI_D0 (GPIO_PORTA | GPIO_PF | 4)
40#define PA5_PF_CSI_D1 (GPIO_PORTA | GPIO_PF | 5)
41#define PA6_PF_CSI_D2 (GPIO_PORTA | GPIO_PF | 6)
42#define PA7_PF_CSI_D3 (GPIO_PORTA | GPIO_PF | 7)
43#define PA8_PF_CSI_D4 (GPIO_PORTA | GPIO_PF | 8)
44#define PA9_PF_CSI_D5 (GPIO_PORTA | GPIO_PF | 9)
45#define PA10_PF_CSI_D6 (GPIO_PORTA | GPIO_PF | 10)
46#define PA11_PF_CSI_D7 (GPIO_PORTA | GPIO_PF | 11)
47#define PA12_PF_CSI_VSYNC (GPIO_PORTA | GPIO_PF | 12)
48#define PA13_PF_CSI_HSYNC (GPIO_PORTA | GPIO_PF | 13)
49#define PA14_PF_CSI_PIXCLK (GPIO_PORTA | GPIO_PF | 14)
50#define PA15_PF_I2C_SDA (GPIO_PORTA | GPIO_PF | GPIO_OUT | 15)
51#define PA16_PF_I2C_SCL (GPIO_PORTA | GPIO_PF | GPIO_OUT | 16)
52#define PA17_AF_ETMTRACEPKT4 (GPIO_PORTA | GPIO_AF | 17)
53#define PA17_AIN_SPI2_SS (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 17)
54#define PA18_AF_ETMTRACEPKT5 (GPIO_PORTA | GPIO_AF | 18)
55#define PA19_AF_ETMTRACEPKT6 (GPIO_PORTA | GPIO_AF | 19)
56#define PA20_AF_ETMTRACEPKT7 (GPIO_PORTA | GPIO_AF | 20)
57#define PA21_PF_A0 (GPIO_PORTA | GPIO_PF | 21)
58#define PA22_PF_CS4 (GPIO_PORTA | GPIO_PF | 22)
59#define PA23_PF_CS5 (GPIO_PORTA | GPIO_PF | 23)
60#define PA24_PF_A16 (GPIO_PORTA | GPIO_PF | 24)
61#define PA24_AF_ETMTRACEPKT0 (GPIO_PORTA | GPIO_AF | 24)
62#define PA25_PF_A17 (GPIO_PORTA | GPIO_PF | 25)
63#define PA25_AF_ETMTRACEPKT1 (GPIO_PORTA | GPIO_AF | 25)
64#define PA26_PF_A18 (GPIO_PORTA | GPIO_PF | 26)
65#define PA26_AF_ETMTRACEPKT2 (GPIO_PORTA | GPIO_AF | 26)
66#define PA27_PF_A19 (GPIO_PORTA | GPIO_PF | 27)
67#define PA27_AF_ETMTRACEPKT3 (GPIO_PORTA | GPIO_AF | 27)
68#define PA28_PF_A20 (GPIO_PORTA | GPIO_PF | 28)
69#define PA28_AF_ETMPIPESTAT0 (GPIO_PORTA | GPIO_AF | 28)
70#define PA29_PF_A21 (GPIO_PORTA | GPIO_PF | 29)
71#define PA29_AF_ETMPIPESTAT1 (GPIO_PORTA | GPIO_AF | 29)
72#define PA30_PF_A22 (GPIO_PORTA | GPIO_PF | 30)
73#define PA30_AF_ETMPIPESTAT2 (GPIO_PORTA | GPIO_AF | 30)
74#define PA31_PF_A23 (GPIO_PORTA | GPIO_PF | 31)
75#define PA31_AF_ETMTRACECLK (GPIO_PORTA | GPIO_AF | 31)
76#define PB8_PF_SD_DAT0 (GPIO_PORTB | GPIO_PF | GPIO_PUEN | 8)
77#define PB8_AF_MS_PIO (GPIO_PORTB | GPIO_AF | 8)
78#define PB9_PF_SD_DAT1 (GPIO_PORTB | GPIO_PF | GPIO_PUEN | 9)
79#define PB9_AF_MS_PI1 (GPIO_PORTB | GPIO_AF | 9)
80#define PB10_PF_SD_DAT2 (GPIO_PORTB | GPIO_PF | GPIO_PUEN | 10)
81#define PB10_AF_MS_SCLKI (GPIO_PORTB | GPIO_AF | 10)
82#define PB11_PF_SD_DAT3 (GPIO_PORTB | GPIO_PF | 11)
83#define PB11_AF_MS_SDIO (GPIO_PORTB | GPIO_AF | 11)
84#define PB12_PF_SD_CLK (GPIO_PORTB | GPIO_PF | 12)
85#define PB12_AF_MS_SCLK0 (GPIO_PORTB | GPIO_AF | 12)
86#define PB13_PF_SD_CMD (GPIO_PORTB | GPIO_PF | GPIO_PUEN | 13)
87#define PB13_AF_MS_BS (GPIO_PORTB | GPIO_AF | 13)
88#define PB14_AF_SSI_RXFS (GPIO_PORTB | GPIO_AF | 14)
89#define PB15_AF_SSI_RXCLK (GPIO_PORTB | GPIO_AF | 15)
90#define PB16_AF_SSI_RXDAT (GPIO_PORTB | GPIO_AF | GPIO_IN | 16)
91#define PB17_AF_SSI_TXDAT (GPIO_PORTB | GPIO_AF | GPIO_OUT | 17)
92#define PB18_AF_SSI_TXFS (GPIO_PORTB | GPIO_AF | 18)
93#define PB19_AF_SSI_TXCLK (GPIO_PORTB | GPIO_AF | 19)
94#define PB20_PF_USBD_AFE (GPIO_PORTB | GPIO_PF | 20)
95#define PB21_PF_USBD_OE (GPIO_PORTB | GPIO_PF | 21)
96#define PB22_PF_USBD_RCV (GPIO_PORTB | GPIO_PF | 22)
97#define PB23_PF_USBD_SUSPND (GPIO_PORTB | GPIO_PF | 23)
98#define PB24_PF_USBD_VP (GPIO_PORTB | GPIO_PF | 24)
99#define PB25_PF_USBD_VM (GPIO_PORTB | GPIO_PF | 25)
100#define PB26_PF_USBD_VPO (GPIO_PORTB | GPIO_PF | 26)
101#define PB27_PF_USBD_VMO (GPIO_PORTB | GPIO_PF | 27)
102#define PB28_PF_UART2_CTS (GPIO_PORTB | GPIO_PF | GPIO_OUT | 28)
103#define PB29_PF_UART2_RTS (GPIO_PORTB | GPIO_PF | GPIO_IN | 29)
104#define PB30_PF_UART2_TXD (GPIO_PORTB | GPIO_PF | GPIO_OUT | 30)
105#define PB31_PF_UART2_RXD (GPIO_PORTB | GPIO_PF | GPIO_IN | 31)
106#define PC3_PF_SSI_RXFS (GPIO_PORTC | GPIO_PF | 3)
107#define PC4_PF_SSI_RXCLK (GPIO_PORTC | GPIO_PF | 4)
108#define PC5_PF_SSI_RXDAT (GPIO_PORTC | GPIO_PF | GPIO_IN | 5)
109#define PC6_PF_SSI_TXDAT (GPIO_PORTC | GPIO_PF | GPIO_OUT | 6)
110#define PC7_PF_SSI_TXFS (GPIO_PORTC | GPIO_PF | 7)
111#define PC8_PF_SSI_TXCLK (GPIO_PORTC | GPIO_PF | 8)
112#define PC9_PF_UART1_CTS (GPIO_PORTC | GPIO_PF | GPIO_OUT | 9)
113#define PC10_PF_UART1_RTS (GPIO_PORTC | GPIO_PF | GPIO_IN | 10)
114#define PC11_PF_UART1_TXD (GPIO_PORTC | GPIO_PF | GPIO_OUT | 11)
115#define PC12_PF_UART1_RXD (GPIO_PORTC | GPIO_PF | GPIO_IN | 12)
116#define PC13_PF_SPI1_SPI_RDY (GPIO_PORTC | GPIO_PF | 13)
117#define PC14_PF_SPI1_SCLK (GPIO_PORTC | GPIO_PF | 14)
118#define PC15_PF_SPI1_SS (GPIO_PORTC | GPIO_PF | 15)
119#define PC16_PF_SPI1_MISO (GPIO_PORTC | GPIO_PF | 16)
120#define PC17_PF_SPI1_MOSI (GPIO_PORTC | GPIO_PF | 17)
121#define PC24_BIN_UART3_RI (GPIO_PORTC | GPIO_BIN | GPIO_OUT | 24)
122#define PC25_BIN_UART3_DSR (GPIO_PORTC | GPIO_BIN | GPIO_OUT | 25)
123#define PC26_AOUT_UART3_DTR (GPIO_PORTC | GPIO_AOUT | GPIO_IN | 26)
124#define PC27_BIN_UART3_DCD (GPIO_PORTC | GPIO_BIN | GPIO_OUT | 27)
125#define PC28_BIN_UART3_CTS (GPIO_PORTC | GPIO_BIN | GPIO_OUT | 28)
126#define PC29_AOUT_UART3_RTS (GPIO_PORTC | GPIO_AOUT | GPIO_IN | 29)
127#define PC30_BIN_UART3_TX (GPIO_PORTC | GPIO_BIN | 30)
128#define PC31_AOUT_UART3_RX (GPIO_PORTC | GPIO_AOUT | GPIO_IN | 31)
129#define PD6_PF_LSCLK (GPIO_PORTD | GPIO_PF | GPIO_OUT | 6)
130#define PD7_PF_REV (GPIO_PORTD | GPIO_PF | 7)
131#define PD7_AF_UART2_DTR (GPIO_PORTD | GPIO_AF | GPIO_IN | 7)
132#define PD7_AIN_SPI2_SCLK (GPIO_PORTD | GPIO_AIN | 7)
133#define PD8_PF_CLS (GPIO_PORTD | GPIO_PF | 8)
134#define PD8_AF_UART2_DCD (GPIO_PORTD | GPIO_AF | GPIO_OUT | 8)
135#define PD8_AIN_SPI2_SS (GPIO_PORTD | GPIO_AIN | 8)
136#define PD9_PF_PS (GPIO_PORTD | GPIO_PF | 9)
137#define PD9_AF_UART2_RI (GPIO_PORTD | GPIO_AF | GPIO_OUT | 9)
138#define PD9_AOUT_SPI2_RXD (GPIO_PORTD | GPIO_AOUT | GPIO_IN | 9)
139#define PD10_PF_SPL_SPR (GPIO_PORTD | GPIO_PF | GPIO_OUT | 10)
140#define PD10_AF_UART2_DSR (GPIO_PORTD | GPIO_AF | GPIO_OUT | 10)
141#define PD10_AIN_SPI2_TXD (GPIO_PORTD | GPIO_AIN | GPIO_OUT | 10)
142#define PD11_PF_CONTRAST (GPIO_PORTD | GPIO_PF | GPIO_OUT | 11)
143#define PD12_PF_ACD_OE (GPIO_PORTD | GPIO_PF | GPIO_OUT | 12)
144#define PD13_PF_LP_HSYNC (GPIO_PORTD | GPIO_PF | GPIO_OUT | 13)
145#define PD14_PF_FLM_VSYNC (GPIO_PORTD | GPIO_PF | GPIO_OUT | 14)
146#define PD15_PF_LD0 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 15)
147#define PD16_PF_LD1 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 16)
148#define PD17_PF_LD2 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 17)
149#define PD18_PF_LD3 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 18)
150#define PD19_PF_LD4 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 19)
151#define PD20_PF_LD5 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 20)
152#define PD21_PF_LD6 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 21)
153#define PD22_PF_LD7 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 22)
154#define PD23_PF_LD8 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 23)
155#define PD24_PF_LD9 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 24)
156#define PD25_PF_LD10 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 25)
157#define PD26_PF_LD11 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 26)
158#define PD27_PF_LD12 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 27)
159#define PD28_PF_LD13 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 28)
160#define PD29_PF_LD14 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 29)
161#define PD30_PF_LD15 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 30)
162#define PD31_PF_TMR2OUT (GPIO_PORTD | GPIO_PF | 31)
163#define PD31_BIN_SPI2_TXD (GPIO_PORTD | GPIO_BIN | 31)
164
165
166#endif
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx21.h b/arch/arm/plat-mxc/include/mach/iomux-mx21.h
new file mode 100644
index 000000000000..63aaa972e275
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/iomux-mx21.h
@@ -0,0 +1,126 @@
1/*
2* Copyright (C) 2009 by Holger Schurig <hs4233@mail.mn-solutions.de>
3*
4* This program is free software; you can redistribute it and/or
5* modify it under the terms of the GNU General Public License
6* as published by the Free Software Foundation; either version 2
7* of the License, or (at your option) any later version.
8* This program is distributed in the hope that it will be useful,
9* but WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program; if not, write to the Free Software
15* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16* MA 02110-1301, USA.
17*/
18
19#ifndef _MXC_IOMUX_MX21_H
20#define _MXC_IOMUX_MX21_H
21
22#ifndef GPIO_PORTA
23#error Please include mach/iomux.h
24#endif
25
26
27/* Primary GPIO pin functions */
28
29#define PB22_PF_USBH1_BYP (GPIO_PORTB | GPIO_PF | 22)
30#define PB25_PF_USBH1_ON (GPIO_PORTB | GPIO_PF | 25)
31#define PC5_PF_USBOTG_SDA (GPIO_PORTC | GPIO_PF | 5)
32#define PC6_PF_USBOTG_SCL (GPIO_PORTC | GPIO_PF | 6)
33#define PC7_PF_USBOTG_ON (GPIO_PORTC | GPIO_PF | 7)
34#define PC8_PF_USBOTG_FS (GPIO_PORTC | GPIO_PF | 8)
35#define PC9_PF_USBOTG_OE (GPIO_PORTC | GPIO_PF | 9)
36#define PC10_PF_USBOTG_TXDM (GPIO_PORTC | GPIO_PF | 10)
37#define PC11_PF_USBOTG_TXDP (GPIO_PORTC | GPIO_PF | 11)
38#define PC12_PF_USBOTG_RXDM (GPIO_PORTC | GPIO_PF | 12)
39#define PC13_PF_USBOTG_RXDP (GPIO_PORTC | GPIO_PF | 13)
40#define PC16_PF_SAP_FS (GPIO_PORTC | GPIO_PF | 16)
41#define PC17_PF_SAP_RXD (GPIO_PORTC | GPIO_PF | 17)
42#define PC18_PF_SAP_TXD (GPIO_PORTC | GPIO_PF | 18)
43#define PC19_PF_SAP_CLK (GPIO_PORTC | GPIO_PF | 19)
44#define PE0_PF_TEST_WB2 (GPIO_PORTE | GPIO_PF | 0)
45#define PE1_PF_TEST_WB1 (GPIO_PORTE | GPIO_PF | 1)
46#define PE2_PF_TEST_WB0 (GPIO_PORTE | GPIO_PF | 2)
47#define PF1_PF_NFCE (GPIO_PORTF | GPIO_PF | 1)
48#define PF3_PF_NFCLE (GPIO_PORTF | GPIO_PF | 3)
49#define PF7_PF_NFIO0 (GPIO_PORTF | GPIO_PF | 7)
50#define PF8_PF_NFIO1 (GPIO_PORTF | GPIO_PF | 8)
51#define PF9_PF_NFIO2 (GPIO_PORTF | GPIO_PF | 9)
52#define PF10_PF_NFIO3 (GPIO_PORTF | GPIO_PF | 10)
53#define PF11_PF_NFIO4 (GPIO_PORTF | GPIO_PF | 11)
54#define PF12_PF_NFIO5 (GPIO_PORTF | GPIO_PF | 12)
55#define PF13_PF_NFIO6 (GPIO_PORTF | GPIO_PF | 13)
56#define PF14_PF_NFIO7 (GPIO_PORTF | GPIO_PF | 14)
57#define PF16_PF_RES (GPIO_PORTF | GPIO_PF | 16)
58
59/* Alternate GPIO pin functions */
60
61#define PA5_AF_BMI_CLK_CS (GPIO_PORTA | GPIO_AF | 5)
62#define PA6_AF_BMI_D0 (GPIO_PORTA | GPIO_AF | 6)
63#define PA7_AF_BMI_D1 (GPIO_PORTA | GPIO_AF | 7)
64#define PA8_AF_BMI_D2 (GPIO_PORTA | GPIO_AF | 8)
65#define PA9_AF_BMI_D3 (GPIO_PORTA | GPIO_AF | 9)
66#define PA10_AF_BMI_D4 (GPIO_PORTA | GPIO_AF | 10)
67#define PA11_AF_BMI_D5 (GPIO_PORTA | GPIO_AF | 11)
68#define PA12_AF_BMI_D6 (GPIO_PORTA | GPIO_AF | 12)
69#define PA13_AF_BMI_D7 (GPIO_PORTA | GPIO_AF | 13)
70#define PA14_AF_BMI_D8 (GPIO_PORTA | GPIO_AF | 14)
71#define PA15_AF_BMI_D9 (GPIO_PORTA | GPIO_AF | 15)
72#define PA16_AF_BMI_D10 (GPIO_PORTA | GPIO_AF | 16)
73#define PA17_AF_BMI_D11 (GPIO_PORTA | GPIO_AF | 17)
74#define PA18_AF_BMI_D12 (GPIO_PORTA | GPIO_AF | 18)
75#define PA19_AF_BMI_D13 (GPIO_PORTA | GPIO_AF | 19)
76#define PA20_AF_BMI_D14 (GPIO_PORTA | GPIO_AF | 20)
77#define PA21_AF_BMI_D15 (GPIO_PORTA | GPIO_AF | 21)
78#define PA22_AF_BMI_READ_REQ (GPIO_PORTA | GPIO_AF | 22)
79#define PA23_AF_BMI_WRITE (GPIO_PORTA | GPIO_AF | 23)
80#define PA29_AF_BMI_RX_FULL (GPIO_PORTA | GPIO_AF | 29)
81#define PA30_AF_BMI_READ (GPIO_PORTA | GPIO_AF | 30)
82
83/* AIN GPIO pin functions */
84
85#define PC14_AIN_SYS_CLK (GPIO_PORTC | GPIO_AIN | GPIO_OUT | 14)
86#define PD21_AIN_USBH2_FS (GPIO_PORTD | GPIO_AIN | GPIO_OUT | 21)
87#define PD22_AIN_USBH2_OE (GPIO_PORTD | GPIO_AIN | GPIO_OUT | 22)
88#define PD23_AIN_USBH2_TXDM (GPIO_PORTD | GPIO_AIN | GPIO_OUT | 23)
89#define PD24_AIN_USBH2_TXDP (GPIO_PORTD | GPIO_AIN | GPIO_OUT | 24)
90#define PE8_AIN_IR_TXD (GPIO_PORTE | GPIO_AIN | GPIO_OUT | 8)
91#define PF0_AIN_PC_RST (GPIO_PORTF | GPIO_AIN | GPIO_OUT | 0)
92#define PF1_AIN_PC_CE1 (GPIO_PORTF | GPIO_AIN | GPIO_OUT | 1)
93#define PF2_AIN_PC_CE2 (GPIO_PORTF | GPIO_AIN | GPIO_OUT | 2)
94#define PF3_AIN_PC_POE (GPIO_PORTF | GPIO_AIN | GPIO_OUT | 3)
95#define PF4_AIN_PC_OE (GPIO_PORTF | GPIO_AIN | GPIO_OUT | 4)
96#define PF5_AIN_PC_RW (GPIO_PORTF | GPIO_AIN | GPIO_OUT | 5)
97
98/* BIN GPIO pin functions */
99
100#define PC14_BIN_SYS_CLK (GPIO_PORTC | GPIO_BIN | GPIO_OUT | 14)
101#define PD27_BIN_EXT_DMA_GRANT (GPIO_PORTD | GPIO_BIN | GPIO_OUT | 27)
102
103/* CIN GPIO pin functions */
104
105#define PB26_CIN_USBH1_RXDAT (GPIO_PORTB | GPIO_CIN | GPIO_OUT | 26)
106
107/* AOUT GPIO pin functions */
108
109#define PA29_AOUT_BMI_WAIT (GPIO_PORTA | GPIO_AOUT | GPIO_IN | 29)
110#define PD19_AOUT_USBH2_RXDM (GPIO_PORTD | GPIO_AOUT | GPIO_IN | 19)
111#define PD20_AOUT_USBH2_RXDP (GPIO_PORTD | GPIO_AOUT | GPIO_IN | 20)
112#define PD25_AOUT_EXT_DMAREQ (GPIO_PORTD | GPIO_AOUT | GPIO_IN | 25)
113#define PD26_AOUT_USBOTG_RXDAT (GPIO_PORTD | GPIO_AOUT | GPIO_IN | 26)
114#define PE9_AOUT_IR_RXD (GPIO_PORTE | GPIO_AOUT | GPIO_IN | 9)
115#define PF6_AOUT_PC_BVD2 (GPIO_PORTF | GPIO_AOUT | GPIO_IN | 6)
116#define PF7_AOUT_PC_BVD1 (GPIO_PORTF | GPIO_AOUT | GPIO_IN | 7)
117#define PF8_AOUT_PC_VS2 (GPIO_PORTF | GPIO_AOUT | GPIO_IN | 8)
118#define PF9_AOUT_PC_VS1 (GPIO_PORTF | GPIO_AOUT | GPIO_IN | 9)
119#define PF10_AOUT_PC_WP (GPIO_PORTF | GPIO_AOUT | GPIO_IN | 10)
120#define PF11_AOUT_PC_READY (GPIO_PORTF | GPIO_AOUT | GPIO_IN | 11)
121#define PF12_AOUT_PC_WAIT (GPIO_PORTF | GPIO_AOUT | GPIO_IN | 12)
122#define PF13_AOUT_PC_CD2 (GPIO_PORTF | GPIO_AOUT | GPIO_IN | 13)
123#define PF14_AOUT_PC_CD1 (GPIO_PORTF | GPIO_AOUT | GPIO_IN | 14)
124
125
126#endif
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx27.h b/arch/arm/plat-mxc/include/mach/iomux-mx27.h
new file mode 100644
index 000000000000..5ac158b70f61
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/iomux-mx27.h
@@ -0,0 +1,207 @@
1/*
2* Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de>
3* Copyright (C) 2009 by Holger Schurig <hs4233@mail.mn-solutions.de>
4*
5* This program is free software; you can redistribute it and/or
6* modify it under the terms of the GNU General Public License
7* as published by the Free Software Foundation; either version 2
8* of the License, or (at your option) any later version.
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program; if not, write to the Free Software
16* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301, USA.
18*/
19
20#ifndef _MXC_IOMUX_MX27_H
21#define _MXC_IOMUX_MX27_H
22
23#ifndef GPIO_PORTA
24#error Please include mach/iomux.h
25#endif
26
27
28/* Primary GPIO pin functions */
29
30#define PA0_PF_USBH2_CLK (GPIO_PORTA | GPIO_PF | 0)
31#define PA1_PF_USBH2_DIR (GPIO_PORTA | GPIO_PF | 1)
32#define PA2_PF_USBH2_DATA7 (GPIO_PORTA | GPIO_PF | 2)
33#define PA3_PF_USBH2_NXT (GPIO_PORTA | GPIO_PF | 3)
34#define PA4_PF_USBH2_STP (GPIO_PORTA | GPIO_PF | 4)
35#define PB22_PF_USBH1_SUSP (GPIO_PORTB | GPIO_PF | 22)
36#define PB25_PF_USBH1_RCV (GPIO_PORTB | GPIO_PF | 25)
37#define PC5_PF_I2C2_SDA (GPIO_PORTC | GPIO_PF | GPIO_IN | 5)
38#define PC6_PF_I2C2_SCL (GPIO_PORTC | GPIO_PF | GPIO_IN | 6)
39#define PC7_PF_USBOTG_DATA5 (GPIO_PORTC | GPIO_PF | GPIO_OUT | 7)
40#define PC8_PF_USBOTG_DATA6 (GPIO_PORTC | GPIO_PF | GPIO_OUT | 8)
41#define PC9_PF_USBOTG_DATA0 (GPIO_PORTC | GPIO_PF | GPIO_OUT | 9)
42#define PC10_PF_USBOTG_DATA2 (GPIO_PORTC | GPIO_PF | GPIO_OUT | 10)
43#define PC11_PF_USBOTG_DATA1 (GPIO_PORTC | GPIO_PF | GPIO_OUT | 11)
44#define PC12_PF_USBOTG_DATA4 (GPIO_PORTC | GPIO_PF | GPIO_OUT | 12)
45#define PC13_PF_USBOTG_DATA3 (GPIO_PORTC | GPIO_PF | GPIO_OUT | 13)
46#define PC16_PF_SSI4_FS (GPIO_PORTC | GPIO_PF | GPIO_IN | 16)
47#define PC17_PF_SSI4_RXD (GPIO_PORTC | GPIO_PF | GPIO_IN | 17)
48#define PC18_PF_SSI4_TXD (GPIO_PORTC | GPIO_PF | GPIO_IN | 18)
49#define PC19_PF_SSI4_CLK (GPIO_PORTC | GPIO_PF | GPIO_IN | 19)
50#define PC25_AF_GPT5_TIN (GPIO_PORTC | GPIO_AF | 25)
51#define PC27_AF_GPT4_TIN (GPIO_PORTC | GPIO_AF | 27)
52#define PD0_PF_SD3_CMD (GPIO_PORTD | GPIO_PF | 0)
53#define PD1_PF_SD3_CLK (GPIO_PORTD | GPIO_PF | 1)
54#define PD2_PF_ATA_DATA0 (GPIO_PORTD | GPIO_PF | 2)
55#define PD3_PF_ATA_DATA1 (GPIO_PORTD | GPIO_PF | 3)
56#define PD4_PF_ATA_DATA2 (GPIO_PORTD | GPIO_PF | 4)
57#define PD5_PF_ATA_DATA3 (GPIO_PORTD | GPIO_PF | 5)
58#define PD6_PF_ATA_DATA4 (GPIO_PORTD | GPIO_PF | 6)
59#define PD7_PF_ATA_DATA5 (GPIO_PORTD | GPIO_PF | 7)
60#define PD8_PF_ATA_DATA6 (GPIO_PORTD | GPIO_PF | 8)
61#define PD9_PF_ATA_DATA7 (GPIO_PORTD | GPIO_PF | 9)
62#define PD10_PF_ATA_DATA8 (GPIO_PORTD | GPIO_PF | 10)
63#define PD11_PF_ATA_DATA9 (GPIO_PORTD | GPIO_PF | 11)
64#define PD12_PF_ATA_DATA10 (GPIO_PORTD | GPIO_PF | 12)
65#define PD13_PF_ATA_DATA11 (GPIO_PORTD | GPIO_PF | 13)
66#define PD14_PF_ATA_DATA12 (GPIO_PORTD | GPIO_PF | 14)
67#define PD15_PF_ATA_DATA13 (GPIO_PORTD | GPIO_PF | 15)
68#define PD16_PF_ATA_DATA14 (GPIO_PORTD | GPIO_PF | 16)
69#define PE0_PF_USBOTG_NXT (GPIO_PORTE | GPIO_PF | GPIO_OUT | 0)
70#define PE1_PF_USBOTG_STP (GPIO_PORTE | GPIO_PF | GPIO_OUT | 1)
71#define PE2_PF_USBOTG_DIR (GPIO_PORTE | GPIO_PF | GPIO_OUT | 2)
72#define PE24_PF_USBOTG_CLK (GPIO_PORTE | GPIO_PF | GPIO_OUT | 24)
73#define PE25_PF_USBOTG_DATA7 (GPIO_PORTE | GPIO_PF | GPIO_OUT | 25)
74#define PF1_PF_NFCLE (GPIO_PORTF | GPIO_PF | 1)
75#define PF3_PF_NFCE (GPIO_PORTF | GPIO_PF | 3)
76#define PF7_PF_PC_POE (GPIO_PORTF | GPIO_PF | 7)
77#define PF8_PF_PC_RW (GPIO_PORTF | GPIO_PF | 8)
78#define PF9_PF_PC_IOIS16 (GPIO_PORTF | GPIO_PF | 9)
79#define PF10_PF_PC_RST (GPIO_PORTF | GPIO_PF | 10)
80#define PF11_PF_PC_BVD2 (GPIO_PORTF | GPIO_PF | 11)
81#define PF12_PF_PC_BVD1 (GPIO_PORTF | GPIO_PF | 12)
82#define PF13_PF_PC_VS2 (GPIO_PORTF | GPIO_PF | 13)
83#define PF14_PF_PC_VS1 (GPIO_PORTF | GPIO_PF | 14)
84#define PF16_PF_PC_PWRON (GPIO_PORTF | GPIO_PF | 16)
85#define PF17_PF_PC_READY (GPIO_PORTF | GPIO_PF | 17)
86#define PF18_PF_PC_WAIT (GPIO_PORTF | GPIO_PF | 18)
87#define PF19_PF_PC_CD2 (GPIO_PORTF | GPIO_PF | 19)
88#define PF20_PF_PC_CD1 (GPIO_PORTF | GPIO_PF | 20)
89#define PF23_PF_ATA_DATA15 (GPIO_PORTF | GPIO_PF | 23)
90
91/* Alternate GPIO pin functions */
92
93#define PB4_AF_MSHC_DATA0 (GPIO_PORTB | GPIO_AF | GPIO_OUT | 4)
94#define PB5_AF_MSHC_DATA1 (GPIO_PORTB | GPIO_AF | GPIO_OUT | 5)
95#define PB6_AF_MSHC_DATA2 (GPIO_PORTB | GPIO_AF | GPIO_OUT | 6)
96#define PB7_AF_MSHC_DATA4 (GPIO_PORTB | GPIO_AF | GPIO_OUT | 7)
97#define PB8_AF_MSHC_BS (GPIO_PORTB | GPIO_AF | GPIO_OUT | 8)
98#define PB9_AF_MSHC_SCLK (GPIO_PORTB | GPIO_AF | GPIO_OUT | 9)
99#define PB10_AF_UART6_TXD (GPIO_PORTB | GPIO_AF | GPIO_OUT | 10)
100#define PB11_AF_UART6_RXD (GPIO_PORTB | GPIO_AF | GPIO_IN | 11)
101#define PB12_AF_UART6_CTS (GPIO_PORTB | GPIO_AF | GPIO_OUT | 12)
102#define PB13_AF_UART6_RTS (GPIO_PORTB | GPIO_AF | GPIO_IN | 13)
103#define PB18_AF_UART5_TXD (GPIO_PORTB | GPIO_AF | GPIO_OUT | 18)
104#define PB19_AF_UART5_RXD (GPIO_PORTB | GPIO_AF | GPIO_IN | 19)
105#define PB20_AF_UART5_CTS (GPIO_PORTB | GPIO_AF | GPIO_OUT | 20)
106#define PB21_AF_UART5_RTS (GPIO_PORTB | GPIO_AF | GPIO_IN | 21)
107#define PC8_AF_FEC_MDIO (GPIO_PORTC | GPIO_AF | GPIO_IN | 8)
108#define PC24_AF_GPT5_TOUT (GPIO_PORTC | GPIO_AF | 24)
109#define PC26_AF_GPT4_TOUT (GPIO_PORTC | GPIO_AF | 26)
110#define PD1_AF_ETMTRACE_PKT15 (GPIO_PORTD | GPIO_AF | 1)
111#define PD6_AF_ETMTRACE_PKT14 (GPIO_PORTD | GPIO_AF | 6)
112#define PD7_AF_ETMTRACE_PKT13 (GPIO_PORTD | GPIO_AF | 7)
113#define PD9_AF_ETMTRACE_PKT12 (GPIO_PORTD | GPIO_AF | 9)
114#define PD2_AF_SD3_D0 (GPIO_PORTD | GPIO_AF | 2)
115#define PD3_AF_SD3_D1 (GPIO_PORTD | GPIO_AF | 3)
116#define PD4_AF_SD3_D2 (GPIO_PORTD | GPIO_AF | 4)
117#define PD5_AF_SD3_D3 (GPIO_PORTD | GPIO_AF | 5)
118#define PD8_AF_FEC_MDIO (GPIO_PORTD | GPIO_AF | GPIO_IN | 8)
119#define PD10_AF_ETMTRACE_PKT11 (GPIO_PORTD | GPIO_AF | 10)
120#define PD11_AF_ETMTRACE_PKT10 (GPIO_PORTD | GPIO_AF | 11)
121#define PD12_AF_ETMTRACE_PKT9 (GPIO_PORTD | GPIO_AF | 12)
122#define PD13_AF_ETMTRACE_PKT8 (GPIO_PORTD | GPIO_AF | 13)
123#define PD14_AF_ETMTRACE_PKT7 (GPIO_PORTD | GPIO_AF | 14)
124#define PD15_AF_ETMTRACE_PKT6 (GPIO_PORTD | GPIO_AF | 15)
125#define PD16_AF_ETMTRACE_PKT5 (GPIO_PORTD | GPIO_AF | 16)
126#define PF1_AF_ETMTRACE_PKT0 (GPIO_PORTF | GPIO_AF | 1)
127#define PF3_AF_ETMTRACE_PKT2 (GPIO_PORTF | GPIO_AF | 3)
128#define PF5_AF_ETMPIPESTAT11 (GPIO_PORTF | GPIO_AF | 5)
129#define PF7_AF_ATA_BUFFER_EN (GPIO_PORTF | GPIO_AF | 7)
130#define PF8_AF_ATA_IORDY (GPIO_PORTF | GPIO_AF | 8)
131#define PF9_AF_ATA_INTRQ (GPIO_PORTF | GPIO_AF | 9)
132#define PF10_AF_ATA_RESET (GPIO_PORTF | GPIO_AF | 10)
133#define PF11_AF_ATA_DMACK (GPIO_PORTF | GPIO_AF | 11)
134#define PF12_AF_ATA_DMAREQ (GPIO_PORTF | GPIO_AF | 12)
135#define PF13_AF_ATA_DA0 (GPIO_PORTF | GPIO_AF | 13)
136#define PF14_AF_ATA_DA1 (GPIO_PORTF | GPIO_AF | 14)
137#define PF15_AF_ETMTRACE_SYNC (GPIO_PORTF | GPIO_AF | 15)
138#define PF16_AF_ATA_DA2 (GPIO_PORTF | GPIO_AF | 16)
139#define PF17_AF_ATA_CS0 (GPIO_PORTF | GPIO_AF | 17)
140#define PF18_AF_ATA_CS1 (GPIO_PORTF | GPIO_AF | 18)
141#define PF19_AF_ATA_DIOW (GPIO_PORTF | GPIO_AF | 19)
142#define PF20_AF_ATA_DIOR (GPIO_PORTF | GPIO_AF | 20)
143#define PF22_AF_ETMTRACE_CLK (GPIO_PORTF | GPIO_AF | 22)
144#define PF23_AF_ETMTRACE_PKT4 (GPIO_PORTF | GPIO_AF | 23)
145
146/* AIN GPIO pin functions */
147
148#define PC14_AIN_SSI1_MCLK (GPIO_PORTC | GPIO_AIN | GPIO_OUT | 14)
149#define PC15_AIN_GPT6_TOUT (GPIO_PORTC | GPIO_AIN | GPIO_OUT | 15)
150#define PD0_AIN_FEC_TXD0 (GPIO_PORTD | GPIO_AIN | GPIO_OUT | 0)
151#define PD1_AIN_FEC_TXD1 (GPIO_PORTD | GPIO_AIN | GPIO_OUT | 1)
152#define PD2_AIN_FEC_TXD2 (GPIO_PORTD | GPIO_AIN | GPIO_OUT | 2)
153#define PD3_AIN_FEC_TXD3 (GPIO_PORTD | GPIO_AIN | GPIO_OUT | 3)
154#define PD9_AIN_FEC_MDC (GPIO_PORTD | GPIO_AIN | GPIO_OUT | 9)
155#define PD16_AIN_FEC_TX_ER (GPIO_PORTD | GPIO_AIN | GPIO_OUT | 16)
156#define PD27_AIN_EXT_DMA_GRANT (GPIO_PORTD | GPIO_AIN | GPIO_OUT | 27)
157#define PF23_AIN_FEC_TX_EN (GPIO_PORTF | GPIO_AIN | GPIO_OUT | 23)
158
159/* BIN GPIO pin functions */
160
161#define PC14_BIN_SSI2_MCLK (GPIO_PORTC | GPIO_BIN | GPIO_OUT | 14)
162
163/* CIN GPIO pin functions */
164
165#define PD2_CIN_SLCDC1_DAT0 (GPIO_PORTD | GPIO_CIN | GPIO_OUT | 2)
166#define PD3_CIN_SLCDC1_DAT1 (GPIO_PORTD | GPIO_CIN | GPIO_OUT | 3)
167#define PD4_CIN_SLCDC1_DAT2 (GPIO_PORTD | GPIO_CIN | GPIO_OUT | 4)
168#define PD5_CIN_SLCDC1_DAT3 (GPIO_PORTD | GPIO_CIN | GPIO_OUT | 5)
169#define PD6_CIN_SLCDC1_DAT4 (GPIO_PORTD | GPIO_CIN | GPIO_OUT | 6)
170#define PD7_CIN_SLCDC1_DAT5 (GPIO_PORTD | GPIO_CIN | GPIO_OUT | 7)
171#define PD8_CIN_SLCDC1_DAT6 (GPIO_PORTD | GPIO_CIN | GPIO_OUT | 8)
172#define PD9_CIN_SLCDC1_DAT7 (GPIO_PORTD | GPIO_CIN | GPIO_OUT | 9)
173#define PD10_CIN_SLCDC1_DAT8 (GPIO_PORTD | GPIO_CIN | GPIO_OUT | 10)
174#define PD11_CIN_SLCDC1_DAT9 (GPIO_PORTD | GPIO_CIN | GPIO_OUT | 11)
175#define PD12_CIN_SLCDC1_DAT10 (GPIO_PORTD | GPIO_CIN | GPIO_OUT | 12)
176#define PD13_CIN_SLCDC1_DAT11 (GPIO_PORTD | GPIO_CIN | GPIO_OUT | 13)
177#define PD14_CIN_SLCDC1_DAT12 (GPIO_PORTD | GPIO_CIN | GPIO_OUT | 14)
178#define PD15_CIN_SLCDC1_DAT13 (GPIO_PORTD | GPIO_CIN | GPIO_OUT | 15)
179#define PD16_CIN_SLCDC1_DAT14 (GPIO_PORTD | GPIO_CIN | GPIO_OUT | 16)
180#define PD23_CIN_SLCDC1_DAT15 (GPIO_PORTD | GPIO_CIN | GPIO_OUT | 23)
181#define PF27_CIN_EXT_DMA_GRANT (GPIO_PORTF | GPIO_CIN | GPIO_OUT | 27)
182/* LCDC_TESTx on PBxx omitted, because it's not clear what they do */
183
184/* AOUT GPIO pin functions */
185
186#define PC14_AOUT_GPT6_TIN (GPIO_PORTC | GPIO_AOUT | GPIO_IN | 14)
187#define PD4_AOUT_FEC_RX_ER (GPIO_PORTD | GPIO_AOUT | GPIO_IN | 4)
188#define PD5_AOUT_FEC_RXD1 (GPIO_PORTD | GPIO_AOUT | GPIO_IN | 5)
189#define PD6_AOUT_FEC_RXD2 (GPIO_PORTD | GPIO_AOUT | GPIO_IN | 6)
190#define PD7_AOUT_FEC_RXD3 (GPIO_PORTD | GPIO_AOUT | GPIO_IN | 7)
191#define PD10_AOUT_FEC_CRS (GPIO_PORTD | GPIO_AOUT | GPIO_IN | 10)
192#define PD11_AOUT_FEC_TX_CLK (GPIO_PORTD | GPIO_AOUT | GPIO_IN | 11)
193#define PD12_AOUT_FEC_RXD0 (GPIO_PORTD | GPIO_AOUT | GPIO_IN | 12)
194#define PD13_AOUT_FEC_RX_DV (GPIO_PORTD | GPIO_AOUT | GPIO_IN | 13)
195#define PD14_AOUT_FEC_RX_CLK (GPIO_PORTD | GPIO_AOUT | GPIO_IN | 14)
196#define PD15_AOUT_FEC_COL (GPIO_PORTD | GPIO_AOUT | GPIO_IN | 15)
197
198#define PC17_BOUT_PC_IOIS16 (GPIO_PORTC | GPIO_BOUT | GPIO_IN | 17)
199#define PC18_BOUT_PC_BVD2 (GPIO_PORTC | GPIO_BOUT | GPIO_IN | 18)
200#define PC19_BOUT_PC_BVD1 (GPIO_PORTC | GPIO_BOUT | GPIO_IN | 19)
201#define PC28_BOUT_PC_BVD2 (GPIO_PORTC | GPIO_BOUT | GPIO_IN | 28)
202#define PC29_BOUT_PC_VS1 (GPIO_PORTC | GPIO_BOUT | GPIO_IN | 29)
203#define PC30_BOUT_PC_READY (GPIO_PORTC | GPIO_BOUT | GPIO_IN | 30)
204#define PC31_BOUT_PC_WAIT (GPIO_PORTC | GPIO_BOUT | GPIO_IN | 31)
205
206
207#endif /* _MXC_GPIO_MX1_MX2_H */
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx2x.h b/arch/arm/plat-mxc/include/mach/iomux-mx2x.h
new file mode 100644
index 000000000000..fb5ae638e79f
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/iomux-mx2x.h
@@ -0,0 +1,237 @@
1/*
2* Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de>
3* Copyright (C) 2009 by Holger Schurig <hs4233@mail.mn-solutions.de>
4*
5* This program is free software; you can redistribute it and/or
6* modify it under the terms of the GNU General Public License
7* as published by the Free Software Foundation; either version 2
8* of the License, or (at your option) any later version.
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program; if not, write to the Free Software
16* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301, USA.
18*/
19
20#ifndef _MXC_IOMUX_MX2x_H
21#define _MXC_IOMUX_MX2x_H
22
23#ifndef GPIO_PORTA
24#error Please include mach/iomux.h
25#endif
26
27
28/* Primary GPIO pin functions */
29
30#define PA5_PF_LSCLK (GPIO_PORTA | GPIO_PF | GPIO_OUT | 5)
31#define PA6_PF_LD0 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 6)
32#define PA7_PF_LD1 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 7)
33#define PA8_PF_LD2 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 8)
34#define PA9_PF_LD3 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 9)
35#define PA10_PF_LD4 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 10)
36#define PA11_PF_LD5 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 11)
37#define PA12_PF_LD6 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 12)
38#define PA13_PF_LD7 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 13)
39#define PA14_PF_LD8 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 14)
40#define PA15_PF_LD9 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 15)
41#define PA16_PF_LD10 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 16)
42#define PA17_PF_LD11 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 17)
43#define PA18_PF_LD12 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 18)
44#define PA19_PF_LD13 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 19)
45#define PA20_PF_LD14 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 20)
46#define PA21_PF_LD15 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 21)
47#define PA22_PF_LD16 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 22)
48#define PA23_PF_LD17 (GPIO_PORTA | GPIO_PF | GPIO_OUT | 23)
49#define PA24_PF_REV (GPIO_PORTA | GPIO_PF | GPIO_OUT | 24)
50#define PA25_PF_CLS (GPIO_PORTA | GPIO_PF | GPIO_OUT | 25)
51#define PA26_PF_PS (GPIO_PORTA | GPIO_PF | GPIO_OUT | 26)
52#define PA27_PF_SPL_SPR (GPIO_PORTA | GPIO_PF | GPIO_OUT | 27)
53#define PA28_PF_HSYNC (GPIO_PORTA | GPIO_PF | GPIO_OUT | 28)
54#define PA29_PF_VSYNC (GPIO_PORTA | GPIO_PF | GPIO_OUT | 29)
55#define PA30_PF_CONTRAST (GPIO_PORTA | GPIO_PF | GPIO_OUT | 30)
56#define PA31_PF_OE_ACD (GPIO_PORTA | GPIO_PF | GPIO_OUT | 31)
57#define PB4_PF_SD2_D0 (GPIO_PORTB | GPIO_PF | 4)
58#define PB5_PF_SD2_D1 (GPIO_PORTB | GPIO_PF | 5)
59#define PB6_PF_SD2_D2 (GPIO_PORTB | GPIO_PF | 6)
60#define PB7_PF_SD2_D3 (GPIO_PORTB | GPIO_PF | 7)
61#define PB8_PF_SD2_CMD (GPIO_PORTB | GPIO_PF | 8)
62#define PB9_PF_SD2_CLK (GPIO_PORTB | GPIO_PF | 9)
63#define PB10_PF_CSI_D0 (GPIO_PORTB | GPIO_PF | GPIO_OUT | 10)
64#define PB11_PF_CSI_D1 (GPIO_PORTB | GPIO_PF | GPIO_OUT | 11)
65#define PB12_PF_CSI_D2 (GPIO_PORTB | GPIO_PF | GPIO_OUT | 12)
66#define PB13_PF_CSI_D3 (GPIO_PORTB | GPIO_PF | GPIO_OUT | 13)
67#define PB14_PF_CSI_D4 (GPIO_PORTB | GPIO_PF | GPIO_OUT | 14)
68#define PB15_PF_CSI_MCLK (GPIO_PORTB | GPIO_PF | GPIO_OUT | 15)
69#define PB16_PF_CSI_PIXCLK (GPIO_PORTB | GPIO_PF | GPIO_OUT | 16)
70#define PB17_PF_CSI_D5 (GPIO_PORTB | GPIO_PF | GPIO_OUT | 17)
71#define PB18_PF_CSI_D6 (GPIO_PORTB | GPIO_PF | GPIO_OUT | 18)
72#define PB19_PF_CSI_D7 (GPIO_PORTB | GPIO_PF | GPIO_OUT | 19)
73#define PB20_PF_CSI_VSYNC (GPIO_PORTB | GPIO_PF | GPIO_OUT | 20)
74#define PB21_PF_CSI_HSYNC (GPIO_PORTB | GPIO_PF | GPIO_OUT | 21)
75#define PB23_PF_USB_PWR (GPIO_PORTB | GPIO_PF | 23)
76#define PB24_PF_USB_OC (GPIO_PORTB | GPIO_PF | 24)
77#define PB26_PF_USBH1_FS (GPIO_PORTB | GPIO_PF | 26)
78#define PB27_PF_USBH1_OE (GPIO_PORTB | GPIO_PF | 27)
79#define PB28_PF_USBH1_TXDM (GPIO_PORTB | GPIO_PF | 28)
80#define PB29_PF_USBH1_TXDP (GPIO_PORTB | GPIO_PF | 29)
81#define PB30_PF_USBH1_RXDM (GPIO_PORTB | GPIO_PF | 30)
82#define PB31_PF_USBH1_RXDP (GPIO_PORTB | GPIO_PF | 31)
83#define PC14_PF_TOUT (GPIO_PORTC | GPIO_PF | 14)
84#define PC15_PF_TIN (GPIO_PORTC | GPIO_PF | 15)
85#define PC20_PF_SSI1_FS (GPIO_PORTC | GPIO_PF | GPIO_IN | 20)
86#define PC21_PF_SSI1_RXD (GPIO_PORTC | GPIO_PF | GPIO_IN | 21)
87#define PC22_PF_SSI1_TXD (GPIO_PORTC | GPIO_PF | GPIO_IN | 22)
88#define PC23_PF_SSI1_CLK (GPIO_PORTC | GPIO_PF | GPIO_IN | 23)
89#define PC24_PF_SSI2_FS (GPIO_PORTC | GPIO_PF | GPIO_IN | 24)
90#define PC25_PF_SSI2_RXD (GPIO_PORTC | GPIO_PF | GPIO_IN | 25)
91#define PC26_PF_SSI2_TXD (GPIO_PORTC | GPIO_PF | GPIO_IN | 26)
92#define PC27_PF_SSI2_CLK (GPIO_PORTC | GPIO_PF | GPIO_IN | 27)
93#define PC28_PF_SSI3_FS (GPIO_PORTC | GPIO_PF | GPIO_IN | 28)
94#define PC29_PF_SSI3_RXD (GPIO_PORTC | GPIO_PF | GPIO_IN | 29)
95#define PC30_PF_SSI3_TXD (GPIO_PORTC | GPIO_PF | GPIO_IN | 30)
96#define PC31_PF_SSI3_CLK (GPIO_PORTC | GPIO_PF | GPIO_IN | 31)
97#define PD17_PF_I2C_DATA (GPIO_PORTD | GPIO_PF | GPIO_OUT | 17)
98#define PD18_PF_I2C_CLK (GPIO_PORTD | GPIO_PF | GPIO_OUT | 18)
99#define PD19_PF_CSPI2_SS2 (GPIO_PORTD | GPIO_PF | 19)
100#define PD20_PF_CSPI2_SS1 (GPIO_PORTD | GPIO_PF | 20)
101#define PD21_PF_CSPI2_SS0 (GPIO_PORTD | GPIO_PF | 21)
102#define PD22_PF_CSPI2_SCLK (GPIO_PORTD | GPIO_PF | 22)
103#define PD23_PF_CSPI2_MISO (GPIO_PORTD | GPIO_PF | 23)
104#define PD24_PF_CSPI2_MOSI (GPIO_PORTD | GPIO_PF | 24)
105#define PD25_PF_CSPI1_RDY (GPIO_PORTD | GPIO_PF | GPIO_OUT | 25)
106#define PD26_PF_CSPI1_SS2 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 26)
107#define PD27_PF_CSPI1_SS1 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 27)
108#define PD28_PF_CSPI1_SS0 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 28)
109#define PD29_PF_CSPI1_SCLK (GPIO_PORTD | GPIO_PF | GPIO_OUT | 29)
110#define PD30_PF_CSPI1_MISO (GPIO_PORTD | GPIO_PF | GPIO_IN | 30)
111#define PD31_PF_CSPI1_MOSI (GPIO_PORTD | GPIO_PF | GPIO_OUT | 31)
112#define PE3_PF_UART2_CTS (GPIO_PORTE | GPIO_PF | GPIO_OUT | 3)
113#define PE4_PF_UART2_RTS (GPIO_PORTE | GPIO_PF | GPIO_IN | 4)
114#define PE5_PF_PWMO (GPIO_PORTE | GPIO_PF | 5)
115#define PE6_PF_UART2_TXD (GPIO_PORTE | GPIO_PF | GPIO_OUT | 6)
116#define PE7_PF_UART2_RXD (GPIO_PORTE | GPIO_PF | GPIO_IN | 7)
117#define PE8_PF_UART3_TXD (GPIO_PORTE | GPIO_PF | GPIO_OUT | 8)
118#define PE9_PF_UART3_RXD (GPIO_PORTE | GPIO_PF | GPIO_IN | 9)
119#define PE10_PF_UART3_CTS (GPIO_PORTE | GPIO_PF | GPIO_OUT | 10)
120#define PE11_PF_UART3_RTS (GPIO_PORTE | GPIO_PF | GPIO_IN | 11)
121#define PE12_PF_UART1_TXD (GPIO_PORTE | GPIO_PF | GPIO_OUT | 12)
122#define PE13_PF_UART1_RXD (GPIO_PORTE | GPIO_PF | GPIO_IN | 13)
123#define PE14_PF_UART1_CTS (GPIO_PORTE | GPIO_PF | GPIO_OUT | 14)
124#define PE15_PF_UART1_RTS (GPIO_PORTE | GPIO_PF | GPIO_IN | 15)
125#define PE16_PF_RTCK (GPIO_PORTE | GPIO_PF | GPIO_OUT | 16)
126#define PE17_PF_RESET_OUT (GPIO_PORTE | GPIO_PF | 17)
127#define PE18_PF_SD1_D0 (GPIO_PORTE | GPIO_PF | 18)
128#define PE19_PF_SD1_D1 (GPIO_PORTE | GPIO_PF | 19)
129#define PE20_PF_SD1_D2 (GPIO_PORTE | GPIO_PF | 20)
130#define PE21_PF_SD1_D3 (GPIO_PORTE | GPIO_PF | 21)
131#define PE22_PF_SD1_CMD (GPIO_PORTE | GPIO_PF | 22)
132#define PE23_PF_SD1_CLK (GPIO_PORTE | GPIO_PF | 23)
133#define PF0_PF_NRFB (GPIO_PORTF | GPIO_PF | 0)
134#define PF2_PF_NFWP (GPIO_PORTF | GPIO_PF | 2)
135#define PF4_PF_NFALE (GPIO_PORTF | GPIO_PF | 4)
136#define PF5_PF_NFRE (GPIO_PORTF | GPIO_PF | 5)
137#define PF6_PF_NFWE (GPIO_PORTF | GPIO_PF | 6)
138#define PF15_PF_CLKO (GPIO_PORTF | GPIO_PF | 15)
139#define PF21_PF_CS4 (GPIO_PORTF | GPIO_PF | 21)
140#define PF22_PF_CS5 (GPIO_PORTF | GPIO_PF | 22)
141
142/* Alternate GPIO pin functions */
143
144#define PB26_AF_UART4_RTS (GPIO_PORTB | GPIO_AF | GPIO_IN | 26)
145#define PB28_AF_UART4_TXD (GPIO_PORTB | GPIO_AF | GPIO_OUT | 28)
146#define PB29_AF_UART4_CTS (GPIO_PORTB | GPIO_AF | GPIO_OUT | 29)
147#define PB31_AF_UART4_RXD (GPIO_PORTB | GPIO_AF | GPIO_IN | 31)
148#define PC28_AF_SLCDC2_D0 (GPIO_PORTC | GPIO_AF | 28)
149#define PC29_AF_SLCDC2_RS (GPIO_PORTC | GPIO_AF | 29)
150#define PC30_AF_SLCDC2_CS (GPIO_PORTC | GPIO_AF | 30)
151#define PC31_AF_SLCDC2_CLK (GPIO_PORTC | GPIO_AF | 31)
152#define PD19_AF_USBH2_DATA4 (GPIO_PORTD | GPIO_AF | 19)
153#define PD20_AF_USBH2_DATA3 (GPIO_PORTD | GPIO_AF | 20)
154#define PD21_AF_USBH2_DATA6 (GPIO_PORTD | GPIO_AF | 21)
155#define PD22_AF_USBH2_DATA0 (GPIO_PORTD | GPIO_AF | 22)
156#define PD23_AF_USBH2_DATA2 (GPIO_PORTD | GPIO_AF | 23)
157#define PD24_AF_USBH2_DATA1 (GPIO_PORTD | GPIO_AF | 24)
158#define PD26_AF_USBH2_DATA5 (GPIO_PORTD | GPIO_AF | 26)
159#define PE0_AF_KP_COL6 (GPIO_PORTE | GPIO_AF | 0)
160#define PE1_AF_KP_ROW6 (GPIO_PORTE | GPIO_AF | 1)
161#define PE2_AF_KP_ROW7 (GPIO_PORTE | GPIO_AF | 2)
162#define PE3_AF_KP_COL7 (GPIO_PORTE | GPIO_AF | 3)
163#define PE4_AF_KP_ROW7 (GPIO_PORTE | GPIO_AF | 4)
164#define PE6_AF_KP_COL6 (GPIO_PORTE | GPIO_AF | 6)
165#define PE7_AF_KP_ROW6 (GPIO_PORTE | GPIO_AF | 7)
166#define PE16_AF_OWIRE (GPIO_PORTE | GPIO_AF | 16)
167#define PE18_AF_CSPI3_MISO (GPIO_PORTE | GPIO_AF | GPIO_IN | 18)
168#define PE21_AF_CSPI3_SS (GPIO_PORTE | GPIO_AF | GPIO_OUT | 21)
169#define PE22_AF_CSPI3_MOSI (GPIO_PORTE | GPIO_AF | GPIO_OUT | 22)
170#define PE23_AF_CSPI3_SCLK (GPIO_PORTE | GPIO_AF | GPIO_OUT | 23)
171
172/* AIN GPIO pin functions */
173
174#define PA6_AIN_SLCDC1_DAT0 (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 6)
175#define PA7_AIN_SLCDC1_DAT1 (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 7)
176#define PA8_AIN_SLCDC1_DAT2 (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 8)
177#define PA0_AIN_SLCDC1_DAT3 (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 0)
178#define PA11_AIN_SLCDC1_DAT5 (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 11)
179#define PA13_AIN_SLCDC1_DAT7 (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 13)
180#define PA15_AIN_SLCDC1_DAT9 (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 15)
181#define PA17_AIN_SLCDC1_DAT11 (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 17)
182#define PA19_AIN_SLCDC1_DAT13 (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 19)
183#define PA21_AIN_SLCDC1_DAT15 (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 21)
184#define PA22_AIN_EXT_DMAGRANT (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 22)
185#define PA24_AIN_SLCDC1_D0 (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 24)
186#define PA25_AIN_SLCDC1_RS (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 25)
187#define PA26_AIN_SLCDC1_CS (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 26)
188#define PA27_AIN_SLCDC1_CLK (GPIO_PORTA | GPIO_AIN | GPIO_OUT | 27)
189#define PB6_AIN_SLCDC1_D0 (GPIO_PORTB | GPIO_AIN | GPIO_OUT | 6)
190#define PB7_AIN_SLCDC1_RS (GPIO_PORTB | GPIO_AIN | GPIO_OUT | 7)
191#define PB8_AIN_SLCDC1_CS (GPIO_PORTB | GPIO_AIN | GPIO_OUT | 8)
192#define PB9_AIN_SLCDC1_CLK (GPIO_PORTB | GPIO_AIN | GPIO_OUT | 9)
193#define PB25_AIN_SLCDC1_DAT0 (GPIO_PORTB | GPIO_AIN | GPIO_OUT | 25)
194#define PB26_AIN_SLCDC1_DAT1 (GPIO_PORTB | GPIO_AIN | GPIO_OUT | 26)
195#define PB27_AIN_SLCDC1_DAT2 (GPIO_PORTB | GPIO_AIN | GPIO_OUT | 27)
196#define PB28_AIN_SLCDC1_DAT3 (GPIO_PORTB | GPIO_AIN | GPIO_OUT | 28)
197#define PB29_AIN_SLCDC1_DAT4 (GPIO_PORTB | GPIO_AIN | GPIO_OUT | 29)
198#define PB30_AIN_SLCDC1_DAT5 (GPIO_PORTB | GPIO_AIN | GPIO_OUT | 30)
199#define PB31_AIN_SLCDC1_DAT6 (GPIO_PORTB | GPIO_AIN | GPIO_OUT | 31)
200#define PC5_AIN_SLCDC1_DAT7 (GPIO_PORTC | GPIO_AIN | GPIO_OUT | 5)
201#define PC6_AIN_SLCDC1_DAT8 (GPIO_PORTC | GPIO_AIN | GPIO_OUT | 6)
202#define PC7_AIN_SLCDC1_DAT9 (GPIO_PORTC | GPIO_AIN | GPIO_OUT | 7)
203#define PC8_AIN_SLCDC1_DAT10 (GPIO_PORTC | GPIO_AIN | GPIO_OUT | 8)
204#define PC9_AIN_SLCDC1_DAT11 (GPIO_PORTC | GPIO_AIN | GPIO_OUT | 9)
205#define PC10_AIN_SLCDC1_DAT12 (GPIO_PORTC | GPIO_AIN | GPIO_OUT | 10)
206#define PC11_AIN_SLCDC1_DAT13 (GPIO_PORTC | GPIO_AIN | GPIO_OUT | 11)
207#define PC12_AIN_SLCDC1_DAT14 (GPIO_PORTC | GPIO_AIN | GPIO_OUT | 12)
208#define PC13_AIN_SLCDC1_DAT15 (GPIO_PORTC | GPIO_AIN | GPIO_OUT | 13)
209#define PE5_AIN_PC_SPKOUT (GPIO_PORTE | GPIO_AIN | GPIO_OUT | 5)
210
211/* BIN GPIO pin functions */
212
213#define PE5_BIN_TOUT2 (GPIO_PORTE | GPIO_BIN | GPIO_OUT | 5)
214
215/* CIN GPIO pin functions */
216
217#define PA14_CIN_SLCDC1_DAT0 (GPIO_PORTA | GPIO_CIN | GPIO_OUT | 14)
218#define PA15_CIN_SLCDC1_DAT1 (GPIO_PORTA | GPIO_CIN | GPIO_OUT | 15)
219#define PA16_CIN_SLCDC1_DAT2 (GPIO_PORTA | GPIO_CIN | GPIO_OUT | 16)
220#define PA17_CIN_SLCDC1_DAT3 (GPIO_PORTA | GPIO_CIN | GPIO_OUT | 17)
221#define PA18_CIN_SLCDC1_DAT4 (GPIO_PORTA | GPIO_CIN | GPIO_OUT | 18)
222#define PA19_CIN_SLCDC1_DAT5 (GPIO_PORTA | GPIO_CIN | GPIO_OUT | 19)
223#define PA20_CIN_SLCDC1_DAT6 (GPIO_PORTA | GPIO_CIN | GPIO_OUT | 20)
224#define PA21_CIN_SLCDC1_DAT7 (GPIO_PORTA | GPIO_CIN | GPIO_OUT | 21)
225#define PB30_CIN_UART4_CTS (GPIO_PORTB | GPIO_CIN | GPIO_OUT | 30)
226#define PE5_CIN_TOUT3 (GPIO_PORTE | GPIO_CIN | GPIO_OUT | 5)
227
228/* AOUT GPIO pin functions */
229
230#define PB29_AOUT_UART4_RXD (GPIO_PORTB | GPIO_AOUT | GPIO_IN | 29)
231#define PB31_AOUT_UART4_RTS (GPIO_PORTB | GPIO_AOUT | GPIO_IN | 31)
232#define PC8_AOUT_USBOTG_TXR_INT (GPIO_PORTC | GPIO_AOUT | GPIO_IN | 8)
233#define PC15_AOUT_WKGD (GPIO_PORTC | GPIO_AOUT | GPIO_IN | 15)
234#define PF21_AOUT_DTACK (GPIO_PORTF | GPIO_AOUT | GPIO_IN | 21)
235
236
237#endif
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx3.h b/arch/arm/plat-mxc/include/mach/iomux-mx3.h
index c9198c0aea18..ab838cfe94f9 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-mx3.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-mx3.h
@@ -92,7 +92,7 @@ enum iomux_gp_func {
92 MUX_EXTDMAREQ2_MBX_SEL = 1 << 15, 92 MUX_EXTDMAREQ2_MBX_SEL = 1 << 15,
93 MUX_TAMPER_DETECT_EN = 1 << 16, 93 MUX_TAMPER_DETECT_EN = 1 << 16,
94 MUX_PGP_USB_4WIRE = 1 << 17, 94 MUX_PGP_USB_4WIRE = 1 << 17,
95 MUX_PGB_USB_COMMON = 1 << 18, 95 MUX_PGP_USB_COMMON = 1 << 18,
96 MUX_SDHC_MEMSTICK1 = 1 << 19, 96 MUX_SDHC_MEMSTICK1 = 1 << 19,
97 MUX_SDHC_MEMSTICK2 = 1 << 20, 97 MUX_SDHC_MEMSTICK2 = 1 << 20,
98 MUX_PGP_SPLL_BYP = 1 << 21, 98 MUX_PGP_SPLL_BYP = 1 << 21,
@@ -109,21 +109,44 @@ enum iomux_gp_func {
109}; 109};
110 110
111/* 111/*
112 * This function enables/disables the general purpose function for a particular 112 * setups a single pin:
113 * signal. 113 * - reserves the pin so that it is not claimed by another driver
114 * - setups the iomux according to the configuration
115 * - if the pin is configured as a GPIO, we claim it throug kernel gpiolib
116 */
117int mxc_iomux_setup_pin(const unsigned int pin, const char *label);
118/*
119 * setups mutliple pins
120 * convenient way to call the above function with tables
114 */ 121 */
115void iomux_config_gpr(enum iomux_gp_func , bool); 122int mxc_iomux_setup_multiple_pins(unsigned int *pin_list, unsigned count,
123 const char *label);
116 124
117/* 125/*
118 * set the mode for a IOMUX pin. 126 * releases a single pin:
127 * - make it available for a future use by another driver
128 * - frees the GPIO if the pin was configured as GPIO
129 * - DOES NOT reconfigure the IOMUX in its reset state
119 */ 130 */
120int mxc_iomux_mode(unsigned int); 131void mxc_iomux_release_pin(const unsigned int pin);
132/*
133 * releases multiple pins
134 * convenvient way to call the above function with tables
135 */
136void mxc_iomux_release_multiple_pins(unsigned int *pin_list, int count);
121 137
122/* 138/*
123 * This function enables/disables the general purpose function for a particular 139 * This function enables/disables the general purpose function for a particular
124 * signal. 140 * signal.
125 */ 141 */
126void mxc_iomux_set_gpr(enum iomux_gp_func, bool); 142void mxc_iomux_set_gpr(enum iomux_gp_func, bool en);
143
144/*
145 * This function only configures the iomux hardware.
146 * It is called by the setup functions and should not be called directly anymore.
147 * It is here visible for backward compatibility
148 */
149int mxc_iomux_mode(unsigned int pin_mode);
127 150
128#define IOMUX_PADNUM_MASK 0x1ff 151#define IOMUX_PADNUM_MASK 0x1ff
129#define IOMUX_GPIONUM_SHIFT 9 152#define IOMUX_GPIONUM_SHIFT 9
@@ -144,6 +167,11 @@ void mxc_iomux_set_gpr(enum iomux_gp_func, bool);
144 MXC_GPIO_IRQ_START) 167 MXC_GPIO_IRQ_START)
145 168
146/* 169/*
170 * The number of gpio devices among the pads
171 */
172#define GPIO_PORT_MAX 3
173
174/*
147 * This enumeration is constructed based on the Section 175 * This enumeration is constructed based on the Section
148 * "sw_pad_ctl & sw_mux_ctl details" of the MX31 IC Spec. Each enumerated 176 * "sw_pad_ctl & sw_mux_ctl details" of the MX31 IC Spec. Each enumerated
149 * value is constructed based on the rules described above. 177 * value is constructed based on the rules described above.
@@ -480,6 +508,9 @@ enum iomux_pins {
480 MX31_PIN_CAPTURE = IOMUX_PIN( 7, 327), 508 MX31_PIN_CAPTURE = IOMUX_PIN( 7, 327),
481}; 509};
482 510
511#define PIN_MAX 327
512#define NB_PORTS 12 /* NB_PINS/32, we chose 32 pins per "PORT" */
513
483/* 514/*
484 * Convenience values for use with mxc_iomux_mode() 515 * Convenience values for use with mxc_iomux_mode()
485 * 516 *
@@ -507,7 +538,9 @@ enum iomux_pins {
507#define MX31_PIN_CSPI1_SS1__SS1 IOMUX_MODE(MX31_PIN_CSPI1_SS1, IOMUX_CONFIG_FUNC) 538#define MX31_PIN_CSPI1_SS1__SS1 IOMUX_MODE(MX31_PIN_CSPI1_SS1, IOMUX_CONFIG_FUNC)
508#define MX31_PIN_CSPI1_SS2__SS2 IOMUX_MODE(MX31_PIN_CSPI1_SS2, IOMUX_CONFIG_FUNC) 539#define MX31_PIN_CSPI1_SS2__SS2 IOMUX_MODE(MX31_PIN_CSPI1_SS2, IOMUX_CONFIG_FUNC)
509#define MX31_PIN_CSPI2_MOSI__MOSI IOMUX_MODE(MX31_PIN_CSPI2_MOSI, IOMUX_CONFIG_FUNC) 540#define MX31_PIN_CSPI2_MOSI__MOSI IOMUX_MODE(MX31_PIN_CSPI2_MOSI, IOMUX_CONFIG_FUNC)
541#define MX31_PIN_CSPI2_MOSI__SCL IOMUX_MODE(MX31_PIN_CSPI2_MOSI, IOMUX_CONFIG_ALT1)
510#define MX31_PIN_CSPI2_MISO__MISO IOMUX_MODE(MX31_PIN_CSPI2_MISO, IOMUX_CONFIG_FUNC) 542#define MX31_PIN_CSPI2_MISO__MISO IOMUX_MODE(MX31_PIN_CSPI2_MISO, IOMUX_CONFIG_FUNC)
543#define MX31_PIN_CSPI2_MISO__SDA IOMUX_MODE(MX31_PIN_CSPI2_MISO, IOMUX_CONFIG_ALT1)
511#define MX31_PIN_CSPI2_SCLK__SCLK IOMUX_MODE(MX31_PIN_CSPI2_SCLK, IOMUX_CONFIG_FUNC) 544#define MX31_PIN_CSPI2_SCLK__SCLK IOMUX_MODE(MX31_PIN_CSPI2_SCLK, IOMUX_CONFIG_FUNC)
512#define MX31_PIN_CSPI2_SPI_RDY__SPI_RDY IOMUX_MODE(MX31_PIN_CSPI2_SPI_RDY, IOMUX_CONFIG_FUNC) 545#define MX31_PIN_CSPI2_SPI_RDY__SPI_RDY IOMUX_MODE(MX31_PIN_CSPI2_SPI_RDY, IOMUX_CONFIG_FUNC)
513#define MX31_PIN_CSPI2_SS0__SS0 IOMUX_MODE(MX31_PIN_CSPI2_SS0, IOMUX_CONFIG_FUNC) 546#define MX31_PIN_CSPI2_SS0__SS0 IOMUX_MODE(MX31_PIN_CSPI2_SS0, IOMUX_CONFIG_FUNC)
@@ -525,6 +558,33 @@ enum iomux_pins {
525#define MX31_PIN_SD1_DATA0__SD1_DATA0 IOMUX_MODE(MX31_PIN_SD1_DATA0, IOMUX_CONFIG_FUNC) 558#define MX31_PIN_SD1_DATA0__SD1_DATA0 IOMUX_MODE(MX31_PIN_SD1_DATA0, IOMUX_CONFIG_FUNC)
526#define MX31_PIN_SD1_CLK__SD1_CLK IOMUX_MODE(MX31_PIN_SD1_CLK, IOMUX_CONFIG_FUNC) 559#define MX31_PIN_SD1_CLK__SD1_CLK IOMUX_MODE(MX31_PIN_SD1_CLK, IOMUX_CONFIG_FUNC)
527#define MX31_PIN_SD1_CMD__SD1_CMD IOMUX_MODE(MX31_PIN_SD1_CMD, IOMUX_CONFIG_FUNC) 560#define MX31_PIN_SD1_CMD__SD1_CMD IOMUX_MODE(MX31_PIN_SD1_CMD, IOMUX_CONFIG_FUNC)
561#define MX31_PIN_LD0__LD0 IOMUX_MODE(MX31_PIN_LD0, IOMUX_CONFIG_FUNC)
562#define MX31_PIN_LD1__LD1 IOMUX_MODE(MX31_PIN_LD1, IOMUX_CONFIG_FUNC)
563#define MX31_PIN_LD2__LD2 IOMUX_MODE(MX31_PIN_LD2, IOMUX_CONFIG_FUNC)
564#define MX31_PIN_LD3__LD3 IOMUX_MODE(MX31_PIN_LD3, IOMUX_CONFIG_FUNC)
565#define MX31_PIN_LD4__LD4 IOMUX_MODE(MX31_PIN_LD4, IOMUX_CONFIG_FUNC)
566#define MX31_PIN_LD5__LD5 IOMUX_MODE(MX31_PIN_LD5, IOMUX_CONFIG_FUNC)
567#define MX31_PIN_LD6__LD6 IOMUX_MODE(MX31_PIN_LD6, IOMUX_CONFIG_FUNC)
568#define MX31_PIN_LD7__LD7 IOMUX_MODE(MX31_PIN_LD7, IOMUX_CONFIG_FUNC)
569#define MX31_PIN_LD8__LD8 IOMUX_MODE(MX31_PIN_LD8, IOMUX_CONFIG_FUNC)
570#define MX31_PIN_LD9__LD9 IOMUX_MODE(MX31_PIN_LD9, IOMUX_CONFIG_FUNC)
571#define MX31_PIN_LD10__LD10 IOMUX_MODE(MX31_PIN_LD10, IOMUX_CONFIG_FUNC)
572#define MX31_PIN_LD11__LD11 IOMUX_MODE(MX31_PIN_LD11, IOMUX_CONFIG_FUNC)
573#define MX31_PIN_LD12__LD12 IOMUX_MODE(MX31_PIN_LD12, IOMUX_CONFIG_FUNC)
574#define MX31_PIN_LD13__LD13 IOMUX_MODE(MX31_PIN_LD13, IOMUX_CONFIG_FUNC)
575#define MX31_PIN_LD14__LD14 IOMUX_MODE(MX31_PIN_LD14, IOMUX_CONFIG_FUNC)
576#define MX31_PIN_LD15__LD15 IOMUX_MODE(MX31_PIN_LD15, IOMUX_CONFIG_FUNC)
577#define MX31_PIN_LD16__LD16 IOMUX_MODE(MX31_PIN_LD16, IOMUX_CONFIG_FUNC)
578#define MX31_PIN_LD17__LD17 IOMUX_MODE(MX31_PIN_LD17, IOMUX_CONFIG_FUNC)
579#define MX31_PIN_VSYNC3__VSYNC3 IOMUX_MODE(MX31_PIN_VSYNC3, IOMUX_CONFIG_FUNC)
580#define MX31_PIN_HSYNC__HSYNC IOMUX_MODE(MX31_PIN_HSYNC, IOMUX_CONFIG_FUNC)
581#define MX31_PIN_FPSHIFT__FPSHIFT IOMUX_MODE(MX31_PIN_FPSHIFT, IOMUX_CONFIG_FUNC)
582#define MX31_PIN_DRDY0__DRDY0 IOMUX_MODE(MX31_PIN_DRDY0, IOMUX_CONFIG_FUNC)
583#define MX31_PIN_D3_REV__D3_REV IOMUX_MODE(MX31_PIN_D3_REV, IOMUX_CONFIG_FUNC)
584#define MX31_PIN_CONTRAST__CONTRAST IOMUX_MODE(MX31_PIN_CONTRAST, IOMUX_CONFIG_FUNC)
585#define MX31_PIN_D3_SPL__D3_SPL IOMUX_MODE(MX31_PIN_D3_SPL, IOMUX_CONFIG_FUNC)
586#define MX31_PIN_D3_CLS__D3_CLS IOMUX_MODE(MX31_PIN_D3_CLS, IOMUX_CONFIG_FUNC)
587#define MX31_PIN_LCS0__GPI03_23 IOMUX_MODE(MX31_PIN_LCS0, IOMUX_CONFIG_GPIO)
528 588
529/*XXX: The SS0, SS1, SS2, SS3 lines of spi3 are multiplexed by cspi2_ss0, cspi2_ss1, cspi1_ss0 589/*XXX: The SS0, SS1, SS2, SS3 lines of spi3 are multiplexed by cspi2_ss0, cspi2_ss1, cspi1_ss0
530 * cspi1_ss1*/ 590 * cspi1_ss1*/
diff --git a/arch/arm/plat-mxc/include/mach/iomux.h b/arch/arm/plat-mxc/include/mach/iomux.h
new file mode 100644
index 000000000000..171f8adc1109
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/iomux.h
@@ -0,0 +1,127 @@
1/*
2* Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de>
3* Copyright (C) 2009 by Holger Schurig <hs4233@mail.mn-solutions.de>
4*
5* This program is free software; you can redistribute it and/or
6* modify it under the terms of the GNU General Public License
7* as published by the Free Software Foundation; either version 2
8* of the License, or (at your option) any later version.
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program; if not, write to the Free Software
16* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301, USA.
18*/
19
20#ifndef _MXC_IOMUX_H
21#define _MXC_IOMUX_H
22
23/*
24* GPIO Module and I/O Multiplexer
25* x = 0..3 for reg_A, reg_B, reg_C, reg_D
26*/
27#define VA_GPIO_BASE IO_ADDRESS(GPIO_BASE_ADDR)
28#define MXC_DDIR(x) (0x00 + ((x) << 8))
29#define MXC_OCR1(x) (0x04 + ((x) << 8))
30#define MXC_OCR2(x) (0x08 + ((x) << 8))
31#define MXC_ICONFA1(x) (0x0c + ((x) << 8))
32#define MXC_ICONFA2(x) (0x10 + ((x) << 8))
33#define MXC_ICONFB1(x) (0x14 + ((x) << 8))
34#define MXC_ICONFB2(x) (0x18 + ((x) << 8))
35#define MXC_DR(x) (0x1c + ((x) << 8))
36#define MXC_GIUS(x) (0x20 + ((x) << 8))
37#define MXC_SSR(x) (0x24 + ((x) << 8))
38#define MXC_ICR1(x) (0x28 + ((x) << 8))
39#define MXC_ICR2(x) (0x2c + ((x) << 8))
40#define MXC_IMR(x) (0x30 + ((x) << 8))
41#define MXC_ISR(x) (0x34 + ((x) << 8))
42#define MXC_GPR(x) (0x38 + ((x) << 8))
43#define MXC_SWR(x) (0x3c + ((x) << 8))
44#define MXC_PUEN(x) (0x40 + ((x) << 8))
45
46#ifdef CONFIG_ARCH_MX1
47# define GPIO_PORT_MAX 3
48#endif
49#ifdef CONFIG_ARCH_MX2
50# define GPIO_PORT_MAX 5
51#endif
52
53#ifndef GPIO_PORT_MAX
54# error "GPIO config port count unknown!"
55#endif
56
57#define GPIO_PIN_MASK 0x1f
58
59#define GPIO_PORT_SHIFT 5
60#define GPIO_PORT_MASK (0x7 << GPIO_PORT_SHIFT)
61
62#define GPIO_PORTA (0 << GPIO_PORT_SHIFT)
63#define GPIO_PORTB (1 << GPIO_PORT_SHIFT)
64#define GPIO_PORTC (2 << GPIO_PORT_SHIFT)
65#define GPIO_PORTD (3 << GPIO_PORT_SHIFT)
66#define GPIO_PORTE (4 << GPIO_PORT_SHIFT)
67#define GPIO_PORTF (5 << GPIO_PORT_SHIFT)
68
69#define GPIO_OUT (1 << 8)
70#define GPIO_IN (0 << 8)
71#define GPIO_PUEN (1 << 9)
72
73#define GPIO_PF (1 << 10)
74#define GPIO_AF (1 << 11)
75
76#define GPIO_OCR_SHIFT 12
77#define GPIO_OCR_MASK (3 << GPIO_OCR_SHIFT)
78#define GPIO_AIN (0 << GPIO_OCR_SHIFT)
79#define GPIO_BIN (1 << GPIO_OCR_SHIFT)
80#define GPIO_CIN (2 << GPIO_OCR_SHIFT)
81#define GPIO_GPIO (3 << GPIO_OCR_SHIFT)
82
83#define GPIO_AOUT_SHIFT 14
84#define GPIO_AOUT_MASK (3 << GPIO_AOUT_SHIFT)
85#define GPIO_AOUT (0 << GPIO_AOUT_SHIFT)
86#define GPIO_AOUT_ISR (1 << GPIO_AOUT_SHIFT)
87#define GPIO_AOUT_0 (2 << GPIO_AOUT_SHIFT)
88#define GPIO_AOUT_1 (3 << GPIO_AOUT_SHIFT)
89
90#define GPIO_BOUT_SHIFT 16
91#define GPIO_BOUT_MASK (3 << GPIO_BOUT_SHIFT)
92#define GPIO_BOUT (0 << GPIO_BOUT_SHIFT)
93#define GPIO_BOUT_ISR (1 << GPIO_BOUT_SHIFT)
94#define GPIO_BOUT_0 (2 << GPIO_BOUT_SHIFT)
95#define GPIO_BOUT_1 (3 << GPIO_BOUT_SHIFT)
96
97
98#ifdef CONFIG_ARCH_MX1
99#include <mach/iomux-mx1.h>
100#endif
101#ifdef CONFIG_ARCH_MX2
102#include <mach/iomux-mx2x.h>
103#ifdef CONFIG_MACH_MX21
104#include <mach/iomux-mx21.h>
105#endif
106#ifdef CONFIG_MACH_MX27
107#include <mach/iomux-mx27.h>
108#endif
109#endif
110
111
112/* decode irq number to use with IMR(x), ISR(x) and friends */
113#define IRQ_TO_REG(irq) ((irq - MXC_INTERNAL_IRQS) >> 5)
114
115#define IRQ_GPIOA(x) (MXC_GPIO_IRQ_START + x)
116#define IRQ_GPIOB(x) (IRQ_GPIOA(32) + x)
117#define IRQ_GPIOC(x) (IRQ_GPIOB(32) + x)
118#define IRQ_GPIOD(x) (IRQ_GPIOC(32) + x)
119#define IRQ_GPIOE(x) (IRQ_GPIOD(32) + x)
120
121
122extern void mxc_gpio_mode(int gpio_mode);
123extern int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count,
124 const char *label);
125extern void mxc_gpio_release_multiple_pins(const int *pin_list, int count);
126
127#endif
diff --git a/arch/arm/plat-mxc/include/mach/memory.h b/arch/arm/plat-mxc/include/mach/memory.h
index 0b808399097f..e0783e619580 100644
--- a/arch/arm/plat-mxc/include/mach/memory.h
+++ b/arch/arm/plat-mxc/include/mach/memory.h
@@ -14,7 +14,12 @@
14#if defined CONFIG_ARCH_MX1 14#if defined CONFIG_ARCH_MX1
15#define PHYS_OFFSET UL(0x08000000) 15#define PHYS_OFFSET UL(0x08000000)
16#elif defined CONFIG_ARCH_MX2 16#elif defined CONFIG_ARCH_MX2
17#ifdef CONFIG_MACH_MX21
18#define PHYS_OFFSET UL(0xC0000000)
19#endif
20#ifdef CONFIG_MACH_MX27
17#define PHYS_OFFSET UL(0xA0000000) 21#define PHYS_OFFSET UL(0xA0000000)
22#endif
18#elif defined CONFIG_ARCH_MX3 23#elif defined CONFIG_ARCH_MX3
19#define PHYS_OFFSET UL(0x80000000) 24#define PHYS_OFFSET UL(0x80000000)
20#endif 25#endif
diff --git a/arch/arm/plat-mxc/include/mach/mx21.h b/arch/arm/plat-mxc/include/mach/mx21.h
new file mode 100644
index 000000000000..e8c4cf56c24e
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/mx21.h
@@ -0,0 +1,78 @@
1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
4 * Copyright 2009 Holger Schurig, hs4233@mail.mn-solutions.de
5 *
6 * This contains i.MX21-specific hardware definitions. For those
7 * hardware pieces that are common between i.MX21 and i.MX27, have a
8 * look at mx2x.h.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 * MA 02110-1301, USA.
23 */
24
25#ifndef __ASM_ARCH_MXC_MX21_H__
26#define __ASM_ARCH_MXC_MX21_H__
27
28#ifndef __ASM_ARCH_MXC_HARDWARE_H__
29#error "Do not include directly."
30#endif
31
32
33/* Memory regions and CS */
34#define SDRAM_BASE_ADDR 0xC0000000
35#define CSD1_BASE_ADDR 0xC4000000
36
37#define CS0_BASE_ADDR 0xC8000000
38#define CS1_BASE_ADDR 0xCC000000
39#define CS2_BASE_ADDR 0xD0000000
40#define CS3_BASE_ADDR 0xD1000000
41#define CS4_BASE_ADDR 0xD2000000
42#define CS5_BASE_ADDR 0xDD000000
43#define PCMCIA_MEM_BASE_ADDR 0xD4000000
44
45/* NAND, SDRAM, WEIM etc controllers */
46#define X_MEMC_BASE_ADDR 0xDF000000
47#define X_MEMC_BASE_ADDR_VIRT 0xF4200000
48#define X_MEMC_SIZE SZ_256K
49
50#define SDRAMC_BASE_ADDR (X_MEMC_BASE_ADDR + 0x0000)
51#define EIM_BASE_ADDR (X_MEMC_BASE_ADDR + 0x1000)
52#define PCMCIA_CTL_BASE_ADDR (X_MEMC_BASE_ADDR + 0x2000)
53#define NFC_BASE_ADDR (X_MEMC_BASE_ADDR + 0x3000)
54
55#define IRAM_BASE_ADDR 0xFFFFE800 /* internal ram */
56
57/* this CPU supports up to 192 GPIOs (don't forget the baseboard!) */
58#define ARCH_NR_GPIOS (6*32 + 16)
59
60/* fixed interrupt numbers */
61#define MXC_INT_USBCTRL 58
62#define MXC_INT_USBCTRL 58
63#define MXC_INT_USBMNP 57
64#define MXC_INT_USBFUNC 56
65#define MXC_INT_USBHOST 55
66#define MXC_INT_USBDMA 54
67#define MXC_INT_USBWKUP 53
68#define MXC_INT_EMMADEC 50
69#define MXC_INT_EMMAENC 49
70#define MXC_INT_BMI 30
71#define MXC_INT_FIRI 9
72
73/* fixed DMA request numbers */
74#define DMA_REQ_BMI_RX 29
75#define DMA_REQ_BMI_TX 28
76#define DMA_REQ_FIRI_RX 4
77
78#endif /* __ASM_ARCH_MXC_MX21_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/mx27.h b/arch/arm/plat-mxc/include/mach/mx27.h
index 0313be720552..6e93f2c0b7bb 100644
--- a/arch/arm/plat-mxc/include/mach/mx27.h
+++ b/arch/arm/plat-mxc/include/mach/mx27.h
@@ -2,6 +2,10 @@
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. 2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de 3 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
4 * 4 *
5 * This contains i.MX27-specific hardware definitions. For those
6 * hardware pieces that are common between i.MX21 and i.MX27, have a
7 * look at mx2x.h.
8 *
5 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2 11 * as published by the Free Software Foundation; either version 2
@@ -27,35 +31,6 @@
27/* IRAM */ 31/* IRAM */
28#define IRAM_BASE_ADDR 0xFFFF4C00 /* internal ram */ 32#define IRAM_BASE_ADDR 0xFFFF4C00 /* internal ram */
29 33
30/* Register offests */
31#define AIPI_BASE_ADDR 0x10000000
32#define AIPI_BASE_ADDR_VIRT 0xF4000000
33#define AIPI_SIZE SZ_1M
34
35#define DMA_BASE_ADDR (AIPI_BASE_ADDR + 0x01000)
36#define WDOG_BASE_ADDR (AIPI_BASE_ADDR + 0x02000)
37#define GPT1_BASE_ADDR (AIPI_BASE_ADDR + 0x03000)
38#define GPT2_BASE_ADDR (AIPI_BASE_ADDR + 0x04000)
39#define GPT3_BASE_ADDR (AIPI_BASE_ADDR + 0x05000)
40#define PWM_BASE_ADDR (AIPI_BASE_ADDR + 0x06000)
41#define RTC_BASE_ADDR (AIPI_BASE_ADDR + 0x07000)
42#define KPP_BASE_ADDR (AIPI_BASE_ADDR + 0x08000)
43#define OWIRE_BASE_ADDR (AIPI_BASE_ADDR + 0x09000)
44#define UART1_BASE_ADDR (AIPI_BASE_ADDR + 0x0A000)
45#define UART2_BASE_ADDR (AIPI_BASE_ADDR + 0x0B000)
46#define UART3_BASE_ADDR (AIPI_BASE_ADDR + 0x0C000)
47#define UART4_BASE_ADDR (AIPI_BASE_ADDR + 0x0D000)
48#define CSPI1_BASE_ADDR (AIPI_BASE_ADDR + 0x0E000)
49#define CSPI2_BASE_ADDR (AIPI_BASE_ADDR + 0x0F000)
50#define SSI1_BASE_ADDR (AIPI_BASE_ADDR + 0x10000)
51#define SSI2_BASE_ADDR (AIPI_BASE_ADDR + 0x11000)
52#define I2C_BASE_ADDR (AIPI_BASE_ADDR + 0x12000)
53#define SDHC1_BASE_ADDR (AIPI_BASE_ADDR + 0x13000)
54#define SDHC2_BASE_ADDR (AIPI_BASE_ADDR + 0x14000)
55#define GPIO_BASE_ADDR (AIPI_BASE_ADDR + 0x15000)
56#define AUDMUX_BASE_ADDR (AIPI_BASE_ADDR + 0x16000)
57
58#define CSPI3_BASE_ADDR (AIPI_BASE_ADDR + 0x17000)
59#define MSHC_BASE_ADDR (AIPI_BASE_ADDR + 0x18000) 34#define MSHC_BASE_ADDR (AIPI_BASE_ADDR + 0x18000)
60#define GPT5_BASE_ADDR (AIPI_BASE_ADDR + 0x19000) 35#define GPT5_BASE_ADDR (AIPI_BASE_ADDR + 0x19000)
61#define GPT4_BASE_ADDR (AIPI_BASE_ADDR + 0x1A000) 36#define GPT4_BASE_ADDR (AIPI_BASE_ADDR + 0x1A000)
@@ -64,55 +39,24 @@
64#define I2C2_BASE_ADDR (AIPI_BASE_ADDR + 0x1D000) 39#define I2C2_BASE_ADDR (AIPI_BASE_ADDR + 0x1D000)
65#define SDHC3_BASE_ADDR (AIPI_BASE_ADDR + 0x1E000) 40#define SDHC3_BASE_ADDR (AIPI_BASE_ADDR + 0x1E000)
66#define GPT6_BASE_ADDR (AIPI_BASE_ADDR + 0x1F000) 41#define GPT6_BASE_ADDR (AIPI_BASE_ADDR + 0x1F000)
67
68#define LCDC_BASE_ADDR (AIPI_BASE_ADDR + 0x21000)
69#define SLCDC_BASE_ADDR (AIPI_BASE_ADDR + 0x22000)
70#define VPU_BASE_ADDR (AIPI_BASE_ADDR + 0x23000) 42#define VPU_BASE_ADDR (AIPI_BASE_ADDR + 0x23000)
71#define USBOTG_BASE_ADDR (AIPI_BASE_ADDR + 0x24000)
72/* for mx27*/
73#define OTG_BASE_ADDR USBOTG_BASE_ADDR 43#define OTG_BASE_ADDR USBOTG_BASE_ADDR
74#define SAHARA_BASE_ADDR (AIPI_BASE_ADDR + 0x25000) 44#define SAHARA_BASE_ADDR (AIPI_BASE_ADDR + 0x25000)
75#define EMMA_PP_BASE_ADDR (AIPI_BASE_ADDR + 0x26000)
76#define EMMA_PRP_BASE_ADDR (AIPI_BASE_ADDR + 0x26400)
77#define CCM_BASE_ADDR (AIPI_BASE_ADDR + 0x27000)
78#define SYSCTRL_BASE_ADDR (AIPI_BASE_ADDR + 0x27800)
79#define IIM_BASE_ADDR (AIPI_BASE_ADDR + 0x28000) 45#define IIM_BASE_ADDR (AIPI_BASE_ADDR + 0x28000)
80
81#define RTIC_BASE_ADDR (AIPI_BASE_ADDR + 0x2A000) 46#define RTIC_BASE_ADDR (AIPI_BASE_ADDR + 0x2A000)
82#define FEC_BASE_ADDR (AIPI_BASE_ADDR + 0x2B000) 47#define FEC_BASE_ADDR (AIPI_BASE_ADDR + 0x2B000)
83#define SCC_BASE_ADDR (AIPI_BASE_ADDR + 0x2C000) 48#define SCC_BASE_ADDR (AIPI_BASE_ADDR + 0x2C000)
84#define ETB_BASE_ADDR (AIPI_BASE_ADDR + 0x3B000) 49#define ETB_BASE_ADDR (AIPI_BASE_ADDR + 0x3B000)
85#define ETB_RAM_BASE_ADDR (AIPI_BASE_ADDR + 0x3C000) 50#define ETB_RAM_BASE_ADDR (AIPI_BASE_ADDR + 0x3C000)
86 51
87#define JAM_BASE_ADDR (AIPI_BASE_ADDR + 0x3E000) 52/* ROM patch */
88#define MAX_BASE_ADDR (AIPI_BASE_ADDR + 0x3F000)
89
90/* ROMP and AVIC */
91#define ROMP_BASE_ADDR 0x10041000 53#define ROMP_BASE_ADDR 0x10041000
92 54
93#define AVIC_BASE_ADDR 0x10040000
94
95#define SAHB1_BASE_ADDR 0x80000000
96#define SAHB1_BASE_ADDR_VIRT 0xF4100000
97#define SAHB1_SIZE SZ_1M
98
99#define CSI_BASE_ADDR (SAHB1_BASE_ADDR + 0x0000)
100#define ATA_BASE_ADDR (SAHB1_BASE_ADDR + 0x1000) 55#define ATA_BASE_ADDR (SAHB1_BASE_ADDR + 0x1000)
101 56
102/* NAND, SDRAM, WEIM, M3IF, EMI controllers */
103#define X_MEMC_BASE_ADDR 0xD8000000
104#define X_MEMC_BASE_ADDR_VIRT 0xF4200000
105#define X_MEMC_SIZE SZ_1M
106
107#define NFC_BASE_ADDR (X_MEMC_BASE_ADDR)
108#define SDRAMC_BASE_ADDR (X_MEMC_BASE_ADDR + 0x1000)
109#define WEIM_BASE_ADDR (X_MEMC_BASE_ADDR + 0x2000)
110#define M3IF_BASE_ADDR (X_MEMC_BASE_ADDR + 0x3000)
111#define PCMCIA_CTL_BASE_ADDR (X_MEMC_BASE_ADDR + 0x4000)
112
113/* Memory regions and CS */ 57/* Memory regions and CS */
114#define SDRAM_BASE_ADDR 0xA0000000 58#define SDRAM_BASE_ADDR 0xA0000000
115#define CSD1_BASE_ADDR 0xB0000000 59#define CSD1_BASE_ADDR 0xB0000000
116 60
117#define CS0_BASE_ADDR 0xC0000000 61#define CS0_BASE_ADDR 0xC0000000
118#define CS1_BASE_ADDR 0xC8000000 62#define CS1_BASE_ADDR 0xC8000000
@@ -122,44 +66,20 @@
122#define CS5_BASE_ADDR 0xD6000000 66#define CS5_BASE_ADDR 0xD6000000
123#define PCMCIA_MEM_BASE_ADDR 0xDC000000 67#define PCMCIA_MEM_BASE_ADDR 0xDC000000
124 68
125/* 69/* NAND, SDRAM, WEIM, M3IF, EMI controllers */
126 * This macro defines the physical to virtual address mapping for all the 70#define X_MEMC_BASE_ADDR 0xD8000000
127 * peripheral modules. It is used by passing in the physical address as x 71#define X_MEMC_BASE_ADDR_VIRT 0xF4200000
128 * and returning the virtual address. If the physical address is not mapped, 72#define X_MEMC_SIZE SZ_1M
129 * it returns 0xDEADBEEF
130 */
131#define IO_ADDRESS(x) \
132 (void __iomem *) \
133 (((x >= AIPI_BASE_ADDR) && (x < (AIPI_BASE_ADDR + AIPI_SIZE))) ? \
134 AIPI_IO_ADDRESS(x) : \
135 ((x >= SAHB1_BASE_ADDR) && (x < (SAHB1_BASE_ADDR + SAHB1_SIZE))) ? \
136 SAHB1_IO_ADDRESS(x) : \
137 ((x >= X_MEMC_BASE_ADDR) && (x < (X_MEMC_BASE_ADDR + X_MEMC_SIZE))) ? \
138 X_MEMC_IO_ADDRESS(x) : 0xDEADBEEF)
139
140/* define the address mapping macros: in physical address order */
141#define AIPI_IO_ADDRESS(x) \
142 (((x) - AIPI_BASE_ADDR) + AIPI_BASE_ADDR_VIRT)
143
144#define AVIC_IO_ADDRESS(x) AIPI_IO_ADDRESS(x)
145
146#define SAHB1_IO_ADDRESS(x) \
147 (((x) - SAHB1_BASE_ADDR) + SAHB1_BASE_ADDR_VIRT)
148
149#define CS4_IO_ADDRESS(x) \
150 (((x) - CS4_BASE_ADDR) + CS4_BASE_ADDR_VIRT)
151
152#define X_MEMC_IO_ADDRESS(x) \
153 (((x) - X_MEMC_BASE_ADDR) + X_MEMC_BASE_ADDR_VIRT)
154 73
155#define PCMCIA_IO_ADDRESS(x) \ 74#define NFC_BASE_ADDR (X_MEMC_BASE_ADDR)
156 (((x) - X_MEMC_BASE_ADDR) + X_MEMC_BASE_ADDR_VIRT) 75#define SDRAMC_BASE_ADDR (X_MEMC_BASE_ADDR + 0x1000)
76#define WEIM_BASE_ADDR (X_MEMC_BASE_ADDR + 0x2000)
77#define M3IF_BASE_ADDR (X_MEMC_BASE_ADDR + 0x3000)
78#define PCMCIA_CTL_BASE_ADDR (X_MEMC_BASE_ADDR + 0x4000)
157 79
158/* fixed interrput numbers */ 80/* fixed interrupt numbers */
159#define MXC_INT_CCM 63 81#define MXC_INT_CCM 63
160#define MXC_INT_IIM 62 82#define MXC_INT_IIM 62
161#define MXC_INT_LCDC 61
162#define MXC_INT_SLCDC 60
163#define MXC_INT_SAHARA 59 83#define MXC_INT_SAHARA 59
164#define MXC_INT_SCC_SCM 58 84#define MXC_INT_SCC_SCM 58
165#define MXC_INT_SCC_SMN 57 85#define MXC_INT_SCC_SMN 57
@@ -167,54 +87,12 @@
167#define MXC_INT_USB2 55 87#define MXC_INT_USB2 55
168#define MXC_INT_USB1 54 88#define MXC_INT_USB1 54
169#define MXC_INT_VPU 53 89#define MXC_INT_VPU 53
170#define MXC_INT_EMMAPP 52
171#define MXC_INT_EMMAPRP 51
172#define MXC_INT_FEC 50 90#define MXC_INT_FEC 50
173#define MXC_INT_UART5 49 91#define MXC_INT_UART5 49
174#define MXC_INT_UART6 48 92#define MXC_INT_UART6 48
175#define MXC_INT_DMACH15 47
176#define MXC_INT_DMACH14 46
177#define MXC_INT_DMACH13 45
178#define MXC_INT_DMACH12 44
179#define MXC_INT_DMACH11 43
180#define MXC_INT_DMACH10 42
181#define MXC_INT_DMACH9 41
182#define MXC_INT_DMACH8 40
183#define MXC_INT_DMACH7 39
184#define MXC_INT_DMACH6 38
185#define MXC_INT_DMACH5 37
186#define MXC_INT_DMACH4 36
187#define MXC_INT_DMACH3 35
188#define MXC_INT_DMACH2 34
189#define MXC_INT_DMACH1 33
190#define MXC_INT_DMACH0 32
191#define MXC_INT_CSI 31
192#define MXC_INT_ATA 30 93#define MXC_INT_ATA 30
193#define MXC_INT_NANDFC 29
194#define MXC_INT_PCMCIA 28
195#define MXC_INT_WDOG 27
196#define MXC_INT_GPT1 26
197#define MXC_INT_GPT2 25
198#define MXC_INT_GPT3 24
199#define MXC_INT_GPT INT_GPT1
200#define MXC_INT_PWM 23
201#define MXC_INT_RTC 22
202#define MXC_INT_KPP 21
203#define MXC_INT_UART1 20
204#define MXC_INT_UART2 19
205#define MXC_INT_UART3 18
206#define MXC_INT_UART4 17
207#define MXC_INT_CSPI1 16
208#define MXC_INT_CSPI2 15
209#define MXC_INT_SSI1 14
210#define MXC_INT_SSI2 13
211#define MXC_INT_I2C 12
212#define MXC_INT_SDHC1 11
213#define MXC_INT_SDHC2 10
214#define MXC_INT_SDHC3 9 94#define MXC_INT_SDHC3 9
215#define MXC_INT_GPIO 8
216#define MXC_INT_SDHC 7 95#define MXC_INT_SDHC 7
217#define MXC_INT_CSPI3 6
218#define MXC_INT_RTIC 5 96#define MXC_INT_RTIC 5
219#define MXC_INT_GPT4 4 97#define MXC_INT_GPT4 4
220#define MXC_INT_GPT5 3 98#define MXC_INT_GPT5 3
@@ -228,36 +106,9 @@
228#define DMA_REQ_UART6_TX 34 106#define DMA_REQ_UART6_TX 34
229#define DMA_REQ_UART5_RX 33 107#define DMA_REQ_UART5_RX 33
230#define DMA_REQ_UART5_TX 32 108#define DMA_REQ_UART5_TX 32
231#define DMA_REQ_CSI_RX 31
232#define DMA_REQ_CSI_STAT 30
233#define DMA_REQ_ATA_RCV 29 109#define DMA_REQ_ATA_RCV 29
234#define DMA_REQ_ATA_TX 28 110#define DMA_REQ_ATA_TX 28
235#define DMA_REQ_UART1_TX 27
236#define DMA_REQ_UART1_RX 26
237#define DMA_REQ_UART2_TX 25
238#define DMA_REQ_UART2_RX 24
239#define DMA_REQ_UART3_TX 23
240#define DMA_REQ_UART3_RX 22
241#define DMA_REQ_UART4_TX 21
242#define DMA_REQ_UART4_RX 20
243#define DMA_REQ_CSPI1_TX 19
244#define DMA_REQ_CSPI1_RX 18
245#define DMA_REQ_CSPI2_TX 17
246#define DMA_REQ_CSPI2_RX 16
247#define DMA_REQ_SSI1_TX1 15
248#define DMA_REQ_SSI1_RX1 14
249#define DMA_REQ_SSI1_TX0 13
250#define DMA_REQ_SSI1_RX0 12
251#define DMA_REQ_SSI2_TX1 11
252#define DMA_REQ_SSI2_RX1 10
253#define DMA_REQ_SSI2_TX0 9
254#define DMA_REQ_SSI2_RX0 8
255#define DMA_REQ_SDHC1 7
256#define DMA_REQ_SDHC2 6
257#define DMA_REQ_MSHC 4 111#define DMA_REQ_MSHC 4
258#define DMA_REQ_EXT 3
259#define DMA_REQ_CSPI3_TX 2
260#define DMA_REQ_CSPI3_RX 1
261 112
262/* silicon revisions specific to i.MX27 */ 113/* silicon revisions specific to i.MX27 */
263#define CHIP_REV_1_0 0x00 114#define CHIP_REV_1_0 0x00
@@ -267,25 +118,8 @@
267extern int mx27_revision(void); 118extern int mx27_revision(void);
268#endif 119#endif
269 120
270/* gpio and gpio based interrupt handling */
271#define GPIO_DR 0x1C
272#define GPIO_GDIR 0x00
273#define GPIO_PSR 0x24
274#define GPIO_ICR1 0x28
275#define GPIO_ICR2 0x2C
276#define GPIO_IMR 0x30
277#define GPIO_ISR 0x34
278#define GPIO_INT_LOW_LEV 0x3
279#define GPIO_INT_HIGH_LEV 0x2
280#define GPIO_INT_RISE_EDGE 0x0
281#define GPIO_INT_FALL_EDGE 0x1
282#define GPIO_INT_NONE 0x4
283
284/* Mandatory defines used globally */ 121/* Mandatory defines used globally */
285 122
286/* this is an i.MX27 CPU */
287#define cpu_is_mx27() (1)
288
289/* this CPU supports up to 192 GPIOs (don't forget the baseboard!) */ 123/* this CPU supports up to 192 GPIOs (don't forget the baseboard!) */
290#define ARCH_NR_GPIOS (192 + 16) 124#define ARCH_NR_GPIOS (192 + 16)
291 125
diff --git a/arch/arm/plat-mxc/include/mach/mx2x.h b/arch/arm/plat-mxc/include/mach/mx2x.h
new file mode 100644
index 000000000000..fc40d3ab8c5b
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/mx2x.h
@@ -0,0 +1,200 @@
1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
4 *
5 * This contains hardware definitions that are common between i.MX21 and
6 * i.MX27.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301, USA.
21 */
22
23#ifndef __ASM_ARCH_MXC_MX2x_H__
24#define __ASM_ARCH_MXC_MX2x_H__
25
26#ifndef __ASM_ARCH_MXC_HARDWARE_H__
27#error "Do not include directly."
28#endif
29
30/* The following addresses are common between i.MX21 and i.MX27 */
31
32/* Register offests */
33#define AIPI_BASE_ADDR 0x10000000
34#define AIPI_BASE_ADDR_VIRT 0xF4000000
35#define AIPI_SIZE SZ_1M
36
37#define DMA_BASE_ADDR (AIPI_BASE_ADDR + 0x01000)
38#define WDOG_BASE_ADDR (AIPI_BASE_ADDR + 0x02000)
39#define GPT1_BASE_ADDR (AIPI_BASE_ADDR + 0x03000)
40#define GPT2_BASE_ADDR (AIPI_BASE_ADDR + 0x04000)
41#define GPT3_BASE_ADDR (AIPI_BASE_ADDR + 0x05000)
42#define PWM_BASE_ADDR (AIPI_BASE_ADDR + 0x06000)
43#define RTC_BASE_ADDR (AIPI_BASE_ADDR + 0x07000)
44#define KPP_BASE_ADDR (AIPI_BASE_ADDR + 0x08000)
45#define OWIRE_BASE_ADDR (AIPI_BASE_ADDR + 0x09000)
46#define UART1_BASE_ADDR (AIPI_BASE_ADDR + 0x0A000)
47#define UART2_BASE_ADDR (AIPI_BASE_ADDR + 0x0B000)
48#define UART3_BASE_ADDR (AIPI_BASE_ADDR + 0x0C000)
49#define UART4_BASE_ADDR (AIPI_BASE_ADDR + 0x0D000)
50#define CSPI1_BASE_ADDR (AIPI_BASE_ADDR + 0x0E000)
51#define CSPI2_BASE_ADDR (AIPI_BASE_ADDR + 0x0F000)
52#define SSI1_BASE_ADDR (AIPI_BASE_ADDR + 0x10000)
53#define SSI2_BASE_ADDR (AIPI_BASE_ADDR + 0x11000)
54#define I2C_BASE_ADDR (AIPI_BASE_ADDR + 0x12000)
55#define SDHC1_BASE_ADDR (AIPI_BASE_ADDR + 0x13000)
56#define SDHC2_BASE_ADDR (AIPI_BASE_ADDR + 0x14000)
57#define GPIO_BASE_ADDR (AIPI_BASE_ADDR + 0x15000)
58#define AUDMUX_BASE_ADDR (AIPI_BASE_ADDR + 0x16000)
59#define CSPI3_BASE_ADDR (AIPI_BASE_ADDR + 0x17000)
60#define LCDC_BASE_ADDR (AIPI_BASE_ADDR + 0x21000)
61#define SLCDC_BASE_ADDR (AIPI_BASE_ADDR + 0x22000)
62#define USBOTG_BASE_ADDR (AIPI_BASE_ADDR + 0x24000)
63#define EMMA_PP_BASE_ADDR (AIPI_BASE_ADDR + 0x26000)
64#define EMMA_PRP_BASE_ADDR (AIPI_BASE_ADDR + 0x26400)
65#define CCM_BASE_ADDR (AIPI_BASE_ADDR + 0x27000)
66#define SYSCTRL_BASE_ADDR (AIPI_BASE_ADDR + 0x27800)
67#define JAM_BASE_ADDR (AIPI_BASE_ADDR + 0x3E000)
68#define MAX_BASE_ADDR (AIPI_BASE_ADDR + 0x3F000)
69
70#define AVIC_BASE_ADDR 0x10040000
71
72#define SAHB1_BASE_ADDR 0x80000000
73#define SAHB1_BASE_ADDR_VIRT 0xF4100000
74#define SAHB1_SIZE SZ_1M
75
76#define CSI_BASE_ADDR (SAHB1_BASE_ADDR + 0x0000)
77
78/*
79 * This macro defines the physical to virtual address mapping for all the
80 * peripheral modules. It is used by passing in the physical address as x
81 * and returning the virtual address. If the physical address is not mapped,
82 * it returns 0xDEADBEEF
83 */
84#define IO_ADDRESS(x) \
85 (void __force __iomem *) \
86 (((x >= AIPI_BASE_ADDR) && (x < (AIPI_BASE_ADDR + AIPI_SIZE))) ? \
87 AIPI_IO_ADDRESS(x) : \
88 ((x >= SAHB1_BASE_ADDR) && (x < (SAHB1_BASE_ADDR + SAHB1_SIZE))) ? \
89 SAHB1_IO_ADDRESS(x) : \
90 ((x >= X_MEMC_BASE_ADDR) && (x < (X_MEMC_BASE_ADDR + X_MEMC_SIZE))) ? \
91 X_MEMC_IO_ADDRESS(x) : 0xDEADBEEF)
92
93/* define the address mapping macros: in physical address order */
94#define AIPI_IO_ADDRESS(x) \
95 (((x) - AIPI_BASE_ADDR) + AIPI_BASE_ADDR_VIRT)
96
97#define AVIC_IO_ADDRESS(x) AIPI_IO_ADDRESS(x)
98
99#define SAHB1_IO_ADDRESS(x) \
100 (((x) - SAHB1_BASE_ADDR) + SAHB1_BASE_ADDR_VIRT)
101
102#define CS4_IO_ADDRESS(x) \
103 (((x) - CS4_BASE_ADDR) + CS4_BASE_ADDR_VIRT)
104
105#define X_MEMC_IO_ADDRESS(x) \
106 (((x) - X_MEMC_BASE_ADDR) + X_MEMC_BASE_ADDR_VIRT)
107
108#define PCMCIA_IO_ADDRESS(x) \
109 (((x) - X_MEMC_BASE_ADDR) + X_MEMC_BASE_ADDR_VIRT)
110
111/* fixed interrupt numbers */
112#define MXC_INT_LCDC 61
113#define MXC_INT_SLCDC 60
114#define MXC_INT_EMMAPP 52
115#define MXC_INT_EMMAPRP 51
116#define MXC_INT_DMACH15 47
117#define MXC_INT_DMACH14 46
118#define MXC_INT_DMACH13 45
119#define MXC_INT_DMACH12 44
120#define MXC_INT_DMACH11 43
121#define MXC_INT_DMACH10 42
122#define MXC_INT_DMACH9 41
123#define MXC_INT_DMACH8 40
124#define MXC_INT_DMACH7 39
125#define MXC_INT_DMACH6 38
126#define MXC_INT_DMACH5 37
127#define MXC_INT_DMACH4 36
128#define MXC_INT_DMACH3 35
129#define MXC_INT_DMACH2 34
130#define MXC_INT_DMACH1 33
131#define MXC_INT_DMACH0 32
132#define MXC_INT_CSI 31
133#define MXC_INT_NANDFC 29
134#define MXC_INT_PCMCIA 28
135#define MXC_INT_WDOG 27
136#define MXC_INT_GPT1 26
137#define MXC_INT_GPT2 25
138#define MXC_INT_GPT3 24
139#define MXC_INT_GPT INT_GPT1
140#define MXC_INT_PWM 23
141#define MXC_INT_RTC 22
142#define MXC_INT_KPP 21
143#define MXC_INT_UART1 20
144#define MXC_INT_UART2 19
145#define MXC_INT_UART3 18
146#define MXC_INT_UART4 17
147#define MXC_INT_CSPI1 16
148#define MXC_INT_CSPI2 15
149#define MXC_INT_SSI1 14
150#define MXC_INT_SSI2 13
151#define MXC_INT_I2C 12
152#define MXC_INT_SDHC1 11
153#define MXC_INT_SDHC2 10
154#define MXC_INT_GPIO 8
155#define MXC_INT_CSPI3 6
156
157/* gpio and gpio based interrupt handling */
158#define GPIO_DR 0x1C
159#define GPIO_GDIR 0x00
160#define GPIO_PSR 0x24
161#define GPIO_ICR1 0x28
162#define GPIO_ICR2 0x2C
163#define GPIO_IMR 0x30
164#define GPIO_ISR 0x34
165#define GPIO_INT_LOW_LEV 0x3
166#define GPIO_INT_HIGH_LEV 0x2
167#define GPIO_INT_RISE_EDGE 0x0
168#define GPIO_INT_FALL_EDGE 0x1
169#define GPIO_INT_NONE 0x4
170
171/* fixed DMA request numbers */
172#define DMA_REQ_CSI_RX 31
173#define DMA_REQ_CSI_STAT 30
174#define DMA_REQ_UART1_TX 27
175#define DMA_REQ_UART1_RX 26
176#define DMA_REQ_UART2_TX 25
177#define DMA_REQ_UART2_RX 24
178#define DMA_REQ_UART3_TX 23
179#define DMA_REQ_UART3_RX 22
180#define DMA_REQ_UART4_TX 21
181#define DMA_REQ_UART4_RX 20
182#define DMA_REQ_CSPI1_TX 19
183#define DMA_REQ_CSPI1_RX 18
184#define DMA_REQ_CSPI2_TX 17
185#define DMA_REQ_CSPI2_RX 16
186#define DMA_REQ_SSI1_TX1 15
187#define DMA_REQ_SSI1_RX1 14
188#define DMA_REQ_SSI1_TX0 13
189#define DMA_REQ_SSI1_RX0 12
190#define DMA_REQ_SSI2_TX1 11
191#define DMA_REQ_SSI2_RX1 10
192#define DMA_REQ_SSI2_TX0 9
193#define DMA_REQ_SSI2_RX0 8
194#define DMA_REQ_SDHC1 7
195#define DMA_REQ_SDHC2 6
196#define DMA_REQ_EXT 3
197#define DMA_REQ_CSPI3_TX 2
198#define DMA_REQ_CSPI3_RX 1
199
200#endif /* __ASM_ARCH_MXC_MX2x_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/mx31.h b/arch/arm/plat-mxc/include/mach/mx31.h
index de026654b00e..0b06941b6139 100644
--- a/arch/arm/plat-mxc/include/mach/mx31.h
+++ b/arch/arm/plat-mxc/include/mach/mx31.h
@@ -1,360 +1,45 @@
1/* 1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_MXC_MX31_H__
12#define __ASM_ARCH_MXC_MX31_H__
13
14#ifndef __ASM_ARCH_MXC_HARDWARE_H__
15#error "Do not include directly."
16#endif
17
18/*
19 * MX31 memory map:
20 *
21 * Virt Phys Size What
22 * ---------------------------------------------------------------------------
23 * F8000000 1FFC0000 16K IRAM
24 * F9000000 30000000 256M L2CC
25 * FC000000 43F00000 1M AIPS 1
26 * FC100000 50000000 1M SPBA
27 * FC200000 53F00000 1M AIPS 2
28 * FC500000 60000000 128M ROMPATCH
29 * FC400000 68000000 128M AVIC
30 * 70000000 256M IPU (MAX M2)
31 * 80000000 256M CSD0 SDRAM/DDR
32 * 90000000 256M CSD1 SDRAM/DDR
33 * A0000000 128M CS0 Flash
34 * A8000000 128M CS1 Flash
35 * B0000000 32M CS2
36 * B2000000 32M CS3
37 * F4000000 B4000000 32M CS4
38 * B6000000 32M CS5
39 * FC320000 B8000000 64K NAND, SDRAM, WEIM, M3IF, EMI controllers
40 * C0000000 64M PCMCIA/CF
41 */
42
43#define CS0_BASE_ADDR 0xA0000000
44#define CS1_BASE_ADDR 0xA8000000
45#define CS2_BASE_ADDR 0xB0000000
46#define CS3_BASE_ADDR 0xB2000000
47
48#define CS4_BASE_ADDR 0xB4000000
49#define CS4_BASE_ADDR_VIRT 0xF4000000
50#define CS4_SIZE SZ_32M
51
52#define CS5_BASE_ADDR 0xB6000000
53#define PCMCIA_MEM_BASE_ADDR 0xBC000000
54
55/*
56 * IRAM 2 * IRAM
57 */ 3 */
58#define IRAM_BASE_ADDR 0x1FFC0000 /* internal ram */ 4#define MX31_IRAM_BASE_ADDR 0x1FFC0000 /* internal ram */
59#define IRAM_BASE_ADDR_VIRT 0xF8000000 5#define MX31_IRAM_SIZE SZ_16K
60#define IRAM_SIZE SZ_16K
61
62/*
63 * L2CC
64 */
65#define L2CC_BASE_ADDR 0x30000000
66#define L2CC_BASE_ADDR_VIRT 0xF9000000
67#define L2CC_SIZE SZ_1M
68
69/*
70 * AIPS 1
71 */
72#define AIPS1_BASE_ADDR 0x43F00000
73#define AIPS1_BASE_ADDR_VIRT 0xFC000000
74#define AIPS1_SIZE SZ_1M
75 6
76#define MAX_BASE_ADDR (AIPS1_BASE_ADDR + 0x00004000)
77#define EVTMON_BASE_ADDR (AIPS1_BASE_ADDR + 0x00008000)
78#define CLKCTL_BASE_ADDR (AIPS1_BASE_ADDR + 0x0000C000)
79#define ETB_SLOT4_BASE_ADDR (AIPS1_BASE_ADDR + 0x00010000)
80#define ETB_SLOT5_BASE_ADDR (AIPS1_BASE_ADDR + 0x00014000)
81#define ECT_CTIO_BASE_ADDR (AIPS1_BASE_ADDR + 0x00018000)
82#define I2C_BASE_ADDR (AIPS1_BASE_ADDR + 0x00080000)
83#define I2C3_BASE_ADDR (AIPS1_BASE_ADDR + 0x00084000)
84#define OTG_BASE_ADDR (AIPS1_BASE_ADDR + 0x00088000) 7#define OTG_BASE_ADDR (AIPS1_BASE_ADDR + 0x00088000)
85#define ATA_BASE_ADDR (AIPS1_BASE_ADDR + 0x0008C000) 8#define ATA_BASE_ADDR (AIPS1_BASE_ADDR + 0x0008C000)
86#define UART1_BASE_ADDR (AIPS1_BASE_ADDR + 0x00090000)
87#define UART2_BASE_ADDR (AIPS1_BASE_ADDR + 0x00094000)
88#define I2C2_BASE_ADDR (AIPS1_BASE_ADDR + 0x00098000)
89#define OWIRE_BASE_ADDR (AIPS1_BASE_ADDR + 0x0009C000)
90#define SSI1_BASE_ADDR (AIPS1_BASE_ADDR + 0x000A0000)
91#define CSPI1_BASE_ADDR (AIPS1_BASE_ADDR + 0x000A4000)
92#define KPP_BASE_ADDR (AIPS1_BASE_ADDR + 0x000A8000)
93#define IOMUXC_BASE_ADDR (AIPS1_BASE_ADDR + 0x000AC000)
94#define UART4_BASE_ADDR (AIPS1_BASE_ADDR + 0x000B0000) 9#define UART4_BASE_ADDR (AIPS1_BASE_ADDR + 0x000B0000)
95#define UART5_BASE_ADDR (AIPS1_BASE_ADDR + 0x000B4000) 10#define UART5_BASE_ADDR (AIPS1_BASE_ADDR + 0x000B4000)
96#define ECT_IP1_BASE_ADDR (AIPS1_BASE_ADDR + 0x000B8000)
97#define ECT_IP2_BASE_ADDR (AIPS1_BASE_ADDR + 0x000BC000)
98
99/*
100 * SPBA global module enabled #0
101 */
102#define SPBA0_BASE_ADDR 0x50000000
103#define SPBA0_BASE_ADDR_VIRT 0xFC100000
104#define SPBA0_SIZE SZ_1M
105 11
106#define MMC_SDHC1_BASE_ADDR (SPBA0_BASE_ADDR + 0x00004000) 12#define MMC_SDHC1_BASE_ADDR (SPBA0_BASE_ADDR + 0x00004000)
107#define MMC_SDHC2_BASE_ADDR (SPBA0_BASE_ADDR + 0x00008000) 13#define MMC_SDHC2_BASE_ADDR (SPBA0_BASE_ADDR + 0x00008000)
108#define UART3_BASE_ADDR (SPBA0_BASE_ADDR + 0x0000C000)
109#define CSPI2_BASE_ADDR (SPBA0_BASE_ADDR + 0x00010000)
110#define SSI2_BASE_ADDR (SPBA0_BASE_ADDR + 0x00014000)
111#define SIM1_BASE_ADDR (SPBA0_BASE_ADDR + 0x00018000) 14#define SIM1_BASE_ADDR (SPBA0_BASE_ADDR + 0x00018000)
112#define IIM_BASE_ADDR (SPBA0_BASE_ADDR + 0x0001C000) 15#define IIM_BASE_ADDR (SPBA0_BASE_ADDR + 0x0001C000)
113#define ATA_DMA_BASE_ADDR (SPBA0_BASE_ADDR + 0x00020000)
114#define MSHC1_BASE_ADDR (SPBA0_BASE_ADDR + 0x00024000)
115#define MSHC2_BASE_ADDR (SPBA0_BASE_ADDR + 0x00024000)
116#define SPBA_CTRL_BASE_ADDR (SPBA0_BASE_ADDR + 0x0003C000)
117 16
118/*
119 * AIPS 2
120 */
121#define AIPS2_BASE_ADDR 0x53F00000
122#define AIPS2_BASE_ADDR_VIRT 0xFC200000
123#define AIPS2_SIZE SZ_1M
124#define CCM_BASE_ADDR (AIPS2_BASE_ADDR + 0x00080000)
125#define CSPI3_BASE_ADDR (AIPS2_BASE_ADDR + 0x00084000) 17#define CSPI3_BASE_ADDR (AIPS2_BASE_ADDR + 0x00084000)
126#define FIRI_BASE_ADDR (AIPS2_BASE_ADDR + 0x0008C000) 18#define FIRI_BASE_ADDR (AIPS2_BASE_ADDR + 0x0008C000)
127#define GPT1_BASE_ADDR (AIPS2_BASE_ADDR + 0x00090000)
128#define EPIT1_BASE_ADDR (AIPS2_BASE_ADDR + 0x00094000)
129#define EPIT2_BASE_ADDR (AIPS2_BASE_ADDR + 0x00098000)
130#define GPIO3_BASE_ADDR (AIPS2_BASE_ADDR + 0x000A4000)
131#define SCC_BASE_ADDR (AIPS2_BASE_ADDR + 0x000AC000)
132#define SCM_BASE_ADDR (AIPS2_BASE_ADDR + 0x000AE000) 19#define SCM_BASE_ADDR (AIPS2_BASE_ADDR + 0x000AE000)
133#define SMN_BASE_ADDR (AIPS2_BASE_ADDR + 0x000AF000) 20#define SMN_BASE_ADDR (AIPS2_BASE_ADDR + 0x000AF000)
134#define RNGA_BASE_ADDR (AIPS2_BASE_ADDR + 0x000B0000)
135#define IPU_CTRL_BASE_ADDR (AIPS2_BASE_ADDR + 0x000C0000)
136#define AUDMUX_BASE_ADDR (AIPS2_BASE_ADDR + 0x000C4000)
137#define MPEG4_ENC_BASE_ADDR (AIPS2_BASE_ADDR + 0x000C8000) 21#define MPEG4_ENC_BASE_ADDR (AIPS2_BASE_ADDR + 0x000C8000)
138#define GPIO1_BASE_ADDR (AIPS2_BASE_ADDR + 0x000CC000)
139#define GPIO2_BASE_ADDR (AIPS2_BASE_ADDR + 0x000D0000)
140#define SDMA_BASE_ADDR (AIPS2_BASE_ADDR + 0x000D4000)
141#define RTC_BASE_ADDR (AIPS2_BASE_ADDR + 0x000D8000)
142#define WDOG_BASE_ADDR (AIPS2_BASE_ADDR + 0x000DC000)
143#define PWM_BASE_ADDR (AIPS2_BASE_ADDR + 0x000E0000)
144#define RTIC_BASE_ADDR (AIPS2_BASE_ADDR + 0x000EC000)
145
146/*
147 * ROMP and AVIC
148 */
149#define ROMP_BASE_ADDR 0x60000000
150#define ROMP_BASE_ADDR_VIRT 0xFC500000
151#define ROMP_SIZE SZ_1M
152
153#define AVIC_BASE_ADDR 0x68000000
154#define AVIC_BASE_ADDR_VIRT 0xFC400000
155#define AVIC_SIZE SZ_1M
156
157/*
158 * NAND, SDRAM, WEIM, M3IF, EMI controllers
159 */
160#define X_MEMC_BASE_ADDR 0xB8000000
161#define X_MEMC_BASE_ADDR_VIRT 0xFC320000
162#define X_MEMC_SIZE SZ_64K
163 22
164#define NFC_BASE_ADDR (X_MEMC_BASE_ADDR + 0x0000) 23#define MX31_NFC_BASE_ADDR (X_MEMC_BASE_ADDR + 0x0000)
165#define ESDCTL_BASE_ADDR (X_MEMC_BASE_ADDR + 0x1000)
166#define WEIM_BASE_ADDR (X_MEMC_BASE_ADDR + 0x2000)
167#define M3IF_BASE_ADDR (X_MEMC_BASE_ADDR + 0x3000)
168#define EMI_CTL_BASE_ADDR (X_MEMC_BASE_ADDR + 0x4000)
169#define PCMCIA_CTL_BASE_ADDR EMI_CTL_BASE_ADDR
170 24
171/*
172 * Memory regions and CS
173 */
174#define IPU_MEM_BASE_ADDR 0x70000000
175#define CSD0_BASE_ADDR 0x80000000
176#define CSD1_BASE_ADDR 0x90000000
177#define CS0_BASE_ADDR 0xA0000000
178#define CS1_BASE_ADDR 0xA8000000
179#define CS2_BASE_ADDR 0xB0000000
180#define CS3_BASE_ADDR 0xB2000000
181
182#define CS4_BASE_ADDR 0xB4000000
183#define CS4_BASE_ADDR_VIRT 0xF4000000
184#define CS4_SIZE SZ_32M
185
186#define CS5_BASE_ADDR 0xB6000000
187#define PCMCIA_MEM_BASE_ADDR 0xBC000000
188
189/*!
190 * This macro defines the physical to virtual address mapping for all the
191 * peripheral modules. It is used by passing in the physical address as x
192 * and returning the virtual address. If the physical address is not mapped,
193 * it returns 0xDEADBEEF
194 */
195#define IO_ADDRESS(x) \
196 (void __iomem *) \
197 (((x >= IRAM_BASE_ADDR) && (x < (IRAM_BASE_ADDR + IRAM_SIZE))) ? IRAM_IO_ADDRESS(x):\
198 ((x >= L2CC_BASE_ADDR) && (x < (L2CC_BASE_ADDR + L2CC_SIZE))) ? L2CC_IO_ADDRESS(x):\
199 ((x >= AIPS1_BASE_ADDR) && (x < (AIPS1_BASE_ADDR + AIPS1_SIZE))) ? AIPS1_IO_ADDRESS(x):\
200 ((x >= SPBA0_BASE_ADDR) && (x < (SPBA0_BASE_ADDR + SPBA0_SIZE))) ? SPBA0_IO_ADDRESS(x):\
201 ((x >= AIPS2_BASE_ADDR) && (x < (AIPS2_BASE_ADDR + AIPS2_SIZE))) ? AIPS2_IO_ADDRESS(x):\
202 ((x >= ROMP_BASE_ADDR) && (x < (ROMP_BASE_ADDR + ROMP_SIZE))) ? ROMP_IO_ADDRESS(x):\
203 ((x >= AVIC_BASE_ADDR) && (x < (AVIC_BASE_ADDR + AVIC_SIZE))) ? AVIC_IO_ADDRESS(x):\
204 ((x >= CS4_BASE_ADDR) && (x < (CS4_BASE_ADDR + CS4_SIZE))) ? CS4_IO_ADDRESS(x):\
205 ((x >= X_MEMC_BASE_ADDR) && (x < (X_MEMC_BASE_ADDR + X_MEMC_SIZE))) ? X_MEMC_IO_ADDRESS(x):\
206 0xDEADBEEF)
207
208/*
209 * define the address mapping macros: in physical address order
210 */
211
212#define IRAM_IO_ADDRESS(x) \
213 (((x) - IRAM_BASE_ADDR) + IRAM_BASE_ADDR_VIRT)
214
215#define L2CC_IO_ADDRESS(x) \
216 (((x) - L2CC_BASE_ADDR) + L2CC_BASE_ADDR_VIRT)
217
218#define AIPS1_IO_ADDRESS(x) \
219 (((x) - AIPS1_BASE_ADDR) + AIPS1_BASE_ADDR_VIRT)
220
221#define SPBA0_IO_ADDRESS(x) \
222 (((x) - SPBA0_BASE_ADDR) + SPBA0_BASE_ADDR_VIRT)
223
224#define AIPS2_IO_ADDRESS(x) \
225 (((x) - AIPS2_BASE_ADDR) + AIPS2_BASE_ADDR_VIRT)
226
227#define ROMP_IO_ADDRESS(x) \
228 (((x) - ROMP_BASE_ADDR) + ROMP_BASE_ADDR_VIRT)
229
230#define AVIC_IO_ADDRESS(x) \
231 (((x) - AVIC_BASE_ADDR) + AVIC_BASE_ADDR_VIRT)
232
233#define CS4_IO_ADDRESS(x) \
234 (((x) - CS4_BASE_ADDR) + CS4_BASE_ADDR_VIRT)
235
236#define X_MEMC_IO_ADDRESS(x) \
237 (((x) - X_MEMC_BASE_ADDR) + X_MEMC_BASE_ADDR_VIRT)
238
239#define PCMCIA_IO_ADDRESS(x) \
240 (((x) - X_MEMC_BASE_ADDR) + X_MEMC_BASE_ADDR_VIRT)
241
242/*
243 * Interrupt numbers
244 */
245#define MXC_INT_PEN_ADS7843 0
246#define MXC_INT_RESV1 1
247#define MXC_INT_CS8900A 2
248#define MXC_INT_I2C3 3
249#define MXC_INT_I2C2 4
250#define MXC_INT_MPEG4_ENCODER 5 25#define MXC_INT_MPEG4_ENCODER 5
251#define MXC_INT_RTIC 6
252#define MXC_INT_FIRI 7 26#define MXC_INT_FIRI 7
253#define MXC_INT_MMC_SDHC2 8 27#define MX31_INT_MMC_SDHC2 8
254#define MXC_INT_MMC_SDHC1 9 28#define MXC_INT_MMC_SDHC1 9
255#define MXC_INT_I2C 10 29#define MX31_INT_SSI2 11
256#define MXC_INT_SSI2 11 30#define MX31_INT_SSI1 12
257#define MXC_INT_SSI1 12
258#define MXC_INT_CSPI2 13
259#define MXC_INT_CSPI1 14
260#define MXC_INT_ATA 15
261#define MXC_INT_MBX 16 31#define MXC_INT_MBX 16
262#define MXC_INT_CSPI3 17 32#define MXC_INT_CSPI3 17
263#define MXC_INT_UART3 18
264#define MXC_INT_IIM 19
265#define MXC_INT_SIM2 20 33#define MXC_INT_SIM2 20
266#define MXC_INT_SIM1 21 34#define MXC_INT_SIM1 21
267#define MXC_INT_RNGA 22 35#define MXC_INT_CCM_DVFS 31
268#define MXC_INT_EVTMON 23
269#define MXC_INT_KPP 24
270#define MXC_INT_RTC 25
271#define MXC_INT_PWM 26
272#define MXC_INT_EPIT2 27
273#define MXC_INT_EPIT1 28
274#define MXC_INT_GPT 29
275#define MXC_INT_RESV30 30
276#define MXC_INT_RESV31 31
277#define MXC_INT_UART2 32
278#define MXC_INT_NANDFC 33
279#define MXC_INT_SDMA 34
280#define MXC_INT_USB1 35 36#define MXC_INT_USB1 35
281#define MXC_INT_USB2 36 37#define MXC_INT_USB2 36
282#define MXC_INT_USB3 37 38#define MXC_INT_USB3 37
283#define MXC_INT_USB4 38 39#define MXC_INT_USB4 38
284#define MXC_INT_MSHC1 39
285#define MXC_INT_MSHC2 40 40#define MXC_INT_MSHC2 40
286#define MXC_INT_IPU_ERR 41
287#define MXC_INT_IPU_SYN 42
288#define MXC_INT_RESV43 43
289#define MXC_INT_RESV44 44
290#define MXC_INT_UART1 45
291#define MXC_INT_UART4 46 41#define MXC_INT_UART4 46
292#define MXC_INT_UART5 47 42#define MXC_INT_UART5 47
293#define MXC_INT_ECT 48
294#define MXC_INT_SCC_SCM 49
295#define MXC_INT_SCC_SMN 50
296#define MXC_INT_GPIO2 51
297#define MXC_INT_GPIO1 52
298#define MXC_INT_CCM 53 43#define MXC_INT_CCM 53
299#define MXC_INT_PCMCIA 54 44#define MXC_INT_PCMCIA 54
300#define MXC_INT_WDOG 55
301#define MXC_INT_GPIO3 56
302#define MXC_INT_RESV57 57
303#define MXC_INT_EXT_POWER 58
304#define MXC_INT_EXT_TEMPER 59
305#define MXC_INT_EXT_SENSOR60 60
306#define MXC_INT_EXT_SENSOR61 61
307#define MXC_INT_EXT_WDOG 62
308#define MXC_INT_EXT_TV 63
309
310#define PROD_SIGNATURE 0x1 /* For MX31 */
311
312/* silicon revisions specific to i.MX31 */
313#define CHIP_REV_1_0 0x10
314#define CHIP_REV_1_1 0x11
315#define CHIP_REV_1_2 0x12
316#define CHIP_REV_1_3 0x13
317#define CHIP_REV_2_0 0x20
318#define CHIP_REV_2_1 0x21
319#define CHIP_REV_2_2 0x22
320#define CHIP_REV_2_3 0x23
321#define CHIP_REV_3_0 0x30
322#define CHIP_REV_3_1 0x31
323#define CHIP_REV_3_2 0x32
324
325#define SYSTEM_REV_MIN CHIP_REV_1_0
326#define SYSTEM_REV_NUM 3
327
328/* gpio and gpio based interrupt handling */
329#define GPIO_DR 0x00
330#define GPIO_GDIR 0x04
331#define GPIO_PSR 0x08
332#define GPIO_ICR1 0x0C
333#define GPIO_ICR2 0x10
334#define GPIO_IMR 0x14
335#define GPIO_ISR 0x18
336#define GPIO_INT_LOW_LEV 0x0
337#define GPIO_INT_HIGH_LEV 0x1
338#define GPIO_INT_RISE_EDGE 0x2
339#define GPIO_INT_FALL_EDGE 0x3
340#define GPIO_INT_NONE 0x4
341
342/* Mandatory defines used globally */
343
344/* this CPU supports up to 96 GPIOs */
345#define ARCH_NR_GPIOS 96
346
347#if !defined(__ASSEMBLY__) && !defined(__MXC_BOOT_UNCOMPRESS)
348
349/* this is a i.MX31 CPU */
350#define cpu_is_mx31() (1)
351
352extern unsigned int system_rev;
353
354static inline int mx31_revision(void)
355{
356 return system_rev;
357}
358#endif
359 45
360#endif /* __ASM_ARCH_MXC_MX31_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/mx35.h b/arch/arm/plat-mxc/include/mach/mx35.h
new file mode 100644
index 000000000000..6465fefb42e3
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/mx35.h
@@ -0,0 +1,29 @@
1/*
2 * IRAM
3 */
4#define MX35_IRAM_BASE_ADDR 0x10000000 /* internal ram */
5#define MX35_IRAM_SIZE SZ_128K
6
7#define MXC_FEC_BASE_ADDR 0x50038000
8#define MX35_NFC_BASE_ADDR 0xBB000000
9
10/*
11 * Interrupt numbers
12 */
13#define MXC_INT_OWIRE 2
14#define MX35_INT_MMC_SDHC1 7
15#define MXC_INT_MMC_SDHC2 8
16#define MXC_INT_MMC_SDHC3 9
17#define MX35_INT_SSI1 11
18#define MX35_INT_SSI2 12
19#define MXC_INT_GPU2D 16
20#define MXC_INT_ASRC 17
21#define MXC_INT_USBHS 35
22#define MXC_INT_USBOTG 37
23#define MXC_INT_ESAI 40
24#define MXC_INT_CAN1 43
25#define MXC_INT_CAN2 44
26#define MXC_INT_MLB 46
27#define MXC_INT_SPDIF 47
28#define MXC_INT_FEC 57
29
diff --git a/arch/arm/plat-mxc/include/mach/mx3x.h b/arch/arm/plat-mxc/include/mach/mx3x.h
new file mode 100644
index 000000000000..3878c6085d5c
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/mx3x.h
@@ -0,0 +1,290 @@
1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_MXC_MX31_H__
12#define __ASM_ARCH_MXC_MX31_H__
13
14#ifndef __ASM_ARCH_MXC_HARDWARE_H__
15#error "Do not include directly."
16#endif
17
18/*
19 * MX31 memory map:
20 *
21 * Virt Phys Size What
22 * ---------------------------------------------------------------------------
23 * FC000000 43F00000 1M AIPS 1
24 * FC100000 50000000 1M SPBA
25 * FC200000 53F00000 1M AIPS 2
26 * FC500000 60000000 128M ROMPATCH
27 * FC400000 68000000 128M AVIC
28 * 70000000 256M IPU (MAX M2)
29 * 80000000 256M CSD0 SDRAM/DDR
30 * 90000000 256M CSD1 SDRAM/DDR
31 * A0000000 128M CS0 Flash
32 * A8000000 128M CS1 Flash
33 * B0000000 32M CS2
34 * B2000000 32M CS3
35 * F4000000 B4000000 32M CS4
36 * B6000000 32M CS5
37 * FC320000 B8000000 64K NAND, SDRAM, WEIM, M3IF, EMI controllers
38 * C0000000 64M PCMCIA/CF
39 */
40
41#define CS0_BASE_ADDR 0xA0000000
42#define CS1_BASE_ADDR 0xA8000000
43#define CS2_BASE_ADDR 0xB0000000
44#define CS3_BASE_ADDR 0xB2000000
45
46#define CS4_BASE_ADDR 0xB4000000
47#define CS4_BASE_ADDR_VIRT 0xF4000000
48#define CS4_SIZE SZ_32M
49
50#define CS5_BASE_ADDR 0xB6000000
51#define PCMCIA_MEM_BASE_ADDR 0xBC000000
52
53/*
54 * L2CC
55 */
56#define L2CC_BASE_ADDR 0x30000000
57#define L2CC_SIZE SZ_1M
58
59/*
60 * AIPS 1
61 */
62#define AIPS1_BASE_ADDR 0x43F00000
63#define AIPS1_BASE_ADDR_VIRT 0xFC000000
64#define AIPS1_SIZE SZ_1M
65
66#define MAX_BASE_ADDR (AIPS1_BASE_ADDR + 0x00004000)
67#define EVTMON_BASE_ADDR (AIPS1_BASE_ADDR + 0x00008000)
68#define CLKCTL_BASE_ADDR (AIPS1_BASE_ADDR + 0x0000C000)
69#define ETB_SLOT4_BASE_ADDR (AIPS1_BASE_ADDR + 0x00010000)
70#define ETB_SLOT5_BASE_ADDR (AIPS1_BASE_ADDR + 0x00014000)
71#define ECT_CTIO_BASE_ADDR (AIPS1_BASE_ADDR + 0x00018000)
72#define I2C_BASE_ADDR (AIPS1_BASE_ADDR + 0x00080000)
73#define I2C3_BASE_ADDR (AIPS1_BASE_ADDR + 0x00084000)
74#define UART1_BASE_ADDR (AIPS1_BASE_ADDR + 0x00090000)
75#define UART2_BASE_ADDR (AIPS1_BASE_ADDR + 0x00094000)
76#define I2C2_BASE_ADDR (AIPS1_BASE_ADDR + 0x00098000)
77#define OWIRE_BASE_ADDR (AIPS1_BASE_ADDR + 0x0009C000)
78#define SSI1_BASE_ADDR (AIPS1_BASE_ADDR + 0x000A0000)
79#define CSPI1_BASE_ADDR (AIPS1_BASE_ADDR + 0x000A4000)
80#define KPP_BASE_ADDR (AIPS1_BASE_ADDR + 0x000A8000)
81#define IOMUXC_BASE_ADDR (AIPS1_BASE_ADDR + 0x000AC000)
82#define ECT_IP1_BASE_ADDR (AIPS1_BASE_ADDR + 0x000B8000)
83#define ECT_IP2_BASE_ADDR (AIPS1_BASE_ADDR + 0x000BC000)
84
85/*
86 * SPBA global module enabled #0
87 */
88#define SPBA0_BASE_ADDR 0x50000000
89#define SPBA0_BASE_ADDR_VIRT 0xFC100000
90#define SPBA0_SIZE SZ_1M
91
92#define UART3_BASE_ADDR (SPBA0_BASE_ADDR + 0x0000C000)
93#define CSPI2_BASE_ADDR (SPBA0_BASE_ADDR + 0x00010000)
94#define SSI2_BASE_ADDR (SPBA0_BASE_ADDR + 0x00014000)
95#define ATA_DMA_BASE_ADDR (SPBA0_BASE_ADDR + 0x00020000)
96#define MSHC1_BASE_ADDR (SPBA0_BASE_ADDR + 0x00024000)
97#define SPBA_CTRL_BASE_ADDR (SPBA0_BASE_ADDR + 0x0003C000)
98
99/*
100 * AIPS 2
101 */
102#define AIPS2_BASE_ADDR 0x53F00000
103#define AIPS2_BASE_ADDR_VIRT 0xFC200000
104#define AIPS2_SIZE SZ_1M
105#define CCM_BASE_ADDR (AIPS2_BASE_ADDR + 0x00080000)
106#define GPT1_BASE_ADDR (AIPS2_BASE_ADDR + 0x00090000)
107#define EPIT1_BASE_ADDR (AIPS2_BASE_ADDR + 0x00094000)
108#define EPIT2_BASE_ADDR (AIPS2_BASE_ADDR + 0x00098000)
109#define GPIO3_BASE_ADDR (AIPS2_BASE_ADDR + 0x000A4000)
110#define SCC_BASE_ADDR (AIPS2_BASE_ADDR + 0x000AC000)
111#define RNGA_BASE_ADDR (AIPS2_BASE_ADDR + 0x000B0000)
112#define IPU_CTRL_BASE_ADDR (AIPS2_BASE_ADDR + 0x000C0000)
113#define AUDMUX_BASE_ADDR (AIPS2_BASE_ADDR + 0x000C4000)
114#define GPIO1_BASE_ADDR (AIPS2_BASE_ADDR + 0x000CC000)
115#define GPIO2_BASE_ADDR (AIPS2_BASE_ADDR + 0x000D0000)
116#define SDMA_BASE_ADDR (AIPS2_BASE_ADDR + 0x000D4000)
117#define RTC_BASE_ADDR (AIPS2_BASE_ADDR + 0x000D8000)
118#define WDOG_BASE_ADDR (AIPS2_BASE_ADDR + 0x000DC000)
119#define PWM_BASE_ADDR (AIPS2_BASE_ADDR + 0x000E0000)
120#define RTIC_BASE_ADDR (AIPS2_BASE_ADDR + 0x000EC000)
121
122/*
123 * ROMP and AVIC
124 */
125#define ROMP_BASE_ADDR 0x60000000
126#define ROMP_BASE_ADDR_VIRT 0xFC500000
127#define ROMP_SIZE SZ_1M
128
129#define AVIC_BASE_ADDR 0x68000000
130#define AVIC_BASE_ADDR_VIRT 0xFC400000
131#define AVIC_SIZE SZ_1M
132
133/*
134 * NAND, SDRAM, WEIM, M3IF, EMI controllers
135 */
136#define X_MEMC_BASE_ADDR 0xB8000000
137#define X_MEMC_BASE_ADDR_VIRT 0xFC320000
138#define X_MEMC_SIZE SZ_64K
139
140#define ESDCTL_BASE_ADDR (X_MEMC_BASE_ADDR + 0x1000)
141#define WEIM_BASE_ADDR (X_MEMC_BASE_ADDR + 0x2000)
142#define M3IF_BASE_ADDR (X_MEMC_BASE_ADDR + 0x3000)
143#define EMI_CTL_BASE_ADDR (X_MEMC_BASE_ADDR + 0x4000)
144#define PCMCIA_CTL_BASE_ADDR EMI_CTL_BASE_ADDR
145
146/*
147 * Memory regions and CS
148 */
149#define IPU_MEM_BASE_ADDR 0x70000000
150#define CSD0_BASE_ADDR 0x80000000
151#define CSD1_BASE_ADDR 0x90000000
152
153/*!
154 * This macro defines the physical to virtual address mapping for all the
155 * peripheral modules. It is used by passing in the physical address as x
156 * and returning the virtual address. If the physical address is not mapped,
157 * it returns 0xDEADBEEF
158 */
159#define IO_ADDRESS(x) \
160 (void __force __iomem *) \
161 (((x >= AIPS1_BASE_ADDR) && (x < (AIPS1_BASE_ADDR + AIPS1_SIZE))) ? AIPS1_IO_ADDRESS(x):\
162 ((x >= SPBA0_BASE_ADDR) && (x < (SPBA0_BASE_ADDR + SPBA0_SIZE))) ? SPBA0_IO_ADDRESS(x):\
163 ((x >= AIPS2_BASE_ADDR) && (x < (AIPS2_BASE_ADDR + AIPS2_SIZE))) ? AIPS2_IO_ADDRESS(x):\
164 ((x >= ROMP_BASE_ADDR) && (x < (ROMP_BASE_ADDR + ROMP_SIZE))) ? ROMP_IO_ADDRESS(x):\
165 ((x >= AVIC_BASE_ADDR) && (x < (AVIC_BASE_ADDR + AVIC_SIZE))) ? AVIC_IO_ADDRESS(x):\
166 ((x >= CS4_BASE_ADDR) && (x < (CS4_BASE_ADDR + CS4_SIZE))) ? CS4_IO_ADDRESS(x):\
167 ((x >= X_MEMC_BASE_ADDR) && (x < (X_MEMC_BASE_ADDR + X_MEMC_SIZE))) ? X_MEMC_IO_ADDRESS(x):\
168 0xDEADBEEF)
169
170/*
171 * define the address mapping macros: in physical address order
172 */
173#define L2CC_IO_ADDRESS(x) \
174 (((x) - L2CC_BASE_ADDR) + L2CC_BASE_ADDR_VIRT)
175
176#define AIPS1_IO_ADDRESS(x) \
177 (((x) - AIPS1_BASE_ADDR) + AIPS1_BASE_ADDR_VIRT)
178
179#define SPBA0_IO_ADDRESS(x) \
180 (((x) - SPBA0_BASE_ADDR) + SPBA0_BASE_ADDR_VIRT)
181
182#define AIPS2_IO_ADDRESS(x) \
183 (((x) - AIPS2_BASE_ADDR) + AIPS2_BASE_ADDR_VIRT)
184
185#define ROMP_IO_ADDRESS(x) \
186 (((x) - ROMP_BASE_ADDR) + ROMP_BASE_ADDR_VIRT)
187
188#define AVIC_IO_ADDRESS(x) \
189 (((x) - AVIC_BASE_ADDR) + AVIC_BASE_ADDR_VIRT)
190
191#define CS4_IO_ADDRESS(x) \
192 (((x) - CS4_BASE_ADDR) + CS4_BASE_ADDR_VIRT)
193
194#define X_MEMC_IO_ADDRESS(x) \
195 (((x) - X_MEMC_BASE_ADDR) + X_MEMC_BASE_ADDR_VIRT)
196
197#define PCMCIA_IO_ADDRESS(x) \
198 (((x) - X_MEMC_BASE_ADDR) + X_MEMC_BASE_ADDR_VIRT)
199
200/*
201 * Interrupt numbers
202 */
203#define MXC_INT_I2C3 3
204#define MXC_INT_I2C2 4
205#define MXC_INT_RTIC 6
206#define MXC_INT_I2C 10
207#define MXC_INT_CSPI2 13
208#define MXC_INT_CSPI1 14
209#define MXC_INT_ATA 15
210#define MXC_INT_UART3 18
211#define MXC_INT_IIM 19
212#define MXC_INT_RNGA 22
213#define MXC_INT_EVTMON 23
214#define MXC_INT_KPP 24
215#define MXC_INT_RTC 25
216#define MXC_INT_PWM 26
217#define MXC_INT_EPIT2 27
218#define MXC_INT_EPIT1 28
219#define MXC_INT_GPT 29
220#define MXC_INT_POWER_FAIL 30
221#define MXC_INT_UART2 32
222#define MXC_INT_NANDFC 33
223#define MXC_INT_SDMA 34
224#define MXC_INT_MSHC1 39
225#define MXC_INT_IPU_ERR 41
226#define MXC_INT_IPU_SYN 42
227#define MXC_INT_UART1 45
228#define MXC_INT_ECT 48
229#define MXC_INT_SCC_SCM 49
230#define MXC_INT_SCC_SMN 50
231#define MXC_INT_GPIO2 51
232#define MXC_INT_GPIO1 52
233#define MXC_INT_WDOG 55
234#define MXC_INT_GPIO3 56
235#define MXC_INT_EXT_POWER 58
236#define MXC_INT_EXT_TEMPER 59
237#define MXC_INT_EXT_SENSOR60 60
238#define MXC_INT_EXT_SENSOR61 61
239#define MXC_INT_EXT_WDOG 62
240#define MXC_INT_EXT_TV 63
241
242#define PROD_SIGNATURE 0x1 /* For MX31 */
243
244/* silicon revisions specific to i.MX31 */
245#define CHIP_REV_1_0 0x10
246#define CHIP_REV_1_1 0x11
247#define CHIP_REV_1_2 0x12
248#define CHIP_REV_1_3 0x13
249#define CHIP_REV_2_0 0x20
250#define CHIP_REV_2_1 0x21
251#define CHIP_REV_2_2 0x22
252#define CHIP_REV_2_3 0x23
253#define CHIP_REV_3_0 0x30
254#define CHIP_REV_3_1 0x31
255#define CHIP_REV_3_2 0x32
256
257#define SYSTEM_REV_MIN CHIP_REV_1_0
258#define SYSTEM_REV_NUM 3
259
260/* gpio and gpio based interrupt handling */
261#define GPIO_DR 0x00
262#define GPIO_GDIR 0x04
263#define GPIO_PSR 0x08
264#define GPIO_ICR1 0x0C
265#define GPIO_ICR2 0x10
266#define GPIO_IMR 0x14
267#define GPIO_ISR 0x18
268#define GPIO_INT_LOW_LEV 0x0
269#define GPIO_INT_HIGH_LEV 0x1
270#define GPIO_INT_RISE_EDGE 0x2
271#define GPIO_INT_FALL_EDGE 0x3
272#define GPIO_INT_NONE 0x4
273
274/* Mandatory defines used globally */
275
276/* this CPU supports up to 96 GPIOs */
277#define ARCH_NR_GPIOS 96
278
279#if !defined(__ASSEMBLY__) && !defined(__MXC_BOOT_UNCOMPRESS)
280
281extern unsigned int system_rev;
282
283static inline int mx31_revision(void)
284{
285 return system_rev;
286}
287#endif
288
289#endif /* __ASM_ARCH_MXC_MX31_H__ */
290
diff --git a/arch/arm/plat-mxc/include/mach/mxc.h b/arch/arm/plat-mxc/include/mach/mxc.h
index f6caab062131..5fa2a07f4eaf 100644
--- a/arch/arm/plat-mxc/include/mach/mxc.h
+++ b/arch/arm/plat-mxc/include/mach/mxc.h
@@ -24,13 +24,74 @@
24#error "Do not include directly." 24#error "Do not include directly."
25#endif 25#endif
26 26
27/* clean up all things that are not used */ 27#define MXC_CPU_MX1 1
28#ifndef CONFIG_ARCH_MX3 28#define MXC_CPU_MX21 21
29# define cpu_is_mx31() (0) 29#define MXC_CPU_MX27 27
30#define MXC_CPU_MX31 31
31#define MXC_CPU_MX35 35
32
33#ifndef __ASSEMBLY__
34extern unsigned int __mxc_cpu_type;
35#endif
36
37#ifdef CONFIG_ARCH_MX1
38# ifdef mxc_cpu_type
39# undef mxc_cpu_type
40# define mxc_cpu_type __mxc_cpu_type
41# else
42# define mxc_cpu_type MXC_CPU_MX1
43# endif
44# define cpu_is_mx1() (mxc_cpu_type == MXC_CPU_MX1)
45#else
46# define cpu_is_mx1() (0)
47#endif
48
49#ifdef CONFIG_MACH_MX21
50# ifdef mxc_cpu_type
51# undef mxc_cpu_type
52# define mxc_cpu_type __mxc_cpu_type
53# else
54# define mxc_cpu_type MXC_CPU_MX21
55# endif
56# define cpu_is_mx21() (mxc_cpu_type == MXC_CPU_MX21)
57#else
58# define cpu_is_mx21() (0)
30#endif 59#endif
31 60
32#ifndef CONFIG_MACH_MX27 61#ifdef CONFIG_MACH_MX27
33# define cpu_is_mx27() (0) 62# ifdef mxc_cpu_type
63# undef mxc_cpu_type
64# define mxc_cpu_type __mxc_cpu_type
65# else
66# define mxc_cpu_type MXC_CPU_MX27
67# endif
68# define cpu_is_mx27() (mxc_cpu_type == MXC_CPU_MX27)
69#else
70# define cpu_is_mx27() (0)
71#endif
72
73#ifdef CONFIG_ARCH_MX31
74# ifdef mxc_cpu_type
75# undef mxc_cpu_type
76# define mxc_cpu_type __mxc_cpu_type
77# else
78# define mxc_cpu_type MXC_CPU_MX31
79# endif
80# define cpu_is_mx31() (mxc_cpu_type == MXC_CPU_MX31)
81#else
82# define cpu_is_mx31() (0)
83#endif
84
85#ifdef CONFIG_ARCH_MX35
86# ifdef mxc_cpu_type
87# undef mxc_cpu_type
88# define mxc_cpu_type __mxc_cpu_type
89# else
90# define mxc_cpu_type MXC_CPU_MX35
91# endif
92# define cpu_is_mx35() (mxc_cpu_type == MXC_CPU_MX35)
93#else
94# define cpu_is_mx35() (0)
34#endif 95#endif
35 96
36#if defined(CONFIG_ARCH_MX3) || defined(CONFIG_ARCH_MX2) 97#if defined(CONFIG_ARCH_MX3) || defined(CONFIG_ARCH_MX2)
@@ -39,4 +100,7 @@
39#define CSCR_A(n) (IO_ADDRESS(WEIM_BASE_ADDR) + n * 0x10 + 0x8) 100#define CSCR_A(n) (IO_ADDRESS(WEIM_BASE_ADDR) + n * 0x10 + 0x8)
40#endif 101#endif
41 102
103#define cpu_is_mx3() (cpu_is_mx31() || cpu_is_mx35())
104#define cpu_is_mx2() (cpu_is_mx21() || cpu_is_mx27())
105
42#endif /* __ASM_ARCH_MXC_H__ */ 106#endif /* __ASM_ARCH_MXC_H__ */
diff --git a/arch/arm/plat-mxc/iomux-mx1-mx2.c b/arch/arm/plat-mxc/iomux-mx1-mx2.c
index df6f18395686..a37163ce280b 100644
--- a/arch/arm/plat-mxc/iomux-mx1-mx2.c
+++ b/arch/arm/plat-mxc/iomux-mx1-mx2.c
@@ -32,7 +32,7 @@
32 32
33#include <mach/hardware.h> 33#include <mach/hardware.h>
34#include <asm/mach/map.h> 34#include <asm/mach/map.h>
35#include <mach/iomux-mx1-mx2.h> 35#include <mach/iomux.h>
36 36
37void mxc_gpio_mode(int gpio_mode) 37void mxc_gpio_mode(int gpio_mode)
38{ 38{
diff --git a/arch/arm/plat-mxc/pwm.c b/arch/arm/plat-mxc/pwm.c
new file mode 100644
index 000000000000..9bffbc507cc2
--- /dev/null
+++ b/arch/arm/plat-mxc/pwm.c
@@ -0,0 +1,300 @@
1/*
2 * simple driver for PWM (Pulse Width Modulator) controller
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * Derived from pxa PWM driver by eric miao <eric.miao@marvell.com>
9 */
10
11#include <linux/module.h>
12#include <linux/kernel.h>
13#include <linux/platform_device.h>
14#include <linux/err.h>
15#include <linux/clk.h>
16#include <linux/io.h>
17#include <linux/pwm.h>
18
19#if defined CONFIG_ARCH_MX1 || defined CONFIG_ARCH_MX21
20#define PWM_VER_1
21
22#define PWMCR 0x00 /* PWM Control Register */
23#define PWMSR 0x04 /* PWM Sample Register */
24#define PWMPR 0x08 /* PWM Period Register */
25#define PWMCNR 0x0C /* PWM Counter Register */
26
27#define PWMCR_HCTR (1 << 18) /* Halfword FIFO Data Swapping */
28#define PWMCR_BCTR (1 << 17) /* Byte FIFO Data Swapping */
29#define PWMCR_SWR (1 << 16) /* Software Reset */
30#define PWMCR_CLKSRC_PERCLK (0 << 15) /* PERCLK Clock Source */
31#define PWMCR_CLKSRC_CLK32 (1 << 15) /* 32KHz Clock Source */
32#define PWMCR_PRESCALER(x) (((x - 1) & 0x7F) << 8) /* PRESCALER */
33#define PWMCR_IRQ (1 << 7) /* Interrupt Request */
34#define PWMCR_IRQEN (1 << 6) /* Interrupt Request Enable */
35#define PWMCR_FIFOAV (1 << 5) /* FIFO Available */
36#define PWMCR_EN (1 << 4) /* Enables/Disables the PWM */
37#define PWMCR_REPEAT(x) (((x) & 0x03) << 2) /* Sample Repeats */
38#define PWMCR_DIV(x) (((x) & 0x03) << 0) /* Clock divider 2/4/8/16 */
39
40#define MAX_DIV (128 * 16)
41#endif
42
43#if defined CONFIG_MACH_MX27 || defined CONFIG_ARCH_MX31
44#define PWM_VER_2
45
46#define PWMCR 0x00 /* PWM Control Register */
47#define PWMSR 0x04 /* PWM Status Register */
48#define PWMIR 0x08 /* PWM Interrupt Register */
49#define PWMSAR 0x0C /* PWM Sample Register */
50#define PWMPR 0x10 /* PWM Period Register */
51#define PWMCNR 0x14 /* PWM Counter Register */
52
53#define PWMCR_EN (1 << 0) /* Enables/Disables the PWM */
54#define PWMCR_REPEAT(x) (((x) & 0x03) << 1) /* Sample Repeats */
55#define PWMCR_SWR (1 << 3) /* Software Reset */
56#define PWMCR_PRESCALER(x) (((x - 1) & 0xFFF) << 4)/* PRESCALER */
57#define PWMCR_CLKSRC(x) (((x) & 0x3) << 16)
58#define PWMCR_CLKSRC_OFF (0 << 16)
59#define PWMCR_CLKSRC_IPG (1 << 16)
60#define PWMCR_CLKSRC_IPG_HIGH (2 << 16)
61#define PWMCR_CLKSRC_CLK32 (3 << 16)
62#define PWMCR_POUTC
63#define PWMCR_HCTR (1 << 20) /* Halfword FIFO Data Swapping */
64#define PWMCR_BCTR (1 << 21) /* Byte FIFO Data Swapping */
65#define PWMCR_DBGEN (1 << 22) /* Debug Mode */
66#define PWMCR_WAITEN (1 << 23) /* Wait Mode */
67#define PWMCR_DOZEN (1 << 24) /* Doze Mode */
68#define PWMCR_STOPEN (1 << 25) /* Stop Mode */
69#define PWMCR_FWM(x) (((x) & 0x3) << 26) /* FIFO Water Mark */
70
71#define MAX_DIV 4096
72#endif
73
74#define PWMS_SAMPLE(x) ((x) & 0xFFFF) /* Contains a two-sample word */
75#define PWMP_PERIOD(x) ((x) & 0xFFFF) /* Represents the PWM's period */
76#define PWMC_COUNTER(x) ((x) & 0xFFFF) /* Represents the current count value */
77
78struct pwm_device {
79 struct list_head node;
80 struct platform_device *pdev;
81
82 const char *label;
83 struct clk *clk;
84
85 int clk_enabled;
86 void __iomem *mmio_base;
87
88 unsigned int use_count;
89 unsigned int pwm_id;
90};
91
92int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
93{
94 unsigned long long c;
95 unsigned long period_cycles, duty_cycles, prescale;
96
97 if (pwm == NULL || period_ns == 0 || duty_ns > period_ns)
98 return -EINVAL;
99
100 c = clk_get_rate(pwm->clk);
101 c = c * period_ns;
102 do_div(c, 1000000000);
103 period_cycles = c;
104
105 prescale = period_cycles / 0x10000 + 1;
106
107 period_cycles /= prescale;
108 c = (unsigned long long)period_cycles * duty_ns;
109 do_div(c, period_ns);
110 duty_cycles = c;
111
112#ifdef PWM_VER_2
113 writel(duty_cycles, pwm->mmio_base + PWMSAR);
114 writel(period_cycles, pwm->mmio_base + PWMPR);
115 writel(PWMCR_PRESCALER(prescale - 1) | PWMCR_CLKSRC_IPG_HIGH | PWMCR_EN,
116 pwm->mmio_base + PWMCR);
117#elif defined PWM_VER_1
118#error PWM not yet working on MX1 / MX21
119#endif
120
121 return 0;
122}
123EXPORT_SYMBOL(pwm_config);
124
125int pwm_enable(struct pwm_device *pwm)
126{
127 int rc = 0;
128
129 if (!pwm->clk_enabled) {
130 rc = clk_enable(pwm->clk);
131 if (!rc)
132 pwm->clk_enabled = 1;
133 }
134 return rc;
135}
136EXPORT_SYMBOL(pwm_enable);
137
138void pwm_disable(struct pwm_device *pwm)
139{
140 if (pwm->clk_enabled) {
141 clk_disable(pwm->clk);
142 pwm->clk_enabled = 0;
143 }
144}
145EXPORT_SYMBOL(pwm_disable);
146
147static DEFINE_MUTEX(pwm_lock);
148static LIST_HEAD(pwm_list);
149
150struct pwm_device *pwm_request(int pwm_id, const char *label)
151{
152 struct pwm_device *pwm;
153 int found = 0;
154
155 mutex_lock(&pwm_lock);
156
157 list_for_each_entry(pwm, &pwm_list, node) {
158 if (pwm->pwm_id == pwm_id) {
159 found = 1;
160 break;
161 }
162 }
163
164 if (found) {
165 if (pwm->use_count == 0) {
166 pwm->use_count++;
167 pwm->label = label;
168 } else
169 pwm = ERR_PTR(-EBUSY);
170 } else
171 pwm = ERR_PTR(-ENOENT);
172
173 mutex_unlock(&pwm_lock);
174 return pwm;
175}
176EXPORT_SYMBOL(pwm_request);
177
178void pwm_free(struct pwm_device *pwm)
179{
180 mutex_lock(&pwm_lock);
181
182 if (pwm->use_count) {
183 pwm->use_count--;
184 pwm->label = NULL;
185 } else
186 pr_warning("PWM device already freed\n");
187
188 mutex_unlock(&pwm_lock);
189}
190EXPORT_SYMBOL(pwm_free);
191
192static int __devinit mxc_pwm_probe(struct platform_device *pdev)
193{
194 struct pwm_device *pwm;
195 struct resource *r;
196 int ret = 0;
197
198 pwm = kzalloc(sizeof(struct pwm_device), GFP_KERNEL);
199 if (pwm == NULL) {
200 dev_err(&pdev->dev, "failed to allocate memory\n");
201 return -ENOMEM;
202 }
203
204 pwm->clk = clk_get(&pdev->dev, "pwm");
205
206 if (IS_ERR(pwm->clk)) {
207 ret = PTR_ERR(pwm->clk);
208 goto err_free;
209 }
210
211 pwm->clk_enabled = 0;
212
213 pwm->use_count = 0;
214 pwm->pwm_id = pdev->id;
215 pwm->pdev = pdev;
216
217 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
218 if (r == NULL) {
219 dev_err(&pdev->dev, "no memory resource defined\n");
220 ret = -ENODEV;
221 goto err_free_clk;
222 }
223
224 r = request_mem_region(r->start, r->end - r->start + 1, pdev->name);
225 if (r == NULL) {
226 dev_err(&pdev->dev, "failed to request memory resource\n");
227 ret = -EBUSY;
228 goto err_free_clk;
229 }
230
231 pwm->mmio_base = ioremap(r->start, r->end - r->start + 1);
232 if (pwm->mmio_base == NULL) {
233 dev_err(&pdev->dev, "failed to ioremap() registers\n");
234 ret = -ENODEV;
235 goto err_free_mem;
236 }
237
238 mutex_lock(&pwm_lock);
239 list_add_tail(&pwm->node, &pwm_list);
240 mutex_unlock(&pwm_lock);
241
242 platform_set_drvdata(pdev, pwm);
243 return 0;
244
245err_free_mem:
246 release_mem_region(r->start, r->end - r->start + 1);
247err_free_clk:
248 clk_put(pwm->clk);
249err_free:
250 kfree(pwm);
251 return ret;
252}
253
254static int __devexit mxc_pwm_remove(struct platform_device *pdev)
255{
256 struct pwm_device *pwm;
257 struct resource *r;
258
259 pwm = platform_get_drvdata(pdev);
260 if (pwm == NULL)
261 return -ENODEV;
262
263 mutex_lock(&pwm_lock);
264 list_del(&pwm->node);
265 mutex_unlock(&pwm_lock);
266
267 iounmap(pwm->mmio_base);
268
269 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
270 release_mem_region(r->start, r->end - r->start + 1);
271
272 clk_put(pwm->clk);
273
274 kfree(pwm);
275 return 0;
276}
277
278static struct platform_driver mxc_pwm_driver = {
279 .driver = {
280 .name = "mxc_pwm",
281 },
282 .probe = mxc_pwm_probe,
283 .remove = __devexit_p(mxc_pwm_remove),
284};
285
286static int __init mxc_pwm_init(void)
287{
288 return platform_driver_register(&mxc_pwm_driver);
289}
290arch_initcall(mxc_pwm_init);
291
292static void __exit mxc_pwm_exit(void)
293{
294 platform_driver_unregister(&mxc_pwm_driver);
295}
296module_exit(mxc_pwm_exit);
297
298MODULE_LICENSE("GPL v2");
299MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
300
diff --git a/arch/arm/plat-mxc/time.c b/arch/arm/plat-mxc/time.c
index 758a1293bcfa..ef1b3cd85bd3 100644
--- a/arch/arm/plat-mxc/time.c
+++ b/arch/arm/plat-mxc/time.c
@@ -34,9 +34,6 @@
34static struct clock_event_device clockevent_mxc; 34static struct clock_event_device clockevent_mxc;
35static enum clock_event_mode clockevent_mode = CLOCK_EVT_MODE_UNUSED; 35static enum clock_event_mode clockevent_mode = CLOCK_EVT_MODE_UNUSED;
36 36
37/* clock source for the timer */
38static struct clk *timer_clk;
39
40/* clock source */ 37/* clock source */
41 38
42static cycle_t mxc_get_cycles(void) 39static cycle_t mxc_get_cycles(void)
@@ -53,13 +50,11 @@ static struct clocksource clocksource_mxc = {
53 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 50 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
54}; 51};
55 52
56static int __init mxc_clocksource_init(void) 53static int __init mxc_clocksource_init(struct clk *timer_clk)
57{ 54{
58 unsigned int clock; 55 unsigned int c = clk_get_rate(timer_clk);
59
60 clock = clk_get_rate(timer_clk);
61 56
62 clocksource_mxc.mult = clocksource_hz2mult(clock, 57 clocksource_mxc.mult = clocksource_hz2mult(c,
63 clocksource_mxc.shift); 58 clocksource_mxc.shift);
64 clocksource_register(&clocksource_mxc); 59 clocksource_register(&clocksource_mxc);
65 60
@@ -177,13 +172,11 @@ static struct clock_event_device clockevent_mxc = {
177 .rating = 200, 172 .rating = 200,
178}; 173};
179 174
180static int __init mxc_clockevent_init(void) 175static int __init mxc_clockevent_init(struct clk *timer_clk)
181{ 176{
182 unsigned int clock; 177 unsigned int c = clk_get_rate(timer_clk);
183
184 clock = clk_get_rate(timer_clk);
185 178
186 clockevent_mxc.mult = div_sc(clock, NSEC_PER_SEC, 179 clockevent_mxc.mult = div_sc(c, NSEC_PER_SEC,
187 clockevent_mxc.shift); 180 clockevent_mxc.shift);
188 clockevent_mxc.max_delta_ns = 181 clockevent_mxc.max_delta_ns =
189 clockevent_delta2ns(0xfffffffe, &clockevent_mxc); 182 clockevent_delta2ns(0xfffffffe, &clockevent_mxc);
@@ -197,14 +190,8 @@ static int __init mxc_clockevent_init(void)
197 return 0; 190 return 0;
198} 191}
199 192
200void __init mxc_timer_init(const char *clk_timer) 193void __init mxc_timer_init(struct clk *timer_clk)
201{ 194{
202 timer_clk = clk_get(NULL, clk_timer);
203 if (!timer_clk) {
204 printk(KERN_ERR"Cannot determine timer clock. Giving up.\n");
205 return;
206 }
207
208 clk_enable(timer_clk); 195 clk_enable(timer_clk);
209 196
210 /* 197 /*
@@ -219,10 +206,9 @@ void __init mxc_timer_init(const char *clk_timer)
219 TIMER_BASE + MXC_TCTL); 206 TIMER_BASE + MXC_TCTL);
220 207
221 /* init and register the timer to the framework */ 208 /* init and register the timer to the framework */
222 mxc_clocksource_init(); 209 mxc_clocksource_init(timer_clk);
223 mxc_clockevent_init(); 210 mxc_clockevent_init(timer_clk);
224 211
225 /* Make irqs happen */ 212 /* Make irqs happen */
226 setup_irq(TIMER_INTERRUPT, &mxc_timer_irq); 213 setup_irq(TIMER_INTERRUPT, &mxc_timer_irq);
227} 214}
228
diff --git a/arch/arm/plat-orion/gpio.c b/arch/arm/plat-orion/gpio.c
index 967186425ca1..0d12c2164766 100644
--- a/arch/arm/plat-orion/gpio.c
+++ b/arch/arm/plat-orion/gpio.c
@@ -265,51 +265,36 @@ EXPORT_SYMBOL(orion_gpio_set_blink);
265 * polarity LEVEL mask 265 * polarity LEVEL mask
266 * 266 *
267 ****************************************************************************/ 267 ****************************************************************************/
268static void gpio_irq_edge_ack(u32 irq)
269{
270 int pin = irq_to_gpio(irq);
271
272 writel(~(1 << (pin & 31)), GPIO_EDGE_CAUSE(pin));
273}
274
275static void gpio_irq_edge_mask(u32 irq)
276{
277 int pin = irq_to_gpio(irq);
278 u32 u;
279
280 u = readl(GPIO_EDGE_MASK(pin));
281 u &= ~(1 << (pin & 31));
282 writel(u, GPIO_EDGE_MASK(pin));
283}
284 268
285static void gpio_irq_edge_unmask(u32 irq) 269static void gpio_irq_ack(u32 irq)
286{ 270{
287 int pin = irq_to_gpio(irq); 271 int type = irq_desc[irq].status & IRQ_TYPE_SENSE_MASK;
288 u32 u; 272 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) {
289 273 int pin = irq_to_gpio(irq);
290 u = readl(GPIO_EDGE_MASK(pin)); 274 writel(~(1 << (pin & 31)), GPIO_EDGE_CAUSE(pin));
291 u |= 1 << (pin & 31); 275 }
292 writel(u, GPIO_EDGE_MASK(pin));
293} 276}
294 277
295static void gpio_irq_level_mask(u32 irq) 278static void gpio_irq_mask(u32 irq)
296{ 279{
297 int pin = irq_to_gpio(irq); 280 int pin = irq_to_gpio(irq);
298 u32 u; 281 int type = irq_desc[irq].status & IRQ_TYPE_SENSE_MASK;
299 282 u32 reg = (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) ?
300 u = readl(GPIO_LEVEL_MASK(pin)); 283 GPIO_EDGE_MASK(pin) : GPIO_LEVEL_MASK(pin);
284 u32 u = readl(reg);
301 u &= ~(1 << (pin & 31)); 285 u &= ~(1 << (pin & 31));
302 writel(u, GPIO_LEVEL_MASK(pin)); 286 writel(u, reg);
303} 287}
304 288
305static void gpio_irq_level_unmask(u32 irq) 289static void gpio_irq_unmask(u32 irq)
306{ 290{
307 int pin = irq_to_gpio(irq); 291 int pin = irq_to_gpio(irq);
308 u32 u; 292 int type = irq_desc[irq].status & IRQ_TYPE_SENSE_MASK;
309 293 u32 reg = (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) ?
310 u = readl(GPIO_LEVEL_MASK(pin)); 294 GPIO_EDGE_MASK(pin) : GPIO_LEVEL_MASK(pin);
295 u32 u = readl(reg);
311 u |= 1 << (pin & 31); 296 u |= 1 << (pin & 31);
312 writel(u, GPIO_LEVEL_MASK(pin)); 297 writel(u, reg);
313} 298}
314 299
315static int gpio_irq_set_type(u32 irq, u32 type) 300static int gpio_irq_set_type(u32 irq, u32 type)
@@ -331,9 +316,9 @@ static int gpio_irq_set_type(u32 irq, u32 type)
331 * Set edge/level type. 316 * Set edge/level type.
332 */ 317 */
333 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) { 318 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) {
334 desc->chip = &orion_gpio_irq_edge_chip; 319 desc->handle_irq = handle_edge_irq;
335 } else if (type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) { 320 } else if (type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) {
336 desc->chip = &orion_gpio_irq_level_chip; 321 desc->handle_irq = handle_level_irq;
337 } else { 322 } else {
338 printk(KERN_ERR "failed to set irq=%d (type=%d)\n", irq, type); 323 printk(KERN_ERR "failed to set irq=%d (type=%d)\n", irq, type);
339 return -EINVAL; 324 return -EINVAL;
@@ -371,19 +356,11 @@ static int gpio_irq_set_type(u32 irq, u32 type)
371 return 0; 356 return 0;
372} 357}
373 358
374struct irq_chip orion_gpio_irq_edge_chip = { 359struct irq_chip orion_gpio_irq_chip = {
375 .name = "orion_gpio_irq_edge", 360 .name = "orion_gpio",
376 .ack = gpio_irq_edge_ack, 361 .ack = gpio_irq_ack,
377 .mask = gpio_irq_edge_mask, 362 .mask = gpio_irq_mask,
378 .unmask = gpio_irq_edge_unmask, 363 .unmask = gpio_irq_unmask,
379 .set_type = gpio_irq_set_type,
380};
381
382struct irq_chip orion_gpio_irq_level_chip = {
383 .name = "orion_gpio_irq_level",
384 .mask = gpio_irq_level_mask,
385 .mask_ack = gpio_irq_level_mask,
386 .unmask = gpio_irq_level_unmask,
387 .set_type = gpio_irq_set_type, 364 .set_type = gpio_irq_set_type,
388}; 365};
389 366
diff --git a/arch/arm/plat-orion/include/plat/gpio.h b/arch/arm/plat-orion/include/plat/gpio.h
index 54deaf274b52..ec743e82c876 100644
--- a/arch/arm/plat-orion/include/plat/gpio.h
+++ b/arch/arm/plat-orion/include/plat/gpio.h
@@ -31,8 +31,7 @@ void orion_gpio_set_blink(unsigned pin, int blink);
31/* 31/*
32 * GPIO interrupt handling. 32 * GPIO interrupt handling.
33 */ 33 */
34extern struct irq_chip orion_gpio_irq_edge_chip; 34extern struct irq_chip orion_gpio_irq_chip;
35extern struct irq_chip orion_gpio_irq_level_chip;
36void orion_gpio_irq_handler(int irqoff); 35void orion_gpio_irq_handler(int irqoff);
37 36
38 37
diff --git a/arch/arm/plat-s3c64xx/irq-eint.c b/arch/arm/plat-s3c64xx/irq-eint.c
index 1f7cc0067f5c..ebb305ce7689 100644
--- a/arch/arm/plat-s3c64xx/irq-eint.c
+++ b/arch/arm/plat-s3c64xx/irq-eint.c
@@ -55,7 +55,7 @@ static void s3c_irq_eint_unmask(unsigned int irq)
55 u32 mask; 55 u32 mask;
56 56
57 mask = __raw_readl(S3C64XX_EINT0MASK); 57 mask = __raw_readl(S3C64XX_EINT0MASK);
58 mask |= eint_irq_to_bit(irq); 58 mask &= ~eint_irq_to_bit(irq);
59 __raw_writel(mask, S3C64XX_EINT0MASK); 59 __raw_writel(mask, S3C64XX_EINT0MASK);
60} 60}
61 61