Commit Graph

188 Commits

Author SHA1 Message Date
Randall Spangler
b1bb8314bd Add LM4 support for hard reset
(And add STM32 support for disabling interrupts before reset, which
got missed before.)

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

BUG=chrome-os-partner:7470
TEST=from console, "reboot", then "reboot hard"

Change-Id: Ib98792abc0c91a01e2230b419fc876052380655a
2012-05-21 09:17:43 -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
Randall Spangler
39149579a4 Add a list of I2C ports
This cleans up I2C init and debug commands across boards.

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

BUG=none
TEST=on link and bds:
  i2cscan
  lightbar run
  powerbtn (to power on system)
  temps (to read i2c temp sensors)
  battery (to read battery)
  charger (to read charger)

Change-Id: If3fb0cdb8d3178592bf68cbb2e72bc4b7f71dec5
2012-05-17 12:22:39 -07:00
Randall Spangler
5907675a47 Add AC state change hook
And start wiring to x86_power so it can detect AC state changes
(needed to enable/disable turbo).

*YES*, this compiles for BDS/Daisy now...

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

BUG=chrome-os-partner:9069
TEST=plug/unplug AC power and look for "x86 AC on" / "x86 AC off" in debug log

Change-Id: I8399fab9637d6635a1c615f07448fd45b86bc25f
2012-05-17 09:30:38 -07:00
Louis Yung-Chieh Lo
1cb328dc0c Fix some behaviors of keyboard command handlers.
The phenomenon is that there is a char on-hold in port 0x60 and the kernel
never picks it up. Hence the keyboard cannnot be recognized after resume.
It comes from multiple reasons:

1. The command I8042_CMD_RESET_BAT(0xff) and I8042_CMD_ENABLE(0xf4) didn't
   clean the buffer.

2. clean_underlying_buffer() has clean the queue, but forgot to clean the
   TOH (TO Host). Add keyboard_clean_buffer() to clean the TOH (To Host).

3. When KB interrupt is just enabled, the IRQ didn't sent if there is
   a char queued in buffer already. keyboard_resume_interrupt() solves
   this.

4. Not all keyboard reset should reset the buffer. Only the enable/disble
   of controller RAM  should NOT reset buffer. Other enable/disable
   should clean the buffer.

5. i8042 commands (those commands to port 0x64) should NOT return ACK
   even the parameter byte(s) goes to port 0x60.

6. Keyboard was disabled by kernel, but key stroke still sent to host
   (this needs the BIOS to fix).

Also fix the minor issues:

1. I8042_CMD_RESEND should not return I8042_RET_ACK.

2. I8042_DIS_KB/I8042_ENA_KB should effect the controller RAM content.

3. only send out the scan code when keyboard is enabled.

4. add kblog command for future debug (disabled by default because it
neeeds 1KB of memory).

Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>

BUG=chrome-os-partner:9525
TEST=tested on link. Start from S0.
1. Run powerd_suspend.
2. Expect system is in S3.
3. Press any key to wake up system.
4. Expect system is up and keyboard is working.
5. repeat for 20+ times.

Change-Id: I1c48822687d7c1f7ef0e8d8bca54bf9b05fd785f
2012-05-17 10:26:16 +08:00
David Hendricks
546aeddc97 stm32: add a FIFO for keyboard usage
This CL adds a simple FIFO to store keystrokes. The keyboard_scan()
function will push keystrokes into the FIFO and is the only producer,
while keyboard_get_scan() will pop entries and is the only consumer.

BUG=chrome-os-partner:9594
TEST=tested on daisy
Signed-off-by: David Hendricks <dhendrix@chromium.org>

Testing was mostly subjectively done by typing a sentence quickly
at the Chrome UI.

Change-Id: I6faff41b0f16b75d6426df13a239f84eb62634ec
2012-05-16 16:53:59 -07: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
33b03d5a39 Sort console commands at build time
Use the linker to sort console commands by name,
this saves execution time and memory.

BUG=none
TEST=generate several images with 5N, 5N+1, 5N-1 commands and check the
output of the "help" command.

