Commit Graph

400 Commits

Author SHA1 Message Date
Rong Chang
e904d1a78a Change STM32 I2C master wait status timeout from 100ms to 10ms
This change shorten the timeout period to 10ms.

Experiments showed that most master mode communication status bit
changed within 2000us. Hence 10ms timeout is much reasonable than
the original value.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=none
TEST=manual, with i2c scope

Change-Id: Ib26795bd2e4877b5c33719e96a2c2c7c11333eab
Reviewed-on: https://gerrit.chromium.org/gerrit/27145
Tested-by: Rong Chang <rongchang@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
2012-07-11 06:55:26 -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
42187535e4 Remove fake dev switch
BUG=chrome-os-partner:9922
TEST=manual

Press power+refresh+d.
From ec console, 'optget'.  No reference to fake dev switch
From host, 'ectool vboot'.  Should see either 'fake_dev=0' or no mention of fake dev switch at all.

Change-Id: I66bc5e926d6e639b206563e764bcc730cce9227c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27061
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-10 14:56:05 -07:00
David Hendricks
ae648cc520 stm32: fix data buffer increment bug in flash_physical_write
This fixes a small bug introduced in a previous refactoring CL where
by the data buffer offset wasn't being incremented, thus causing
writes to repeatedly write the first two bytes of the incoming data
to each chunk of memory.

BUG=chrome-os-partner:11097
TEST=successfully wrote and verified data on Snow
Signed-off-by: David Hendricks <dhendrix@chromium.org>

Change-Id: I8dae00652f4d74bc6ef449297b6e78b13b21255f
Reviewed-on: https://gerrit.chromium.org/gerrit/26985
Reviewed-by: Katie Roberts-Hoffman <katierh@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2012-07-10 11:27:08 -07:00
Vic Yang
37b295fd6e Add a test of flash overwrite
This test checks we cannot overwrite current running system image.

BUG=chrome-os-partner:10262
TEST=Test passed

Change-Id: I72be277c9de2114e72000a102d8b885e842ef15a
Reviewed-on: https://gerrit.chromium.org/gerrit/27006
Commit-Ready: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-10 00:35:58 -07:00
Vic Yang
42d0270990 Clear UART FIFO when initializing to prevent reading garbage
When debug port is left unconnected, EC get garbage keypress input from
both UART ports due to UART pin floating. By clearing UART receive FIFO
when initializing UART module, this can be prevented.

BUG=chrome-os-partner:10235
TEST=Reset EC with debug port unconnected. Check u-boot doesn't get any
     keypress.

Change-Id: I3e84db1f2f95a0173c11180f6afb3edb705d0ae5
Reviewed-on: https://gerrit.chromium.org/gerrit/26908
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-07-09 19:50:22 -07:00
Vic Yang
80d92fd6dd Handle invalid parameter of fan duty cycle and keyboard backlight
If the 'percent' passed in is lower than 0, then set it to 0. If it is
higher than 100, set to 100.

BUG=chrome-os-partner:11052
TEST=Check with 'kblight', 'fanduty', and 'faninfo'.

Change-Id: If84ab12658bf136eaaf1adecc0522a977c94f98d
Reviewed-on: https://gerrit.chromium.org/gerrit/26904
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-09 19:50:21 -07:00
Randall Spangler
46bc2721c5 Remove unused UART defines
No longer needed since the rewrite of the panic handler in C.

BUG=none
TEST=link and snow still compile

Change-Id: Ib790004ae4d0ba11f0800e85e14ea372a53025f8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26890
Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-09 10:58:14 -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
1c287d0486 Increase UART output buffer size on LM4
512 bytes isn't enough to capture all the debug output early in the
init process, and Link EC has lots of unused RAM.  stm32 doesn't, so
only do this for LM4 processor.

BUG=none
TEST=build; debug output during init shouldn't be garbled

Change-Id: Ie4fd204fa4e0c6ca99ea7eae94b095ef175836e4
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26877
2012-07-07 23:05:50 -07:00
Vic Yang
41a55ba8ac Preserve PWM module state across system jump
If we don't store PWM module state, fan would be disabled after system
jump until the next reboot. Let's preserve fan and keyboard backlight
state.

