Commit Graph

1399 Commits

Author SHA1 Message Date
David Hendricks
2f229ea226 stm32: make read_raw_input_state() more portable
This re-factors read_raw_input_state() to use GPIO port and mask
values from the board's gpio_list array. This eliminates the reliance
on hard-coded bit mask values and ports, thus making the code
adaptable for future designs.

As a slight optimization, the GPIO input data register is re-read
only if the port changes from the previous iteration. Thus, it's best
if the GPIOs are listed such that changes to the port address are
minimized.

BUG=none
BRANCH=none
TEST=Tested on Snow by running finger across keys.

Change-Id: I4a79363f060f37690bfebfd6763f7bfe6cb7991a
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44993
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-13 14:14:02 -07:00
Todd Broch
abc11d883c stm32: Force disconnect of UART prior to writing firmware.
For chromeos devices with the stm32 EC we write the firmware via
uart.  Often developers are connected to this UART for console I/O
which causes flash_ec to fail.

This change looks for any pids currently attached to the UART and
forcibly kills them prior to attempting to write the firmware.

Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=spring
BUG=none
TEST=manual,

./util/flash_ec --board spring ...

Forcibly grabs UART from both:
  cu -l /dev/pts/<num>
  minicom -p /dev/pts/<num>

Change-Id: Ie2a2b7aaf437c2cedd1d16e399c63068f2b02da3
Reviewed-on: https://gerrit.chromium.org/gerrit/45217
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
2013-03-13 13:50:27 -07:00
David Hendricks
e1c1756808 stm32: remove unused kbc_gpio struct
This removes a struct which is unused.

BUG=none
BRANCH=none
TEST=locally compiled

Change-Id: I664714d371aac9829c984b5a5ed591745ef78eb1
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44983
2013-03-13 13:04:15 -07:00
David Hendricks
7c9f26b582 stm32: add some documentation to keyboard_scan.c
This adds some documentation explaining the method to the madness
involving the board's gpio_list array.

BUG=none
BRANCH=none
TEST=it's just comments.

Change-Id: I30731555bbc358b0bebd75f906cbbb3116206146
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44994
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-13 12:41:12 -07:00
David Hendricks
cdfbe88e92 stm32: list keyboard output ports on a per-board basis
This CL moves the keyboard port listing to board.h for each mainboard
to reduce board-specific clutter in keyboard_scan.c. Since the info
is now exposed outside of keyboard_scan.c, a more descriptive name was
chosen.

Note: GPIO_D does not need to be included in this list for any current
platform.

BUG=none
BRANCH=none
Test=tested on Snow by pressing all number and letter keys

Signed-off-by: David Hendricks <dhendrix@chromium.org>

Change-Id: I1ce924a41cafae557467997ecba9c5abeed86211
Reviewed-on: https://gerrit.chromium.org/gerrit/45284
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2013-03-13 12:12:01 -07:00
Vic Yang
2823e7e132 stm32f: Add support for ADC watchdog
This makes it possible to have ADC module monitor an input voltage and
trigger interrupt when it goes out of accepted range.

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

Change-Id: Ia0c981fadd9bcaa40afe30ca2624c2f3644b95fe
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45277
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-13 12:11:59 -07:00
Todd Broch
eefc0ac8c5 spring: stm32: Generate battery key when charging status changes.
In order to update charger status we have added a virtual keystroke to
signal change to the kernel via the MKBP interface.

CL creates the virtual key press and calls it from within the
USB charging code.

Signed-off-by: Todd Broch <tbroch@chromium.org>

BUG=chrome-os-partner:17927
BRANCH=spring
TEST=manual

1. Compile for daisy,snow,spring.
2. Test on spring.

Change-Id: I0afa0fc82c96fa3fd8119523a113b5028c8f64a3
Reviewed-on: https://gerrit.chromium.org/gerrit/45126
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
2013-03-13 11:14:55 -07:00
Bill Richardson
cb03fa5c63 Update lbplay.c with correct cooperative locking.
BUG=none
BRANCH=none
TEST=manual

Build it manually, copy lbplay to DUT, run lbplay & ectool simultaneously.

  cd /mnt/stateful_partition
  mount -o remount,exec .
  scp USER@SOMEWHERE:/SOME/PATH/TO/lbplay .
  ./lbplay &
  ectool lightbar params
  ectool lightbar params
  ectool lightbar params

