Commit Graph

603 Commits

Author SHA1 Message Date
Randall Spangler
f2b56fcb9f Clean up configuring GPIO alternate functions
GPIO alternate functions used to be configured throughout the code,
which made it hard to tell which ones you needed to configure yourself
in board.c.  It also sometimes (chip/lm4/i2c.c) led to GPIOs being
configured as alternate functions even if they weren't used on a given
board.

With this change, every board has a table in board.c which lists ALL
GPIOs which have alternate functions.  This is now the only place
where alternate functions are configured.  Each module then calls
gpio_init_module() to set up its GPIOs.

This also fixes a bug where gpio_set_flags() ignored most of the flags
passed to it (only direction and level were actually used).

On stm32f, gpio_set_alternate() does not exist, and pins are
configured via direct register writes from board.c.  Rather than
attempt to change that in the same CL, I've stubbed out
gpio_set_alternate() for stm32f, and will fix the register writes in a
follow-up CL.

BUG=chrome-os-partner:21618
BRANCH=peppy (fixes I2C1 being initialized even though those pins are used
       for other things)
TEST=boot link, falco, pit, spring

Change-Id: I40f47025d8f767e0723c6b40c80413af9ba8deba
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64400
2013-08-07 12:43:35 -07:00
Randall Spangler
b91e63b0f9 Clean up SPI state machine and add state codes
The old low-level SPI protocol provided no useful information to the
host about whether it was ready to receive or not.  It also could get
stuck waiting to receive data without setting up receive DMA, if the
host did two transactions back-to-back.

Add a real state machine to the SPI module.

Add a range of byte codes the EC can return outside of a response
frame, to indicate its current state.  If the AP receives one of these
codes, it can abort the transaction since it now knows the EC is
unable to determine when it can send a response frame.

This change is backwards-compatible with current AP firmware and
kernel drivers, since those only look for the framing byte and don't
care what other bytes are received in the meantime.

BUG=chrome-os-partner:20257
BRANCH=none
TEST=crosec test; passes at 70us.

Change-Id: Ia06109ead3fbc421848e01050f7baf753cbeb16c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64254
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-08-05 19:16:25 -07:00
Vic Yang
19e30d9c7d Remove proxy config flags for unit tests
This moves per-test config flags from test_config.mk to test_config.h,
where one can define/undefine config flags for individual test.

BUG=chrome-os-partner:19235
TEST=Pass all tests
BRANCH=None

Change-Id: I096aded2007881433d3b6414d37f8bfdc6a2c45c
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64367
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-08-04 13:11:08 -07:00
Randall Spangler
93536fbe55 Change one-wire bus to use normal gpio interface
There's no need for it to directly access the GPIO registers.  That
was only necessary at the beginning of link, when gpio_set_flags()
didn't exist.

BUG=chrome-os-partner:21612
BRANCH=none
TEST=onewire red / onewire green / onewire yellow all set the adapter LED
     (tested on link, since I don't have a bolt, but the EC chip and adapter
     are identical)

Change-Id: I2386962ff039bb2251be38eaadcaeae8ffd1ea7b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64375
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-08-02 17:32:35 -07:00
Randall Spangler
889f7bdd3b Move input character processing from UART interrupt to console task
Previously, processing of arrow keys and control characters was done
in the interrupt handler itself.  This increased the impact of UART
input on other interrupts and high-priority tasks.  It also makes it
harder to implement DMA-based UART input on STM32L (in an imminent
CL), since the processing affected the circular UART input buffer
in-place.

This change turns uart_buffering.c back into a dumb I/O buffering
module, and puts all the command line editing and history support into
console.c.

Console history is done via a simple array of input lines instead of a
packed circular buffer of characters.  This is a little less
RAM-efficient, but is easier to implement and read.  History depth is
controlled via CONFIG_CONSOLE_HISTORY, and is 3 for STM32F and 8 for
other platforms.  If we really need a greater history depth, we can
look into implementing a packed circular buffer again, but this time
at task time in console.c.  Also added a 'history' command to print
the current console history.

