This source file includes following definitions.
- pdc_chassis_setup
- pdc_chassis_checkold
- pdc_chassis_panic_event
- pdc_chassis_reboot_event
- parisc_pdc_chassis_init
- pdc_chassis_send_status
- pdc_chassis_warn_show
- pdc_chassis_create_procfs
1
2
3
4
5
6
7
8
9
10
11
12
13 #undef PDC_CHASSIS_DEBUG
14 #ifdef PDC_CHASSIS_DEBUG
15 #define DPRINTK(fmt, args...) printk(fmt, ## args)
16 #else
17 #define DPRINTK(fmt, args...)
18 #endif
19
20 #include <linux/init.h>
21 #include <linux/module.h>
22 #include <linux/kernel.h>
23 #include <linux/reboot.h>
24 #include <linux/notifier.h>
25 #include <linux/cache.h>
26 #include <linux/proc_fs.h>
27 #include <linux/seq_file.h>
28
29 #include <asm/pdc_chassis.h>
30 #include <asm/processor.h>
31 #include <asm/pdc.h>
32 #include <asm/pdcpat.h>
33
34 #define PDC_CHASSIS_VER "0.05"
35
36 #ifdef CONFIG_PDC_CHASSIS
37 static unsigned int pdc_chassis_enabled __read_mostly = 1;
38
39
40
41
42
43
44
45
46 static int __init pdc_chassis_setup(char *str)
47 {
48
49 get_option(&str, &pdc_chassis_enabled);
50 return 1;
51 }
52 __setup("pdcchassis=", pdc_chassis_setup);
53
54
55
56
57
58
59
60
61
62 #if 0
63 static void __init pdc_chassis_checkold(void)
64 {
65 switch(CPU_HVERSION) {
66 case 0x480:
67 case 0x481:
68 case 0x482:
69 case 0x483:
70 case 0x516:
71 break;
72
73 default:
74 break;
75 }
76 DPRINTK(KERN_DEBUG "%s: pdc_chassis_checkold(); pdc_chassis_old = %d\n", __FILE__, pdc_chassis_old);
77 }
78 #endif
79
80
81
82
83
84
85
86 static int pdc_chassis_panic_event(struct notifier_block *this,
87 unsigned long event, void *ptr)
88 {
89 pdc_chassis_send_status(PDC_CHASSIS_DIRECT_PANIC);
90 return NOTIFY_DONE;
91 }
92
93
94 static struct notifier_block pdc_chassis_panic_block = {
95 .notifier_call = pdc_chassis_panic_event,
96 .priority = INT_MAX,
97 };
98
99
100
101
102
103
104
105
106 static int pdc_chassis_reboot_event(struct notifier_block *this,
107 unsigned long event, void *ptr)
108 {
109 pdc_chassis_send_status(PDC_CHASSIS_DIRECT_SHUTDOWN);
110 return NOTIFY_DONE;
111 }
112
113
114 static struct notifier_block pdc_chassis_reboot_block = {
115 .notifier_call = pdc_chassis_reboot_event,
116 .priority = INT_MAX,
117 };
118 #endif
119
120
121
122
123
124
125 void __init parisc_pdc_chassis_init(void)
126 {
127 #ifdef CONFIG_PDC_CHASSIS
128 if (likely(pdc_chassis_enabled)) {
129 DPRINTK(KERN_DEBUG "%s: parisc_pdc_chassis_init()\n", __FILE__);
130
131
132 printk(KERN_INFO "Enabling %s chassis codes support v%s\n",
133 is_pdc_pat() ? "PDC_PAT" : "regular",
134 PDC_CHASSIS_VER);
135
136
137 atomic_notifier_chain_register(&panic_notifier_list,
138 &pdc_chassis_panic_block);
139
140
141 register_reboot_notifier(&pdc_chassis_reboot_block);
142 }
143 #endif
144 }
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161 int pdc_chassis_send_status(int message)
162 {
163
164 int retval = 0;
165 #ifdef CONFIG_PDC_CHASSIS
166 if (likely(pdc_chassis_enabled)) {
167
168 DPRINTK(KERN_DEBUG "%s: pdc_chassis_send_status(%d)\n", __FILE__, message);
169
170 #ifdef CONFIG_64BIT
171 if (is_pdc_pat()) {
172 switch(message) {
173 case PDC_CHASSIS_DIRECT_BSTART:
174 retval = pdc_pat_chassis_send_log(PDC_CHASSIS_PMSG_BSTART, PDC_CHASSIS_LSTATE_RUN_NORMAL);
175 break;
176
177 case PDC_CHASSIS_DIRECT_BCOMPLETE:
178 retval = pdc_pat_chassis_send_log(PDC_CHASSIS_PMSG_BCOMPLETE, PDC_CHASSIS_LSTATE_RUN_NORMAL);
179 break;
180
181 case PDC_CHASSIS_DIRECT_SHUTDOWN:
182 retval = pdc_pat_chassis_send_log(PDC_CHASSIS_PMSG_SHUTDOWN, PDC_CHASSIS_LSTATE_NONOS);
183 break;
184
185 case PDC_CHASSIS_DIRECT_PANIC:
186 retval = pdc_pat_chassis_send_log(PDC_CHASSIS_PMSG_PANIC, PDC_CHASSIS_LSTATE_RUN_CRASHREC);
187 break;
188
189 case PDC_CHASSIS_DIRECT_LPMC:
190 retval = pdc_pat_chassis_send_log(PDC_CHASSIS_PMSG_LPMC, PDC_CHASSIS_LSTATE_RUN_SYSINT);
191 break;
192
193 case PDC_CHASSIS_DIRECT_HPMC:
194 retval = pdc_pat_chassis_send_log(PDC_CHASSIS_PMSG_HPMC, PDC_CHASSIS_LSTATE_RUN_NCRIT);
195 break;
196
197 default:
198 retval = -1;
199 }
200 } else retval = -1;
201 #else
202 if (1) {
203 switch (message) {
204 case PDC_CHASSIS_DIRECT_BSTART:
205 retval = pdc_chassis_disp(PDC_CHASSIS_DISP_DATA(OSTAT_INIT));
206 break;
207
208 case PDC_CHASSIS_DIRECT_BCOMPLETE:
209 retval = pdc_chassis_disp(PDC_CHASSIS_DISP_DATA(OSTAT_RUN));
210 break;
211
212 case PDC_CHASSIS_DIRECT_SHUTDOWN:
213 retval = pdc_chassis_disp(PDC_CHASSIS_DISP_DATA(OSTAT_SHUT));
214 break;
215
216 case PDC_CHASSIS_DIRECT_HPMC:
217 case PDC_CHASSIS_DIRECT_PANIC:
218 retval = pdc_chassis_disp(PDC_CHASSIS_DISP_DATA(OSTAT_FLT));
219 break;
220
221 case PDC_CHASSIS_DIRECT_LPMC:
222 retval = pdc_chassis_disp(PDC_CHASSIS_DISP_DATA(OSTAT_WARN));
223 break;
224
225 default:
226 retval = -1;
227 }
228 } else retval = -1;
229 #endif
230 }
231 #endif
232 return retval;
233 }
234
235 #ifdef CONFIG_PDC_CHASSIS_WARN
236 #ifdef CONFIG_PROC_FS
237 static int pdc_chassis_warn_show(struct seq_file *m, void *v)
238 {
239 unsigned long warn;
240 u32 warnreg;
241
242 if (pdc_chassis_warn(&warn) != PDC_OK)
243 return -EIO;
244
245 warnreg = (warn & 0xFFFFFFFF);
246
247 if ((warnreg >> 24) & 0xFF)
248 seq_printf(m, "Chassis component failure! (eg fan or PSU): 0x%.2x\n",
249 (warnreg >> 24) & 0xFF);
250
251 seq_printf(m, "Battery: %s\n", (warnreg & 0x04) ? "Low!" : "OK");
252 seq_printf(m, "Temp low: %s\n", (warnreg & 0x02) ? "Exceeded!" : "OK");
253 seq_printf(m, "Temp mid: %s\n", (warnreg & 0x01) ? "Exceeded!" : "OK");
254 return 0;
255 }
256
257 static int __init pdc_chassis_create_procfs(void)
258 {
259 unsigned long test;
260 int ret;
261
262 ret = pdc_chassis_warn(&test);
263 if ((ret == PDC_BAD_PROC) || (ret == PDC_BAD_OPTION)) {
264
265 printk(KERN_INFO "Chassis warnings not supported.\n");
266 return 0;
267 }
268
269 printk(KERN_INFO "Enabling PDC chassis warnings support v%s\n",
270 PDC_CHASSIS_VER);
271 proc_create_single("chassis", 0400, NULL, pdc_chassis_warn_show);
272 return 0;
273 }
274
275 __initcall(pdc_chassis_create_procfs);
276
277 #endif
278 #endif