The lbplay program should cause the lightbar to slowly ramp up to green and
down to red. Meanwhile, the ectool command should work and not hang.

Change-Id: I4f26b0530ceaacbc18f8b9f38d7cbdfdabf78015
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45257
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2013-03-13 11:14:54 -07:00
David Hendricks
f5f30a22c6 stm32: Move KB_INPUTS to board.h
This moves KB_INPUTS from keyboard_scan.c to board.h where KB_OUTPUTS
is #defined. Although we use the same 13x8 keyboard matrix on all
platforms, KB_OUTPUTS is defined on a per-board basis due to its usage
in keyboard_test.

BUG=none
BRANCH=none
TEST=locally compiled

Change-Id: I0d66705d2959c7824b96cc8aae55368eca39a21a
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44970
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-11 22:08:56 -07:00
David Hendricks
0631409955 stm32: finish cleaning up row/column/input/output naming
This is a purely cosmetic change that removes any remaining
references of rows/columns in favor of inputs/outputs since the
former is inconsistent across platforms.

Higher-level code (such as MKBP) may still refer to logical rows
and columns, but low-level GPIO handling code will refer to GPIOs
by their input/output function.

BUG=none
BRANCH=none
TEST=Tested on Snow (ran finger across all numbers and letters)

Change-Id: Idb8b76e8d013568505d826c3a54a1ed8ce143d12
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44982
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-11 22:08:55 -07:00
David Hendricks
d4ca1d9c00 stm32: Dynamically generate keyboard IRQ mask
This replaces the hard-coded IRQ mask which has so far worked on
Chrome platforms with a variable that gets set in the initialization
part of keyboard_scan_task(). A simple loop is used to OR the GPIO
mask for each keyboard input provided by the board's gpio_list array.

This will make it easier to adapt the code to future targets with
different pin mappings.

BUG=none
BRANCH=none
TEST=Tested on Snow

Signed-off-by: David Hendricks <dhendrix@chromium.org>
Change-Id: I848ab3c7e8d276dbb807a97c6b26c5b3c05af166
Reviewed-on: https://gerrit.chromium.org/gerrit/44952
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-08 13:27:22 -08:00
Vic Yang
4ac742b4d5 spring: Fix ID_MUX polarity
This reflects the change of the ID_MUX polarity.

BUG=chrome-os-partner:18165
TEST=none
BRANCH=none

Change-Id: Iea126149f8785a0f028221463d197c63b39a3bd7
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44945
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-08 12:01:46 -08:00
David Hendricks
ea000b0fc0 stm32f10x: Initial import
This adds initial support for the other chips in the stm32f10x
series: stm32f101, stm32f102x, stm32f103x, stm32f105x, stm32f107x.

The main difference is in the register definitions. Clock, flash,
GPIO, and JTAG modules are similar enough that for now we can symlink
the existing source for stm32f100.

BRANCH=none
BUG=none
TEST=Tested on McCroskey (follow-up CL)
Signed-off-by: David Hendricks <dhendrix@chromium.org>

Change-Id: I67363d02578e21be51d842b6bd8b5e4848720993
Reviewed-on: https://gerrit.chromium.org/gerrit/43412
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
2013-03-08 12:01:46 -08: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
Jeremy Thorpe
f568b82321 Rename CODEC_INT to ID_MUX.
Rename CODEC_INT to ID_MUX and let it be settable on the EC command line.  This
GPIO line controls the ID line MUX in Spring.

BRANCH=spring
BUG=chrome-os-partner:16196
TEST=manual

Change-Id: Ib29f31cf5dd28f5166236b5f98560543298b083b
Signed-off-by: Jeremy Thorpe <jeremyt@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44531
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-07 20:37:33 -08:00
Vic Yang
fa144d8ac0 spring: avoid AC bad when load suddenly increase
To avoid AC bad condition when system load suddenly increase, we should:
  - Keep VBUS voltage at reasonable level on battery assist
  - Allow PWM to bring VBUS voltage up before asserting AC bad

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

Change-Id: I8058ffba9f91550f22408ea25911a1dded835584
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44612
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-05 18:42:26 -08:00
Vic Yang
03a1da3b65 spring: switch default current limit mode to aggressive mode
Measurement result for aggressive mode looks good. Let's switch to it by
default.

