Commit Graph

29 Commits

Author SHA1 Message Date
Bill Richardson
104f811e67 cleanup: fix all the header guards
This unifies all the EC header files to use __CROS_EC_FILENAME_H
as the include guard. Well, except for test/ util/ and extra/
which use __TEST_ __UTIL_ and __EXTRA_ prefixes respectively.

BUG=chromium:496895
BRANCH=none
TEST=make buildall -j

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: Iea71b3a08bdec94a11239de810a2b2e152b15029
Reviewed-on: https://chromium-review.googlesource.com/278121
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-06-18 19:07:00 +00:00
Louis Yung-Chieh Lo
5a4b239981 rename power_state* to charge_state*
Those are actually charge state, not power state. Rename the misleading
names.

BUG=chrome-os-partner:24832
BRANCH=link,falco,samus,rambi,peppy,spring,pit,snow
TEST=build only because no name conflicts.
make clean BOARD=link && make -j32 BOARD=link && \
make clean BOARD=falco && make -j 32 BOARD=falco && \
make clean BOARD=samus && make -j 32 BOARD=samus && \
make clean BOARD=rambi && make -j 32 BOARD=rambi && \
make clean BOARD=peppy && make -j 32 BOARD=peppy && \
make clean BOARD=snow && make -j 32 BOARD=snow && \
make clean BOARD=spring && make -j 32 BOARD=spring && \
make clean BOARD=pit && make -j 32 BOARD=pit && \
make clean BOARD=nyan && make -j 32 BOARD=nyan && \
make runtests -j 32 && make tests -j 32 BOARD=link && \
make tests -j 32 BOARD=falco && make tests -j 32 BOARD=samus && \
make tests -j 32 BOARD=rambi && make tests -j 32 BOARD=peppy && \
make tests -j 32 BOARD=snow && make tests -j 32 BOARD=spring && \
make tests -j 32 BOARD=pit && make tests -j 32 BOARD=nyan

Change-Id: Ie15052d5a7dbd97d519303d37260945346a27779
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/181505
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-01-07 04:53:20 +00:00
Randall Spangler
64e38af781 Clean up and document PMU config options
No functional changes, just documenting and renaming.

All boards which use the PMU must provide pmu_board_init().  This was
already true - except that Daisy's pmu_board_init() was implemented as
part of pmu_init() instead of its code living in board.c; I've moved
the code there now.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms

Change-Id: I85ad06dc3b6287ad917fe13acf83182f24a8f23d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62906
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-07-23 11:14:16 -07:00
Vic Yang
56bd316488 spring: Drop support for VFET2 video poewr output
VFET2 is only used by early stage boards. Let's drop it now.

Also, disable power output when power good for VFET is not set. This
essentially adds retry for video power output.

BUG=chrome-os-partner:18186
TEST=Boot and test video output.
BRANCH=Spring

Original-Change-Id: I1937522a6a523a4f5dbeb9882518ca6e37655bea
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60852
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit e82589e073c5a863797fa87ecaa1dfafb1a9228d)

Change-Id: Ib043f952e699eb99b373da205379f56230887f6a
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61396
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-07-10 11:16:36 -07:00
Vic Yang
9fb93c09d3 Reset charge state machine on charge timeout
For Spring, the charging time can be quite long and TPS65090 ends up in
timeout state and stops charging. Let's put charge state machine back to
re-init so that the device continues charging after checking charging
condition is good.

BUG=chrome-os-partner:19405
TEST=Pass charger test
BRANCH=spring

Change-Id: I838741e7283eb31ed76cf3979dbad7f070947aea
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/55720
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-20 10:54:00 -07:00
Vic Yang
7319480603 Rename REINIT to IDLE0 in TPS65090 charge state machine
The state REINIT in TPS65090 charge state machine is more like IDLE0
state in charge_state.h. Rename it so that it's less confusing and
easier to merge the two state machines in the future. Also move the
state name definition to the header file.

BUG=chrome-os-partner:18914
TEST=Boot Spring
BRANCH=None

Change-Id: I116438fedc46ff188dfb6a3964795715b5af4d1f
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49732
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-01 13:19:20 -07:00
Vic Yang
6d19c024a9 spring: Enable both VFET2 and VFET4 for video
We are moving video power from VFET2 to VFET4. To support old boards, we
need to enable both of them. When new boards are in place, we can then
drop VFET2.

BUG=chrome-os-partner:18186
TEST=Build spring
BRANCH=spring

