Commit Graph

130 Commits

Author SHA1 Message Date
Vic Yang
1db93690d9 Report error when PECI temperature read fails.
We used to have flaky PECI temperature read so we ignored failure. Now
the PECI temperature read seems to work fine so we should have it report
error on failure.

Signed-off-by: Vic Yang <victoryang@chromium.org>

BUG=chrome-os-partner:7493
TEST=When powered off, 'temps' shows error on PECI temperature reading.

Change-Id: I161a8f84f66ba06959c21838ee364b2f8d8b4945
2012-03-01 16:19:54 -08:00
Randall Spangler
9a60f37c8d Refactor LPC status / result codes
This is necessary to support SCI/SMI events.

Note that this breaks compatibility with previous ectool builds - and
probably also breaks flashrom support.

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

BUG=chrome-os-partner:8253
TEST='ectool hello' and 'ectool flashinfo' still work
and 'ectool usbchargemode 3 1' fails with error 2

Change-Id: If39e5b6e7cdcec1b5ec765594e8492925b430b10
2012-03-01 15:22:14 -08:00
Vic Yang
5cd0f292e9 Console command for thermal engine fan control.
Add console command 'autofan' to turn on automatic fan speed control.
Also modify 'fanset' to disable automatic control before setting fan
speed.

Signed-off-by: Vic Yang <victoryang@chromium.org>

BUG=chrome-os-partner:8250
TEST=Manual test

Change-Id: I2db85ce2e754bba21567b2c92e4476049d517627
2012-02-29 16:26:26 -08:00
Vincent Palatin
9ecf232dbd stm32l: fix new line output on the UART
On the STM32L UART without a FIFO, the Transmit Register might need
some time before pushing its content to the shift register.

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

BUG=None
TEST=on ADV board, verify we are no longer missing most of the carriage
return on console.

Change-Id: Ic638dc452d6e30a5f127710fc964143d477fa1d6
2012-02-29 21:28:27 +00:00
Gerrit
2a469c61cf Merge "Make all warnings into errors." 2012-02-28 10:08:56 -08:00
Bill Richardson
ae8dd20d77 Make all warnings into errors.
Also fix a couple places where that makes it fail.

BUG=none
TEST=none

Change-Id: I3b434b4bfa547a579193aac67c1a9d440a2c4e51
2012-02-27 15:54:00 -08:00
Vic Yang
44140b3c57 EC_LPC_COMMAND_PWM_GET_FAN_RPM return target RPM
Actual RPM is now read from LPC mapped space. Modify this command to
return target RPM so we can verify EC receives target RPM.

Signed-off-by: Vic Yang <victoryang@chromium.org>

BUG=chrome-os-partner:8238
TEST=Get the same value after setting target RPM.

Change-Id: I9bcc9edd327cec1311b51fd0fcbc4a43b353daff
2012-02-27 15:11:42 -08:00
Vic Yang
f40df60a9a Write current fan speed to LPC mapped value space.
Add a task to update fan speed in LPC mapped memory once per second.
Also added read_mapped_mem16 and read_mapped_mem32.

Signed-off-by: Vic Yang <victoryang@chromium.org>

BUG=chrome-os-partner:8183
TEST="ectool pwmgetfanrpm" shows same result as "faninfo" from ec
console.

Change-Id: Ibc536acd39f836ffcad0bfa7c9c14e730220bd49
2012-02-27 13:18:32 -08:00
Randall Spangler
28b89fdf94 Disable fan PWM when +5VS is disabled
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

faninfo
  should report fan is disabled
powerbtn
  system turns on, fan turns on
faninfo
  should report fan is enabled
powerbtn
  system turns off, fan turns off
faninfo
  should report fan is disabled again

Change-Id: I1be67004edb23ccd18ad434c9340bfbecc22e7c4
2012-02-27 12:32:20 -08:00
Dave Tu
80c2f0ff66 Revert "Disable fan PWM when +5VS is disabled"
This is causing a merge conflict on https://gerrit.chromium.org/gerrit/#change,16827.

This reverts commit 3a460ea765
2012-02-27 11:41:04 -08:00
Randall Spangler
3a460ea765 Disable fan PWM when +5VS is disabled
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

