Commit Graph

31 Commits

Author SHA1 Message Date
Bill Richardson
addcb13711 Change ectool command args to work like main()
The commands in ectool.c look like this:

  int cmd_foo(int argc, char *argv[]) { ... }

but unlike normal C convention, argv[0] is NOT the command. This change
makes argv[0] be the command name, so it's just like main().

BUG=chrome-os-partner:8748
TEST=manual

Run ectool as usual. You should see no difference in behavior.

Change-Id: Ia92784d46a287ab08f279f6255487817b620f200
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-04-19 09:41:18 -07:00
Louis Yung-Chieh Lo
1a9a415cf6 Support chipinfo command (ectool/host commands)
Add a host command returning chip information. The interface is in common/
while the implementations are in chip-specific code (note: added simple
value for stm).

BUG=chrome-os-partner:8567
TEST=on board
% ectool chipinfo
Chip info:
  vendor:    xx
  name:      yyyy
  revision:  zzzzz

Change-Id: I5030a03a6fcfbfc080d5acd8efb763fde7eefde5
2012-04-09 14:25:30 +08:00
Duncan Laurie
32012be3c0 Export more battery information in LPC map
This data is used to populate the _BIF/_BIX packages in ACPI
but it currently needs an EC command to retrieve that isn't
easy to query in ACPI since it isn't using standard EC RAM.

1) Export these additional fields in init() state:
- Design Capacity of Full
- Design Voltage
- Last Full Charge Capacity
- Cycle Count
- Manufacturer String
- Model String
- Serial Number String

2) Fix an issue where battery current was not reported when
the battery was charging.

3) Remove the command interface so there is no duplication.

BUG=chrome-os-partner:7734
TEST=using (not yet published) coreboot to read battery status
via ACPI and verify that battery removal/insertion events
are properly handled.

Change-Id: If337aad3255e5b1a0f85168838f1dd86a32bbeb3
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
2012-04-06 14:49:30 -07:00
Bill Richardson
17fe1ce017 First "ectool lightbar" command.
BUG=chrome-os-partner:8728
TEST=manual

I don't have a system that has both an EC and a lightsaber, so I can't be
certain this works, but I *think* it will.

I do have a Link proto 0.5. With that, you can say

  ectool lightbar test

and the EC console says it's poking at the lightbar, but of course there's
nothing there. If there was, it *should* flash in pretty colors. I have a
lightsaber attached to a BDS, and from the EC console running "lightsaber
test" does make it blink.

Change-Id: Ib6021ad8e53959de52b12efda376254071e5fb4b
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-04-04 13:14:04 -07:00
Vic Yang
afe7cda377 Revert "Add back LPC temperature read command as workaround."
This reverts commit dfe22b2b1e.
We seem to have solved I2C block issue. Reverting the workaround LPC
command and ectool command.

Signed-off-by: Vic Yang <victoryang@google.com>

BUG=chrome-os-partner:8239
TEST=Compilation succeed. Manually tested temperature polling still
works.

Change-Id: I0acb567a138282479c7cc07cbfa723c439d04cd7
2012-04-05 00:06:49 +08:00
Vic Yang
9f8e8dc6a3 Temperature sensor grouping.
Group temperature sensors into different types so we only have to set
temperature threshold for each type instead of each sensor.

Signed-off-by: Vic Yang <victoryang@google.com>

BUG=chrome-os-partner:8466
TEST=Fan control still works.

Change-Id: I7acc714c32f282cec490b9e02d402ab91a53becf
2012-03-16 10:40:52 +08:00
Randall Spangler
c72f66c050 Add wake signal to PCH
This works similar to SCI/SMI events, but triggers a separate
level-sensitive signal to the PCH instead.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:8514
TEST=manual

From EC console:
gpioget PCH_WAKEn --> should be 1
hostevent wake 0x1
close lid switch (with magnet)
hostevent -> should show wake mask 0x1, raw events 0x1
gpioget PCH_WAKEn --> should be 0
hostevent clear 0x1
hostevent -> should show raw events 0
gpioget PCH_WAKEn --> should be 1