Change-Id: If0cbc1ac49affc1e3c7ec9650a661f80be826f97
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49431
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-29 03:47:56 -07:00
Randall Spangler
fd38ba353c Move PMU charger irq handler to charger module
No code changes; this is just moving the irq to the module which
actually handles it.  This makes it simpler to disable the charger
task separately from the PMU module.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build pit, spring

Change-Id: Ife44a17f69bf21aa000d162318a459cea6fdf661
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49334
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2013-04-26 13:46:47 -07:00
Vic Yang
92bd863d8d Add new TPS65090 charge state REINIT and BAD_COND
Currently INIT state can mean different things. This change introduces
two new states to demultiplex INIT. Now, REINIT means charge state
machine is deciding the next state. BAD_COND means it's waiting for
acceptable charging condition. Note that the three states are doing the
same thing so there is no functional change.

BUG=chrome-os-partner:18914
TEST=none
BRANCH=spring
CQ-DEPEND=CL:49327

Change-Id: Ia783e76cf27e28103ef44fe7b8a43674dadccc54
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49326
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-26 12:36:26 -07:00
Randall Spangler
765c50ef5f Move board hard reset code into tpschrome driver
Hard reset is done by shorting 3.3V to ground.  This is only really
necessary to work around the PMU's I2C engine getting into a weird /
uncommunicative state.

This should not make any functional changes; the code is behaving the
same way it did before.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build daisy, snow, spring

Change-Id: I0edbdfc11bd5f6643075ffc83f4df3e11fc14675
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47199
2013-04-05 11:28:51 -07:00
Randall Spangler
9137686ebe Clean up board.c files
Just renaming functions and reordering #defines; no functional changes.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all EC boards

Change-Id: I90e9ea860110625012cd5fb99de966283ec82880
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47179
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-04-03 11:49:06 -07:00
Vic Yang
db20e7afde spring: keep AP off when battery level is too low
When battery level is too low, we want to keep the AP off even when a
power on event is received. Current threshold is set to 1 mAh.

Note that after this change, a board without a battery will need to wait
for 15 seconds before it can boot up.

BUG=chrome-os-partner:18318
TEST=Press power button and see power on event ignored. Charge battery
to over AP off threshold and check we can power on the system.
BRANCH=spring

Change-Id: If32a1935a69be102778bde7ad8976eea0921f87e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45825
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-20 23:47:40 -07:00
Vic Yang
6e07f94c90 spring: More stable battery LED control
This includes:
  - Discharging with AC present now recognized as battery assist mode
  - Trigger LED update every second instead of from PMU task
  - Minor breathing effect optimization
  - Control LED power and color from the same task to prevent
    simultaneous access to LED driver

BUG=chrome-os-partner:18244
TEST=Manual
BRANCH=spring

Change-Id: I9b34934f46cd4f04aaa7ca30cbe90316aec3e61e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45632
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-19 14:59:47 -07:00
Vic Yang
a44e0d91c8 spring: support new ID detection circuit
This enables the EC to switch the signals to ANX7808 properly.

BUG=chrome-os-partner:18165
TEST=Manual on reworked Spring board
BRANCH=none

Change-Id: Ib3ff57e17afab9ba8fc78fdb037e65aae844f38b
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44897
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-08 00:07:07 -08:00
Vincent Palatin
2cf4d02acd keep ADC reference voltage on between successive reads
To decrease the amount of time needed for PMU ADC reads, add the option
to keep the ADC reference voltage enable as its stabilization time is
the longest pole.
Also set the stabilization time to 10ms as the max defined in the
datasheet.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=chrome-os-partner:17997
TEST=on Spring, measure EC_CMD_POWER_INFO latency and see it going from
49ms to 18ms.

Change-Id: I7ed20bcddab165250108eb9f768539b19fa251de
Reviewed-on: https://gerrit.chromium.org/gerrit/44008
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-25 22:22:34 -08:00
Vic Yang
aab9accfce spring: Add host command to read power info
Getting voltage and current can be handy when verifying hardware design.
Let's add host command to do this.

BUG=chrome-os-partner:17880
TEST=Manual on Spring
BRANCH=none

Change-Id: I4d4f6a42a9d0f917292d092e132ccd9ce3367fd6
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43508
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-19 23:01:10 -08:00
Vic Yang
f4a9ffdee3 spring: Control battery LED
This implements a basic battery LED policy:
  - Charged: green
  - Charging: yellow
  - Error: red
  - No charger: off

BUG=chrome-os-partner:17561
TEST=Manual
BRANCH=none

Change-Id: I7fa8242efa4d0382d8ef0cafe80f01d44c390397
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42607
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-05 20:16:17 -08:00
Vic Yang
6eb8a6e999 tps65090: Throttle PMU interrupt instead of charger task
This is a prepartory work for integrating USB port control into PMU
task.

