summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* panic output: remove assertfirmware-grunt-11031.BBoris Mittelberg2023-03-222-3/+13
| | | | | | | | | | | | | | | | | | | Remove assert to avoid nested panic while getting panic info. Truncate panic data to maximal supported size. BRANCH=none BUG=b:254485444 TEST=./twister -p native_posix -p unit_testing --coverage Signed-off-by: Boris Mittelberg <bmbm@google.com> Change-Id: Ibcf3c0244b159578b6c51c80eec23453522059df Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3975601 Reviewed-by: Ricardo Quesada <ricardoq@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> (cherry picked from commit 0a031be7f2ca6b9f11f0085cb22960d7780ee4a4) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4329105 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org>
* baseboard: enable powered of PP1 and PP2 for port 1amber.chen2023-01-101-0/+9
| | | | | | | | | | | | | | | | | | | | | | | Due to in Treeya360 project add "#undef CONFIG_HIBERNATE_PSL" this configuration, so PPC1 remains powered during hibernate. PPC1 therefore now needs to be configured the same way as PPC0, to mimic the previous dead-battery behavior and allow wake on AC plug. BRANCH=none BUG=b:259211176 TEST=make buildall -j48 Change-Id: Ie353a3f3ca118dd94a2131d8ea62ddf5ee12c470 Signed-off-by: amber.chen <amber.chen@lcfc.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4119878 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Zhuohao Lee <zhuohao@chromium.org> (cherry picked from commit 950c21ed4d0181029653bfebabcbfc990c1757d3) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4140778 Reviewed-by: YH Lin <yueherngl@chromium.org> Commit-Queue: YH Lin <yueherngl@chromium.org>
* Battery: Apply fake SoC to display chargeDaisuke Nojiri2022-09-132-6/+7
| | | | | | | | | | | | | | | | | This patch makes the battfake command apply the fake SoC to the display SoC as well as the raw battery SoC. This patch also cleans up battery_compensate_params. BUG=None BRANCH=None TEST=Atlas Change-Id: Ifbdaa81204d27501df8a4f5e025c19a79d62feff Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2994748 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872714
* Battery: Apply faked state of charge to remaining capacityDaisuke Nojiri2022-09-131-6/+22
| | | | | | | | | | | | | | | | | | Currently, only the state of charge is modified by battfake command. This patch applies the faked state of charge to the remaining capacity as well. BUG=b:163721887 BRANCH=Octopus TEST=Verified Fleex wakes up host on BATTERY_LEVEL_CRITICAL. TEST=Verified powerd reports faked state of charge. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I34eb409bab129804a983abbe2a1d021298ce044e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432865 Reviewed-by: Todd Broch <tbroch@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872713 Reviewed-by: Jett Rink <jettrink@chromium.org>
* chgstv2: Unify power-on and shutdown battery thresholdsDaisuke Nojiri2022-09-1329-66/+2930
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, power-on battery SoC and shutdown battery SoC are independently configured by each board. This patch will unify the setting as follows: CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON = 2 (don't boot if soc < 2%) CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE = 2 (shutdown if soc <= 2%) BATTERY_LEVEL_SHUTDOWN = 3 (shutdown if soc < 3%) CONFIG_BATTERY_EXPORT_DISPLAY_SOC = Y (removed) CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC = 1 This allows us to show the low battery alert whenever we can because EC doesn't inhibit power-on even if it knows the host would immediately shut down. With CONFIG_BATTERY_EXPORT_DISPLAY_SOC, boards will start using the CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE = 2% as the low battery threshold (and the SoC will be agreed between the EC and Powerd). Boards with CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON = 1 will keep the same threshold. This is for avoiding degrading the UX by increasing the power-on threshold (even though a question that 1% may not be enough for soft sync to finish consistently remains to be answered). Boards with CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON > 2 will have a lower threshold but we think 2% is enough to finish the software sync. A lower threshold also improves the UX by showing the low battery alert in the situation where otherwise the system would leave the user uninformed by not responding to a power button press. BUG=b:191837893 BRANCH=None TEST=buildall Change-Id: If6ff733bc181f929561a3fffb8a84e760668ce37 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2981468 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872712
* Battery: Add command to export display SoCDaisuke Nojiri2022-09-133-13/+92
| | | | | | | | | | | | | | | | | | | | | | | Currently, CrOS EC passes the battery remaining capacity (mAh) and the full capacity (mAh) through ACPI to the AP so that the host can calculate the battery SoC. The host further manipulates the SoC to get the display SoC, which is used to determine user visible behaviors. To get consistent behaviors in all power states, this change enables the EC to send the display SoC to the host via EC_CMD_DISPLAY_SOC command. The Powerd's part is I5bd1371f2569d21d55df1b50a3d709b98bbf0325. BUG=b:174433637, b:181506409, b:80270446, b:109954565 BRANCH=dedede, trogdor, nami, hatch TEST=Storo, CoachZ Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Idc6992625d992a73be141987d02ed220508d3b74 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2853142 Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872711
* Battery: Make battery command print display percentageDaisuke Nojiri2022-09-131-1/+8
| | | | | | | | | | | | | | | | | | | | | This patch make battery console command print display percentage and compensated full capacity. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:109954565,b:80270446 BRANCH=none TEST=Verify display percentage and compensated full capacity are printed on Sona. Change-Id: Idc8ee063249fd0937209c8cb32aee59ee3598258 Reviewed-on: https://chromium-review.googlesource.com/1313475 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872710 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org>
* kodama: overwrite bad battery params to known good valueTing Shen2022-09-135-0/+241
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Kodama's bitbang driver fails randomly, and there's no way to notify kernel side that bitbang read failed (batt->flags does not propagate into kernel). Thus, if any value in batt_params is bad, replace it with a cached good value, to make sure we never send random numbers to kernel side. BUG=b:144195782 TEST=Modify smart battery driver to make sb_read has 50% fail rate, and monitor /sys/class/power_supply/sbs*/*, make sure the bad values does not observable in kernel. BRANCH=kukui Change-Id: Idf4691eb743f1ef785593b308b8f07a34e5ea642 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1943637 Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872709 Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* battery: Update the default powerd's full factor valueWai-Hong Tam2022-09-131-2/+3
| | | | | | | | | | | | | | | | | | | | Use the same default value as powerd, i.e. 97% instead of 94%. The value comes from: src/platform2/power_manager/default_prefs/power_supply_full_factor BRANCH=None BUG=b:162604872 TEST=Checked EC showing the same Display percentage as the UI. Change-Id: Ia8547915251ea80bc663b5f15435060acacf9021 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2335887 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872708 Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* battery: Calculate the display charge percentageWai-Hong Tam2022-09-132-11/+14
| | | | | | | | | | | | | | | | | It doesn't require the powerd's full factory to be 100%. Also refine the comment on the powerd's equation to make it more understandable. BRANCH=None BUG=b:162604872 TEST=With the follower CL which updates the powerd's full factor value, checked EC showing the same Display percentage as the UI. Change-Id: I50ae7c38c423722188d892f91f4fc93d4d5f84e1 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872707 Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* battery: Remove redundant lfcc variable when calculate compensationWai-Hong Tam2022-09-131-8/+4
| | | | | | | | | | | | | | | | | | | The value of lfcc variable, which is copied from host_get_memmap(EC_MEMMAP_BATT_LFCC), is actually the compensated full capacity. Use the value of *full directly. BRANCH=None BUG=b:162604872 TEST=Checked the battery console command result. Change-Id: Iae103dd325679333c524698ce7a86cdc96a3587e Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2335885 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872706 Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* battery: Simplify the compensation logic by using pointersWai-Hong Tam2022-09-131-10/+8
| | | | | | | | | | | | | | | | | | Simplify the logic by using pointers, instead of copying the values from and to other variables. No behavior changes. BRANCH=None BUG=b:162604872 TEST=Checked the sysfs battery info. Change-Id: I2dafd0c774354bbf563be121a8bf9d65f1d4dfd3 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2335884 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872705 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Battery: Use host full capacity to compute display percentageDaisuke Nojiri2022-09-133-17/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | The full capacity known by the host may slightly differ from the full capacity known by the EC because we notify the host of the new capacity only if the difference is larger than 5 mAh. This patch makes the EC use the host's full capacity instead of the local full capacity to compute the display percentage. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:109954565,b:80270446 BRANCH=none TEST=Verify display percentages printed by EC and power_supply_info move up synchronously on charge and the LED and the taskbar icon turn to full at the same time. TEST=buildall Change-Id: Ie695a9937a22fc7a769b82448f4600d4491935b3 Reviewed-on: https://chromium-review.googlesource.com/1330101 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872564 Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* common/battery: Avoid negative display percentagesEvan Green2022-09-131-0/+2
| | | | | | | | | | | | | | | | | | | | | Battery charges less than batt_host_shutdown_pct cause the display charge to go negative. This looks silly in EC console prints: [38.474266 Battery 2% (Display -2.-7 %) / 3h:15 to full] BUG=b:134586427 BRANCH=None TEST=Run kohaku down to low battery, observe display stays at 0. Change-Id: If8eb477b8bb21451069bac5c1474b7a408b30582 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1650136 Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872563 Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Battery: Apply full factor to full capacityDaisuke Nojiri2022-09-132-11/+14
| | | | | | | | | | | | | | | | | | | | | | | This change introduces CONFIG_BATT_HOST_FULL_FACTOR. If it's 100, meaning no compensation, we multiply full capacity by CONFIG_BATT_FULL_FACTOR. This makes the rest of the system see consistent charge percentage behavior. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:109954565,b:80270446 BRANCH=none TEST=Verify display percentages printed by EC and power_supply_info move up synchronously on charge and turns to full at the same time. Change-Id: Ifb27c802b0cf04195ac5b426c13f9476189feb75 Reviewed-on: https://chromium-review.googlesource.com/1313468 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872562 Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* chgstv2/sustainer: Stop AC current when dischargingDaisuke Nojiri2022-09-132-8/+80
| | | | | | | | | | | | | | | | | | | | Currently, the battery sustainer discharges the battery using CHARGE_CONTROL_IDLE, which uses the AC current and stops the current from the battery. With this change, when lower < upper, the sustainer discharges using DISCHARGE. When lower == upper, the sustainer discharges using IDLE. BUG=b:188457962 BRANCH=None TEST=run-sbs_charging_v2 Change-Id: I4af31eff488bc9cfa627f84994b685488c3c9061 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3049290 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Derek Basehore <dbasehore@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3869647
* chgstv2/sustainer: Add tests for full battery and ACDaisuke Nojiri2022-09-132-16/+64
| | | | | | | | | | | | | | | | | | Currently, unit tests do not check whether the battery sustainer can be enabled when the battery is already full or when the AC is already present. This patch adds tests which check the battery sustainer can be enabled when the battery is already full or when the AC is already present. BUG=b:188457962 BRANCH=None TEST=run-sbs_charging_v2 Change-Id: I4ec9785554d126baca0b60e889c4a2dabbfb628a Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3869646 Reviewed-by: Jett Rink <jettrink@chromium.org>
* chgstv2: call sustain_battery_soc without checking previous statesTommy Chung2022-09-131-1/+4
| | | | | | | | | | | | | | | | | | | | | | When we enalbe battery sustain after battery returns that it is full, we need to add this condition for sustain_battery_soc(). Also, add this test condition for battery sustainer. BUG=b:188457962 BRANCH=none TEST=make sure the battery sustain works when enabling it after battery returns that it is full. Also, make sure that "make run-sbs_charging_v2" pass. Signed-off-by: Tommy Chung <tommy.chung@quanta.corp-partner.google.com> Change-Id: If10b9fd0264717abfb7cdbb7ddc947b370291895 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3070946 Reviewed-by: Devin Lu <Devin.Lu@quantatw.com> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3869645 Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org>
* chgstv2: Add unit test for battery sustainerDaisuke Nojiri2022-09-132-20/+107
| | | | | | | | | | | | | | | This patch adds a unit test for the battery sustainer. BUG=b:188457962 BRANCH=None TEST=make run-sbs_charging_v2 Change-Id: Ica227cf4ee3f71a746150fb6a5f4e40ab8ca0720 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2987734 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3869644 Reviewed-by: Jett Rink <jettrink@chromium.org>
* chgstv2: Add battery sustainerDaisuke Nojiri2022-09-131-3/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the battery sustainer. Given a target SoC by the host, the sustainer will try to keep the SoC stay close within the range near the target. The diagram below shows how the sustainer uses the charge mode to charge or discharge the battery as the SoC moves near the target: T-d% T% ----------|----------------------|----------- charge normally charge normally/slowly (mode=NORMAL) ... ----> +---------------------> | | <----------------------+ <----- ... discharge naturally discharge normally (mode=IDLE) (mode=DISCHARGE) When AC is unplugged, the sustainer is disabled. Currently, the sustainer requires CONFIG_CHARGER_DISCHARGE_ON_AC. > chgstate state_of_charge = 69% chg_ctl_mode = NORMAL manual_voltage = -1 manual_current = -1 Battery sustainer = off (-1% ~ -1%) > chgstate sustain 70 72 state_of_charge = 69% chg_ctl_mode = NORMAL manual_voltage = -1 manual_current = -1 Battery sustainer = on (70% ~ 72%) > battfake 71 > chgstate state_of_charge = 71% chg_ctl_mode = NORMAL > battfake 73 > chgstate state_of_charge = 73% chg_ctl_mode = DISCHARGE manual_voltage = -1 manual_current = -1 > battfake 71 > chgstate state_of_charge = 71% chg_ctl_mode = IDLE manual_voltage = 0 manual_current = 0 Unplug AC and EC keeps running. > chgstate state_of_charge = 73% chg_ctl_mode = DISCHARGE manual_voltage = -1 manual_current = -1 Replug AC. > chgstate state_of_charge = 73% chg_ctl_mode = DISCHARGE manual_voltage = 0 manual_current = 0 BUG=b:188457962 BRANCH=None TEST=Atlas. See the description above. Change-Id: I62b4e8bc9517900a5a32d2f35369c645fa8a60c3 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2929347 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3869323 Reviewed-by: Jett Rink <jettrink@chromium.org>
* charge_state_v2: Move the first battery_get_params to HOOK_INITWai-Hong Tam2022-09-131-1/+5
| | | | | | | | | | | | | | | | | | | | | | Other tasks read the params like state_of_charge at the beginning of their tasks. In the existing code, the first battery_get_params is called at the beginning of the charger task. It is not guaranteed the battery params are ready. This change moves it to the HOOK_INIT. BRANCH=None BUG=b:169453974 TEST=Cut off the battery, checked the first boot has PD-enabled, which uses the battery state_of_charge param to make the decision. Change-Id: Ie7bd31ee71fb3d1ea47a31910f0dfa7ac93cbcef Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2436760 Tested-by: Nitin Kolluru <nkolluru@google.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3869322 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* chgstv2: Notify on display percentage changeDaisuke Nojiri2022-09-132-5/+21
| | | | | | | | | | | | | | | | | | | | | | | | This patch makes the charger task v2 notify HOOK_BATTERY_SOC_CHANGE handlers when the display charge percentage changes. This allows EC to update LEDs synchronously to the number on the display. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:109954565,b:80270446 BRANCH=none TEST=Verify charge LED changes to white (full) on Sona synchronously to the display percentage. TEST=Verify charge LED changes to blinking white (low) on Sona within 30 seconds synchronously to the display percentage. Change-Id: Ib2c587ad3307fe62b268a25a93344c88c6c137f3 Reviewed-on: https://chromium-review.googlesource.com/1309034 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3869321 Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* Update EC_CMD_CHARGE_CONTROL to version 2Daisuke Nojiri2022-09-134-10/+190
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Version 2 of EC_CMD_CHARGE_CONTROL can control battery sustainer. It allows the host to set the upper and lower thresholds between which the EC tries to keep the battery state of charge. Version 2 of EC_CMD_CHARGE_CONTROL also supports 'GET' request. It allows the host to query the current charge control settings. localhost ~ # ectool chargecontrol Charge mode = NORMAL (0) Battery sustainer = off (-1% ~ -1%) localhost ~ # ectool chargecontrol normal 66 66 Charge state machine is in normal mode with sustainer enabled. localhost ~ # ectool chargecontrol Charge mode = NORMAL (0) Battery sustainer = on (66% ~ 66%) localhost ~ # ectool chargecontrol normal Charge state machine is in normal mode. BUG=b:188457962 BRANCH=none TEST=Atlas. See above. Change-Id: I81ec62172b4f159c46334fc0f940a2adae3f2b8a Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2929340 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3869320 Reviewed-by: Jett Rink <jettrink@chromium.org>
* chgstv2: Refactor charger_discharge_on_acDaisuke Nojiri2022-09-132-29/+38
| | | | | | | | | | | | | | | | | This patch makes charger_discharge_on_ac call board_discharge_on_ac. It also makes set_chg_ctrl_mode call charger_discharge_on_ac. This makes sense since when the charge control mode changes, discharge-on-ac also needs to be enabled or disabled. BUG=b:188457962 BRANCH=none TEST=make runhosttests Change-Id: I65ec09f580afc987cc86f4c60c15c1f90ead6c3c Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2986848 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3869319 Reviewed-by: Jett Rink <jettrink@chromium.org>
* Battery: Get display charge percentageDaisuke Nojiri2022-09-133-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | This patch converts the actual battery charge to the display percentage using the same conversion used by Powerd. EC can use this number to control LEDs synchronously to the value on the display. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:109954565,b:80270446 BRANCH=none TEST=Verify charge LED changes to white (full) on Sona synchronously to the display percentage. TEST=Verify charge LED changes to blinking white (low) on Sona within 30 seconds synchronously to the display percentage. Change-Id: I2041cb768dee27b8dba94a32db0eb62dfa14c73b Reviewed-on: https://chromium-review.googlesource.com/1309033 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3869318 Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* Battery: Compensate remaining charge to match full capacityDaisuke Nojiri2022-09-125-0/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If remaining charge is more than x% of the full capacity, the remaining charge is raised to the full capacity before it's reported to the rest of the system. Some batteries don't update full capacity timely or don't update it at all. On such systems, compensation is required to guarantee the remaining charge will be equal to the full capacity eventually. On some systems, Rohm charger generates audio noise when the battery is fully charged and AC is plugged. A workaround is to do charge- discharge cycles between 93 and 100%. On such systems, compensation was also applied to mask this cycle from users. This used to be done in ACPI, thus, all software components except EC was able to see the compensated charge. This patch is moving the logic to EC. With this and the following changes, EC can see what the rest of the system sees, thus, can control LEDs synchronously (to the display percentage). Another rationale of this move is EC can perform more granular and precise compensation than ACPI since it has more knowledge about the battery and the charger. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> CQ-DEPEND=CL:3880010 BUG=b:109954565,b:80270446 BRANCH=none TEST=Verify charge LED changes to white (full) on Sona synchronously to the display percentage. TEST=Verify charge LED changes to blinking white (low) on Sona within 30 seconds synchronously to the display percentage. Change-Id: I4e3f70efa39e62c91cb8894b603c551cd23511aa Reviewed-on: https://chromium-review.googlesource.com/1312204 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3869317 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* treeya: add psl code back for some sku requestarthur.lin2022-02-261-2/+96
| | | | | | | | | | | | | | | | | | | Add the the PSL code to the treeya's board.c file, and use sku id to distinguish for enter PSL or not. BUG=b:214155147 BRANCH=None TEST=make buildall -j In Treeya360, keep KSI1, KSI2, and KSI3 on when system in hibernate Cq-Depend: chromium:3325632 Signed-off-by: arthur.lin <arthur.lin@lcfc.corp-partner.google.com> Change-Id: I9877bda5024964e83797cdf2cb6301c59886d68f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3384980 Reviewed-by: Martin Roth <martinroth@google.com> Commit-Queue: Martin Roth <martinroth@google.com> (cherry picked from commit eecb83f9ba22f7c65d054dbdc6d0c2b16fe7f7dd) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3487375
* treeya: undef hibernate psl and keep KSI1/3 high in deep sleepreno.wang2022-02-252-0/+19
| | | | | | | | | | | | | | | | | | | | | | | It's workaround to reduce keyboard's "Silver Migration". From keyboard vendor's feedback, there are two factors to cause "Silver Migration". 1. A voltage potential between trace 2. The presence of an electrolyte , such as moisture. The reason cause voltage potential between KSIxx trace is EC enter ec hibernate PSL and turn EC's VCC1 power off. Besides KSI2, the other KSIxx will be turn off. KSI2 is powered by H1. To avoid voltage potential is keep KSI1, KSI2, and KSI3 on. That means not to enter ec hibernate PSL. BUG=b:214155147 BRANCH=None TEST=make -j BOARD=treeya, KSIxx keep 3.3V under DC mode after calling system_hibernate(). Signed-off-by: reno.wang <reno.wang@lcfc.corp-partner.google.com> Change-Id: I36c9d945a836ad54aa33d5af02d3a69ae57f1d29 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3325632 Reviewed-by: Martin Roth <martinroth@google.com>
* treeya: add skuid 0xbe, 0xbf for treeya360arthur.lin2021-09-151-2/+5
| | | | | | | | | | | | | | | | | | Add skuid 0xbe(190), 0xbf(191) for treeya360 new audio codec sku. BRANCH=grunt BUG=b:185972050 TEST=make buildall -j Signed-off-by: arthur.lin <arthur.lin@lcfc.corp-partner.google.com> Change-Id: I8d9fb10af1d4ec5abb146561172180c23d327226 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3088958 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Yu-Hsuan Hsu <yuhsuan@chromium.org> Commit-Queue: Yu-Hsuan Hsu <yuhsuan@chromium.org> (cherry picked from commit 721b08706da83d59100c06be1da5a8a853e2597a) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3105910
* Clear OWNERS for factory/firmware branchBrian Norris2021-09-102-10/+1
| | | | | | | | | | | | BUG=none TEST=none Change-Id: I0f03f432ada1064ffba9595be78ca7ab4d25ecd1 Signed-off-by: Brian Norris <briannorris@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3155183 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Owners-Override: Jora Jacobi <jora@google.com> Tested-by: Jack Rosenthal <jrosenth@chromium.org>
* careena: Deassert PROCHOT on sysjumpEdward Hill2021-07-091-0/+14
| | | | | | | | | | | | | | | | | The GPIO was an input in old RO images. On sysjump to new RW, the direction is changed to output but the level is not set, which results in the output driving low, which asserts PROCHOT incorrectly. BUG=chromium:1226694 b:185082703 BRANCH=grunt TEST=check PROCHOT is high after sysjump from old RO Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I81e6237d2643c58fa15672987b6ac815cbcd8211 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3016409 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit e53eff67bebfdddcfd6ebb8d6ab468509fa340fc) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3017595
* careena: Add thermal protectionDevin Lu2021-04-193-1/+23
| | | | | | | | | | | | | | | | This patch adds thermal protection to prevent AP runaway. BUG=b:185082703 BRANCH=firmware-grunt-11031.B TEST=Verify thermal halt/alert as expected. Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Change-Id: I4fccc93b0cb89a2e5d2784dfc0a41aa866f691f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2822269 Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org> (cherry picked from commit 0d11b2f71e40e0147cc1dfc0a53b76758d318c77) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2834496
* Mordin: Add one more SKUIDsDevin Lu2021-03-121-0/+1
| | | | | | | | | | | | | | BUG=b:171755306 BRANCH=firmware-grunt-11031.B TEST=make buildall -j Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Change-Id: I45830335545206f665e84866e0b11a2c666d0101 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2752572 Reviewed-by: Edward Hill <ecgh@chromium.org> (cherry picked from commit 01e7c7cc367f1e17804640f7820f071738b2f83a) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2755353 Commit-Queue: Edward Hill <ecgh@chromium.org>
* Reland "aleena: Add detect accel/gyro sensor in HOOK_INIT"David Huang2021-02-041-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit e5fa7fc82639d619b7a53db6b8b94117c857014e. Reason for revert: Add include "adc.h" to fix build error. Need this change when sysjump rw and make sure ec get correct sku_id from adc. Original change's description: > Revert "aleena: Add detect accel/gyro sensor in HOOK_INIT" > > This reverts commit 103e253e60bb6e37278eb13ac880f172d6941358. > > Reason for revert: build fails on firmware-grunt-11031.B branch: > board/aleena/board.c:163:204: error: 'HOOK_PRIO_INIT_ADC' undeclared here (not in a function) > > Original change's description: > > aleena: Add detect accel/gyro sensor in HOOK_INIT > > > > Add detect accel/gyro sensor in HOOK_INIT for sysjump rw. > > Use "HOOK_PRIO_INIT_ADC + 2" For sku_id checking. > > And make sure detect sensor when chipset power on. > > > > BUG=none > > BRANCH=grunt > > TEST=sysjump ro/rw to check motionsense data. > > > > Signed-off-by: David Huang <david.huang@quanta.corp-partner.google.com> > > > > Change-Id: I143cde2ab3028ec5658acd16fdb6ec6aae710ef6 > > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2655305 > > Tested-by: David Huang <david.huang@quanta.corp-partner.google.com> > > Auto-Submit: David Huang <david.huang@quanta.corp-partner.google.com> > > Reviewed-by: YH Lin <yueherngl@chromium.org> > > Reviewed-by: Keith Short <keithshort@chromium.org> > > Commit-Queue: David Huang <david.huang@quanta.corp-partner.google.com> > > (cherry picked from commit 8801fd7768c8b8436bd0282af71cdd449257c08a) > > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2662223 > > Commit-Queue: Keith Short <keithshort@chromium.org> > > Bug: none > Change-Id: I2cf8d24b2a41f715293b4a08ef11833e2320ce73 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2674380 > Reviewed-by: Edward Hill <ecgh@chromium.org> > Commit-Queue: Edward Hill <ecgh@chromium.org> > Tested-by: Edward Hill <ecgh@chromium.org> Bug: none Change-Id: Ic981032a15ec87ec611fd62ccc7bc9c8996cde66 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2673584 Tested-by: David Huang <david.huang@quanta.corp-partner.google.com> Auto-Submit: David Huang <david.huang@quanta.corp-partner.google.com> Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org>
* Revert "aleena: Add detect accel/gyro sensor in HOOK_INIT"Edward Hill2021-02-041-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 103e253e60bb6e37278eb13ac880f172d6941358. Reason for revert: build fails on firmware-grunt-11031.B branch: board/aleena/board.c:163:204: error: 'HOOK_PRIO_INIT_ADC' undeclared here (not in a function) Original change's description: > aleena: Add detect accel/gyro sensor in HOOK_INIT > > Add detect accel/gyro sensor in HOOK_INIT for sysjump rw. > Use "HOOK_PRIO_INIT_ADC + 2" For sku_id checking. > And make sure detect sensor when chipset power on. > > BUG=none > BRANCH=grunt > TEST=sysjump ro/rw to check motionsense data. > > Signed-off-by: David Huang <david.huang@quanta.corp-partner.google.com> > > Change-Id: I143cde2ab3028ec5658acd16fdb6ec6aae710ef6 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2655305 > Tested-by: David Huang <david.huang@quanta.corp-partner.google.com> > Auto-Submit: David Huang <david.huang@quanta.corp-partner.google.com> > Reviewed-by: YH Lin <yueherngl@chromium.org> > Reviewed-by: Keith Short <keithshort@chromium.org> > Commit-Queue: David Huang <david.huang@quanta.corp-partner.google.com> > (cherry picked from commit 8801fd7768c8b8436bd0282af71cdd449257c08a) > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2662223 > Commit-Queue: Keith Short <keithshort@chromium.org> Bug: none Change-Id: I2cf8d24b2a41f715293b4a08ef11833e2320ce73 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2674380 Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org> Tested-by: Edward Hill <ecgh@chromium.org>
* grunt: Disable SBU on hibernateEdward Hill2021-02-031-0/+7
| | | | | | | | | | | | | | | | | If CCD not active, set port 0 SBU_EN=0 to avoid power leakage during hibernation. BUG=b:175674973 BRANCH=grunt TEST=no power leakage during hibernate Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I05b8079aebc1282b9bb955bbf153c0fc2399bee1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2668063 Tested-by: Peichao Wang <pwang12@lenovo.corp-partner.google.com> Reviewed-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Peichao Wang <pwang12@lenovo.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2643589
* aleena: Fix aleena accel icm matrix.David Huang2021-02-021-1/+1
| | | | | | | | | | | | | | Fix aleena accel icm matrix. BUG=None BRANCH=grunt TEST=Check CTS-V accelerometer measurement tests pass. Signed-off-by: David Huang <david.huang@quanta.corp-partner.google.com> Change-Id: Ic340aa5df4e4121986c99828ac3a88b8ac68708f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2666546 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* aleena: Add detect accel/gyro sensor in HOOK_INITDavid Huang2021-02-011-0/+3
| | | | | | | | | | | | | | | | | | | | | | | Add detect accel/gyro sensor in HOOK_INIT for sysjump rw. Use "HOOK_PRIO_INIT_ADC + 2" For sku_id checking. And make sure detect sensor when chipset power on. BUG=none BRANCH=grunt TEST=sysjump ro/rw to check motionsense data. Signed-off-by: David Huang <david.huang@quanta.corp-partner.google.com> Change-Id: I143cde2ab3028ec5658acd16fdb6ec6aae710ef6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2655305 Tested-by: David Huang <david.huang@quanta.corp-partner.google.com> Auto-Submit: David Huang <david.huang@quanta.corp-partner.google.com> Reviewed-by: YH Lin <yueherngl@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: David Huang <david.huang@quanta.corp-partner.google.com> (cherry picked from commit 8801fd7768c8b8436bd0282af71cdd449257c08a) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2662223 Commit-Queue: Keith Short <keithshort@chromium.org>
* driver: icm426xx: Use calibration unit to set/get offsetGwendal Grignou2021-01-291-24/+15
| | | | | | | | | | | | | | | | EC interface use constant (not range dependent) units to get/set offsets. Use them in icm426xx driver. BUG=b:177292639 BRANCH=hatch,nami,kukui,dedede,grunt,zork,octopus,volteer TEST=compile Change-Id: I6e6b1551464ea389db34646ba5b2bb553d683d7a Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2657955 Reviewed-by: Ching-Kang Yen <chingkang@chromium.org> Reviewed-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2659407
* aleena: Add base accel/gyro config for icm-426xxDavid Huang2021-01-193-1/+116
| | | | | | | | | | | | | | | | Add icm-426xx config for new second source base accel/gyro. BUG=none BRANCH=grunt TEST=Check ectool motionsense and get x,y,z data. Signed-off-by: David Huang <david.huang@quanta.corp-partner.google.com> Change-Id: I9a772fe700e97e29c7110c971683fa1c7f6c2f23 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2626796 Reviewed-by: Keith Short <keithshort@chromium.org> (cherry picked from commit 46afea52cc38b00505b24b601b732f035708975b) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2626797 Commit-Queue: Keith Short <keithshort@chromium.org>
* icm426xx: reset data rate when initDavid Huang2021-01-071-0/+2
| | | | | | | | | | | | | | | | | When icm426xx init, reset data rate to enable sensor. BUG=chromium:1160266 BRANCH=main TEST=Check ectool motionsense get data after shutdown and power on. Signed-off-by: David Huang <david.huang@quanta.corp-partner.google.com> Change-Id: I0a1042eaf6dbdb132c4bb50975eae3c6f0cfad00 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2597131 Reviewed-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2600805 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* driver: add icm426xx chip type defineJean-Baptiste Maneyrol2021-01-072-0/+4
| | | | | | | | | | | | | | | | | | | | | Add new enum motionsensor_chip and update ectool motionsense. BUG=chromium:1117541 BRANCH=None TEST=ectool motionsense info Cq-Depend: chromium:2317888 Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Change-Id: I07736d61bdb7332bfdc44c8f7294233e43a6e00d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2374647 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Commit-Queue: Gwendal Grignou <gwendal@chromium.org> Tested-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2600804 Tested-by: David Huang <david.huang@quanta.corp-partner.google.com> Auto-Submit: David Huang <david.huang@quanta.corp-partner.google.com> Reviewed-by: YH Lin <yueherngl@chromium.org> Commit-Queue: YH Lin <yueherngl@chromium.org>
* driver: add ICM-426xx driver supportJean-Baptiste Maneyrol2021-01-079-0/+1581
| | | | | | | | | | | | | | | | | | | | | | | Add ICM-426xx accel/gyro driver code. BUG=chromium:1117541 BRANCH=None TEST=ectool motionsense fifo_read && tast run hardware.SensorRing Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Change-Id: I83fe48abc6aa9cde86576a777ac4272d90fac597 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2317888 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Commit-Queue: Gwendal Grignou <gwendal@chromium.org> Tested-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2584545 Tested-by: David Huang <david.huang@quanta.corp-partner.google.com> Reviewed-by: Zhuohao Lee <zhuohao@chromium.org> Commit-Queue: Zhuohao Lee <zhuohao@chromium.org> Auto-Submit: David Huang <david.huang@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2600803 Reviewed-by: YH Lin <yueherngl@chromium.org> Commit-Queue: YH Lin <yueherngl@chromium.org>
* ec_commands: Add GENMASK macrosTom Hughes2020-12-281-0/+6
| | | | | | | | | | | | | | | | | | GENMASK is used in ec_commands.h, but is not defined if not compiling in kernel or Chrome OS EC environments. BRANCH=none BUG=b:144959033 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I439b0d77c47f3921f7bf2afd04c62cc72d668ea6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2558857 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2600802 Tested-by: David Huang <david.huang@quanta.corp-partner.google.com> Auto-Submit: David Huang <david.huang@quanta.corp-partner.google.com> Commit-Queue: Keith Short <keithshort@chromium.org>
* driver: bmi160: Fix rounding error in set_offset() and get_offset()Ching-Kang Yen2020-12-243-8/+26
| | | | | | | | | | | | | | | | | | | | | | | | The original set_offset() and get_offset() codes in the driver/accelgyro_bmi160 use simple divisions to write the data. The more times the set_offset() and get_offset() is used, the data will get closer to 0. Fixing it by replacing simple division to round_divide(), division that round to nearest, in the common/math_util.c. BRANCH=octopus BUG=b:146823505 TEST=Testing on octopus:ampton on branch [firmware-octopus-11297.B]. Checking the data did not rounding to 0. Change-Id: Ide9df9e32fc501e63d6f952cb8254df7662afd23 Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2002998 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Commit-Queue: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2600801 Tested-by: David Huang <david.huang@quanta.corp-partner.google.com> Auto-Submit: David Huang <david.huang@quanta.corp-partner.google.com>
* i2c: add generic read/modify/write operationsDenis Brockus2020-12-232-0/+137
| | | | | | | | | | | | | | | | | | | i2c_update is used to set or clear a mask i2c_field_update is used to clear out a field before the set BUG=none BRANCH=none TEST=make buildall -j Change-Id: I7f8f93f4894fb9635092931a93961d328eacfeb9 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1956437 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2600800 Tested-by: David Huang <david.huang@quanta.corp-partner.google.com> Auto-Submit: David Huang <david.huang@quanta.corp-partner.google.com>
* usbc: Remove pd_ts_dts_plugged() check from PD_DRP_FORCE_SINKEdward Hill2020-12-112-21/+3
| | | | | | | | | | | | | | | | | | PD_DRP_FORCE_SINK had an exception (since crrev.com/c/277275), allowing role to remain source on S5 entry if DTS (debug accessory) is connected. Remove this exception. rddkeepalive on cr50 (set when servod starts) ensures CCD mode stays enabled across power and role changes. BUG=b:173457150 BRANCH=none TEST=servo_v4_role:snk, AP S0/S5/G3, EC reboot/hibernate -> CCD keeps working Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: Iccdfb504c6269ee2ba072e9818920e3e10a56739 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2584857
* mordin: Add CosMX B00C4473A9D0002 batteryDevin Lu2020-11-182-0/+31
| | | | | | | | | | | | | | BUG=b:173343686 BRANCH=firmware-grunt-11031.B TEST=Test on charging/discharging/battery cut off pass. Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Change-Id: I69f50259c25e3fe6774afe2660a65db820cdaead Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2539712 Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org> (cherry picked from commit 7f46efd099ef8c4b7695658ee5bd0136e3d25b74) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2545910
* careena/barla: enable 2nd TCPC source PS8755 for port 1Devin Lu2020-09-113-0/+27
| | | | | | | | | | | | | | | | | | | | This patch adds one more TCPC PS8755 in the port 1. These two are all supported by ps8xxx.c and the board function board_get_ps8xxx_product_id is implemented to judge the source by checking TCPC ID pin. BUG=b:157298401, b:158983814 BRANCH=firmware-grunt-11031.B TEST=Verify DUT with PS8755 or PS8751 in the sub-board can work correctly in sink and source roles. Verify USBC charger is able to charging. Change-Id: I867e925ee5bb54597ba09539743a0048c220e298 Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2393407 Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org>
* ps8xxx: support multiple chips in the runtimeMarco Chen2020-09-113-115/+298
| | | | | | | | | | | | | | | | BUG=b:159082424 BRANCH=none TEST=verify the same EC image can work on devices with PS8751 or PS8755 for src / snk roles. Signed-off-by: Marco Chen <marcochen@chromium.org> Change-Id: I3a743666a4ccbcae37ecb6f0d6657122cf9c5a69 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2304237 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2393406 Tested-by: Devin Lu <Devin.Lu@quantatw.com> Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org>