BUG=chrome-os-partner:14319
TEST=Boot and check current limit mode.
BRANCH=none

Change-Id: I117170aaea8c3a3304dc27815ffb429fff2f22c7
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44607
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-05 18:42:26 -08:00
Randall Spangler
e60f1ab224 Give the AP 30 sec warning before shutting down due to low battery
This allows the AP to shut down cleanly.  If it doesn't shut down in
that time period, the EC will forcibly shut it down.

BUG=chrome-os-partner:17124
BRANCH=link
TEST=manual

1. With system off,
  - battfake 2 -> EC hibernates immediately

2. With system on,
  - battfake 2 -> battery shutdown event posted to AP
  - power off system manually within 30 sec -> EC hibernates

3. With system on,
  - battfake 2 -> battery shutdown event posted to AP
  - do not power off AP
  - after 30 sec, EC shuts down AP then hibernates

4. With system on,
  - battfake 2 -> battery shutdown event posted to AP
  - after 15 sec, apply AC power
  - system does NOT shut down
  - remove AC power -> battery shutdown event posted to AP
    (because battfake 2 is still faking 2% battery left)
  - after 30 sec, EC shuts down AP then hibernates
    (check to make sure the full 30 sec elapses; the timer
     should have been restarted when AC power was removed;
     if the EC shuts down the AP immediately this is a
     failure indicating the timer is still running from
     the first shutdown event)

Change-Id: I1a13765f501d705d3a580b2acbbb173d47e020ff
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44413
2013-03-05 10:26:21 -08:00
Randall Spangler
6971fd7a7f After shutting down AP, hibernate EC if battery is low
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
2013-03-05 10:26:21 -08:00
Randall Spangler
70cdf52ea1 Wait to power on system until battery state is known
This prevents the system from waking from hibernate at very low
battery, then powering on the AP to do software sync only to find that
the charge state machine shuts down the AP before software sync can
complete.

BUG=chrome-os-partner:17124
BRANCH=link
TEST=manual

On both AC and mostly-charged battery:
- With lid open, reboot EC -> on
- With lid open, reboot EC with power held down -> on
- With lid closed, reboot EC -> system boots and does EC software sync
- With system on -> battfake 2 shuts system down
  (and at that point, opening lid or pressing power does nothing)

With a hacked charge_state.c so fake_state_of_charge starts at 2:
- With lid open or closed, reboot EC -> off
- Opening lid does not turn on system
- Pressing power button does not turn on system
- Plug power back in and press power -> system turns on

Change-Id: Ie1f2933060fac87b1afe68718f374d51cb8994de
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44313
2013-03-05 10:26:20 -08:00
Vic Yang
1866d471f4 spring: battery LED breath yellow on battery assist
When in battery assit mode, show breathing yellow on battery LED slowly
to indicate battery is actually discharging.

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

Change-Id: I688470d8870b181bf2dd20b5ebcbd6e2d861c5b0
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44514
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-04 16:44:48 -08:00
Vic Yang
6249a40069 spring: set maximum allowed duty cycle
We should allow a minimum amount of current input in case the
battery is dead.

BUG=chrome-os-partner:14319
TEST=Boot with a dead battery
BRANCH=none

Change-Id: I3c172d43c8190ed2dc5d421dcf2b5aaf0e88ecd9
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44510
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-04 16:24:56 -08:00
Randall Spangler
d86df6c388 Add reinit state to charge_state module to distinguish it from at-ec-boot init
This is a precursor to changing the switch state machine to delay
powering on the AP until the charge_state module knows if there's
enough power to do so (which it will know when it leaves the INIT
state).

BUG=chrome-os-partner:17124
BRANCH=link
TEST=manual

1. Reboot EC on battery power.  See charge state init->discharging
2. Plug in AC.  See charge state discharging->reinit
(charge state will then transition to some other charging or idle state
based on battery level)

Change-Id: Ia02cc8b37e9b5e8d6dd8c2fbfdf14e385694b1bf
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44291
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-02-28 16:12:05 -08:00
Sameer Nanda
9a1fc51faf temp_metrics: use iotools wrmsr instead of wrmsr
Use the "iotools wrmsr" command instead of the wrmsr alias since iotools
ebuild no longer installs the symlinks by default.

