Commit Graph

1226 Commits

Author SHA1 Message Date
Vincent Palatin
07aa700e92 spring: enable USB boost charger by default
Needed for easy power on until we have the full USB charge state
machine.

note: the GPIO name ILIM_1500 is somewhat misleading,
it is connected to the enable pin of the TPS43060

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

BUG=chrome-os-partner:14319
TEST=manual :
plug the board and press servo power button,
see the AP rails coming up.

Change-Id: I93421d1581065bcc1e7be07086e74d11d1e1ec56
Reviewed-on: https://gerrit.chromium.org/gerrit/35271
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-10-11 23:32:23 -07:00
Bill Richardson
d6f05e0d61 Parameterize the lightbar behavior as much as possible.
This change replaces most of the hard-coded lightbar constants with values
that can be updated at run-time, so that if we change our minds about colors
and timing we can tweak some of the values without requiring an EC/BIOS
update.

It also adds the "ectool lightbar params" command to get and set those
values from the host. You can see the values from the EC console ("lightbar
params"), but there's no way to set them.

BUG=chrome-os-partner:8039
BRANCH=Link
TEST=manual

From the EC console, run

  lightbar params

It should display the current values that can be changed.

Log in to the host and run this to see the same values:

  ectool lightbar params

Or edit and change them with this:

  ectool lightbar params > /tmp/vals.txt
  vi /tmp/vals.txt
  ectool lightbar params /tmp/vals.txt

The updated parameters are persistent across EC jumps (RO->RW), but are lost
when/if the EC reboots (as it will after the AP is off for 24 hours, for
example).

Change-Id: Ic2a3fd6f8062673432b48904933e0c7239b8658b
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35289
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-10-11 14:24:43 -07:00
Randall Spangler
b00a446ec5 link: EC reclaims fan control on AP shutdown
Previously, if the AP took fan control, the EC would never take it
back.  This meant the EC would leave the fan off even if the system
was sitting at the INSERT screen or booted an alternate OS.

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

- boot system
- from EC console, fanset 0
- faninfo shows fan at 0rpm
- from root shell, crossystem recovery_request=123 && reboot
- wait a few mins
- faninfo should show fan spinning again

Change-Id: I534c9978194085467f1df6eae971c55d4e8083be
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35309
2012-10-11 14:24:43 -07:00
Randall Spangler
ceb696a208 link: Reset fan target RPM when suspending
This prevents the fan from coming on loudly during resume.

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

- power on system
- wait for it to heat up; type faninfo periodically from ec console
- when faninfo reports non-zero, type 'powerd_suspend' at root shell
- faninfo should now report Target: 0 rpm Enable: no

Change-Id: Ia5ee93c0f5c6626afd54a22d2996ab65cf8e3b18
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35303
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-10-11 14:24:42 -07:00
Randall Spangler
25c6574da6 link: TMP006 S0 param is uncalibrated by default
S0 values are incorrect and may even need to be calibrated on a
per-system basis.  Set them to 0 by default so that the EC doesn't
return inaccurate remote temperature readings before calibration data
is sent.

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

- temps -> remote temps are all not calibrated
- t6cal 1 s0 9301
- temps -> PCH D-Object temp now returns a temperature

Change-Id: I43facc60cf947ebd9441a8a629a76f7ffc8f3959
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35302
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-10-11 14:24:41 -07:00
Randall Spangler
23fe5ed867 link: Added sensor-not-calibrated error for TMP006
BUG=chrome-os-partner:15174
BRANCH=link
TEST=manual, from root shell
 - ectool temps all -> prints all temps
 - ectool tmp006cal 1 0 0 0 0
 - ectool temps all -> sensor 3 not calibrated

Change-Id: I16ee818c948fe90ac7c18b230c5d9f9a0ec83ded
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35288
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-10-11 14:24:40 -07:00
Randall Spangler
22e03a1de6 link: Temp sensors can return not-powered error code
This removes the need for a separate method to check sensor power, and
gets rid of temp_sensor.c knowledge of what powers each sensor.

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

- reboot
- within a second, type 'temps'; I2C sensors should return error 1
- type 'temps' again; all sensors should return data
- power off system
- type 'temps' again; I2C sensors and PECI should return error 8
- 'gpioset enable_vs 1'
- type 'temps' again; I2C sensors should return valid data; PECI should still
  return error 8.

Change-Id: I17c353b3c483bc320769307c7715008ec729089b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35287
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-10-11 14:24:36 -07:00
Randall Spangler
8f2e99da75 link: Temp sensor read can return an error code
This will be used in a follow-up CL to return specific error codes
(not powered, not calibrated, etc.)

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

Power on system.
'temps' should return all good temps.
Power off system (into S5)
Only ECInternal temp should work; others should return Error 1
'gpioset enable_vs 1' and wait a second
Now all the I2C temps should display good data, but PECI will still be error 1.

Change-Id: I925434e71653ad53ad76bad992a7a8fdeadb088c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35286
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-10-11 13:47:17 -07:00
Randall Spangler
d1bebbbe66 Add host command to get/set TMP006 calibration data
Needed for host-based thermal control and tweaking.

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

From a root shell,
  ectool tmp006cal 0 3.5e-14 -2.8e-5 -5.5e-7 4.5e-9
  ectool tmp006cal 2 3.6e-14 -2.9e-5 -5.6e-7 4.6e-9
  ectool tmp006cal 0
    S0: 3.500000e-14
    b0: -2.800000e-05
    b1: -5.500000e-07
    b2: 4.500000e-09
  ectool tmp006cal 2
    S0: 3.600000e-14
    b0: -2.900000e-05
    b1: -5.600000e-07
    b2: 4.600000e-09

At the ec console, "t6cal" should show the settings took effect as well.

Change-Id: If43b11e1e827483f0a20db1a2e5644f3475fd95e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35215
2012-10-11 13:47:17 -07:00
Randall Spangler
bea56570f3 Add t6cal console command to set/print TMP006 calibration
Note that radix must be specified as an integer, because we don't have
floating-point parsing.  So to set the first sensor's S0 to 3.600e-14,
do:
   t6cal 0 S0 3600

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

From EC console,
  t6cal 0 s0 3500
  t6cal 1 b0 -3000
  t6cal 1 b1 -5600
  t6cal 2 b2 4700
  t6cal
The final t6cal should show the changes from the previous commands

Change-Id: I2f8f71890e8e64a427cc29c3ef86ca991ce6b039
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35204
2012-10-11 10:06:56 -07:00
Randall Spangler
0b6b6b7754 Refactor TMP006 module
1) Use floating-point more freely, since it's on all the time now, and
the old fixed-point code no longer compiled.

