Merge xburst target.
[openwrt.git] / target / linux / xburst / files-2.6.32 / arch / mips / jz4740 / setup.c
1 /*
2  * linux/arch/mips/jz4740/common/setup.c
3  * 
4  * JZ4740 common setup routines.
5  * 
6  * Copyright (C) 2006 Ingenic Semiconductor Inc.
7  *
8  *  This program is free software; you can distribute it and/or modify it
9  *  under the terms of the GNU General Public License (Version 2) as
10  *  published by the Free Software Foundation.
11  *
12  *  This program is distributed in the hope it will be useful, but WITHOUT
13  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15  *  for more details.
16  *
17  *  You should have received a copy of the GNU General Public License along
18  *  with this program; if not, write to the Free Software Foundation, Inc.,
19  *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
20  *
21  */
22 #include <linux/init.h>
23 #include <linux/string.h>
24 #include <linux/kernel.h>
25 #include <linux/io.h>
26 #include <linux/ioport.h>
27 #include <linux/tty.h>
28 #include <linux/serial.h>
29 #include <linux/serial_core.h>
30 #include <linux/serial_8250.h>
31
32 #include <asm/cpu.h>
33 #include <asm/bootinfo.h>
34 #include <asm/irq.h>
35 #include <asm/mipsregs.h>
36 #include <asm/reboot.h>
37 #include <asm/pgtable.h>
38 #include <asm/time.h>
39 #include <asm/mach-jz4740/jz4740.h>
40 #include <asm/mach-jz4740/regs.h>
41 #include <asm/mach-jz4740/clock.h>
42 #include <asm/mach-jz4740/serial.h>
43
44 extern char *__init prom_getcmdline(void);
45 extern void __init jz_board_setup(void);
46 extern void jz_restart(char *);
47 extern void jz_halt(void);
48 extern void jz_power_off(void);
49 extern void jz_time_init(void);
50
51 static void __init soc_cpm_setup(void)
52 {
53         /* Enable CKO to external memory */
54         __cpm_enable_cko();
55
56         /* CPU enters IDLE mode when executing 'wait' instruction */
57         __cpm_idle_mode();
58 }
59
60
61 static void __init jz_serial_setup(void)
62 {
63 #ifdef CONFIG_SERIAL_8250
64         struct uart_port s;
65         REG8(UART0_FCR) |= UARTFCR_UUE; /* enable UART module */
66         memset(&s, 0, sizeof(s));
67         s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
68         s.iotype = SERIAL_IO_MEM;
69         s.regshift = 2;
70         s.uartclk = JZ_EXTAL;
71
72         s.line = 0;
73         s.membase = (u8 *)UART0_BASE;
74         s.irq = JZ_IRQ_UART0;
75         if (early_serial_setup(&s) != 0) {
76                 printk(KERN_ERR "Serial ttyS0 setup failed!\n");
77         }
78
79         s.line = 1;
80         s.membase = (u8 *)UART1_BASE;
81         s.irq = JZ_IRQ_UART1;
82         if (early_serial_setup(&s) != 0) {
83                 printk(KERN_ERR "Serial ttyS1 setup failed!\n");
84         }
85 #endif
86 }
87
88 void __init plat_mem_setup(void)
89 {
90         char *argptr;
91
92         argptr = prom_getcmdline();
93
94         /* IO/MEM resources. Which will be the addtion value in `inX' and
95          * `outX' macros defined in asm/io.h */
96         set_io_port_base(0);
97         ioport_resource.start   = 0x00000000;
98         ioport_resource.end     = 0xffffffff;
99         iomem_resource.start    = 0x00000000;
100         iomem_resource.end      = 0xffffffff;
101
102         _machine_restart = jz_restart;
103         _machine_halt = jz_halt;
104         pm_power_off = jz_power_off;
105         soc_cpm_setup();
106         jz_serial_setup();
107 }
108