remove 'svn:keywords' property, not needed anymore after [15242]
[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 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) /* TODO remove when 2.6.24 is stable */
29 extern void ar7_time_init(void);
30 #endif
31 static void ar7_machine_restart(char *command);
32 static void ar7_machine_halt(void);
33 static void ar7_machine_power_off(void);
34
35 static void ar7_machine_restart(char *command)
36 {
37 u32 *softres_reg = (u32 *)ioremap(AR7_REGS_RESET +
38 AR7_RESET_SOFTWARE, 1);
39 writel(1, softres_reg);
40 }
41
42 static void ar7_machine_halt(void)
43 {
44 while (1);
45 }
46
47 static void ar7_machine_power_off(void)
48 {
49 u32 *power_reg = (u32 *)ioremap(AR7_REGS_POWER, 1);
50 u32 power_state = readl(power_reg) | (3 << 30);
51 writel(power_state, power_reg);
52 ar7_machine_halt();
53 }
54
55 const char *get_system_type(void)
56 {
57 u16 chip_id = ar7_chip_id();
58 switch (chip_id) {
59 case AR7_CHIP_7300:
60 return "TI AR7 (TNETD7300)";
61 case AR7_CHIP_7100:
62 return "TI AR7 (TNETD7100)";
63 case AR7_CHIP_7200:
64 return "TI AR7 (TNETD7200)";
65 default:
66 return "TI AR7 (Unknown)";
67 }
68 }
69
70 static int __init ar7_init_console(void)
71 {
72 return 0;
73 }
74
75 /*
76 * Initializes basic routines and structures pointers, memory size (as
77 * given by the bios and saves the command line.
78 */
79
80 extern void ar7_init_clocks(void);
81
82 void __init plat_mem_setup(void)
83 {
84 unsigned long io_base;
85
86 _machine_restart = ar7_machine_restart;
87 _machine_halt = ar7_machine_halt;
88 pm_power_off = ar7_machine_power_off;
89 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) /* TODO remove when 2.6.24 is stable */
90 board_time_init = ar7_time_init;
91 #endif
92 panic_timeout = 3;
93
94 io_base = (unsigned long)ioremap(AR7_REGS_BASE, 0x10000);
95 if (!io_base) panic("Can't remap IO base!\n");
96 set_io_port_base(io_base);
97
98 prom_meminit();
99 ar7_init_clocks();
100
101 ioport_resource.start = 0;
102 ioport_resource.end = ~0;
103 iomem_resource.start = 0;
104 iomem_resource.end = ~0;
105
106 printk(KERN_INFO "%s, ID: 0x%04x, Revision: 0x%02x\n",
107 get_system_type(),
108 ar7_chip_id(), ar7_chip_rev());
109 }
110
111 console_initcall(ar7_init_console);