2) Sensitivity and Bn values are now in a RAM-based struct in
preparation for setting them at runtime.  No changes from current
values.

3) If a sensor fails to read good data, is initialized, or loses
power, its die temperature history will be set to the next good
temperature, rather than persisting an arbitrary start value or old
state.  This fixes reading wildly inaccurate object temperatures for
the first few seconds following boot/resume.

4) If a sensor loses power, wait for the sensor to report data-ready
before reading temperature/voltage.  Otherwise, those read as 0, which
again throws off the first few seconds of data.

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

TEST=Boot system and set at login screen for a minute to reach thermal
equilibrium.  Then reboot system, type 'temps' repeatedly.  Data from
TMP006's should initially be Error; after a second or so it should be
good, and shouldn't change more than a few degrees.

Change-Id: Id0b42b9b18e94978ba7d3a1ee33194e44b1904bc
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35188
2012-10-11 10:06:54 -07:00
Randall Spangler
678e649240 Add console channel for thermal output
Needed for debugging upcoming TMP006 calibration changes

BUG=none
TEST=boot; EC console output should appear as before
BRANCH=link

Change-Id: I93a18949888533ecefd226fdc64e1fab7d52a8f1
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35187
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-10-10 16:28:40 -07:00
Sameer Nanda
3af7bc4335 temp_metrics: remove prochot and TCC modifications
External prochot input was disabled due to board issues. Re-enable it
since those board issues are now fixed.

Remove modification of TCC offset. Changes to TCC offset from this
script are ineffective since they need to happen before the BIOS sets
the BIOS_RESET_CPL bit way early in the initialization sequence.

BUG=chrome-os-partner:9193
TEST=from shell run "rdmsr 0 0x1fc" and check that bit 0 is set to 1.
BRANCH=link

Change-Id: Ida2a090539d7e074794e13a90f251babb6c4ade9
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35067
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
2012-10-10 15:59:04 -07:00
Bill Richardson
f874e2a1ca Fix lightbar test pattern
An earlier commit made the lightbar test sequence run much too quickly. This
puts it back. I'm not sure if the factory still looks at this, but I think
they did at one time, so we might as well keep it working. It's helpful for
debugging anyway.

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

