271dfaa6b401a024a17a8e0aee5f450b38d351bb
[openwrt.git] / target / linux / adm5120 / files / arch / mips / adm5120 / common / setup.c
1 /*
2 * ADM5120 specific setup
3 *
4 * Copyright (C) 2007-2009 Gabor Juhos <juhosg@openwrt.org>
5 *
6 * This code was based on the ADM5120 specific port of the Linux 2.6.10 kernel
7 * done by Jeroen Vreeken
8 * Copyright (C) 2005 Jeroen Vreeken (pe1rxq@amsat.org)
9 *
10 * Jeroen's code was based on the Linux 2.4.xx source codes found in various
11 * tarballs released by Edimax for it's ADM5120 based devices
12 * Copyright (C) ADMtek Incorporated
13 *
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License version 2 as published
16 * by the Free Software Foundation.
17 *
18 */
19
20 #include <linux/init.h>
21 #include <linux/kernel.h>
22 #include <linux/io.h>
23
24 #include <asm/reboot.h>
25 #include <asm/time.h>
26 #include <asm/mips_machine.h>
27
28 #include <asm/mach-adm5120/adm5120_info.h>
29 #include <asm/mach-adm5120/adm5120_defs.h>
30 #include <asm/mach-adm5120/adm5120_switch.h>
31 #include <asm/mach-adm5120/adm5120_platform.h>
32
33 #define ADM5120_SYS_TYPE_LEN 64
34
35 unsigned char adm5120_sys_type[ADM5120_SYS_TYPE_LEN];
36 void (*adm5120_board_reset)(void);
37
38 static char *prom_names[ADM5120_PROM_LAST+1] __initdata = {
39 [ADM5120_PROM_GENERIC] = "Generic",
40 [ADM5120_PROM_CFE] = "CFE",
41 [ADM5120_PROM_UBOOT] = "U-Boot",
42 [ADM5120_PROM_MYLOADER] = "MyLoader",
43 [ADM5120_PROM_ROUTERBOOT] = "RouterBOOT",
44 [ADM5120_PROM_BOOTBASE] = "Bootbase"
45 };
46
47 static void __init adm5120_report(void)
48 {
49 printk(KERN_INFO "SoC : %s\n", adm5120_sys_type);
50 printk(KERN_INFO "Bootdev : %s flash\n",
51 adm5120_nand_boot ? "NAND":"NOR");
52 printk(KERN_INFO "Prom : %s\n", prom_names[adm5120_prom_type]);
53 }
54
55 const char *get_system_type(void)
56 {
57 return adm5120_sys_type;
58 }
59
60 static void adm5120_restart(char *command)
61 {
62 /* TODO: stop switch before reset */
63
64 if (adm5120_board_reset)
65 adm5120_board_reset();
66
67 SW_WRITE_REG(SWITCH_REG_SOFT_RESET, 1);
68 }
69
70 static void adm5120_halt(void)
71 {
72 local_irq_disable();
73
74 while (1) {
75 if (cpu_wait)
76 cpu_wait();
77 }
78 }
79
80 void __init plat_time_init(void)
81 {
82 mips_hpt_frequency = adm5120_speed / 2;
83 }
84
85 void __init plat_mem_setup(void)
86 {
87 adm5120_soc_init();
88 adm5120_mem_init();
89
90 sprintf(adm5120_sys_type, "ADM%04X%s rev %u, running at %lu.%03lu MHz",
91 adm5120_product_code,
92 adm5120_package_bga() ? "" : "P",
93 adm5120_revision,
94 (adm5120_speed / 1000000), (adm5120_speed / 1000) % 1000);
95
96 adm5120_report();
97
98 _machine_restart = adm5120_restart;
99 _machine_halt = adm5120_halt;
100 pm_power_off = adm5120_halt;
101
102 set_io_port_base(KSEG1);
103 }
104
105 static int __init adm5120_board_setup(void)
106 {
107 adm5120_gpio_init();
108
109 mips_machine_setup(adm5120_mach_type);
110
111 return 0;
112 }
113 arch_initcall(adm5120_board_setup);
114
115 static void __init adm5120_generic_board_setup(void)
116 {
117 adm5120_add_device_uart(0);
118 adm5120_add_device_uart(1);
119
120 adm5120_add_device_flash(0);
121 adm5120_add_device_switch(6, NULL);
122 }
123
124 MIPS_MACHINE(MACH_ADM5120_GENERIC, "Generic ADM5120 board",
125 adm5120_generic_board_setup);
This page took 0.05087 seconds and 3 git commands to generate.