PageRenderTime 38ms CodeModel.GetById 32ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

/arch/mips/ar7/setup.c

https://bitbucket.org/thekraven/iscream_thunderc-2.6.35
C | 92 lines | 58 code | 13 blank | 21 comment | 3 complexity | c529d73263740ff1f14d4515c04ca5a5 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
 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/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{
29	u32 *softres_reg = ioremap(AR7_REGS_RESET + AR7_RESET_SOFTWARE, 1);
30
31	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);
44
45	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();
52	switch (chip_id) {
53	case AR7_CHIP_7100:
54		return "TI AR7 (TNETD7100)";
55	case AR7_CHIP_7200:
56		return "TI AR7 (TNETD7200)";
57	case AR7_CHIP_7300:
58		return "TI AR7 (TNETD7300)";
59	default:
60		return "TI AR7 (unknown)";
61	}
62}
63
64static int __init ar7_init_console(void)
65{
66	return 0;
67}
68console_initcall(ar7_init_console);
69
70/*
71 * Initializes basic routines and structures pointers, memory size (as
72 * given by the bios and saves the command line.
73 */
74void __init plat_mem_setup(void)
75{
76	unsigned long io_base;
77
78	_machine_restart = ar7_machine_restart;
79	_machine_halt = ar7_machine_halt;
80	pm_power_off = ar7_machine_power_off;
81	panic_timeout = 3;
82
83	io_base = (unsigned long)ioremap(AR7_REGS_BASE, 0x10000);
84	if (!io_base)
85		panic("Can't remap IO base!\n");
86	set_io_port_base(io_base);
87
88	prom_meminit();
89
90	printk(KERN_INFO "%s, ID: 0x%04x, Revision: 0x%02x\n",
91			get_system_type(), ar7_chip_id(), ar7_chip_rev());
92}