diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2006-09-07 05:57:00 -0400 |
|---|---|---|
| committer | Wim Van Sebroeck <wim@iguana.be> | 2006-10-04 16:44:59 -0400 |
| commit | 0cd544763bacad14d0d15fb16d29999b450cb77f (patch) | |
| tree | 56de46e2e4c11f6af8aba86f057f6a4ff0cb4536 | |
| parent | fe851ebade80af9b58599c74d61718657b02cfd3 (diff) | |
[WATCHDOG] w83697hf/hg WDT driver - patch 9
This is patch 9 in the series of patches that converts
Marcus Junker's w83697hf watchdog driver to Samuel Tardieau's
w83697hf/hg watchdog driver.
This patch contains following changes:
- add w83697hf_get_reg() and w83697hf_set_reg()
functions.
Signed-off-by: Samuel Tardieu <sam@rfc1149.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
| -rw-r--r-- | drivers/char/watchdog/w83697hf_wdt.c | 42 |
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 | |||
| 90 | static unsigned char | ||
| 91 | w83697hf_get_reg(unsigned char reg) | ||
| 92 | { | ||
| 93 | outb_p(reg, W83697HF_EFIR); | ||
| 94 | return inb_p(W83697HF_EFDR); | ||
| 95 | } | ||
| 96 | |||
| 97 | static void | ||
| 98 | w83697hf_set_reg(unsigned char reg, unsigned char data) | ||
| 99 | { | ||
| 100 | outb_p(reg, W83697HF_EFIR); | ||
| 101 | outb_p(data, W83697HF_EFDR); | ||
| 102 | } | ||
| 103 | |||
| 85 | static void | 104 | static void |
| 86 | w83697hf_select_wd_register(void) | 105 | w83697hf_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 | ||
| 99 | static void | 115 | static 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 | ||
