Commit Graph

150 Commits

Author SHA1 Message Date
Randall Spangler
e68844824b Clean up chip/board configs for LM4
Board-specific features like lightbar should be config'd at the board
level, not at the chip level.

BUG=none
TEST=build link, bds, daisy

Change-Id: If1df2ca0422f7b8bdc172d0df7bd9f6a1af6a9d2
Signed-off-by: Randall Spangler <rspangler@chromium.org>
2012-03-16 14:02:59 -07:00
Randall Spangler
a9f4794edb Add support for 1-wire protocol and power adapter LEDs
BUG=chrome-os-partner:7498
TEST=powerled {off, red, yellow, green}

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

Change-Id: I48beaad94d75c0ec30a969ea4b0e35f54e052085
2012-03-16 11:03:13 -07:00
Vincent Palatin
e456584ce1 Fix test build
Allow to build without the power button task.

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

BUG=None
TEST=make qemu-tests

Change-Id: Ibc757a6641f195f0d10e6a673792b996694f8cec
2012-03-15 21:25:48 +00:00
Randall Spangler
c72f66c050 Add wake signal to PCH
This works similar to SCI/SMI events, but triggers a separate
level-sensitive signal to the PCH instead.

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

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

From EC console:
gpioget PCH_WAKEn --> should be 1
hostevent wake 0x1
close lid switch (with magnet)
hostevent -> should show wake mask 0x1, raw events 0x1
gpioget PCH_WAKEn --> should be 0
hostevent clear 0x1
hostevent -> should show raw events 0
gpioget PCH_WAKEn --> should be 1

Change-Id: I29832c1dc30239a98987578f07dfeb25791dde11
2012-03-15 12:42:11 -07:00
Gerrit
1a3becdbc2 Merge "Add comxtest debug command" 2012-03-14 09:17:41 -07:00
Randall Spangler
1c6709a332 Add comxtest debug command
Remove dummy boot-time output to UART1; no longer needed now that
there's a debug command to do the same thing.

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

BUG=none
TEST=manual
comxtest - prints default message to x86 UART
comxtext ccc123 - prints 'ccc123' to x86 UART

Change-Id: I37d37aeca06bf71b106f5ad3473a79780fd089a9
2012-03-13 16:52:53 -07:00
Randall Spangler
3eafbbe360 Remove unused temp_sensor.c file
Not compiled into any target; new version of temp_sensor.c is in common/

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

BUG=none
TEST=build link and bds

Change-Id: I00232a7cd8a8a9ee6353c5f04c86fcacc83cbd3e
2012-03-13 13:05:59 -07:00
Randall Spangler
eec896d6d8 Watch LPC0RESET line and print changes
For debugging PCH reset.

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

BUG=chrome-os-partner:8397
TEST=power system on, then use x86reset to reset it.  Should see line state changes printed.

Change-Id: Ief2f09bd0986339812183d0b32dc0208437d1103
2012-03-13 12:53:52 -07:00
Randall Spangler
186deea4c4 Use precision internal osciallator for UART and ADC
This simplifies upcoming transitions to/from sleep (with PLL shutdown).

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

BUG=none
TEST=manual - make sure 'adc' command and uarts still work

Change-Id: I070ca2d96ba4fef6fef6519896e7e9a181866efc
2012-03-12 17:59:18 -07:00
Randall Spangler
b3798eaacd GPIO changes for link proto1
Note that this moves the charger to a different I2C port.  If you're
working on battery charging, you'll need to hack board.h in your local
repo to move it back.

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

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

Change-Id: Id94ee2ce1ef6c973c1786037e07d0c64a89a9940
2012-03-12 17:57:25 -07:00
Randall Spangler
9789c3b8fc Fan console commands should enable the fan
And faninfo now checks if the fan is powered.

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

BUG=none
TEST=manual

1) faninfo --> fan is initially disabled and powered off
3) gpioset enable_vs 1 --> fan is now powered on, but still disabled
2) fanset 8000 --> fan is now enabled, and you should hear it

Change-Id: I97f35a20022cabd4520522f2d18ecb7603faabd1
2012-03-08 10:32:36 -08:00
Randall Spangler
6500cb9481 Update LPC mapped switch states with write protect and recovery states
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

Boot system with lid open.  'ectool switches' should show lid open.

Use 'dut-control goog_rec_mode:on'.  'ectool switches should show
dedicated recovery signal on.'

Use 'dut-control goog_rec_mode:off'.  'ectool switches should show
dedicated recovery signal off.'

Disable write protect via screw.  'ectool switches' should show WP
signal disabled.

