Commit Graph

37 Commits

Author SHA1 Message Date
Randall Spangler
c304ff7d81 Use response pointer and size from host command args struct
Saves 2 params being passed around needlessly.

BUG=chrome-os-partner:11275
TEST=mkbp hash from u-boot console should still work

Change-Id: I958e4a09f16413e4d051e278dc0384aa9b791aa4
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27312
2012-07-12 15:50:14 -07:00
Randall Spangler
02f0ad7ea8 Pass maximum size of response buffer in via host command handler args
BUG=chrome-os-partner:11275
TEST=from u-boot prompt, 'mkbp hash'

Change-Id: I4cf37acfdd8e4edfe2cb6259b0fc6d0860ef0f79
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27225
2012-07-12 11:32:06 -07:00
Randall Spangler
347b5062a4 Initialize memory mapped data and add data versions
BUG=chrome-os-partner:11275
TEST=manual

localhost ~ # io_read8 0x920
0x45 // 'E'
localhost ~ # io_read8 0x921
0x43 // 'C'
localhost ~ # io_read8 0x922
0x01 // version 1
localhost ~ # io_read8 0x9fe
0x00 // unused data initialized to 0

Change-Id: If8de85ddc0e5f99b7c4213214d4b2d30b1439da8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27196
2012-07-12 11:32:06 -07:00
Randall Spangler
bdf3ba5ded Move host_cmd_handler_args farther up the call chain
This is necessary for an imminent change which passes version data
from the host bus (LPC/I2C/SPI) into the host command handler.

BUG=chrome-os-partner:11275
TEST=from u-boot prompt, 'mkbp hash'

Change-Id: If34d0d7c6dc320ad5632becf512c30900fd61aca
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27190
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-11 17:22:57 -07:00
Randall Spangler
fe5c01cb6e Add host command to check what command versions are supported
BUG=chrome-os-partner:11275
TEST=manual

ectool cmdversions 0x08 -> should print 0x00000001
ectool cmdversions 0xdd -> should print command not supported

Change-Id: I7801be51492eb6a5321accaa2b66f0dc8d5a2797
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27181
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-11 14:46:31 -07:00
Randall Spangler
07ca0977fe Refactor API for host commands, and handle variable length data better
Added version mask field to DECLARE_HOST_COMMAND() because it's
convenient to do so when I'm touching all host command
implementations, but all commands simply declare version 0 and nothing
checks it yet.  Will add version support in a followup CL.

This change is internal to the EC; it does not change the data sent
over the host interface.

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

ectool version && ectool echash; should get sane data from both

ectool flashread 0x80 0x40 /tmp/foo && od -tx1 /tmp/foo
should match data from offset 0x80 of ec.bin (od -j128 -n64 -tx1 ec.bin)

Change-Id: I5699f72b8d5e1ac23929353c9a34158d76c44206
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27172
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-11 14:46:30 -07:00
Randall Spangler
29332907d4 Host command interface has only one slot now
Now that ACPI events are handled directly in the LPC interrupt
handler, we can simplify the host event code.

BUG=chrome-os-partner:11240
TEST=boot system; should boot
close lid; should send SMI and suspend system

Change-Id: I8c73ea31a66e94310e4460a008635a103220413e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27100
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-10 21:52:07 -07:00
Randall Spangler
f2400b869e Move ACPI query-event handling to LPC interrupt
And only support it for port 62/66.

Also remove 'ectool queryec', because it can't touch port 62/66 once
the kernel/ACPI owns it, and query-event isn't supported on the user
command port.

BUG=chrome-os-partner:11240
TEST=boot system and check EC console output; should see event clears between
host commands 0x23, 0x8e, but no hostcmd 0x84.