Change-Id: Ib5d8f3bca726621c68ab152f4fa662cee355abb1
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
2012-05-15 01:32:44 +00:00
Gerrit
dc703b5ae4 Merge "Slightly update the host commands API" 2012-05-14 17:27:49 -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
a59178373a Change polarity of PROCHOT signal to match EVT
This would throttle proto1 systems, if it weren't for a HW bug which
means we don't have prochot control over proto1 systems at all.

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

BUG=chrome-os-partner:8982
TEST=system still boots

Change-Id: Ie42c034141f24795ec2bfee592e194001d3cd174
2012-05-14 16:07:17 -07:00
Vadim Bendebury
6a324c1de5 Allow console commands abbreviation
The EC console input handling code is being enhanced to accept
abbreviated command names.

If the abbreviation is unique, the appropriate command is used, if the
abbreviation is ambiguous, the command is handled as nonexistent. The
error message is being modified to mention that the command either
does not exist or is ambiguous.

This change also makes it impossible to have command names matching
the beginning of other command names. Two such cases are being fixed
(`ch' renamed to `chan' and `thermal' renamed to 'thermalconf').

BUG=none
TEST=manual
 . program the new EC image. Try entering at the console:
  > h
  Command 'h' either not found or ambiguous.
  Command returned error 1
  > he
  Known commands:
    adc            autofan        battery        ch             charger
  ...
  > help
  Known commands:
    adc            autofan        battery        ch             charger
  ...

Change-Id: Iaa3e91e1504e42daefb02d561e00c39003548197
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
2012-05-14 13:35:03 -07:00
Simon Glass
fddbc9edc4 timer: Allow callers to pass 'now' to timestamp_expired()
To avoid calling get_time() when the caller already knows the value, add
a parameter to timestamp_expired().

BUG=chrome-os-partner:9424
TEST=build and boot on Daisy

Change-Id: Ibb97c86f429ec4b814e17b41cbf79b612a75097a
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-05-14 09:12:50 -07:00
Randall Spangler
27e8bdb7c0 Maintain timer value across sysjumps and clean up init debug output
This helps us keep track of how long vboot is taking on the EC.

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

BUG=chrome-os-partner:9651
TEST=reboot system and look at debug log.  time shouldn't start over after it jumps to image A.

Change-Id: Iad86e90d42dabf1c67b2c2be80dda1151cf9a288
2012-05-11 13:36:34 -07:00
Bill Richardson
8101b71316 Enable verified boot for EC firmware
BUG=chrome-os-partner:7459
TEST=manual

In the chroot:

  cd src/platform/ec
  make BOARD=link

The firmware image (build/link/ec.bin) is signed with dev-keys. Reflash the
EC and try it, and it should verify and reboot into RW A.

Additional tests (setting USE_RO_NORMAL, poking random values into VBLOCK_A
or FW_MAIN_A to force RW B to run, etc.) are left as an exercise for the
reader. I've done them and they work, though.

Change-Id: I29a23ea69aef02a11aebd4af3b043f6864723523
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-05-10 17:27:36 -07:00
Simon Glass
f8f5599178 Allow boards to set the default console mask
Some boards don't like to have every keyboard scan printed, but some
devs find this info comforting. Add a way for boards to select the
require console mask.

BUG=none
TEST=manual:
build and boot on daisy, see that key scan messages are suppressed.
build on all platforms

Change-Id: I8e6e640eaabc0a08e5427cd97f7089dda1238025
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-05-10 14:16:07 -07:00
Randall Spangler
30a33e6b04 Drop DPWROK when system is off for more than 10 sec
This saves ~70mw of power.

To make this work, I also had to stretch the power button signal to
give the system a chance to come back up when the user taps the power
button.

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

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

For each of the following tests, wait ~15 sec after the system is
powered off to give it a chance to drop DPWROK.

1) tap power button -> system turns on
2) hold power button 1 sec -> system turns on
3) open lid -> system turns on
4) silego reset (power+refresh, or power+esc on proto1) -> system stays off
5) silego recovery (power+esc+refresh) -> system turns on
6) hold down power button and type 'reboot' on EC console -> system turns on
7) type 'powerbtn' on EC console -> system turns on