BUG=chrome-os-partner:11027
TEST=Boot and "sysjump a". Check fan is still enabled.

Change-Id: I57dbcabef79264af7fcedb8fa0c00ff6299b97d5
Reviewed-on: https://gerrit.chromium.org/gerrit/26757
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-07-07 19:10:27 -07:00
Randall Spangler
e129d5f1fa Support host event get/set/clear on all host interfaces
BUG=chrome-os-partner:11090
TEST=suspend laptop, then press power button; should resume from suspend

Change-Id: I36b7c62b2e115bb97d37defcd3c783af0f91d5f8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26730
2012-07-07 17:36:46 -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
0e42faf85b i2c: Display reason for each timeout
There are a lot of timeous in the i2c driver. When one occurs, print
out the number of it so that the root cause can more easily be
examined.

BUG=chrome-os-partner:10888
TEST=manual:
Lock up the i2c bus from the AP by running the kernel without bus
arbitration doing i2c traffic:

while true; do i2cdump  -f -y 4 0x48; done >/dev/null

and using 'pmu 100' on the EC.

Then see that a timeout error is printed, for example:

i2c wait_status timeout type 2, 101387 us

Change-Id: I3fb3fcf9f07966ef4e71d4358c791fea90aba5d5
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26830
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2012-07-05 22:56:39 -07:00
Randall Spangler
b4789cf1f7 x86power module must init before power button module
The power button module now needs to know whether the chipset is in
the on state at init-time, in which case it doesn't need to send a
power button pulse to the chipset.

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

1. power on AP to BIOS screen (e.g., in recovery mode)
2. At EC console, 'sysjump A'
3. system should stay powered on

Signed-off-by: Randall Spangler <rspangler@chromium.org>
Change-Id: Ic1f509204f502d1ddf87314f0e1582c21c991156
Reviewed-on: https://gerrit.chromium.org/gerrit/26700
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-07-03 23:51:16 -07:00
Vic Yang
24acac67a3 Lower PECI baud rate and increase poll frequency
We see some intermittent failure on PECI read. This CL lower PECI baud
rate from 150K to 100K. Also, we poll PECI temperature 4 times per
second and average over last 4 values. We only report read error when
last 4 read all fails.

This CL also increases the external path delay, increases retry count,
and also enable timing negotiation error bypass.

BUG=chrome-os-partner:10382
TEST=Still able to read from all temperature sensors

Change-Id: I38cefeabd9e3eff4bb8e4df4138c4ffd49cd84a2
Reviewed-on: https://gerrit.chromium.org/gerrit/26554
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-07-03 10:50:46 -07:00
Simon Glass
aa64550a3f gpio: Add fast access to GPIO level
The current gpio_get_level() is pretty slow because it looks things up each
time. Add a new function to find out the register address and mask to use
to check the value for a particular GPIO.

Time-critical code can then use this to check a GPIO.

BUG=chrome-os-partner:10146
TEST=manual:
build and boot on snow;
Power on the board, hold power button for 10s and see that it powers off
Power control still works, thus GPIOs are functional

Change-Id: Ifc6c56f5cb811e0243e7712725a51948eabd42ab
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26175
2012-07-02 22:35:52 -07:00
Simon Glass
9a4eff992f flash: Provide direct flash access with flash_dataptr()
Sometimes it is useful to get access to the flash directly, without using
flash_read(). Add a function to do this.

Since the range checking is done in every function in flash_common,
use the new function to do it for us. That way we get a slight (64 byte)
code size reduction.

BUG=chrome-os-partner:10146
TEST=manual:
build and boot on snow with SPI flash emulation, in U-Boot:

See that the 32KB of flash has been provided correctly.

Change-Id: I6622a24234edaed371dd5b9bf43d1f3974d55e39
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26174
2012-07-02 22:35:51 -07:00
Simon Glass
9b48067b09 stm32: Use a timer as the watchdog warning
The WWDG is not ideal for this purpose, since if we fail to handle its
interrupt withint 60ms or so, we get a reset. This can be a problem when we
are reporting a panic, since the uart output takes a long time.

Change to using timer 9, which is free, and make it print a watchdog warning
after one second.

BUG=chrome-os-partner:10146
TEST=manual:
build and boot on snow; waitms 1200 and see that a watchdog timeout is
reported correctly.
See that the panic message is displayed in full without a reset happening
before the end.

