summaryrefslogtreecommitdiff
path: root/common/keyboard_8042.c
Commit message (Collapse)AuthorAgeFilesLines
* Retry 8042 keyboard interrupts if host isn't respondingRandall Spangler2014-04-051-2/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the host somehow fails to see an edge on the keyboard IRQ line, it won't read the 8042 data register. The EC won't ever send another IRQ, because it only does so after filling the register. So the keyboard will hang. Work around this with a retry mechanism. If the AP hasn't responded after 3 additional keyboard events, generate another IRQ. So a stuck key will get unstuck if you tap it a few times. That's reasonable, and matches what people do already if they have a sticky key due to crud accumulating in the keyboard. I've tested this when the system is booted to the OS. I don't see any additional IRQs generated on the EC console ("KB extra IRQ"), so the host is keeping up with the keyboard input stream. If I'm in dev or recovery mode and bang on the keyboard right after powering the system on (when the BIOS isn't yet paying attention to the keyboard), I can see extra IRQs generated. This shows the retry mechanism is working. The extra IRQs have no negative effect on the boot process, and the keyboard works normally when the OS does eventually boot. BUG=chrome-os-partner:27222 BRANCH=rambi TEST=Bang on the keyboard like a monkey. Keyboard should still work. Change-Id: I6faff3f42f541d5f8d939a8ae7ba1c9867812ae6 Original-Change-Id: Idd41b2d133267f48f959bca0cf062a18ca6551fb Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/193363 Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org> Commit-Queue: Shawn Nematbakhsh <shawnn@chromium.org> Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
* i8042: add a console command to dump internal state (cherry-pick).Louis Yung-Chieh Lo2014-04-041-6/+89
| | | | | | | | | | | | | | | | | | | | | | To help i8042 debug, add a new "8042" command. It also integrates other 8042-related command in one place to dump all 8042 state. Also few fixes to re-format the output. BUG=none BRANCH=none TEST=Buidl and tested on squawks Original-Change-Id: I23d0522aa9d32b38efc864cb97217852a5ad1ea0 Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/193123 Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 6d8276c431b9549aa1b573bbe867342a1cdbc08b) Change-Id: I466714a547503180a6a41d1d9d1ae60999f095af Reviewed-on: https://chromium-review.googlesource.com/193208 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Yung-chieh Lo <yjlou@chromium.org> Tested-by: Yung-chieh Lo <yjlou@chromium.org>
* 8042: Add typematic support for non-matrixed buttonsChromeOS Developer2014-02-261-15/+51
| | | | | | | | | | | | | | BUG=chrome-os-partner:24956 BRANCH=ToT TEST=Using evtest, verify off-keyboard volume buttons now send repeat codes while held down. Verify power button does not send repeat codes. Verify keyboard keys still send repeat codes as before. Change-Id: I873548181cdfa40d8e8929a6538c0ecd5ed8e92c Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/187938 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Fix set2 scancode for volume up media keyChromeOS Developer2014-02-071-2/+1
| | | | | | | | | | | | | | Also removes a useless BUILD_ASSERT. BUG=None BRANCH=ToT TEST=Boot kernel with cmdline arg i8042.direct=1 to force set2 mode. Push volume up/down & power key. Change-Id: Ifc735d66b2f707e68b5c59959c47a0e295a7688c Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/185392 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Add support for extra buttons not on the keyboardChromeOS Developer2014-02-041-1/+2
| | | | | | | | | | | BUG=chrome-os-partner:24370 BRANCH=tot TEST=Run button unit test. Change-Id: I61b4a6624d62831ce0bfdf7a0f36a45349b37f96 Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/184544 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* 8042: Add interface for handling off-matrix button changesChromeOS Developer2014-02-031-61/+95
| | | | | | | | | | BUG=chrome-os-partner:24370 BRANCH=tot TEST=Power key and keyboard work normally. Signed-off-by: Dave Parker <dparker@chromium.org> Change-Id: I291ff384ae2fc3e074132330713f0b0c2cc36a76 Reviewed-on: https://chromium-review.googlesource.com/184543
* Add F13 to 8042 keyboard scan matrixDave Parker2014-01-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | F13 is used to trigger the lock/password screen for users logged into Chromium OS. F13 is already used for this purpose on the USB Chrome keyboard. BUG=chrome-os-partner:24376 BRANCH=baytrail TEST=Run "kbpress 9 3 1" to simulate keypress. Verify lock screen is entered in Chromium OS. Set1: Run evtest. Verify KEY_F13 scan code, value=5d Set2: Add kernel parameter "i8042.direct=1" to use RAW mode. Run evtest. Verify KEY_F13 scan code, value=2f Change-Id: If9b9785faae374c496c94f3e2dd71ca95b237c27 Original-Change-Id: I71200810681f683c17e30b383e1221784deae0cd Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/182289 Reviewed-on: https://chromium-review.googlesource.com/184325 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Pad jump tags to 4 bytes inside the system moduleRandall Spangler2013-11-051-1/+0
| | | | | | | | | | | | | | | | | | | | | | | That way all the users of jump tags don't need to know about the padding requirements. BUG=chrome-os-partner:23851 BRANCH=none TEST=enable CONFIG_CMD_JUMPTAGS, then 'jumptags'. Output should be something like this: 20007fbc: 0x5550 UP.1 2 20007fc4: 0x4b42 KB.2 3 20007fcc: 0x4c50 LP.1 12 20007fdc: 0x4d54 MT.1 8 All the addresses in the first column should be word-aligned. The sizes in the last column don't need to be a multiple of 4. Change-Id: I91f9c29701a007ef8a56b5b7e0ea09930dfbea31 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/175591 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Update keyboard scanmatrix for Japanese keyboards.Dave Parker2013-08-301-6/+6
| | | | | | | | | | | | | BUG=chrome-os-partner:21798 BRANCH=peppy TEST=Run evtest. Push every key. Verify correct key code reported. Signed-off-by: Dave Parker <dparker@chromium.org> Change-Id: Ic6e4a38608f4bc8c66f487998912a7921ddb03cb Reviewed-on: https://chromium-review.googlesource.com/65623 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Yung-chieh Lo <yjlou@chromium.org>
* Remove unneeded includes of registers.hRandall Spangler2013-08-021-1/+0
| | | | | | | | | | | | | | | | | | | The registers.h file should only be included by code in the chip/ and board/ directories. Code outside those directories should not access chip-specific registers. (This change doesn't completely fix that, because common/extpower_usb.c uses STM32-specific regs, but we'll fix that in a separate CL.) BUG=chrome-os-partner:18343 BRANCH=none TEST=compile all platforms Change-Id: Ic499f56690c38663083423b0593800161a68e6e9 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/64382 Reviewed-by: Vic Yang <victoryang@chromium.org>
* Clean up more config options - FMAP, etc.Randall Spangler2013-07-241-5/+1
| | | | | | | | | | | | | | | | CONFIG_FMAP is now defined by default, because all platforms other than the host unit tests use it. No functional changes, just renaming config options and removing dead code. BUG=chrome-os-partner:18343 BRANCH=none TEST=build all platforms Change-Id: Ie6496310c822491068e2fa6976933486f26badb0 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/63271 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Clean up and document keyboard config optionsRandall Spangler2013-07-231-1/+1
| | | | | | | | | | | | | No functional changes, just renaming config options. BUG=chrome-os-partner:18343 BRANCH=none TEST=build all platforms Change-Id: Ie811066a26eeaf2a5b2002b934e25b660d29058d Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/63109 Reviewed-by: Vic Yang <victoryang@chromium.org>
* Fixed two i8042 bugs.Louis Yung-Chieh Lo2013-07-231-12/+31
| | | | | | | | | | | | | | | | | | | | | 1. The buffer for host i8042 command is too small so that a command is dropped (buffer full) in some cases. Enlarging it can solve bug. 2. The keystrokes are queued in buffer so that kernel driver cannot get stable CTR value. We workaround this by disabling the keystroke and clearing buffer when keyboard is disabled. BUG=chrome-os-partner:20758 BRANCH=falco,link TEST=Verified on link. Repeatedly press Ctrl + U during booting. The keyboard is working after boot. Change-Id: I7d8daef8d815b8e4d08df6f6a26ab2a471e5b150 Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/62986 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Duncan Laurie <dlaurie@chromium.org> Tested-by: Duncan Laurie <dlaurie@chromium.org>
* keyboard: Preserve keystroke enable state.stabilize-daisy-4319.96.Brelease-R29-4319.BShawn Nematbakhsh2013-06-241-2/+5
| | | | | | | | | | | | | | | Preserve the state of keystroke_enabled to prevent keystrokes from being initially disabled on RO --> RW transition. This will allow us to use the keyboard on EC cold boot. BUG=chrome-os-partner:20430. TEST=Manual. Verify keyboard works on EC cold boot on Peppy. BRANCH=None. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I603a73ee0f8435c91d430a64803add345c92f025 Reviewed-on: https://gerrit.chromium.org/gerrit/59798 Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
* Split out power button code from switch.cRandall Spangler2013-04-251-28/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The power button code is platform-independent. This change splits the code out of the LM4 switch.c module so that a subseqent change to STM32 platforms can start using it. BUG=chrome-os-partner:18945 BRANCH=none TEST=manual 1. Power+refresh+esc goes to recovery mode, 2. Press power button at recovery screen turns off. 3. With system off, power button turns system on. 4. Press power button for a second; screen locks. 5. Press power button while typing; blocks keystrokes while it's pressed. 6. Hold power button down for 8 sec; system forced to shutdown. 7. From EC console, with system on: hostevent clear hostevent -> event 0x04 is clear press power button hostevent -> event 0x04 is set 8. From EC console, with system off: powerbtn -> system turns on powerbtn 5000 -> system turns off, just like power button was held for 5 sec Change-Id: If2a9b02514a201e1d03c857d128e2ccab51a16ef Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49217 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Replace generated CONFIG_TASK_ macros with HAS_TASK_Bill Richardson2013-04-241-2/+2
| | | | | | | | | | | | | | | CONFIG_ macros should be set directly. Expanding the task names in the same way made it difficult to tell what was a configuration choice and what was due to changes in ec.tasklist BUG=chrome-os-partner:18343 TEST=build all, run link BRANCH=none Change-Id: Ib82e34f974238ee2dd216f33b701b6f4c6a4f1f1 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49098 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add parse_bool() to centralize parsing boolean optionsRandall Spangler2013-03-291-10/+16
| | | | | | | | | | | | | | | | | | | | | | This way debug commands which previously took only yes/no or on/off or enable/disable can take any of those options. BUG=chrome-os-partner:18467 BRANCH=none TEST=Try "on", "off", "yes", "no", "true", "false", "ena", "disable", for each of the following commands: - ilim (spring) - pll (link) - power (spring/snow) - hcdebug (all) - kblog (link) - ksscan (all) - lp5562 (spring) Change-Id: Ie8e0fae3775b1da711864bcba6682ba5e68a06f1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46900 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Rename I8042CMD task to KEYPROTORandall Spangler2013-03-291-4/+4
| | | | | | | | | | | | | | | | Since it's really the keyboard protocol task, not just handling i8042 commands. For consistency across keyboard protocols. No functional changes, just renaming. BUG=chrome-os-partner:18360 BRANCH=none TEST=boot link and type on keyboard Change-Id: I800a691a344f82bf582693cae865414b7d5d382a Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46885 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Merge typematic task info i8042cmd taskRandall Spangler2013-03-291-31/+24
| | | | | | | | | | | | | Getting rid of a task saves on RAM requirements. BUG=chrome-os-partner:18360 BRANCH=none TEST=boot link and hold a key down; see it repeat as expected Change-Id: I1ae4dc486f6669d5ad15899202abef85b8c1e7e8 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46826 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Convert typematic task from countdown to deadline-basedRandall Spangler2013-03-291-52/+56
| | | | | | | | | | | | | | | This is in preparation for merging the typematic and i8042cmd tasks. It also reduces the overhead of the typematic task during key-repeat; previously, it woke up every millisecond to tick down. BUG=chrome-os-partner:18360 BRANCH=none TEST=boot link and hold a key down; see it repeat as expected Change-Id: If6aee44ce7c746c8c1e68ed5cffced59fc575e4b Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46806 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Merge i8042.c into keyboard_8042.cRandall Spangler2013-03-291-80/+245
| | | | | | | | | | | | | | | | This is in preparation for cleaning up the 8042 protocol stack and merging the typematic and i8042cmd tasks. No functionality change, just shuffling code and renaming functions. BUG=chrome-os-partner:18360 BRANCH=none TEST=boot link and type on its keyboard Change-Id: Iefc41cd5b8d18ac87830bff3080cfff92e9d10d2 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46805 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Merge lm4 and stm32 implementations of keyboard_scanRandall Spangler2013-03-291-76/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Scanning is now performed identically on all platforms. keyboard_scan talks to chip-specific keyboard_raw on the bottom end, and 8042 or mkbp keyboard protocol on the top end. 8042 can now take advantage of CONFIG_KEYBOARD_TEST to simulate scan results. BUG=chrome-os-partner:18360 BRANCH=none TEST=compile all boards; test keyboard on spring and link 1) Type on keyboard. Should produce keystrokes. 2) At EC console: kbpress 3 7 1 kbpress 3 7 0 Should produce 'r' keystroke(s); key repeat should kick in if you wait a while between the commands. 3) Hold power button while typing. Should not produce keystrokes. 4) Reboot with power+refresh+esc. Should go to recovery mode. 5) While the system is up, alt+volup+R should reboot the AP. Change-Id: I48e0bca15b869162672b5f54ffcb561f6fcf0f45 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46666 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Move files in preparation for merging keyboard_scan modulesRandall Spangler2013-03-271-0/+1007
This is part one of a series to merge the keyboard scan interface to be common across all platforms. This change just moves and renames files and APIs and removes some read code, and sets up protocol-specific CONFIG options. It makes the next CL which actually merges keyboard scanning easier to parse. BUG=chrome-os-partner:18360 BRANCH=none TEST=compile all boards; test keyboard on spring and link Change-Id: I815a40aae4e5d5f333b8501aff9656080533d913 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46549 Reviewed-by: Bill Richardson <wfrichar@chromium.org>