Commit Graph

221 Commits

Author SHA1 Message Date
David Hendricks
e56ba2e689 Update message protocol length byte to include postamble
This simply changes the constant '4' to MSG_PROTO_BYTES, which
includes the postamble. This helps reduce magic constant values
used in processing a packet.

BUG=chrome-os-partner:8975
TEST=tested on daisy (with kernel mkbp driver change)

Signed-off-by: David Hendricks <dhendrix@chromium.org>
Change-Id: Id4634076ad63f45783354179dfebea4fd450fc1e
2012-04-23 14:05:41 -07:00
David Hendricks
66fa2685f0 fix array indexing bug in message_process_cmd
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
2012-04-23 11:53:57 -07:00
Louis Yung-Chieh Lo
913473db71 Keyboard hook up for SYSJUMP and INIT.
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
2012-04-23 17:57:41 +08:00
Randall Spangler
9f552ff5aa Implement 64-bit integer printing in uart_printf()
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7490
TEST=timerinfo; numbers should look reasonable

Change-Id: I698be99c87bf311013427ac0ed9e93e5687f40c0
2012-04-20 14:01:11 -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
Gerrit
ff8926b5e3 Merge "Added HOOK_INIT for driver module inits" 2012-04-19 14:22:36 -07:00
Gerrit
92ded9777c Merge "Tweaks to lightbar code, detect konami sequence" 2012-04-19 14:03:42 -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
Bill Richardson
49de2279d1 Tweaks to lightbar code, detect konami sequence
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>
2012-04-19 12:44:43 -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
61ea623120 Merge "Add chipinfo command" 2012-04-19 07:25:18 -07:00
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
Rong Chang
23b8885a02 Trickle charging state and minor bugs fix
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
2012-04-19 01:16:01 +08: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
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
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
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
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
bf0df6e33c Merge "Add preliminary lightbar functionality." 2012-04-12 16:06:57 -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
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
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
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
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
Randall Spangler
7209e7c2d0 Clip charging current to valid range
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

Plug in a fully-discharged system.  Run 'charger' and 'battery'
commands to see that it's requesting a really small current.  See that
we're now feeding it a larger current.

Change-Id: I4312e2976b4f39d093deb73f665f8fbaba72d7c8
2012-04-09 14:47:29 -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
32012be3c0 Export more battery information in LPC map
This data is used to populate the _BIF/_BIX packages in ACPI
but it currently needs an EC command to retrieve that isn't
easy to query in ACPI since it isn't using standard EC RAM.

1) Export these additional fields in init() state:
- Design Capacity of Full
- Design Voltage
- Last Full Charge Capacity
- Cycle Count
- Manufacturer String
- Model String
- Serial Number String

2) Fix an issue where battery current was not reported when
the battery was charging.

3) Remove the command interface so there is no duplication.

BUG=chrome-os-partner:7734
TEST=using (not yet published) coreboot to read battery status
via ACPI and verify that battery removal/insertion events
are properly handled.

Change-Id: If337aad3255e5b1a0f85168838f1dd86a32bbeb3
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
Louis Yung-Chieh Lo
0eb9447051 Fix the build error on adv board.
BUG=none
TEST=successfully BOARD=adv make.

Change-Id: I75e0f1e0487f52411c0c50b804e8997065f4e06c
2012-04-06 10:19:10 +08:00
Gerrit
8ea8bbbfd5 Merge "Increase fan speed control to 5 steps." 2012-04-05 17:39:41 -07:00
Vic Yang
94ef5f3ab3 Increase fan speed control to 5 steps.
Factor out fan speed control for easier adjusting fan speed stepping.
Also increase number of fan speed steps from 2 to 5.

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

BUG=chrome-os-partner:8466
TEST=Manual test.

Change-Id: I0ff601c0a4f2ed2a4867bdc6e550eb2827404754
2012-04-05 11:30:16 +08:00
Gerrit
732d256dd9 Merge "First "ectool lightbar" command." 2012-04-04 17:46:50 -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
Bill Richardson
17fe1ce017 First "ectool lightbar" command.
BUG=chrome-os-partner:8728
TEST=manual