Log in, run "ectool lightbar seq test". You should see the lightbar colors
pulse in various colors, then go back to whatever they were doing before.

Change-Id: I11c24a448bf40f0c0c82456fcf6e0415a0392c28
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35190
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-10-10 15:59:01 -07:00
Vincent Palatin
160b343e7c stm32: fix race condition enabling keyboard interrupt
Previously, if a key was pressed after the last polling but
the interrupts were fully enabled, we were missing the edge.
So dropping the key press event and seeing only the key release.

Now we check if keys are down before waiting for the next interrupt,
if any, we re-start polling immediatly.

The row state reading code is unchanged, just moved to a function
in order to re-use it.

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

(Note: This patch was originally submitted in the firmware-snow-2695.B
branch, but needed some re-factoring to merge cleanly into ToT)

BRANCH=snow
BUG=chrome-os-partner:7484 chrome-os-partner:12179
TEST=type on the keyboard and do not see any missing key presses.
On instrumented board, record the the matrix scans with a logic analyzer
and stare at the waveforms.

Change-Id: I98dc4c3af9611a276b960887384a6304b91d8b30
Reviewed-on: https://gerrit.chromium.org/gerrit/35168
Commit-Ready: 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>
2012-10-10 14:53:16 -07:00
Doug Anderson
8d187addc8 snow: i2c: Reset i2c if we get a timeout in slave mode
This is important to do because if we don't reset we could leave
the i2c bus in a wedged state (it's possible that whoever was
mastering us could have reset halfway through a transaction).

BUG=chrome-os-partner:14430
BRANCH=snow
TEST=From vt2 type: "echo bug > /proc/breakme" several times
and see good reboots.  Check scope trace and see that reset of
i2c bus helped (SDA low for 100ms and then fixed).
TEST=Run hacky "repro" script from bug see that i2c doesn't get
wedged.

Change-Id: I57010dcc5f4baa63278b6a025d44f10f00eb9e9d
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35115
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Charlie Mooney <charliemooney@chromium.org>
2012-10-10 12:48:14 -07:00
Rong Chang
e679d8504d link: Revive under voltage protection battery pack
Experiments showed that some UVP batteries took ~30 seconds to restart
its gas gauge IC. This change adds 30 seconds polling check to determine
the condition.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BRANCH=link
BUG=chrome-os-partner:13923
BUG=chrome-os-partner:14094
TEST=manual
  Disconnect battery and plug in charger. The charging LED should turn
  red after 30 seconds.

Change-Id: I425e63c428aeeaf1468bc2f9886457de1145cada
Reviewed-on: https://gerrit.chromium.org/gerrit/34886
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
2012-10-08 23:05:45 -07:00
Randall Spangler
fcd0f0a5e4 link: Hibernate EC when battery level drops below 2%
We already shut down the main processor below 3%.  Hibernating the EC
below 2% will further cut power draw and minimize the risk of
deep-discharging the battery.

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

1) discharge battery below 3%; system should shut down.  when powered
on again it should shut back down within ~10 sec.

2) discharge battery below 2%; when system shuts down it should also hibernate.

(I've also tested this with a hacked smart_battery.c which lies about
the battery state of charge, since that's faster than waiting for my
battery to discharge.)

Change-Id: I504ba927012430db5cf10b895a36e6cd6fdf4c8b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34793
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-10-05 15:21:18 -07:00
Simon Glass
1173102ae1 stm32: Implement keyboard debouncing
This brings Randall's key debounce logic into STM32. We need to
rationalize the code, but for this morning...

This should fix problems with double keypresses and missing keypresses.

BUG=chrome-os-partner:12179
BRANCH=snow
TEST=manual
- type quickly; should work
- run your finger really quickly over the keyboard; should be able to
  see keys which don't show up because you didn't press them long enough
- run your finger quickly from 1 to 0; numbers should show up in order
  (some may be missing if you sweep too fast.  there is a point where if
  two keys are hit within 1.7ms of each other they can be swapped, but any
  slower than that and they should never be out of order)
- mash your face into the keyboard to cause ghosting; should see only a few
  keys pressed

Change-Id: I6b164a17de1b4dd698f9b45a3852fd3b6c084e0a
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34765
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
2012-10-05 15:21:13 -07:00
Simon Glass
dd2d41003d stm32: Implement keyscan configuration command
Implement a command to allow getting and setting the keyboard
configuration.

