[ifxmips] add ar9 target
[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_AR9 "AR9"
13 #define SYSTEM_AR9_CHIPID1 0x00129083
14 #define SYSTEM_AR9_CHIPID2 0x0012B083
15
16 static unsigned int chiprev = 0;
17 unsigned char ifxmips_sys_type[IFXMIPS_SYS_TYPE_LEN];
18
19 unsigned int
20 ifxmips_get_cpu_ver(void)
21 {
22 return (ifxmips_r32(IFXMIPS_MPS_CHIPID) & 0xF0000000) >> 28;
23 }
24 EXPORT_SYMBOL(ifxmips_get_cpu_ver);
25
26 const char*
27 get_system_type(void)
28 {
29 return ifxmips_sys_type;
30 }
31
32 static void
33 ifxmips_machine_restart(char *command)
34 {
35 printk(KERN_NOTICE "System restart\n");
36 local_irq_disable();
37 ifxmips_w32(ifxmips_r32(IFXMIPS_RCU_RST) | IFXMIPS_RCU_RST_ALL,
38 IFXMIPS_RCU_RST);
39 for(;;);
40 }
41
42 static void
43 ifxmips_machine_halt(void)
44 {
45 printk(KERN_NOTICE "System halted.\n");
46 local_irq_disable();
47 for(;;);
48 }
49
50 static void
51 ifxmips_machine_power_off(void)
52 {
53 printk(KERN_NOTICE "Please turn off the power now.\n");
54 local_irq_disable();
55 for(;;);
56 }
57
58 static inline u16 get_chip_partnum(void)
59 {
60 return (ifxmips_r32(IFXMIPS_MPS_CHIPID) & 0x0FFFF000) >> 12;
61 }
62
63 void __init
64 ifxmips_soc_setup(void)
65 {
66 char *name = SYSTEM_AR9;
67 ioport_resource.start = IOPORT_RESOURCE_START;
68 ioport_resource.end = IOPORT_RESOURCE_END;
69 iomem_resource.start = IOMEM_RESOURCE_START;
70 iomem_resource.end = IOMEM_RESOURCE_END;
71
72 _machine_restart = ifxmips_machine_restart;
73 _machine_halt = ifxmips_machine_halt;
74 pm_power_off = ifxmips_machine_power_off;
75
76 switch (get_chip_partnum())
77 {
78 case 0x16C,
79 name = = "ARX188",
80 break;
81 case 0x16D,
82 name = = "ARX168",
83 break;
84 case 0x16F,
85 name = = "ARX182",
86 break;
87 case 0x170,
88 name = = "GRX188",
89 break;
90 case 0x171,
91 name = = "GRX168",
92 break;
93 default:
94 printk(KERN_ERR "This is not a AR9 chiprev : 0x%08X\n", get_chip_partnum());
95 BUG();
96 break;
97 }
98
99 snprintf(ifxmips_sys_type, IFXMIPS_SYS_TYPE_LEN - 1, "%s rev1.%d %dMhz",
100 name, ifxmips_get_cpu_ver(),
101 ifxmips_get_cpu_hz() / 1000000);
102 ifxmips_sys_type[IFXMIPS_SYS_TYPE_LEN - 1] = '\0';
103 }
This page took 0.050308 seconds and 5 git commands to generate.