Minor fixes, do not count interrupts without interrupt source as spurious (#1755)
[openwrt.git] / target / linux / adm5120-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  *      Copyright (C) 2007 OpenWrt.org
7  */
8
9 #include <linux/autoconf.h>
10 #include <linux/init.h>
11 #include <linux/device.h>
12 #include <linux/platform_device.h>
13
14 #include <asm/reboot.h>
15 #include <asm/io.h>
16 #include <asm/time.h>
17
18 #include <adm5120_info.h>
19
20 #define ADM5120_SOFTRESET       0x12000004
21 #define STATUS_IE               0x00000001
22 #define ALLINTS (IE_IRQ0 | IE_IRQ5 | STATUS_IE)
23
24 void  mips_time_init(void);
25
26 extern unsigned int mips_counter_frequency;
27
28 void adm5120_restart(char *command)
29 {
30         *(u32*)KSEG1ADDR(ADM5120_SOFTRESET)=1;
31 }
32
33
34 void adm5120_halt(void)
35 {
36         printk(KERN_NOTICE "\n** You can safely turn off the power\n");
37         while (1);
38 }
39
40
41 void adm5120_power_off(void)
42 {
43         adm5120_halt();
44 }
45
46 void __init adm5120_time_init(void)
47 {
48         mips_counter_frequency = adm5120_speed >> 1;
49 }
50
51 void __init plat_timer_setup(struct irqaction *irq)
52 {
53         /* to generate the first timer interrupt */
54         write_c0_compare(read_c0_count()+ mips_counter_frequency/HZ);
55         clear_c0_status(ST0_BEV);
56         set_c0_status(ALLINTS);
57 }
58
59 void __init plat_mem_setup(void)
60 {
61         printk(KERN_INFO "ADM5120 board setup\n");
62
63         board_time_init = adm5120_time_init;
64         //board_timer_setup = mips_timer_setup;
65
66         _machine_restart = adm5120_restart;
67         _machine_halt = adm5120_halt;
68         pm_power_off = adm5120_power_off;
69
70         set_io_port_base(KSEG1);
71 }
72
73 const char *get_system_type(void)
74 {
75         return adm5120_board_name();
76 }
77
78 #ifdef CONFIG_USB
79 static struct resource adm5120_hcd_resources[] = {
80         [0] = {
81                 .start  = 0x11200000,
82                 .end    = 0x11200084,
83                 .flags  = IORESOURCE_MEM,
84         },
85         [1] = {
86                 .start  = 0x3,
87                 .end    = 0x3,
88                 .flags  = IORESOURCE_IRQ,
89         },
90 };
91
92 static struct platform_device adm5120hcd_device = {
93         .name           = "adm5120-hcd",
94         .id             = -1,
95         .num_resources  = ARRAY_SIZE(adm5120_hcd_resources),
96         .resource       = adm5120_hcd_resources,
97 };
98
99 static struct platform_device *devices[] __initdata = {
100         &adm5120hcd_device,
101 };
102
103 static int __init adm5120_init(void)
104 {
105         return platform_add_devices(devices, ARRAY_SIZE(devices));
106 }
107
108 arch_initcall(adm5120_init);
109 #endif