BUG=chrome-os-partner:20485
BRANCH=none
TEST=console_edit unit test passes; 'history' command prints the last commands

Change-Id: I142a0be0d67718c58341e4569f4e2908f191d8b0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64363
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-08-02 17:32:26 -07:00
Randall Spangler
c6dfa7e03b Host commands don't set the response pointer
Remove support for allowing host command handlers to set the response
pointer.  This is just one more thing that can break (and did, on SPI
protocol V2).  No commands other than the trivial read-memory-map
command in host_command.c and flash read made use of this capability,
and the savings in performance was negligible.

BUG=chrome-os-partner:21576
BRANCH=none
TEST=boot pit; still boots

Change-Id: I0a9bcf57dbea7155318fc389d7b47d3742a1a00a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64236
2013-08-02 13:05:56 -07:00
Dave Parker
0d3bdc690e Falco: Stop charging after a timeout of 10 hours
BUG=chrome-os-partner:20145
BRANCH=falco
TEST=Hack it. Add (uint64_t)599 * MINUTE to ctx->curr.ts.val
in the timeout comparison. This makes the 10 hour timeout only
take 1 minute. Testing this directly is tricky as a healthy battery
will charge quickly. If you force it to trickle charge it will
give up before 10 hours pass.

Change-Id: I69094a07e58c2d65e322ddc6a1b2ced828da0e26
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64309
2013-08-02 12:16:44 -07:00
Dave Parker
33f8086c90 Track the duration of each charge/discharge state.
BUG=chromium:267146
BRANCH=falco,peppy
TEST=Manual. Observe charge state messages on the ec console.

Change-Id: I25f04db56bf62394b5bb2e0d56edbda3a0bb5e25
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64280
2013-08-02 12:16:43 -07:00
Randall Spangler
9078a1d9b2 Fix documentation for lid change and power button hooks
They're now called from a deferred function call, which is done in the
hook task and not the chipset task.

No code changes.

BUG=none
BRANCH=none
TEST=compile code

Change-Id: I115b6b254bd2b0ddd9688df603621e7ce0c12e1e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64258
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-08-01 18:15:50 -07:00
Randall Spangler
bebfb9431e Word-align the host memory map
This fixes unaligned access exceptions when totally-unrelated code
changes happen to move around host_command.c's global variables.

BUG=chrome-os-partner:21578
BRANCH=none
TEST=add a ccprintf() call to host_command.c; no longer causes an exception

Change-Id: I5407e5631a08ea647dc40e5bd9c7bd101868ced0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64233
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-08-01 14:22:44 -07:00
Dave Parker
8e28efa7ac Add hook for changes in the charge state machine
BUG=chrome-os-partner:20145
BRANCH=falco,peppy
TEST=Manual. Tested with charging timeout logic.

Change-Id: Iab1c9746dcab5820fcdeb3e0d94bfcb0c47e57f2
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63537
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-08-01 11:07:58 -07:00
Bill Richardson
86bef29c3d Abstract polite AP throttling into a function
This wraps the EC_HOST_EVENT_THROTTLE_START/STOP host events in a new
function called host_throttle_cpu(), similar to chipset_throttle_cpu().

That function requests the AP to throttle itself, which is less drastic than
just smacking it down from the EC.

BUG=chrome-os-partner:20805
BRANCH=falco,peppy
TEST=manual

This is a refactoring change only. All boards should still build, all tests
should still pass.

Change-Id: I871cce8f0e13230cb52eeb5e16955266f8461374
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63909
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-31 12:33:31 -07:00
Bill Richardson
af77729737 Add build-time checks on board-specific array sizes.
We've been declaring a bunch of statically-sized arrays:

  extern struct foo_t foo[FOO_COUNT];

And then initializing them like so:

  struct foo_t foo[FOO_COUNT] = {
    /* blah */
  };