Change-Id: Ifc3671098e1f3a7ef409b8d1fb919d22eaa90358
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26172
2012-07-02 22:35:51 -07:00
Simon Glass
f492f04a9d stm32: Fix up SPI driver to use host_command interface
This driver was not refactored when the host_command changes were made,
although i2c was. Tidy this up.

SPI requests the command response immediately rather than going through
the task queue, since otherwise a response may take long enough that the
SPI master misses it altogether.

BUG=chrome-os-partner:10533
TEST=manual:
build and boot on snow; In U-Boot:
> sspi 4:0 240 20
See that it gets key messages back now

Change-Id: Ia2c24d4c8876fefedad4c02802f77e50d7159d03
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25982
2012-07-02 22:35:50 -07:00
Simon Glass
34bba87577 snow: Implement I2C arbitration
Use two suitable GPIOs to implement a simple arbitration scheme.
Each side owns one of the GPIOs, which are normally pulled high.
When one side wants to use I2C as a master, it pulls its GPIO low,
waits for a short period to make sure that the other side is not
also pulling its GPIO low, and then goes ahead with the transaction.

When the transaction is over, the GPIO is released, thus freeing the
I2C bus up for use by the other end.

For simplicity the terminolgy used here is EC for us, and AP for the
other end.

BUG=chrome-os-partner:10888
TEST=manual:
build for all boards
boot on snow (cannot test i2c as it is broken)

Change-Id: I97d9fbd5aba8248c8c1240baaec17db22860665c
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26142
2012-07-02 22:35:50 -07:00
David Hendricks
95f11b09eb stm32: force update generation during timer setup
This corrects a small bug where by the UG bit in EGR was
not getting set, so the shadow registers were not being
reloaded as the comments suggest they should be.

This is really only a minor clean-up. The timer appears to
work fine with or without the patch.

Signed-off-by: David Hendricks <dhendrix@chromium.org>
BUG=none
TEST=timerinfo appears sane on Snow

Change-Id: I637e2fc1f5dbfa1e70d33f96c8bf38ac57cc7b2c
Reviewed-on: https://gerrit.chromium.org/gerrit/26520
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
2012-07-02 21:10:26 -07:00
David Hendricks
3ed21ca42c stm32: increase CONFIG_FW_IMAGE_SIZE to 64KB
This increases the size of each image for STM32 devices from 32KB
to 64KB.

Signed-off-by: David Hendricks <dhendrix@chromium.org>
BUG=none
TEST=Built and flashed to Snow, built for Daisy

Change-Id: Ide9b0a9e9929c8861a701c868e7ad3010aa575e1
Reviewed-on: https://gerrit.chromium.org/gerrit/26635
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Commit-Ready: Simon Glass <sjg@chromium.org>
2012-07-02 20:36:58 -07:00
Simon Glass
8a640043f1 stm32: i2c: Simplify host_send_response()
Simplify this code, so that it does only one pass of the response data,
calculating the checksum as it copies.

BUG=chrome-os-partner:10535
TEST=manual:
build for all boards
build and boot on daisy
see that keyboard still works

Change-Id: I8b0a2ce1632dd4c1ff54736fb636d9a5cf8c9214
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25981
2012-07-02 20:36:57 -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
David Hendricks
1bedd55970 Daisy/Snow: Drive power LED with PWM
This drives the power LED for Snow (PB3) using TIM2 in PWM mode.

Since timer setup and manipulation is STM32-specific, the power LED
logic moved to to chip/stm32/power_led.c.

This also adds a "powerled" console command for testing.

Signed-off-by: David Hendricks <dhendrix@chromium.org>

BUG=chrome-os-partner:10647
TEST=Tested on Snow with powerled command, compiled for Daisy

Change-Id: I5a7dc20d201ea058767e3e76d54e7c8567a3b83c
Reviewed-on: https://gerrit.chromium.org/gerrit/26267
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2012-07-02 15:26:02 -07:00
Simon Glass
d7dd49471c dma: Add dma_dump() and rename debug config to CONFIG_DMA_HELP
Add a new function to dump the current dma state, and hide it behind
a more official-sounding CONFIG_DMA_HELP.

