Commit Graph

77 Commits

Author SHA1 Message Date
Randall Spangler
1fd7062b29 Tidy ADC channel definitions
We moved a while ago to a table of ADC channels, so having a
meaningless constant defined in board.h is more harmful than helpful.

BUG=none
TEST=build link, bds

Change-Id: I651a609c9ed13f879bb943c90731275407d77e50
Signed-off-by: Randall Spangler <rspangler@chromium.org>
2012-03-19 09:05:16 -07:00
Randall Spangler
9ff6f390b9 Remove code for skipping duplicate port 80 writes
The kernel no longer uses port 80 as a delay mechanism, so we don't
need to detect the no-longer-present spammy writes.

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

BUG=chrome-os-partner:7972
TEST=port80 scroll, then boot the system.  see a few repeated bytes,
but not piles of 00 and ff's.

Change-Id: Id14dc43ab4e1b15c6bab99a17c062f295a59e7e6
2012-03-19 09:05:07 -07:00
Randall Spangler
2a9f80d2d9 More cleanup of board/chip configs and initialization
More modules can be disabled individually through CONFIG_ defines.

Reordered early module pre-init and init, and added comments to
explain why things are ordered in main() the way they are.

Fixed a few assorted init-related bugs along the way, like st32m
keyboard scan double-initializing.

BUG=none
TEST=build link, bds, daisy

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

Change-Id: I04a7fa51d743adfab4be4bdddaeef68943b96dec
2012-03-19 09:04:56 -07:00
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
Gerrit
2743514996 Merge "Fix test build" 2012-03-15 20:43:56 -07:00
Vic Yang
9f8e8dc6a3 Temperature sensor grouping.
Group temperature sensors into different types so we only have to set
temperature threshold for each type instead of each sensor.

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

BUG=chrome-os-partner:8466
TEST=Fan control still works.

Change-Id: I7acc714c32f282cec490b9e02d402ab91a53becf
2012-03-16 10:40:52 +08: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
Vic Yang
d2fbdfbc67 Temp sensor report 0xfd on sensor unpowered.
Make temp sensor report 0xfd when sensor is unpowered.
Also refactor power specification of temp sensors from thermal.c to
temp_sensor.c.

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

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

Change-Id: Ib13813bdbac2f048fbc3b98fae5bbf104ebf37d7
2012-03-14 13:32:02 +08: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
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
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
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
Rong Chang
1c70e29165 Add battery charge state machine and task
This CL adds a charge state machine for SMB compliant battery pack.
Vendor specific charge constraints can be applied through function
call, defined in battery_pack.h .

BUG=chrome-os-partner:7526
TEST=Attach EC serial console
  Unplug AC adapter: state ==> "discharge"
  Plug AC adapter:   state ==> "charge"
  Battery full:      state ==> "idle"
  Unplug battery:    state ==> "error"

Change-Id: Iabff0988a6067d37c17c11b060bbb7e66505c118
2012-03-03 14:01:52 +08:00
Vic Yang
13b5c41951 Thermal Engine
The thermal engine monitors the temperature readings from all sensors.
For each sensor, five threshold temperatures can be set:
    1. Low fan speed.
    2. High fan speed.
    3. SMI warning.
    4. Shutdown CPU.
    5. Shutdown everything we can.
Each of these thresholds can be set to either a fixed value or disabled.
Currently the real implementation of SMI warning and shutting down is
left as TODO, as indicated in the comment.

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

BUG=chrome-os-partner:8250
TEST=Manually change threshold value to test all actions can be triggered.

Change-Id: If168dcff78ef2d7a3203cb227e1739a08eca961e
2012-02-28 16:51:54 -08:00
Randall Spangler
e84fc7b110 Add persistent host storage in EC EEPROM
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

from root shell on host:
  ectool pstoreinfo   --> should print PstoreSize 1024 AccessSize 4
  echo testing 1 2 3 4 > /tmp/infile
  ectool pstorewrite 8 /tmp/infile
  ectool pstoreread 8 /tmp/outfile
  diff /tmp/infile /tmp/outfile

Change-Id: I565e580307584f7def36c5e53d360c1a897d67d2
2012-02-28 13:02:17 -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
0592fe594a Only deassert RCINn in S0
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

gpioget PCH_RCINn --> should return 0
powerbtn --> should turn system on
gpioget PCH_RCINn --> should return 1

Change-Id: I6801bc2e5801ecac53a50b99cf802c00295faf0b
2012-02-27 12:29:05 -08:00
Randall Spangler
1f786bc348 x86power module is not present on bds board
On bds, always send the keyboard scan code for the power button.

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

BUG=none
TEST=none

Change-Id: I56ad8c9dd67edfd54190d64f16742896a86b9ac1
2012-02-27 12:24:44 -08:00
Dave Tu
c5b323f995 Merge "Revert "Only deassert RCINn in S0"" 2012-02-27 11:41:32 -08:00
Dave Tu
8e6d7f5fef Revert "Only deassert RCINn in S0"
This change broke the tree.

This reverts commit 1d1a38a6cc
2012-02-27 11:32:18 -08:00
Randall Spangler
4f3f3fdf3d Merge "Only deassert RCINn in S0" 2012-02-27 11:06:42 -08:00
Randall Spangler
1d1a38a6cc Only deassert RCINn in S0
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

