Commit Graph

1063 Commits

Author SHA1 Message Date
Randall Spangler
2ad076f8a0 cleanup: Rename and move header files
Device-specific headers belong in driver/ or chip/.  The include/
directory should be for common interfaces.

Code should not normally need to include driver-specific headers.  If
it does, it should use the full relative path from the EC project root
(for example, drivers/charger/bq24715.h).

Change-Id: Id23db37a431e2d802a74ec601db6f69b613352ba
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173746
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-23 21:27:40 +00:00
Randall Spangler
8cf03ac056 Move source files to driver/ and power/ subdirs
The common/ subdir was getting cluttered.  Move drivers for external
components to a new driver/ tree, and move what used to be called
chipset_*.c to a new power/ directory.

This does not move/rename header files or CONFIG options.  That will
be done in subsequent steps, since moving and modifying .c files in
the same CL is harder to review.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all boards; pass unit tests

Change-Id: I67a3003dc8564783a320335cf0e9620a21982d5e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173601
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-10-23 20:07:25 +00:00
Randall Spangler
5f26987366 cleanup: Comments about PMU powerinfo module
Document some Pit-platform-specific assumptions.

No code changes.

BUG=none
BRANCH=none
TEST=build pit

Change-Id: I601ca4a57645ba45e7db01e271556a30d334f9cd
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/174056
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-22 23:18:13 +00:00
Randall Spangler
ba0b7bf32d puppy: remove temporary workaround in pmu chipset startup
This was temporary until bug 18778 was fixed - which it was, a while ago.

BUG=chrome-os-partner:23425
BRANCH=none
TEST=build puppy

Change-Id: I053867dcb1c3e74d0c09ac98a5c218bdca925317
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173799
Reviewed-by: Jeremy Thorpe <jeremyt@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-10-22 21:41:33 +00:00
Randall Spangler
99d52c8874 cleanup: FIFO comment in MKBP driver
A 16-element FIFO consumes 208 bytes of RAM, which isn't too horrible.

No code changes, just expanding on a comment.

BUG=none
BRANCH=none
TEST=build spring

Change-Id: Ibb51970b6fc72623435d21bd0b368c3e60da24da
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173922
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-10-22 17:56:20 +00:00
Randall Spangler
712177cf14 cleanup: Thermal comments
No code changes, just replacing a FIXME from the comments with a more
thorough explanation.

BUG=chrome-os-partner:20805
BRANCH=none
TEST=build falco

Change-Id: Ibd98322c2b9fd6e0447771ce5fe43e0283743c60
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173930
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-22 01:13:34 +00:00
Randall Spangler
8e13fec4b8 cleanup: Comments in extpower_falco.c
Note that adapter current limits are specific to the given battery
charger chip used in falco.  Since the file is named extpower_falco.c,
no additional fixing needed.

Comment change only; code is the same.

BUG=none
BRANCH=none
TEST=compile falco

Change-Id: I28d8b6c9335ec188c30f7c47fb2f8ecdda276bae
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173914
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-22 01:11:57 +00:00
Alec Berg
10bd1db6d7 lm4: Use low speed clock in deep sleep.
Changed the low power idle task to use the low speed clock in deep
sleep. The low power idle task is currently only enabled for Peppy,
Slippy, and Falco. This change decreases power consumption when
the AP is not running.

Note that the low speed clock is slow enough that the JTAG cannot be
used and the EC console UART cannot be used. To work around that,
this commit detects when the JTAG is in use and when the EC console
is in use, and will not use the low speed clock if either is in use.
The JTAG in use never clears after being set and the console in use
clears after a fixed timeout period.

BUG=None
BRANCH=None
TEST=Passes all unit tests.
Tested that the EC console works when in deep sleep.
Tested that it is possible to run flash_ec when in deep sleep and
using the low speed clock.