Change-Id: I781cf3e665104192521b7fb9ff75a3c3e7f43464
2012-05-09 16:54:17 -07:00
Randall Spangler
1655c8727a Add hooks for chipset power transitions
This is cleaner than having x86_power explicitly know about everything
else in the system that cares about power transitions.

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

BUG=none
TEST=boot and shutdown system; still works.  Mouse powered to system is off in S5.

Change-Id: Ib673ca2d9edd5473334e7604e98b99b02b768419
2012-05-09 16:09:10 -07:00
Randall Spangler
8ea7983c29 Add gpio_set_flags() and system_get_board_version()
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:9117
TEST=version; board version should be 0 on proto1 and 1 on EVT

Change-Id: Ic64ad0d009151fbda09f5c1605ef50ae708cb6ae
2012-05-08 21:00:38 -07:00
Gerrit
2615d8cdae Merge "Automatically switch USB charging mode" 2012-05-08 20:27:50 -07:00
Vic Yang
527eddedaa Automatically switch USB charging mode
Disable USB ports when system is down and set USB ports to standard
downstream mode when system is up or sleeping.

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

BUG=chrome-os-partner:9249
TEST=Plug in a phone and see it charge when system is on.
Turn off the system and see it stop charging.

Change-Id: I02850dee7051ed6589e0f176a933069203f0efdf
2012-05-09 10:15:03 +08:00
Gerrit
87b4278299 Merge "Move gpio list into gpio.h header file" 2012-05-08 14:39:37 -07:00
Bill Richardson
468bc6171c Add LPC lightbar command to get the current sequence.
Instead of making the STOP command synchronous, we can just have the
host-side app tell the EC to stop, then poll until it has.

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

"make BOARD=link", then
copy build/link/util/lbplay to the host and run it.

Change-Id: I846924ae7994a498e0089197785cf239898fe2a3
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-05-08 12:03:49 -07:00
Simon Glass
42842e4378 Move gpio list into gpio.h header file
This is referenced by various files, so should be in the gpio.h header.

BUG=none
TEST=manual:
build and boot on daisy, see that USB download still works
build on all platforms

Change-Id: If579c975ef6c82988b9e411eeaa97c950d9efce4
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-05-08 11:31:52 -07:00
Randall Spangler
cbdd518422 Clean up sysjump struct parsing and add memmove()
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:9447
TEST=update from old EC 517 to this one

Change-Id: I275b5bf6c4ae1ab6e0c0a05cf9260314d644c79b
2012-05-07 16:26:43 -07:00
Simon Glass
ea845714fd Add gpio_get_name() to return the name of a signal
Add this to the GPIO API. It seems that the implementation is copied
in LM4 and STM32 so I have reluctantly done the same with this new
function.

BUG=chrome-os-partner:9424
TEST=build and boot on Daisy

Change-Id: Ifddc52e69b2b33af2645384c0171dd264e588fcd
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-05-03 22:05:57 -07:00
Gerrit
5ba4576cf3 Merge "timer: Add timestamp_expired() to check for expiry" 2012-05-03 12:05:25 -07:00
Simon Glass
4935a885ee timer: Add timestamp_expired() to check for expiry
Rather than open code this each time, create a function for this. The
wrap-around condition may not be needed, if the timer starts at zero,
since we have 64 bits to play with.

BUG=chrome-os-partner:9424
TEST=build and boot on daisy

Change-Id: I84ae651212769b5927c452bc03f31f60a25a829e
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-05-02 19:43:39 -07:00
Vadim Bendebury
0467763f5a Enhance LPC EC REBOOT reset command to allow to request recovery
When the host reboots the EC it should be able to request the EC to
force recovery mode after reset. This is achieved by extending the
REBOOT EC command with a bitmask byte, with bit 0 dedicated to
recovery request.

