Commit Graph

440 Commits

Author SHA1 Message Date
Randall Spangler
55dfbb89cc Add chipinfo command
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=chipinfo

Change-Id: Ie3414bf92c9dd35aaa4e54028bd525e860028c33
2012-04-18 18:55:27 -07:00
Louis Yung-Chieh Lo
a77d59b19a Fixe the bug in keyboard state restore.
For legacy issue, the keyboard controller defaults to turn on XLATE
(translate) bit (which means EC generates scan codeset 1 althought
it internally supports codeset 2). In normal case, the BIOS/OS would clear
the XLATE bit to ask EC to generate codeset 2.

However, when EC jumps happens, the internal keyboard state doesn't know
this and always reset XLATE as on. This makes the EC generate garbage to OS.

So, this patch fixes would clear the XLATE if the EC reboot is a warmboot
based on the assumption that moderm OSes clear the XLATE bit.

BUG=chrome-os-partner:9102
TEST=on link
% ectool reboot_ec A  (from r438 to r438)
  Expect keyboard is hang (r438 is still buggy)
% chromeos-firmwareupdater --mode=recovery
  Expect fail at gec_need_2nd_pass()
% ectool reboot_ec RO
  Keyboard is still working!  Bug fixed!
% ectool reboot_ec RO
  Again. Still working.

Change-Id: If47bd8d7bbbb03b810d3b464ba3d92f8ff548237
2012-04-18 13:57:11 +08:00
Louis Yung-Chieh Lo
755a767c2b Fixed the bug that reboot_ec resets the keyboard state to disabled.
The reboot_ec command could warm boot the EC while the host is still
running. However, this resets the internal state so that the keyboard
module is disabled on the EC side.

Check the reset cause during the keyboard init code. If it is wrm boot,
enable the keyboard (assume the host is on).

BUG=chrome-os-partner:9102
TEST=on link 1.0
% ectool version
Firmware copy: RO
% ectool reboot_ec RO
the keyboard keeps working.

Change-Id: I0009c561e2cd88789e50f9129b494538e50ee00e
2012-04-18 10:45:28 +08:00
David Hendricks
7a33ee53a6 daisy: Plumb in I2C driver
This adds I2C2 support for Daisy:
- Initializes I2C2 GPIO lines
- Adds CONFIG_I2C so main() will call init function
- Adds work task for I2C2

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

Change-Id: I147e3781b8bcac87ff248fb45c9978b614a24b89
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Hendricks <dhendrix@chromium.org>
2012-04-17 13:44:03 -07:00
David Hendricks
2559041f39 daisy v1.02: setup GPIO signal to audio codec
Set up signal to audio codec as open-drain output. This should
be benign on older revisions of Daisy.

The signal CODEC_INT is driven low whenever a keypress has been
processed. For Daisy, a delay of about ~1ms from the time a key
is pressed until the time the codec is signaled is okay. This
gives us time to scan the columns to see if a key was actually
pressed so that we don't cause spurious codec interrupts.

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

BUG=None
TEST=Tested on Daisy using oscilloscope

Change-Id: Id3564f4aacbf7294b7151b082075f3c3ec8b1eb2
2012-04-17 12:46:29 -07:00
Gerrit
48aba27dd5 Merge "stm32l: eliminate GPIO initialization done in keyboard code" 2012-04-17 11:36:35 -07:00
Gerrit
92efde83c4 Merge "daisy: Set up EC_INT as open-drain output" 2012-04-17 11:36:34 -07:00
Gerrit
e70d6886cd Merge "stm32l: Update gpio_pre_init to operate with explicit types" 2012-04-17 11:36:34 -07:00
Louis Yung-Chieh Lo
12753d10f2 Support keyboard typematic.
Mainly add a typematic task that counts down the delay. Set the initial delay
in the keyboard_state_changed() when key pressed and clean it when released.

BUS=chrome-os-partner:8463
TEST=press on a particular key and screen shows that key is repeating.

Change-Id: Ic8432f8b38b514476588e0b7ad8fdc8a0b0c0b51
2012-04-17 17:09:46 +08:00
Randall Spangler
f3301b4944 Fix getting version string for other images
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

sysjump ro
version
sysjump a
version
sysjump b
version

All should return versions for RO, RW-A, RW-B.

Change-Id: Ie189d2d777a4743460e2edec65750e563bc69354
2012-04-13 15:59:18 -07:00
Chris Sosa
bf2fad0a25 Merge "Remove DDR shunt signal, which is no longer present on proto1" 2012-04-13 15:58:12 -07:00
Chris Sosa
4fd27c6919 Merge "add more explicit GPIO types" 2012-04-13 15:56:53 -07: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
432b128c06 daisy: Set up EC_INT as open-drain output
This sets the EC_INT GPIO as an open-drain output and initializes
it in high-impedence state.

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