Currently TPS65090 charger task is throttled to only waken by event once
per 500 ms. This in a way makes it hard to integrate other functionality
into this task. This CL moves the throttling mechanism to interrupt
handler so as to provide better control of when to throttle the
interrupt event.

BUG=chrome-os-partner:14319
TEST=Build success and boot on spring.
BRANCH=none

Change-Id: I72e63180442b379a379e1a87c10ef62395434872
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/40189
Reviewed-by: Rong Chang <rongchang@chromium.org>
2012-12-28 07:48:24 -08:00
Rong Chang
eee90a3f35 Add TPSChrome FET API
Some designs will have the PMU not directly connected to the AP but
behind the EC.
For easier bring-up, it's nice to be able to force power rails.

Signed-off-by: Rong Chang <rongchang@chromium.org>
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BUG=chrome-os-partner:10912 chrome-os-partner:14324
TEST=manual
On snow, switch on and off the backlight using the API
BRANCH=none

Change-Id: I74e05308043546cb11f7f2cdbe644944c0a0a35e
Reviewed-on: https://gerrit.chromium.org/gerrit/26234
Reviewed-by: Rong Chang <rongchang@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2012-09-21 14:54:33 -07:00
Vincent Palatin
c350c20f44 tpschrome: AC detection is board specific.
the PMU VACG signal used to detect AC state is connected to a GPIO, so
it's a board specific configuration.
On top of that, Daisy variants have custom logic on that line which is
not present on the next boards, so we need to update it before doing BSP
for next-gen boards.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=chrome-os-partner:14313
TEST=make BOARD=snow && make BOARD=daisy
on snow EC console, type "pmu" command with AC plugge and unplugged, see
that the "ac gpio" line reflects the right value.
BRANCH=none

Change-Id: If1e19b89b2f2de45d8dddc8340931e56c5f7f0a5
Reviewed-on: https://gerrit.chromium.org/gerrit/33630
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2012-09-20 07:14:18 -07:00
Charlie Mooney
bb3bb92628 Snow: Adding in EC ability to hard reset pmic
By pulling line gio_A15 high, you can for a hard reset of the pmic after
the stuff resistor is changed.  This change adds a function that you can
call from the EC and trigger this event (board_hard_reset).  The user has
access to this command over the EC console by running "pmu reset" and
it will force the emergency reset.

The board_hard_reset function is used in the pmu's reset code.  Whenever
it is trying to initialize or shut down the pmu, it resets many or all
of its registers over i2c.  If the i2c commands fail to get a response
from the pmu, the EC will now force a hard reset of the system, which
restores everything, allowing for a restart to fix any situation where
the pmu has gotten its configuration trashed.

BUG=chrome-os-partner:12913
TEST=boot the machine.  From EC console check the pmic's register
values, then alter them.  Run "pmu reset" to force a reset, and check
the values again.  They should be safe values, which you can confirm
by powering on the AP.  Repeat this from various starting states: only
the EC on, AP on as well, and setting various registers to 0x00's and
0xff's.  To stress test the hard-reset ability from the EC's POV, run
while true; do echo "pmu reset"; sleep 5; done | cu -l DEVICE -s 15200
BRANCH=snow

Change-Id: I911fb9623a7c106d1f993ee4681258c05d4dedae
Signed-off-by: Charlie Mooney <charliemooney@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/31524
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-08-28 12:09:19 -07:00
Rong Chang
38454d7a16 snow: Change TPSCHROME fastcharge timeout to 6 hours
When battery temperature t in range 0C to 10C, default charging current
is 50%. And it will take longer than 3 hours to charge battery from 0%
to full.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BRANCH=snow
BUG=chrome-os-partner:13172
TEST=manual
  Check pmu register 0x4. FASTCHARGE bits[4:2] should be 0b100.

Change-Id: I133acee21c0886b0739b4b41766ca077bb4babbc
Reviewed-on: https://gerrit.chromium.org/gerrit/31458
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
2012-08-28 03:44:43 -07:00
Charlie Mooney
ecd4e1b5d6 Reset pmic registers to known safe values on boot
If a bug causes the pmic's internal registers to be overwritten with
garbage, they won't go away and can cause long lasting problems.  This
change overwrites them all whenever the EC or AP turn on with known,
safe values, so if that happens, a reboot will restore them instead of
forcing the user to pull the battery.  It also overwrites a few of them
when the AP shuts down, to prevent AP bugs from leaving the pmu powering
a bunch of peripherals that it doesn't need after it has turned off.