That only catches cases where we initialize with too many entries. It
doesn't catch cases where we haven't initialized enough. This change tests
for both cases like so:

  extern struct foo_t foo[];

  struct foo_t foo[] = {
    /* blah */
  };
  BUILD_ASSERT(ARRAY_SIZE(foo) == FOO_COUNT);

The affected arrays are:

  adc_channels[ADC_CH_COUNT]
  gpio_list[GPIO_COUNT]
  temp_sensors[TEMP_SENSOR_COUNT]
  x86_signal_list[X86_SIGNAL_COUNT]
  i2c_ports[I2C_PORTS_USED]

BUG=chrome-os-partner:18343
BRANCH=falco,peppy
TEST=build all platforms

All platforms should still build, all tests should still pass.

Change-Id: Ibb16dc3201f32df7cdc875648e89ba4ffb09f733
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63833
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-31 12:33:31 -07:00
Rong Chang
bf71082456 Add PMU powerinfo host command and console command
Before this change, powerinfo host command supports only one target
with USB charging. This change adds a common powerinfo host command
and console command for TPSChrome based targets.

BRANCH=None
BUG=chrome-os-partner:20326
TEST=manual
  build and flash pit target, check console command 'powerinfo'.
  check ectool powerinfo with and without AC adapter.

Change-Id: I2cfd8dfa011e23f819c6bae19cf22b4a7343f044
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63350
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-07-29 11:07:31 -07:00
Bill Richardson
ac78e589af Add new hostevents to ask the AP to throttle itself
Occasionally the EC wants to ask the AP to throttle itself. Currently, the
only thing that the EC can do (at least on x86) is to assert the PROCHOT#
signal, which is a fairly intrusive operation and one that Intel suggests we
save for emergencies.

This CL adds a new pair of host events to ask the BIOS to throttle the AP
politely, or stop doing so. The turbo charger code will send these events to
the AP if they become necessary.

BUG=chrome-os-partner:20739
BRANCH=falco,peppy
TEST=manual

Tests should still pass, everything else is unchanged.

  make BOARD=${BOARD} runtests

Currently, there's nothing on the BIOS/OS side that would respond to these
events, so they're just ignored. You can test that, even without this CL, by
running

  hostevent set 0x40000
  hostevent set 0x80000

Change-Id: I4a7a1b6eb87e42df94ddd09f4c6abee6ebcbd485
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63379
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2013-07-25 19:02:09 -07:00
Bill Richardson
298a7276c2 Add turbo mode charger support, and tests for it.
Some chargers can run in a "turbo" mode, which lets it draw from the battery
to provide extra power to the AP in short bursts. In order for this to work
properly, the EC has to watch the current closely to make sure specific
limits are observed. It also has to recognize specific adapters, since those
limits vary depending on the rated power that the adapter can provide.

This adds the basic functionality, plus a test for it.

BUG=chrome-os-partner:20739
BRANCH=falco,peppy
TEST=manual

  make BOARD=${BOARD} runtests

On Falco, you can also use the "adapter" EC command to see what's going on.
Try replacing the adapters and running that command to be sure they're
correctly identified, too:

  > adapter
  Adapter 65W (590mv), turbo 1, AP_throttled 0
  >

We currently support 45W, 65W, and 90W adapters. Unknown adapters are
treated as 65W, but don't enable turbo mode.

Change-Id: I7e5407db825ce7e596cb495fb8cb4d1dd1ff639c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63372
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-25 15:50:13 -07:00
Randall Spangler
1960b9f957 Add descriptions for lots of config options
No functional changes, no renaming options, just adding comments.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms

Change-Id: I7218f8a4465e3e27b33a1d1a5313da83e474d633
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63281
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-07-24 19:08:18 -07:00
Randall Spangler
b4d903487e Clean up onewire config options
Rename onewire_led to led_driver_ds2413, since we may have other LED
drivers hanging off a one-wire bus in the future.

No functional changes, just renaming config options.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms

Change-Id: I1d70b1c5778da94bda4ebef3b57f7c39bfba2322
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63273
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-07-24 18:08:32 -07:00
Randall Spangler
90215a4494 Clean up more config options - FMAP, etc.
CONFIG_FMAP is now defined by default, because all platforms other
than the host unit tests use it.

No functional changes, just renaming config options and removing dead code.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms

Change-Id: Ie6496310c822491068e2fa6976933486f26badb0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63271
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-07-24 18:08:31 -07:00
Randall Spangler
ba3733e492 Clean up more config options
No functional changes, just renaming config options.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms

Change-Id: I65b310b670e61bcb3531c581dfc57625df064df2
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63248
2013-07-24 18:08:29 -07:00
Randall Spangler
e6f0c272a0 Clean up and document UART config options
No functional changes, just renaming config options.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms

Change-Id: I91584cb1f8990dd0f980abd32c04465a66243e71
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63244
2013-07-24 16:31:14 -07:00
Vic Yang
99e4a97798 Reboot emulator with execv()
With this, the emulator is able to reboot itself without the help of
run_host_test script. This makes it easier for development and also
speeds up the test.

BUG=chrome-os-partner:19235
TEST=Pass all tests
BRANCH=None

Change-Id: Ifa510442de19256c671ab91b6bc75fe9e8b9dc7b
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62969
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-07-24 15:50:19 -07:00
Rong Chang
5afcb815d6 Collect board X specific files into build.mk common-$(BOARD_X)
This change removes all CONFIG_module_FOO from board/foo/board.h .

BRANCH=None
BUG=chrome-os-partner:21302
TEST=util/ecmakeall.sh