Change-Id: Ia65997eb8e607a5df9b2c7d68e4826bfb1e0194c
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173326
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-10-21 23:59:38 +00:00
Randall Spangler
1d6687429c rambi: Support USB port power control
Rambi shares several of the control signals (CTL1, ILIM_SEL) between
both ports, and hard-wires some of the others (CTL2, CTL3).  It still
has separate enable lines for each port.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=boot system; gpioget shows (in part)

  1  USB_CTL1
  0  USB_ILIM_SEL
  1  USB1_ENABLE
  1  USB2_ENABLE

  Then do 'apshutdown' and gpioget shows

  1  USB_CTL1
  0  USB_ILIM_SEL
  0  USB1_ENABLE
  0  USB2_ENABLE

Change-Id: Ib3d321ca2b0aa7dce08ddd6633810a75641bc9a8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173737
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-10-21 21:10:40 +00:00
Randall Spangler
d9530449fd cleanup: Consolidate power interrupts
Every chipset had its own header file just to declare a GPIO interrupt
handler.  Since this seems to be a common feature of the power
interface, make a standard power_interrupt() API provided by
chipset.h.  This lets us get rid of 4 include files, and makes it
easier to add more chipsets in the future.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all boards; pass unit tests

Change-Id: I1fc5612d42625ea46e0a8e16a83085b66d476664
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173745
2013-10-21 21:10:36 +00:00
Randall Spangler
15e2fa02fd Clean up documentation of RCIN# open-drain workaround
On many of the Haswell boards, RCIN# was attached to PL6, which is not
an open-drain capable GPIO.  As a workaround, we toggle it to an input
to get it into a high-Z state.  Now that we understand the problem,
document it and remove the FIXME tag from the comments.

Baytrail systems map RCIN# to a different pin, so don't need this
workaround at all.

BUG=chrome-os-partner:20173
BRANCH=none
TEST=build all boards; pass unit tests

Change-Id: I545a90a523e2967fad40bd47cb47a51983a37bdb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173796
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-21 21:10:13 +00:00
Duncan Laurie
35916b4bc1 i2c: Add common i2cxfer console command
This console command is useful during bringup to interrogate
devices on the EC I2C interfaces.

Ported from STM32 into the common file.  This command now
takes an additional argument for the port to be used.

BUG=chrome-os-partner:23449
BRANCH=samus
TEST=emerge-samus chromeos-ec, tested on samus

Change-Id: I8308fbc2f34e369a20051dca9c5d43872f239777
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173837
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-10-21 20:05:41 +00:00
Yen Lin
140404ffdf ec: add nyan board
This is to add nyan board support:
  - new files in board/nyan folder, including battery.c
  - new common/chipset_tegra.c, which is mostly based on
    chipset_gaia.c
  - new include/tegra_power.h
  - modified build.mk and flash_ec for nyan

BUG=none
BRANCH=nyan
TEST=tested on Venice 2 board

Change-Id: I36895f34f2f4d144a9440aff358c8274797ebbd6
Signed-off-by: Yen Lin <yelin@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/168078
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-10-17 22:52:12 +00:00
Randall Spangler
737160dd5d cleanup: Config defines
Add some missing descriptions in config.h and rename a few defines to
be more consistent.

No functional changes, just comments and symbol renaming.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms; pass unit tests

Change-Id: I05a9a2ed6fd7bc8b14a18a0dc57d7d22430de21a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173111
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-10-16 22:24:42 +00:00
Randall Spangler
1a0fcc27bb x86: x86indebug command should print bit defintions
The chipset module prints debugging information about the state of
power good lines and chipset signals, but those have previously been
decodable only by looking at the EC source code.

Change the 'x86indebug' command to print a decoder ring.

BUG=chrome-os-partner:22895
BRANCH=none
TEST=x86indebug prints a list of bit meanings

Change-Id: I10eb653e23d19ece10635e5de61cd53b0d4d33d5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173089
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2013-10-16 01:52:30 +00:00
Alec Berg
c5b90d7e77 lm4: Add a low power idle task.
First implementation of a low power idle task for the LM4 chip. The
low power mode is selected by defining CONFIG_LOW_POWER_IDLE in a
board.h file. This commit turns it on for Peppy, Slippy, and Falco
only because those are the only boards tested.