Change-Id: I29832c1dc30239a98987578f07dfeb25791dde11
2012-03-15 12:42:11 -07:00
Vic Yang
dfe22b2b1e Add back LPC temperature read command as workaround.
Until we solve the I2C hanging issue, we need a reliable way to read
temperature. Add back LPC temperature read command that actually trigger
a I2C read.

Signed-off-by: Vic Yang <victoryang@google.com>

BUG=chrome-os-partner:8452,chrome-os-partner:8495
TEST=none

Change-Id: Icddd1fe3c1f09889bca633af19041a8aca582de9
2012-03-14 20:53:42 +08:00
Vic Yang
d2fbdfbc67 Temp sensor report 0xfd on sensor unpowered.
Make temp sensor report 0xfd when sensor is unpowered.
Also refactor power specification of temp sensors from thermal.c to
temp_sensor.c.

Signed-off-by: Vic Yang <victoryang@google.com>

BUG=chrome-os-partner:8279
TEST=none

Change-Id: Ib13813bdbac2f048fbc3b98fae5bbf104ebf37d7
2012-03-14 13:32:02 +08:00
Louis Yung-Chieh Lo
9e3e87f802 Support reboot_ec command in ectool (temporarily).
Note that this is a big security hole and should be removed after we
complete the EC autoupdate mechanism and vboot code.

To full update EC firmware on proto 1.0, we need a manual way to switch
EC running on RO/RW. This CL implements the LPC command.

BUG=chrome-os-partner:8415
TEST=on proto 0.5.
ectool reboot_ec RW_A  # EC boots to RW A
ectool reboot_ec RO    # EC boots to RO

Change-Id: Ibf050328bc4e3d2c6d72bfc478d6334f11f0eb46
2012-03-09 21:10:13 +08:00
Randall Spangler
6500cb9481 Update LPC mapped switch states with write protect and recovery states
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:8325
TEST=manual

Boot system with lid open.  'ectool switches' should show lid open.

Use 'dut-control goog_rec_mode:on'.  'ectool switches should show
dedicated recovery signal on.'

Use 'dut-control goog_rec_mode:off'.  'ectool switches should show
dedicated recovery signal off.'

Disable write protect via screw.  'ectool switches' should show WP
signal disabled.

Boot system in recovery mode (power+esc+reload).  Should show 0x09.

Change-Id: I0434427c4b5f8c07c02a8714618f7eb101b86fed
2012-03-07 13:28:12 -08:00
Rong Chang
321b077ed5 Retabify ectool and add battery ectool command
util/ectool.c source contains mixed indentation. This change
adds battery command and retabifies the whole file.

Signed-off-by: Rong Chang <rongchang@chromium.org>

BUG=chrome-os-partner:8181
TEST=manual:
  Type command 'ectool battery' and check battery info.

Change-Id: Id60a53b88b414524cc8735c9456bdf4e15a4400f
2012-03-07 17:22:16 +08:00
Randall Spangler
89a8a082b1 Update switch positions in EC mapped data
Note that this only handles lid and power button; see
crosbug.com/p/8325 for write protect.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:8185
TEST=manual

1. Check state with lid open
localhost ~ # ectool switches
Current switches: 0x01
Lid switch:       OPEN
Power button:     UP
Write protect:    ENABLED

2. Press power button
localhost ~ # ectool switches
Current switches: 0x03
Lid switch:       OPEN
Power button:     DOWN
Write protect:    ENABLED

3. Release power button and close lid
localhost ~ # ectool switches
Current switches: 0x00
Lid switch:       CLOSED
Power button:     UP
Write protect:    ENABLED

Change-Id: I25f2fa3dfeac004dde9b10a4243ee235875f1b6e
2012-03-05 12:07:50 -08:00
Randall Spangler
e85cb93715 Add LPC command to get EC build info
Useful when debugging to determine if a user has an official build or
not, particularly early in the devel process where we're handing
builds to everyone.  Particularly useful for proto1, since not all
those systems will be case-open servo-attached.

