modernize backfire 10.03 so it can be operational again
[openwrt-10.03/.git] / target / linux / xburst / files / 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 #include "clock.h"
45
46 extern char *__init prom_getcmdline(void);
47 extern void jz_restart(char *);
48 extern void jz_halt(void);
49 extern void jz_power_off(void);
50
51 static void __init jz_serial_setup(void)
52 {
53 #ifdef CONFIG_SERIAL_8250
54         struct uart_port s;
55         REG8(UART0_FCR) |= UARTFCR_UUE; /* enable UART module */
56         memset(&s, 0, sizeof(s));
57         s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
58         s.iotype = SERIAL_IO_MEM;
59         s.regshift = 2;
60         s.uartclk = jz4740_clock_bdata.ext_rate;
61
62         s.line = 0;
63         s.membase = (u8 *)UART0_BASE;
64         s.irq = JZ_IRQ_UART0;
65         if (early_serial_setup(&s) != 0) {
66                 printk(KERN_ERR "Serial ttyS0 setup failed!\n");
67         }
68
69         s.line = 1;
70         s.membase = (u8 *)UART1_BASE;
71         s.irq = JZ_IRQ_UART1;
72         if (early_serial_setup(&s) != 0) {
73                 printk(KERN_ERR "Serial ttyS1 setup failed!\n");
74         }
75 #endif
76 }
77
78 void __init plat_mem_setup(void)
79 {
80         char *argptr;
81
82         argptr = prom_getcmdline();
83
84         /* IO/MEM resources. Which will be the addtion value in `inX' and
85          * `outX' macros defined in asm/io.h */
86         set_io_port_base(0);
87         ioport_resource.start   = 0x00000000;
88         ioport_resource.end     = 0xffffffff;
89         iomem_resource.start    = 0x00000000;
90         iomem_resource.end      = 0xffffffff;
91
92         _machine_restart = jz_restart;
93         _machine_halt = jz_halt;
94         pm_power_off = jz_power_off;
95         jz_serial_setup();
96 }
97