When using the low power idle task, the chip goes in to deep sleep
when it can. Deep sleep disables clocks to most peripherals and puts
the onboard flash and RAM into a low power mode. The chip is woken
out of deep sleep using the RTC in the hibernate module. Increased
the idle task stack size to handle more involved idle task.

In board.c, the array of GPIO info can be used to select which GPIO
points can wake up the EC from deep sleep. Currenlty selected are
the power button, lid open, AC present, PCH_SLP_S3, and PCH_SLP_S5.
Additionally the port with the KB scan row GPIO point is also
enabled to wake up the EC from deep sleep.

Signed-off-by: Alec Berg <alecaberg@chromium.org>

BUG=None
BRANCH=none
TEST=Passes all unit tests. Runs on slippy, peppy, and falco with no
noticeable side affects. Verified that the power consumed by the EC
is lower when in S3, S5 and G3 by scoping the sense resistor
powering the chip.

Change-Id: I83fa9a159a4b79201b99f2c32678dc4fc8921726
Reviewed-on: https://chromium-review.googlesource.com/172183
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
Tested-by: Alec Berg <alecaberg@chromium.org>
2013-10-15 00:27:14 +00:00
Randall Spangler
193f2298bd Enforce a minimum number of clocks between keyboard scans
When the EC CPU is running at a decreased clock frequency, frequent
keyboard scans can starve other EC tasks of CPU and lead to dropped
data or watchdog timeouts.

Enforce a minimum number of EC clocks between keyboard scans to
prevent this from happening.  The default chosen (16000 clocks) is
equal to the shortest post-scan delay (1 ms) of any current board when
the AP is in S0, so this should have no effect when the AP is in S0.
When the AP is in S3 or S5, we don't need to scan the keyboard as
frequently anyway.  This can be overridden on a per-board basis for
future boards if needed.

BUG=chrome-os-partner:23247
BRANCH=pit
TEST=apshutdown, then hold down a key for 10 seconds.  Should not see a
     watchdog reset.

Change-Id: I228f53a32ad4769f6a137a9ab06903111bea115d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/172895
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-10-14 23:27:31 +00:00
Vic Yang
027be6fdbb Return hash status on HAST_START command
On HASH_START command, we should also fill in hash status in response so
that the caller sees BUSY status in response.

BUG=chrome-os-partner:23067
TEST=Along with u-boot change, corrupting EC RW followed by a warm reset
doesn't result in shutdown.
BRANCH=All

Change-Id: Ie0c1b35d71bc0420b011f0413f92feb88138db4d
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/172380
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-10-14 23:27:11 +00:00
Randall Spangler
1006187c61 Add baytrail power sequencing
This is an initial version of power sequencing for the rambi rev.1
boards.  It has a workaround for a rev.1 board problem; this requires
turning on PP5000 early.