Also move get-version LPC command into system.c, where it's closer to
the system functions it calls (matches what we do for other host
commands).

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=none

Change-Id: Idb0f6edf31ca00e32f083be0b0d3f23ab79c5fba
2012-03-05 11:05:15 -08:00
Randall Spangler
2464e96469 Add SMI/SCI support
BUG=chrome-os-partner:8277
TEST=manual

On EC console:
   hostevent set 0x1e
From root shell:
   ectool eventget --> should return 0x1e
   ectool eventclear 0x02
   ectool eventget --> should return 0x1c
   ectool queryec  --> should return event 3
   ectool queryec  --> should return event 4
   ectool queryec  --> should return event 5
   ectool queryec  --> should return no event pending
   ectool eventsetsmimask 0x1200
   ectool eventsetscimask 0x0034
   ectool eventgetsmimask --> should return 0x1200
   ectool eventgetscimask --> should return 0x0034
On EC console:
   hostevent --> should show raw=0 SMI mask = 0x1200 SCI mask = 0x34

Change-Id: I33042fa80c0b148cd63209a94a184af493e25ed3
2012-03-05 09:23:51 -08:00
Randall Spangler
29e494d54c Refactor ectool command handling
The list of if()'s was getting long and obnoxious.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=run a few ectool commands and see that they still work

Change-Id: Ie292b50a27e98ca2c48f13e1141faf273efdd94b
2012-03-02 12:26:26 -08:00
Vic Yang
26ab6057d2 Fix a bug causing ectool to return error return code.
'ectool temps 0' always have non-zero return code.

Signed-off-by: Vic Yang <victoryang@chromium.org>

BUG=chrome-os-partner:8294
TEST="ectool temps 0 && echo 'test'" gives 'test' on screen.

Change-Id: I3a4eff513638c25ec68e24968ce9d1022b4c1281
2012-03-02 10:09:56 -08:00
Randall Spangler
9a60f37c8d Refactor LPC status / result codes
This is necessary to support SCI/SMI events.

Note that this breaks compatibility with previous ectool builds - and
probably also breaks flashrom support.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:8253
TEST='ectool hello' and 'ectool flashinfo' still work
and 'ectool usbchargemode 3 1' fails with error 2

Change-Id: If39e5b6e7cdcec1b5ec765594e8492925b430b10
2012-03-01 15:22:14 -08:00
Vic Yang
747b1f7520 Thermal Engine: LPC commands.
Implement LPC commands and ectool commands to
  1. Set/get threshold temperature values.
  2. Toggle on/off automatic fan speed control.

Signed-off-by: Vic Yang <victoryang@chromium.org>

BUG=chrome-os-partner:8251
TEST=Manual test

Change-Id: Ia4282a6fa47a838aed26540f33c1eb7acc92ef0e
2012-02-29 14:42:45 -08:00
Randall Spangler
e84fc7b110 Add persistent host storage in EC EEPROM
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:8247
TEST=manual

from root shell on host:
  ectool pstoreinfo   --> should print PstoreSize 1024 AccessSize 4
  echo testing 1 2 3 4 > /tmp/infile
  ectool pstorewrite 8 /tmp/infile
  ectool pstoreread 8 /tmp/outfile
  diff /tmp/infile /tmp/outfile

Change-Id: I565e580307584f7def36c5e53d360c1a897d67d2
2012-02-28 13:02:17 -08:00
Vic Yang
f40df60a9a Write current fan speed to LPC mapped value space.
Add a task to update fan speed in LPC mapped memory once per second.
Also added read_mapped_mem16 and read_mapped_mem32.

Signed-off-by: Vic Yang <victoryang@chromium.org>

BUG=chrome-os-partner:8183
TEST="ectool pwmgetfanrpm" shows same result as "faninfo" from ec
console.