BUG=chrome-os-partner:10533
TEST=build and boot on snow

Change-Id: I42fb101628e9044284a6b39447b0b1fc2d36587b
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26168
2012-07-02 15:02:06 -07:00
Simon Glass
79353032e0 dma: Add dma_bytes_done() to return bytes completed in a dma channel
By subtracting the current dma count from the number of bytes originally
requested to be transferred, we can find out how many bytes have been
transferred so far.

BUG=chrome-os-partner:10533
TEST=build and boot on snow

Change-Id: Ideee1ed27c08b56882f5d2095341fe04bbe9c34b
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26167
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2012-07-02 12:24:44 -07:00
Rong Chang
f429744005 Fix multiple charging issues on snow
This change fixes mutiple snow charging issues. Including:
  - disable i2c host auto selection
  - i2c_read8 got wrong output value
  - pmu CHARGE_EN control workaround

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:11010
TEST=Only test on snow dvt with AP turned off
  plug/unplug ac adapter and check charging led
  check console command 'battery'

Change-Id: I29d554b3daa4cfc538bd5bf5ba5233976d381861
Reviewed-on: https://gerrit.chromium.org/gerrit/26529
Tested-by: Rong Chang <rongchang@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-07-01 15:45:09 -07:00
David Hendricks
6900449d0c stm32: switch 32-bit timer to use TIM3/4
Chain TIM3/4 as the 32-bit timer instead of TIM2/3. This frees
up TIM2 to be used for other purposes.

BUG=chrome-os-partner:10647
TEST=Flashed onto Snow, stuff works and timerinfo output is sane

Signed-off-by: David Hendricks <dhendrix@chromium.org>

Change-Id: Icdfe3596a15bc2ee8536f160b1f08ac3041b9193
Reviewed-on: https://gerrit.chromium.org/gerrit/26202
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2012-06-29 19:58:46 -07:00
Simon Glass
7bcf881bd6 Implement board-level I2C arbitration
Add a way for boards to permit or deny access to the I2C port. This
works in a board-specific manner.

All I2C master traffic requires that board_i2c_claim() be called
first. A dummy function is provided for boards which do not require
this.

BUG=chrome-os-partner:10888
TEST=manual:
build for all boards
boot on snow (cannot test i2c as it is broken)

Change-Id: I786d4ae17f1d798faf13b303b5389679fb6720cb
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26141
2012-06-29 10:46:22 -07:00
Simon Glass
3d632987cc dma: Deprecate dma_start_tx() in favor of dma_prepare_tx()
This allows us to prepare a dma transaction in advance, and quickly
start it when needed.

BUG=chrome-os-partner:10533
TEST=build and boot on snow

Change-Id: Ib7d843b2d3a5cd94b6025b9741db1794ebbcfda0
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26449
2012-06-29 09:57:08 -07:00
davidjames
a1cde77c51 Revert "dma: Deprecate dma_start_tx() in favor of dma_prepare_tx()"
This reverts commit 7af4172be4afad9d576549721a82b3a47d701647 / Iac605b879b3556f33af5585b298ada6bc4f52c90.

This change bypassed the commit queue and broke daisy as a result.

BUG=chrome-os-partner:10533
TEST=build and boot on snow

Signed-off-by: Simon Glass <sjg@chromium.org>
Change-Id: I7a05ab42f71a901d167bde977f8a025c7ef62dfc
Reviewed-on: https://gerrit.chromium.org/gerrit/26379
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
2012-06-28 19:57:34 -07:00
Simon Glass
9ae29ecd25 dma: Deprecate dma_start_tx() in favor of dma_prepare_tx()
This allows us to prepare a dma transaction in advance, and quickly
start it when needed.

BUG=chrome-os-partner:10533
TEST=build and boot on snow

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

Change-Id: Iac605b879b3556f33af5585b298ada6bc4f52c90
Reviewed-on: https://gerrit.chromium.org/gerrit/26166
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Commit-Ready: Simon Glass <sjg@chromium.org>
2012-06-28 19:02:08 -07:00
Simon Glass
3db49e8acf dma: Adjust prepare_channel() to use a channel pointer
Rather than a channel number, use a pointer. Also we don't need a
return value, since this function cannot fail.

