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