BUG=chrome-os-partner:12179
TEST=manual
- use ectool to read all keyscan paramters
- use ectool to update flags to 0, see that keyboard stops working,
then set flags to 1 and see that it starts working again.
- use ectool to update scanning period to 100ms, see that it drops lots
of keys when typing
- use ectool to set fifo size to 1, see that the fifo no longer fills
up

Change-Id: I5afb3b48b1262a1570d7411ffd8b2e6ea3a65f6b
BRANCH=snow,link
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34635
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-10-05 10:41:21 -07:00
Simon Glass
9bf1539d21 stm32: Reduce keyboard scan period from 10ms to 3ms
Experimentally it is possible to press a key on snow for only 4.8ms.
We should aim to scan more frequently to catch those who only just
touch the keys, or type very quickly.

It takes a little over 2ms to complete a keyboard scan at present.
We shold aim to reduce this, but for now, it seems safe to reduce the
default scanning frequency to 3ms.

BUG=chrome-os-partner:12179
TEST=manual
Type on keyboard on snow in browser, and see that we still get results
and the EC is stable.

Change-Id: I60827c33a58c34dd808504e58bca480bd61f5932
BRANCH=snow
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34634
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-10-05 10:41:20 -07:00
Simon Glass
a3a6a9f34b stm32: Update keyboard_scan to use run-time configuration
At present the keyboard scan parameters are hard-coded, so changing them
requires a new EC image. This can be problematic if we want to adjust
the behavior of keyboard scanning since we must send an EC update.

Change stm32's keyboard scan to use run-time config. All parameters
and behavior should remain the same with this change.

The configuration is defined by ec_commands.h since we intend to create
a command to allow access to it. It does not seem worth defining a
separate structure within keyboard_scan at present, although if we
add a new version of the command in the future then we may want to
separate these.

BUG=chrome-os-partner:12179
BRANCH=snow
TEST=manual
Boot snow into U-Boot and Linux, try the keyboard, seeing that it seems
to work as before. This is a very subjective test.

Change-Id: Ie6160f1d73b983867b96f8ccb421853f6ec99524
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34633
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-10-05 10:41:18 -07:00
Simon Glass
c782abf208 stm32: Drop key scan masks
The masks were intended to be used to ignore certain keys in the matrix to
help with de-ghosting of keys. Since this is done on the AP anyway, there
really isn't any need for them. Punt.

BUG=chrome-os-partner:12179
BRANCH=snow
TEST=manual
Build and boot into kernel, see that keyboard still works.

Change-Id: I00d1b761d24ab503c66439b095a8336fff5d5db6
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34657
2012-10-05 04:26:21 -07:00
Simon Glass
41b42b5ead Define key scan parameters and get/set command
At present the keyboard scan parameters are hard-coded, so changing them
requires a new EC image. This can be problematic if we want to adjust
the behavior of keyboard scanning since we must send an EC update.

Define the keyboard scan parameters and commands to get/set these
parameters.

Signed-off-by: Simon Glass <sjg@chromium.org>

BUG=chrome-os-partner:12179
BRANCH=snow,link
TEST=manual
Build for all boards

Change-Id: I715755cb5357503723b27ae33053dba1452e48e0
Reviewed-on: https://gerrit.chromium.org/gerrit/34656
Commit-Ready: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
2012-10-05 04:26:20 -07:00
Randall Spangler
a752e1f5d1 link: fix race condition enabling keyboard interrupt
Previously, an edge on a keyboard row could be missed if it occurred
after the last scan, but before interrupts are enabled.  Now we
explicitly check if any keys are down before waiting for an interrupt,
and if any are, we simply don't wait to scan.

BUG=chrome-os-partner:7484
BRANCH=link
TEST=the race condition's really tricky to hit

The best we can do for testing is to ensure that we ARE sleeping in
the normal case where no keys are held down.  For that, don't press
any keys, and run 'taskinfo' from the EC console twice about 10 sec
apart.  Both printouts should have virtually identical times for the
KEYSCAN task.

Change-Id: I4e0ef18a2d71d0a5d3655742bd49fc15afc4aaed
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34709
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
2012-10-05 04:26:19 -07:00
Randall Spangler
6d6cfad2a0 link: Implement keyboard debouncing
This should fix problems with double keypresses and missing keypresses.

BUG=chrome-os-partner:8826
BRANCH=link
TEST=manual
- type quickly; should work
- run your finger really quickly over the keyboard; should be able to
  see keys which don't show up because you didn't press them long enough