BUG=chrome-os-partner:10533
TEST=build and boot on snow

Change-Id: I9d7e567a9f3d496184fd28f0820ad798b1c43a28
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26165
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2012-06-28 17:06:47 -07:00
Simon Glass
a366d64981 dma: Export dma_get_channel()
Access to dma is currently via a channel number. It is more efficient
to export a pointer to the dma channel since it avoids the conversion
on every API call. This helps, because dma is often on the critical
path.

Export the function to provide a pointer to a dma channel given its
number.

BUG=chrome-os-parter:10533
TEST=manual: build for all boards

Change-Id: I0318e59dbb1b9077f0445804692ca7ea99cf6581
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26164
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2012-06-28 17:06:47 -07:00
Randall Spangler
7957516145 Add flash_link_ro command to openocd
This is ~4x as fast as flashing the entire EC image, and is similar to
the existing flash_link_a command.

BUG=none
TEST=from openocd prompt, flash_link_ro

Change-Id: I04160af3d7d70028f8d2789480094c283a1ce2ab
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26268
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-06-28 16:32:55 -07:00
Simon Glass
9905a80a4b i2c: Tidy up common code for i2c master
At present there is quite a bit of duplicated code. Create a new
i2c_transfer() function to take care of this.

BUG=chrome-os-partner:10888
TEST=manual:
build for all boards
boot on snow (cannot test i2c as it is broken)

Change-Id: I3672cc4ff9de4e2e0deaec2997590ee892ef09aa
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26140
2012-06-28 11:56:39 -07:00
Vincent Palatin
240470a54b stm32: fix race condition in I2C response
When we are transmitting a response to the EC, we don't want to race
with the TX empty interrupt handler. So just disable I2C interrupt
during the transmission.

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

BUG=None
TEST=on Lucas DVT, use the keyboard and see we are no longer getting
"bad checksum" in the kernel log.

Change-Id: Ic59532d1ac0a3eabb67ba0d498940986282bd87f
Reviewed-on: https://gerrit.chromium.org/gerrit/26162
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2012-06-26 20:52:35 -07:00
Vincent Palatin
cbbaf428a9 stm32: fix I2C waveforms and states
- most events happen in the first 100us, we don't want to sleep to 2ms.
  This introduces big delays. Just poll the 150us, then fall back to
  sleep.
- restore properly the port state after master transfers.

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

BUG=None
TEST=On Lucas DVT, probe I2C signals with logic analyzer and manually
check them. Verify that the keyboard is still working with the charging
code enabled.

Change-Id: Ic0afde081d070ff6720d924469ecc7166bbc9e4c
Reviewed-on: https://gerrit.chromium.org/gerrit/26161
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2012-06-26 20:52:33 -07:00
Simon Glass
9bee82222e flash-stm32f100: Fix unaligned cast
There isn't a good reason for doing things this way, so tidy up the
code and remove the TODO.

BUG=chrome-os-partner:10533
TEST=manual:
build and boot on snow
Test writing of flash still works using U-Boot command

Change-Id: I66a8f16072dc28f24c493af7674f7be5d838529c
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26163
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-06-26 17:54:56 -07:00
Randall Spangler
55073a0a84 Power on AP every EC reboot.
Needed for EC software sync so the AP can verify the EC's RW code and
tell the EC to jump to RW when necessary.  If the AP then decides it
doesn't need to stay booted, the AP can shut back down.  (The AP
verifying the EC's code and/or shutting back down are NOT part of this
CL...)

Also add a Power+Refresh+DownArrow key combination which causes the EC
to reset WITHOUT powering on the AP; this will be needed for debugging
the AP power-on sequence.

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

1) power+refresh+down -> ec reboots, system stays down
2) power+refresh+esc -> ec reboots, system to recovery
3) power+refresh -> ec reboots, system boots
4) hibernate, then open lid -> ec reboots, system boots
5) hibernate, then power button -> ec reboots, system boots
6) yank battery, then reconnect -> ec reboots, system boots
7) reboot ec -> system boots
8) 'sysjump A' when AP already booted -> system stays on
9) 'sysjump A' when AP shut down -> system boots

