Commit Graph

207 Commits

Author SHA1 Message Date
Gerrit
3a4cd3f8f3 Merge "stm32l: clear and then set GPIO mode and pull-up/down settings" 2012-04-24 10:44:39 -07:00
Randall Spangler
507532d081 Set BOOTCFG register to test value
Needed for testing preprogramming chips

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

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

hibernate 1; should reboot
rw 0x400fe1d0; should print: read word 0x400fe1d0 = 0xfffffdfe

Change-Id: I95b419d7285a0bf5204f95d1f68f64dc212bb39e
2012-04-24 09:18:41 -07:00
David Hendricks
97a49113d9 stm32l: clear and then set GPIO mode and pull-up/down settings
GPIO mode and pull-up/down registers do not all get initialized to
zero on reset. This patch ensures that all bits in the those registers
are set explicitly. An intermediate variable is used so that changes
are made atomically.

Note: output speed registers are also not all initialized to zero, but
we don't handle that in gpio_pre_init yet.

BUG=none
TEST=tested on newer daisy boards (which needed this patch to boot)

Change-Id: Ice2795197135dcee8f8484e4908dbfcf90fec2c9
Signed-off-by: David Hendricks <dhendrix@chromium.org>
2012-04-23 19:18:42 -07:00
Gerrit
f99b650a23 Merge "stm32l: fix length argument for i2c writes" 2012-04-23 11:32:25 -07:00
David Hendricks
9b942e570c stm32l: fix length argument for i2c writes
Pass the actual msg_len instead of the maximum outbound message size.

BUG=none
TEST=tested on daisy using logic analyzer (notes below)

Beforehand, the output on a logic analyzer looked sane until the last
bits and stop condition, after which the bus appeared to go haywire
and the system would reset. I'm guessing that this is due to the EC
trying to drive SDA line while the host is holding SCL high.

Change-Id: I1afa520d858905a571540341fe02f374dcdf43c1
Signed-off-by: David Hendricks <dhendrix@chromium.org>
2012-04-23 10:56:12 -07:00
Gerrit
a05deade13 Merge "Remove clock calibration for PIOSC" 2012-04-20 11:09:45 -07:00
Randall Spangler
34df8261f7 Remove clock calibration for PIOSC
Proto1 has A3 silicon which is factory-trimmed.

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

BUG=chrome-os-partner:7693
TEST=boot and look for glitchy EC console.  If it's not glitchy, it worked.

Change-Id: I56cb2458e600e76e458bce0f24832ef4f456ac14
2012-04-20 10:13:17 -07:00
Randall Spangler
b2f34fcfd1 Add openocd macros to write image A or B
These are faster than writing the entire EC, and safer if you're
mucking with things like the clock config.  Of course, if you're
changing verified boot or something else that happens before
vboot_init(), these new commands won't help, and you should keep using
the existing flash_link command.

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

BUG=none
TEST=manual from openocd
- Compile a new image
- From openocd, flash_link_b
- From ec console, note build compile date in image A: shouldn't have changed
- From ec consle, sysjump b; compile date should be for your new image

Change-Id: Ifd6aabe963948d3c5da5bdeb78c5f962a0f9f857
2012-04-20 10:04:48 -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
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
ee3edc0116 Clean up inits
We can clear the reset cause in system pre-init now because of a
previous change which preserves it across a sysjump.

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

BUG=none
TEST=if it boots, it works

Change-Id: I1d8b99df5a0be0de9545d22ad1a6b7fb3140f813
2012-04-19 11:08:28 -07:00
Randall Spangler
70f3fcaf86 Add hooks module so modules can be notified of system-level events.
This will be used for sleep/wake/sysjump/etc.  For now it's just wired
up to clock frequency changing.

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

BUG=none
TEST=manual: use nopll command, should still work

Change-Id: Iedcea5830bc18eacfd955c29b8f793aba8905dd8
2012-04-19 08:39:41 -07:00
Gerrit
6ecbb86b63 Merge "EC: Use interrupt for ADC" 2012-04-19 07:25:19 -07:00
Gerrit
48aba27dd5 Merge "stm32l: eliminate GPIO initialization done in keyboard code" 2012-04-17 11:36:35 -07:00
Gerrit
e70d6886cd Merge "stm32l: Update gpio_pre_init to operate with explicit types" 2012-04-17 11:36:34 -07:00
Vic Yang
85885221af EC: Use interrupt for ADC
We used to wait in a loop for ADC conversion completion. This CL modify
this to use real interrupt.

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

BUG=chrome-os-partner:7492
TEST=See 'temps' still reporting EC internal temperature