Change-Id: If36c792d7a8587a186287eee5fa31b4c4cf1c006
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63211
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-24 15:50:17 -07:00
Randall Spangler
fe660aa372 Standardize concatenation macros
To create a token by concatenating already-defined macros and new
text, it's necessary to use multiple levels of macro.  We'd already
done that in several places in the code such as STM32_CAT; this now
standardizes it into a single place.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=Build all platforms; examine ec.RO.map to see that irq_*_handler and prio_* symbols
     evaluated the same as before.  (Other macro evaluations would simply fail to compile
     if they were incorrect, since the concatenated tokens wouldn't fully expand.)

Change-Id: Ic9bf11d27881a84507fe7b6096dab6217c6c6dc7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63231
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-07-24 14:05:17 -07:00
Rong Chang
6c280b1b32 Move TPSChrome charging temperature range to battery pack
This change moves vendor specific temperature ranges to battery pack
files or board setup files. And added a host test case to verify that
does not change x86 smart battery charging state machine behavior.

BUG=chrome-os-partner:21181
BRANCH=None
TEST=manual
  build test: util/ecmakeall.sh
  hosttests: make hosttests && make runtests

Change-Id: I48e76826b5555f64b78e3c063ce5f02416c72aa2
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62978
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-07-24 13:07:13 -07:00
Aaron Durbin
18f0bd28e2 x86: build chipset_x86_common.o conditionally
Add a CONFIG_CHIPSET_X86 option that determines if
chipset_x86_common.o is built.

BUG=chrome-os-partner:20372
BRANCH=None
TEST=built bolt and link. All other boards should be covered.

Change-Id: I980a8fc68a31162b920429e695631909c5f6a4db
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63208
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-24 12:09:49 -07:00
Randall Spangler
8cd69cfe53 Clean up and document more config options
No functional changes, just renaming config options.

Remove README, now that all options described in it have been moved to
config.h, and the remaining information is out of date.  (Yes, we
should have a README which describes the organization of the EC
repository, but that's a matter for another CL; this one's about
cleaning up config options.)

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms

Change-Id: Iafefbe94369f1217c698f11d358bc0ecac2bdfde
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63145
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-07-24 12:09:47 -07:00
Randall Spangler
8b81636780 Clean up and document keyboard config options
No functional changes, just renaming config options.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms

Change-Id: Ie811066a26eeaf2a5b2002b934e25b660d29058d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63109
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-07-23 17:37:54 -07:00
Randall Spangler
cb1f7306b3 Clean up debug config options
All of these were defined on all but a few platforms, and those
explicitly #undef them.  So define them as enabled by default in
config.h so the board.h files are cleaner.

No functional changes; just rearranging/renaming config constants.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms; FEATURES=test emerge-falco chromeos-ec

Change-Id: I1201a1472ae29641e9e219c2a0347691ca64cd28
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63102
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-07-23 17:37:53 -07:00
Randall Spangler
64e38af781 Clean up and document PMU config options
No functional changes, just documenting and renaming.

All boards which use the PMU must provide pmu_board_init().  This was
already true - except that Daisy's pmu_board_init() was implemented as
part of pmu_init() instead of its code living in board.c; I've moved
the code there now.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms

Change-Id: I85ad06dc3b6287ad917fe13acf83182f24a8f23d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62906
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-07-23 11:14:16 -07:00
Randall Spangler
4288e45815 Clean up and document battery config options
No functional changes, just documenting and renaming.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms

Change-Id: I0b0d3cdce535d90ce437e82e96346fc3ca9be7b0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62673
2013-07-23 11:14:15 -07:00
Randall Spangler
345c22be08 Clean up charger config options
These are now described in config.h.  The various BQ chargers now also
use a consistent naming for their sense resistor options.

No functional changes, just renaming, and removal of obsolete
never-defined configs.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms

Change-Id: Ie274546fe45f5ffc6fd0f26096c4622805baf8a0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62540
2013-07-23 11:14:14 -07:00
Vic Yang
8218aa1346 Add system_common unit test
This tests reboot-on-ap-shutdown.

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

Change-Id: Ic1a07670f82646e85d014d52a2aba0835319c212
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62855
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-07-22 16:09:47 -07:00
Dave Parker
46af344b87 Battery LED control for Slippy
BUG=chrome-os-partner:21180
BRANCH=slippy
TEST=Manual. Verify LED is amber while charging, blue when
charged, and off when external power disconnected.

Signed-off-by: Dave Parker <dparker@chromium.org>

Change-Id: If80bb9b0c70951d257621a2fe3ef20cd8749a033
Reviewed-on: https://gerrit.chromium.org/gerrit/62848
Tested-by: Dave Parker <dparker@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Dave Parker <dparker@chromium.org>
2013-07-22 15:28:58 -07:00
Randall Spangler
fe76b51da0 Truncate version string to 32 characters
The version struct and EC_CMD_GET_VERSION assume 32-character version
strings.  But if the git tree is dirty and the board name is long, the
version string overflows that limit.

This change truncates what's stored in the version string to fit.

The build info still contains the full version string, as it did before.

BUG=chrome-os-partner:21156
BRANCH=none
TEST=build BOARD=mccroskey with a dirty tree; it should build.
     Then cat build/mccroskey/ec_version.h to see CROS_EC_VERSION32 has
     truncated the version string.  Then build a platform of your choice
     and type 'version' to see that the version string and build info is
     still reported correctly.

Change-Id: Ie71b8efd99a83315f8b4d5ad10c51e48781b12f4
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62649
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-07-19 18:01:55 -07:00
Simon Glass
db347953e1 Add an enum for the number of flash regions
Add an enum for the number of flash regions so we can keep track of all
the possible regions.

(This is used in U-Boot which wants to declare an array of all possible
regions.)

BUG=chromium:244019
BRANCH=none
TEST=manual
Build EC for pit.

Change-Id: I494d857f1388dcc5c64b1cd580cf0084bdef0212
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62701
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-19 18:01:49 -07:00
Dave Parker
c243537dda Constrain charging voltage to values chargers can provide.
BUG=chrome-os-partner:20863
BRANCH=falco,peppy,slippy,wolf
TEST=Manual. On Peppy, there should no longer be "Charging
Voltage" messages every second on the EC console. On other platforms
verify that V_Batt reported by the 'charger' command is divisible
by 16.

Change-Id: Idd775a1d8033ff3405d10919e1e15ddddebc6c23
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62699
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-19 18:01:48 -07:00
Dave Parker
50ebe05652 Peppy: Detect physical presence of battery before waking it
BUG=chrome-os-partner:20889
BRANCH=peppy
TEST=Power device without battery. It should boot with no 30
second delay. The battery LED blinks orange indicating a
battery error.

Change-Id: Iea4f5644ae223b60dc8058dc52e06405e275c001
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61820
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Marc Jones <marc.jones@se-eng.com>
2013-07-19 17:02:18 -07:00
Dave Parker
7f1c49ab4b Add ectool discharge command to Falco and Peppy.
Expands and renames ectool 'chargeforceidle' command to
'chargecontrol'. Board-specific calls are needed to enable and
disable the discharge while on AC power state.

BUG=chrome-os-partner:20506
BRANCH=falco,peppy
TEST=Run ectool chargecontrol command with each option (normal,
 idle, discharge) on Falco and Peppy. Verifiy battery is discharging
 in discharge mode via EC console 'battery' command.

Change-Id: I7ac2b18b4f143bf6abc1e0bb878ad21a99f52100
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60689
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-19 10:58:18 -07:00
Randall Spangler
5691ac8168 Add EC_CMD_GET_FLASH_INFO version 1
This adds two new fields: the ideal write size for best EC flashing
performance (e.g., page mode instead of word mode), and a flags field
with a flag to indicate whether the EC erases its bits to 0 or 1.

The EC still supports the old version 0 command, since u-boot and
flashrom expect that to work.

BUG=chrome-os-partner:20973
BRANCH=(all haswell); this will speed up flashing and software sync
TEST=ectool flashinfo
     1. old EC, new ectool -> only reports version 0 info
     2. new EC, old ectool -> only reports version 0 info
     3. new EC, new ectool -> reports new fields

Change-Id: I484327fe22a58d2b69d7f6ac767b2d3e81b3e0b7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62378
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2013-07-18 16:47:00 -07:00
Randall Spangler
672057cb7e Split x86 power button logic out of switch.c
Power button logic is common across all platforms and is not
LM4-specific, so move it to its own module.  Switch.c will eventually
be moving to common/ and will common across all platforms (not just
x86), and splitting out the x86 power button logic is needed before
that too.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=manual
     1) power on system with both lid and power button.
     2) power+refresh -> reboots
     3) power+refresh+esc -> recovery mode
     4) power+refresh+downarrow -> reboots, AP stays off
     5) toggling recovery GPIO via servo should generate SW debug output
        showing bit 0x10 toggling