gpioget PCH_RCINn --> should return 0
powerbtn --> should turn system on
gpioget PCH_RCINn --> should return 1

Change-Id: I8e58e2b6a48c811d5e57549bdcaea27bca964c08
2012-02-24 18:02:20 -08:00
Vincent Palatin
64e6afdefa stm32l: fix ACOK signal
The PMIC_ACOK signal is active-low.
Let's drive it correctly.

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

BUG=None
TEST=On ADV board, check that a short key press on the power button is
now able to start the board

Change-Id: Iea71939aeb532618019a9e7774721703c632976f
2012-02-23 13:28:46 -08:00
Vincent Palatin
c651715a2c stm32l: add keyboard configuration for ADV and Daisy boards
Set the keyboard GPIO interrupts and task for the Daisy and ADV boards.

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

BUG=None
TEST=make BOARD=adv && make BOARD=daisy
run EC firmware on ADV board.

Change-Id: I01c7f0112b7ab3382e04ad032a86fb0f3878b02b
2012-02-21 18:18:15 +00: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
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
Vincent Palatin
4778d823be stm32l: add a simple power sequencing for Daisy board
This should be enough to switch on the board from either the power
button or the EC console.

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

BUG=None
TEST=run Daisy firmware on Discovery board with logic analyzer attached
to GPIO pins. With an added task to simulate PMIC startup and AP
startup, check the timing chart looks good.

Change-Id: I5dfeab05d0481d121ddacb36b69a542cc1bd428c
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
Vincent Palatin
359b9eebab stm32l: fix Daisy GPIO declaration
The order of the GPIO in the header was not matching the signal list.
EC_INT is an output to trigger an interrupt on the application
processor.

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

BUG=None
TEST=make BOARD=daisy

Change-Id: Ib0eb675ad7d7e9e105b1d486c181a6df9bd5ad9b
2012-02-15 23:17:34 +00:00
Vincent Palatin
ee9279c1a8 stm32l: set pin mux for USART1
When we are not running the ROM monitor first, we must set the pins used
for USART1 (PA9/PA10) as alternate function.

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

BUG=None
TEST=Run firmware on the discovery board not from the monitor and see
the traces.

Change-Id: I32be3d5a88a3e71828d081d74503722331a649b8
2012-02-15 18:24:04 +00:00
Gerrit
c160dae1d4 Merge "stm32l: Add skeleton for Daisy board" 2012-02-14 18:25:42 -08:00
Vincent Palatin
b34c1ce954 stm32l: Add skeleton for Daisy board
Necessary files to build it and GPIO definitions.

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

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

Change-Id: I22ad8d2d859f9c884bf2e3f92db02d992ad669a6
2012-02-14 23:02:14 +00: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
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
Rong Chang
62df62ccd4 Add basic smart battery driver
This change adds a common part of smart battery driver. Following
features are not implemented, or in chip specific driver:
  Battery access control, authentication, factory mode
  Manufacturer access/data commands
  Block read/write, device name, flash data
  Chip specific features, per cell info/temp/capacity

Signed-off-by: Rong Chang <rongchang@google.com>
BUG=chrome-os-partner:7856
TEST=console command check battery staus
  [unplug power]
  > battery
  [check voltage,current,capacity,time to empty]
  [plug power]
  > charger voltage 8400
  > charger current 4250
  > battery
  [check current,time to full]
  > charger input 4032
  > battery
  [check current,time to full]
  [wait 130 seconds, charger watch dog timeout]
  > battery
  [check current]

Change-Id: Ifac17a0892f52e8f37eebc14b00e71f18360776c
Signed-off-by: Rong Chang <rongchang@chromium.org>
2012-02-10 16:12:56 -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
Randall Spangler
e42cd379de Print repeated port 80 writes, for coreboot/uboot debugging
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7972
TEST=boot main processor; look for repeated sequential port 80 writes

Change-Id: I07b247130945296ce73177a342e0b2cf5645f4fb
2012-02-09 11:00:11 -08:00
chrome-bot
898aaf1914 Merge "Add tmp006 object temperature calculation" 2012-02-08 17:59:11 -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
Vic Yang
059c633a27 Add tmp006 object temperature calculation
Implement TMP006 object temperature calculation. Also add a console
command to calculate temperature with manually entered data.

BUG=chrome-os-partner:7801
TEST=In console, "tempremote 29715 -105000 6390" gives 285.00K.

Change-Id: I0f9193fb970fdc36566399e7083e73ab58965a85
2012-02-08 14:53:17 +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
Rong Chang
57c581891d Add board configuration flags in board.h
Current makefile takes CONFIG_* flags from $(CHIP)/config.h . This
CL adds $(BOARD)/board.h and a sample charger config flag.

Signed-off-by: Rong Chang <rongchang@google.com>
BUG=chrome-os-partner:7917
TEST=build bds,link board and check warning and error messages.

Change-Id: I1f13d24da6b18c014f40f941ef7245487e5ccc81
2012-02-06 14:45:20 -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
Vincent Palatin
54f36995a4 stm32l: basic GPIO support
No interrupt support yet.

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

BUG=None
TEST=on Discovery EC console, using "gpioget" and "gpioset" commands
check we can switch the LED and read the button state.

Change-Id: I01294643d3df070a535dab5a6be02c296487fca5
2012-02-03 02:00:27 +00:00