Change-Id: Ibc536acd39f836ffcad0bfa7c9c14e730220bd49
2012-02-27 13:18:32 -08:00
Vic Yang
675cddb258 Write temperature values to LPC mapped value space.
Add a task to update temperature values in LPC mapped value space every
second. Also modify ectool to read directly from LPC mapped space.

Signed-off-by: Vic Yang <victoryang@chromium.org>

BUG=chrome-os-partner:8065
TEST="ectool temps" gives same result as "temps" from ec console.

Change-Id: Idcdef8d822724f9bd22d7e819c717cba5af5eb77
2012-02-24 13:09:44 -08:00
Randall Spangler
12b12e5334 Add EC host commands for keyboard backlight
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:8128
TEST='ectool setkblight X && ectool getkblight' for X=1, 20, 99, 100, 0

Change-Id: I540fd2d05f4caa110cd1dc45e9b5184fc8777a06
2012-02-21 12:59:44 -08:00
Vic Yang
6a60a7fbdc USB charging control LPC command.
Add a LPC command to control USB charging mode. Also add the command to
ectool.

BUG=chrome-os-partner:7476
TEST=Manually test on link proto-0.

Change-Id: Ica87d0a690bc86e28844bd695f31641398b21939
Signed-off-by: Vic Yang <victoryang@chromium.org>
2012-02-16 12:45:51 -08:00
Randall Spangler
6101cebb6a Reduce LPC command parameters to 128 bytes; add LPC memory-mapped space
This will allow more efficient access to EC-provided data (temperature,
fan, battery) by the main processor.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7857
TEST='ectool hello' from link main processor should still work

Change-Id: I2dc683f3441b34de9fb4debf772e386b9fdcfa82
2012-02-15 15:12:03 -08:00
Vic Yang
000a6d5742 Refactor temperature sensor code and add support of Link I2C temp sensor.
Refactor board/chip-specific code into corresponding directories.
Add support of the four I2C temp sensor in Link.
Use table lookup to handle different types of temperature sensors.

BUG=chrome-os-partner:7527
TEST=Correctly read EC internal temperature on bds.
Compile for link succeeded.

Change-Id: I694cfa54e1545798d877fafdf18c5585ab5f03e2
2012-02-04 14:37:04 +08:00
Vic Yang
0650392f53 Add ectool option to specify single temp sensor to read data.
Add an option to read temperature from only specified temperature
sensor. With this we can prevent ectool returning error if we already
know a sensor is not connected and do not want ectool to read it.

BUG=none
TEST=ectool temps; ectool temps temp_sensor_ec_internal

Change-Id: I221f1e3390d17f4a3ae99f58eb701a99c7b566b9
2012-01-04 16:21:39 +08:00
Vic Yang
e98b6befca Add EC host command to control fan speed.
Add LPC host command to get and set fan speed.

BUG=chrome-os-partner:7313
TEST=Connect a fan and manually test fan actual speed matches target
speed.

Change-Id: I4b6a711a1b8cca0dbd1c1936fe4f0f15240d3453
2011-12-27 10:14:29 +08:00
Vic Yang
b228bc14c0 Add host command to read temperature sensor value
Add a LPC host command to read temperature sensor value with given
sensor id.
Add ectool command to read temperature sensor value through LPC.

BUG=chrome-os-partner:7329
TEST=Manual check the reading received is the same as value printed by
console command.

Change-Id: Id3386774435be6c3ae010a143f4fa894568efdb8
2011-12-22 13:51:07 +08:00
Randall Spangler
20886cb9c0 Add user-mode LPC endpoint
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST='ectool hello' on target system

Change-Id: I39845c2ea107ea6f85ef556d58e49343f5a0e9c0
2011-12-08 16:18:20 -08:00
Randall Spangler
bdf7da5b08 Initial sources import 1/3
source files mainly done by Randall.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

Change-Id: Iaff83a842b17f3350fb6f2a3f1597ad4c29bd12a
2011-12-07 19:10:02 +00:00