Commit Graph

1244 Commits

Author SHA1 Message Date
Simon Glass
8f73372cef stm32: Swallow special keys instead of passing them to AP
During the debounce refactor we unintentionally adjusted the behavior
of special keys so that they are no longer swallowed (as per commit
9332d76). The LM4's keyboard behaves differently so this code cannot
be brought over as is.

Bring back the required behavior for STM32.

BUG=chrome-os-partner:14496
TEST=hit alt-volume_up-r keys together. See that the AP does not see
this keypress in U-Boot by checking the EC console has no 0x60 messages.
BRANCH=snow

Change-Id: I043fbba4d9be5941e550257b99bdb2137792c133
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35767
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-10-17 15:23:49 -07:00
Bill Richardson
f574f1c37c Make S3 red-light flash adjustable.
This makes the timing for the S3 low-power indicator adjustable without
reflashing.

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

Boot, log in, run this to put the lightbar into demo mode:

  ectool lightbar demo 1
  ectool lightbar seq s3s0

The lightbar should act as though the system is asleep.

Then press the left arrow a couple of times and the down-arrow four or five
times.  You should see the red light pulse every 5 seconds or so.

Now run

  ectool lightbar params > /tmp/w

Edit /tmp/w to change the timing lines to this:

  100             # .s3_ramp_up
  100             # .s3_ramp_down

Then run

  ectool lightbar params /tmp/w

After a cycle or two, you should see the lightbar flash instead of pulse.

Change-Id: If815ff2fb9a158c0e1f4dbb6a269ad07e122d84c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35839
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-10-17 12:50:26 -07:00
Vic Yang
a2c0103908 Fix delay loop for battery detecting
The charging voltage and current are not necessary zero. Remove the
conditions.

BUG=chrome-os-partner:14094
TEST=Remove the battery with AC connected. LED turns red after 30
seconds.
Plug in AC with battery disconnected. LED turns red after 30 seconds.
BRANCH=link

Change-Id: I754383b05af6de0ceeb706612f1cb534254e47e3
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35807
Reviewed-by: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
2012-10-17 00:54:30 -07:00
Bill Richardson
a6ec0e16d8 Finally final lightbar tweaks. Really. I think...
This is hopefully the finally final tweak to the lightbar behavior. It does
this:

* When booting or awakening from sleep, Google colors pulse briefly.
* When the chromebook is fully on, lightbar is dim blue. Every 3-5 seconds,
  a pulse of brighter blue sweeps across.
* On battery, the lightbar is not quite as bright, and the sweep goes in the
  other direction and is slightly slower. If the battery charge drops below
  10%, the lightbar changes from blue to red (but only on battery, not AC).
* When going to sleep (close lid while logged in), lightbar fades to black,
  then pulses Google colors, then off.
* While asleep, lightbar does nothing, UNLESS on battery and battery charge
  is under 10%. Then it pulses red every 5-8 seconds.
* When shutting off, it just goes black with no special effects.

Other than the slight dimming on battery power, there is no ambient light or
dynamic brightness control.

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

Turn it on, watch the blinky lights. Log in, close the lid, open the lid.
Connect/disconnect AC. The lights should change as described above. Ta Da.

Change-Id: Id174a452639decc4b5eefb9e21b28cf3643529f5
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35742
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-10-16 18:32:06 -07:00
Randall Spangler
fdaa78e3c2 link: increase time in hibernate for EC cold reset
This works around a problem where the Silego chip doesn't cleanly
reset for short hibernate durations.

BUG=chrome-os-partner:14687
BRANCH=link
TEST=ectool reboot_ec cold (~100 times), then check if power+refresh still
     reboots the system

Change-Id: I14098940da9331856dd061a56a60a47c9a1cf1f8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34832
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-10-16 16:48:20 -07:00
Simon Glass
943c241545 Add EC keyscan test interface
Add EC commands for managing a list of keyscan events which the EC
should replay instead of its normal key scanning operation.

There are two commands: one adds to the list of events. The other
allows the list to be cleared, the sequence to be started, and the
resulting information to be collected.

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

See that the test passes.

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

