include missing atm-tools to setup pppoe/a links
[openwrt/openwrt.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 #include <linux/console.h>
23 #include <linux/serial.h>
24 #include <linux/serial_8250.h>
25
26 #include <asm/reboot.h>
27 #include <asm/time.h>
28 #include <asm/ar7/ar7.h>
29 #include <asm/ar7/prom.h>
30
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);
33 #endif
34 static void ar7_machine_restart(char *command);
35 static void ar7_machine_halt(void);
36 static void ar7_machine_power_off(void);
37
38 static void ar7_machine_restart(char *command)
39 {
40 u32 *softres_reg = (u32 *)ioremap(AR7_REGS_RESET +
41 AR7_RESET_SOFTWARE, 1);
42 writel(1, softres_reg);
43 }
44
45 static void ar7_machine_halt(void)
46 {
47 while (1);
48 }
49
50 static void ar7_machine_power_off(void)
51 {
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);
55 ar7_machine_halt();
56 }
57
58 const char *get_system_type(void)
59 {
60 u16 chip_id = ar7_chip_id();
61 switch (chip_id) {
62 case AR7_CHIP_7300:
63 return "TI AR7 (TNETD7300)";
64 case AR7_CHIP_7100:
65 return "TI AR7 (TNETD7100)";
66 case AR7_CHIP_7200:
67 return "TI AR7 (TNETD7200)";
68 default:
69 return "TI AR7 (Unknown)";
70 }
71 }
72
73 static int __init ar7_init_console(void)
74 {
75 int res;
76
77 static struct uart_port uart_port[2];
78
79 memset(uart_port, 0, sizeof(struct uart_port) * 2);
80
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]);
90 if (res)
91 return res;
92
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]);
104 if (res)
105 return res;
106 }
107
108 return add_preferred_console("ttyS", 0, NULL);
109 }
110
111 /*
112 * Initializes basic routines and structures pointers, memory size (as
113 * given by the bios and saves the command line.
114 */
115
116 extern void ar7_init_clocks(void);
117
118 void __init plat_mem_setup(void)
119 {
120 unsigned long io_base;
121
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;
127 #endif
128 panic_timeout = 3;
129
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);
133
134 prom_meminit();
135 ar7_init_clocks();
136
137 ioport_resource.start = 0;
138 ioport_resource.end = ~0;
139 iomem_resource.start = 0;
140 iomem_resource.end = ~0;
141
142 printk(KERN_INFO "%s, ID: 0x%04x, Revision: 0x%02x\n",
143 get_system_type(),
144 ar7_chip_id(), ar7_chip_rev());
145 }
146
147 console_initcall(ar7_init_console);