BUG=chrome-os-partner:22895
BRANCH=none
TEST=AP should power on to S0 (PLTRST# deasserts) automatically when EC boots
     Then 'apshutdown' should drag it back to G3.
     Then 'powerbtn' should take it back to S0.

Change-Id: Id9bc6fe9b55fce3eb46ce1265891724ec7a4ae20
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/172675
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2013-10-11 03:58:09 +00:00
Alec Berg
f7e69a211c Fix bug with hibernate delay when running off battery
Fixes hibernate delay logic for chipset x86. With this change
the machine will go in to hibernate one hour after going into G3
when running off battery.

BUG=chrome-os-partner:23224
BRANCH=none
TEST=Used console command hibdelay to set a reasonable hibernate
delay time and tested all combinations of running off battery vs.
AC and shutting off before or after the machine has been on for
a hibdelay amount of time.

Change-Id: Idd94d3677669dcd405732195b8cbbc1edca1e171
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/172512
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-10-10 16:40:58 +00:00
Randall Spangler
ff8c8fee79 rambi: Control LEDs using PWM
Rambi has a pair of LEDs which are attached to the PWM fan controller.
Add support for them.  Also add a generic 'pwmduty' command which can
be used to get/set the duty cycle for any PWM channel.

Also fix rounding errors in pwm module, so that set/get duty doesn't
keep rounding down.

BUG=chrome-os-partner:22895
BRANCH=none
TEST=Boot rambi. LEDs are off.
     pwmduty -> both are 0%
     pwmduty 0 10 -> green LED on dimly
     pwmduty 1 10 -> red LED on dimly
     pwmduty 0 99 -> green LED on brightly
     pwmduty 1 100 -> red LED on brightly
     pwmduty 1 0 -> red LED off
     pwmduty 1 -1 -> red LED turns back on because fan controller is disabled
     pwmduty -> channel 0 at 99%, channel 1 disabled
     Build all platforms.  Pass all unit tests.

Change-Id: Ib0a6289a757554e696a9a0153a85bdc34e2ee2ae
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/172094
2013-10-08 20:41:32 +00:00
Randall Spangler
99157c265c cleanup: Battery header files and filenames
battery.h is the high-level interface.  battery_smart.h is the
low-level interface.  Most things don't need the low-level interface,
but were including smart_battery.h solely to get at battery.h.  Fixed
this.  Also merged battery_pack.h into battery.h, since it was odd to
split that data across multiple header files.  Tidied the function
comments in battery.h as well.

No functional changes, just renaming files and adding comments.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all boards; pass unit tests

Change-Id: I5ef372f0a5f8f5f36e09a3a1ce24008685c1fd0d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/171967
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-07 18:30:50 +00:00
Randall Spangler
90a6676ad5 cleanup: Move board-specific LED state machines to board dirs
The LED state machine ends up being very board-specific, as does the
specific configuration of LEDs and whether they're PWM'd or just
GPIOs.  dparker has some clever ideas for how to move more of the
functionality to common/led_common.c (used at present only by peppy);
that will be done as a follow-on to this CL.

There's a unit test for the spring LED implementation.  To keep that
compiling, just use a symlink to the spring-specific implementation.

No code changes; just moving around files.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all boards; pass unit tests

Change-Id: I5973e701a29a72575db9a161dc146855ab21cca6
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/171771
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-07 18:30:45 +00:00
Bill Richardson
57aaa0267e cleanup: Replace awkward I2C_PORTS_USED macro with constant
We only used I2C_PORTS_USED to iterate through the list of hardware ports
actually in use, but we defined it in board.h at the same place where we
matched particular I2C devices to the (possibly shared) buses they're on.

This CL makes I2C_PORTS_USED into a global constant, so it can be set
automatically where we initialize the ports, and doesn't have to be
related to the list of attached devices.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=manual

Build everything, run all tests, should still work.

Change-Id: I65f22f5cadfc4b3afe51af48faa5fb369bc3aa09
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/171884
2013-10-07 16:20:59 +00:00
Bill Richardson
9af47b787c samus: alternate functions, charger
Adding some more board-specific configurations for Samus.

BUG=chrome-os-partner:22870
BRANCH=none
TEST=manual

  make runtests

Change-Id: I86c909e899fb5bdb6ba75f476ced58bae2c75c29
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/171809
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-10-04 20:04:44 +00:00
Bill Richardson
9ef58858c4 Cleanup use of config.h macros
include/config.h should have the canonical list of all CONFIG_* macros used
everywhere else. This fixes some that weren't included, and some that had
been changed in one place but not in others.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=manual

Build everything. It should still work.

  cd src/plaform/ec
  make runtests

  for i in bds bolt daisy discovery falco kirby link mccroskey peppy pit puppy rambi samus slippy snow spring; do make BOARD=$i || touch died.$i; done

There shouldn't be any died.* files.

Change-Id: I0a1ec2d57668509c514dc5a521e547836a3e9894
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/171690
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-10-04 01:54:46 +00:00
Bill Richardson
0550d92204 Internalize magic numbers for smart USB charging
Link is the only platform that uses smart usb ports. Link's board.h defines
USB_CHARGE_PORT_COUNT, yet the usb_port_power_smart.c file is peppered with
assumptions that that constant is always 2.

This moves the constant into usb_port_power_smart.c where it belongs.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=manual

  make runtests

Code refactoring only, no visible changes,

Change-Id: Id45e11d88585a98348105b1399c7e18c554add50
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/171565
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-10-02 18:30:46 +00:00
Rong Chang
24986704af Always enable tpschrome low current charging
The PMU charger loop is conservative. And there is no need to set
hardware low charging current termination.

BRANCH=pit
BUG=chrome-os-partner:22946
TEST=manual
  Discharge the battery to level < 40%.
  Issue console command 'pmu', check register 0x09 output.
  The NOITERM bit(5) should be set to 1. That means no low charging
  current termination.

Signed-off-by: Rong Chang <rongchang@chromium.org>
Change-Id: I45532dcaab3bab566407b209f26693e2c3451014
Reviewed-on: https://chromium-review.googlesource.com/170906
Reviewed-by: Hung-ying Tyan <tyanh@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Jaehoon Kim <jh228.kim@samsung.com>
Tested-by: Jaehoon Kim <jh228.kim@samsung.com>
2013-10-02 09:19:42 +00:00
Randall Spangler
05c367d9ce Clean up G781 temperature sensor power detection
This was previously done in a board-specific function across 4 boards.
Except that the board-specific function was identical in all cases
(that is, not really board-specific).  Put it back in the common
implementation to get rid of duplicated code, and use
CONFIG_TEMP_SENSOR_POWER_GPIO to indicate which GPIO rail controls the
sensor power.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all boards; pass unit tests

Change-Id: I29de40001d5d4dc873e5ba8f3abb328c6271f235
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/171140
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-01 19:12:07 +00:00
Randall Spangler
6d522eef9d Wake keyboard task when lid opens
If keyboard scanning is active when the lid closes, it will disable
scanning put the scan task to sleep.  We need a corresponding task
wake when the lid opens, or scanning will be stuck off (until
something else happens, like poking the power button).

BUG=chrome-os-partner:22190
BRANCH=peppy
TEST=Hold down a key.  Use a magnet to trigger the lid switch.  Scanning
     should stop while the lid is "closed", and restart when the magnet is
     moved to "open" the lid again.

Change-Id: I0a900f17f65b75cbdb45950cea7f50190d2bf9b1
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170993
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-09-30 18:58:15 +00:00
Randall Spangler
5ee634b1a5 Battery command needs to delay between iterations
The battery command takes a long time to run if given a high repeat
count.  Since it doesn't sleep at all between iterations by default,
this will unsurprisingly starve all other tasks and cause a watchdog
timeout.

Reset the watchdog between iterations, to give the rest of the system time
to do things.  This is similar to what we do in the i2cscan command.

BUG=chrome-os-partner:22232
BRANCH=none
TEST=apshutdown, then battery 1000 = no watchdog

Change-Id: I3ce55e15d90a6dfda34b1e2e332d7f7828922e78
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170968
2013-09-30 18:58:11 +00:00
Randall Spangler
84ba188120 Support backlight control via lid only
The old backlight_x86 code did

  (backlight enable) = (lid is open) && (GPIO request from AP)

Newer systems will AND those signals in hardware.  Support those
systems by separating CONFIG_BACKLIGHT_LID and
CONFIG_BACKLIGHT_REQ_GPIO, and add tests for the case where the enable
signal is dependent only on the lid position.

BUG=chrome-os-partner:22960
BRANCH=none
TEST=pass unit tests

Change-Id: I1909426e49f00a8acd5047fd88c801cba1dacd76
Reviewed-on: https://chromium-review.googlesource.com/170925
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Randall Spangler <rspangler@chromium.org>
2013-09-27 23:07:21 +00:00
Vic Yang
1e16031f75 Add a test for x86 backlight passthrough
This checks x86 backlight passthrough by toggling lid switch and PCH
backlight output, and also by host command.

Also fix a bug that backlight switch host command can never be invoked
due to incorrect version mask.

BUG=chrome-os-partner:19236
TEST=util/make_all.sh
BRANCH=None (unless some platform needs backlight switch host command)

Change-Id: Iefc5f4b7387c4d2aa43059d073bd70aed879fe34
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170758
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-27 04:33:40 +00:00
Randall Spangler
a617846582 Make support for dedicated recovery GPIO signal optional
switch.c currently assumes that all boards have GPIO_RECOVERY_L.  This
is not true for Rambi, and also isn't true for ARM boards (which
should also eventually use the common switch implementation).