faninfo
  should report fan is disabled
powerbtn
  system turns on, fan turns on
faninfo
  should report fan is enabled
powerbtn
  system turns off, fan turns off
faninfo
  should report fan is disabled again

Change-Id: I8e94c142bf18d07f83bac05287bcd503a098cee7
2012-02-27 11:09:32 -08:00
Vic Yang
c977d241b3 Use mutex to arbitrate I2C buses.
We now have a task contantly polling temperature sensors, so we need to
use mutex to arbitrate I2C buses.

Signed-off-by: Vic Yang <victoryang@chromium.org>

BUG=chrome-os-partner:7491
TEST=temps, i2cscan, and i2cread all work fine.

Change-Id: I1360afb22d98b47da3da0820c95df45c15056f82
2012-02-22 11:17:39 -08:00
Randall Spangler
12b12e5334 Add EC host commands for keyboard backlight
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:8128
TEST='ectool setkblight X && ectool getkblight' for X=1, 20, 99, 100, 0

Change-Id: I540fd2d05f4caa110cd1dc45e9b5184fc8777a06
2012-02-21 12:59:44 -08:00
Gerrit
63c9ebaac9 Merge "Set VDD3ON flag when hibernating" 2012-02-21 11:46:12 -08:00
Randall Spangler
1d50137e31 Set VDD3ON flag when hibernating
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:8125
TEST='hibernate 1000' should hibernate and wake back up

Change-Id: I3bf36171ea86a90415593bdc884c004bfff62c4c
2012-02-21 11:03:26 -08:00
Vincent Palatin
66db728f60 use RTCK on Servo v2 JTAG
The FT4232 chip used on Servo v2 has adaptative clocking feature.
Let's try to use it to avoid signal integrity issue we observe on
Proto-0.5 JTAG.

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

BUG=None
TEST=connect to Link proto-0 and read/write all the SRAM without errors.

Change-Id: Ic2b91acc29c6d510fb6f3364dd253d3deb650949
2012-02-20 09:24:27 -08:00
Gerrit
ed9a5a5573 Merge "Add keyboard_scan for STM32" 2012-02-18 09:26:44 -08:00
Vic Yang
0fefd25c0c Temperature polling and temporal correction
A temperature polling task is added to achieve temporal correction and
also reduce the latency of reading temperature.

Factor out sensor specific part to keep code clean.

Signed-off-by: Vic Yang <victoryang@chromium.org>

BUG=chrome-os-partner:7801
TEST=On link, 'temps' shows all temperature readings.
Cover each sensor with hand and see object temperature rise.
Compilation succeeded on bds/adv/daisy/discovery.

Change-Id: I3c44c8b2e3ab2aa9ce640d3fc25e7fba56534b86
2012-02-18 13:37:53 +08:00
David Hendricks
a3d621f1b2 Add keyboard_scan for STM32
This loosely ports the LM4 keyboard_scan code to STM32

Notable differences:
- Keyboard GPIO layout is spread across multiple ports and is not
  contiguous in many places. Because of this, bitmasks are mostly
  generated on-the-fly instead of hard coded (IO is kept to a minimum)

- Longer timeout when scanning columns (100us versus 20us)

Also, some functions are stubbed out currently since they rely on
other bits being implemented:
- keyboard_state_changed()
- keyboard_has_char()
- keyboard_put_char()

BUG=none
TEST=Tested on STM32L-Discovery (monitoring keystrokes via UART)

Change-Id: I84985879589e70688b2b29b288ab17037f7668b2
2012-02-17 20:30:07 -08:00
Bill Richardson
737fbbd032 Delay enabling UART1 until after LPC bus is enabled.
BUG=none
TEST=manual

Try it on a bds with no LPC bus. It gets a BusFault without this patch.

Change-Id: If3f38df5f7bebaf4c7045a9f48fbe3ac66e8bdbf
2012-02-17 15:55:32 -08:00
Vic Yang
e75a32d2e3 Temporarily remove image RW.B due to code size.
To accomodate our growing code, image RW.B is removed so that RO and
RW.A can both have 60K space. This is just a temporary solution. Add
RW.B back when we have enough space for all three images.