[0.396780 LPC RESET# deasserted]
[0.486953 Port 80: 0x29]
[0.487415 hostcmd1 0x23]
[0.764407 Port 80: 0x88]
[0.764579 event clear 0x00000008 -> 00002080]
[0.764928 event clear 0x00000080 -> 00002000]
[0.765224 event clear 0x00002000 -> 00000000]
[0.765578 hostcmd1 0x8e]
[0.765868 hostcmd1 0x06]

Change-Id: I8ed161dbccd396d685ddf6829a27dfef87d919fb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27095
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-10 21:52:07 -07:00
Randall Spangler
2daf748e0e Get rid of double debug output for host commands
(in both command_process() and host_command_process())

BUG=none
TEST=none

Change-Id: I6eafe110b425afac9d94ace710efe5bbf7342073
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27080
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-10 16:18:59 -07:00
Randall Spangler
1e8e8cd6aa Add new event for host interface ready
Also add new 'invalid' host event bit; if the host reads this, it
knows the memory-mapped data for current events is invalid.

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

On host, ectool eventget -> should print events = 0
On EC, hostevent set 0x80000000
On host, ectool eventget -> should print events = invalid

Reboot EC; should see debug output where event mask 0x2000 is set
during the boot process.

Signed-off-by: Randall Spangler <rspangler@chromium.org>
Change-Id: I8d3f161eec25db50ac06e3642a1a1fb8edb9590e
Reviewed-on: https://gerrit.chromium.org/gerrit/26876
2012-07-07 23:05:50 -07:00
Randall Spangler
7f5f7be3e5 Add memory-mapped data support for I2C and SPI protocols
And fix returning memory-mapped string length on LPC as well.

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

from EC, 'hostevent set 0x40000'
from host, 'ectool eventget' --> should print 0x40000

Signed-off-by: Randall Spangler <rspangler@chromium.org>
Change-Id: I9edbd0a1468b5d4160ce67c471332226e51fa868
Reviewed-on: https://gerrit.chromium.org/gerrit/26719
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-07-07 17:14:18 -07:00
Simon Glass
9a4205faf3 Add host_command_process() to process a command immediately
Rather than go through the task queue, host_command_process() processes
the command immediately, has all of its required state passed in,
allowing the caller complete control of the buffers.

BUG=chrome-os-partner:10533
TEST=manual:
build and boot on link, see that messages are stil processed
build and boot on snow, which uses this new command
See that the SPI keyboard works now

Change-Id: Ib7587de10c42caf01bc95bb4d515fd0afc3da7d8
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25983
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2012-07-03 13:24:28 -07:00
Simon Glass
e723318ec1 Remove unnecessary host_send_result()
This seems to be a hangover from the LPC protocol. We can send a result
just by sending a response with no data.

Drop this function and remove all uses of it.

Also use 'enum ec_status' instead of int, since this is the correct
response type.

BUG=chrome-os-partner:10533
TEST=manual:
build for all boards
build and boot on daisy

Change-Id: I93a029bd6ba8cec567b61af3b410bcead015b5c0
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25980
2012-07-02 20:36:57 -07:00
Randall Spangler
b2c4ee6cf8 Even more debug command cleanup to save space
BUG=none
TEST=(run the commands)

Change-Id: Ibc414ffd594e06dbdce64c51859b6f247bb10d36
Signed-off-by: Randall Spangler <rspangler@chromium.org>
2012-05-21 14:57:08 -07:00
Vincent Palatin
4c5f1365b5 Use common host command processing for Daisy I2C
This also updates the communication protocol between the EC and the AP in a
non backward compatible way.

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

BUG=chrome-os-partner:9614
TEST=on Daisy with updated kernel driver, use the keyboard in ChromeOS

Change-Id: I5a50e9a74b9891153a37ea79318c8a66a1b0c5ca
2012-05-18 17:57:51 +00:00
Vincent Palatin
b74cbd8a74 de-LPCify the EC host interface
Preparatory work to use common host command code between ARM and x86.

Just rename constants, do not change the binary API.

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

BUG=chrome-os-partner:9614
TEST=make BOARD=link

Change-Id: I534d427c9b50103273835a6f32a0ddb622c762b3
2012-05-15 18:34:50 -07:00
Vincent Palatin
87d3707f62 Slightly update the host commands API
Preparatory work to use common host command code between ARM and x86.

Every command sends back explicitly the size of the response payload.
The size of the response defaults to 0 ond can be updated.

Add a protocol version number returned as command 0x00 to help with
backward compatibility.

move a couple of function from lpc specific header to host commands to
be able to implement them for the I2C link.

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

BUG=chrome-os-partner:9614
TEST=make BOARD=link

Change-Id: I6a28edf02996ddf6b7f32a3831d07d5f0271848f
2012-05-14 23:33:21 +00:00
Randall Spangler
135f14bf49 Refactor async console output
This adds a 'ch' command which prints/sets which channels are active

This handles all the async output; the remaining debug commands will
be refactored to use ccprintf() / ccputs() in a followup CL.

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

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

ch --> all channels active
ch 0x100 -> just port80 active
powerbtn -> system boots; only port 80 codes shown on console

Change-Id: I9efc43acec919b62b78c2c82c61946d32380adfe
2012-04-24 17:46:54 -07:00
Randall Spangler
24dafefb3a Move externs from .lds file into a header file
Fewer magic externs = good.

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

BUG=none
TEST=if it boots, it works

Change-Id: Ifadeb1701400c5492c40d2eaf8f68f2d70189648
2012-04-19 14:29:07 -07:00
Randall Spangler
a61d8db3d3 Change task messages to events
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

make BOARD={bds,link,daisy}
make tests
flash link system and make sure it boots

Change-Id: I1241a1895c083e387e38ddab01ac346ca4474eb9
2012-04-06 09:06:53 -07: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
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
Randall Spangler
b2b5455f32 Fix version command crashing if no image B
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

Change-Id: Ie14465283c09029c3d2fa9a32296f32ce7304760
2012-02-28 14:29:52 -08:00
Randall Spangler
4c89ccd89e Register host commands the same clever way we do console commands
BUG=none
TEST=run assorted ectool commands

Change-Id: I830d3cbf2d1557b3ab455ec8736d3de5e5d3e697
2012-02-28 13:58:34 -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
b9999a2c6c Remove EC_LPC_COMMAND_TEMP_SENSOR_GET_READINGS
We now read temp sensor readings using the EC mapped space.
So we don't need this command.

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

BUG=chrome-os-partner:8239
TEST="ectool temps 0" works.

Change-Id: I47f425e45cea992b19734f39ac6d9f6db6433d39
2012-02-27 14:18:25 -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
Vincent Palatin
c21f07e58e register console commands at compile-time
Instead of using a runtime callback to register the console commands,
put them in a special linker section. So we can do a macro to "register"
them during the build.

It saves 684 bytes and a few microseconds at startup.

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

BUG=None
TEST=run a few commands from the BDS command line.

Change-Id: Id33ea210b9035bf76ed720373c74c5dd24ccd1b1
2012-01-24 00:50:08 +00: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
Louis Yung-Chieh Lo
6995d4771f Support flash checksum command for re-transmit.
The LPC is not stable enough to test. Kodus Rong. He creates this idea
to checksum the partial content of flash for read/write/erase. This can
improve the robustness of flashrom.

BUG=none
TEST=Tested with flashrom.

Change-Id: I2a2f7b698a94674c03cbd8e3f15caf34f8986399
2011-12-12 21:24:48 +08:00
Rong Chang
1eb5417847 Add flash write protect range command
This CL add host command to enable, get/set flash write protect range.

BUG=None
TEST=Use flashrom utility to set write protect range, enable write
protect and get status.

Change-Id: I345f1eb65944d8cf8028e6fdb7e43c40cc742a6d
Signed-off-by: Rong Chang <rongchang@chromium.org>
2011-12-12 18:21:08 +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
f141306de2 Fix LPC drive strength for I/O lines interfering with x86 boot.
Fix 1-sec delay in HELLO host command for testing.

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

BUG=none
TEST=on host, boot and run 'ectool hello'

Change-Id: I6017d12be400616b06ea337829ce85d193ad90e5
2011-12-08 10:33:30 -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