Change-Id: I07714e2c035dceece66f90407983397d2697e7d5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61780
2013-07-17 10:49:48 -07:00
Aaron Durbin
7d6e01d617 lm4: make configure_kblight_gpios() board dependent
The configure_kblight_gpios() funciton was specific to
the link board. Therefore, move the function to be defined
within the board-specific file.

BUG=chrome-os-partner:20372
BRANCH=None
TEST=Built. Tested similar change on bolt.

Change-Id: Ib5847130450024c50d6526d2c1a64d67ab501637
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62209
2013-07-16 16:40:38 -07:00
Randall Spangler
0c73fdae77 Make a top-level config.h file to include sub-configs
This file will soon contain the exhaustive list of all CONFIG defines
and their descriptions.

Chip-level configs are renamed to config_chip.h to avoid naming
conflicts.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms

Change-Id: I9e94146f5b4c016894bd3ae3d371c4b9f3f69afe
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62122
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-07-16 12:06:31 -07:00
Randall Spangler
873e4425c5 Remove unneeded direct includes of board.h and config.h
Both of these are included via common.h, which is in turn included by
most other header files.  Directly including board.h or config.h is
redundant and discouraged.

No code changes, just removing #includes.

This is in preparation for making a top-level config.h file, but that
change will be easier to review if it doesn't touch as many files.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms

Change-Id: I204bcebe5607c6e6808821eb071cfc31d2a93a7c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62121
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-07-16 12:06:30 -07:00
Randall Spangler
f8955d14b6 Remove unused board_version enums
These were briefly used on link, and are not used by any other
platform.  The values for those platforms are almost certainly wrong,
and incorrect information is worse than no information.

This does not remove reading the stuffing resistors - it just removes
the assumption that they map to PROTO1 and EVT.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=compile all platforms

Change-Id: I2ba19fd52660559bfd1d8e3b8a9949e9b8abbddf
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61929
2013-07-16 12:06:30 -07:00
Vic Yang
a8cda83a27 spring: lower LED brightness to save power
Lower LED brightness:
  - Green:  0x80 -> 0x10
  - Yellow: 0x80 -> 0x40 (looks equivalently bright to green @ 0x10)
  - Red:    Not changed since it's an error condition

BUG=chrome-os-partner:20768
TEST=Build success
BRANCH=Spring

Original-Change-Id: Ib80b4f5c746163d98a09e21246ea97a6aeb2c054
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61672
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 1f6e5f8a1e074bd91acd3fc0b3de268495199c10)

Change-Id: I8f37cfa79d9fd30f503318e0913f4c12c1737219
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61852
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-15 14:11:13 -07:00
Randall Spangler
20e3309579 Remove fancy trickle charging logic
We implemented a fancy state machine for link to try and feed
almost-dead batteries smaller amounts of current than the charger
could normally supply, by dithering down the voltage to less than was
requested.  It's a lot simpler just to give the battery the smallest
non-zero amount of current we can give it at the voltage it asks for.

Remove the precharge code, since we won't use it on any future
platform and link has already branched.

BUG=chrome-os-partner:20881
BRANCH=none
TEST=find a really dead batery and try to charge it, or do what I did
     and just hack the battery module to lie about the requested values,
     and see that it always gets the minimum current step at the requested
     voltage.

Change-Id: I30bcb62bbe215abafb3a98c52e2afed3b74ead1a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61789
2013-07-15 14:10:45 -07:00
Dave Parker
92b62d1cd9 x86: Enable all wireless switches when going into S0
BUG=None
BRANCH=slippy,peppy,falco,wolf
TEST=Boot device and verify WLAN and WWAN enable GPIOs are active.

Change-Id: I1b488bc26ddbe50c570aefd8fcd3cdcb4d5b38d4
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61653
Commit-Queue: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-12 16:49:14 -07:00
Dave Parker
b2bc8aaa20 Basic G781 temp sensor support for Falco and Peppy.
This lets us read the internal and external temp values.
More functionality to come once we figure out what is
needed.

BUG=chrome-os-partner:20432
BRANCH=falco,peppy
TEST=run ec 'temps' command on Falco and Peppy.
Signed-off-by: Dave Parker <dparker@chromium.org>

Change-Id: I4f452f438e0a158dc8b34901e3faad3ce36d28b2
Reviewed-on: https://gerrit.chromium.org/gerrit/60145
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Commit-Queue: Dave Parker <dparker@chromium.org>
Tested-by: Dave Parker <dparker@chromium.org>
2013-07-11 22:32:52 -07:00
Randall Spangler
eb8920c939 Split wireless power/radio control out of switch.c
Chipset control of wireless power uses the new API instead of overriding
the wireless power itself.

Refactor board-specific support for it to just a few config #defines
instead of board-specific functions.  This makes some assumptions
about the polarity of the enable signals.  Not making those
assumptions would require defining an array of structs or some other
heavier-weight board-specific info.  Since the assumptions hold for
all current boards, let's make them now because this is a step in the
right direction, and reserve doing something more general until we
actually have a use case for it (so we build in just the flexibility
we need).

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms; see that link wifi turns on at boot and off at
     shutdown (verify via 'gpioget' from EC console)

Change-Id: Ic036e76158198d2d5e3dd244c3c7b9b1e8d62982
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61608
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-07-11 16:51:40 -07:00