[ifxmips] adss 2.6.33 kernel patches, not defult yet as linux-atm breaks on 2.6.33
[openwrt.git] / target / linux / ifxmips / files-2.6.33 / arch / mips / ifxmips / ar9 / setup.c
1 #include <linux/cpu.h>
2 #include <linux/init.h>
3 #include <linux/kernel.h>
4 #include <linux/pm.h>
5 #include <linux/io.h>
6 #include <linux/ioport.h>
7 #include <asm/reboot.h>
8 #include <asm/system.h>
9 #include <ifxmips.h>
10 #include <ifxmips_cgu.h>
11
12 #define SYSTEM_DANUBE                   "Danube"
13 #define SYSTEM_DANUBE_CHIPID1   0x00129083
14 #define SYSTEM_DANUBE_CHIPID2   0x0012B083
15
16 #define SYSTEM_TWINPASS                 "Twinpass"
17 #define SYSTEM_TWINPASS_CHIPID  0x0012D083
18
19 static unsigned int chiprev = 0;
20 unsigned char ifxmips_sys_type[IFXMIPS_SYS_TYPE_LEN];
21
22 unsigned int
23 ifxmips_get_cpu_ver(void)
24 {
25         return (ifxmips_r32(IFXMIPS_MPS_CHIPID) & 0xF0000000) >> 28;
26 }
27 EXPORT_SYMBOL(ifxmips_get_cpu_ver);
28
29 const char*
30 get_system_type(void)
31 {
32         return ifxmips_sys_type;
33 }
34
35 static void
36 ifxmips_machine_restart(char *command)
37 {
38         printk(KERN_NOTICE "System restart\n");
39         local_irq_disable();
40         ifxmips_w32(ifxmips_r32(IFXMIPS_RCU_RST) | IFXMIPS_RCU_RST_ALL,
41                 IFXMIPS_RCU_RST);
42         for(;;);
43 }
44
45 static void
46 ifxmips_machine_halt(void)
47 {
48         printk(KERN_NOTICE "System halted.\n");
49         local_irq_disable();
50         for(;;);
51 }
52
53 static void
54 ifxmips_machine_power_off(void)
55 {
56         printk(KERN_NOTICE "Please turn off the power now.\n");
57         local_irq_disable();
58         for(;;);
59 }
60
61 void __init
62 ifxmips_soc_setup(void)
63 {
64         char *name = SYSTEM_DANUBE;
65         ioport_resource.start = IOPORT_RESOURCE_START;
66         ioport_resource.end = IOPORT_RESOURCE_END;
67         iomem_resource.start = IOMEM_RESOURCE_START;
68         iomem_resource.end = IOMEM_RESOURCE_END;
69
70         _machine_restart = ifxmips_machine_restart;
71         _machine_halt = ifxmips_machine_halt;
72         pm_power_off = ifxmips_machine_power_off;
73
74         chiprev = (ifxmips_r32(IFXMIPS_MPS_CHIPID) & 0x0FFFFFFF);
75
76         switch (chiprev)
77         {
78         case SYSTEM_DANUBE_CHIPID1:
79         case SYSTEM_DANUBE_CHIPID2:
80                 name = SYSTEM_DANUBE;
81                 break;
82
83         case SYSTEM_TWINPASS_CHIPID:
84                 name = SYSTEM_TWINPASS;
85                 break;
86
87         default:
88                 printk(KERN_ERR "This is not a danube chiprev : 0x%08X\n", chiprev);
89                 BUG();
90                 break;
91         }
92         snprintf(ifxmips_sys_type, IFXMIPS_SYS_TYPE_LEN - 1, "%s rev1.%d %dMhz",
93                 name, ifxmips_get_cpu_ver(),
94                 ifxmips_get_cpu_hz() / 1000000);
95         ifxmips_sys_type[IFXMIPS_SYS_TYPE_LEN - 1] = '\0';
96 }