summaryrefslogtreecommitdiff
path: root/common/keyboard_8042.c
Commit message (Collapse)AuthorAgeFilesLines
* ish: Trim down the release branchstabilize-wristpin-14469.59.B-ishstabilize-voshyr-14637.B-ishstabilize-quickfix-14695.187.B-ishstabilize-quickfix-14695.124.B-ishstabilize-quickfix-14526.91.B-ishstabilize-14695.85.B-ishstabilize-14695.107.B-ishstabilize-14682.B-ishstabilize-14633.B-ishstabilize-14616.B-ishstabilize-14589.B-ishstabilize-14588.98.B-ishstabilize-14588.14.B-ishstabilize-14588.123.B-ishstabilize-14536.B-ishstabilize-14532.B-ishstabilize-14528.B-ishstabilize-14526.89.B-ishstabilize-14526.84.B-ishstabilize-14526.73.B-ishstabilize-14526.67.B-ishstabilize-14526.57.B-ishstabilize-14498.B-ishstabilize-14496.B-ishstabilize-14477.B-ishstabilize-14469.9.B-ishstabilize-14469.8.B-ishstabilize-14469.58.B-ishstabilize-14469.41.B-ishstabilize-14442.B-ishstabilize-14438.B-ishstabilize-14411.B-ishstabilize-14396.B-ishstabilize-14395.B-ishstabilize-14388.62.B-ishstabilize-14388.61.B-ishstabilize-14388.52.B-ishstabilize-14385.B-ishstabilize-14345.B-ishstabilize-14336.B-ishstabilize-14333.B-ishrelease-R99-14469.B-ishrelease-R98-14388.B-ishrelease-R102-14695.B-ishrelease-R101-14588.B-ishrelease-R100-14526.B-ishfirmware-cherry-14454.B-ishfirmware-brya-14505.B-ishfirmware-brya-14505.71.B-ishfactory-kukui-14374.B-ishfactory-guybrush-14600.B-ishfactory-cherry-14455.B-ishfactory-brya-14517.B-ishJack Rosenthal2021-11-051-1328/+0
| | | | | | | | | | | | | | | | | | | | | | In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* mkbp: EC buttons and switches via MKBPBoris Mittelberg2021-05-101-2/+4
| | | | | | | | | | | | | | Allowing EC buttons and switches to be signaled via MKBP protocol, using CONFIG_MKBP_INPUT_DEVICES. Default behaviour is unchanged. BUG=b:170966461 BRANCH=main,firmware-dedede-13606.B,firmware-volteer-13672.B-main TEST=None Signed-off-by: Boris Mittelberg <bmbm@google.com> Cq-Depend: chromium:2824044 Change-Id: Ib96f98ecb3717a8ee8963be69fb7d7eb72e6d132 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2796382
* zephyr: shim keyboard_8042 functionJunLin2021-02-031-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL Connects Zephyr host interface APIs for KBC to lpc_keyboard_* functions. BUG=b:178747744 BRANCH=None. TEST=pass "make buildall" TEST=pass "zmake testall" TEST=check console, see 8042 protocol hankshaking messages printed: 21-02-01 16:22:22.142 [25.885700 KB Clear Buffer] 21-02-01 16:22:22.143 [25.887600 KB enable] 21-02-01 16:22:22.143 [25.888900 KS enable] 21-02-01 16:22:22.143 [25.890800 KB Clear Buffer] 21-02-01 16:22:22.143 [25.893700 KB scancode set to 1] 21-02-01 16:22:22.151 [25.896400 KB Clear Buffer] 21-02-01 16:22:22.151 [25.899000 KB Clear Buffer] 21-02-01 16:22:23.144 [00025887] <inf> espi_shim: KB put 55 21-02-01 16:22:23.144 [00025887] <inf> espi_shim: KB put 00 21-02<inf> espi_shim: KB put fa 21-02-01 16:22:23.156 [00025898] <inf> espi_shim: KB put fa 21-02-01 16:22:23.156 [00025901] <inf> espi_shim: KB put fa Signed-off-by: JunLin <CHLin56@nuvoton.com> Change-Id: I39ee19630da8561e392de34a277c043dbeae4c6c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2659137 Tested-by: CH Lin <chlin56@nuvoton.com> Reviewed-by: Simon Glass <sjg@chromium.org> Commit-Queue: Simon Glass <sjg@chromium.org>
* zephyr: Enable the '8042' commandSimon Glass2020-11-071-20/+18
| | | | | | | | | | | | | | | | | | | | | | | | | This is used to provide information about the keyboard operation. Enable this command and its subcommands. Note that in ECOS these subcommands are also top-level commands, but this is not the case in Zephyr, since it seems unnecessary. Note also that changing these to console sub-commands may end up making FAFT testing more difficult since the invocation on the EC UART would be different. BUG=b:167405015 BRANCH=none TEST=make BOARD=volteer zmake configure .../zephyr-chrome/projects/experimental/volteer \ -B /tmp/z/cos zmake build /tmp/z/cos Run on volteer and try out '8042 kbd', etc. Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: Ia11092af350247ac98681485a9ddd309c7192272 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2523452 Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr: Allow keyboard_8042 to build with zephyrSimon Glass2020-11-061-5/+30
| | | | | | | | | | | | | | | | | Make a few changes so that this file can build. It does not work yet. BUG=b:167405015 BRANCH=none TEST=make BOARD=volteer zmake configure .../zephyr-chrome/projects/experimental/volteer \ -B /tmp/z/cos zmake build /tmp/z/cos See there are no errors Change-Id: If68cc8e4541f513013481bde859fbe2f4681a0bc Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2521358 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Keyboard: Add AP wakeup to PS2 trackpoint interruptJosie Nordrum2020-10-071-0/+5
| | | | | | | | | | | | | | | | | | | | | Wake up AP for PS2 interrupt using Device Event as trigger. AP must have device event wakeup mask enabled and board must select CONFIG_DEVICE_EVENT in EC. This device event is only triggered when the chipset is suspended to avoid triggering SCIs in S0. BUG=b:160345665 BRANCH=Zork TEST=Wake from S3 by trackpoint Signed-off-by: Josie Nordrum <josienordrum@google.com> Change-Id: Ia431525ee8f572922c8f9bfe613d44e83308d9f8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2430288 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org>
* keyboard_8042: Send aux data to host from interrupt context.Edward Hill2020-07-241-7/+22
| | | | | | | | | | | | | | | Add a queue for aux (PS2) RX data so that i8042_send_to_host() is not called from interrupt context. i8042_send_to_host() locks to_host_mutex which must not be done in interrupt context. BUG=b:160975910 BRANCH=none TEST=PS2 still works Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: Ic4403d571592037173e64286aa013720f85acc9a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2306289 Reviewed-by: Raul E Rangel <rrangel@chromium.org>
* common: Make scancode table always mutableRajat Jain2020-04-211-3/+3
| | | | | | | | | | | | | | | | Since the vivaldi requires the scancode to be mutable, and vivaldi shall be enabled by default for all boards, thus make the scancode table to be always mutable and get rid of the config option it hides behind. BUG=b:146501925 TEST=Build BRANCH=firmware-hatch-12672.B Signed-off-by: Rajat Jain <rajatja@google.com> Change-Id: Iaedcd6d84caf31c91a61854f96414bcea38f5c2a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2133825 Reviewed-by: Jett Rink <jettrink@chromium.org>
* common/keyboard_8042: Add ability to send/receive AUX dataRaul E Rangel2020-03-021-24/+75
| | | | | | | | | | | | | | | | | | | | * Added CHAN_AUX to CHAN enum. * Added two new types to kblog for AUX data. * Moved mouse methods to handle_mouse_data so they can respond on the AUX channel. * Call lpc_aux_put_char to put an AUX byte. * Added send_aux_data_to_host and send_aux_data_to_device to pipe data in and out of the 8042. CONFIG_8042_AUX must be set if the board implements these methods. BUG=b:145575366 BRANCH=none TEST=Verified I can see AUX data going in and out. Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: Iea1fc315846a9f768a1d82e309ff0725d1d2a9c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2079695 Reviewed-by: Edward Hill <ecgh@chromium.org>
* common/keyboard_8042: Add logging to keyboard_clear_bufferRaul E Rangel2020-03-021-0/+4
| | | | | | | | | | | | | It's useful to know when the buffer has been cleared. BUG=b:145575366 BRANCH=none TEST=Saw x in kblog Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: I1c3474687c91a3e017d7a7a0e4e7967c3fb10f05 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2079693 Reviewed-by: Edward Hill <ecgh@chromium.org>
* common/keyboard_8042: Update kblog while holding mutexRaul E Rangel2020-03-021-2/+3
| | | | | | | | | | | | | | i8042_send_to_host can be called from multiple tasks. Make sure we don't mix up or lose any kblog entries. BUG=b:145575366 BRANCH=none TEST=Built and saw kblog is still populated. Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: I5d036f6db4c829c2071850c1ec92f74a24b135b7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2079692 Reviewed-by: Edward Hill <ecgh@chromium.org>
* common/keyboard_8042: Add ability to specify 8042 channelRaul E Rangel2020-02-271-13/+32
| | | | | | | | | | | | | | | We actually have two data channels we can send data on. This CL only adds the functionality to specify the additional channel. We only define the KBD channel for now. A follow up will add the AUX channel. BUG=b:145575366 BRANCH=none TEST=Verified keyboard data is still sent Change-Id: Icaed0a741cee4dac5eb5e6f36bd4e45d4a1e1bcd Signed-off-by: Raul E Rangel <rrangel@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2073285 Reviewed-by: Edward Hill <ecgh@chromium.org>
* common/keyboard_8042: Track aux chan enable and aux irq enableRaul E Rangel2020-02-271-0/+33
| | | | | | | | | | | | | Start tracking these so we can correctly filter mouse messages. BUG=b:145575366 BRANCH=none TEST=Verified 8042 command prints current state Change-Id: I8a5fe3c66196d961c3a1adbb7355532de5ac0dc9 Signed-off-by: Raul E Rangel <rrangel@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2073284 Reviewed-by: Edward Hill <ecgh@chromium.org>
* common/keyboard_8042: Rename i8042_irq_enabledRaul E Rangel2020-02-271-5/+5
| | | | | | | | | | | | | | Rename i8042_irq_enabled to i8042_keyboard_irq_enabled to avoid confusion when adding i8042_aux_irq_enabled. BUG=b:145575366 BRANCH=none TEST=Build test Change-Id: I031bf941faf80d99a01bf2a3834f61b5040f7674 Signed-off-by: Raul E Rangel <rrangel@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2073283 Reviewed-by: Edward Hill <ecgh@chromium.org>
* builtin: Introduce and use inttypes.hEvan Green2019-10-051-2/+2
| | | | | | | | | | | | | | | | | | | | | In order to pass the right printf format specifiers for certain types that are compiled both in 32-bit EC and 64-bit host environments, standard macros PRIx64 and PRId64 must be introduced. These specify the correct printf format specifier in the given compilation environment for printing a 64-bit value. On the host, inttypes.h already exists. Add an inttypes.h for the EC codebase so that these macros can be used where they're needed. BUG=chromium:984041 TEST=make -j buildall BRANCH=none Change-Id: I76e3bdc88aef7da6e5234d5b86b595f7138ea9a1 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1819642 Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-191-1/+1
| | | | | | | | | | | | | | | | Ran the following command: git grep -l 'Copyright (c)' | \ xargs sed -i 's/Copyright (c)/Copyright/g' BRANCH=none BUG=none TEST=make buildall -j Change-Id: I6cc4a0f7e8b30d5b5f97d53c031c299f3e164ca7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1663262 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* 8042: Only send back ACK in response to reset command(0xff)Furquan Shaikh2019-06-051-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8042 keyboard command reset (0xff) was returning ACK(0xfa) as well as BAT(0xaa). From [1], 0xaa seems to be represent OK. However, the spec does not expect OK to be sent in response to reset command. Coreboot libpayload 8042 driver was recently updated to send a reset command on initialization to make it work with certain payloads. Sending back 0xaa along with ACK seems to make the initialization fail because it is not expecting anything other than ACK. This change gets rid of the return value 0xaa that was being sent for reset command. [1] http://zet.aluzina.org/images/d/d4/8042.pdf BUG=b:134366527 BRANCH=None TEST=Verified that keyboard initialization no longer fails in depthcharge. Change-Id: I0ac917dc94aa381ab705474cd7bcf494fb8b10d6 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1641756 Reviewed-by: Frank Wu <frank_wu@compal.corp-partner.google.com> Reviewed-by: Duncan Laurie <dlaurie@google.com> Tested-by: Frank Wu <frank_wu@compal.corp-partner.google.com> Tested-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org>
* common: replace 1 << digits, with BIT(digits)Gwendal Grignou2019-03-261-6/+6
| | | | | | | | | | | | | | | | Requested for linux integration, use BIT instead of 1 << First step replace bit operation with operand containing only digits. Fix an error in motion_lid try to set bit 31 of a signed integer. BUG=None BRANCH=None TEST=compile Change-Id: Ie843611f2f68e241f0f40d4067f7ade726951d29 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1518659 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Keyboard: Allow keyboard size to be set at run timeDaisuke Nojiri2018-10-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Currently, the keyboard size (i.e. number of columns) is static. This patch allows it to be configured at run time. It's required to support a keyboard with/without keypad in a single image. KEYBOARD_COLS_MAX has the build time col size. It's used to allocate exact spaces for arrays. Actual keyboard scanning is done using keyboard_cols, which holds a runtime col size. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:117126568 BRANCH=none TEST=Verify keyboard functionality on Sona and Veyron. Change-Id: I4b3552be0b4b315c3fe5a6884cf25e10aba8be7c Reviewed-on: https://chromium-review.googlesource.com/1285292 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Keyboard: switch column and row of scancode tableDaisuke Nojiri2018-10-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch switches column and row of scancode_set2. That is, scancode_set2[ROWS][COLS] = {0x00, 0x01, 0x02, ..., 0x10, 0x11, ..., 0x20, ..., becomes scancode_set2[COLS][ROWS] = {0x00, 0x10, 0x20, ..., 0x01, 0x11, ..., 0x02, ..., This will allow us to extend the table for a keypad without losing too much readability. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:117126568 BRANCH=none TEST=Verify keyboard functionality on Sona. Change-Id: I49a7c0796d5c91989f1d3686c80743fb4bcd5ba7 Reviewed-on: https://chromium-review.googlesource.com/1285291 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* keyboard: display keycap label in key status debug messagesNamyoon Woo2018-09-131-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current debug message in keyboard_8042.c displays a tuple of row, column, and press status. Additionally, this CL displays a keycap label for better readability. For keycap label mapping table can be adjustable under "CONFIG_KEYBOARD_SCANCODE_MUTABLE" condition as scancode_set2[] is. For coral board, Enabling CONFIG_KEYBOARD_DEBUG (w/o this CL) occupies 652 bytes in flash, and this CL occupies another 312 bytes. BUG=b:111060830 TEST=manually tested by pressing keyboards and check the EC console screen. BRANCH=kblog Signed-off-by: Namyoon Woo <namyoon@chromium.org> Changes to be committed: modified: board/eve/board.c modified: common/keyboard_8042.c modified: common/keyboard_8042_sharedlib.c modified: include/keyboard_8042_sharedlib.h Change-Id: Idd71a5475b1ee313f99e087be9143dcfb6f81550 Reviewed-on: https://chromium-review.googlesource.com/1214543 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Namyoon Woo <namyoon@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* keyboard: Move keyboard_special (lightbar demo) to samus/board.cHung-Te Lin2018-08-201-54/+0
| | | | | | | | | | | | | | | | | | Currently the keyboard_special has only one function - to enter demo or easter egg mode if lightbar task is running. However, only Samus has lightbar so we should not waste time doing keyboard_special on all boards. The better approach is to use the new CONFIG_KEYBOARD_SCANCODE_CALLBACK and provide the lightbar demo check inside samus board.c. BUG=None TEST=make buildall -j BRANCH=None Change-Id: Ie8ab994b5439309663328a75680d45230a6eaeea Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1168702 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* keyboard: Add CONFIG_KEYBOARD_SCANCODE_CALLBACK for board-specific hooks.Hung-Te Lin2018-08-171-0/+9
| | | | | | | | | | | | | | | | | | | | | Many devices may want board-specific keyboard hooks, for example allowing easter egg (to replace the key_special today), or to provide dynamic translation. Both can be done by having a callback whenever the key state is changed (after scancode is found). The new CONFIG_KEYBOARD_SCANCODE_CALLBACK allows boards to define their own hook keyboard_scancode_callback so the keystrokes can be either changed or monitored. BUG=b:72200093 TEST=make buildall -j BRANCH=eve Change-Id: I02e3bf5c217b2f30b942d96ecb2c493ce200638f Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1168281 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* keyboard: Change scan code magic values to enum.Hung-Te Lin2018-08-161-10/+13
| | | | | | | | | | | | | The key codes are now always scan code set 2 so we can create a list of scan codes and use them easily. BUG=None TEST=make buildall -j; boots properly BRANCH=None Change-Id: I1fdd7ab81bc13c97c4139afc19d71f5898e22f96 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1166743
* keyboard: Keep only scan code set 2 table and do translation for set 1.Hung-Te Lin2018-08-151-56/+32
| | | | | | | | | | | | | | | | | | | | | | | | | The 8042 scan code set 1 can be directly translated from set 2, with a 256 byte table. With this change, we can always process key stroke in scan code (set 2), and only translate in the single function `scancode_bytes`. This is very helpful when we need to do key processing, for example the buttons_8042 can now be simplified with only one scan code. And is extremely helpful if we want to do dynamic translation (i.e., to prevent something like CL:1164725). For `make BOARD=samus', the free space is also increased from 18472 to 18656 (+184) bytes. BUG=None TEST=make buildall; manually installed on Eve and tested by running 'keyboard' factory test to make sure all key scancodes are not changed. BRANCH=None Change-Id: Ieb303d84edcd4375bbeb1ea5f032d0462bbfd250 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1166742 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* reset: Log the reason for AP resets.Jonathan Brandmeyer2018-07-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provides a new EC host command 'uptime info' which gathers up some information which may be useful for debugging spurious resets on the AP (was the EC reset recently? Why was the EC reset? If the EC reset the AP, why did it do so?, etc.). Provide ectool support for the same. Example results of `ectool uptimeinfo`: ``` localhost ~ # ectool uptimeinfo EC uptime: 475.368 seconds AP resets since EC boot: 2 Most recent AP reset causes: 315.903: reset: console command 363.507: reset: keyboard warm reboot EC reset flags at last EC boot: reset-pin | sysjump ``` BRANCH=none TEST=Perform some `apreset` commands from the EC console and observe their side-effects via the `ectool uptimeinfo` command on the AP side. Test sequences include no-resets through 5 resets, observing that the ring buffer handling was correct. BUG=b:110788201, b:79529789 Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Change-Id: I0bf29d69de471c64f905ee8aa070b15b4f34f2ba Reviewed-on: https://chromium-review.googlesource.com/1139028 Commit-Ready: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Tested-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* keyboard_8042: Clear buffer before adding command byteFurquan Shaikh2018-07-251-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the host attempts to read CTR, first clear the keyboard buffer to ensure that we do not have any stale data in it. If the buffered data is not cleared, host could end up interpreting the keypress data as CTR thus resulting in unwanted side-effects. Reason for putting in this change is because Linux kernel does not disable keyboard scanning when doing a reboot or poweroff. Now, if user keeps pressing keys while the system is booting up, kernel could end up reading key press data as CTR thus resulting in keyboard being disabled on boot-up. This change ensures that keyboard buffer is cleared before adding CTR data to it. BUG=b:111228655 BRANCH=poppy,eve,nami TEST=Verified on nautilus that keyboard is still functional after doing a reboot from AP shell and continuously pressing keys while system is booting up in normal mode. Change-Id: I5cbc904629fbd40b39625e37abccb80c83447d39 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/1147866 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* shared_mem: Assert that shared memory size is large enoughNicolas Boichat2018-05-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We add a configuration option to set the minimum shared memory size (CONFIG_SHAREDMEM_MINIMUM_SIZE), so that the link will fail if there is not enough IRAM left. Also, we add 2 macros around shared_mem_acquire, that check, at build time, that the shared memory size is sufficient for the allocation: - SHARED_MEM_ACQUIRE_CHECK should be used instead of shared_mem_acquire, when size is known in advance. - SHARED_MEM_CHECK_SIZE should be used when only a maximum size is known. This does not account for "jump tags" that boards often add on jump from RO to RW. Luckily, RW usually does not do verification, and does not need as much shared memory. BRANCH=none BUG=chromium:739771 TEST=make buildall -j, no error Change-Id: Ic4c72938affe65fe8f8bc17ee5111c1798fc536f Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1002713 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Code cleanup: Remove cold reset logicVijay Hiremath2018-04-031-1/+1
| | | | | | | | | | | | | | | | | | | | | Majority of the chipsets do not have a dedicated GPIO to trigger AP cold reset. Current code either ignores cold reset or does a warm reset instead or have a work around to put AP in S5 and then bring back to S0. In order to avoid the confusion, removed the cold reset logic and only apreset is used hence forth. BUG=b:72426192 BRANCH=none TEST=make buildall -j Manually tested on GLKRVP, apreset EC command can reset AP. Change-Id: Ie32d34f2f327ff1b61b32a4d874250dce024cf35 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/991052 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* console: Fix help for parse_boolEdward Hill2018-03-161-1/+1
| | | | | | | | | | | | | | | A few commands had help text of "[0 | 1]" but parse_bool() doesn't recognize 0 and 1. Change help text to "[on | off]", matching other commands. BUG=b:75302458 BRANCH=none TEST=none Change-Id: I9b1e4a70e024d17ec8bccc015069e31d7fff08ca Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/967248 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Fix keyboard in systemd-bootStefan Reinauer2017-10-191-13/+5
| | | | | | | | | | | | | | | | | | | This prevents problematic disabling of the keystrokes by making it so that 0xAD can't disable keystrokes. Also cleans up keyboard controller enable/disable code. BRANCH=none BUG=none TEST=keyboard now working in UEFI bootloaders like systemd-boot (aka gummiboot) Change-Id: I921834fc418572c9a0f4586039ac1ce05504bf1d Signed-off-by: Matt DeVillier <matt.devillier@gmail.com> Signed-off-by: Stefan Reinauer <reinauer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/722124 Tested-by: Stefan Reinauer <reinauer@google.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* keyboard_8042: ensure key scanning on when keyboard enabledStefan Reinauer2017-10-171-0/+2
| | | | | | | | | | | | | BRANCH=none BUG=none TEST=Boot Windows in legacy mode and observe keyboard is working. Change-Id: Id203a8804b86e0fcfbb9974658f66e9bd2602151 Signed-off-by: Matt DeVillier <matt.devillier@gmail.com> Signed-off-by: Stefan Reinauer <reinauer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/722123 Tested-by: Stefan Reinauer <reinauer@google.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* 8042: Fix error conditionMartin Roth2017-08-121-1/+1
| | | | | | | | | | | | | | | | | Since the scancode_setX arrays are defined with size [KEYBOARD_ROWS][KEYBOARD_COLS], if rows or columns are equal to either of those values, it would be accessing values outside of the array. BUG=b:64477774 TEST=Build Change-Id: I8a92d142b03281f2f4ad35eaba605b5a46df798d Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://chromium-review.googlesource.com/606452 Commit-Ready: Martin Roth <martinroth@chromium.org> Tested-by: Martin Roth <martinroth@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* Fix inconsistent task function declarationsStefan Reinauer2017-08-081-1/+1
| | | | | | | | | | | | | | | Tasks are defined inconsistently across the code base. Signed-off-by: Stefan Reinauer <reinauer@google.com> BRANCH=none TEST=make buildall -j, also verify kevin boots to OS BUG=none Change-Id: I19a076395a9a8ee1e457e67a89d80d2f70277c97 Reviewed-on: https://chromium-review.googlesource.com/602739 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* keyboard: Clear typematic when disabling keyboardDaisuke Nojiri2017-05-031-1/+1
| | | | | | | | | | | | | | | | This patch clears the typematic buffer when disabling keyboard scan. When the device goes to tablet mode with a key being pressed, this should prevent keyboard_protocol_task from sending scan codes to the host. BUG=b:35585725 BRANCH=none TEST=make buildall. Tested on Electro. Change-Id: I73e9d2948b472458814967307412aebeb410ff2e Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/425075 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* cleanup: DECLARE_CONSOLE_COMMAND only needs 4 argsBill Richardson2016-08-241-12/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Since pretty much always, we've declared console commands to take a "longhelp" argument with detailed explanations of what the command does. But since almost as long, we've never actually used that argument for anything - we just silently throw it away in the macro. There's only one command (usbchargemode) that even thinks it defines that argument. We're never going to use this, let's just get rid of it. BUG=none BRANCH=none CQ-DEPEND=CL:*279060 CQ-DEPEND=CL:*279158 CQ-DEPEND=CL:*279037 TEST=make buildall; tested on Cr50 hardware Everything builds. Since we never used this arg anyway, there had better not be any difference in the result. Change-Id: Id3f71a53d02e3dc625cfcc12aa71ecb50e35eb9f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/374163 Reviewed-by: Myles Watson <mylesgw@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Keyboard: Add a macro to conditionally compile the console commandsVijay Hiremath2015-08-281-1/+2
| | | | | | | | | | | | | | | | | | | | Added macros to conditionally compile the keyboard test console commands to save the memory. These macros can be enabled/disabled in the board specific files. BUG=none TEST=make buildall -j BRANCH=none Change-Id: I3ad190f1f3c9310e4f706b3b23cb8ca8755e49ef Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/295942 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Commit-Ready: Divya Jyothi <divya.jyothi@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Divya Jyothi <divya.jyothi@intel.com> Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Shawn N <shawnn@chromium.org>
* libsharedobjs: Add 8042 scancodes to shared lib.Aseda Aboagye2015-07-171-64/+1
| | | | | | | | | | | | | | | | | | | | | | | | | This commit adds the 8042 scancodes to the shared objects library saving 504 bytes from the RW image. To enable the space savings, define CONFIG_SHAREDLIB in the target's board.h file. BUG=none BRANCH=none TEST=make -j buildall tests TEST=Built samus EC image and verified keyboard still worked in RO and RW. TEST=Built samus EC image with CONFIG_SHAREDLIB enabled and verified that the keyboard still worked in RO and RW. TEST=Enabled CONFIG_SHAREDLIB for glados and cyan and watched build fail. CQ-DEPEND=CL:275344 Change-Id: I1241506c6b34d63e270677d4e8d0531a8a4236c9 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/276212 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* Queue: Add policies to queuesAnton Staaf2015-05-261-2/+2
| | | | | | | | | | | | | | | | | | | | Policies give a convenient place to hook into the queue operations and notify something that there is new space free in the queue or new units added. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: I94b2aa94b8e8d07911191bc19a39fa827623b117 Reviewed-on: https://chromium-review.googlesource.com/271791 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Anton Staaf <robotboy@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org> Trybot-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org>
* nuc: Add all IC specific drivers of NPCX5M5GIan Chao2015-01-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add npcx_evb in board folder for testing Add shared-spi arch support in common layer. Modified drivers for 1. Fan.c: console command “pwmduty”. 2. Pwm.c: for the issue when set duty to 0. 3. System.c: for hw reset only during system reset. 4. Flash.c: Fixed access denied bug of the flash driver for host command. 5. Comments from Patch Set 1 6. Comments from Patch Set 3 (except sha256.c) 7. Add openocd and flash_ec support for npcx_evb 8. Add little FW and spi-flash upload FW in chip folder 9. Add optional make rules for PROJECT_EXTRA 10.Replace CONFIG_SHRSPI_ARCH with CONFIG_CODERAM_ARCH and remove changes in common layer sources for shared-spi arch. (except sysjump) 11.Find the root cause of JTAG issue and use workaround method with SUPPORT_JTAG in clock.c 12 Execute hibernate in low power RAM for better power consumption 13 Add workaround method for version console command 14 Modified coding style issues by checkpatch.pl tool BUG=chrome-os-partner:34346 TEST=make buildall -j; test nuvoton IC specific drivers BRANCH=none Change-Id: I5e383420642de1643e2bead837a55c8c58481786 Signed-off-by: Ian Chao <mlchao@nuvoton.com> Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/233742
* Add demo_tap() function for lightbar demo modeBill Richardson2014-09-261-0/+3
| | | | | | | | | | | | | | | | | | | BUG=chrome-os-partner:29041 BRANCH=ToT TEST=manual From the host run ectool lightbar demo on Then press the 'T' key. The lightbar should change to indicate the charge state. Fiddle with the arrows to change the pretend battery level and AC presence. Change-Id: I398a829e2e5de5e1a186500aa2ed72c61e71deaa Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/220024 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* Queue: Add functionality needed by new USART stream driverAnton Staaf2014-09-181-26/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously there was no way to remove multiple units at a time from the queue, and the queue was wasting an entry to disambiguate full from empty. There was also no way to get the free entry count from the queue, only the ability to query if it was above a required amount. The queue was also storing its constant compile time configuration as well as its dynamic state in the same structure. This wasted RAM on configuration information that doesn't change. This refactor fixes these issues, making the queue suitable for use in the new USART stream driver. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: I284cee52d8189928dbc4c499f87ab34e14019e5a Reviewed-on: https://chromium-review.googlesource.com/210533 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org>
* Add cprints() and ccprints()Vic Yang2014-05-211-27/+27
| | | | | | | | | | | | | | | | | | | | | Our code base contains a lot of debug messages in this pattern: CPRINTF("[%T xxx]\n") or ccprintf("[%T xxx]\n") The strings are taking up spaces in the EC binaries, so let's refactor this by adding cprints() and ccprints(). cprints() is just like cprintf(), except that it adds the brackets and the timestamp. ccprints() is equivalent to cprints(CC_CONSOLE, ...) This saves us hundreds of bytes in EC binaries. BUG=chromium:374575 TEST=Build and check flash size BRANCH=None Change-Id: Ifafe8dc1b80e698b28ed42b70518c7917b49ee51 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200490 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* 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: Idd41b2d133267f48f959bca0cf062a18ca6551fb Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/193272 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Benson Leung <bleung@chromium.org> Reviewed-by: Yung-chieh Lo <yjlou@chromium.org>
* i8042: add a console command to dump internal state.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 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>
* 8042: Add typematic support for non-matrixed buttonsChromeOS Developer2014-03-251-17/+59
| | | | | | | | | | | | | | | | | | | | | | | BUG=chrome-os-partner:24956 BRANCH=ToT TEST=Using evtest, verify off-keyboard 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. Original-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> Conflicts: common/keyboard_8042.c Change-Id: Ie7c7a1064cf45083f4707580f4ffc4d364035df9 Reviewed-on: https://chromium-review.googlesource.com/191312 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Dave Parker <dparker@chromium.org> Tested-by: Dave Parker <dparker@chromium.org>
* Samus: Support capsense input as keyboard events.Bill Richardson2014-02-081-2/+4
| | | | | | | | | | | | | | | | | | | | | | This is experimental for now; the capsense chip simply reports its buttons as the number keys on the keyboard (1-8). BUG=chrome-os-partner:23382 BRANCH=samus,ToT TEST=manual To test, you'll need a reworked and correctly programmed capsense module. Boot the system, and switch to VT2. Touch the capsense bar and you'll see the input appear on the console as though you were typing numbers. Note that the capsense hardware is still buggy. Refer to the bug for workarounds. Change-Id: I4c3a8b70b8197ffd538c38c59c9336383365afa7 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/185434 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Dave Parker <dparker@chromium.org>
* Fix set2 scancode for volume up media keyChromeOS Developer2014-02-081-2/+1
| | | | | | | | | | | | | | | | Also removes a useless BUILD_ASSERT. BUG=None BRANCH=None TEST=Boot kernel with cmdline arg i8042.direct=1 to force set2 mode. Push volume up/down & power key. Change-Id: I1689f06c5ae690624733c0625ce043cb1462abd0 Original-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> Reviewed-on: https://chromium-review.googlesource.com/185315
* Add support for extra buttons not on the keyboardChromeOS Developer2014-02-071-1/+2
| | | | | | | | | | | | | | | | | | BUG=chrome-os-partner:24370 BRANCH=tot TEST=Run button unit test. Orig-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> (cherry picked from commit f6426cc21c20a4f876cff28b9ce7e3115f0b054a) Change-Id: I4face9bf0797a91ec8bef390093aab8e3d8f97ab Reviewed-on: https://chromium-review.googlesource.com/185243 Tested-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Randall Spangler <rspangler@chromium.org>
* 8042: Add interface for handling off-matrix button changesChromeOS Developer2014-02-071-61/+95
| | | | | | | | | | | | | | | | | BUG=chrome-os-partner:24370 BRANCH=tot TEST=Power key and keyboard work normally. Signed-off-by: Dave Parker <dparker@chromium.org> Orig-Change-Id: I291ff384ae2fc3e074132330713f0b0c2cc36a76 Reviewed-on: https://chromium-review.googlesource.com/184543 (cherry picked from commit c65f82a5b02cdecf5b62f71ef2e916795f808389) Change-Id: I1cd02e824c97eb5909e7bff68c8ecefc89f52df0 Reviewed-on: https://chromium-review.googlesource.com/185242 Tested-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Randall Spangler <rspangler@chromium.org>