Commit Graph

454 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
c06e987c1b Tweak lp5562 driver interface
This makes it possible to define color constants so as to reduce code
size when called.

BUG=chrome-os-partner:17561
TEST=Build success.
BRANCH=none

Change-Id: I800b8d4b84749907b071febfea58d27fef7cc2b7
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42617
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-05 09:45:44 -08:00
Vic Yang
17dae824d2 spring: Add LP5562 driver
BUG=chrome-os-partner:17341
TEST=Set LED color on Spring board
BRANCH=none

Change-Id: Ibae11a0cf8a724a38e96c5c49952799101bb5764
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/41693
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-01-21 20:25:47 -08:00
Vincent Palatin
c8a61c39ef Add a pass-through for the smart battery
Allow to send commands to the smart battery using EC commands when the
battery is connected to an I2C bus behind the EC.

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

BRANCH=none
BUG=chrome-os-partner:14314
TEST=on Spring, with a kernel including patch to use the pass-through
for the sbs-battery driver, run "power-supply-info" and see the correct
information.

Change-Id: Ie10f1c95afe4a33cf0b55d5a0de7640d5971ebb3
Reviewed-on: https://gerrit.chromium.org/gerrit/41289
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2013-01-19 10:59:20 -08:00
Vincent Palatin
b24b745f81 Add a pass-through for TPSchrome LDOs
Allow to send commands to switch on/off the TPSchrome LDOs by using EC commands
when the TPSchrome chip is connected to an I2C bus behind the EC.

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

BRANCH=none
BUG=chrome-os-partner:14314
TEST=on Spring, with an updated bootloader, switch on screen FETs from
U-Boot instead of hardcoding them in the EC board code.

Change-Id: Ic6cebf04ba73a7c0ca2c54f532f8cf4c953ac0c1
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/41288
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-01-16 08:35:03 -08:00
Vic Yang
fd29230988 spring: Add a host command for USB mux switching
To make test and bring-up easier, adds a host command for USB mux
switching.

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

Change-Id: I9da43fe934881ce24f326275ef312c4e6a474f11
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/40586
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-01-08 09:30:00 -08:00
Vic Yang
40c79398a6 spring: Sense attached device type
This adds USB port control to charger task. For now, it only senses
attached device type and log it to console.

BUG=chrome-os-partner:14319
TEST=Attach/detach charger and see console output.
BRANCH=none

Change-Id: I1218d520c292d9d398c868122ae3876d3fc889bc
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/40078
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-01-08 08:58:36 -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
Vic Yang
4d7820f4ad spring: Add interrupt and device type support for TSU6721
This adds functions to control interrupt and get device type from
TSU6721.
Also expose initialization function so that we can initialize TSU6721
before we solve the initialization problem.

BUG=chrome-os-partner:14318
TEST=Build success.
BRANCH=none

Change-Id: Ia50f1c93309360d35902a707090694e94a3f7a74
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/40077
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-12-21 08:23:24 -08:00
Vincent Palatin
e927d1506a spring: add basic TSU6721 driver
for now, just control the USB pins muxing.

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

BRANCH=none
BUG=chrome-os-partner:14318
TEST=on Spring, put the EC UART on the micro-B connector and read it
using a modified FTDI cable.

Change-Id: Ib0c87e483fb0bbe1835bd6ea008176b88d6f12f8
Reviewed-on: https://gerrit.chromium.org/gerrit/38361
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2012-12-13 09:01:09 -08:00
Randall Spangler
ad2adc4022 Invalidate hash if flash operation changes the hashed region
This prevents the EC from returning a stale hash.

BUG=chrome-os-partner:16668
BRANCH=link,snow
TEST=manual, with WP disabled

From EC console
- Boot system and wait a second
- hash --> prints valid hash
- flasherase 0x20000 0x1000
- hash --> invalid
- hash rw
- hash --> prints valid hash
- flashwrite 0x20000 0x1000
- hash --> invalid
- hash rw
- flasherase 0x38000 0x1000
- flashwrite 0x38000 0x1000
- hash --> still valid (since 0x38000 is outside the rw section)

From root shell
- ectool hash --> prints valid hash
- ectool flasherase 0x20000 0x1000
- ectool hash --> invalid
- ectool hash recalc RW
- ectool hash --> prints valid hash
- echo 'Making a hash of this' > /tmp/hashofthis
- ectool flashwrite 0x20000 /tmp/hashofthis
- ectool hash --> invalid
- ectool hash recalc RW
- ectool flasherase 0x38000 0x1000
- ectool flashwrite 0x38000 /tmp/hashofthis
- ectool hash --> still valid (since 0x38000 is outside the rw section)

Change-Id: Id915a504a7bc70b8b8c339b5ce55dc5bad5838fe
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/39484
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-12-10 15:14:38 -08:00
Vincent Palatin
3c575ccb02 link: allow to decrease maximum battery charging current
Add an interface to allow the CPU to cap the maximum battery charging
current.
The maximum is removed every time the machine goes to S3 or S5.

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

BRANCH=link
BUG=chrome-os-partner:16041
TEST=on Link, plug AC to charge the battery,
then run "ectool chargecurrentlimit 1200" and see
the charging current in "power-supply-info" decreasing to 1.2 A.

Change-Id: I10900e1c264d2db67809638ec0dcb836d721fa75
Reviewed-on: https://gerrit.chromium.org/gerrit/37532
Reviewed-by: Sameer Nanda <snanda@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2012-11-07 23:48:04 -08:00
Louis Yung-Chieh Lo
25bbb6b5de More supports for A20 enable/disable
Add i8042 output port commands (0xf0-0xff), I8042_ENABLE_A20 and
I8042_DISABLE_A20.

