wanzongshun | a62e903 | 2009-12-31 15:06:05 +0100 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-nuc93x/cpu.c |
| 3 | * |
| 4 | * Copyright (c) 2009 Nuvoton corporation. |
| 5 | * |
| 6 | * Wan ZongShun <mcuos.com@gmail.com> |
| 7 | * |
| 8 | * NUC93x series cpu common support |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation;version 2 of the License. |
| 13 | * |
| 14 | */ |
| 15 | |
| 16 | #include <linux/kernel.h> |
| 17 | #include <linux/types.h> |
| 18 | #include <linux/interrupt.h> |
| 19 | #include <linux/list.h> |
| 20 | #include <linux/timer.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/platform_device.h> |
| 23 | #include <linux/io.h> |
| 24 | #include <linux/serial_8250.h> |
| 25 | #include <linux/delay.h> |
| 26 | |
| 27 | #include <asm/mach/arch.h> |
| 28 | #include <asm/mach/map.h> |
| 29 | #include <asm/mach/irq.h> |
| 30 | #include <asm/irq.h> |
| 31 | |
| 32 | #include <mach/hardware.h> |
| 33 | #include <mach/regs-serial.h> |
| 34 | #include <mach/regs-clock.h> |
| 35 | #include <mach/regs-ebi.h> |
| 36 | |
| 37 | #include "cpu.h" |
| 38 | #include "clock.h" |
| 39 | |
| 40 | /* Initial IO mappings */ |
| 41 | |
| 42 | static struct map_desc nuc93x_iodesc[] __initdata = { |
| 43 | IODESC_ENT(IRQ), |
| 44 | IODESC_ENT(GCR), |
| 45 | IODESC_ENT(UART), |
| 46 | IODESC_ENT(TIMER), |
| 47 | IODESC_ENT(EBI), |
| 48 | }; |
| 49 | |
| 50 | /* Initial nuc932 clock declarations. */ |
| 51 | static DEFINE_CLK(audio, 2); |
| 52 | static DEFINE_CLK(sd, 3); |
| 53 | static DEFINE_CLK(jpg, 4); |
| 54 | static DEFINE_CLK(video, 5); |
| 55 | static DEFINE_CLK(vpost, 6); |
| 56 | static DEFINE_CLK(2d, 7); |
| 57 | static DEFINE_CLK(gpu, 8); |
| 58 | static DEFINE_CLK(gdma, 9); |
| 59 | static DEFINE_CLK(adc, 10); |
| 60 | static DEFINE_CLK(uart, 11); |
| 61 | static DEFINE_CLK(spi, 12); |
| 62 | static DEFINE_CLK(pwm, 13); |
| 63 | static DEFINE_CLK(timer, 14); |
| 64 | static DEFINE_CLK(wdt, 15); |
| 65 | static DEFINE_CLK(ac97, 16); |
| 66 | static DEFINE_CLK(i2s, 16); |
| 67 | static DEFINE_CLK(usbck, 17); |
| 68 | static DEFINE_CLK(usb48, 18); |
| 69 | static DEFINE_CLK(usbh, 19); |
| 70 | static DEFINE_CLK(i2c, 20); |
| 71 | static DEFINE_CLK(ext, 0); |
| 72 | |
| 73 | static struct clk_lookup nuc932_clkregs[] = { |
| 74 | DEF_CLKLOOK(&clk_audio, "nuc932-audio", NULL), |
| 75 | DEF_CLKLOOK(&clk_sd, "nuc932-sd", NULL), |
| 76 | DEF_CLKLOOK(&clk_jpg, "nuc932-jpg", "NULL"), |
| 77 | DEF_CLKLOOK(&clk_video, "nuc932-video", "NULL"), |
| 78 | DEF_CLKLOOK(&clk_vpost, "nuc932-vpost", NULL), |
| 79 | DEF_CLKLOOK(&clk_2d, "nuc932-2d", NULL), |
| 80 | DEF_CLKLOOK(&clk_gpu, "nuc932-gpu", NULL), |
| 81 | DEF_CLKLOOK(&clk_gdma, "nuc932-gdma", "NULL"), |
| 82 | DEF_CLKLOOK(&clk_adc, "nuc932-adc", NULL), |
| 83 | DEF_CLKLOOK(&clk_uart, NULL, "uart"), |
| 84 | DEF_CLKLOOK(&clk_spi, "nuc932-spi", NULL), |
| 85 | DEF_CLKLOOK(&clk_pwm, "nuc932-pwm", NULL), |
| 86 | DEF_CLKLOOK(&clk_timer, NULL, "timer"), |
| 87 | DEF_CLKLOOK(&clk_wdt, "nuc932-wdt", NULL), |
| 88 | DEF_CLKLOOK(&clk_ac97, "nuc932-ac97", NULL), |
| 89 | DEF_CLKLOOK(&clk_i2s, "nuc932-i2s", NULL), |
| 90 | DEF_CLKLOOK(&clk_usbck, "nuc932-usbck", NULL), |
| 91 | DEF_CLKLOOK(&clk_usb48, "nuc932-usb48", NULL), |
| 92 | DEF_CLKLOOK(&clk_usbh, "nuc932-usbh", NULL), |
| 93 | DEF_CLKLOOK(&clk_i2c, "nuc932-i2c", NULL), |
| 94 | DEF_CLKLOOK(&clk_ext, NULL, "ext"), |
| 95 | }; |
| 96 | |
| 97 | /* Initial serial platform data */ |
| 98 | |
| 99 | struct plat_serial8250_port nuc93x_uart_data[] = { |
| 100 | NUC93X_8250PORT(UART0), |
| 101 | {}, |
| 102 | }; |
| 103 | |
| 104 | struct platform_device nuc93x_serial_device = { |
| 105 | .name = "serial8250", |
| 106 | .id = PLAT8250_DEV_PLATFORM, |
| 107 | .dev = { |
| 108 | .platform_data = nuc93x_uart_data, |
| 109 | }, |
| 110 | }; |
| 111 | |
| 112 | /*Init NUC93x evb io*/ |
| 113 | |
| 114 | void __init nuc93x_map_io(struct map_desc *mach_desc, int mach_size) |
| 115 | { |
| 116 | unsigned long idcode = 0x0; |
| 117 | |
| 118 | iotable_init(mach_desc, mach_size); |
| 119 | iotable_init(nuc93x_iodesc, ARRAY_SIZE(nuc93x_iodesc)); |
| 120 | |
| 121 | idcode = __raw_readl(NUC93XPDID); |
| 122 | if (idcode == NUC932_CPUID) |
| 123 | printk(KERN_INFO "CPU type 0x%08lx is NUC910\n", idcode); |
| 124 | else |
| 125 | printk(KERN_ERR "CPU type detect error!\n"); |
| 126 | |
| 127 | } |
| 128 | |
| 129 | /*Init NUC93x clock*/ |
| 130 | |
| 131 | void __init nuc93x_init_clocks(void) |
| 132 | { |
| 133 | clks_register(nuc932_clkregs, ARRAY_SIZE(nuc932_clkregs)); |
| 134 | } |
| 135 | |