Add preliminary RouterBoard RB1xx support
[openwrt.git] / target / linux / rb1xx-2.6 / files / arch / mips / adm5120 / setup.c
1 /*
2  *      Copyright (C) ADMtek Incorporated.
3  *              Creator : daniell@admtek.com.tw
4  *      Copyright 1999, 2000 MIPS Technologies, Inc.
5  *      Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2005
6  */
7
8 #include <linux/autoconf.h>
9 #include <linux/init.h>
10 #include <linux/device.h>
11 #include <linux/platform_device.h>
12
13 #include <asm/reboot.h>
14 #include <asm/io.h>
15 #include <asm/time.h>
16
17 #include <adm5120_info.h>
18
19 #define ADM5120_SOFTRESET       0x12000004
20 #define STATUS_IE               0x00000001
21 #define ALLINTS (IE_IRQ0 | IE_IRQ5 | STATUS_IE)
22
23 void  mips_time_init(void);
24
25 extern unsigned int mips_counter_frequency;
26
27 void adm5120_restart(char *command)
28 {
29         *(u32*)KSEG1ADDR(ADM5120_SOFTRESET)=1;
30 }
31
32
33 void adm5120_halt(void)
34 {
35         printk(KERN_NOTICE "\n** You can safely turn off the power\n");
36         while (1);
37 }
38
39
40 void adm5120_power_off(void)
41 {
42         adm5120_halt();
43 }
44
45 void __init adm5120_time_init(void)
46 {
47         mips_counter_frequency = adm5120_info.cpu_speed >> 1;
48 }
49
50 void __init plat_timer_setup(struct irqaction *irq)
51 {
52         /* to generate the first timer interrupt */
53         write_c0_compare(read_c0_count()+ mips_counter_frequency/HZ);
54         clear_c0_status(ST0_BEV);
55         set_c0_status(ALLINTS);
56 }
57
58 void __init plat_mem_setup(void)
59 {
60         printk(KERN_INFO "ADM5120 board setup\n");
61
62         board_time_init = adm5120_time_init;
63         //board_timer_setup = mips_timer_setup;
64
65         _machine_restart = adm5120_restart;
66         _machine_halt = adm5120_halt;
67         pm_power_off = adm5120_power_off;
68
69         set_io_port_base(KSEG1);
70 }
71
72 const char *get_system_type(void)
73 {
74         return "ADM5120 Board";
75 }
76
77 static struct resource adm5120_hcd_resources[] = {
78         [0] = {
79                 .start  = 0x11200000,
80                 .end    = 0x11200084,
81                 .flags  = IORESOURCE_MEM,
82         },
83         [1] = {
84                 .start  = 0x3,
85                 .end    = 0x3,
86                 .flags  = IORESOURCE_IRQ,
87         },
88 };
89
90 static struct platform_device adm5120hcd_device = {
91         .name           = "adm5120-hcd",
92         .id             = -1,
93         .num_resources  = ARRAY_SIZE(adm5120_hcd_resources),
94         .resource       = adm5120_hcd_resources,
95 };
96
97 static struct platform_device *devices[] __initdata = {
98         &adm5120hcd_device,
99 };
100
101 static int __init adm5120_init(void)
102 {
103         return platform_add_devices(devices, ARRAY_SIZE(devices));
104 }
105
106 subsys_initcall(adm5120_init);