blob: 7bb9a670bb73574ce208cfc75d6a5b9945d9f35a [file] [log] [blame]
Florian Fainelli7ca5dc12009-06-24 11:12:57 +02001/*
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 */
Florian Fainelli7ca5dc12009-06-24 11:12:57 +020018#include <linux/init.h>
19#include <linux/ioport.h>
20#include <linux/pm.h>
21#include <linux/time.h>
22
23#include <asm/reboot.h>
24#include <asm/mach-ar7/ar7.h>
25#include <asm/mach-ar7/prom.h>
26
27static void ar7_machine_restart(char *command)
28{
Alexander Clouter4d1da8c2010-01-31 19:38:19 +000029 u32 *softres_reg = ioremap(AR7_REGS_RESET + AR7_RESET_SOFTWARE, 1);
30
Florian Fainelli7ca5dc12009-06-24 11:12:57 +020031 writel(1, softres_reg);
32}
33
34static void ar7_machine_halt(void)
35{
36 while (1)
37 ;
38}
39
40static void ar7_machine_power_off(void)
41{
42 u32 *power_reg = (u32 *)ioremap(AR7_REGS_POWER, 1);
43 u32 power_state = readl(power_reg) | (3 << 30);
Alexander Clouter4d1da8c2010-01-31 19:38:19 +000044
Florian Fainelli7ca5dc12009-06-24 11:12:57 +020045 writel(power_state, power_reg);
46 ar7_machine_halt();
47}
48
49const char *get_system_type(void)
50{
51 u16 chip_id = ar7_chip_id();
Florian Fainelli238dd312010-08-29 17:08:44 +020052 u16 titan_variant_id = titan_chip_id();
53
Florian Fainelli7ca5dc12009-06-24 11:12:57 +020054 switch (chip_id) {
Florian Fainelli7ca5dc12009-06-24 11:12:57 +020055 case AR7_CHIP_7100:
56 return "TI AR7 (TNETD7100)";
57 case AR7_CHIP_7200:
58 return "TI AR7 (TNETD7200)";
Alexander Clouter4d1da8c2010-01-31 19:38:19 +000059 case AR7_CHIP_7300:
60 return "TI AR7 (TNETD7300)";
Florian Fainelli238dd312010-08-29 17:08:44 +020061 case AR7_CHIP_TITAN:
62 switch (titan_variant_id) {
63 case TITAN_CHIP_1050:
64 return "TI AR7 (TNETV1050)";
65 case TITAN_CHIP_1055:
66 return "TI AR7 (TNETV1055)";
67 case TITAN_CHIP_1056:
68 return "TI AR7 (TNETV1056)";
69 case TITAN_CHIP_1060:
70 return "TI AR7 (TNETV1060)";
71 }
Florian Fainelli7ca5dc12009-06-24 11:12:57 +020072 default:
Alexander Clouter4d1da8c2010-01-31 19:38:19 +000073 return "TI AR7 (unknown)";
Florian Fainelli7ca5dc12009-06-24 11:12:57 +020074 }
75}
76
77static int __init ar7_init_console(void)
78{
79 return 0;
80}
81console_initcall(ar7_init_console);
82
83/*
84 * Initializes basic routines and structures pointers, memory size (as
85 * given by the bios and saves the command line.
86 */
Florian Fainelli7ca5dc12009-06-24 11:12:57 +020087void __init plat_mem_setup(void)
88{
89 unsigned long io_base;
90
91 _machine_restart = ar7_machine_restart;
92 _machine_halt = ar7_machine_halt;
93 pm_power_off = ar7_machine_power_off;
Florian Fainelli7ca5dc12009-06-24 11:12:57 +020094
95 io_base = (unsigned long)ioremap(AR7_REGS_BASE, 0x10000);
96 if (!io_base)
Ralf Baechleab75dc02011-11-17 15:07:31 +000097 panic("Can't remap IO base!");
Florian Fainelli7ca5dc12009-06-24 11:12:57 +020098 set_io_port_base(io_base);
99
100 prom_meminit();
101
102 printk(KERN_INFO "%s, ID: 0x%04x, Revision: 0x%02x\n",
Alexander Clouter4d1da8c2010-01-31 19:38:19 +0000103 get_system_type(), ar7_chip_id(), ar7_chip_rev());
Florian Fainelli7ca5dc12009-06-24 11:12:57 +0200104}