Also add license header to firmware_image.lds.S so that repo does not
complain about it.

BUG=chrome-os-partner:8079
TEST=build image and run on proto-0.

Change-Id: I85b723f3e645c12fd89b189263ca44d58c4621eb
Signed-off-by: Vic Yang <victoryang@chromium.org>
2012-02-16 14:06:55 -08:00
Vincent Palatin
b221c77b62 stm32l: add support for ADV board
Compared to Daisy, it has the EC console on USART2 (pins PA2 and PA3)
and regulator enable GPIOS EN_PP1350 and EN_PP5000 are on PA9/PA10.

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

BUG=None
TEST=make BOARD=adv && make BOARD=daisy && make BOARD=discovery

Change-Id: I545f7c9b05480e58db913ea562c77a1a1cd2b11c
2012-02-16 02:52:29 +00:00
Vincent Palatin
8a37e9a0d8 stm32l: de-duplicate stubs used for all STM32L based boards
Avoid duplicating in each board file, the stub functions replacing not
implemented drivers on the STM32L platform.

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

BUG=None
TEST=make BOARD=daisy && make BOARD=discovery

Change-Id: I25cd949c31e53a90c39f623617c7d52517a3d205
2012-02-16 02:52:29 +00:00
Vincent Palatin
c9cb9bd6f3 stm32l: implement gpio_set_alternate_function
Allow to set easily the SoC pins to one of their native functions.

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

BUG=None
TEST=on Discovery board, check the muxing of the USART pins is still
working and we get traces.

Change-Id: I6e83d2eea8986d814720ad4b2fef588908b99079
2012-02-16 02:52:29 +00:00
David Hendricks
05f0eb3005 Make i8042 independent of host <--> KBC bus.
This CL attempts to abstract underlying bus from i8042 code. Nearly
all i8042 logic is isolated already. This patch is intended to allow
us to use i8042 logic for processing keys and commands on boards which
do not necessarily use LPC as the host <--> KBC bus interface.

This CL does the following:
- Define KBC bus <--> host (kbc_host_bus) on a per-board basis in
  board.c.

- Add generic wrappers in place of lpc_keyboard_* in i8042 code.

- Define the behavior of generic wrappers in EC-specific keyboard
  sources. If board.c specifies LPC, then send via LPC.

TODO: This needs to be tested on real hardware...

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

BUG=None
TEST=Locally compiled for Link, BDS and Discovery.

Change-Id: I9cabd514bd44fd6b508c26994eccc3011eedbc0f
2012-02-15 18:20:28 -08:00
Gerrit
9e50c75cdb Merge "stm32l: add external interrupt support for GPIOs" 2012-02-15 16:06:36 -08:00
Gerrit
42c3bee3ea Merge "Reduce LPC command parameters to 128 bytes; add LPC memory-mapped space" 2012-02-15 16:06:35 -08:00
Vincent Palatin
9a242f6840 stm32l: add external interrupt support for GPIOs
Allow to setup edge triggered interrupts on the GPIOs.

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

BUG=None
TEST=add a adhoc handler for the USER button and check its trace.

Change-Id: I11a280c412c1d333bab4a74f869221edf59fcf8e
2012-02-15 23:17:34 +00:00
Randall Spangler
6101cebb6a Reduce LPC command parameters to 128 bytes; add LPC memory-mapped space
This will allow more efficient access to EC-provided data (temperature,
fan, battery) by the main processor.

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

BUG=chrome-os-partner:7857
TEST='ectool hello' from link main processor should still work

Change-Id: I2dc683f3441b34de9fb4debf772e386b9fdcfa82
2012-02-15 15:12:03 -08:00
Vic Yang
502613771e FPU control
Implement enable_fpu() and disable_fpu().
enable_fpu() disables interrupt and then enables FPU.
disable_fpu() disables FPU and enables interrupt.
Also added a CONFIG_FPU flag.

BUG=chrome-os-partner:7920
TEST=none

