Commit Graph

1428 Commits

Author SHA1 Message Date
Vincent Palatin
e2dd54288d tsu6721: accept new revision of the chip
We have new TSU6721 silicon with Version ID = 2,
so we need to accept 0x12 as Device ID.

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

BRANCH=spring
BUG=none
TEST=run on a board with the new silicon version and see that the
charger is properly detected.

Original-Change-Id: I12ea80b21a0d3abc5ce45856e9c9f9cdf8fd7e3e
Reviewed-on: https://gerrit.chromium.org/gerrit/46752
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 5838bd56096903eb3dec420fb0c3399fea52a870)

Change-Id: Id24e436e5900b6f4047a783cb4f50ca1a4344f29
Reviewed-on: https://gerrit.chromium.org/gerrit/46755
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-03-28 11:18:09 -07:00
Randall Spangler
c2b94fd184 Move files in preparation for merging keyboard_scan modules
This is part one of a series to merge the keyboard scan interface to
be common across all platforms.

This change just moves and renames files and APIs and removes some
read code, and sets up protocol-specific CONFIG options.  It makes the
next CL which actually merges keyboard scanning easier to parse.

BUG=chrome-os-partner:18360
BRANCH=none
TEST=compile all boards; test keyboard on spring and link

Change-Id: I815a40aae4e5d5f333b8501aff9656080533d913
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46549
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-03-27 11:35:20 -07:00
Todd Broch
0a2603e8ea spring: Enable low power mode.
This mode was disabled initially to make sure it didn't side-effect
things during early development.  Now that branch is cut lets
re-enable and backport when stability is proven.

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

BRANCH=spring
BUG=chrome-os-partner:17587
TEST=manual, install & run on Spring ... system functions.

When device is plugged stays awake regardless of battery state.
When device is unplugged sleeps and power is saved.
When device is re-plugged awakes.

Change-Id: I9a85fa7376d1a94c9864beed3d053e8b49480959
Reviewed-on: https://gerrit.chromium.org/gerrit/45594
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
2013-03-26 18:03:20 -07:00
Randall Spangler
c5127abeee stm32: unimplemented hibernate hard-reboots instead of hanging
This more closely emulates what LM4 does if it hibernates and then
immediately wakes.  Keeps the system from becoming silently
unresponsive if a hibernate is triggered on STM32.

BUG=chrome-os-partner:18371
BRANCH=none
TEST=from ec console, 'hibernate' reboots instead of hanging

Change-Id: I031f79239725d69ba054323e4fbf8f59133f2093
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46286
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-03-25 11:45:19 -07:00
Randall Spangler
10ac310605 Move keyboard dimension and key constants to keyboard_config.h
These were previously duplicated between multiple keyboard_scan.c and
board.c files, and there were a bunch of different constants #defined
to be 13.

BUG=chrome-os-partner:18360
BRANCH=none
TEST=compile all boards; test keyboard on spring and link

Change-Id: I91bf9d56d2a56ff25ff307ff10883ca87b6937e5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46165
2013-03-22 11:24:29 -07:00
Randall Spangler
743c05f01f Add keyboard_raw interface
This is the low-level platform-dependent interface to drive keyboard
columns, read rows, and handle keyboard interrupts.

Both lm4 and stm32 had something like this before, but the interfaces
weren't fully explicit or compatible.

BUG=chrome-os-partner:18360
BRANCH=none
TEST=manual

- Build all platforms.
- Boot system and test typing on keyboard.
- Hold power+refresh+esc to test boot key detection; should go to recovery.

Change-Id: Ie3bcc1d066a4da5204f0e236daeb52c4064a6213
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46156
2013-03-22 11:24:28 -07:00
Vic Yang
cdb08e1221 Use timeout instead of retry count for pre-charging
Now that PMU task is waken not only by timer, we shouldn't depend on
retry count anymore. This moves pre-charging timeout to actually use
timestamp.

BUG=none
TEST=Remove battery and boot. See charge state goes to error after 15
seconds.
BRANCH=spring

Change-Id: Iff587bc824ffee93650184c14f1fc403d26ebc06
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45957
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-20 23:47:46 -07:00
Vic Yang
89ad54d2b2 spring: minor cleanup of USB charging code
No functionality change.

This includes:
  - Breaking the way-too-long function into multiple functions
  - Less verbose logging code

BUG=none
TEST=Build and check USB charging still works.
BRANCH=spring

Change-Id: I8524cb3da9a0e90427664e839ce33d3abe0263a0
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45842
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-20 23:47:46 -07:00
Vic Yang
a0661f6742 spring: disable boost when AP is off and no charger is attached
When AP is off and no charger is attached, we can safely disable boost
to save power.