- run your finger quickly from 1 to 0; numbers should show up in order
  (some may be missing if you sweep too fast.  there is a point where if
  two keys are hit within 1.7ms of each other they can be swapped, but any
  slower than that and they should never be out of order)
- mash your face into the keyboard to cause ghosting; should see only a few
  keys pressed

Change-Id: I66e95c56d94cba16454ee2c37498deeb57f1a2c3
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34697
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-10-05 04:26:16 -07:00
Simon Glass
024520b1ff Remove some extensions from .gitignore
Since build output is in build/ we don't really need to have *.bin (and
others) excluded throughout the source tree. This change allows us to
check in .bin files without warnings.

BUG=none
BRANCH=snow,link
TEST=manual
$ git status
- see that we still have no stray files reported

$ git add test/test-matrix.bin
- see that there is no warning given now

Change-Id: Ia71c5c2b89c3f0eef5098c86c701cb34f666e164
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34632
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-10-04 12:22:20 -07:00
Randall Spangler
a9e8f809a3 link: add hibernate option to ectool reboot_ec
This enables the OS to request the EC drop into its lowest-power
shutdown state.  Targeted at end of factory flow, where the
at-shutdown variant is the desired variant because it allows the main
processor to shut down cleanly first.

BUG=chrome-os-partner:14838
BRANCH=link
TEST=from root shell,
  ectool reboot_ec hibernate at-shutdown
  shutdown -h now

System should shut down, and EC console should be unresponsive (since
it's hibernating).  Press power button, and system should power back on.

  ectool reboot_ec hibernate

System should shut down immediately.  Press power button, and system
should power back on.

Change-Id: I8084a3a1bca6b7c201e090552b193fe1568708a2
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34569
Reviewed-by: Vic Yang <victoryang@chromium.org>
2012-10-04 09:30:59 -07:00
Randall Spangler
66dda8936e link: Pass keyboard state array as a parameter
This is a precursor to implementing proper keyboard debouncing, and
should have no functional effect; it's just refactoring.

BUG=chrome-os-partner:8826
BRANCH=link
TEST=manual
- power+refresh+esc -> recovery mode
- boot normally and type -> yaay, you can type

Change-Id: I828d2380c164c92330d725002379b6442894f41d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34567
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-10-04 09:30:58 -07:00
Bill Richardson
c8685031a1 Major rewrite of lightbar using FP math.
Latest tweaks after working with the UI folks. This changes the S3 and S0
sequences and the transitions between them, using Google colors, smooth
fades, and persistent state across EC resets.

In S3, we only pulse when the battery is low and is discharging.

BUG=chrome-os-partner:8039
BRANCH=Link
TEST=none

Artistic criticism only, please.

Change-Id: Id75b8c2c96e2e9dc9ff27af0bfe126cfad5d490e
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34465
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-10-02 16:05:19 -07:00
Sameer Nanda
c98e107931 Fine tuning of temp_metrics thermal loop
Fine tuned temperature thresholds and added watermark concept to the
thermal loop.

BUG=chrome-os-partner:9193
TEST=Vary CPU and GPU load on the system.  The fan speed and CPU/GPU
limits should change as the skin temperature responds to changes in the
load.
BRANCH=link

Change-Id: I43739097e699bc4e724e395c6e830c7c694704cc
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34454
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-10-02 16:05:18 -07:00
Randall Spangler
3c06f602b6 link: Add charge_near_full state
Tell the host the battery is no longer charging when it hits 97%, and
set the power adapter LED to green.

This solves several problems:

1) The last 3% of charge takes a looong time.  Kernel/ACPI/UI already
have a hack to show the battery as charged when it's about 3% from
full, but the EC still showed a yellow LED.

2) If the system is charged and you briefly unplug the adapter, the
LED turned yellow for a long time as it slowly trickle-charged.  Now
it goes right to green.

3) A fully-charged battery will drop below 100% charge as it settles,
but won't accept more current at that time.  This caused the LED to
turn yellow and stay there until the battery finally settled down to
~96%, at which point it'd accept more current and top itself off.  The
whole time it did this, the kernel/ACPI/UI hack from (1) would keep
reporting "battery full".  Now the LED stays green too.

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