Boot system in recovery mode (power+esc+reload).  Should show 0x09.

Change-Id: I0434427c4b5f8c07c02a8714618f7eb101b86fed
2012-03-07 13:28:12 -08:00
Randall Spangler
7e508c0d34 Clean up debug console output
Also prints the current timer value when inits are done, and when the
watchdog task first gets to run (after all higher priority tasks sleep
at least once).

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

BUG=none
TEST=none

Change-Id: I342f86ad087fd18ab064a10a5bcdd0b69ee373d0
2012-03-06 09:28:47 -08:00
Rong Chang
a81f0cd547 Add I2C transmit/receive function
Implement a generalized I2C transmit-receive function that
write-then-read blocks of raw data. Original 8-bit and 16-bit
read/write functions are refactored.

SMBus read-block protocol for ASCII string is also implemented
based on this API.

Signed-off-by: Rong Chang <rongchang@chromium.org>

BUG=chrome-os-partner:8026,8316
TEST=manual:
  Type 'lightsaber' to check 8-bit read/write.
  Type 'charger' to check 16-bit read.
  Type 'charger input 4032' to check 16-bit write.

Change-Id: I0ad3ad45b796d9ec03d8fbc1d643aa6a92d6343f
2012-03-06 12:07:22 +08:00
Randall Spangler
89a8a082b1 Update switch positions in EC mapped data
Note that this only handles lid and power button; see
crosbug.com/p/8325 for write protect.

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

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

1. Check state with lid open
localhost ~ # ectool switches
Current switches: 0x01
Lid switch:       OPEN
Power button:     UP
Write protect:    ENABLED

2. Press power button
localhost ~ # ectool switches
Current switches: 0x03
Lid switch:       OPEN
Power button:     DOWN
Write protect:    ENABLED

3. Release power button and close lid
localhost ~ # ectool switches
Current switches: 0x00
Lid switch:       CLOSED
Power button:     UP
Write protect:    ENABLED

Change-Id: I25f2fa3dfeac004dde9b10a4243ee235875f1b6e
2012-03-05 12:07:50 -08:00
Randall Spangler
0106129061 Only send power button pulse on lid-open when main chipset is off
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

1. When system is off, open lid.  Debug console should show PB PCH pwrbtn activity.
2. Wait for system to boot.
3. Quickly close and open lid.  Debug console should not show pwrbtn activity.

Change-Id: Ia018ff06a31ac2a68f20021d17e47ddb06096eb8
2012-03-05 10:14:24 -08:00
Randall Spangler
05d89738ba Trigger host events for power button and lid switch
(Also define other host events)

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

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

Use magnet to trigger lid-closed and lid-open.
'hostevent' should show raw events = 0x3.
Press power button.
'hostevent' should now show raw events = 0x7.

Change-Id: I9c8367d5152d526299a7a3149250de84cc2e0557
2012-03-05 09:25:58 -08:00
Randall Spangler
2464e96469 Add SMI/SCI support
BUG=chrome-os-partner:8277
TEST=manual

On EC console:
   hostevent set 0x1e
From root shell:
   ectool eventget --> should return 0x1e
   ectool eventclear 0x02
   ectool eventget --> should return 0x1c
   ectool queryec  --> should return event 3
   ectool queryec  --> should return event 4
   ectool queryec  --> should return event 5
   ectool queryec  --> should return no event pending
   ectool eventsetsmimask 0x1200
   ectool eventsetscimask 0x0034
   ectool eventgetsmimask --> should return 0x1200
   ectool eventgetscimask --> should return 0x0034
On EC console:
   hostevent --> should show raw=0 SMI mask = 0x1200 SCI mask = 0x34

Change-Id: I33042fa80c0b148cd63209a94a184af493e25ed3
2012-03-05 09:23:51 -08:00
Gerrit
2ae113da55 Merge "Handle ghost key in matrix scanner." 2012-03-04 19:16:44 -08:00
Louis Yung-Chieh Lo
763af1f695 Handle ghost key in matrix scanner.
implement actual_key_masks[]. A ghost key exists if two columns share
more than one row (after ANDed actual_key_masks[]).

BUG=chrome-os-partner:7485
TEST=on bds. test cases:
  single press of all keys.
  ~ 1 4 5: later 2 keys should be ignored (ghost).
  h j k: all keys should work.
  u R-shift 0 P: p should be ignored (ghost).
  i R-shift ' p: P should show up.

Change-Id: I1ac105874a5327e839a5240ccbdd6304637ad404
2012-03-02 11:29:06 +08:00
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