summaryrefslogtreecommitdiff
path: root/common/switch.c
Commit message (Collapse)AuthorAgeFilesLines
* Update license boilerplate text in source code filesMike Frysinger2022-09-121-1/+1
| | | | | | | | | | | | | | | Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BRANCH=none BUG=chromium:1098010 TEST=`repo upload` works Change-Id: Icd3a1723c20595356af83d190b2c6a9078b3013b Signed-off-by: Mike Frysinger <vapier@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3891203 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* tree-wide: const-ify argv for console commandsCaveh Jalali2022-09-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | This updates the API for console commands from "int cmd(int argc, char **argv)" to "int cmd(int argc, const char **argv)" which is more accurate and in line with common convention. BRANCH=none BUG=b:244387210 TEST="make buildall" passes TEST="zmake build -a" passes TEST="util/compare_build.sh -b all" passes TEST="./twister -v -T zephyr/test" passes Cq-Depend: chrome-internal:4960125 Cq-Depend: chrome-internal:4959932 Change-Id: I57de9f35b85b8f3c7119df36aefb2abf25d2625f Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3863941 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* common/switch.c: Format with clang-formatJack Rosenthal2022-06-291-9/+4
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: I4a9738b6283499e4c52d11f2cbe9b38f5ea9ea91 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729752 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* write protect: extract checking write protectDawid Niedzwiecki2022-02-111-5/+2
| | | | | | | | | | | | | | | | | | | | | | The write-protect state can be checked on 2 pins GPIO_WP or GPIO_WP_L. The CONFIG_WP_ACTIVE_HIGH config is used to distinguish these two cases. Move the checking the config and pin state to a separate header file. For Zephyr, start using the gpio_get_level function that takes into account the GPIO_ACTIVE_LOW flag. Also, use 'gpio-wp' alias to the WP pin instead of the legacy enum-name property and 'int-wp' alias to the WP GPIO interrupt. BUG=b:211779766 TEST=zmake testall & make sure WP works BRANCH=main Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I70bfbcd5e539fcc8cd157f2feae1a6c8e25083a4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3447404 Reviewed-by: Andrew McRae <amcrae@google.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* include/flash: rename the APIsTim Lin2021-06-091-1/+1
| | | | | | | | | | | | | | | | The names conflict when enabling both Zephyr's flash driver and CONFIG_FLASH_CROS option. Rename all the APIs in include/flash.h BUG=b:187192628 BRANCH=none TEST=make buildall -j4 Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com> Change-Id: If1fd0ea28fa9f5cec1c1daa8f72f63eb7a0e6500 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2931749 Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* switch: cleanup lid_is_open logicJack Rosenthal2021-03-251-6/+1
| | | | | | | | | | | | | | | Cleanup an ifdef here for systems without a lid switch, so that "lid looks open" is just a consequence of !IS_ENABLED(CONFIG_LID_SWITCH). BUG=none BRANCH=none TEST=buildall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I1bbc145a0ffb49a127cb5a4e3986ed0955381353 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2787588 Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@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>
* common: bit change 1 << constants with BIT(constants)Gwendal Grignou2019-03-261-1/+1
| | | | | | | | | | | | | | | | | Mechanical replacement of bit operation where operand is a constant. More bit operation exist, but prone to errors. Reveal a bug in npcx: chip/npcx/system-npcx7.c:114:54: error: conversion from 'long unsigned int' to 'uint8_t' {aka 'volatile unsigned char'} changes value from '16777215' to '255' [-Werror=overflow] BUG=None BRANCH=None TEST=None Change-Id: I006614026143fa180702ac0d1cc2ceb1b3c6eeb0 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1518660 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Allow lid-less configurationDaisuke Nojiri2017-05-091-0/+5
| | | | | | | | | | | | | | | | | | | power_button_x86.c and switch.c assume there is a lid switch. This patch separate them so that a board with power button but with no lid can be configured properly. This patch also moves backlight control to the board directory so that only the boards with a backlight turn it on/off when power state changes. BUG=none BRANCH=none TEST=boot fizz. make buildall. Change-Id: If4070cdc4b1221fae68b35ec3497335d81f192fd Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/489602 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* switch: Initialize switch state earlier during HOOK_INITShawn Nematbakhsh2017-03-021-1/+1
| | | | | | | | | | | | | | | | | | | | The host may ask for our switch state at any time, so do initialization immediately after lid + power button are initialized. BUG=chrome-os-partner:63073 BRANCH=gru TEST=On kevin, verify system boots when EC reset is triggered with lid open. Verify lid close and power button press still succeed to power-down from dev screen. Change-Id: I8e37c02ef4f4d2d7c06beb383cdbda8eea67bc5c Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/444322 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 106d33cd3a8e4f3356950a3b2b92ea587977b4e7) Reviewed-on: https://chromium-review.googlesource.com/445276 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org>
* kevin / gru: Reduce SRAM footprintShawn Nematbakhsh2017-02-131-1/+2
| | | | | | | | | | | | | | | Remove console commands and add CONFIG options to reduce RAM usage. BUG=chrome-os-partner:54099 BRANCH=gru TEST=Verify charge_ramp CONFIG + task builds for gru. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I2d7bc77d1fc032c6cb75eb1ec8d13dacb676658d Reviewed-on: https://chromium-review.googlesource.com/437662 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@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>
* Deferred: Use deferred_data instead of function pointerAnton Staaf2016-04-181-1/+1
| | | | | | | | | | | | | | | | | | | | | Previously calls to hook_call_deferred were passed the function to call, which was then looked up in the .rodata.deferred section with a linear search. This linear search can be replaced with a subtract by passing the pointer to the deferred_data object created when DECLARE_DEFERRED was invoked. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None CQ-DEPEND=CL:*255812 TEST=make buildall -j Change-Id: I951dd1541302875b102dd086154cf05591694440 Reviewed-on: https://chromium-review.googlesource.com/334315 Commit-Ready: Bill Richardson <wfrichar@chromium.org> Tested-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Add cprints() and ccprints()Vic Yang2014-05-211-2/+2
| | | | | | | | | | | | | | | | | | | | | 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>
* cleanup: Even more TODO commentsRandall Spangler2013-11-011-2/+3
| | | | | | | | | | | | | | | Update comments with more info, or remove if no longer applicable. No code changes. BUG=chrome-os-partner:18343 BRANCH=none TEST=build all platforms; pass unit tests Change-Id: I5b56eeb500bc0f00e84e91ef99684f4b1b310972 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/175418 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Make support for dedicated recovery GPIO signal optionalRandall Spangler2013-09-251-0/+4
| | | | | | | | | | | | | | | | | | switch.c currently assumes that all boards have GPIO_RECOVERY_L. This is not true for Rambi, and also isn't true for ARM boards (which should also eventually use the common switch implementation). Add a new CONFIG_SWITCH_DEDICATED_RECOVERY option to control whether to compile this support. BUG=chrome-os-partner:22893 BRANCH=none TEST=compile all boards; pass unit tests Change-Id: If6f34d1afd580c9d79a8edcdda18833068e70f66 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/170489 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Move switch module from chip/lm4 to commonRandall Spangler2013-07-171-0/+123
There's nothing LM4-specific about the switch module; it's just checking GPIOs and updating a memory-mapped register. No code changes; just moving a file. BUG=chrome-os-partner:18343 BRANCH=none TEST=verify switch.c is compiled for link and falco, but not pit or spring Change-Id: I186f3aac1405c7ba8d94b47bb2586c2ad191daba Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/61930