use common get_system_type function
[openwrt/openwrt.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / setup.c
1 /*
2 * Ralink RT305x SoC specific setup
3 *
4 * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
5 *
6 * Parts of this file are based on Ralink's 2.6.21 BSP
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
11 */
12
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/io.h>
16 #include <linux/serial_8250.h>
17
18 #include <asm/mips_machine.h>
19 #include <asm/reboot.h>
20 #include <asm/time.h>
21
22 #include <asm/mach-ralink/common.h>
23 #include <asm/mach-ralink/rt305x.h>
24 #include <asm/mach-ralink/rt305x_regs.h>
25
26 #include "machine.h"
27
28 enum rt305x_mach_type rt305x_mach;
29
30 static void rt305x_restart(char *command)
31 {
32 rt305x_sysc_wr(RT305X_RESET_SYSTEM, SYSC_REG_RESET_CTRL);
33 while (1)
34 if (cpu_wait)
35 cpu_wait();
36 }
37
38 static void rt305x_halt(void)
39 {
40 while (1)
41 if (cpu_wait)
42 cpu_wait();
43 }
44
45 static void __init rt305x_early_serial_setup(void)
46 {
47 struct uart_port p;
48 int err;
49
50 memset(&p, 0, sizeof(p));
51 p.flags = UPF_SKIP_TEST;
52 p.iotype = UPIO_AU;
53 p.uartclk = rt305x_sys_freq;
54 p.regshift = 2;
55 p.type = PORT_16550A;
56
57 p.mapbase = RT305X_UART0_BASE;
58 p.membase = ioremap_nocache(p.mapbase, RT305X_UART0_SIZE);
59 p.line = 0;
60 p.irq = RT305X_INTC_IRQ_UART0;
61
62 err = early_serial_setup(&p);
63 if (err)
64 printk(KERN_ERR "RT305x: early UART0 registration failed %d\n",
65 err);
66
67 p.mapbase = RT305X_UART1_BASE;
68 p.membase = ioremap_nocache(p.mapbase, RT305X_UART1_SIZE);
69 p.line = 1;
70 p.irq = RT305X_INTC_IRQ_UART1;
71
72 err = early_serial_setup(&p);
73 if (err)
74 printk(KERN_ERR "RT305x: early UART1 registration failed %d\n",
75 err);
76 }
77
78 unsigned int __cpuinit get_c0_compare_irq(void)
79 {
80 return CP0_LEGACY_COMPARE_IRQ;
81 }
82
83 void __init ramips_soc_setup(void)
84 {
85 rt305x_sysc_base = ioremap_nocache(RT305X_SYSC_BASE, PAGE_SIZE);
86 rt305x_memc_base = ioremap_nocache(RT305X_MEMC_BASE, PAGE_SIZE);
87
88 rt305x_detect_sys_type();
89 rt305x_detect_sys_freq();
90
91 printk(KERN_INFO "%s running at %lu.%02lu MHz\n", ramips_sys_type,
92 rt305x_cpu_freq / 1000000,
93 (rt305x_cpu_freq % 1000000) * 100 / 1000000);
94
95 _machine_restart = rt305x_restart;
96 _machine_halt = rt305x_halt;
97 pm_power_off = rt305x_halt;
98
99 rt305x_early_serial_setup();
100 }
101
102 void __init plat_time_init(void)
103 {
104 mips_hpt_frequency = rt305x_cpu_freq / 2;
105 }
106
107 static int __init rt305x_machine_setup(void)
108 {
109 mips_machine_setup(rt305x_mach);
110
111 return 0;
112 }
113
114 arch_initcall(rt305x_machine_setup);