Add a new CONFIG_SWITCH_DEDICATED_RECOVERY option to control whether
to compile this support.

BUG=chrome-os-partner:22893
BRANCH=none
TEST=compile all boards; pass unit tests

Change-Id: If6f34d1afd580c9d79a8edcdda18833068e70f66
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170489
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-09-25 01:23:29 +00:00
Vic Yang
1e08d488bd Mock flash erase/write function at physical layer
This moves the mock function from common layer down to physical layer to
complete the test of common layer.

Also disable flash test for hardware tests, as this is only testing
common layer.

BUG=chrome-os-partner:19236
TEST=util/make_all.sh
BRANCH=None

Change-Id: Idd1c2c44591952894486f84d428872cfbf2cfdad
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170297
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-24 21:00:25 +00:00
Randall Spangler
6277f7e336 Fix thermal.c compilation if fans are not present.
Currently, it doesn't compile unless CONFIG_FAN is defined.

BUG=chrome-os-partner:22803
BRANCH=none
TEST=temporarily undefine CONFIG_FAN in board/link/board.h; code compiles
     and all unit tests pass

Change-Id: I251d670ccd299f7a50b1455364a817e07fad4cb1
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170106
2013-09-23 21:26:26 +00:00
Randall Spangler
61c40db16c stm32: Fix polarity of charger interrupt
The charger interrupt is active-low.  Snow and Spring properly
triggered on falling (asserting) edge, but Pit (and Daisy/Puppy)
didn't.  Fix those boards, and rename the signal to end in _L so we
don't make that mistake again.