Change-Id: I2d71f396d9c7d7ac4a6a2d525f3d86f8aae87521
Signed-off-by: Vic Yang <victoryang@chromium.org>
2012-02-16 05:42:08 +08:00
Randall Spangler
5575be5b48 Refactor power button module to support lid events
This also significantly refactors the module in other ways.  Instead
of polling for changes every second, the power button task sleeps
until its next state transition or input.

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

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

1. Reboot EC with lid open.  System should NOT power on.
2. Close lid.  System should power on.
3. Open lid.  System should power on.
4. Press power button.  System should power off.

For now, EC debug messages should also indicate [PB task wait] only
when transitions are taking place; the task function should be
sleeping at other times.

Change-Id: I86ac420506cebcdf9ca62bdca342e86857d9e242
2012-02-14 15:48:23 -08:00
Randall Spangler
805c89652f Check for recovery key sequence at init
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7451
TEST=hold down no keys; KB init state should be blank
hold down reload (F3); KB init should indicate recovery key pressed
hold down F3 + ESC; same
hold down F3 + F2 + ESC; KB init should NOT indicate recovery key pressed

Change-Id: I0fbf15407b20669396f667e6499ee5a9d545a4d5
2012-02-14 10:51:24 -08:00
Bill Richardson
12cdccc00c Add 'lightsaber' command to test the blinky lights.
BUG=chrome-os-partner:7839
TEST=none, work in progress

Change-Id: I20acde8db7f250227adcd4b9dc59328362e68720
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-02-13 16:16:20 -08:00
Bill Richardson
e5b17f9047 Add 8-bit I2C read/write functions.
These provide 8-bit accesses to registers within an I2C device.

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

Testing will come when I start using them.

Change-Id: Ib53d3347253bccee93cb9c5da12db92970155d92
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-02-13 16:16:10 -08:00
Bill Richardson
616c60e707 Tiny code cleanup in i2c.c
BUG=none
TEST=none

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

Change-Id: Ibce7c92767d2a65b992a1e629057cc52c7156a20
2012-02-13 14:43:12 -08:00
Randall Spangler
6b8e8be703 Fix discovery and bds builds, which don't have temp sensor or peci
Remove id field from temp_sensor_t struct, since it's only used by the
console command (which already knows the id, because it's looping over
it).

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

BUG=none
TEST='temps'

Change-Id: I0970850073d644509cd5501d7ac4421c7373143b
2012-02-13 10:41:34 -08:00
Bill Richardson
ee7fce76b0 Must wait on I2C controller before checking status
We have to wait until the controller is no longer busy before we announce
that we're done. Just waiting for the first interrupt isn't enough, because
that's often just an error indicator and the controller still has to stop.

BUG=none
TEST=none

Change-Id: I065c049111d7de276bf8f7cd0eed39c3f5cff5f4
2012-02-10 15:59:02 -08:00
Randall Spangler
6063ad473c Add PECI module and CPU temperature monitoring
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7493
TEST='powerbtn' to boot main processor, then 'temps' and 'pecitemp'

Change-Id: Id57526ebb37c8aecb05ecebccc2824f462b9de1a
2012-02-10 14:09:42 -08:00
Louis Yung-Chieh Lo
186c81dcac Send scan code to host when power button is pressed/released.
But only if the system is in S0.

Approved at internal gerrit: 11595.

BUG=none
TEST=tested on bds.
2012-02-10 12:11:42 +08:00
Vincent Palatin
4467fc3541 stm32l: use USART1 as console
The Daisy board will have the EC UART on the debug connector wired to
USART1 (PA9/PA10 pins)

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

BUG=None
TEST=Run Discovery board with mini-servo attached to PA9/PA10 and see
the traces.

Change-Id: I97c59ba388fddb150ff6c76ec3317deedb567546
2012-02-08 17:03:30 -08:00
chrome-bot
16df421edc Merge "Initial bq24725 charger driver import" 2012-02-07 16:15:16 -08:00
Randall Spangler
7423b63ea3 More complete x86 power module
Supports turning system on and off via power button.

Also added 'powerbtn' command, which sends a power button press of the
specified duration, and deprecated the 'x86power s0' command, since
pressing the power button is a more correct way of powering on/off the
system.

