Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Stefan Reinauer | 094198c | 2009-07-21 21:24:22 +0000 | [diff] [blame] | 4 | * Copyright (C) 2009 coresystems GmbH |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 5 | * Copyright (C) 2008 Advanced Micro Devices, Inc. |
Stefan Reinauer | 094198c | 2009-07-21 21:24:22 +0000 | [diff] [blame] | 6 | * Copyright (C) 2003 Ollie Lo <ollielo@hotmail.com> |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; version 2 of the License. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | |
Eric Biederman | 5cd8173 | 2004-03-11 15:01:31 +0000 | [diff] [blame] | 23 | #include <console/console.h> |
| 24 | #include <pc80/keyboard.h> |
| 25 | #include <device/device.h> |
Ronald G. Minnich | ef5f218 | 2003-09-26 15:24:54 +0000 | [diff] [blame] | 26 | #include <arch/io.h> |
Stefan Reinauer | 094198c | 2009-07-21 21:24:22 +0000 | [diff] [blame] | 27 | #include <delay.h> |
| 28 | |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 29 | #define KBD_DATA 0x60 |
| 30 | #define KBD_COMMAND 0x64 |
| 31 | #define KBD_STATUS 0x64 |
| 32 | #define KBD_IBF (1 << 1) // 1: input buffer full (data ready for ec) |
| 33 | #define KBD_OBF (1 << 0) // 1: output buffer full (data ready for host) |
| 34 | |
| 35 | // Keyboard Controller Commands |
| 36 | #define KBC_CMD_READ_COMMAND 0x20 // Read command byte |
| 37 | #define KBC_CMD_WRITE_COMMAND 0x60 // Write command byte |
| 38 | #define KBC_CMD_SELF_TEST 0xAA // Controller self-test |
Mathias Krause | 1c80cf0 | 2011-12-14 08:40:48 +0100 | [diff] [blame^] | 39 | #define KBC_CMD_KBD_TEST 0xAB // Keyboard Interface test |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 40 | |
| 41 | /* The Keyboard controller command byte |
| 42 | * BIT | Description |
| 43 | * ----+------------------------------------------------------- |
| 44 | * 7 | reserved, must be zero |
| 45 | * 6 | XT Translation, (1 = on, 0 = off) |
| 46 | * 5 | Disable Mouse Port (1 = disable, 0 = enable) |
| 47 | * 4 | Disable Keyboard Port (1 = disable, 0 = enable) |
| 48 | * 3 | reserved, must be zero |
| 49 | * 2 | System Flag (1 = self-test passed. DO NOT SET TO ZERO) |
| 50 | * 1 | Mouse Port Interrupts (1 = enable, 0 = disable) |
| 51 | * 0 | Keyboard Port Interrupts (1 = enable, 0 = disable) |
| 52 | */ |
| 53 | |
| 54 | // Keyboard Controller Replies |
| 55 | #define KBC_REPLY_SELFTEST_OK 0x55 // controller self-test succeeded |
| 56 | |
| 57 | // |
| 58 | // Keyboard Replies |
| 59 | // |
| 60 | #define KBD_REPLY_POR 0xAA // Power on reset |
| 61 | #define KBD_REPLY_ACK 0xFA // Command ACK |
| 62 | #define KBD_REPLY_RESEND 0xFE // Command NACK, send command again |
| 63 | |
Stefan Reinauer | d1149d7 | 2010-03-24 21:24:17 +0000 | [diff] [blame] | 64 | /* Wait 400ms for keyboard controller answers */ |
| 65 | #define KBC_TIMEOUT_IN_MS 400 |
Ronald G. Minnich | 430111b | 2003-09-26 16:12:23 +0000 | [diff] [blame] | 66 | |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 67 | static int kbc_input_buffer_empty(void) |
Eric Biederman | 029517c | 2004-11-11 11:56:00 +0000 | [diff] [blame] | 68 | { |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 69 | u32 timeout; |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 70 | for(timeout = KBC_TIMEOUT_IN_MS; timeout && (inb(KBD_STATUS) & KBD_IBF); timeout--) { |
Stefan Reinauer | 094198c | 2009-07-21 21:24:22 +0000 | [diff] [blame] | 71 | mdelay(1); |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | if (!timeout) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 75 | printk(BIOS_WARNING, "Unexpected Keyboard controller input buffer full\n"); |
Eric Biederman | 029517c | 2004-11-11 11:56:00 +0000 | [diff] [blame] | 76 | } |
| 77 | return !!timeout; |
| 78 | } |
| 79 | |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 80 | |
| 81 | static int kbc_output_buffer_full(void) |
Eric Biederman | 029517c | 2004-11-11 11:56:00 +0000 | [diff] [blame] | 82 | { |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 83 | u32 timeout; |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 84 | for(timeout = KBC_TIMEOUT_IN_MS; timeout && ((inb(KBD_STATUS) & KBD_OBF) == 0); timeout--) { |
Stefan Reinauer | 094198c | 2009-07-21 21:24:22 +0000 | [diff] [blame] | 85 | mdelay(1); |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | if (!timeout) { |
Stefan Reinauer | d1149d7 | 2010-03-24 21:24:17 +0000 | [diff] [blame] | 89 | printk(BIOS_INFO, "Keyboard controller output buffer result timeout\n"); |
Eric Biederman | 029517c | 2004-11-11 11:56:00 +0000 | [diff] [blame] | 90 | } |
| 91 | return !!timeout; |
| 92 | } |
| 93 | |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 94 | |
| 95 | static int kbc_cleanup_buffers(void) |
| 96 | { |
| 97 | u32 timeout; |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 98 | for(timeout = KBC_TIMEOUT_IN_MS; timeout && (inb(KBD_STATUS) & (KBD_OBF | KBD_IBF)); timeout--) { |
Stefan Reinauer | 094198c | 2009-07-21 21:24:22 +0000 | [diff] [blame] | 99 | mdelay(1); |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 100 | inb(KBD_DATA); |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | if (!timeout) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 104 | printk(BIOS_ERR, "Couldn't cleanup the keyboard controller buffers\n"); |
| 105 | printk(BIOS_ERR, "Status (0x%x): 0x%x, Buffer (0x%x): 0x%x\n", |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 106 | KBD_STATUS, inb(KBD_STATUS), KBD_DATA, inb(KBD_DATA)); |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 107 | } |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 108 | |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 109 | return !!timeout; |
| 110 | } |
| 111 | |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 112 | static int kbc_self_test(void) |
| 113 | { |
| 114 | u8 self_test; |
| 115 | |
| 116 | /* Clean up any junk that might have been in the KBC. |
| 117 | * Both input and output buffers must be empty. |
| 118 | */ |
| 119 | if (!kbc_cleanup_buffers()) |
| 120 | return 0; |
| 121 | |
| 122 | /* reset/self test 8042 - send cmd 0xAA */ |
| 123 | outb(KBC_CMD_SELF_TEST, KBD_COMMAND); |
| 124 | |
| 125 | if (!kbc_output_buffer_full()) { |
| 126 | /* There probably is no keyboard controller. */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 127 | printk(BIOS_ERR, "Could not reset keyboard controller.\n"); |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 128 | return 0; |
| 129 | } |
| 130 | |
| 131 | /* read self-test result, 0x55 is returned in the output buffer */ |
| 132 | self_test = inb(KBD_DATA); |
| 133 | |
| 134 | if (self_test != 0x55) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 135 | printk(BIOS_ERR, "Keyboard Controller self-test failed: 0x%x\n", |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 136 | self_test); |
| 137 | return 0; |
| 138 | } |
| 139 | |
Mathias Krause | 1c80cf0 | 2011-12-14 08:40:48 +0100 | [diff] [blame^] | 140 | /* ensure the buffers are empty */ |
| 141 | kbc_cleanup_buffers(); |
| 142 | |
| 143 | /* keyboard interface test */ |
| 144 | outb(KBC_CMD_KBD_TEST, KBD_COMMAND); |
| 145 | |
| 146 | if (!kbc_output_buffer_full()) { |
| 147 | printk(BIOS_ERR, "Keyboard Interface test timed out.\n"); |
| 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | /* read test result, 0x00 should be returned in case of no failures */ |
| 152 | self_test = inb(KBD_DATA); |
| 153 | |
| 154 | if (self_test != 0x00) { |
| 155 | printk(BIOS_ERR, "Keyboard Interface test failed: 0x%x\n", |
| 156 | self_test); |
| 157 | return 0; |
| 158 | } |
| 159 | |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 160 | return 1; |
| 161 | } |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 162 | |
| 163 | static u8 send_keyboard(u8 command) |
| 164 | { |
| 165 | u8 regval = 0; |
| 166 | u8 resend = 10; |
| 167 | |
| 168 | do { |
| 169 | if (!kbc_input_buffer_empty()) return 0; |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 170 | outb(command, KBD_DATA); |
Mathias Krause | 1c80cf0 | 2011-12-14 08:40:48 +0100 | [diff] [blame^] | 171 | /* the reset command takes much longer then normal commands and |
| 172 | * even worse, some keyboards do send the ACK _after_ doing the |
| 173 | * reset */ |
| 174 | if (command == 0xFF) { |
| 175 | u8 retries; |
| 176 | for (retries = 9; retries && !kbc_output_buffer_full(); retries--) |
| 177 | ; |
| 178 | } |
Stefan Reinauer | 094198c | 2009-07-21 21:24:22 +0000 | [diff] [blame] | 179 | if (!kbc_output_buffer_full()) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 180 | printk(BIOS_ERR, "Could not send keyboard command %02x\n", |
Stefan Reinauer | 094198c | 2009-07-21 21:24:22 +0000 | [diff] [blame] | 181 | command); |
| 182 | return 0; |
| 183 | } |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 184 | regval = inb(KBD_DATA); |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 185 | --resend; |
Stefan Reinauer | 9c3e8b5 | 2010-02-28 19:12:37 +0000 | [diff] [blame] | 186 | } while (regval == KBD_REPLY_RESEND && resend > 0); |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 187 | |
| 188 | return regval; |
| 189 | } |
| 190 | |
Stefan Reinauer | 740b587 | 2010-02-23 20:31:37 +0000 | [diff] [blame] | 191 | void pc_keyboard_init(struct pc_keyboard *keyboard) |
Ronald G. Minnich | ef5f218 | 2003-09-26 15:24:54 +0000 | [diff] [blame] | 192 | { |
Mathias Krause | 1c80cf0 | 2011-12-14 08:40:48 +0100 | [diff] [blame^] | 193 | u8 retries; |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 194 | u8 regval; |
Kevin O'Connor | 9c35c84 | 2010-09-09 08:34:02 +0000 | [diff] [blame] | 195 | if (!CONFIG_DRIVERS_PS2_KEYBOARD) |
| 196 | return; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 197 | printk(BIOS_DEBUG, "Keyboard init...\n"); |
Ronald G. Minnich | ef5f218 | 2003-09-26 15:24:54 +0000 | [diff] [blame] | 198 | |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 199 | /* Run a keyboard controller self-test */ |
| 200 | if (!kbc_self_test()) |
Ronald G. Minnich | ef5f218 | 2003-09-26 15:24:54 +0000 | [diff] [blame] | 201 | return; |
Stefan Reinauer | 094198c | 2009-07-21 21:24:22 +0000 | [diff] [blame] | 202 | |
| 203 | /* Enable keyboard interface - No IRQ */ |
Marc Jones | e59f2e1 | 2009-09-29 19:12:23 +0000 | [diff] [blame] | 204 | if (!kbc_input_buffer_empty()) return; |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 205 | outb(0x60, KBD_COMMAND); |
Marc Jones | e59f2e1 | 2009-09-29 19:12:23 +0000 | [diff] [blame] | 206 | if (!kbc_input_buffer_empty()) return; |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 207 | outb(0x20, KBD_DATA); /* send cmd: enable keyboard */ |
Marc Jones | e59f2e1 | 2009-09-29 19:12:23 +0000 | [diff] [blame] | 208 | if (!kbc_input_buffer_empty()) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 209 | printk(BIOS_INFO, "Timeout while enabling keyboard\n"); |
Marc Jones | e59f2e1 | 2009-09-29 19:12:23 +0000 | [diff] [blame] | 210 | return; |
| 211 | } |
Ronald G. Minnich | ef5f218 | 2003-09-26 15:24:54 +0000 | [diff] [blame] | 212 | |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 213 | /* clean up any junk that might have been in the keyboard */ |
| 214 | if (!kbc_cleanup_buffers()) return; |
Ronald G. Minnich | ef5f218 | 2003-09-26 15:24:54 +0000 | [diff] [blame] | 215 | |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 216 | /* reset keyboard and self test (keyboard side) */ |
| 217 | regval = send_keyboard(0xFF); |
Stefan Reinauer | 9c3e8b5 | 2010-02-28 19:12:37 +0000 | [diff] [blame] | 218 | if (regval == KBD_REPLY_RESEND) { |
| 219 | /* keeps sending RESENDs, probably no keyboard. */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 220 | printk(BIOS_INFO, "No PS/2 keyboard detected.\n"); |
Stefan Reinauer | 9c3e8b5 | 2010-02-28 19:12:37 +0000 | [diff] [blame] | 221 | return; |
| 222 | } |
| 223 | |
| 224 | if (regval != KBD_REPLY_ACK) { |
Mathias Krause | 1c80cf0 | 2011-12-14 08:40:48 +0100 | [diff] [blame^] | 225 | printk(BIOS_ERR, "Keyboard reset failed ACK: 0x%x\n", regval); |
Ronald G. Minnich | ef5f218 | 2003-09-26 15:24:54 +0000 | [diff] [blame] | 226 | return; |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 227 | } |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 228 | |
Mathias Krause | 1c80cf0 | 2011-12-14 08:40:48 +0100 | [diff] [blame^] | 229 | /* the reset command takes some time, so wait a little longer */ |
| 230 | for (retries = 9; retries && !kbc_output_buffer_full(); retries--) |
| 231 | ; |
| 232 | |
Stefan Reinauer | 094198c | 2009-07-21 21:24:22 +0000 | [diff] [blame] | 233 | if (!kbc_output_buffer_full()) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 234 | printk(BIOS_ERR, "Timeout waiting for keyboard after reset.\n"); |
Stefan Reinauer | 094198c | 2009-07-21 21:24:22 +0000 | [diff] [blame] | 235 | return; |
| 236 | } |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 237 | |
| 238 | regval = inb(KBD_DATA); |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 239 | if (regval != 0xAA) { |
Mathias Krause | 1c80cf0 | 2011-12-14 08:40:48 +0100 | [diff] [blame^] | 240 | printk(BIOS_ERR, "Keyboard reset selftest failed: 0x%x\n", regval); |
Ronald G. Minnich | ef5f218 | 2003-09-26 15:24:54 +0000 | [diff] [blame] | 241 | return; |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | /* |
| 245 | * The following set scancode stuff is what normal BIOS do. It could be |
| 246 | * argued that coreboot shouldn't set the scan code..... |
| 247 | */ |
| 248 | |
| 249 | /* disable the keyboard */ |
| 250 | regval = send_keyboard(0xF5); |
Stefan Reinauer | 9c3e8b5 | 2010-02-28 19:12:37 +0000 | [diff] [blame] | 251 | if (regval != KBD_REPLY_ACK) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 252 | printk(BIOS_ERR, "Keyboard disable failed ACK: 0x%x\n", regval); |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 253 | return; |
| 254 | } |
| 255 | |
| 256 | /* Set scancode command */ |
| 257 | regval = send_keyboard(0xF0); |
Stefan Reinauer | 9c3e8b5 | 2010-02-28 19:12:37 +0000 | [diff] [blame] | 258 | if (regval != KBD_REPLY_ACK) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 259 | printk(BIOS_ERR, "Keyboard set scancode cmd failed ACK: 0x%x\n", regval); |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 260 | return; |
| 261 | } |
| 262 | /* Set scancode mode 2 */ |
| 263 | regval = send_keyboard(0x02); |
Stefan Reinauer | 9c3e8b5 | 2010-02-28 19:12:37 +0000 | [diff] [blame] | 264 | if (regval != KBD_REPLY_ACK) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 265 | printk(BIOS_ERR, "Keyboard set scancode mode failed ACK: 0x%x\n", regval); |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 266 | return; |
| 267 | } |
| 268 | |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 269 | /* All is well - enable keyboard interface */ |
Marc Jones | e59f2e1 | 2009-09-29 19:12:23 +0000 | [diff] [blame] | 270 | if (!kbc_input_buffer_empty()) return; |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 271 | outb(0x60, KBD_COMMAND); |
Marc Jones | e59f2e1 | 2009-09-29 19:12:23 +0000 | [diff] [blame] | 272 | if (!kbc_input_buffer_empty()) return; |
Mathias Krause | 1c80cf0 | 2011-12-14 08:40:48 +0100 | [diff] [blame^] | 273 | outb(0x65, KBD_DATA); /* send cmd: enable keyboard and IRQ 1 */ |
Scott Duplichan | 9c934d1 | 2010-09-09 20:37:00 +0000 | [diff] [blame] | 274 | if (!kbc_input_buffer_empty()) { |
Mathias Krause | 1c80cf0 | 2011-12-14 08:40:48 +0100 | [diff] [blame^] | 275 | printk(BIOS_ERR, "Timeout during keyboard enable\n"); |
| 276 | return; |
| 277 | } |
| 278 | |
| 279 | /* enable the keyboard */ |
| 280 | regval = send_keyboard(0xF4); |
| 281 | if (regval != KBD_REPLY_ACK) { |
| 282 | printk(BIOS_ERR, "Keyboard enable failed ACK: 0x%x\n", regval); |
Marc Jones | e59f2e1 | 2009-09-29 19:12:23 +0000 | [diff] [blame] | 283 | return; |
| 284 | } |
Ronald G. Minnich | ef5f218 | 2003-09-26 15:24:54 +0000 | [diff] [blame] | 285 | } |
| 286 | |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 287 | /* |
| 288 | * Support PS/2 mode - oddball SIOs(KBC) need this setup |
| 289 | * Not well documented. Google - 0xcb keyboard controller |
| 290 | * This is called before pc_keyboard_init(). |
| 291 | */ |
Stefan Reinauer | bbe29ee | 2009-05-23 22:02:31 +0000 | [diff] [blame] | 292 | void set_kbc_ps2_mode(void) |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 293 | { |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 294 | /* Run a keyboard controller self-test */ |
| 295 | if (!kbc_self_test()) |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 296 | return; |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 297 | |
| 298 | /* Support PS/2 mode */ |
| 299 | if (!kbc_input_buffer_empty()) return; |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 300 | outb(0xcb, KBD_COMMAND); |
| 301 | |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 302 | if (!kbc_input_buffer_empty()) return; |
Stefan Reinauer | dd3e82a | 2009-10-24 18:15:07 +0000 | [diff] [blame] | 303 | outb(0x01, KBD_DATA); |
| 304 | |
Marc Jones | ecd176f | 2008-09-26 19:15:38 +0000 | [diff] [blame] | 305 | kbc_cleanup_buffers(); |
| 306 | } |