ar7: clocks setup (prerequisite for dsl/usb) and misc cleanups.
[openwrt/svn-archive/archive.git] / target / linux / ar7-2.6 / files / arch / mips / ar7 / setup.c
1 /*
2 * $Id$
3 *
4 * Copyright (C) 2006, 2007 OpenWrt.org
5 *
6 * Carsten Langgaard, carstenl@mips.com
7 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
8 *
9 * This program is free software; you can distribute it and/or modify it
10 * under the terms of the GNU General Public License (Version 2) as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
21 */
22 #include <linux/init.h>
23 #include <linux/sched.h>
24 #include <linux/ioport.h>
25 #include <linux/pci.h>
26 #include <linux/tty.h>
27 #include <linux/pm.h>
28 #include <linux/serial_8250.h>
29 #include <linux/serial_core.h>
30 #include <linux/serial.h>
31 #include <linux/serial_reg.h>
32
33 #include <asm/cpu.h>
34 #include <asm/irq.h>
35 #include <asm/mips-boards/generic.h>
36 #include <asm/mips-boards/prom.h>
37 #include <asm/dma.h>
38 #include <asm/time.h>
39 #include <asm/traps.h>
40 #include <asm/io.h>
41 #include <asm/reboot.h>
42 #include <asm/gdb-stub.h>
43 #include <asm/ar7/ar7.h>
44
45 extern void ar7_time_init(void);
46 static void ar7_machine_restart(char *command);
47 static void ar7_machine_halt(void);
48 static void ar7_machine_power_off(void);
49
50 static void ar7_machine_restart(char *command)
51 {
52 volatile u32 *softres_reg = (u32 *)ioremap(AR7_REGS_RESET +
53 AR7_RESET_SOFTWARE, 1);
54 prom_printf("Reboot\n");
55 *softres_reg = 1;
56 }
57
58 static void ar7_machine_halt(void)
59 {
60 prom_printf("Halt\n");
61 while (1);
62 }
63
64 static void ar7_machine_power_off(void)
65 {
66 volatile u32 *power_reg = (u32 *)ioremap(AR7_REGS_POWER, 1);
67 u32 power_state = *power_reg | (3 << 30);
68 prom_printf("Power off\n");
69 *power_reg = power_state;
70 ar7_machine_halt();
71 }
72
73 const char *get_system_type(void)
74 {
75 u16 chip_id = ar7_chip_id();
76 switch (chip_id) {
77 case AR7_CHIP_7300:
78 return "TI AR7 (TNETD7300)";
79 case AR7_CHIP_7100:
80 return "TI AR7 (TNETD7100)";
81 case AR7_CHIP_7200:
82 return "TI AR7 (TNETD7200)";
83 default:
84 return "TI AR7 (Unknown)";
85 }
86 }
87
88 static int __init ar7_init_console(void)
89 {
90 return 0;
91 }
92
93 /*
94 * Initializes basic routines and structures pointers, memory size (as
95 * given by the bios and saves the command line.
96 */
97
98 extern void ar7_init_clocks(void);
99
100 void __init plat_mem_setup(void)
101 {
102 unsigned long io_base;
103
104 _machine_restart = ar7_machine_restart;
105 _machine_halt = ar7_machine_halt;
106 pm_power_off = ar7_machine_power_off;
107 board_time_init = ar7_time_init;
108 panic_timeout = 3;
109
110 io_base = (unsigned long)ioremap(AR7_REGS_BASE, 0x10000);
111 if (!io_base) panic("Can't remap IO base!\n");
112 set_io_port_base(io_base);
113
114 prom_meminit();
115 ar7_init_clocks();
116
117 ioport_resource.start = 0;
118 ioport_resource.end = ~0;
119 iomem_resource.start = 0;
120 iomem_resource.end = ~0;
121 }
122
123 console_initcall(ar7_init_console);