BUG=chromium-os:39180
TEST=On a Pixel issue "sudo start temp_metrics" and check
/var/log/messages to ensure that no new messages such as "init:
temp_metrics main process ended, respawning" show up.
BRANCH=none

Change-Id: I46cd8770c7e6c1af1affe8e2100033a29b9a90bb
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44073
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2013-02-26 13:19:51 -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
10f34bf8a9 Allow TSU6721 auto mode under any condition
Although TSU6721 cannot go manual mode under certain conditions, it
is able to go auto mode no matter what.

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

Change-Id: Iba8b9bf815a4c0e5a3462e72c4afe85571845d33
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43864
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-25 22:22:34 -08:00
Vic Yang
998c0344b5 spring: a more aggressive current control approach
Currently we stop raising current input when a predefined limit is
reached. To take advantage of high power charger, we now push the limit
and detect over current shut off if any. This allows us to detect the
actual current limit of the charger.

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

Change-Id: I5aefd8c0ac02bd0ca9920e861a4fa62fc6e588e5
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43863
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-25 22:22:33 -08:00
Vic Yang
9aba3baf15 spring: minimize the window that loses TSU6721 interrupt
Since TSU6721 processing is integrated into PMU task, an interrupt
closely following previous one may be dropped. We should check interrupt
status before yeilding control.

BUG=chrome-os-partner:14319, chrome-os-partner:14318
TEST=Boot on Spring. Check TSU6721 functionality.
BRANCH=none

Change-Id: I7ce1c70a214bb4afc9456eb206203cc6c3fe2f33
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43862
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-25 18:59:56 -08:00
Louis Yung-Chieh Lo
c1b16d21e6 Change the I8042_CMD_ENABLE (0xf4) for keystroke (not for KBC).
Old code treat following commands as the same:
  1. I8042_CMD_ENABLE in include/i8042_protocol.h
  2. I8042_ENA_KB (0xae) in include/i8042_protocol.h
  3. bit 4 of command byte, see I8042_KBD_DIS in include/i8042_protocol.h

New code changes 1 in keystroke_enabled variable.

Signed-off-by: Yung-Chieh Lo <yjlou@chromium.org>
BUG=chrome-os-partner:17005,chrome-os-partner:17810
BRANCH=link
TEST=Tested vincent's script with following scenario:
1. not-workarounded kernel: PASS more than 2767, 2946, and 7300 loops.
2. workarounded kernel: PASS more than 5000 loops.

Change-Id: I879a1b1f0186594e4b9dd7fc4320232ebab4a1e1
Reviewed-on: https://gerrit.chromium.org/gerrit/43006
Commit-Queue: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
2013-02-23 17:34:20 -08:00
Vic Yang
17e84f1589 spring: Avoid picking up USB power from AP
When powered device is removed, VBUS is still powered by the AP. We
should turn off power from AP and let it settle before we sense external
VBUS input.

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

Change-Id: Ie868a3df27e395c948ba8c6342e84764d182ce82
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43779
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-22 21:56:27 -08:00
Vic Yang
6492c99cca spring: Tweak current limit and voltage threshold
Fine tune current limit and voltage threshold so that we don't hit
current limit so easily.

BUG=chrome-os-partner:14319
TEST=Manual on Spring
BRANCH=None

Change-Id: Ia9ccd13b9e7eac7cdee83d0f488a1a83c27318c0
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43716
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-21 21:16:44 -08:00
Vic Yang
517d4d771b spring: Handle AP VBUS power
The VBUS power from AP is now incorrectly recognized as AC source. Let's
gate this with device type and BOOST_EN.

BUG=chrome-os-partner:14319
TEST=Manual
BRANCH=None

Change-Id: Id8127ab6f85fb25adfadb1c2bef4c753a58cdc4f
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43709
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-21 21:16:43 -08:00
Vic Yang
070943e9bf spring: Handle dead battery and booting with low power charger
This tweaks initial PWM configuration so that:
  - When battery is dead, more current is allowed to sustain the system.
  - When EC boots with a low power charger, input current is throttled
    so as not to kill the charger.

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