So, when BIOS on the way up determines that recovery is requested, but
the EC is not running from the RO space, the BIOS would reset the EC
forcing it to run from RO and to request recovery mode through the LPC
bitmask. Then BIOS will restart itself ensuring that the system comes
up in consistent state.

Some refactoring was also done to make the code a bit more compact.

BUG=chrome-os-partner:9040
TEST=manual
  . tested along with coreboot changes (test described in the coerboot CL).

Change-Id: I29801b6aec80da0901ba0e8db8e92e615cc778bd
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
2012-04-30 15:36:41 -07:00
Bill Richardson
31190cf215 Create host-side lightbar bikeshedding tool.
BUG=chrome-os-partner:7839
TEST=manual

  cd src/platform/ec
  make BOARD=link

  copy ./build/link/util/lbplay to the host and run it as root.

Change-Id: I6a4a842b7500751185c8f4c2744f4389226bae9b
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-04-26 13:57:19 -07:00
Gerrit
9a59d98b3d Merge "Issue warning on fan stall." 2012-04-26 10:16:24 -07:00
Vic Yang
7710ed563a Issue warning on fan stall.
When PWM module detects fan stall, issue SMI warning and print warning
message to console.

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

BUG=chrome-os-partner:7497
TEST=Disconnect fan and power up. See warning message.

Change-Id: I4d96595f7f3cdfab5df333afc35206304bacab9d
2012-04-26 13:45:43 +08:00
Bill Richardson
e763812a3a Give ectool the same lightbar commands as the console.
BUG=chrome-os-partner:7839
TEST=manual

Try "lightbar help" on the EC console and "ectool lightbar help" on the
host. You should see the same commands and behavior.

Change-Id: I6e879e8bb892ef5ada7ef85a97fdf243149f4cb6
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-04-25 18:42:36 -07:00
Gerrit
fe16e4b3a9 Merge "Watchdog fixes" 2012-04-25 16:56:04 -07:00
David Hendricks
ef9424dd10 simplified message protocol
This simplifies the messaging protocol. Messages will now only have
the raw content plus a checksum byte at the end. We will worry about
needs of the transport layer (e.g. preamble/postamble bytes) on the
host driver side, and will not support variable-length commands for
now.

There is also a protocol version command, which is now command number
0x00, which returns a 4-byte protocol version followed by a 1-byte
checksum.

BUG=none
TEST=tested on daisy using mkbp kernel driver
Signed-off-by: David Hendricks <dhendrix@chromium.org>

Change-Id: I8fcc693cd50bc2b515164ea7a2a941cdd8333e73
2012-04-25 14:51:33 -07:00
Randall Spangler
1aa57e140e Watchdog fixes
1) When frequency changes, reload the watchdog timer right away, or it
may expire before the next reload.  (Only matters when re-enabling the
PLL.)

2) Split out the timer/task debug output used by the watchdog into
their own routines, instead of assuming it's safe to call the command
handlers.  Also make the flushes in those print routines safe to call
from interrupt level.

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

BUG=none
TEST=waitms 1500; should print task dump again

Change-Id: I07e0ed24a526ae499566dab0bbeb0f5755cd5be6
2012-04-25 14:49:49 -07:00
David Hendricks
83082746a9 Separate message protocol command types and reserve slots accordingly
This organizes the commands in the messaging protocol so that we have
a more clear distinction between commands which are intended to to
control or get status of the EC itself and those which are intended
to query information about peripherals, such as the obtaining the
keyboard state.

Note: This will require the mkbp code to be updated.

BUG=none
TEST=compile tested for now

Change-Id: I2d5c58fc794563d402da24e19fee146df817472a
Signed-off-by: David Hendricks <dhendrix@chromium.org>
2012-04-25 11:31:42 -07:00
Bill Richardson
b4ac7cf558 Clean up lightbar msg command parsing, add some help.
BUG=none
TEST=none

Change-Id: I5767bd45bd66793606014b3ce8020d0eb2e17090
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-04-25 09:30:20 -07:00
Randall Spangler
470916fb0f Use console output instead of uart output for console commands
This completes console output cleanup.  The remaining calls to
uart_puts() and uart_printf() actually need to be that way.

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

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