I don't have a system that has both an EC and a lightsaber, so I can't be
certain this works, but I *think* it will.

I do have a Link proto 0.5. With that, you can say

  ectool lightbar test

and the EC console says it's poking at the lightbar, but of course there's
nothing there. If there was, it *should* flash in pretty colors. I have a
lightsaber attached to a BDS, and from the EC console running "lightsaber
test" does make it blink.

Change-Id: Ib6021ad8e53959de52b12efda376254071e5fb4b
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-04-04 13:14:04 -07:00
Vic Yang
afe7cda377 Revert "Add back LPC temperature read command as workaround."
This reverts commit dfe22b2b1e.
We seem to have solved I2C block issue. Reverting the workaround LPC
command and ectool command.

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

BUG=chrome-os-partner:8239
TEST=Compilation succeed. Manually tested temperature polling still
works.

Change-Id: I0acb567a138282479c7cc07cbfa723c439d04cd7
2012-04-05 00:06:49 +08:00
Gerrit
8ee84c5db5 Merge "lightbar: add reset GPIO" 2012-04-03 22:37:03 -07:00
Gerrit
84b4dc972d Merge "Remove write protect -> recovery signal hack" 2012-04-03 18:26:01 -07:00
Bill Richardson
e881236a72 lightbar: add reset GPIO
De-assert the lightbar reset GPIO to be able to access its registers.

According to the HW guys, it will consume less power in standby than in
reset due the pull-up on the reset line.

Signed-off-by: Bill Richardson <wfrichar@chromium.org>

BUG=None
TEST=manual

On Link proto-1, type "lightbar test" in the EC console and see it blink.

On BDS, just build it. Nothing actually changes for BDS.

Change-Id: I9ec612c80f48d41ccf779f0962fc047966d4b7ba
2012-04-03 17:57:05 -07:00
Gerrit
e215358e8f Merge "Don't wait for CPU_CORE and VGFX_CORE good before asserting PWROK" 2012-04-03 16:19:26 -07:00
Randall Spangler
cb214ee8d8 Remove write protect -> recovery signal hack
Servo2 can set the write protect signal

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

Then from EC console:
  gpioget WRITE_PROTECTn
  0  WRITE_PROTECTn

From chroot:
  dut-control fw_wp_en:on
  dut-control mfg_mode:off

Then from EC console:
  gpioget WRITE_PROTECTn
  1* WRITE_PROTECTn

Change-Id: I9976cd6f114c8dae75434adf99d9409107b6ada0
2012-04-03 15:58:11 -07:00
Randall Spangler
3d2c4f758f Don't wait for CPU_CORE and VGFX_CORE good before asserting PWROK
In addition, it's not necessary for VGFX_CORE to be enabled for the
system to be in S0; just CPU_CORE is sufficient.

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

BUG=chrome-os-partner:8725
TEST=boot system via power button; should boot normally

Change-Id: Iea32837b698845355f7fa6bd2eaca9fd95f6726b
2012-04-03 15:24:22 -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
Gerrit
d1f2890982 Merge "Preserve reset cause when jumping between EC images" 2012-04-03 10:03:40 -07:00
Randall Spangler
ed33516e2e Preserve reset cause when jumping between EC images
BUG=chrome-os-partner:8718
TEST=manual

1) Use 'reboot' command from console to boot image.  Should end up in
image A, with last reset reason soft cold.  'sysinfo' should show we
jumped to this image.

2) sysjump RO.  Should end up in RO; otherwise same as 1)

3) reboot using Power+Esc+Reload.  Should end up in image RO, with last
reset reason reset pin.  'sysinfo' should show we did not jump to this
image.

4) sysjump A.  Should end up in A with reset reason reset pin.
'sysinfo' should show we jumped here.

Change-Id: I2dd5595eab4ba2c91bfe8b2b2e9677d7732aca63
Signed-off-by: Randall Spangler <rspangler@chromium.org>
2012-04-03 09:26:25 -07:00