BUG=chrome-os-partner:18305
TEST=1. AP off, no charger     -> BOOST_EN 0
     2. AP off, with charger   -> BOOST_EN 1
     3. AP on, no charger      -> BOOST_EN 1
     4. AP on, with charger    -> BOOST_EN 1
     5. AP on->off, no charger -> BOOST_EN 1->0
     6. AP off->on, no charger -> BOOST_EN 0->1
BRANCH=spring

Change-Id: I7ff49e51057126490d09a3f0b1be2c60ca6a9bd3
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45830
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-20 23:47:43 -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
Randall Spangler
447b05b828 Move asserting host keyboard interrupt signal to keyboard_scan
The implementation is identical on all stm32 hardware, so remove all
the duplicate copies from board.c files.  mccrosskey doesn't have
GPIO_EC_INT so stub it out like we do on bds.

No functional change, just moving code.

BUG=none
BRANCH=none
TEST=build mccrosskey,daisy,snow,spring

Change-Id: I7d4378650d7b4c640c15180c41459a41620f5bd3
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45920
2013-03-20 17:42:04 -07:00
Randall Spangler
22ff9df913 Move battery LED code on spring to common
It's not board-specific, so move it out of board.c.

No functional changes; this is just moving code and renaming a few functions.

BUG=chrome-os-partner:18256
BRANCH=none
TEST=build spring

Change-Id: Ib004066aed93745cb0c96d3cb45d70b728545492
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45918
2013-03-20 17:42:04 -07:00
Randall Spangler
f8393fab2c Move gaia event handler declarations to gaia_power.h
This removes duplicated code in 3 different board.c files.

No functional changes, just moving declarations.

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

Change-Id: Ie6266dca7d7d160e154fce1a09452e5cc9a1095c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45898
2013-03-20 17:42:03 -07:00
Randall Spangler
78b0e9863d Use chipset_reset() interface instead of system_warm_reboot()
We have a common chipset interface for performing a warm reset of the
AP, so move the implementation from system_warm_reboot() there.  (It
was never a system function anyway; system = EC+AP; chipset = AP)

No functional change; just renaming functions.

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

Change-Id: Ibc2c5efced5660c4335cd1868470184397800acd
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45891
2013-03-20 15:23:29 -07:00
Randall Spangler
34e17d4c05 Move I2C arbitration to its own file
It's only board-specific in that we've only needed it on snow so far.
But by that logic, x86_power would be board specific because we've
only needed it on link.

No functionality change, just moving code between files and renaming
the interface to indicate it's not board-specific.

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

Change-Id: I35debdaa71829d55a2fbc5d3c62b2aaf6e467633
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45879
2013-03-20 15:23:29 -07:00
Vic Yang
19920f1f74 spring: reset TSU6721 when Toad's ID changes
When Toad's ID changes, VBUS goes low for 10ms. This, however, is not
picked up by TSU6721 and thus we need to monitor VBUS and reset TSU6721
when necessary. By resetting TSU6721, we can force it to update device
type.

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

Change-Id: Ib96bbb0f101c8c5f5371591603af2dee27f01cc8
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45727
2013-03-20 01:02:09 -07:00
Randall Spangler
f8d5958b6f Fix spring not compiling
Apparently the presubmit queue isn't building Spring firmware?  My
change and Vic's collided and TOT doesn't compile.  This fixes it.

BUG=none
BRANCH=none
TEST=build spring

Change-Id: I3903c7dce741d4395d0d71585da4332b47f62aba
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45901
2013-03-19 18:03:33 -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
Randall Spangler
24f0d888dd Use common declaration of keyboard_scan_interrupt()
Code cleanup: declare keyboard_scan_interrupt() once, not per board;
the implementation is common anyway.

No functional changes; just renaming.

BUG=none
BRANCH=none
TEST=build daisy,snow,spring,mccrosskey

Change-Id: I1e33cbe2c868bc47b641d36d26f07c3b5a7ba3c7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45874
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-03-19 14:59:32 -07:00
Randall Spangler
a3c2a73226 Rename board_get_ac() to extpower_is_present()
Code cleanup; use the same function names to mean the same thing
across boards.  No functional changes; just renaming.

BUG=none
BRANCH=none
TEST=build daisy,snow,spring

Change-Id: Icbb4cfda5f5f9ba0cbbc07fee622e9c21af3f8cd
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45867
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: David James <davidjames@chromium.org>
2013-03-19 14:59:31 -07:00
Randall Spangler
9ddb7e0708 Rename tasks to HOOKS and CHIPSET
Rename tasks

TICK -> HOOKS
  The hooks task handles more than just the TICK hook now.

X86POWER -> CHIPSET
GAIAPOWER -> CHIPSET
  Kinda kludgy that the name of the task controls which chipset source gets
  included.  Change this to a CONFIG_CHIPSET_{X86,GAIA} #define to make it
  easier to support future chipsets.  Also, rename the task function to
  chipset_task() so ec.tasklist is chipset-agnostic.

