aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/watchdog/w83697hf_wdt.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/drivers/char/watchdog/w83697hf_wdt.c b/drivers/char/watchdog/w83697hf_wdt.c
index 6a357a818c8a..f62f17238712 100644
--- a/drivers/char/watchdog/w83697hf_wdt.c
+++ b/drivers/char/watchdog/w83697hf_wdt.c
@@ -82,18 +82,34 @@ w83697hf_lock(void)
82 outb_p(0xAA, W83697HF_EFER); /* Leave extended function mode */ 82 outb_p(0xAA, W83697HF_EFER); /* Leave extended function mode */
83} 83}
84 84
85/*
86 * The two functions w83697hf_get_reg() and w83697hf_set_reg()
87 * must be called with the device unlocked.
88 */
89
90static unsigned char
91w83697hf_get_reg(unsigned char reg)
92{
93 outb_p(reg, W83697HF_EFIR);
94 return inb_p(W83697HF_EFDR);
95}
96
97static void
98w83697hf_set_reg(unsigned char reg, unsigned char data)
99{
100 outb_p(reg, W83697HF_EFIR);
101 outb_p(data, W83697HF_EFDR);
102}
103
85static void 104static void
86w83697hf_select_wd_register(void) 105w83697hf_select_wd_register(void)
87{ 106{
88 w83697hf_unlock(); 107 w83697hf_unlock();
89 108
90 outb_p(0x29, W83697HF_EFER); /* select CR29 */ 109 w83697hf_set_reg(0x29, 0x20); /* Set pin 119 to WDTO# mode (= CR29, WDT0) */
91 outb_p(0x20, W83697HF_EFDR); /* select WDTO */
92 110
93 outb_p(0x07, W83697HF_EFER); /* point to logical device number reg */ 111 w83697hf_set_reg(0x07, 0x08); /* Switch to logic device 8 (GPIO2) */
94 outb_p(0x08, W83697HF_EFDR); /* select logical device 8 (GPIO2) */ 112 w83697hf_set_reg(0x30, 0x01); /* Enable timer/activate GPIO2 via bit 0 */
95 outb_p(0x30, W83697HF_EFER); /* select CR30 */
96 outb_p(0x01, W83697HF_EFDR); /* set bit 0 to activate GPIO2 */
97} 113}
98 114
99static void 115static void
@@ -109,17 +125,14 @@ w83697hf_init(void)
109 125
110 w83697hf_select_wd_register(); 126 w83697hf_select_wd_register();
111 127
112 outb_p(0xF3, W83697HF_EFER); /* Select CRF3 */ 128 t = w83697hf_get_reg(0xF3); /* Read CRF3 */
113
114 t=inb_p(W83697HF_EFDR); /* read CRF3 */
115 if (t != 0) { 129 if (t != 0) {
116 printk (KERN_INFO PFX "Watchdog already running. Resetting timeout to %d sec\n", timeout); 130 printk (KERN_INFO PFX "Watchdog already running. Resetting timeout to %d sec\n", timeout);
117 outb_p(timeout, W83697HF_EFDR); /* Write back to CRF3 */ 131 w83697hf_set_reg(0xF3, timeout); /* Write new timeout */
118 } 132 }
119 outb_p(0xF4, W83697HF_EFER); /* Select CRF4 */ 133 t = w83697hf_get_reg(0xF4); /* Read CRF4 */
120 t=inb_p(W83697HF_EFDR); /* read CRF4 */
121 t&=~0x0C; /* set second mode & disable keyboard turning off watchdog */ 134 t&=~0x0C; /* set second mode & disable keyboard turning off watchdog */
122 outb_p(t, W83697HF_EFDR); /* Write back to CRF4 */ 135 w83697hf_set_reg(0xF4, t); /* Write back to CRF4 */
123 136
124 w83697hf_unselect_wd_register(); 137 w83697hf_unselect_wd_register();
125} 138}
@@ -131,8 +144,7 @@ wdt_ctrl(int timeout)
131 144
132 w83697hf_select_wd_register(); 145 w83697hf_select_wd_register();
133 146
134 outb_p(0xF4, W83697HF_EFER); /* Select CRF4 */ 147 w83697hf_set_reg(0xF4, timeout); /* Write Timeout counter to CRF4 */
135 outb_p(timeout, W83697HF_EFDR); /* Write Timeout counter to CRF4 */
136 148
137 w83697hf_unselect_wd_register(); 149 w83697hf_unselect_wd_register();
138 150