BUG=chrome-os-partner:22827
BRANCH=pit
TEST=unplug/replug AC adapter on pit; see debug output as follows:
	[batt] state charging -> idle0
	Charger IRQ received.
	[batt] state idle0 -> charging
	Charger IRQ received.

Change-Id: I1f5c9370d1118461dc033955ba77aab2cebb7ece
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170256
Reviewed-by: Jaehoon Kim <jh228.kim@samsung.com>
Tested-by: Jaehoon Kim <jh228.kim@samsung.com>
Reviewed-by: Doug Anderson <dianders@chromium.org>
2013-09-23 19:23:58 +00:00
Vic Yang
a4f3a72cf8 Record average runtime and delay of hooks
In additional to recording the maximum runtime and delay, let's also
keep track of the moving average. The average is calculated by:
    New_Avg = (Old_Avg * 7 + New_Val) / 8
every time the hook fires.

The average values are only accurate for hooks that fire enough times,
but it won't be useful anyway for a hook that only fires just once or
twice.

Also, show warning if HOOK_TICK or HOOK_SECOND fires more than 10% late.

BUG=chrome-os-partner:21801
TEST=On Kirby, check average values are sane.
TEST='waitms 800' and see warning of HOOK_TICK firing late.
BRANCH=None

Change-Id: I453545830d854c6c5bfc795d01fc558a965cff6e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169704
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-23 06:10:32 +00:00
Randall Spangler
883dd51006 cleanup: move test mocks to board/host and remove unused mocks
Now that we have a better test framework in place, mock
implementations go in either chip/host/ or board/host/, depending on
whether they're mocking chip or common/board functionality.  Move the
remaining mocks there.  Also, several mocks were neither compiled nor
used, and haven't kept pace with other refactoring; delete those.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all board; pass all unit tests