BUG=chrome-os-partner:12913
TEST=from EC console run "i2c w 0x90 0x0c 0xff" to screw up one of the
pmic registers.  Reboot the EC, and the AP should be able to boot just
fine.  Once the AP is booted, run that command again.  This time, just
reboot the AP, it should come back on like normal.  Try again with "i2c
w 0x90 0x0c 0x00".  Without the change, this fails to work.
BRANCH=snow

Change-Id: If3f0764f23e0112cc11be60b413f51e1b66e54a7
Signed-off-by: Charlie Mooney <charliemooney@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/31259
Reviewed-by: Doug Anderson <dianders@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Puneet Kumar <puneetster@chromium.org>
2012-08-27 09:27:43 -07:00
Rong Chang
40cab43256 Blink charger LED on charging error
Charger LED is controlled by TPSCHROME chip. And it blinks only when
hardware detected charging error. On other charging error conditions
not detected by TPSCHROME, we set the temperature thresholds to make
charger generate the error blink.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BRANCH=snow
BUG=chrome-os-partner:12224
TEST=manual
  Plug AC power, heat up battery to 65 C. The charging LED should
  start blinking instead of green.

Change-Id: Ib1c38a88c026471a52fbbb4f803e3b2aba93ab40
Reviewed-on: https://gerrit.chromium.org/gerrit/31139
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
2012-08-23 13:47:30 -07:00
Simon Que
1178484e0e Handle IRQ from TPS65090, pass AC status to AP
Changes made by this patch:
1. Create IRQ handler for the TPS65090 IRQ.  IRQ wakes up charger task.
2. Charger task sets the AC_STATUS GPIO based on the AC status.
3. Initialize PMU at power-on.

BRANCH=snow
BUG=chrome-os-partner:11739
TEST=Power on the system, with servo v2 connected to EC console.  Plug
and unplug AC.  The IRQ handler should be triggered.

Change-Id: Ice23411c275111fdb56d2c47ba28c3c44dee4d71
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29914
Commit-Ready: Rong Chang <rongchang@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
2012-08-14 17:04:50 -07:00
Rong Chang
709f6d8b2e Set TPSCHROME temp range configuration
Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:11627
TEST=manual
  Check pmu registers under uart console: "pmu"
  TPSCHROME version < 3:
    reg(7) == 0xbd
    reg(8) == 0xfd
  TPSCHROME version >= 3:
    reg(7) == 0xbf
    reg(8) == 0xff

Change-Id: Ifeda54aa142b362aa224575c55220913b0ee7436
Reviewed-on: https://gerrit.chromium.org/gerrit/28587
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
2012-07-29 22:35:45 -07:00
Rong Chang
717e556759 Initialize PMU default settings using board configuration
Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:11749
TEST=on snow with fully discharged dead battery
  plug ac power and check if it can charge to full

Change-Id: Ie90255614bff879780edbd2bf1fc77bf8e2c04c8
Reviewed-on: https://gerrit.chromium.org/gerrit/26674
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
2012-07-03 23:51:19 -07:00
Rong Chang
f429744005 Fix multiple charging issues on snow
This change fixes mutiple snow charging issues. Including:
  - disable i2c host auto selection
  - i2c_read8 got wrong output value
  - pmu CHARGE_EN control workaround

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:11010
TEST=Only test on snow dvt with AP turned off
  plug/unplug ac adapter and check charging led
  check console command 'battery'

Change-Id: I29d554b3daa4cfc538bd5bf5ba5233976d381861
Reviewed-on: https://gerrit.chromium.org/gerrit/26529
Tested-by: Rong Chang <rongchang@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-07-01 15:45:09 -07:00
Rong Chang
c56b1a7bdb TPSChrome charging loop
This change contains a basic charging loop that follows Chromium
battery charging flow. The temperature range constants, loop delay
time will be move to battery pack later.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:9724,9757,9759
TEST=manual, uart console
  Plug AC adapter:
    > pmu event: 0000000000001110
    [batt] state discharging -> idle
    [batt] state idle -> charging
    > battery
      I:         0x04fd = 1277 mA(CHG)a

  Unplug AC adapter:
    > pmu event: 0000000000000110
    [batt] state charging -> idle
    [batt] state idle -> discharging
    > battery
      I:         0xffcb = -53 mA(DISCHG)

Change-Id: Ifed594d78c0ed08c5e4821a9c8581c1a87526729
Reviewed-on: https://gerrit.chromium.org/gerrit/25618
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2012-06-26 18:15:35 -07:00