No code changes, just renaming constants and functions.

BUG=none
BRANCH=none
TEST=build bds,link,daisy,snow,spring

Change-Id: I163ce1cd27b2d8d030d42bb1f7eb46b880c244fb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45805
2013-03-19 10:31:12 -07:00
ChromeOS Developer
6c285c0994 Move external power detect for link to its own file
Now that it doesn't need to leverage SWITCH_TASK to send the AC_CHANGE
notification, pure GPIO-based external power detection can move from
switch.c to its own file.

BUG=chrome-os-partner:18256
BRANCH=none
TEST=add AC power, UI shows charging indicator; remove AC, indicator goes away

Change-Id: Id495f34185b7d971c241ac6d0a8311a6bf544507
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45789
2013-03-19 10:31:12 -07:00
Randall Spangler
c196c66432 Call AC change hook from the hook task
Using code like this, modules which service interrupts and notify
hooks will no longer need to have their own tasks to call
hook_notify() from.  They can share the hook task as long as they
don't mind the notification possibly being deferred.

BUG=chrome-os-partner:18256
BRANCH=none
TEST=add AC power, UI shows charging indicator; remove AC, indicator goes away

Change-Id: I1bc32d21b2202c3242d39e0fc533198cd5bb9c66
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45780
2013-03-19 10:31:10 -07:00
Vincent Palatin
f2df09d602 spring: set boost PWM frequency to 32Khz
Push the PWM frequency outside the audio band to avoid audible whining.

Also fix the off-by-one in the PWM frequency computation.

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

BRANCH=spring
BUG=chrome-os-partner:17583
TEST=manual : probe the PWM output with a scope.

Change-Id: Ie1c8c5aed72bef46c8bac16c1bf3007e8e9573bb
Reviewed-on: https://gerrit.chromium.org/gerrit/45584
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-15 11:02:49 -07:00
Randall Spangler
05f496759f Add external power present flag to charge_get_flags()
Modules that need to find out about charge/power state no longer need
to use the lower-level switch API.

(This will matter more in future CLs which handle conditions like
"external power present, but at low power so we're doing battery
assist" - that can simply be state=discharging,flags=external_power_present.

BUG=chrome-os-partner:18256
BRANCH=none
TEST=add AC power, UI shows charging indicator; remove AC, indicator goes away

Change-Id: I62130a4e089297fa47ab03f6a76082593c936761
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45515
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-03-15 09:07:58 -07:00
Randall Spangler
744cada9d5 Rename power_led.c to onewire_led.c
No code changes, just renaming to make the filename more useful.

BUG=chromium-os:18256
BRANCH=none
TEST=build link.  Plug in AC.  See plug LED come on.

Change-Id: I00d9f222de0b097bb68ef235bc6b0015e4c62f7e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45494
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-03-14 15:44:15 -07:00
Randall Spangler
75acd4065a Clean up power LED state machine on link
The power LED now has its own tick-based handler which knows how to
blink the LED and resend the desired LED state to work around the
flaky 1-wire connection.

Removes a bunch of LED state code from charge_state.c.

No user-visible impact.  Does not need to go into link branch.

BUG=chromium-os:18256
BRANCH=none
TEST=manual

1) Discharge battery to <97%
2) Plug in AC.  LED=yellow
3) 'ectool chargeforceidle 1' from root shell.  LED=blinking green/off.
4) 'ectool chargeforceidle 0' from root shell.  LED=yellow.
5) Wait for battery >= 97% (or 'battfake 98' from EC console).  LED=green.
6) Unplug battery.  LED=red (may take 10 sec).
7) Replug battery.  LED=green.

Change-Id: I999ee3e1abe269bb3f737bbc75e0b872316605ce
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45469
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-03-14 15:44:14 -07:00
Vic Yang
10d845eb10 spring: Fix a bug that yellow LED is not turned off
When leaving breathing mode, we should switch yellow LED from lighting
engine back to PWM control.

BUG=chrome-os-partner:18244
TEST=Check yellow LED leaves breathing mode
BRANCH=spring

Change-Id: I39260ac9040baaf193ce95eec7941aeb6d97e7e8
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45436
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-14 11:27:14 -07:00
David Hendricks
94f4bb38a0 Initial McCroskey support
This adds a board target for McCroskey. It is loosely based on
Snow.

The clock will be set up differently and the keyboard GPIOs are
not the same, so some stm32 code needed to be updated.

BUG=none
BRANCH=none
TEST=tested on McCroskey (we get to the serial console)
Signed-off-by: David Hendricks <dhendrix@chromium.org>

Change-Id: I5e11a3257fed1797f4cc4dcccf3530585b78da82
Reviewed-on: https://gerrit.chromium.org/gerrit/43414
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2013-03-13 16:05:39 -07:00
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