Change-Id: Ie2a81c3ccd4506679192d979aa87fe7ed6c1c5a0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169873
2013-09-19 23:30:03 +00:00
Randall Spangler
a95e80dd47 cleanup: move board-specific battery files to board dirs
The battery files contain board-specific constants and a few small
methods like battery-detect and battery-cut.  Most of these aren't
reused across platforms.  The battery files have also been cleaned up
so those board-specific constants basically all that's left in them.

Where a file is used by a single board only, move it to
board/(boardname)/battery.c.  Batteries used by more than one board
(e.g. battery_link.c used by both link and bolt) are still in
common/battery_*.c, since that's cleaner than duplicating the file in
each board's directory.

No code changes, just moving files.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all boards and pass unit tests

Change-Id: I946c8eb874672c77f9b77105e5b900f98fa48d0f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169893
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-09-19 00:41:12 +00:00
Vic Yang
6aa88ffa4e Fix console channel name list
This adds back missing "hook" channel name. Also add a build assertion
to make sure we don't miss this again.

BUG=chrome-os-partner:21801
TEST=Build all boards. Remove "hook" channel and check build fails.
BRANCH=None

Change-Id: I373016504fd3753e1a791077d49b3af14b2b1aa4
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169703
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-18 22:09:04 +00:00
Dave Parker
2c16da8e91 Haswell: Add control for touchscreen reset
BUG=chrome-os-partner:22076
BRANCH=peppy
TEST=Manual. Verify touchscreen operational in S0.

Change-Id: Ife2d4e11142195bddf202933430ec8af243b1309
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167150
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-18 22:09:00 +00:00
Vic Yang
a2c962b7f6 Remove 'sb' and 'sbc' console commands
The functionality of these commands can be fully covered by 'i2cxfer'
command. Remove them to save code size.

BUG=None
TEST=Build all boards. Pass all tests.
BRANCH=None

Change-Id: I3f57e797530b17cff17b50feec80436ad7872409
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169510
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-17 03:22:34 +00:00
Vic Yang
1b66740546 Mock smart battery at lower level
Instead of mocking it at sb_read()/sb_write() level, let's mock them at
I2C transaction level so as to increase test coverage of smart battery
driver.

BUG=chrome-os-partner:19236
TEST=Pass sbs_charging test.
BRANCH=None

Change-Id: I9bcd69517b084ea598c7b074a40143338e6150fe
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169512
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-17 03:22:15 +00:00
Randall Spangler
cdd5c206cd stm32: Use DMA for UART receive
STM32 has a single-byte mailbox for UART I/O.  When the core clock
runs at 16Mhz we can service interrupts fast enough to handle 115200
baud input, but when we drop to 1MHz we drop characters.  Using DMA to
receive input solves this problem.

The STM32 DMA engine can only generate interrupts when the transfer is
half-done / all-done, so we need to poll the DMA receive-head-pointer
to see if individual characters have been received.  Do this in the
tick task (every 250ms).  When a character is received, poll more
quickly for a bit (5 times before the next tick) so the input console
is more responsive to typing.

BUG=chrome-os-partner:20485
BRANCH=none
TEST=Console is responsive to debug commands.  For example, help -> prints help
     apshutdown -> shuts down AP
     arrow keys -> move cursor and scroll through command history
     Ctrl+Q, help, wait a second, Ctrl+S -> help output printed after Ctrl+S

     Then in chip/stm32/config_chip.h, comment out #define CONFIG_UART_RX_DMA
     and rebuild/reflash the EC.  When the AP is up, the console works normally
     but after 'apshutdown', the EC drops to 1MHz core clock, and the arrow
     keys don't work.  (This step confirms that adding DMA support did not
     change the behavior of systems where CONFIG_UART_RX_DMA is not defined.)

