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