0a117746242e6669e33cb0397a7a4e9335214e6a
[openwrt/svn-archive/archive.git] / target / linux / adm5120 / files-2.6.26 / arch / mips / adm5120 / common / setup.c
1 /*
2 * ADM5120 specific setup
3 *
4 * Copyright (C) 2007-2008 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
27 #include <asm/mach-adm5120/adm5120_info.h>
28 #include <asm/mach-adm5120/adm5120_defs.h>
29 #include <asm/mach-adm5120/adm5120_switch.h>
30 #include <asm/mach-adm5120/adm5120_board.h>
31
32 void (*adm5120_board_reset)(void);
33
34 static char *prom_names[ADM5120_PROM_LAST+1] __initdata = {
35 [ADM5120_PROM_GENERIC] = "Generic",
36 [ADM5120_PROM_CFE] = "CFE",
37 [ADM5120_PROM_UBOOT] = "U-Boot",
38 [ADM5120_PROM_MYLOADER] = "MyLoader",
39 [ADM5120_PROM_ROUTERBOOT] = "RouterBOOT",
40 [ADM5120_PROM_BOOTBASE] = "Bootbase"
41 };
42
43 static void __init adm5120_report(void)
44 {
45 printk(KERN_INFO "SoC : ADM%04X%s revision %d, running "
46 "at %ldMHz\n",
47 adm5120_product_code,
48 adm5120_package_bga() ? "" : "P",
49 adm5120_revision, (adm5120_speed / 1000000));
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 static void adm5120_restart(char *command)
56 {
57 /* TODO: stop switch before reset */
58
59 if (adm5120_board_reset)
60 adm5120_board_reset();
61
62 SW_WRITE_REG(SWITCH_REG_SOFT_RESET, 1);
63 }
64
65 static void adm5120_halt(void)
66 {
67 local_irq_disable();
68
69 while (1) {
70 if (cpu_wait)
71 cpu_wait();
72 }
73 }
74
75 void __init plat_time_init(void)
76 {
77 mips_hpt_frequency = adm5120_speed / 2;
78 }
79
80 void __init plat_mem_setup(void)
81 {
82 adm5120_soc_init();
83 adm5120_mem_init();
84 adm5120_report();
85
86 _machine_restart = adm5120_restart;
87 _machine_halt = adm5120_halt;
88 pm_power_off = adm5120_halt;
89
90 set_io_port_base(KSEG1);
91 }