Change-Id: I199448354824bd747c7b290ea7fd5ccf354c11bb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169406
Reviewed-by: Simon Glass <sjg@chromium.org>
2013-09-16 23:31:07 +00:00
Vic Yang
b718dfc059 Add hook statistics
If CONFIG_HOOK_DEBUG is defined, the maximum run time of each hook is
recorded.  Also, record the delayed amount of time of HOOK_TICK and
HOOK_SECOND firing. The statistics are available through console command
'hookstats'.

Also fix a bug that CC_HOOK is used but not defined when
CONFIG_HOOK_DEBUG is defined.

BUG=chrome-os-partner:21801
TEST=Build with HOOK_DEBUG and check 'hookstats'
BRANCH=None

Change-Id: I3acba3abdd487cf20d9a532429f766cdddea2e93
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169274
2013-09-14 18:30:43 +00:00
Randall Spangler
573e695a69 Simplify uart_tx_start()
All calls to it did

    if (uart_tx_stopped())
        uart_tx_start();

And that was the only use of uart_tx_stopped().  Merge the functions.

BUG=chrome-os-partner:20485
BRANCH=none
TEST=EC debug console still prints output and accepts commands.
     Ctrl+Q pauses output and Ctrl+S resumes it.

Change-Id: I113c64f5fdfc6b02b63034a74b1a3c6c6a76c351
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169329
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-09-14 00:32:13 +00:00
Randall Spangler
40f4d61266 Remove unused uart functions
Nothing ever called uart_flush_input() or uart_gets(), so remove them.
They're dead code, and make implementing UART DMA input more complex.

BUG=chrome-os-partner:20485
BRANCH=none
TEST=build all platforms; pass unit tests

Change-Id: I94c2c372ac3f326b98e819b2c89b8995311b2868
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169345
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-09-13 23:23:48 +00:00
Bill Richardson
6bfeb49855 Falco: correct input current limit for 45W adapter, Turbo off
Change the charger's Input Current Register setting for the 45W adapter to
match the latest spec.

BUG=chrome-os-partner:20739
BRANCH=Falco,ToT
TEST=manual

Connect a 45W adapter, run the "battery" and "charger" commands on the EC
console.

When the battery charge is below 10% (turbo off), the "I_in" value displayed
by the "charger" command should be 1536. Before it was 2560.

Change-Id: I0483b5408aa2da352cd3aeda58e1656c095d86b2
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169323
Reviewed-by: Randall Spangler <rspangler@chromium.org>
(cherry picked from commit 3a2ef8cb38d9b0fcc638bbc9a5f7a465a8b14565)
Reviewed-on: https://chromium-review.googlesource.com/169392
2013-09-13 23:23:27 +00:00
Bill Richardson
87d694a906 Falco: Always update charger's input current limit.
I was just updating the input current limit when turbo mode was enabled and
disabled. However, it turns out that the charger can decide to change the
setting all by itself if the inrush current is too high. This happens pretty
much every time that the AC is applied.

We didn't notice this while the AP was on, but when the AP was off we were
exiting the watch_adapter_closely() function too soon and so we missed the
transition. This CL fixes that.

But just to be safe, instead of only updating when we think we need to,
we're going to just update the value every time we check on the adapter.
That way if we happen to miss a change due to a race condition or transient,
we'll catch it the next time through the loop.

BUG=chrome-os-partner:20739
BRANCH=Falco,ToT
TEST=manual

Before this CL, you can run "sbc 0x3f" on the EC console while plugging and
unplugging the AC adapter. When the AP is off and AC is reapplied, you'd see
the reported value mysteriously change.

After this CL, it doesn't.

Change-Id: I5661c548cccd4eb24ba4d8a0b8cd070acc2e49ef
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169322
Reviewed-by: Randall Spangler <rspangler@chromium.org>
(cherry picked from commit 1bcdd0eb6ff353a7215efe0b24630148ea7a9f28)
Reviewed-on: https://chromium-review.googlesource.com/169391
2013-09-13 23:23:24 +00:00