Source buffer was not being incremented properly, so the destination
buffer containing message payload was always msg[0].
BUG=none
TEST=tested on daisy (now keyboard protocol actually shows keys...)
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Change-Id: If5a417291c9bff36bbeb2a87153de80300045257
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>
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
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
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
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
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
More cleanup to come...
BUG=chrome-os-partner:7839
TEST=manual
Lights should blink in various ways, depending on the CPU state.
Also try the konami code on the keyboard.
Change-Id: I90be9aabb611278ed509493fbab4d5faff74e24c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
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
The commands in ectool.c look like this:
int cmd_foo(int argc, char *argv[]) { ... }
but unlike normal C convention, argv[0] is NOT the command. This change
makes argv[0] be the command name, so it's just like main().
BUG=chrome-os-partner:8748
TEST=manual
Run ectool as usual. You should see no difference in behavior.
Change-Id: Ia92784d46a287ab08f279f6255487817b620f200
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
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
Adding trickle charging mode to precharge batteries with
voltage lower than minimal design value. This CL adds
control to charger voltage to track battery input current
change.
To prevent battery from deeply discharging, this CL preserves
3% of the design capacity.
Minor bug fixes include error state check and charger control
logic.
Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:8660,8661
TEST=manual
Plug AC power, the power adapter led should be
'yellow'. On the EC serial console, type 'battery'
and 'charger' commands.
Battery input current should staid close to its
desired current.
A deeply discharged battery (5.5V) should be revived to
a healthy state after 30 minutes ~ 4 hours.
Change-Id: Ibaa2396c6b751639d98db32f5919b1e8ec700e40
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
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
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>
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
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
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
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
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
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
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
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
Signed-off-by: Randall Spangler <rspangler@chromium.org>
BUG=none
TEST=power system on; should still boot
Change-Id: I2e6c1f1cb4ffabf37d3113faca900da17c1353e9
(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>
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>
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>
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
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
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>