BUG=none
TEST=tested on daisy (applied keyboard patch and tested that AP gets
interrupted and requests keyboard state upon keypress)

Change-Id: Id4b043dd0066db823cd1502bd738f69bb656eada
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
28292ae663 add more explicit GPIO types
This patch adds explicit handling of open-drain outputs
and adds Hi-Z for high-impedence state (floating) outputs.

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

BUG=none
TEST=compile tested

Change-Id: I1a0c2e8366f6a82cd9cd7e83e57122944f2bdc2d
2012-04-13 14:46:33 -07:00
Randall Spangler
f6d9b19358 Remove DDR shunt signal, which is no longer present on proto1
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=power system on; should still boot

Change-Id: I2e6c1f1cb4ffabf37d3113faca900da17c1353e9
2012-04-13 14:12:45 -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
Simon Glass
9fa4246a8d Initialize SPI on start-up
Now that we have a SPI driver, we must init it when we start up.

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

Change-Id: I84b458d3ebc3fed9368dce8e06d040dbfc4e9125
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-04-13 10:24:12 -07:00
David Hendricks
826d334633 daisy: Plumb in SPI support
This adds support for setting up the SPI pins and driver, as well as the
required SPI work task.

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

Change-Id: Ie73560356fc8e4fcec0773c4692ecd6a7ba7affa
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-04-13 10:24:11 -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
Vincent Palatin
765386a623 fix task stuck on timer wake-up event
When we are in interrupt context and doing a task_set_event,
if we are interrupted by a timer interrupt firing, we might end
resetting the runnable bit added by the expiration of a timer (when
finishing the interrupted read-modify-write to tasks_ready).
So we need to have an atomic access there.

We don't need to atomic primitives (and the associated overhead) on other
tasks_ready accesses because there are always done at the highest
priority.

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

BUG=chrome-os-partner:8721
TEST=from Linux, run "ectool lightbar test" several times and see that
the keyboard task no longer ends up stuck with a timer event set and no
runnable bit.

Change-Id: Ied45ee33cb6aba4549626d35d694f1c259f2400c
2012-04-12 23:12:42 +00:00
Gerrit
bf0df6e33c Merge "Add preliminary lightbar functionality." 2012-04-12 16:06:57 -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
Gerrit
c87611ff57 Merge "stm32l: remove unnecessary inner loop from check_keys_changed()" 2012-04-12 15:47:18 -07:00
Gerrit
e469b28f08 Merge "stm32l: Tweak keyboard scan delays" 2012-04-12 15:47:17 -07:00
Gerrit
41e427f88f Merge "Don't trigger watchdog when power button is held down" 2012-04-12 15:23:27 -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
Gerrit
77c3f9c35b Merge "Add timeout for flash operations." 2012-04-12 14:24:40 -07:00
Gerrit
81327a620d Merge "daisy: Provide an interrupt function for keyboard scan" 2012-04-12 13:53:05 -07:00
Bill Richardson
d86ad99165 Add preliminary lightbar functionality.
I need to clean up the console commands and provide the same functionality
via ectool, but this is a good starting point.

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

Power up the CPU. The lights should blink.

Change-Id: Ic05a171d2b647551f1cfc7d6b2fd101088cac137
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-04-12 13:40:09 -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
8e326b6b0a Don't trigger watchdog when power button is held down
This situation occurs during USB download - the EC resets itself which
causes USB programming to generally fail.

Is this the correct fix?

BUG=none
TEST=build on daisy and discovery; run on daisy
$ cros_bundle_firmware -b daisy -w usb
See that it now succeeds

Change-Id: I293e85d08d3c488d5b6bebe3379deb949f211986
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-04-12 09:13:56 -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
Simon Glass
c7f8239afd daisy: Provide an interrupt function for keyboard scan
Provide a function which is called when keyboard scan data is ready,
and make it do the right thing.

BUG=chromium-os:28925
TEST=build on daisy and discovery; run on daisy
Signed-off-by: Simon Glass <sjg@chromium.org>

Change-Id: I0089a7ff78ba035ba6648220ae2e03a958d444d8
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
84ee7cd803 Add a message format and processing function
Whatever means is used to talk to the AP there is no justifcation for
putting message processing directly in drivers. Create a suitable
header file to define the interface, and provide a processing function
which can provide responses to incoming messages.

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

Change-Id: If09ea3e30d42d8c5f226dc4421d4895adc54f937
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-04-11 11:57:43 -07:00
Simon Glass
66052e8b11 daisy: Initialize DMA library
We want to use this for drivers, so start it up on boot.

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

Change-Id: Ie69fb9d6df75150dd3903fe37a9b72c0a663f045
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-04-11 11:01:50 -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
Gerrit
9ac6546f9c Merge "Pass include directories to C preprocessor" 2012-04-11 10:57:19 -07:00