Note that current coreboot doesn't seem to boot reliably; when it
fails, the x86 asks for S5 and then S0 a second later.  It boots about
every 3rd try.  No indication this is due to the EC; the EC just was
ignoring these requests until this CL.

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

BUG=chrome-os-partner:7851
TEST=reboot, 'powerbtn', system should power on
'powerbtn', system should power off
'powerbtn 5000', system should power off regardless of previous state
press power button, system should power on
press power button again, system should power off
hold power button 8 sec, system should power off regardless of previous state

Change-Id: I89f419553289b20c78a57bc8cb1699932b095aa1
2012-02-07 15:01:50 -08:00
Rong Chang
812b3f8cb6 Initial bq24725 charger driver import
Battery charging state machine contains many file changes.
This is the 1st part of the break down. Refactor original
test code into board dummy driver. Normalize charger API.
And import link's charger IC driver.

Signed-off-by: Rong Chang <rongchang@google.com>
BUG=chrome-os-partner:7855
TEST=build without warning and error
  BOARD=bds make
  BOARD=link make
  BOARD=discovery make

Change-Id: I34b6e9862a45331378916bc77653d4adb22ca548
2012-02-07 12:54:28 -08:00
Randall Spangler
36d39dbb0d Merge "Fix power button being held down for 8 sec" 2012-02-07 09:36:28 -08:00
Randall Spangler
7ce07a7835 Fix power button being held down for 8 sec
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7932
TEST=hold down power button >8 sec; PCH_PWRBTNn should stay low

Change-Id: If3168984982343735f0c31fb5951374808eb1caf
2012-02-07 09:32:54 -08:00
Vic Yang
730f099c83 Handle up/down arrow keys for UART console.
Record commands used previously and use up/down arrow key to navigate in
the command history.
Also removed the command '.' of repeating last command as we can use up
arrow key now.

Also changed the behaviour of uart_write_char() to be blocking on
transmit FIFO full, so that we do not lose echoed character and do not
need to flush.

BUG=chrome-os-partner:7815
TEST=Type 'help' and enter. Then type 'aaaa' and up arrow key, should
show 'help', and pressing enter prints help.
Type 'hellp' and enter. Then type 'aaaaaa' and up arrow key, should show
'hellp'. Should be able to use left/right arrow key and backspace to
correct it to 'help', and pressing enter prints help.
Type 'help' and enter. Then type 'aaa', up arrow key, and down arrow
key. Should show 'aaa'.

Change-Id: I65c615d61bf63acb31bea329aa91a3202d4db0ad
2012-02-07 10:23:59 +08:00
Randall Spangler
300e7edb87 Add UART1 receive support (UART to x86 console)
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7488
TEST=type things into the x86 console UART; should appear on the u-boot prompt

Change-Id: I75fd225842c03d11d79280fb7453ad37695279e3
2012-02-06 14:53:49 -08:00
Vic Yang
000a6d5742 Refactor temperature sensor code and add support of Link I2C temp sensor.
Refactor board/chip-specific code into corresponding directories.
Add support of the four I2C temp sensor in Link.
Use table lookup to handle different types of temperature sensors.

BUG=chrome-os-partner:7527
TEST=Correctly read EC internal temperature on bds.
Compile for link succeeded.

Change-Id: I694cfa54e1545798d877fafdf18c5585ab5f03e2
2012-02-04 14:37:04 +08:00
chrome-bot
249467b9f2 Merge "Use udelay for more stable manual IRQ firing." 2012-02-03 00:45:52 -08:00
Louis Yung-Chieh Lo
088b79f285 Use udelay for more stable manual IRQ firing.
Original code tests SND bit, but it is not reliable to indicate the
SERIRQ frame has been sent out because the EC always clears it
immediately. Unfortunately the SIRQRIS is always asserted in
continuous mode so that we cannot rely on it.

So, the udelay(4us) method is the best way we can use now.

Note: the quiet mode? Forget it. My EC never sends out further frames
      after the first has been sent.

BUG=none
TEST=on bds board.

Change-Id: Ica79b463f3dbe7435fe75f3db4cef00ad7ad5ec0
2012-02-03 12:38:42 +08:00