Change-Id: Ib52894b07fecdd533aecab312f40afa0b6df5676
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43600
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-20 09:22:43 -08:00
Vic Yang
95253a68dd spring: Add current limit loop
This monitors input voltage and adjust current limit accordingly to keep
voltage in acceptable range.

BUG=chrome-os-partner:17881
TEST=Manual on spring
BRANCH=none

Change-Id: Ie4b44844983f622ef7f648cf022c3c093597246c
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43511
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-20 09:22:40 -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
David Hendricks
2e64bed323 assert ENTERING_RW only if it exists
This adds an #ifdef to fix compilation for boards which do not have
ENTERING_RW (such as McCroskey).

BUG=none
BRANCH=none
TEST=Tested on McCroskey
Signed-off-by: David Hendricks <dhendrix@chromium.org>

Change-Id: Ic5577753edafd7fc249b8c23ab84e8c355a348e7
Reviewed-on: https://gerrit.chromium.org/gerrit/43413
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-19 07:28:17 -08:00
Todd Broch
1da883a6bc Unify dut-control command.
Previous CL included --port but I neglected one invocation.  Better to
just unify how dut-control is called with a global.

BRANCH=none
BUG=none
TEST=manual,

./util/flash_ec --board spring
- device connected to servod @ port 9999 is successfully flashed

./util/flash_ec --board spring --port 9902
- device connected to servod @ port 9902 is successfully flashed

Change-Id: I9cf57d0ddd94cf825d3015f9768effffca94eaf2
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43222
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-13 19:46:11 -08:00
Todd Broch
6fd61fa6f1 Allow flashing of EC binary from host with multiple servod invocations.
Adds argument --port to provide ability to flash from host that has
multiple servos running.

BRANCH=none
BUG=none
TEST=manual,

./util/flash_ec --board spring
- device connected to servod @ port 9999 is successfully flashed

./util/flash_ec --board spring --port 9902
- device connected to servod @ port 9902 is successfully flashed

Signed-off-by: Todd Broch <tbroch@chromium.org>
Change-Id: Iecc4b8df51236a1f21be5feca8bb87f5a1d03e97
Reviewed-on: https://gerrit.chromium.org/gerrit/43182
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-13 13:00:59 -08:00
Vincent Palatin
154c73f32d spring: always enable the PP3300_WWAN rail
The kernel driver to control the 3G modem LDO is not submitted yet.
Let's hardcode it for now to enable RF testing and revert this patch
later.

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

BRANCH=none
BUG=chrome-os-partner:17790
TEST=on Spring, boot and dump the TPS65090 configuration from the EC
command line by using "pmu" command.
See 0x1f in the register 0x11 for FET3.

Change-Id: I29aa7d1d7fb819ff1881a756e9592e272e87ad0b
Reviewed-on: https://gerrit.chromium.org/gerrit/43181
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2013-02-13 11:58:41 -08:00
Vincent Palatin
92ceccbc4b tps65090: update LDOs configuration
Match the configuration on Snow :
- set overcurrent timeout to 3200us (max)
 (to avoid triggering the protection on initial inrush current)
- properly enable the auto-discharge feature
 (we need it when the LDOs are turned OFF)

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

BRANCH=none
BUG=chrome-os-partner:17790 chrome-os-partner:17804
TEST=on Spring, boot and dump the TPS65090 configuration from the EC
command line by using "pmu" command.
See 0x1f in registers 0x0f and 0x14 for LCD and Backlight LDOs.

Change-Id: I20b0cb11d7abb890e921816e75e8ed816ca4f2d4
Reviewed-on: https://gerrit.chromium.org/gerrit/43180
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2013-02-13 11:58:41 -08:00
Randall Spangler
695289cfe6 Add console command to fake battery state of charge
The new 'battfake' command is really handy for testing low-battery
shutdown logic.

BUG=chrome-os-partner:17124
BRANCH=link
TEST=from EC console:
	  reboot
	  battfake -> using real battery level
	  power on system -> lightbar should be blue
	  battfake 5
	  lightbar turns red after a few seconds
	  UI shows battery is very low
	     (shows <5% due to different kernel math)
	  'ectool battery' from root shell shows present capacity ~5% of
	  	  design capacity
	  remove AC power
	  battfake 4
	  UI shows low-battery screen and shuts down (may take a minute)
	  battfake 50
	  power on system
	  UI shows battery at 45-55%
	  battfake 2 -> system shuts down immediately
	  battfake -1
	  power on system
	  UI shows actual battery level