Change-Id: Ie4c3e4d0f5c1dbf642185fec99b9201d47532ae1
Reviewed-on: https://gerrit.chromium.org/gerrit/35117
Commit-Ready: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-10-16 10:46:50 -07:00
Bill Richardson
aadfab96c0 Fix lightbar bug, add more tweaks.
I introduced a glitch in the parameterization CL. This fixes it, and makes
the choice between the gentle throbbing and occasional pulse something that
can be selected as a parameter. Default is the new pulsey style.

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

Using the ectool that's part of this change, run these commands to flip
between suspend and active displays:

  ectool lightbar seq s3s0
  ectool lightbar seq s0s3

Change the "new_s0" value (0/1) and reload the params with

  ectool lightbar params | tee /tmp/w
  vi /tmp/w
  ectool lightbar params /tmp/w

In each case you'll see some pretty patterns. Pass/Fail is an artistic
decision. No QA required.

Change-Id: I8de0b1b3cc77f65879befe95e110bbbce18846d9
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35620
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-10-15 17:47:01 -07:00
Sameer Nanda
4dd3940d19 temp_metrics: disable ACPI thermal zone 1
ACPI thermal zone 0 is used for critical thermal events while thermal zone 1
is used for asserting (internal) prochot and duty cycling. Since the
equivalent of thermal zone 1 functionality exists in temp_metrics,
disable ACPI's thermal zone 1 in order to prevent conflicts between ACPI
and temp_metrics.

BUG=chrome-os-partner:9193
TEST='cat /sys/class/thermal/thermal_zone1/mode' and check that it is
disabled.
BRANCH=none

Change-Id: I689e8e5c1747c5f259f4a72a9f86396f4aa5c0b2
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35593
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-10-15 17:46:57 -07:00
Sameer Nanda
dd300b5baf temp_metrics: tmp006 calibration and fan loop updates
With the recent changes that have gone into the EC, the TMP006
calibration data is no longer present in the EC by default. Push it down
to the EC via the newly added ectool tmp006cal command.

Also added couple of changes to the fan loop:
- hand back fan control loop to the EC if none of the TMP006 sensors
  report valid temperatures.
- handle S0->S3->S0 transition where the EC sets the fan to 0 RPM.

BUG=chrome-os-partner:9193
TEST=run "ectool tmp006cal" command for sensors 0, 1, 2 and 3 and ensure
that they return non-zero calibration values.
BRANCH=none

Change-Id: Iaf91216a4d3353f15489b39aba9acb34055551cf
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35469
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
2012-10-15 17:46:57 -07:00
Randall Spangler
e764bdbb03 link:re-enable fan RPM controller when needed
Previously, any command which set the fan duty manually would leave
the PWM RPM controller disabled.  Setting the fan back to auto mode
via 'ectool autofanctrl' or 'autofan' or 'ectool pwmsetfanrpm'
wouldn't turn the controller back on.  Now it does.

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

  - Reboot in recovery mode and wait for INSERT screen

  - From EC console
    fanduty 100 -> fan turns on all the way
    faninfo -> mode is duty
    fanset 6000 -> fan turns down to a lower level
    faninfo -> mode is rpm
    fanduty 0 -> fan turns off all the way
    faninfo -> mode is duty
    (wait a min or so for the system to heat up)
    autofan -> fan turns on
    faninfo -> mode is rpm

  - Reboot normally

  - From root shell
    ectool fanduty 100 -> fan turns on all the way
    ectool pwmsetfanrpm 6000 -> fan turns down to a lower level

Change-Id: I3b07e8b49500f5f8a42f20909d2869cf63987d6d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35335
Reviewed-by: Sameer Nanda <snanda@chromium.org>
2012-10-15 13:41:28 -07:00
Vincent Palatin
9a0e69cbbf spring: force power on LCD and backlight
For board bring-up.

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

BRANCH=none
BUG=chrome-os-partner:10912 chrome-os-partner:14324
TEST=on Spring, boot the AP, issue "pmu" command on the EC console
and FET1 and FET6 (registers 0xf and 0x14) contains 0x13.