Change-Id: Ib1d6d370d30429017b3d11994894fece75fab6ea
2012-04-24 18:34:46 -07: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
0d19c59aba Implement task profiling
Also tracks the distribution of IRQs, so we can see what's triggering
interrupts.

Task profiling is optional, enabled via CONFIG_TASK_PROFILING.

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

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

Change-Id: I266f2b49bff9648cda446210d5a302b460fec244
2012-04-24 12:54:29 -07:00
Randall Spangler
7ecb8358b9 Disable PLL at end of init
This saves power.

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

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

Get a proto1 system modified with INA current sensor

1) From chroot:
  dut-control i2c_mux_en:on i2c_mux:rem
  dut-control pp3300_alw_mv pp3300_alw_ma

2) From EC console:
pll
(this should turn the PLL back on; it'll report clock frequency ~66MHz)

3) From chroot:
  dut-control i2c_mux_en:on i2c_mux:rem
  dut-control pp3300_alw_mv pp3300_alw_ma
Current (ma) should be bigger than in step 1

Change-Id: I806953684c57fd60bf481acb01dddffe2f2ad0ed
2012-04-24 09:59:31 -07:00
David Hendricks
e56ba2e689 Update message protocol length byte to include postamble
This simply changes the constant '4' to MSG_PROTO_BYTES, which
includes the postamble. This helps reduce magic constant values
used in processing a packet.

BUG=chrome-os-partner:8975
TEST=tested on daisy (with kernel mkbp driver change)

Signed-off-by: David Hendricks <dhendrix@chromium.org>
Change-Id: Id4634076ad63f45783354179dfebea4fd450fc1e
2012-04-23 14:05:41 -07:00
Louis Yung-Chieh Lo
913473db71 Keyboard hook up for SYSJUMP and INIT.
During the reboot_ec command, the keyboard state is lost after jump.
We need to restore info including:
  - code set
  - controller_ram[0]:
    - XLATE
    - KB/TP disabled
    - KB/TP IRQ enabled

Remove the un-necessary keyboard_init() function.

BUG=chrome-os-partner:9102
TEST=tested on link.
EC runs on A
% ectool reboot_ec A
keyboard still working
% ectool reboot_ec RO
keybaord still working
% ectool reboot_ec RO
keybaord still working
ESC + power yo reset all system
repeat above steps and the keyboard keeps working.

Change-Id: I0fe21f7876459fc8047ff018fbfaaef5311cc49b
2012-04-23 17:57:41 +08:00
Randall Spangler
9f552ff5aa Implement 64-bit integer printing in uart_printf()
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7490
TEST=timerinfo; numbers should look reasonable

Change-Id: I698be99c87bf311013427ac0ed9e93e5687f40c0
2012-04-20 14:01:11 -07:00
Randall Spangler
13ad1c007b Implement HOOK_SYSJUMP and use it to preserve LPC host event mask
This also changes shared_mem to use all the remaining RAM, instead of
reserving a fixed-size buffer.

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

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

hostevent  --> all masks should be 0
hostevent smi 0x12300000
hostevent  --> should confirm SMI mask was set
sysjump b
hostevent  --> should confirm SMI mask is still set
reboot
hostevent  --> should confirm SMI mask is back to 0

Change-Id: Iccb6da6ccc93ee5036a3f478d24b717a462d9150
2012-04-19 18:15:18 -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
Gerrit
ff8926b5e3 Merge "Added HOOK_INIT for driver module inits" 2012-04-19 14:22:36 -07:00
Gerrit
92ded9777c Merge "Tweaks to lightbar code, detect konami sequence" 2012-04-19 14:03:42 -07:00
Randall Spangler
f4e772708b Added HOOK_INIT for driver module inits
This covers modules which need to initialize before task_start(), but
don't particularly care in what order they're initialized.

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

BUG=none
TEST=if it boots, it works

Change-Id: I69829aac8d1c3c14ee04916a794b84bbf03a09eb
2012-04-19 13:08:58 -07:00