Commit Graph

18 Commits

Author SHA1 Message Date
Randall Spangler
dd702e8447 baytrail: Workaround for stuck boot process
In some cases, the system will boot to S0 from the point of view of
the EC, but PLTRST# will never deassert.  Work around this by waiting
50 ms for PLTRST# to deassert.  If it doesn't, force the chipset all
the way down by deasserting RSMRST#, then pulse the power button to
turn it back on.

Also add a powerfail debug command to simulate this failure event, so
that the recovery process can be tested.

Add API to the LPC module to get the state of PLTRST#, and to the
power button state machine to force it released when we shut down the
chipset and and force another power button pulse as we reset the
chipset.

BUG=chrome-os-partner:28422
BRANCH=baytrail
TEST=1. Boot system.  Should boot normally.  Shut system down.
     2. powerfail
     3. Boot system.  On the EC console, should see the system come up,
        go back down through G3S5, then come back up.  From the user's
	point of view, it just boots.
     1. Boot system.  Should boot normally.  (That is, powerfail is not sticky)

Change-Id: Ia57f196606f79b9f2fce7d9cd109ab932c3571aa
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/197523
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2014-04-30 10:00:02 +00:00
Bill Richardson
e6588c803f Move ACPI stuff out of chip/lm4 and into common
The port 62/66 ACPI commands were implemented in chip/lm4/lpc.c. They should
be handled in common instead of being tied to a particular EC.

BUG=chrome-os-partner:23774
BRANCH=none
TEST=manual

read EC_ACPI_MEM_VERSION

  # iotools io_write8 0x66 0x80; iotools io_write8 0x62 0; iotools io_read8 0x62
  0x01

write & read EC_ACPI_MEM_TEST

  # iotools io_write8 0x66 0x81; iotools io_write8 0x62 1; iotools io_write8 0x62 0xa5
  # iotools io_write8 0x66 0x80; iotools io_write8 0x62 1; iotools io_read8 0x62
  0xa5
  # iotools io_write8 0x66 0x80; iotools io_write8 0x62 2; iotools io_read8 0x62
  0x5a

  # iotools io_write8 0x66 0x81; iotools io_write8 0x62 1; iotools io_write8 0x62 0xbb
  # iotools io_write8 0x66 0x80; iotools io_write8 0x62 1; iotools io_read8 0x62
  0xbb
  # iotools io_write8 0x66 0x80; iotools io_write8 0x62 2; iotools io_read8 0x62
  0x44

read & write EC_ACPI_MEM_KEYBOARD_BACKLIGHT

  # iotools io_write8 0x66 0x81; iotools io_write8 0x62 3; iotools io_write8 0x62 100
  (keyboard lights up)
  # iotools io_write8 0x66 0x80; iotools io_write8 0x62 3; iotools io_read8 0x62
  0x64
  # iotools io_write8 0x66 0x81; iotools io_write8 0x62 3; iotools io_write8 0x62 50
  (keyboard dimmer)
  # iotools io_write8 0x66 0x80; iotools io_write8 0x62 3; iotools io_read8 0x62
  0x32
  # iotools io_write8 0x66 0x81; iotools io_write8 0x62 3; iotools io_write8 0x62 0
  (keyboard goes dark)
  # iotools io_write8 0x66 0x80; iotools io_write8 0x62 3; iotools io_read8 0x62
  0x00

read & write EC_ACPI_MEM_FAN_DUTY

  # iotools io_write8 0x66 0x81; iotools io_write8 0x62 4; iotools io_write8 0x62 100
  (fan on full)
  # iotools io_write8 0x66 0x80; iotools io_write8 0x62 4; iotools io_read8 0x62
  0x64
  # iotools io_write8 0x66 0x81; iotools io_write8 0x62 4; iotools io_write8 0x62 50
  (fan on half speed)
  # iotools io_write8 0x66 0x80; iotools io_write8 0x62 4; iotools io_read8 0x62
  0x32
  # iotools io_write8 0x66 0x81; iotools io_write8 0x62 4; iotools io_write8 0x62 0
  (fan off)
  # iotools io_write8 0x66 0x80; iotools io_write8 0x62 4; iotools io_read8 0x62
  0x00
  # iotools io_write8 0x66 0x81; iotools io_write8 0x62 4; iotools io_write8 0x62 0xff
  (fan back to EC control)
  # iotools io_write8 0x66 0x80; iotools io_write8 0x62 4; iotools io_read8 0x62
  0xff

