aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorWim Van Sebroeck <wim@iguana.be>2006-01-09 16:03:41 -0500
committerWim Van Sebroeck <wim@iguana.be>2006-02-12 08:46:43 -0500
commitaf3b38d99d7d52340cf59a06ff90d90e0fa25b6d (patch)
tree3a8e4deb0f0c27ca8d60b37b0a8cca2e947fb159 /drivers
parent85875211acc94ecb76fe04fbebc6aca12b6da60d (diff)
[WATCHDOG] pcwd.c show card info patch
Put all code for showing the card's boot info in one sub-routine. Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/watchdog/pcwd.c157
1 files changed, 79 insertions, 78 deletions
diff --git a/drivers/char/watchdog/pcwd.c b/drivers/char/watchdog/pcwd.c
index 0549b2e89966..f8f80d52d4de 100644
--- a/drivers/char/watchdog/pcwd.c
+++ b/drivers/char/watchdog/pcwd.c
@@ -229,6 +229,83 @@ static inline void pcwd_check_temperature_support(void)
229 pcwd_private.supports_temp = 1; 229 pcwd_private.supports_temp = 1;
230} 230}
231 231
232static inline char *get_firmware(void)
233{
234 int one, ten, hund, minor;
235 char *ret;
236
237 ret = kmalloc(6, GFP_KERNEL);
238 if(ret == NULL)
239 return NULL;
240
241 if (set_command_mode()) {
242 one = send_isa_command(CMD_ISA_VERSION_INTEGER);
243 ten = send_isa_command(CMD_ISA_VERSION_TENTH);
244 hund = send_isa_command(CMD_ISA_VERSION_HUNDRETH);
245 minor = send_isa_command(CMD_ISA_VERSION_MINOR);
246 sprintf(ret, "%c.%c%c%c", one, ten, hund, minor);
247 }
248 else
249 sprintf(ret, "ERROR");
250
251 unset_command_mode();
252 return(ret);
253}
254
255static inline int pcwd_get_option_switches(void)
256{
257 int option_switches=0;
258
259 if (set_command_mode()) {
260 /* Get switch settings */
261 option_switches = send_isa_command(CMD_ISA_SWITCH_SETTINGS);
262 }
263
264 unset_command_mode();
265 return(option_switches);
266}
267
268static void pcwd_show_card_info(void)
269{
270 char *firmware;
271 int option_switches;
272
273 /* Get some extra info from the hardware (in command/debug/diag mode) */
274 if (pcwd_private.revision == PCWD_REVISION_A)
275 printk(KERN_INFO PFX "ISA-PC Watchdog (REV.A) detected at port 0x%04x\n", pcwd_private.io_addr);
276 else if (pcwd_private.revision == PCWD_REVISION_C) {
277 firmware = get_firmware();
278 printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port 0x%04x (Firmware version: %s)\n",
279 pcwd_private.io_addr, firmware);
280 kfree(firmware);
281 option_switches = pcwd_get_option_switches();
282 printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n",
283 option_switches,
284 ((option_switches & 0x10) ? "ON" : "OFF"),
285 ((option_switches & 0x08) ? "ON" : "OFF"));
286
287 /* Reprogram internal heartbeat to 2 seconds */
288 if (set_command_mode()) {
289 send_isa_command(CMD_ISA_DELAY_TIME_2SECS);
290 unset_command_mode();
291 }
292 }
293
294 if (pcwd_private.supports_temp)
295 printk(KERN_INFO PFX "Temperature Option Detected\n");
296
297 if (pcwd_private.boot_status & WDIOF_CARDRESET)
298 printk(KERN_INFO PFX "Previous reboot was caused by the card\n");
299
300 if (pcwd_private.boot_status & WDIOF_OVERHEAT) {
301 printk(KERN_EMERG PFX "Card senses a CPU Overheat. Panicking!\n");
302 printk(KERN_EMERG PFX "CPU Overheat\n");
303 }
304
305 if (pcwd_private.boot_status == 0)
306 printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n");
307}
308
232static void pcwd_timer_ping(unsigned long data) 309static void pcwd_timer_ping(unsigned long data)
233{ 310{
234 int wdrst_stat; 311 int wdrst_stat;
@@ -644,47 +721,9 @@ static inline int get_revision(void)
644 return r; 721 return r;
645} 722}
646 723
647static inline char *get_firmware(void)
648{
649 int one, ten, hund, minor;
650 char *ret;
651
652 ret = kmalloc(6, GFP_KERNEL);
653 if(ret == NULL)
654 return NULL;
655
656 if (set_command_mode()) {
657 one = send_isa_command(CMD_ISA_VERSION_INTEGER);
658 ten = send_isa_command(CMD_ISA_VERSION_TENTH);
659 hund = send_isa_command(CMD_ISA_VERSION_HUNDRETH);
660 minor = send_isa_command(CMD_ISA_VERSION_MINOR);
661 sprintf(ret, "%c.%c%c%c", one, ten, hund, minor);
662 }
663 else
664 sprintf(ret, "ERROR");
665
666 unset_command_mode();
667 return(ret);
668}
669
670static inline int get_option_switches(void)
671{
672 int rv=0;
673
674 if (set_command_mode()) {
675 /* Get switch settings */
676 rv = send_isa_command(CMD_ISA_SWITCH_SETTINGS);
677 }
678
679 unset_command_mode();
680 return(rv);
681}
682
683static int __devinit pcwatchdog_init(int base_addr) 724static int __devinit pcwatchdog_init(int base_addr)
684{ 725{
685 int ret; 726 int ret;
686 char *firmware;
687 int option_switches;
688 727
689 cards_found++; 728 cards_found++;
690 if (cards_found == 1) 729 if (cards_found == 1)
@@ -732,46 +771,8 @@ static int __devinit pcwatchdog_init(int base_addr)
732 /* Check whether or not the card supports the temperature device */ 771 /* Check whether or not the card supports the temperature device */
733 pcwd_check_temperature_support(); 772 pcwd_check_temperature_support();
734 773
735 /* Get some extra info from the hardware (in command/debug/diag mode) */ 774 /* Show info about the card itself */
736 if (pcwd_private.revision == PCWD_REVISION_A) 775 pcwd_show_card_info();
737 printk(KERN_INFO PFX "ISA-PC Watchdog (REV.A) detected at port 0x%04x\n", pcwd_private.io_addr);
738 else if (pcwd_private.revision == PCWD_REVISION_C) {
739 firmware = get_firmware();
740 printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port 0x%04x (Firmware version: %s)\n",
741 pcwd_private.io_addr, firmware);
742 kfree(firmware);
743 option_switches = get_option_switches();
744 printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n",
745 option_switches,
746 ((option_switches & 0x10) ? "ON" : "OFF"),
747 ((option_switches & 0x08) ? "ON" : "OFF"));
748
749 /* Reprogram internal heartbeat to 2 seconds */
750 if (set_command_mode()) {
751 send_isa_command(CMD_ISA_DELAY_TIME_2SECS);
752 unset_command_mode();
753 }
754 } else {
755 /* Should NEVER happen, unless get_revision() fails. */
756 printk(KERN_INFO PFX "Unable to get revision\n");
757 release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4);
758 pcwd_private.io_addr = 0x0000;
759 return -1;
760 }
761
762 if (pcwd_private.supports_temp)
763 printk(KERN_INFO PFX "Temperature Option Detected\n");
764
765 if (pcwd_private.boot_status & WDIOF_CARDRESET)
766 printk(KERN_INFO PFX "Previous reboot was caused by the card\n");
767
768 if (pcwd_private.boot_status & WDIOF_OVERHEAT) {
769 printk(KERN_EMERG PFX "Card senses a CPU Overheat. Panicking!\n");
770 printk(KERN_EMERG PFX "CPU Overheat\n");
771 }
772
773 if (pcwd_private.boot_status == 0)
774 printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n");
775 776
776 /* Check that the heartbeat value is within it's range ; if not reset to the default */ 777 /* Check that the heartbeat value is within it's range ; if not reset to the default */
777 if (pcwd_set_heartbeat(heartbeat)) { 778 if (pcwd_set_heartbeat(heartbeat)) {