- Discharge system to <95% full.
- Plug adapter in.  LED should come on yellow.
- At around 97% full, the LED should turn green.
- Around that the UI will display "battery full".
  (Note that due to rounding, the UI may take a few minutes to display
   "battery full" after the LED goes green; that's ok)
- Unplug and replug adapter.  LED should come on green.  UI still reports
  "battery full".

Change-Id: Ie56fbf3a05239e73d2c765bb98d36aa5cfedc2ef
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34452
2012-10-02 16:05:17 -07:00
Randall Spangler
2768a49fd1 link: Add more info to 'ectool battery'
Now prints the rest of the memory-mapped battery info.

BUG=chrome-os-partner:14630
BRANCH=link
TEST=ectool battery, then compare with 'battery' at ec console

Change-Id: I3f5222d898bbcb8b79774a5848f9aed0067a0d49
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34424
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-10-02 12:51:50 -07:00
Bill Richardson
bc50e0cabb Enable FPU support for Link EC
With this CL, if CONFIG_FPU is defined (only for Link, ATM), the EC task
switcher will enable CONTROL.FPCA and expect all stack contexts to include
floating point state as well as normal state (an additional 18 words).

To support this, we need to increase the allocated stack space for each
task. The stack sizes are already chosen empirically, so I'm just rounding
them up a bit.

BUG=chrome-os-partner:14766
BRANCH=Link
TEST=manual

There should be no noticeable change. If you run the EC command "taskinfo"
you'll see the increased size each thread's stack, but everything that was
working before should continue to work just fine.

The additional overhead required to load and store another 18 words on each
context switch is not really measurable (I tried).

Change-Id: Ibaca7d7a2565285f049fda6906f32761e83207af
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34391
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-10-02 10:52:54 -07:00
Randall Spangler
56ce828309 link: Don't set power LED green until second idle
Currently, the charge state machine sets the power LED green the first
time it hits IDLE.  This causes the LED to briefly flash green when
the adapter is inserted, because the state machine goes
discharging->init->idle->charging.

Instead, add a new idle0 state in between init and idle which does not
set the power LED.  This allows the state machine to go
discharging->init->idle0->charging, so the LED only goes from off->yellow.

If the system is actually fully charged, it'll go init->idle0->idle
and show green.

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

- Remove adapter and allow system to discharge a bit
- Insert adapter
- Should see LED go from off directly to yellow
- Wait for charge
- Should see LED go green

Change-Id: I9b77f01fad27c8574133211c9fe250486609f3c1
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34387
Reviewed-by: Rong Chang <rongchang@chromium.org>
2012-10-01 23:50:16 -07:00
Sameer Nanda
bb66bec788 Update temp_metrics to look at skin temperatures
Updated temp_metrics to take the skin temperature into account instead
of PECI CPU temperature for controlling fan speed as well as Ivy Bridge
throttling.

BUG=chrome-os-partner:9193
TEST=Vary CPU and GPU load on the system. The fan speed and CPU/GPU
limits should change as the skin temperature responds to changes in the
load.
BRANCH=link

Change-Id: Ie3d85112de1043cf5b12a78ca1fc50f5eb6c0497
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34221
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-10-01 15:20:17 -07:00
Randall Spangler
f847d33740 Re-enable keyboard scanning at end of debounce interval
This fixes a problem where a very short power button press would
disable scanning, but not debounce to down so we'd never have a
debounced release to re-enable scanning.

BUG=chrome-os-partner:14678
BRANCH=link
TEST=tap power button very quickly, then see if keyboard still works
(may need to repeat that a few times to be sure it always works)

Change-Id: I3dd3d3f2d892f309a507463d7ad6accf32df30c4
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34225
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
2012-09-28 11:31:16 -07:00
Randall Spangler
194ad20c5b link: Re-enable USB ports on resume
Previously, ports were only enabled on S5->S3, not S3->S0.  Seems like
they should always get re-enabled on resume.

This also consolidates the USB code into a single file, cleans up the
debug output, and prints the current USB charge state when the
usbchargemode command is run without args.

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

- Boot system
- At ec console, 'usb' should print port 0 and 1 are in mode 1.
- At a root shell, 'ectool chargemode 0 0'
- At a root shell, 'ectool chargemode 1 0'
- Suspend system
- At ec console, 'usb' should print port are in mode 0.
- Resume system
- At ec console, 'usb' should print port 0 and 1 are in mode 1.

Change-Id: I3875a104338fb64db503929a018b8577d6f970e4
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34062
Reviewed-by: Vic Yang <victoryang@chromium.org>
2012-09-26 11:31:31 -07:00
Randall Spangler
5943e6c1f5 Clean up reboot host command
1) Only send the host response immediately for commands which won't
return.  This prevents double-sending a response for the disable-jump
command.

