Commit Graph

163 Commits

Author SHA1 Message Date
Simon Glass
ea845714fd Add gpio_get_name() to return the name of a signal
Add this to the GPIO API. It seems that the implementation is copied
in LM4 and STM32 so I have reluctantly done the same with this new
function.

BUG=chrome-os-partner:9424
TEST=build and boot on Daisy

Change-Id: Ifddc52e69b2b33af2645384c0171dd264e588fcd
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-05-03 22:05:57 -07:00
Gerrit
5ba4576cf3 Merge "timer: Add timestamp_expired() to check for expiry" 2012-05-03 12:05:25 -07:00
Simon Glass
4935a885ee timer: Add timestamp_expired() to check for expiry
Rather than open code this each time, create a function for this. The
wrap-around condition may not be needed, if the timer starts at zero,
since we have 64 bits to play with.

BUG=chrome-os-partner:9424
TEST=build and boot on daisy

Change-Id: I84ae651212769b5927c452bc03f31f60a25a829e
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-05-02 19:43:39 -07:00
Vadim Bendebury
0467763f5a Enhance LPC EC REBOOT reset command to allow to request recovery
When the host reboots the EC it should be able to request the EC to
force recovery mode after reset. This is achieved by extending the
REBOOT EC command with a bitmask byte, with bit 0 dedicated to
recovery request.

So, when BIOS on the way up determines that recovery is requested, but
the EC is not running from the RO space, the BIOS would reset the EC
forcing it to run from RO and to request recovery mode through the LPC
bitmask. Then BIOS will restart itself ensuring that the system comes
up in consistent state.

Some refactoring was also done to make the code a bit more compact.

BUG=chrome-os-partner:9040
TEST=manual
  . tested along with coreboot changes (test described in the coerboot CL).

Change-Id: I29801b6aec80da0901ba0e8db8e92e615cc778bd
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
2012-04-30 15:36:41 -07:00
Bill Richardson
31190cf215 Create host-side lightbar bikeshedding tool.
BUG=chrome-os-partner:7839
TEST=manual

  cd src/platform/ec
  make BOARD=link

  copy ./build/link/util/lbplay to the host and run it as root.

Change-Id: I6a4a842b7500751185c8f4c2744f4389226bae9b
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-04-26 13:57:19 -07:00
Gerrit
9a59d98b3d Merge "Issue warning on fan stall." 2012-04-26 10:16:24 -07:00
Vic Yang
7710ed563a Issue warning on fan stall.
When PWM module detects fan stall, issue SMI warning and print warning
message to console.

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

BUG=chrome-os-partner:7497
TEST=Disconnect fan and power up. See warning message.

Change-Id: I4d96595f7f3cdfab5df333afc35206304bacab9d
2012-04-26 13:45:43 +08:00
Bill Richardson
e763812a3a Give ectool the same lightbar commands as the console.
BUG=chrome-os-partner:7839
TEST=manual

Try "lightbar help" on the EC console and "ectool lightbar help" on the
host. You should see the same commands and behavior.

Change-Id: I6e879e8bb892ef5ada7ef85a97fdf243149f4cb6
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-04-25 18:42:36 -07:00
Gerrit
fe16e4b3a9 Merge "Watchdog fixes" 2012-04-25 16:56:04 -07:00
David Hendricks
ef9424dd10 simplified message protocol
This simplifies the messaging protocol. Messages will now only have
the raw content plus a checksum byte at the end. We will worry about
needs of the transport layer (e.g. preamble/postamble bytes) on the
host driver side, and will not support variable-length commands for
now.

There is also a protocol version command, which is now command number
0x00, which returns a 4-byte protocol version followed by a 1-byte
checksum.

BUG=none
TEST=tested on daisy using mkbp kernel driver
Signed-off-by: David Hendricks <dhendrix@chromium.org>

Change-Id: I8fcc693cd50bc2b515164ea7a2a941cdd8333e73
2012-04-25 14:51:33 -07:00
Randall Spangler
1aa57e140e Watchdog fixes
1) When frequency changes, reload the watchdog timer right away, or it
may expire before the next reload.  (Only matters when re-enabling the
PLL.)