test EC_CMD_ACPI_QUERY_EVENT

  # iotools io_write8 0x66 0x84; iotools io_read8 0x62
  0x00

  On EC console:
  > hostevent set 0x0f000000

  # ectool eventget
  Current host events: 0x0f000000

  # iotools io_write8 0x66 0x84; iotools io_read8 0x62
  0x19
  # iotools io_write8 0x66 0x84; iotools io_read8 0x62
  0x1a
  # iotools io_write8 0x66 0x84; iotools io_read8 0x62
  0x1b
  # iotools io_write8 0x66 0x84; iotools io_read8 0x62
  0x1c
  # iotools io_write8 0x66 0x84; iotools io_read8 0x62
  0x00

  # ectool eventget
  Current host events: 0x00000000

Change-Id: I011a5a2051171ec1d37e55ce03e1ce74b93a7e14
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/179692
2013-12-12 18:21:56 +00:00
Louis Yung-Chieh Lo
25bbb6b5de More supports for A20 enable/disable
Add i8042 output port commands (0xf0-0xff), I8042_ENABLE_A20 and
I8042_DISABLE_A20.

BUG=chrome-os-partner:13119,
BRANCH=None
TEST=Tested on W7 installer. No KB error shown on EC console.

Change-Id: I9ad1fd7baa10683ef18ccf13faf09dc0cefcca0a
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34994
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
2012-11-04 20:27:57 -08:00
Randall Spangler
f76cb374f8 Clean up LPC module
Tidied comments, and removed handling of ACPI events on host command
port (not needed since EVT hardware is now EOL'd).

BUG=chrome-os-partner:15579
BRANCH=none
TEST='ectool hello' succeeds

Change-Id: I063382b9981f713ba23f7714b4ccb7faa957b411
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36804
2012-10-30 12:42:45 -07:00
Randall Spangler
7946a3eb3d Simplify host event processing
Now both copies of the event state live in host_event_commands.c, and
lpc / memmap just shadows the main copy.

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

Boot system.  should see events 0x2000, 0x80, 0x08 get set and then cleared.

At U-boot prompt, type on keyboard.  Should set event 0x1000 get set,
but only on the first keypress (because U-boot doesn't consume that
event).

Then from EC console,
hostevent clear 0x1000 -> see event 0x1000 clear
hostevent clear 0x1000 -> no debug output (it's already clear)
hostevent clearb 0x1000 -> see event copy B 0x1000 clear
hostevent clearb 0x1000 -> no debug output (copy B is already clear)

Change-Id: I855c035865649ba1490cd9027157d5bcdcc9895f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27321
2012-07-12 18:22:24 -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
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
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
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
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
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
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
Randall Spangler
300e7edb87 Add UART1 receive support (UART to x86 console)
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7488
TEST=type things into the x86 console UART; should appear on the u-boot prompt

Change-Id: I75fd225842c03d11d79280fb7453ad37695279e3
2012-02-06 14:53:49 -08:00
Louis Yung-Chieh Lo
7e8d739b38 Fix the missing IRQ problem.
The problem comes from the different assumption of interrupt mode in EC and
the PCH. The PCH assumes IRQ1 is edge-triggered and triggered at a rising edge.
However, the auto-IRQ functino of EC is level-triggered and uses low-active to
assert an IRQ. This makes the deadlock so that the kernel never gets an
interrupt until a byte is manually pulled from host.

So, the solution is manually firing an IRQ_1 to host after EC puts a byte to
port 0x60. Note that the auto IRQ needs to be disabled in order to avoid
the interference with manual IRQ generation.

This CL also moves chip specific code to lm4/lpc.c and handle some minor
keyboard commands.

BUG=none
TEST=on hacked baord.

Change-Id: Ib57f5a4d749cb019e4c3c00da110054c4f335c7b
2012-02-02 20:51:45 +08:00
Randall Spangler
70c3e30b63 Clean up UART code
LPC module no longer directly talks to UART registers, and vice-versa.

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

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

Change-Id: Id070c0d849bdfe91c752e0af651d357b695d2648
(cherry picked from commit ab8c3c2b8e3b08a4bf5573cda3a12dd3a384e67d)
2011-12-12 14:12:09 -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