2) Remove references to the POWER_ON flag.  This was never implemented
or used, since with EC software sync the EC always powers on after
rebooting.

3) Fix help text for reboot_ec command.  (Both "A" and "RW" still do the
same thing, but "RW" is now the preferred option string.)

BUG=chrome-os-partner:12635
BRANCH=link (also applies to snow, but don't pick unless needed)
TEST=from a root shell,

flashrom -p internal:bus=lpc -r /tmp/ec.bin
flashrom -p internal:bus=lpc -w /tmp/ec.bin
ectool reboot_ec RW
ectool reboot_ec RO
ectool disable-jump

All commands should succeed.

Change-Id: Ibf5b4fb88d93e64fc7361a9f962ec7aa1df0cf3c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34051
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
2012-09-26 11:31:31 -07:00
Vic Yang
1b14b2c922 stm32f: ADC driver
This adds basic ADC support for multiple channel conversion.

BUG=chrome-os-partner:14316
BRANCH=none
TEST=1. Boot on snow.
     2. Use keyboard signal as input. Check read value changes as input
        signal changes.

Change-Id: I3c15c37446fa9273d098f6d581573c11ced45b5e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/33883
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-09-26 08:58:59 -07:00
Vic Yang
cfcd1412ea stm32: Export DMA memory size option
We need different memory size configuration in different application.
Let's export the memory size option to DMA function parameters.

BUG=chrome-os-partner:14316
TEST=Boot on snow. Check I2C host command works.
BRANCH=none

Change-Id: I30481ddf86a1526d517961e009898642ecdd649a
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/33981
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-09-26 08:58:57 -07:00
Randall Spangler
c51a8982ff link: If discharging and system is off, only poll battery once a minute
This reduces power consumption in S3/S5 because the EC doesn't need to
poll the battery every 500ms.

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

As much as can be tested with the current debug information:

- Boot system with AC adapter in.  Charge state machine should go to
  charging state.
- Remove AC adapter.  Charge state -> discharging.
- Shut system down.
- Plug AC adapter in.  Charge state -> init -> charging over the course of
  a few seconds (NOT a minute).
- Remove AC adapter.  Charge state -> discharging.

Really good testing requires a source-level change.  Hack in a line of
debug output above task_wait_event(sleep_next) in
charge_state_machine_task() which prints how long the charge state
machine is sleeping.  It should sleep for ~250ms when charging, ~500ms
when discharging and the system is on, or ~60000ms when discharging
and the system is off.  (I did this when writing this change, but
removed it because it clutters up the debug console output.)

Change-Id: I7d3e291fbc40bfcc67d1fb4982d91f0e6bf2e785
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/33921
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2012-09-25 10:56:43 -07:00
Sameer Nanda
9332d769e9 Don't forward keys in case of warm reboot sequence match
If the key combination matches the warm reboot sequence
(alt-volume_up-r), do not forward these keys to the AP. If the keys do
get forwarded, the AP's key handler can race with the EC's GAIAPOWER
task and unpredicatable things may happen.

BUG=chrome-os-partner:14496
TEST=hit alt-volume_up-r keys together. This should cause the system to
reboot. If in dev mode, check the contents of /dev/pstore/console_ramoops
file -- the contents should be from the previous boot.
BRANCH=snow

Change-Id: Ida08bf10c593c75186f472721992a52015e4bf24
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/33916
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2012-09-24 16:29:08 -07:00
Randall Spangler
8b592052ce Only ask the charger for current steps it can supply
This reduces oscillations in the charging algorithm.  This change also adds
more debug output so it's easier to see what the charging state machine is
doing.

BUG=chrome-os-partner:9572
BRANCH=link
TEST=discharge battery; charge battery; note infrequent but useful debug output

Change-Id: I4c8609c2ca8a6cab3eae151ecf2bb1520103fece
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/33811
Reviewed-by: Rong Chang <rongchang@chromium.org>
2012-09-24 10:56:50 -07:00
Bill Richardson
3c4f66648d Use two-color lightbar scheme, with KB backlight for brightness
Yet another set of tweaks to the lightbar patterns:

At Startup or wake from sleep, Google colors cycle in.

While running, > 25% power level in the battery:
All blue, in a breathing effect (cycle up and down 30%).

While running, <= 25% power level in battery:
Same as above, but with red

Shutting down, or going into sleep:
Cycle out the Google colors (Note: the effect is only visible for S0->S3,
because shutting down kills power to the lightbar before we can react).

While sleeping:
Similar to now, but only using Blue and red for battery indication as above.

The EC doesn't have access to the ALS, so we use the keyboard backlight to
control the lightbar brightness instead:

If keyboard backlight is OFF (which it is when ambient is bright), use max
brightness for lightbar.

If keyboard backlight is ON, use keyboard backlight brightness.

BUG=chrome-os-partner:13870
BRANCH=Link
TEST=none

This is an aesthetic change. Nothing to test, only artisitic criticism.

Change-Id: Ib0b98eef18984945a83e988588c225025c4e8e52
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/33824
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-09-24 10:56:50 -07:00
Bill Richardson
ef71b1a3e5 Prevent I2C interrupts from consuming pending task events
This manifested as the lightbar task missing transitions between CPU states.
The underlying cause was that when a task talks over the I2C bus, the I2C
communication was using the task scheduler to wait for an interrupt to
signal completed I2C traffic without blocking the other threads, but while
doing so it was not preserving pending events. This CL seems to fix it.

BUG=chrome-os-partner:12431
BRANCH=all
TEST=manual

The original bug is tricky to reproduce without adding some delay to the I2C
task code, but you can do it. Boot the CPU, then from the EC console
repeatedly alternate these two commands:

  lightbar seq s0
  lightbar seq s3

You should see the lightbar pattern turn off and on, but occasionally you'll
type the command and the EC won't change the pattern.

With this change applied, it should *always* work.

Change-Id: Ie6819a4a36162a8760455c71c41ab8a468656af1
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/33805
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-09-21 16:48:54 -07:00
Bill Richardson
e802e4fa37 Refactor lightbar host command to pass messages the new way.
We recently changed the way host messages are passed to the EC to make it
work nicer across I2C. When we did, we updated all the internal structs
except those used for lightbar commands. This CL updates the lightbar
commands too.

BUG=chrome-os-partner:11277
BRANCH=all
TEST=manual

This shouldn't change anything, but you can ensure that by poking at the
lightbar manually. On Link, run this from a root shell:

  ectool lightbar seq stop
  ectool lightbar 4 ff 00 ff
  ectool lightbar seq run

With the first command, the lightbar pattern should freeze.
With the second command, it should turn magenta.
With the third command, it should resume pulsing as before.

Change-Id: Ic5dc4c827b3b4459288d7d9bd7d06af8a5176b3c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/33798
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-09-21 16:48:53 -07:00
Rong Chang
eee90a3f35 Add TPSChrome FET API
Some designs will have the PMU not directly connected to the AP but
behind the EC.
For easier bring-up, it's nice to be able to force power rails.

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

Change-Id: I74e05308043546cb11f7f2cdbe644944c0a0a35e
Reviewed-on: https://gerrit.chromium.org/gerrit/26234
Reviewed-by: Rong Chang <rongchang@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2012-09-21 14:54:33 -07:00
Randall Spangler
e97896945d Only use trickle charging logic when battery is mostly discharged
At other times, the battery should follow the normal charging rules.
Using the trickle charging logic has 2 problems here:

1) Battery voltage is near maximum, so trickle charging logic starts
out with voltage less than the actual battery voltage, and less than
the charging spec.

2) Trickle charging only exits when battery requests more current
(which it won't if it's near full) or on 4-hour timeout, not when
battery reads 100%.  So this can cause overcharging.

Note that we still limit the charging current to what the battery asks
for, but if that's less than the minimum current from the charger we
simply provide the minimum and don't fiddle with the voltage since
that may interfere with the battery's ability to determine it's fully
charged.

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

1. charge laptop to full
2. quickly unplug and plug charger
3. look at debug log; should either not charge at all (if charge is currently
   100%) or charge at 8400mV (if charge is less than 100%).

Change-Id: Ifd5a9eb2e9bb791f74196713b645d1c9211eb736
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/33729
Reviewed-by: Rong Chang <rongchang@chromium.org>
2012-09-21 00:36:19 -07:00
Vincent Palatin
ce74696f56 Fix spring build
I pushed the wrong version of my previous CL I6384024a,
a warning prevents the spring board from building successfully.

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

BUG=chrome-os-partner:14313
TEST=make BOARD=spring
BRANCH=none

Change-Id: If0b088daf7e3db7615fb778f3289d7fd7cf69f2a
Reviewed-on: https://gerrit.chromium.org/gerrit/33700
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2012-09-20 10:14:18 -07:00