Change-Id: I65d2f7d9cca3acb84b76302cdcd8c8a800f03253
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26158
2012-06-26 17:33:53 -07:00
Randall Spangler
b73bfcaa92 Only check for boot key on the first boot after keyboard reset
Don't check if we've jumped to this image (which preserves the reboot reason,
so was causing us to re-check).

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

1) power+refresh; should see EC print [KB boot key 0]
2) sysjump A; should NOT see [KB boot key 0]

Change-Id: I46cc60358e1d1952484f52147787fee06e4ff69f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26155
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-06-26 17:01:53 -07:00
Randall Spangler
7b155fb8ac Refactor boot key detection
Keyboard scan module now owns the recovery key state on all platforms.

And clean up a few comments to linux kernel style

BUG=chrome-os-partner:10890
TEST=manual
- Power on system.  Should boot normally.
- Power+Refresh+D.  Should turn dev switch on.
- Power+Refresh+F.  Should turn dev switch off.
- Power+Esc.  Should reboot system.  Power button should power on normally.
- Power+Refresh+Esc.  Should power on into recovery mode.
- Then press power to shut system down.
- Power button should power on normally (not back into recovery mode).

Change-Id: I4d16e1e8b039efeacbd41e8acec115844bc8457d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26147
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-06-26 17:01:52 -07:00
Randall Spangler
fb123b4838 Only one RW image is now the default
And if RW B isn't enabled, it's not even linked.

BUG=chrome-os-partner:10881
TEST=on link, should be no B image, and 'sysjump B' should fail
On BDS, still should be A and B images

Signed-off-by: Randall Spangler <rspangler@chromium.org>
Change-Id: Icb2af07881cc7e28b9b877f45824486a22fde8d7
Reviewed-on: https://gerrit.chromium.org/gerrit/26116
2012-06-26 13:58:54 -07:00
Randall Spangler
90afebac64 Strip out vboot signature code and stay in RO for link
BUG=chrome-os-partner:10880
TEST=boot EC; should stay in RO and not do signature check
(verify via debug console output)

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

Change-Id: I831aa91f8273bc7fb1a624cf36d9f21d52d8f3d8
Reviewed-on: https://gerrit.chromium.org/gerrit/26115
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Randall Spangler <rspangler@chromium.org>
2012-06-26 13:58:53 -07:00
Randall Spangler
aab92d552d Shut off keyboard backlight at chipset shutdown
This ensures the keyboard backlight will go off even if the chipset
shuts down due to overheating (or some other unclean shutdown).

(Also fixes inter-function line spacing to linux kernel coding style
and reformats a few comments.)

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

1. power on system
2. turn on keyboard backlight (kblight 100 at EC console)
3. power off system (for example, via power button)
4. keyboard backlight should turn off

Signed-off-by: Randall Spangler <rspangler@chromium.org>
Change-Id: I5bbcd1681ae9c972c9875e9c720617bdf51e3d64
Reviewed-on: https://gerrit.chromium.org/gerrit/26039
2012-06-25 15:37:42 -07:00
Randall Spangler
24395bcc87 Remove proto1 workarounds
At this point, EC code requires EVT.  If you still have a proto1,
here's what'll break:
  1) Keyboard recovery mode checks refresh key, and may read unreliably due
     to proto1 silego reset circuit.
  2) Lightbar may not start in the correct state.
  3) EC 'hibernate' command will not work.
  4) Board version may read incorrectly.

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

1) powerbtn -> system powers on, lightbar displays proper sequence
2) version -> board version 1 (EVT)
3) power+refresh+esc -> system boots into recovery mode
4) power+refresh, then power button -> system reboots, then boots normally

Signed-off-by: Randall Spangler <rspangler@chromium.org>
Change-Id: I699946e365d15ae38622b69da1a0241e72d05f61
Reviewed-on: https://gerrit.chromium.org/gerrit/26053
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-06-25 15:37:41 -07:00
Vic Yang
1105a28a8c Add a test of checking keyboard de-ghosting
This test check when a ghost key appears, it is correctly ignored.

BUG=chrome-os-partner:10285
TEST=Test passed.

Change-Id: Ic5a6a9b5c78a969899df7c7a82f1c9d0c01b1325
Reviewed-on: https://gerrit.chromium.org/gerrit/25831
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-06-25 08:39:13 -07:00