2) Split out the timer/task debug output used by the watchdog into
their own routines, instead of assuming it's safe to call the command
handlers.  Also make the flushes in those print routines safe to call
from interrupt level.

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

BUG=none
TEST=waitms 1500; should print task dump again

Change-Id: I07e0ed24a526ae499566dab0bbeb0f5755cd5be6
2012-04-25 14:49:49 -07:00
David Hendricks
83082746a9 Separate message protocol command types and reserve slots accordingly
This organizes the commands in the messaging protocol so that we have
a more clear distinction between commands which are intended to to
control or get status of the EC itself and those which are intended
to query information about peripherals, such as the obtaining the
keyboard state.

Note: This will require the mkbp code to be updated.

BUG=none
TEST=compile tested for now

Change-Id: I2d5c58fc794563d402da24e19fee146df817472a
Signed-off-by: David Hendricks <dhendrix@chromium.org>
2012-04-25 11:31:42 -07:00
Bill Richardson
b4ac7cf558 Clean up lightbar msg command parsing, add some help.
BUG=none
TEST=none

Change-Id: I5767bd45bd66793606014b3ce8020d0eb2e17090
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-04-25 09:30:20 -07:00
Randall Spangler
470916fb0f Use console output instead of uart output for console commands
This completes console output cleanup.  The remaining calls to
uart_puts() and uart_printf() actually need to be that way.

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

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

Change-Id: Ib1d6d370d30429017b3d11994894fece75fab6ea
2012-04-24 18:34:46 -07:00
Randall Spangler
135f14bf49 Refactor async console output
This adds a 'ch' command which prints/sets which channels are active

This handles all the async output; the remaining debug commands will
be refactored to use ccprintf() / ccputs() in a followup CL.

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

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

ch --> all channels active
ch 0x100 -> just port80 active
powerbtn -> system boots; only port 80 codes shown on console

Change-Id: I9efc43acec919b62b78c2c82c61946d32380adfe
2012-04-24 17:46:54 -07:00
Randall Spangler
0d19c59aba Implement task profiling
Also tracks the distribution of IRQs, so we can see what's triggering
interrupts.

Task profiling is optional, enabled via CONFIG_TASK_PROFILING.

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

BUG=chrome-os-partner:7464
TEST=taskinfo

Change-Id: I266f2b49bff9648cda446210d5a302b460fec244
2012-04-24 12:54:29 -07:00
Randall Spangler
7ecb8358b9 Disable PLL at end of init
This saves power.

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

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

Get a proto1 system modified with INA current sensor

1) From chroot:
  dut-control i2c_mux_en:on i2c_mux:rem
  dut-control pp3300_alw_mv pp3300_alw_ma

2) From EC console:
pll
(this should turn the PLL back on; it'll report clock frequency ~66MHz)

3) From chroot:
  dut-control i2c_mux_en:on i2c_mux:rem
  dut-control pp3300_alw_mv pp3300_alw_ma
Current (ma) should be bigger than in step 1

Change-Id: I806953684c57fd60bf481acb01dddffe2f2ad0ed
2012-04-24 09:59:31 -07:00
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
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
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
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
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
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
bf0df6e33c Merge "Add preliminary lightbar functionality." 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
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
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
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
Gerrit
d79abe08d1 Merge "Support dynamically changing the system clock" 2012-04-09 11:13:47 -07: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
Duncan Laurie
5d003a3489 Make lpc_commands.h usable in coreboot for both C and ACPI
- The max IO buffer size in ACPI is 255/0xFF bytes.
- The ACPI ASL code in coreboot is pre-processed to handle
constant #defines, but the IASL compiler cannot handle any
actual C code so add an __ACPI__ guard.

BUG=chrome-os-partner:7734
TEST=include this header in coreboot and compile successfully

Change-Id: Ife61935cec1a39f072625c2788f70487c3559060
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
2012-04-09 10:28:03 -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
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
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