Change-Id: Iffd3cc3c021d82d3284bed198589be5b63d72d4d
2012-04-16 22:50:22 +08:00
David Hendricks
fe2bae3dd5 stm32l: eliminate GPIO initialization done in keyboard code
This eliminates the GPIO init code from stm32l's version of
keyboard_scan.c. It moves all initialization to board.c, and
also eliminates the input/output arrays that were used to represent
keyboard GPIOs earlier on. The keyboard code no longer needs
board-specific GPIO knowledge.

There were some minor nomenclature clean-ups along the way, but
but there is still more clean-up to do in future CLs.

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

BUG=none
TEST=tested on Daisy

Change-Id: I27e92b10262e686111f20d8e3ed9e416db245355
2012-04-13 14:46:33 -07:00
David Hendricks
250ce6dfc9 stm32l: Update gpio_pre_init to operate with explicit types
This re-works the gpio_pre_init() function to do the following:
- Works on explicit types introduced in the previous CL.
  This will allow more flexibility so that we can remove
  GPIO initialization done outside of board.c.
- Separates handling of direction (in/out) and other port config
  options such as pull-up/down, open-drain/push-pull, etc.
- Moves setting port as input/output and setting level (if required)
  to the very end to avoid driving certain outputs high before they've
  been properly configured.

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

BUG=none
TEST=Tested on daisy (using subsequent patches in this series).

Change-Id: I7ed030b5cb52c201a0b3aa07f515f5f954430083
2012-04-13 14:46:33 -07:00
David Hendricks
82609a3c72 stm32l: add i2c driver
(Derived from Vincent's original I2C slave CL)

This configures I2C port 2 as a slave device at 8-bit address 0xEC
(7-bit address is 0x76).

This CL only implements single-byte read and write transactions.
A master-initiated write will set EC mode, and a master-initiated read
will send bytes back depending on the mode.

BUG=chromium-os:28925
TEST=build on daisy and discovery; run on daisy

Change-Id: I1e9f28feb99e25bb7656b6e9ae8643d3ae285a28
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-04-13 12:26:00 -07:00
Gerrit
335af85983 Merge "Disable screen and keyboard backlights when lid is closed." 2012-04-13 10:02:21 -07:00
Gerrit
20467eb15b Merge "stm32l: Add basic SPI driver" 2012-04-13 10:02:21 -07:00
Randall Spangler
fd828569e6 Disable screen and keyboard backlights when lid is closed.
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

1. Power on system
2. From ec console: kblight 100
3. Use a magnet next to the left shift key to trigger the lid switch.  Screen and keyboard should go dark.
4. Remove the magnet and they should light up again.

Change-Id: I298ea94930976153d8dcd102316b010ee28cd747
2012-04-13 09:23:26 -07:00
Gerrit
2da4ad907c Merge "Fix power button turning system back on after 4 sec" 2012-04-12 16:06:57 -07:00
David Hendricks
71030319ec stm32l: Add basic SPI driver
Add a SPI driver which can receive and process commands, and provide
responses using the message interface.

BUG=chromium-os:28925
TEST=build on daisy and discovery; run on daisy

Change-Id: I286da803b85640525607de6c4d41f0629f7006dc
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-04-12 15:52:07 -07:00
Randall Spangler
9f09fbe42c Fix power button turning system back on after 4 sec
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

Turn system on
Hold power button for 5 sec
Let go
System should stay off

Change-Id: I4660108972795d631b7c33926df58513ee09e1c7
2012-04-12 15:14:56 -07:00
David Hendricks
a7f86c2774 stm32l: remove unnecessary inner loop from check_keys_changed()
This inner loop was used to detect single changes for use by the
i8042 keyboard interface code used on LM4. Since we only send
the entire matrix state, we do not need this particular bit of
code.

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

BUG=none
TEST=tested on daisy

Change-Id: I4d36a7db77d20ace29f534c9e12f7ed9558c953d
2012-04-12 15:13:42 -07:00
David Hendricks
57354c52cf stm32l: Tweak keyboard scan delays
Tweak some of the original keyboard_scan delays for better responsiveness
now that we have real hardware to test on.

BUG=chromium-os:28925
TEST=build on daisy and discovery; run on daisy

Change-Id: Ib2f5418c624bb0b7a0009d01ab669299607c1a59
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-04-12 15:13:42 -07:00
Gerrit
21c2391e24 Merge "Remove keyboard message on power-up" 2012-04-12 14:45:22 -07:00
Randall Spangler
3b5ecd0d83 Add timeout for flash operations.
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7479
TEST=manual.  From the linux console,

ectool reboot_ec RO
ectool flashread 81920 163840 /tmp/ec.bin
ectool flasherase 163840 81920
ectool flashwrite 81920 /tmp/ec.bin
ectool reboot_ec A

Change-Id: I850f4cea5dfdb76cfe3957988b10cf8841de55c1
2012-04-12 12:27:29 -07:00
Randall Spangler
f411bbbe19 Re-enable watchdog in watchdog_reload()
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

waitms 1500
(see watchdog trace)
waitms 1500
(should see watchdog trace again)
waitms 3000
(should see trace, then system should reboot)

Change-Id: Ieb5009d7a7bc9e1ed795e58efb0cb44a1eeb2706
2012-04-12 12:04:37 -07:00
Randall Spangler
20fdc57a35 Reload watchdog timer during flash operations.
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

While ssh'd into the device:

1) Create a test image:

Extracting to: /tmp/ecup

132+1 records in
132+1 records out
136132 bytes (136 kB) copied, 0.000550122 s, 247 MB/s

2) Force the EC into its RO image:

done.

3) Erase the A and B images, then reprogram them:

Erasing 163840 bytes at offset 81920...
done.

Reading 136132 bytes from /home/chronos/user/ecb.bin...
Writing to offset 81920...
done.

4) Repeat step 3 about 10 times while monitoring the EC debug console.
Commands should complete successfully all the time.  (Note that during
the flashwrite, there's a ton of debug output; what you should NOT see
is something like this:
   WATCHDOG PC=00002104 / LR=0000597f / pSP=200013a0

Change-Id: I2f1f05eb19abcd6e19c6364f6d4ac785cca6a4c6
2012-04-12 09:41:35 -07:00
Simon Glass
c748a0a9df Remove keyboard message on power-up
We want the Chrome EC message to be the first one produced after
start-up, so remove the message for the keyboard:

[kbscan keyboard_scan_init()] initializing keyboard...

BUG=none
TEST=build on daisy and discovery; run on daisy

Change-Id: I264450036145406e2d3bc39171ba672984f7dc99
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-04-12 09:13:56 -07:00
Gerrit
e581c9e4ca Merge "Update keyboard scanning for stm32 to use messages" 2012-04-11 17:21:21 -07:00
Simon Glass
220a5a496d Update keyboard scanning for stm32 to use messages
Provide the required plumbing for the stm32 keyboard scan code so that
the message layer will pick up keyboard scans.

The design is as follows:
- When a change in keyboard state is detected, the keyboard matrix
  scanning code will call the board-specific board_keyboard_scan_ready()
  function to interrupt the AP.
- The AP will initiate a CMDC_KEY_STATE transaction over SPI or I2C
- The SPI or I2C driver will call message_process_cmd() to process the
  command
- This in turn will call keyboard_get_scan() to get the latest scan data

For SPI:
- The AP will initiate an 20-byte (or longer) SPI transaction
- The EC will see the command, and provide the keyboard state in response,
  with the response being part of the same transaction

For I2C:
- The AP will initiate a 1-byte write to set the EC mode.
- The AP will then initiate an 18-byte read, and the EC will send the
  message including keyboard state

BUG=chromium-os:28925
TEST=build on daisy and discovery; run on daisy
Change-Id: I905ef9d567e43d85fb851052f67586eff58e1167
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-04-11 16:28:53 -07:00
Randall Spangler
406158a2a7 Add USER_REG3 and indicate it's reserved for preprogramming process data.
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:8889
TEST=code still builds

Change-Id: Ifdd31189fb5de779f090aa089173407e381c62b7
2012-04-11 16:16:20 -07:00
Simon Glass
9e50df36b3 Add support for DMA controller
Add some basic functions to start DMA operations for transmit and
receive.

BUG=chromium-os:28925
TEST=build on daisy and discovery; run on daisy

Change-Id: Ifceeed2af80cf5f00e1ce1a49b1139a76585b0bf
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-04-11 11:01:50 -07:00
Randall Spangler
322eebbae4 Add fake developer switch
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

  optget fake_dev_switch --> 0
  optset fake_dev_switch 1
  optget fake_dev_switch --> 1
  optset fake_dev_switch 0
  optget fake_dev_switch --> 0

Reboot by holding ESC+D and tapping power

  optget fake_dev_switch --> 1

Reboot by holding ESC+F and tapping power

  optget fake_dev_switch --> 0

Change-Id: Iccb3bc8b3d571e551e204892769efc4161858055
2012-04-10 14:09:40 -07:00
Vincent Palatin
d8541f29c8 use the full 256kB for partitions
Now Link has 256kB parts, we can restore the third partition and use 80kB partitions.

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

BUG=None
TEST=on Link proto-1, try to use RO/A/B images (sysjump B, then boot).

Change-Id: I9b7e4cae1504e86a62643db4d035cc9f3de0af52
(cherry picked from commit cefaf59328e4b91308d0347cc1f55861e93db480)
2012-04-10 00:31:17 +00:00
Randall Spangler
e9328ac4f6 Support dynamically changing the system clock
Add nopll command to turn off the PLL, reducing the system clock to 16Mhz.

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

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

boot system
press power button to boot x86
temps   // should print all temperatures
timerinfo
timerinfo
timerinfo  // convince yourself this is counting up at about 1MHz
nopll  // this drops the system clock to 16MHz
temps   // should still print all temperatures
timerinfo
timerinfo
timerinfo  // should still be counting up at about 1MHz

Change-Id: Ie29ceb17af348148bffadf63d60c1b731f4c3f6d
2012-04-09 10:33:35 -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
9936df2b8b Split lid handling into separate functions and add command interface
This has been useful for me to be able to test lid behavior remotely
since it is not available via servo.

This also has a minor change to send a task message after sending
the power button pulse so the state machine behaves properly.

BUG=none
TEST=Execute 'lidclose' and 'lidopen' commands via ec uart and
see the appropriate events set and wake behavior when the system
is off.  With a (not yet published) coreboot I am able to handle
lid close events to enter suspend.

Change-Id: Iec1c68121d42b66305ba5dfd20e81453538a97e2
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
2012-04-06 14:49:42 -07:00
Duncan Laurie
6abb3579af Add support for generating SCI via LPC
The SCI pin is not connected to a GPIO and it uses a different
method to trigger a pulse via LPC0SCI.

The ACPI specification requires SCI for 3 conditions:
- SCI event pending
- Input Buffer Empty
- Output Buffer Full

The buffer full/empty SCIs are used to nudge the kernel driver
along so it does not have to poll for a potential slow EC to
be ready.  This only really makes sense for the kernel channel
so they are only generated there.

BUG=chrome-os-partner:8277
TEST=using (unreleased) coreboot BIOS to test that the kernel
can receive SCI events and the ACPI method is successfully run.

Change-Id: I6b3717fcad6569bda4482d9aaa37d45b4cf36335
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
2012-04-06 14:49:30 -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
bae507a2da Invert write protect signal
Write protect is active-high, not active-low.

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

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

From chroot:
  dut-control fw_wp_en:on
  dut-control mfg_mode:on
From console:
  gpioget WRITE_PROTECT
  0  WRITE_PROTECT

From chroot:
  dut-control fw_wp_en:on
  dut-control mfg_mode:off
From console:
  gpioget WRITE_PROTECT
  1  WRITE_PROTECT

Change-Id: I81c7858cac43c6c9b8630bf7f5aa0f491e6554ad
2012-04-04 15:26:25 -07:00
Randall Spangler
0f23e72532 Power button state machine handles keyboard-controlled reset
On Power+ESC -> ignore the power button being down until it's
released; system stays powered down.

On Power+ESC+Refresh -> send a power button pulse to the PCH.  Ignore
the power button until after both the pulse has finished and the power
button is released.

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

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

Reboot system.
Press power.
System powers on normally.

Hold down ESC, tap power very quickly.
System resets and stays off.

Hold down ESC and power for several seconds.
System resets and stays off.

Hold down ESC and refresh and tap power very quickly.
System powers on; EC console indicates it's in RO.

Hold down ESC and refresh and press power for ~100ms
System powers on; EC console indicates it's in RO.

Hold down ESC and refresh and press power for several seconds.
System powers on; EC console indicates it's in RO.

Hold down ESC and refresh and press power for at least 10 seconds.
System powers on; EC console indicates it's in RO.

Change-Id: Idf9619da54ab299b0c65e6d68abb5e35e2ce9c79
2012-04-04 15:12:27 -07:00
Randall Spangler
206476570d Only check for recovery key if reset was triggered by reset pin
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

1) Hold down refresh key and type 'reboot' from EC console.  Console
should not show "[KB recovery key pressed at init!]"

2) Press power+esc+refresh.  Console SHOULD show the message.

3) Press power+esc.  Console should NOT show the message.

Change-Id: I642a7667b81c8d90c9490b23ce0f3519364427e4
2012-04-04 12:16:14 -07:00
Gerrit
422f8ea6ba Merge "Add %T format code to print current timestamp." 2012-04-03 13:58:05 -07:00
Randall Spangler
95462ad4fe Add %T format code to print current timestamp.
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:8724
TEST=if timestamps show up in the debug output, it works

Change-Id: I5264a3a40a07a824cc15b39a7bd81f2db02a3c13
2012-04-03 11:35:47 -07:00
Vincent Palatin
1652892d82 lm4f: fix watchdog trace
After commit 84a286b1, the watchdog handler was no longer properly
connected to the interrupt vector.

Also add a couple of flushes to get all the traces.

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

BUG=chrome-os-partner:8721
TEST=type "waitms 5000" in the EC console to trigger the watchdog and
check we get the right serial trace.

Change-Id: I5a4dcdbc9000e7caeb5361d196c1f737a477c353
2012-04-03 16:43:13 +00:00