Change-Id: Ic8fd681c2e2f3e2168de2cb7f83920d4feefd485
Reviewed-on: https://gerrit.chromium.org/gerrit/33703
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2012-10-15 12:14:27 -07:00
Randall Spangler
b3fa69f17f link: thermal controls ignore case temp by default
The remote temperature sensors for case temps are now not used until
they're calibrated by the host.  But the EC still tries to control the
fan based on case temps.  At best this has no effect because the
sensors haven't been enabled by host calibration.  At worst, the host
calibrates them, but doesn't set up the temerature thresholds to
match, so the EC spins up the fan briefly during boot before the host
takes over (annoying), or potentially asserts prochot, shuts the
system down, or triggers a bunch of SMIs (really annoying).  It's
safer just to leave these thresholds disabled by default; if the host
wants the EC to use them, it can easily set them at the same time it
sets the remote sensor calibration data.

Also, adjust overheated thresholds up based on snanda's recommendations.

BUG=chrome-os-partner:9193
BRANCH=link
TEST=thermalconf 2 --> should print 0 K for all levels

Change-Id: I5bd1ea65eaefc4d39238b22363176d32663434a0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35449
Reviewed-by: Sameer Nanda <snanda@chromium.org>
2012-10-15 10:37:26 -07:00
Bill Richardson
814d0d227f Replace pulsing with sweeping.
BUG=chrome-os-partner:8039
BRANCH=Link
TEST=none

More cosmetic changes.

Change-Id: If33e39d3cea1e3930d630ad84a156e9afb4c57fd
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35485
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-10-14 18:58:01 -07:00
Bill Richardson
eb59ac66bd Set minimum brightness to 35%, variable osc settings.
BUG=chrome-os-partner:8039
BRANCH=Link
TEST=none

More cosmetic changes.

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: I1fd9318131ce55541d845ac8be5faa9334c3953f
Reviewed-on: https://gerrit.chromium.org/gerrit/35484
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-10-14 18:57:58 -07:00
Randall Spangler
8c742b2fc3 link: Ignore keyboard when lid is closed
The lid is flexible enough that it's possible to press keys by
squeezing the laptop.  To keep this from waking the device from
suspend or powering it on, don't scan the keyboard or power button
when the lid is closed.

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

- boot system
- use a magnet near the search key to trigger the lid-closed switch
- press space, then power.  neither one should trigger resume
- remove magnet.  system resumes
- space and power should work as expected again
- log out
- use magnet to trigger lid-closed switch (looking at EC console output is
  handy here).  system should shut down
- pressing power should not boot the system
- remove magnet; system will boot
- pressing power should work as expected again

Change-Id: I92080237b0a2f21774301df3d8e866878697b793
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35425
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-10-12 14:24:39 -07:00
Vincent Palatin
94063c0f35 stm32: support DMA on I2C1
Each I2C controller needs to use a fixed pair of DMA channels.
The former code was hardcoded for I2C2. We now use the board
configuration to decide between I2C1 and I2C2 DMA channels.

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

BRANCH=none
BUG=chrome-os-partner:15185
TEST=make BOARD=snow && make BOARD=spring && make BOARD=daisy
run on Spring and Snow and see we can communicate both with the PMU
(using "pmu" EC console command) and the AP (answering U-Boot host command)

Change-Id: Ifd6806205b443c623e3db09fb1a2d5804bb94214
Reviewed-on: https://gerrit.chromium.org/gerrit/35355
Reviewed-by: Charlie Mooney <charliemooney@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2012-10-11 23:32:26 -07:00
Vincent Palatin
1edad9de11 spring: de-activate power LED code
the power LED code is doing useless operations and messing up with
the former LED pin.

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

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

Change-Id: Idf44bdb7b7a779706bd6579fb66ba3e6932de89f
Reviewed-on: https://gerrit.chromium.org/gerrit/35273
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:25 -07:00
Vincent Palatin
fbc4c150d2 stm32: make power led optional
The spring board doesn't have one and we doesn't want to mess up with
that pin.
When the POWERLED task is not present, let's de-activate cleanly that
code.

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

BUG=chrome-os-partner:14324
TEST=make BOARD=spring (no power_led.o compiled)
make BOARD=snow (power_led.o compiled)
make BOARD=link && make BOARD=bds
run on Snow and see the power LED working

Change-Id: Ib44f5df54ec4fdee1863814e6c7052fd6620fee8
Reviewed-on: https://gerrit.chromium.org/gerrit/35272
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:24 -07:00
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