summaryrefslogtreecommitdiff
path: root/include/battery.h
Commit message (Collapse)AuthorAgeFilesLines
* After shutting down AP, hibernate EC if battery is lowRandall Spangler2013-03-051-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This preserves more battery for the real-time clock. It also gets rid of one battery level/state, since the EC will now shut down at the same level (2%) as the AP. Having the EC hibernate at the same level as the AP shuts down also prevents the following weird scenario: - EC powers on at 2% battery. - EC won't power on the AP to do software sync because battery is low. - But the charge state machine won't actually hibernate the EC until 1%. - Between 2% and 1%, AC is inserted and system starts charging. - But EC-RO is what's doing the charging; we should go through software sync before charging. BUG=chrome-os-partner:17124 BRANCH=link TEST=manual On battery power, 1) With system on, battfake 2 -> system shuts down and EC hibernates 2) With system off, battfake 2 -> EC hibernates Change-Id: I87d17f70d60673f3e3f1c6eb88f3f00a8c9ed4e7 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/44314
* Rename and document battery constantsRandall Spangler2013-02-121-16/+20
| | | | | | | | | | | | | | | | | | | | | In preparation for cleaning up low-battery logic. Make clear what comparison operator is used for each constant (<=, <, >=, >). Also remove hard-coded and unused display of design warning/low battery levels from ectool. Verified via code search that these are not used anywhere. Even if we later care about these levels, they should be battery-specific and not hard-coded as a platform-independent percentage of full capacity when ectool is compiled. BUG=chrome-os-partner:17124 BRANCH=link TEST=compile link; 'ectool battery' from root shell prints valid info Change-Id: I3650e27a08f4cc77067beb0685ee1488cc56d02f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/43119 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Set minimum brightness to 35%, variable osc settings.Bill Richardson2012-10-141-6/+0
| | | | | | | | | | | | | BUG=chrome-os-partner:8039 BRANCH=Link TEST=none More cosmetic changes. Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: I1fd9318131ce55541d845ac8be5faa9334c3953f Reviewed-on: https://gerrit.chromium.org/gerrit/35484 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* link: Hibernate EC when battery level drops below 2%Randall Spangler2012-10-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | We already shut down the main processor below 3%. Hibernating the EC below 2% will further cut power draw and minimize the risk of deep-discharging the battery. BUG=chrome-os-partner:14839 BRANCH=link TEST=manual 1) discharge battery below 3%; system should shut down. when powered on again it should shut back down within ~10 sec. 2) discharge battery below 2%; when system shuts down it should also hibernate. (I've also tested this with a hacked smart_battery.c which lies about the battery state of charge, since that's faster than waiting for my battery to discharge.) Change-Id: I504ba927012430db5cf10b895a36e6cd6fdf4c8b Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/34793 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* link: Add charge_near_full stateRandall Spangler2012-10-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tell the host the battery is no longer charging when it hits 97%, and set the power adapter LED to green. This solves several problems: 1) The last 3% of charge takes a looong time. Kernel/ACPI/UI already have a hack to show the battery as charged when it's about 3% from full, but the EC still showed a yellow LED. 2) If the system is charged and you briefly unplug the adapter, the LED turned yellow for a long time as it slowly trickle-charged. Now it goes right to green. 3) A fully-charged battery will drop below 100% charge as it settles, but won't accept more current at that time. This caused the LED to turn yellow and stay there until the battery finally settled down to ~96%, at which point it'd accept more current and top itself off. The whole time it did this, the kernel/ACPI/UI hack from (1) would keep reporting "battery full". Now the LED stays green too. BUG=chrome-os-partner:11248 BRANCH=link TEST=manual - Discharge system to <95% full. - Plug adapter in. LED should come on yellow. - At around 97% full, the LED should turn green. - Around that the UI will display "battery full". (Note that due to rounding, the UI may take a few minutes to display "battery full" after the LED goes green; that's ok) - Unplug and replug adapter. LED should come on green. UI still reports "battery full". Change-Id: Ie56fbf3a05239e73d2c765bb98d36aa5cfedc2ef Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/34452
* Use two-color lightbar scheme, with KB backlight for brightnessBill Richardson2012-09-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Yet another set of tweaks to the lightbar patterns: At Startup or wake from sleep, Google colors cycle in. While running, > 25% power level in the battery: All blue, in a breathing effect (cycle up and down 30%). While running, <= 25% power level in battery: Same as above, but with red Shutting down, or going into sleep: Cycle out the Google colors (Note: the effect is only visible for S0->S3, because shutting down kills power to the lightbar before we can react). While sleeping: Similar to now, but only using Blue and red for battery indication as above. The EC doesn't have access to the ALS, so we use the keyboard backlight to control the lightbar brightness instead: If keyboard backlight is OFF (which it is when ambient is bright), use max brightness for lightbar. If keyboard backlight is ON, use keyboard backlight brightness. BUG=chrome-os-partner:13870 BRANCH=Link TEST=none This is an aesthetic change. Nothing to test, only artisitic criticism. Change-Id: Ib0b98eef18984945a83e988588c225025c4e8e52 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/33824 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Only use trickle charging logic when battery is mostly dischargedRandall Spangler2012-09-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At other times, the battery should follow the normal charging rules. Using the trickle charging logic has 2 problems here: 1) Battery voltage is near maximum, so trickle charging logic starts out with voltage less than the actual battery voltage, and less than the charging spec. 2) Trickle charging only exits when battery requests more current (which it won't if it's near full) or on 4-hour timeout, not when battery reads 100%. So this can cause overcharging. Note that we still limit the charging current to what the battery asks for, but if that's less than the minimum current from the charger we simply provide the minimum and don't fiddle with the voltage since that may interfere with the battery's ability to determine it's fully charged. BUG=chrome-os-partner:14402 BRANCH=link TEST=manual 1. charge laptop to full 2. quickly unplug and plug charger 3. look at debug log; should either not charge at all (if charge is currently 100%) or charge at 8400mV (if charge is less than 100%). Change-Id: Ifd5a9eb2e9bb791f74196713b645d1c9211eb736 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/33729 Reviewed-by: Rong Chang <rongchang@chromium.org>
* Add "lightbar demo" mode for executive bikesheddingBill Richardson2012-08-201-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I keep getting asked to build an EC image to manually control the lightbar patterns so that the Powers That Be can look at it. This change just makes it possible to turn that mode on and off for yourself. You'll need a root shell or the EC console to do it, though. BUG=chrome-os-partner:8039 BRANCH=link TEST=manual From the EC console, type lightbar demo 1 OR from the root shell run ectool lightbar demo 1 After that, these keys should change the lightbar appearance (transitions may be slow and subtle - that's intended): UP = battery is more fully charged DOWN = battery is less fully charged RIGHT = battery is charging LEFT = battery is discharging BRIGHT = increase lightbar brightness DIM = decrase lightbar brightness Note that this does not interfere with the normal function of any keys. It only adds some additional EC behavior. Change-Id: Ia1a9855188244d74b670f9dbfdf60e3ac0343460 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/30899
* Implement something close to final lightbar code.Bill Richardson2012-07-231-0/+12
| | | | | | | | | | | | BUG=chrome-os-partner:8039 TEST=manual Boot the system, look at the lightbar. It should pulse colors slowly on battery, faster on AC. Change-Id: I0184973d11eda51db87d652aa2c92995f5a25588 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27810
* Trickle charging state and minor bugs fixRong Chang2012-04-191-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adding trickle charging mode to precharge batteries with voltage lower than minimal design value. This CL adds control to charger voltage to track battery input current change. To prevent battery from deeply discharging, this CL preserves 3% of the design capacity. Minor bug fixes include error state check and charger control logic. Signed-off-by: Rong Chang <rongchang@chromium.org> BUG=chrome-os-partner:8660,8661 TEST=manual Plug AC power, the power adapter led should be 'yellow'. On the EC serial console, type 'battery' and 'charger' commands. Battery input current should staid close to its desired current. A deeply discharged battery (5.5V) should be revived to a healthy state after 30 minutes ~ 4 hours. Change-Id: Ibaa2396c6b751639d98db32f5919b1e8ec700e40
* Add battery SMI events and refactor charging stateRong Chang2012-03-191-2/+4
| | | | | | | | | | | | | | | | | This CL adds battery SMI events. And refactors the charging state machine by adding share state context for all handlers. Power events are moved to common handler. Minor clean up on console output messages. Signed-off-by: Rong Chang <rongchang@chromium.org> BUG=chrome-os-partner:7526,7937,8450 TEST=manual: Watch console message when connecting/disconnecting AC adapter and battery. Check the state transition. Change-Id: I42eec4f87a9d49bd193cb9dde9080e3dfccbb77c
* Add battery lpc commandsRong Chang2012-03-071-0/+15
This CL adds LPC commands to provide the following information: - Design Capacity (dword) - Last Full Charge Capacity (dword) - Design Voltage (dword) - Design Capacity of Warning (dword) - Design Capacity of Low (dword) - Battery Type (ascii) - Model Number (ascii) - Serial Number (ascii) - OEM (usually Vendor) (ascii) - Battery charge cycle count (dword) Signed-off-by: Rong Chang <rongchang@chromium.org> BUG=chrome-os-partner:8181 TEST=none CQ-DEPEND:Iad4d63c996272568b5a661a6716790ef151b29c5 Change-Id: Iabaf7d9862e15c5b21cf5170cf43450e472b7836