BUG=chrome-os-partner:13119,
BRANCH=None
TEST=Tested on W7 installer. No KB error shown on EC console.

Change-Id: I9ad1fd7baa10683ef18ccf13faf09dc0cefcca0a
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34994
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
2012-11-04 20:27:57 -08:00
Randall Spangler
e9e02762dd Move reset/overheat/shutdown funcs to chipset interface
They're not x86-specific, so move to the chipset interface.

BUG=chrome-os-partner:15579
BRANCH=none
TEST=x86reset warm, then x86reset cold.  Should reboot OS in each case.

Change-Id: Ib571ab916bab16179198a0d054320e59afbae124
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36785
2012-11-01 12:45:28 -07:00
Randall Spangler
d83f42bdc8 Switch temp sensor polling to use hooks instead of task
This reduces memory / code size, and gets rid of ifdefs in temp_sensor.c.

BUG=chrome-os-partner:15714
BRANCH=none
TEST=boot system and run 'ectool temps all' every few seconds
    - ectool temps all
The numbers should update over time.

Change-Id: Idaac7e6e4cbc1d6689f5d3b607c623a5cc536a4f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36940
2012-11-01 12:45:22 -07:00
Randall Spangler
e3c5f77924 link: Fix overflow in hibernate time calculation
The time out value passed to task_wait_event() is signed 32-bit and
thus waiting for 24 hours will cause overflow.  Limit max wait time.

BUG=chrome-os-partner:15797
BRANCH=link

TEST=Disconnect AC, shut down system, and close lid.  From ec console,
do 'hibdelay 8000' and then wait 2.5 hours.  EC should have
hibernated.  (8000 is more than twice the max time for
task_wait_event())

Change-Id: I5fa505554182e8bad6399c12a382ff71bb123d8f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/37095
Reviewed-by: Vic Yang <victoryang@chromium.org>
2012-11-01 10:08:54 -07:00
Simon Glass
f3c88fa1ab stm32: Implement keyscan test infrastructure
Support the keyscan test functionality on stm32.

Note: This is enabled by default so that it continues to build. But it
is unlikely that we will want this in a shipping image. I suggest we add
the facility for a dev build.

Secondly, the stack has to be larger due to a printf (which admittedly I
could just remove). Should we make the stack size conditional on the
CONFIG? Seems a bit ugly, on the other hand we don't want to waste IRAM.

BUG=chrome-os-partner:12179
BRANCH=none
TEST=manual for now:
On snow:
./ectool keyscan 20000 key_sequence.txt

See that the test passes.

Change-Id: Ic441ca0bde1be9589a924374605e2f146d16f423
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35118
2012-10-31 17:21:00 -07:00
Randall Spangler
433f98c6b6 Add per-second hook
PWM and temp sensor monitoring want to happen every second,
vs. several times a second for watchdog and LPC.

This is still considerably simpler than having tick functions declare
an interval at which they want to be called, which would require a
RAM-based array of pending tick functions and alarm times.  If you
need that level of complexity, you still need a task.

BUG=chrome-os-partner:15714
BRANCH=none

TEST=temporarily add HOOK_TICK and HOOK_SECOND hooks and see that on
LM4, HOOK_TICK is called 4x a second and HOOK_SECOND is called every
second.

Change-Id: I5c09842fd356d3254021486949b2799142068b4f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36938
Commit-Ready: Simon Glass <sjg@chromium.org>
2012-10-30 15:33:25 -07:00
Randall Spangler
8b3a242ff0 Watchdog is reloaded by HOOK_TICK, not its own task
This reduces memory footprint.

BUG=chrome-os-partner:15714
BRANCH=none
TEST=system still boots; 'waitms 1500' prints watchdog error dump

Change-Id: Ieb0248a34655514b03d919cc36c2b369691da716
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36937
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-10-30 15:33:24 -07:00
Randall Spangler
a21ea56e76 Rename power_button module to switch
Since it handles not just power button, but also lid switch, AC
detect, and other switches.

No functional changes; just renaming.

BUG=chrome-os-partner:15579
BRANCH=none
TEST=boot system, power on/off with power button

Change-Id: I51628a52293f7207715f5f6bf368a08fe6c3dbce
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36821
2012-10-30 14:50:03 -07:00
Randall Spangler
80467aff91 Clean up clock module
No functional changes; just code cleanup.  On LM4 this also #ifdef's
out the 'sleep' and 'pll' commands since they're big and we don't use
them.

BUG=chrome-os-partner:15579
BRANCH=none
TEST=boot system

Change-Id: I1b72d07d6cca2c783d7ac4c880119df3e88e356e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36799
2012-10-30 12:42:47 -07:00
Randall Spangler
ef89439cc0 Clean up GPIO module.
No functional changes, just code cleanup.

BUG=chrome-os-partner:15579
BRANCH=none
TEST=gpioget returns reasonable values

Change-Id: I4301ccc68ade775f78f4ccd84710d2cd4bc25252
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36800
2012-10-30 12:42:46 -07:00
Randall Spangler
e82b68bcb9 Clean up jtag module
No functional changes

BUG=chrome-os-partner:15579
BRANCH=none
TEST=boot system; use gdb to connect to EC

Change-Id: I2817d04e4de102e4201506cfe51cdf0bd939fcdb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36802
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-10-30 12:42:46 -07:00
Randall Spangler
f76cb374f8 Clean up LPC module
Tidied comments, and removed handling of ACPI events on host command
port (not needed since EVT hardware is now EOL'd).

BUG=chrome-os-partner:15579
BRANCH=none
TEST='ectool hello' succeeds

Change-Id: I063382b9981f713ba23f7714b4ccb7faa957b411
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36804
2012-10-30 12:42:45 -07:00