[ar7] move files to file-2.6.30
[15.05/openwrt.git] / target / linux / ar7 / files-2.6.30 / 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/gpio.h>
27 #include <asm/ar7/prom.h>
28
29 static int titan_variant;  /*hold the results of the gpio_init_titan_variant() so that it is only called once*/
30 static void ar7_machine_restart(char *command);
31 static void ar7_machine_halt(void);
32 static void ar7_machine_power_off(void);
33
34 static void ar7_machine_restart(char *command)
35 {
36         u32 *softres_reg = (u32 *)ioremap(AR7_REGS_RESET +
37                                           AR7_RESET_SOFTWARE, 1);
38         writel(1, softres_reg);
39 }
40
41 static void ar7_machine_halt(void)
42 {
43         while (1);
44 }
45
46 static void ar7_machine_power_off(void)
47 {
48         u32 *power_reg = (u32 *)ioremap(AR7_REGS_POWER, 1);
49         u32 power_state = readl(power_reg) | (3 << 30);
50         writel(power_state, power_reg);
51         ar7_machine_halt();
52 }
53
54 const char *get_system_type(void)
55 {
56         u16 chip_id = ar7_chip_id();
57         switch (chip_id) {
58         case AR7_CHIP_7300:
59                 return "TI AR7 (TNETD7300)";
60         case AR7_CHIP_7100:
61                 return "TI AR7 (TNETD7100)";
62         case AR7_CHIP_7200:
63                 return "TI AR7 (TNETD7200)";
64         case AR7_CHIP_TITAN:
65                 titan_variant = ar7_init_titan_variant();
66                 switch (titan_variant /*(gpio_get_value_titan(1) >> 12) & 0xf*/) {
67                 case TITAN_CHIP_1050:
68                         return "TI AR7 (TNETV1050)";
69                 case TITAN_CHIP_1055:
70                         return "TI AR7 (TNETV1055)";
71                 case TITAN_CHIP_1056:
72                         return "TI AR7 (TNETV1056)";
73                 case TITAN_CHIP_1060:
74                         return "TI AR7 (TNETV1060)";
75                 }
76         default:
77                 return "TI AR7 (Unknown)";
78         }
79 }
80
81 static int __init ar7_init_console(void)
82 {
83         return 0;
84 }
85
86 /*
87  * Initializes basic routines and structures pointers, memory size (as
88  * given by the bios and saves the command line.
89  */
90
91 extern void ar7_init_clocks(void);
92
93 void __init plat_mem_setup(void)
94 {
95         unsigned long io_base;
96
97         _machine_restart = ar7_machine_restart;
98         _machine_halt = ar7_machine_halt;
99         pm_power_off = ar7_machine_power_off;
100         panic_timeout = 3;
101
102         io_base = (unsigned long)ioremap(AR7_REGS_BASE, 0x10000);
103         if (!io_base) panic("Can't remap IO base!\n");
104         set_io_port_base(io_base);
105
106         prom_meminit();
107         ar7_init_clocks();
108
109         ioport_resource.start = 0;
110         ioport_resource.end   = ~0;
111         iomem_resource.start  = 0;
112         iomem_resource.end    = ~0;
113
114         printk(KERN_INFO "%s, ID: 0x%04x, Revision: 0x%02x\n",
115                                         get_system_type(),
116                 ar7_chip_id(), ar7_chip_rev());
117 }
118
119 console_initcall(ar7_init_console);