summaryrefslogtreecommitdiff
path: root/common/console_output.c
Commit message (Collapse)AuthorAgeFilesLines
* fix ChromiumOS authors and whitespace warningsMary Ruthven2022-09-131-1/+1
| | | | | | | | | | | BUG=none TEST=none Change-Id: I61b0b0106a43f723ec3bc805eb190aef00bbd05b Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3894391 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
* Revert "console_output: Add option to disable console channels"Mary Ruthven2021-11-181-10/+0
| | | | | | | | | | | | This reverts commit 35e278bb41dc9f54e1317b0225c371b4c939eb12. BUG=b:200823466 TEST=make buildall -j Change-Id: I1af86919d833fd383350f55b2fb7cbd61d010a78 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3273425 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
* console: add service functions to enable/disable console outputVadim Sukhomlinov2020-06-161-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | FIPS 140-2 certification requires that security related output from module should be disabled until completion of known-answer tests. However, it's tricky to justify what output is security related, as most of output data can be used to track current execution stage which may be helpful for attacker. So, its safer to disable any output for a short time once internal testing is done. Provide console_disable_output() and console_enable_output() functions which are supposed to be used by board initialization code driving FIPS mode initialization. BUG=b:138577539 TEST=manual; make buildall -j Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com> Change-Id: I42902acef7a5e99142ce2b6517ae511f63206e93 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2247103 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org> Auto-Submit: Vadim Sukhomlinov <sukhomlinov@chromium.org>
* Prepare for transitioning to packet mode consoleVadim Bendebury2020-03-311-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A very few changes are needed to support the packet mode: - provide functions to report how much room is left in USB/UART transmit buffers; - compile out cprintf/cprints/cputs just in case to be able to catch cases where util_precompile.py fails to convert them for whatever reason; - do not add CR to every LF, this messes up packet transmissions, and the terminal is doing the right thing anyways - there is a problem with the USB channel in packet mode: the device reboots as soon as an attempt to send something to the host is undertaken. The problem can be rectified by disabling the deferred function path in the Cr50 console USB channel. A bug was open to track it down, but in packet mode using deferred function in this path is less critical, as the amount of sent data always is at least as much as the packet header size BUG=b:149964350, b:152116489 TEST=with the rest of the patches applied packet mode console works fine. When packet mode is disabled the conventional mode console works fine. Change-Id: Ib010cede36adc87cf80f49e5d76ec9e274d9e608 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2114238 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Namyoon Woo <namyoon@chromium.org>
* cmsg.c, console packet mode driverVadim Bendebury2020-03-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a console driver for packet mode. The driver processes information prepared by util_precomplie.py when processing printf invocations in the source code. Each invocation is replaced by a cmsgX function, where X is the number of format arguments. cmsgX functions prepare an array of parameters of size X and invoke a common function, passing it the array and an integer value, consisting of up to 8 4 bit fields, describing the parameters. Since both console drivers need to be able to filter logical console channels, the channel_mask variable is made global. BUG=b:149964350 TEST=with the rest of patches applied and packet mode enabled, verified proper operation of both Cr50 consoles (USB and UART). Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I1f6ef5ea50bffbe14d3e3850fff0191c54f37033 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2113931 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* include: De-longify CC_MASK() and CC_ALLEvan Green2019-10-051-1/+1
| | | | | | | | | | | | | | | These are consistently stored into 32-bit values, so there's no need for their macros to be suffixed with a long designator. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Signed-off-by: Evan Green <evgreen@chromium.org> Change-Id: I0618cb30cf1afa5e0e015006e2eee9c9abfc5402 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1834602 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org>
* printf: Fix formatting errorsEvan Green2019-10-051-1/+1
| | | | | | | | | | | | | | | | | | | This change fixes the printf formatting errors found by the compile-time prinf format checker. The errors fall into a few categories: 1. Incorrect size specifier (missing or extra l). 2. Missing or extra arguments. 3. Bad line splitting. BUG=chromium:984041 TEST=make -j buildall BRANCH=none Change-Id: I5618097a581210b9fcbfc81560dec050ae30b61c Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1819653 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* printf: Convert %T to %pTEvan Green2019-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | In order to be more compliant to standards, and ultimately turn on compile-time printf format validation, switch the non-standard %T into %pT, which takes a pointer to a 64-bit timestamp as an argument. For convenience, define PRINTF_TIMESTAMP_NOW, which will use the current time as the timestamp value, rather than forcing everyone to pass a pointer to get_time().val. For a couple of instances, simply use CPRINTS instead. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Cq-Depend:chrome-internal:1473305 Change-Id: I83e45b55a95ea27256dc147544ae3f7e39acc5dd Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704216 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@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>
* console_output: make chan a safe commandMary Ruthven2018-05-311-3/+3
| | | | | | | | | | | | | | | | | | We need to control the console channels for cr50 testing, so we need access to chan even if the console is restricted. Make chan a safe command so it is always accessible. BUG=b:80319784 BRANCH=cr50 TEST=on cr50 make sure the command is accessible no matter the console state Change-Id: Ia392f32c319c1acf9bb97b97d7f72c7e56427ce3 Signed-off-by: Mary Ruthven <mruthven@google.com> Reviewed-on: https://chromium-review.googlesource.com/1079452 Commit-Ready: Mary Ruthven <mruthven@chromium.org> Tested-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* console_output: Add option to disable console channelsNicolas Boichat2018-05-241-0/+10
| | | | | | | | | | | | | | On hammer, we do not need the console channels, so we can just disable them to save flash size. BRANCH=poppy BUG=b:35647963 TEST=make newsizes, staff image size shrinks by 704 bytes Change-Id: I7a493ae57573814b166d45e57f1ad3d885f26086 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1070949 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Cr50: The chan command is not safe.Bill Richardson2016-10-011-3/+3
| | | | | | | | | | | | | It could be used to sniff TPM commands. BUG=chrome-os-partner:57408 BRANCH=none TEST=make buildall; try on Gru with and without CR50_DEV=1 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: Ia2e11fb8e01002c2cf5e53b175e3e8b2741e4585 Reviewed-on: https://chromium-review.googlesource.com/391244 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* Cr50: Mark several console commands as safeBill Richardson2016-08-311-3/+3
| | | | | | | | | | | | | | | | | | | Even when CONFIG_RESTRICTED_CONSOLE_COMMANDS is enabled, there are many commands that can't do anything dangerous. This marks some of those commands as safe to use, even when restrictions are enforced. I'm only marking commands that are used by the Cr50, since that's the only board that has restrictions. BUG=chrome-os-partner:55322 BRANCH=none TEST=make buildall, test on Cr50 hardware Change-Id: I6289d332830175b6adcb6b20cb4c21d01d27a25e Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/376188 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* cleanup: DECLARE_CONSOLE_COMMAND only needs 4 argsBill Richardson2016-08-241-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Console: Fix channel enum valuesAnton Staaf2016-03-221-53/+9
| | | | | | | | | | | | | | | | | | | The channel enum and string name array were out of sync (when CONFIG_EXTENSION_COMMAND is defined). This was caused by the two lists being specified separately. I argue that this is a good reason to merge the lists into a separate X-Macro include file. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: I81d143f550a0fe6ef0c64e3c8357ed18aee4bfdc Reviewed-on: https://chromium-review.googlesource.com/334381 Commit-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* add the 'extension' command frameworkVadim Bendebury2015-11-171-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces a facility which would allow to compile in callbacks for arbitrary commands passed over various communication protocols. Typically this will be used for testing, when various test commands are multiplexed over an existing protocol. The callbacks are associated with 16 bit command codes. On input the callback receives a buffer, containing the command's argument, the size of the command argument and the maximum size of the buffer. On output the callback stores processing result in the same buffer and updates the size to the actual amount of returned data. Callback descriptors are stored in a dedicated read only section which is scanned by extension_route_command() to find a callback associated with a certain command code. A console channel is also being introduced to allow controlling console output generated by extension commands handlers. BRANCH=none BUG=chrome-os-partner:47524 TEST=none yet Change-Id: I8ae16a78ca7d72176a5e7f74dd7a232078e7c06c Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/312586 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* tpm: add a console channel for TPM subsystemVadim Bendebury2015-07-251-0/+1
| | | | | | | | | | | | | With conditional compilation in place more channels can be created. BRANCH=none BUG=chrome-os-partner:43025 TEST=none yet Change-Id: Ia5aa5dba054b53adeabf7bd49d1111f65e87e924 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/287129 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* console: compile some channels in conditionallyVadim Bendebury2015-07-251-0/+6
| | | | | | | | | | | | | | | | As new features come along the console channel space limited at 32 becomes very tight. But not all features are present all the time. Let's make some of the channels compile time configurable. This makes for uglier code but allows to support more channels. BRANCH=none BUG=none TEST=make buildall -j Change-Id: Id21560d4aa05c0e5245872c50ae19340cda8fd3e Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/286610 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* cr50: Use distinct configuration option for SPI Slave supportVadim Bendebury2015-07-251-0/+1
| | | | | | | | | | | | | | | | | | | | SPI slave and master interfaces require very different code to support, they should have separate configuration options. Host command code printouts should use their own console channel. Using SPS to designate SPI Slave interface is not universally acceptable, a bug has been opened to discuss the alternatives and clean up the code. BRANCH=none BUG=chromium:512613 TEST=make buildall -j Change-Id: I6683286a221c4689ecc247fdfe8ebca529f3f458 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/286469 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* console: remove CC_USBMSGwendal Grignou2015-04-071-1/+0
| | | | | | | | | | | | | | | Mass storage has been removed by https://chromium-review.googlesource.com/238763 We can remove the USBMS entry from console.h BUG=chromium:474394 BRANCH=none TEST=make -j buildall Change-Id: Ic18f205eb49be411988ad47151b6de678d08355e Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/264420 Reviewed-by: Anton Staaf <robotboy@chromium.org>
* ensure all console channels are displaying properlyVincent Palatin2015-04-061-0/+2
| | | | | | | | | | | | | | | | | | If the number of console channels is greater than 32 (the bit size of the channel mask), the overflowing ones are silently masked. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=add one channel and see the build failing on the assert. Change-Id: I1793b22990be85882d80aae44503bba62358fbd2 Reviewed-on: https://chromium-review.googlesource.com/264062 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* Samus: Split motion sense and lid angleGwendal Grignou2014-10-291-0/+1
| | | | | | | | | | | | | | | Split motion_sense.c. Translate the accel data in the Android coordinate right away. BUG=chrome-os-partner:32002 BRANCH=ToT TEST=On samus, check lid angle are still correct. Change-Id: If743e25245dc1ce4cdacb8a4d5af22616c4a79e4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225486 Reviewed-by: Sheng-liang Song <ssl@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
* Samus: move gesture to commonGwendal Grignou2014-10-291-0/+1
| | | | | | | | | | | | | | | | Move gesture to common directory, 1st step to be reused by other board. Cleanup motion_sense shutdown path. BUG=chrome-os-partner:33102 TEST=Double tap still works on Samus BRANCH=ToT Change-Id: I0a3b38c4a7dbe95c27dcdebff04c1176aaf932d1 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225235 Reviewed-by: Sheng-liang Song <ssl@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
* usb: add support for mass storage (bulk-only)Dominic Chen2014-08-151-0/+1
| | | | | | | | | | | | | | implement USB mass storage class using the bulk-only transport protocol with the transparent SCSI command set. BRANCH=none BUG=none TEST=verify that usb mass storage functions on windows xp, 7, 8, mac os x, goobuntu precise Change-Id: Ideecad55bd275df7b30aa4a3ed263304a3a109cd Signed-off-by: Dominic Chen <ddchen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/206303 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* usb: add USB console driverVincent Palatin2014-07-171-6/+25
| | | | | | | | | | | | | | | | | Provide access to the EC console through 2 USB bulk endpoints. (which can be used through the usbserial driver) Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=run on Fruitpie and use the console over USB Change-Id: Ia897764f3a030972ee2ed323f293c5fca899765a Reviewed-on: https://chromium-review.googlesource.com/204167 Reviewed-by: Anton Staaf <robotboy@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org>
* samus: add retry mechanism for EC to PD host commandsAlec Berg2014-06-281-0/+1
| | | | | | | | | | | | | | | Add a retry mechanism for EC to PD host commands to make the communication channel more robust. BUG=none BRANCH=none TEST=run on system to verify that we don't drop host commands to PD MCU. Change-Id: Ida6f02a149e4dd9e85a5aac21790928b16864104 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/205148 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* stm32: add USB driverVincent Palatin2014-06-181-0/+1
| | | | | | | | | | | | | | | | | | Enough USB support to be able to enumerate the device and use bulk or interrupt endpoints. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28295 TEST=with the following USB console CL, connect a Fruitpie through USB and use its console over USB. Change-Id: I37b7f3b6a754cb82ab5f940ea20122d2e16b3b5b Reviewed-on: https://chromium-review.googlesource.com/193983 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* Add cprints() and ccprints()Vic Yang2014-05-211-0/+19
| | | | | | | | | | | | | | | | | | | | | 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>
* USB Power Delivery core codeVincent Palatin2014-04-121-0/+1
| | | | | | | | | | | | | | | | The protocol layer implementation for USB Power Delivery messaging. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=none Change-Id: I7db75b004cf9dbf13fa1df95336f206e93236fc9 Reviewed-on: https://chromium-review.googlesource.com/189866 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* rambi: glimmer: Disable key scanning in suspend when lid is openAlec Berg2014-03-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Added ability to disable the keyboard to wake from suspend when the lid is outside a certain angle range. This has been added to glimmer by defining CONFIG_LID_ANGLE_KEY_SCAN in its board.h. Also modified the lid angle calculation to include a reliability flag which can be used to tell when the hinge aligns too closely with gravity and the lid angle value is unreliable. BUG=none BRANCH=rambi TEST=Tested on a glimmer: In S3, verified that when the lid is open past ~180 deg, the keyboard does not wake the machine. Also verified that if you align hinge with gravity, the keyboard enabled/disabled status remains the same (since we can't actually trust the lid angle value). Change-Id: I45b2c7c3c4bbcae61d3a0f8b5baa461ab8dabfb0 Original-Change-Id: If1a1592d259902d38941936961854b81b3a75b95 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/190061 Reviewed-on: https://chromium-review.googlesource.com/191612 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* accel: clapper: glimmer: Add support for accelerometer interrupt.stabilize-5696.BAlec Berg2014-03-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Adding in support for accelerometer interrupt for use currently in clapper and glimmer. This is disabled by default and can be enabled with CONFIG_ACCEL_INTERRUPTS. BUG=none BRANCH=rambi TEST=Manual test on a glimmer using accelint console command. On console enter: accelint 0 32 When you tap the lid, it should fire the interrupt and print msg to console. accelint 1 32 Tap the base and it will fire another interrupt. Change-Id: Iaab324945e34d527140399ec4f06efd812a62840 Original-Change-Id: I0329112fdcae3c8adc0ca07e74fef7a591d4b9a1 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/190099 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/191549
* rambi: Add motion sense task to track motionAlec Berg2014-02-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added motion sense task to Clapper and Glimmer. This task samples the accelerometers and calculate a lid angle. Note that as the machine is rotated towards the hinge angle aligning with gravity, the lid calculation becomes less trustworthy. Added a math_util file to hold various mathematical functions useful for calculating lid angle that may be helpful in other places. For each board with accelerometers we need to define some orientation specific data in board.c. There is a calibration procedure through the EC console that can be enabled by defining CONFIG_ACCEL_CALIBRATE. The calibration procedure can help determine the orientation data required. For debugging purposes there is a console command to regularly print to the EC console the accelerometer data and derived lid angle. The console command can be enabled by defining CONFIG_CMD_LID_ANGLE. BUG=none Original-BUG=chrome-os-partner:24703 BRANCH=rambi TEST=Ran the calibration procedure on a Glimmer unit, and then rotated the machine in space. Verified that the lid angle calculated roughly matched actual lid angle. Original-Change-Id: I63a5e384b7f6b628b4ea01de49843355fb8d6ebe Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/184783 Reviewed-by: Randall Spangler <rspangler@chromium.org> Signed-off-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit efb07945a5159fa0e7a746c666b2519ebdca9c22) Conflicts: board/clapper/board.c board/clapper/ec.tasklist board/glimmer/board.c board/glimmer/ec.tasklist Change-Id: Ibc492ef5c11e7084e87f01338c4d7775f9a08c18 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/187433 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* cleanup: Comments in console_output.cRandall Spangler2013-10-251-4/+14
| | | | | | | | | | | | | | No code changes, just tidying some comments and moving a TODO to a bug. BUG=chrome-os-partner:23557 BRANCH=none TEST=compile any project; hey, this is just a change in comments. Change-Id: Ib1e3190ac9abdc90fb04c785e1f20b9cc66b1bc3 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/174447 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* lm4: Add a low power idle task.stabilize-4825.BAlec Berg2013-10-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | First implementation of a low power idle task for the LM4 chip. The low power mode is selected by defining CONFIG_LOW_POWER_IDLE in a board.h file. This commit turns it on for Peppy, Slippy, and Falco only because those are the only boards tested. When using the low power idle task, the chip goes in to deep sleep when it can. Deep sleep disables clocks to most peripherals and puts the onboard flash and RAM into a low power mode. The chip is woken out of deep sleep using the RTC in the hibernate module. Increased the idle task stack size to handle more involved idle task. In board.c, the array of GPIO info can be used to select which GPIO points can wake up the EC from deep sleep. Currenlty selected are the power button, lid open, AC present, PCH_SLP_S3, and PCH_SLP_S5. Additionally the port with the KB scan row GPIO point is also enabled to wake up the EC from deep sleep. Signed-off-by: Alec Berg <alecaberg@chromium.org> BUG=None BRANCH=none TEST=Passes all unit tests. Runs on slippy, peppy, and falco with no noticeable side affects. Verified that the power consumed by the EC is lower when in S3, S5 and G3 by scoping the sense resistor powering the chip. Change-Id: I83fa9a159a4b79201b99f2c32678dc4fc8921726 Reviewed-on: https://chromium-review.googlesource.com/172183 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org> Tested-by: Alec Berg <alecaberg@chromium.org>
* Fix console channel name listVic Yang2013-09-181-1/+3
| | | | | | | | | | | | | | | This adds back missing "hook" channel name. Also add a build assertion to make sure we don't miss this again. BUG=chrome-os-partner:21801 TEST=Build all boards. Remove "hook" channel and check build fails. BRANCH=None Change-Id: I373016504fd3753e1a791077d49b3af14b2b1aa4 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169703 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* console_output: Add commands for saving / restoring print mask.Shawn Nematbakhsh2013-08-081-13/+24
| | | | | | | | | | | | | | | | | | | | | | | Saving + restoring the channel print mask previously involved running the 'chan' command with no parameters, then parsing the output. This parsing is unreliable if other tasks are also writing to the console. Add commands to save / backup the current channel mask, and later restoring it. Typical method to limit channel mask will now be: chan save chan <mask> ... chan restore BUG=chromium:269758. TEST=Run 'chan save' / 'chan 0' / 'chan restore' on EC console, verify print mask is restored. BRANCH=Peppy/Falco. Change-Id: I725c7fb5e3ac7e55ed5f435446f8fc5c54af165f Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/65208 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Move files in preparation for merging keyboard_scan modulesRandall Spangler2013-03-271-1/+0
| | | | | | | | | | | | | | | | | | 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>
* Rename power_button module to switchRandall Spangler2012-10-301-1/+1
| | | | | | | | | | | | | | | Since it handles not just power button, but also lid switch, AC detect, and other switches. No functional changes; just renaming. BUG=chrome-os-partner:15579 BRANCH=none TEST=boot system, power on/off with power button Change-Id: I51628a52293f7207715f5f6bf368a08fe6c3dbce Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36821
* Clean up console moduleRandall Spangler2012-10-241-3/+1
| | | | | | | | | | | | Code cleanup and reformatting. No functional changes. BUG=chrome-os-partner:15579 BRANCH=none TEST=compile code; type a debug command like 'help list'. Change-Id: I641215ba3333628f658eec86d9d99718c43b111f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36387
* Add console channel for thermal outputRandall Spangler2012-10-101-0/+1
| | | | | | | | | | | | | Needed for debugging upcoming TMP006 calibration changes BUG=none TEST=boot; EC console output should appear as before BRANCH=link Change-Id: I93a18949888533ecefd226fdc64e1fab7d52a8f1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35187 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Simplify host event processingRandall Spangler2012-07-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Now both copies of the event state live in host_event_commands.c, and lpc / memmap just shadows the main copy. BUG=chrome-os-partner:11172 TEST=manual Boot system. should see events 0x2000, 0x80, 0x08 get set and then cleared. At U-boot prompt, type on keyboard. Should set event 0x1000 get set, but only on the first keypress (because U-boot doesn't consume that event). Then from EC console, hostevent clear 0x1000 -> see event 0x1000 clear hostevent clear 0x1000 -> no debug output (it's already clear) hostevent clearb 0x1000 -> see event copy B 0x1000 clear hostevent clearb 0x1000 -> no debug output (copy B is already clear) Change-Id: I855c035865649ba1490cd9027157d5bcdcc9895f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27321
* Split console output into its own moduleRandall Spangler2012-06-131-0/+114
No code changes, just rearranging source in preparation for an experiment to see how much the binary shrinks if we disable the interactive console. BUG=none TEST=none Change-Id: Ie21f1b3dcd04272e80fd40b2ed54d1eaf7fb1cdf Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/25232 Reviewed-by: Bill Richardson <wfrichar@chromium.org>