Change-Id: I3180e321241c0f586f3baad2150fb6a2b2d2e242
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43151
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-02-12 18:10:14 -08:00
Randall Spangler
9fde14da9b Rename and document battery constants
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>
2013-02-12 13:46:44 -08:00
Randall Spangler
c19a4db9e4 link: If a required power rail drops, shut down
This protects the system from ending up in a weird state if one of the
rails fails to come up, or shuts down after coming up.

BUG=chrome-os-partner:17774
BRANCH=link
TEST=manual

- Boot system
- From EC console: gpioset enable_1_5v_ddr 0
- System shuts down; EC console prints "x86 power lost input"
- Press power button; system turns back on
- From EC console: gpioset enable_vs 0
- System shuts down; EC console prints "x86 power lost input"
- Press power button; system turns back on
- Suspend system
- From EC console: gpioset enable_1_5v_ddr 0
- System shuts down; EC console prints "x86 power lost input"
- Press power button; system turns back on

Change-Id: I8ae1630deb4001716b8dfd89d7dec7300cddb5ae
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43097
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2013-02-12 10:35:12 -08:00
Vic Yang
c93378dafa spring: Distinguish Apple Chargers
This uses D+/D- voltage to distinguish different Apple chargers.

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

Change-Id: I50075d466f6e6b1adf613748cf433d7f43c04bfe
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42850
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-07 22:06:05 -08:00
Vic Yang
f84a5fa8b1 stm32: Lengthen ADC sample time
Current sample time 1.75us seems too short and some nets with weaker
driver don't convert correctly. Let's lengthen it to 8.75us.

BUG=chrome-os-partner:14319
TEST=See correct voltage level.
BRANCH=none

Change-Id: Ib65a07474787504e5f72522167bafad8bb5730bc
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42845
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-06 23:17:15 -08:00
Vincent Palatin
fe2e8852b9 stm32mon: add back flashing progression
As we no longer have the low-tech dots to show the progression of the
on-going flashing, display a completion percentage to give the user a
hint of the ETA.

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

BRANCH=none
BUG=none
TEST=./util/flash_ec --board=spring
and see accurate progression percentage reported.

Change-Id: I75ccbe3433acd6c94d03a08bf462ea4516e4ce02
Reviewed-on: https://gerrit.chromium.org/gerrit/42733
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2013-02-06 10:35:52 -08:00
Vic Yang
e9c3b705d5 spring: Tweak battery LED policy
When battery is nearly full, we sometimes see:
  - Battery asks for no current, but slowly discharge (5-7 mA)
  - Battery asks for current, but not charging.
For these cases, we consider the battery full and show green LED.

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

Change-Id: I2808d4c1a89d37000244fb308197cdef473ec5be
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42688
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-05 23:20:17 -08:00
Vic Yang
e955c62792 spring: Limit USB port current
BUG=chrome-os-partner:14319
TEST=Attach different chargers and see corresponding PWM duty cycle set.
BRANCH=none

Change-Id: I10c6e28ddf5a959849a6f14d9ca3894be4f16e30
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42691
2013-02-05 21:20:06 -08:00
Vic Yang
57d9c35198 Mask 'tags' in .gitignore
If ctags is used, git complains about uncommitted 'tags'. Let's add it
to .gitignore.

BUG=None
TEST='git status' and doesn't see git complain about 'tags'.
BRANCH=none

Change-Id: I6026e83b1537eb61439f22a0b09dccb07283c820
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42689
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-05 20:58:44 -08:00
Vincent Palatin
231319c08c stm32: implement SMBUS-style read block/string
Add support in the I2C driver for SMBUS-style read block operations.
As defined by the SMBUS standard, a "read block" returns at most 32
bytes of data plus the size of response as the first byte.

It's used to read smart battery strings such as manufacturer or model.

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

BRANCH=none
BUG=chrome-os-partner:14314
TEST=On Spring, read the battery manufacturer and model from a kernel
patched for the smart-battery passthrough.

Change-Id: I069ce7f64414817e94516e913643d3847a29d176
Reviewed-on: https://gerrit.chromium.org/gerrit/42647
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-05 20:16:22 -08:00