2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
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.
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
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.
18 #include <linux/version.h>
19 #include <linux/init.h>
20 #include <linux/ioport.h>
22 #include <linux/console.h>
23 #include <linux/serial.h>
24 #include <linux/serial_8250.h>
26 #include <asm/reboot.h>
28 #include <asm/ar7/ar7.h>
29 #include <asm/ar7/prom.h>
31 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) /* TODO remove when 2.6.24 is stable */
32 extern void ar7_time_init(void);
34 static void ar7_machine_restart(char *command);
35 static void ar7_machine_halt(void);
36 static void ar7_machine_power_off(void);
38 static void ar7_machine_restart(char *command)
40 u32 *softres_reg = (u32 *)ioremap(AR7_REGS_RESET +
41 AR7_RESET_SOFTWARE, 1);
42 writel(1, softres_reg);
45 static void ar7_machine_halt(void)
50 static void ar7_machine_power_off(void)
52 u32 *power_reg = (u32 *)ioremap(AR7_REGS_POWER, 1);
53 u32 power_state = readl(power_reg) | (3 << 30);
54 writel(power_state, power_reg);
58 const char *get_system_type(void)
60 u16 chip_id = ar7_chip_id();
63 return "TI AR7 (TNETD7300)";
65 return "TI AR7 (TNETD7100)";
67 return "TI AR7 (TNETD7200)";
69 return "TI AR7 (Unknown)";
73 static int __init ar7_init_console(void)
77 static struct uart_port uart_port[2];
79 memset(uart_port, 0, sizeof(struct uart_port) * 2);
81 uart_port[0].type = PORT_AR7;
82 uart_port[0].line = 0;
83 uart_port[0].irq = AR7_IRQ_UART0;
84 uart_port[0].uartclk = ar7_bus_freq() / 2;
85 uart_port[0].iotype = UPIO_MEM;
86 uart_port[0].mapbase = AR7_REGS_UART0;
87 uart_port[0].membase = ioremap(uart_port[0].mapbase, 256);
88 uart_port[0].regshift = 2;
89 res = early_serial_setup(&uart_port[0]);
93 /* Only TNETD73xx have a second serial port */
94 if (ar7_has_second_uart()) {
95 uart_port[1].type = PORT_AR7;
96 uart_port[1].line = 1;
97 uart_port[1].irq = AR7_IRQ_UART1;
98 uart_port[1].uartclk = ar7_bus_freq() / 2;
99 uart_port[1].iotype = UPIO_MEM;
100 uart_port[1].mapbase = UR8_REGS_UART1;
101 uart_port[1].membase = ioremap(uart_port[1].mapbase, 256);
102 uart_port[1].regshift = 2;
103 res = early_serial_setup(&uart_port[1]);
108 return add_preferred_console("ttyS", 0, NULL);
112 * Initializes basic routines and structures pointers, memory size (as
113 * given by the bios and saves the command line.
116 extern void ar7_init_clocks(void);
118 void __init plat_mem_setup(void)
120 unsigned long io_base;
122 _machine_restart = ar7_machine_restart;
123 _machine_halt = ar7_machine_halt;
124 pm_power_off = ar7_machine_power_off;
125 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) /* TODO remove when 2.6.24 is stable */
126 board_time_init = ar7_time_init;
130 io_base = (unsigned long)ioremap(AR7_REGS_BASE, 0x10000);
131 if (!io_base) panic("Can't remap IO base!\n");
132 set_io_port_base(io_base);
137 ioport_resource.start = 0;
138 ioport_resource.end = ~0;
139 iomem_resource.start = 0;
140 iomem_resource.end = ~0;
142 printk(KERN_INFO "%s, ID: 0x%04x, Revision: 0x%02x\n",
144 ar7_chip_id(), ar7_chip_rev());
147 console_initcall(ar7_init_console);