Commit Graph

742 Commits

Author SHA1 Message Date
Vic Yang
c6e5d592cb Add LP5562 functions to control engine execution state
This gives us better control over the execution state of lighting
engine.

BUG=chromium:233832
TEST=Build success
BRANCH=spring

Change-Id: Ibfa86be0eef2b7dff8495f770649577295d4cb6f
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48773
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-23 10:39:13 -07:00
Vic Yang
4d96bf649d Unify lid switch GPIO name
Link uses LID_SWITCH_L but it means the same thing as LID_OPEN. Changing
it to LID_OPEN so that all boards use the same name.

No functional changes, just renaming.

BUG=chrome-os-partner:18343
TEST=build link, bds
BRANCH=none

Change-Id: I74893e1365ad3068f13e7fe948f1a54c6c6301bb
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48893
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-04-23 10:39:10 -07:00
Vic Yang
2dd01e59ea Software flow control in console
This adds software flow control handling (a.k.a X-on/X-off). When Ctrl-Q
is received, UART transmitting is paused until Ctrl-S is received. If
the FIFO or buffer fill up during this period, console output is lost.

BUG=chrome-os-partner:18680
TEST=Press Ctrl-Q and see console stopped. Press Ctrl-S and see buffered
messages.
BRANCH=spring

Change-Id: I9ce1198a1119dadc558bb522c48037bb83bba415
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48887
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-04-23 10:39:09 -07:00
Bill Richardson
4d0c4b1a53 Increase EC low-battery threshold to 14% to match kernel
There is a 4% difference between the kernel's view of battery level and the
actual battery level, to give userspace a chance to shut down cleanly. The
EC should turn the lightbar red when the battery drops below 10%, so this
change makes that happen when the kernel says it's 10%, instead of the real
10%.

Note: We don't have to cherry-pick this to the Link branch. Although it
affects the EC, we already patch the EC lightbar parameters at boot and
that's done in userspace.

BUG=chromium:225500
BRANCH=none
TEST=manual

Unplug Link, let the battery run down. The lightbar should pulse red when
the battery level reported by the UI drops to 9% (there may be a little
delay due to rounding). Note that it's only red when on battery.

Change-Id: If3d335c54ceb37c86da59e4a66f8ecd46ce15664
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48904
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-04-23 10:39:09 -07:00
Randall Spangler
57b77a3a8f Active-low Link GPIOs end with _L, not n.
This is now consistent with other boards.

No functional changes, just renaming,

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build link, bds

Change-Id: Ifd7c1ec608ab61f5f66800e91803ffafe1d944b6
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48804
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-22 16:44:37 -07:00
Randall Spangler
dcb2425f45 Turn on 3.3V rail earlier in power sequence for pit
The 3.3V rails powers some of the buck supplies, so must be turned on
1ms after the 5V rail.

BUG=chrome-os-partner:18657
BRANCH=none
TEST=build pit, snow

Change-Id: I18a165744352ae375080824fecfeb56f6ac81a9c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48729
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-04-22 09:55:49 -07:00
Randall Spangler
5f18b03e1b PMIC_PWROK is active-high on pit
Add a function which handles translation of PWROK from logical level
to physical level.

Also implement chipset_force_shutdown() in gaia_power.c, so PMU code
doesn't need to know about PWROK physical level.

BUG=chrome-os-partner:18738
BRANCH=none
TEST=build all platforms; boot spring

Change-Id: I360266ef89b6ead49a633cd57b7530f791b04c9e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48251
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-16 14:55:13 -07:00
Randall Spangler
9844e82ca8 Remove _OFF from GPIO register macros
This is left over from when we had a pair of macros for each GPIO
register, one which concatenated its base address name and one which
took a base address.  Only the latter has survived, but its naming is
longer than it needs to be and isn't consistent with other register
banks (USART, TIM, etc.).

No code changes, just renaming macros.

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

Change-Id: I15a282fd01db2a25219970e28ce551d8dc80193f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48226
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-16 14:55:12 -07:00
Vic Yang
216bb93128 Fix flash tests
This merges flash_overwrite and flash_rw_erase to a single test binary.

BUG=chrome-os-partner:18598
TEST=Run on Spring
BRANCH=None

Change-Id: I1da7577cb5dc196178930dda3a07bb942d959866
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48090
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-04-15 20:40:02 -07:00
Randall Spangler
b9d0d9c60b Move gpio_get_name() to gpio_common.c
Its implementation is the same on all platforms.

No functional changes, just renaming/moving.

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

Change-Id: I78741c6587ea61e7ac8edae5a509502b7ab5078b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47898
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-11 15:38:08 -07:00
Vic Yang
4adcb45f2c Fix kb_deghost test
BUG=chrome-os-partner:18598
TEST=Run test on Spring
BRANCH=none

Change-Id: Ia95ba6144dbdac0ffe77f6aef9c4ed948de181d8
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47841
2013-04-11 11:29:32 -07:00
Randall Spangler
e5f4032866 Clean up USB external power module
Make internal APIs static, and remove board_ prefix for clarity.

Move TSU6721 calls from charger task to extpower_usb functions for
better encapsulation.

No functional changes, just moving code.  Yes, this will make
cherry-picking back from spring to TOT less convenient, but now the
code is more readable and it will make maintaining the PMU code easier
as we add boards.

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

Change-Id: I52b37e57fc8519859996a110b0503277c6f0bbc8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47657
2013-04-10 14:24:10 -07:00
Vic Yang
9aa3716ca0 Turn on/off 3.3V output properly
When the system is turned off and then back on, we need to re-enable
3.3V output from TPS65090. Also, when we see 5V input, we should shut
down 3.3V output and re-enable it when 5V input goes away.

BUG=chrome-os-partner:18186, chrome-os-partner:18482
TEST=Manual
BRANCH=spring

Change-Id: I0cf0597a60988cc9ec28282eea54908c81e5eabc
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47736
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-10 09:35:05 -07:00
Vic Yang
64ae15f3b3 Decouple gaia_power from keyscan task
This makes gaia_power.c compile when keyscan task is not present.

BUG=chrome-os-partner:18598
TEST=Build spring without keyscan task.
BRANCH=none

Change-Id: I70823fb562a2542d92929b9219d034216f636938
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47630
2013-04-10 01:08:43 -07:00
Randall Spangler
861d7d667d Rename usb_charging.c to extpower_usb.c and move to common/
This more clearly indicates what it does - it manages external power
supplied by USB.  This code will be common to multiple boards which
take power via USB, so it might as well move now.

No code changes, just moving the file.

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

Change-Id: Iae74122db38666bc346104a5096fa82df8cb0c19
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47656
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-09 14:47:28 -07:00
Vic Yang
54ea657965 Decouple keyboard MKBP code from key scan code
When unit testing, we may need to disable key scan task but leave
keyboard protocol code for testing.

Also fix a bug in determining if ENABLE flag is set.

BUG=chrome-os-partner:18598
TEST=Remove KEYSCAN task and build for spring.
BRANCH=none

Change-Id: I3b3adf1257e8446fd1f57bce50b4c7a029b1ce3b
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47539
2013-04-08 21:03:47 -07:00
Randall Spangler
303aef9e3f Rename onewire_led functions and constants
This removes overlap between onewire_led.c (LED on link cable) and
powerled.c (LED on snow power button), which had the same names but
did different things.

No functional changes, just renaming.

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

Change-Id: I711f1a7e4e5512d1923872cb0f19d64be153c7c5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47420
2013-04-05 14:28:49 -07:00
Randall Spangler
14adad27e8 Clean up board configuration
Board configuration interfaces are now defined in board_config.h, not
in every board.h file.

Tidied /alphabetized CONFIG defines.

No functional changes, just rearranging code.

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

Change-Id: I6196591784f8fa9ce6dfccd31891b679fb200063
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47419
2013-04-05 14:28:42 -07:00
Randall Spangler
765c50ef5f Move board hard reset code into tpschrome driver
Hard reset is done by shorting 3.3V to ground.  This is only really
necessary to work around the PMU's I2C engine getting into a weird /
uncommunicative state.

This should not make any functional changes; the code is behaving the
same way it did before.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build daisy, snow, spring

Change-Id: I0edbdfc11bd5f6643075ffc83f4df3e11fc14675
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47199
2013-04-05 11:28:51 -07:00
Randall Spangler
a3dcfd54ef Improve deferred function calls
1) Check vs. number of allowable deferred function calls is made at
link time.

2) Added a check for whether hook_call_deferred() has been made after
the start of calculating the time when the hook task should wake.  If
it has, go back and recalculate the wake time.  This works around a
race condition.

BUG=chrome-os-partner:18473
BRANCH=none
TEST=add a bunch of deferrable functions and recompile; generates a link error

Change-Id: Ie833e2a699c47b6702957ed67bf7d3925f2df099
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47266
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-04 16:32:27 -07:00
Todd Broch
af4d0fb297 Inhibit host interrupt for battery_key.
Battery key is used to signal to the host that USB charging status has
changed.  This virtual keystroke should not wake the device like
physical keystroke does.  Change still copies keystroke to the
keyboard fifo but bypasses sending host interrupt.

Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=spring
BUG=chrome-os-partner:18333
TEST=manual,

Scenario1:
  suspend device then plug/unplug USB charging.  Device doesn't wake.
  When resume 'cat /sys/class/power_supply/cros_ec-charger/online' is
  correct.

Scenario2:
  while true ; do
    cat /sys/class/power_supply/cros_ec-charger/online
  done

  plug/unplug USB charging and device online status changes in a
  timely manner

Change-Id: I8938798b30e70c0c5021405d4fc5da9ce398c311
Reviewed-on: https://gerrit.chromium.org/gerrit/47251
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
2013-04-04 16:32:20 -07:00
Randall Spangler
6d49e2660e Add common implementation for daisy/snow extpower_is_present
The implementations are identical for daisy and snow, so move to a
common file instead of having duplicate code in board.c

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build daisy, snow

Change-Id: I63597885607fd03b3bf87bcebf2146190b301f22
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47183
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-04-03 11:49:07 -07:00
Randall Spangler
9137686ebe Clean up board.c files
Just renaming functions and reordering #defines; no functional changes.

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

Change-Id: I90e9ea860110625012cd5fb99de966283ec82880
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47179
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-04-03 11:49:06 -07:00
Randall Spangler
bdd16f8206 Split lid switch code out of switch.c to its own file
This will allow ARM code to use the same lid switch code (in a subsequent CL).

BUG=chrome-os-partner:18343
BRANCH=none
TEST=open lid; system boots. close lid; system suspends.  open lid; resumes.

Change-Id: I83536a3ad24c4446dccf8a6b6e296756659070a8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47043
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-02 14:12:57 -07:00
Randall Spangler
50c53c0d54 Move enabling AC_PRESENT interrupt to extpower_gpio.c
The interrupt handler moved a while ago, but the code to enable the
interrupt at init-time didn't.  Fix that.

BUG=chrome-os-partner:18256
BRANCH=none
TEST=boot system.  unplug AC.  replug AC.  UI charging indicator should update.

Change-Id: Ie16aa7f6eb9e871a6e3e8ecf6733ecbdc883be0b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47041
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-02 14:12:56 -07:00
Randall Spangler
5966f22a8a Add support for calling deferred functions
This is a cleaner way of deferring work from interrupt-time to
task-time without requiring a task for each module which needs this.

Replaces/supersedes delayed hook notification, which didn't scale well
(since every function would have needed to be its own hook type).

BUG=chrome-os-partner:18473
BRANCH=none
TEST=boot system.  plug/unplug AC power; notifies the host properly

Change-Id: I50263fe1ce37e74c1ef8db3671379098997102ed
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46953
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-02 14:12:55 -07:00
Randall Spangler
97bf36c9d3 Add parse_bool() to centralize parsing boolean options
This way debug commands which previously took only yes/no or on/off or
enable/disable can take any of those options.

BUG=chrome-os-partner:18467
BRANCH=none
TEST=Try "on", "off", "yes", "no", "true", "false", "ena", "disable", for
each of the following commands:
  - ilim (spring)
  - pll (link)
  - power (spring/snow)
  - hcdebug (all)
  - kblog (link)
  - ksscan (all)
  - lp5562 (spring)

Change-Id: Ie8e0fae3775b1da711864bcba6682ba5e68a06f1
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46900
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-03-29 15:39:34 -07:00
Randall Spangler
c317992194 Rename charging task to CHARGER, charger_task
This makes the charging task name consistent across platform.

No functional changes, just renaming.

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

Change-Id: I348b31313f6604df2a05b474bdf6e0be7450c8c9
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46891
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-03-29 15:39:33 -07:00
Randall Spangler
49b9c0faa9 Rename I8042CMD task to KEYPROTO
Since it's really the keyboard protocol task, not just handling i8042
commands.  For consistency across keyboard protocols.

No functional changes, just renaming.

BUG=chrome-os-partner:18360
BRANCH=none
TEST=boot link and type on keyboard

Change-Id: I800a691a344f82bf582693cae865414b7d5d382a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46885
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-03-29 15:39:32 -07:00
Randall Spangler
c2b9d1d8c2 Merge typematic task info i8042cmd task
Getting rid of a task saves on RAM requirements.

BUG=chrome-os-partner:18360
BRANCH=none
TEST=boot link and hold a key down; see it repeat as expected

Change-Id: I1ae4dc486f6669d5ad15899202abef85b8c1e7e8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46826
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-03-29 11:40:36 -07:00
Randall Spangler
19ff62cbb0 Convert typematic task from countdown to deadline-based
This is in preparation for merging the typematic and i8042cmd tasks.
It also reduces the overhead of the typematic task during key-repeat;
previously, it woke up every millisecond to tick down.

BUG=chrome-os-partner:18360
BRANCH=none
TEST=boot link and hold a key down; see it repeat as expected

Change-Id: If6aee44ce7c746c8c1e68ed5cffced59fc575e4b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46806
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-03-29 11:40:35 -07:00
Randall Spangler
95a3a4107a Merge i8042.c into keyboard_8042.c
This is in preparation for cleaning up the 8042 protocol stack and
merging the typematic and i8042cmd tasks.

No functionality change, just shuffling code and renaming functions.

BUG=chrome-os-partner:18360
BRANCH=none
TEST=boot link and type on its keyboard

Change-Id: Iefc41cd5b8d18ac87830bff3080cfff92e9d10d2
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46805
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-03-29 11:40:35 -07:00
Randall Spangler
fe3ccdf70a Merge lm4 and stm32 implementations of keyboard_scan
Scanning is now performed identically on all platforms.  keyboard_scan
talks to chip-specific keyboard_raw on the bottom end, and 8042 or mkbp
keyboard protocol on the top end.

8042 can now take advantage of CONFIG_KEYBOARD_TEST to simulate scan results.

BUG=chrome-os-partner:18360
BRANCH=none
TEST=compile all boards; test keyboard on spring and link

1) Type on keyboard.  Should produce keystrokes.

2) At EC console:
    kbpress 3 7 1
    kbpress 3 7 0
Should produce 'r' keystroke(s); key repeat should kick in if you wait
a while between the commands.

3) Hold power button while typing.  Should not produce keystrokes.

4) Reboot with power+refresh+esc.  Should go to recovery mode.

5) While the system is up, alt+volup+R should reboot the AP.

Change-Id: I48e0bca15b869162672b5f54ffcb561f6fcf0f45
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46666
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-03-29 11:40:34 -07:00
Vic Yang
4311bc5ccf Initialize LP5562 power on init
On init, we should either explicitly power on or off LP5562 in case.

BUG=none
TEST=Manual
BRANCH=spring

Change-Id: I7e331349090f3383da19f840762fa4d72a1a054b
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46847
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-29 03:18:30 -07:00
Vincent Palatin
e2dd54288d tsu6721: accept new revision of the chip
We have new TSU6721 silicon with Version ID = 2,
so we need to accept 0x12 as Device ID.

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

BRANCH=spring
BUG=none
TEST=run on a board with the new silicon version and see that the
charger is properly detected.

Original-Change-Id: I12ea80b21a0d3abc5ce45856e9c9f9cdf8fd7e3e
Reviewed-on: https://gerrit.chromium.org/gerrit/46752
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 5838bd56096903eb3dec420fb0c3399fea52a870)

Change-Id: Id24e436e5900b6f4047a783cb4f50ca1a4344f29
Reviewed-on: https://gerrit.chromium.org/gerrit/46755
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-03-28 11:18:09 -07:00
Randall Spangler
c2b94fd184 Move files in preparation for merging keyboard_scan modules
This is part one of a series to merge the keyboard scan interface to
be common across all platforms.

This change just moves and renames files and APIs and removes some
read code, and sets up protocol-specific CONFIG options.  It makes the
next CL which actually merges keyboard scanning easier to parse.

BUG=chrome-os-partner:18360
BRANCH=none
TEST=compile all boards; test keyboard on spring and link

Change-Id: I815a40aae4e5d5f333b8501aff9656080533d913
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46549
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-03-27 11:35:20 -07:00
Randall Spangler
10ac310605 Move keyboard dimension and key constants to keyboard_config.h
These were previously duplicated between multiple keyboard_scan.c and
board.c files, and there were a bunch of different constants #defined
to be 13.

BUG=chrome-os-partner:18360
BRANCH=none
TEST=compile all boards; test keyboard on spring and link

Change-Id: I91bf9d56d2a56ff25ff307ff10883ca87b6937e5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46165
2013-03-22 11:24:29 -07:00
Vic Yang
cdb08e1221 Use timeout instead of retry count for pre-charging
Now that PMU task is waken not only by timer, we shouldn't depend on
retry count anymore. This moves pre-charging timeout to actually use
timestamp.

BUG=none
TEST=Remove battery and boot. See charge state goes to error after 15
seconds.
BRANCH=spring

Change-Id: Iff587bc824ffee93650184c14f1fc403d26ebc06
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45957
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-20 23:47:46 -07:00
Vic Yang
db20e7afde spring: keep AP off when battery level is too low
When battery level is too low, we want to keep the AP off even when a
power on event is received. Current threshold is set to 1 mAh.

Note that after this change, a board without a battery will need to wait
for 15 seconds before it can boot up.

BUG=chrome-os-partner:18318
TEST=Press power button and see power on event ignored. Charge battery
to over AP off threshold and check we can power on the system.
BRANCH=spring

Change-Id: If32a1935a69be102778bde7ad8976eea0921f87e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45825
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-20 23:47:40 -07:00
Randall Spangler
22ff9df913 Move battery LED code on spring to common
It's not board-specific, so move it out of board.c.

No functional changes; this is just moving code and renaming a few functions.

BUG=chrome-os-partner:18256
BRANCH=none
TEST=build spring

Change-Id: Ib004066aed93745cb0c96d3cb45d70b728545492
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45918
2013-03-20 17:42:04 -07:00
Randall Spangler
f8393fab2c Move gaia event handler declarations to gaia_power.h
This removes duplicated code in 3 different board.c files.

No functional changes, just moving declarations.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build daisy,spring,snow

Change-Id: Ie6266dca7d7d160e154fce1a09452e5cc9a1095c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45898
2013-03-20 17:42:03 -07:00
Randall Spangler
78b0e9863d Use chipset_reset() interface instead of system_warm_reboot()
We have a common chipset interface for performing a warm reset of the
AP, so move the implementation from system_warm_reboot() there.  (It
was never a system function anyway; system = EC+AP; chipset = AP)

No functional change; just renaming functions.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build daisy,snow,spring,mccroskey

Change-Id: Ibc2c5efced5660c4335cd1868470184397800acd
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45891
2013-03-20 15:23:29 -07:00
Randall Spangler
34e17d4c05 Move I2C arbitration to its own file
It's only board-specific in that we've only needed it on snow so far.
But by that logic, x86_power would be board specific because we've
only needed it on link.

No functionality change, just moving code between files and renaming
the interface to indicate it's not board-specific.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build daisy,snow,spring

Change-Id: I35debdaa71829d55a2fbc5d3c62b2aaf6e467633
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45879
2013-03-20 15:23:29 -07:00
Vic Yang
19920f1f74 spring: reset TSU6721 when Toad's ID changes
When Toad's ID changes, VBUS goes low for 10ms. This, however, is not
picked up by TSU6721 and thus we need to monitor VBUS and reset TSU6721
when necessary. By resetting TSU6721, we can force it to update device
type.

BUG=chrome-os-partner:18292
TEST=manual
BRANCH=spring

Change-Id: Ib96bbb0f101c8c5f5371591603af2dee27f01cc8
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45727
2013-03-20 01:02:09 -07:00
Vic Yang
6e07f94c90 spring: More stable battery LED control
This includes:
  - Discharging with AC present now recognized as battery assist mode
  - Trigger LED update every second instead of from PMU task
  - Minor breathing effect optimization
  - Control LED power and color from the same task to prevent
    simultaneous access to LED driver

BUG=chrome-os-partner:18244
TEST=Manual
BRANCH=spring

Change-Id: I9b34934f46cd4f04aaa7ca30cbe90316aec3e61e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45632
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-19 14:59:47 -07:00
Randall Spangler
a3c2a73226 Rename board_get_ac() to extpower_is_present()
Code cleanup; use the same function names to mean the same thing
across boards.  No functional changes; just renaming.

BUG=none
BRANCH=none
TEST=build daisy,snow,spring

Change-Id: Icbb4cfda5f5f9ba0cbbc07fee622e9c21af3f8cd
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45867
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: David James <davidjames@chromium.org>
2013-03-19 14:59:31 -07:00
Randall Spangler
9ddb7e0708 Rename tasks to HOOKS and CHIPSET
Rename tasks

TICK -> HOOKS
  The hooks task handles more than just the TICK hook now.

X86POWER -> CHIPSET
GAIAPOWER -> CHIPSET
  Kinda kludgy that the name of the task controls which chipset source gets
  included.  Change this to a CONFIG_CHIPSET_{X86,GAIA} #define to make it
  easier to support future chipsets.  Also, rename the task function to
  chipset_task() so ec.tasklist is chipset-agnostic.

No code changes, just renaming constants and functions.

BUG=none
BRANCH=none
TEST=build bds,link,daisy,snow,spring

Change-Id: I163ce1cd27b2d8d030d42bb1f7eb46b880c244fb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45805
2013-03-19 10:31:12 -07:00
ChromeOS Developer
6c285c0994 Move external power detect for link to its own file
Now that it doesn't need to leverage SWITCH_TASK to send the AC_CHANGE
notification, pure GPIO-based external power detection can move from
switch.c to its own file.

BUG=chrome-os-partner:18256
BRANCH=none
TEST=add AC power, UI shows charging indicator; remove AC, indicator goes away

Change-Id: Id495f34185b7d971c241ac6d0a8311a6bf544507
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45789
2013-03-19 10:31:12 -07:00
Randall Spangler
c196c66432 Call AC change hook from the hook task
Using code like this, modules which service interrupts and notify
hooks will no longer need to have their own tasks to call
hook_notify() from.  They can share the hook task as long as they
don't mind the notification possibly being deferred.

BUG=chrome-os-partner:18256
BRANCH=none
TEST=add AC power, UI shows charging indicator; remove AC, indicator goes away

Change-Id: I1bc32d21b2202c3242d39e0fc533198cd5bb9c66
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45780
2013-03-19 10:31:10 -07:00
Randall Spangler
05f496759f Add external power present flag to charge_get_flags()
Modules that need to find out about charge/power state no longer need
to use the lower-level switch API.

(This will matter more in future CLs which handle conditions like
"external power present, but at low power so we're doing battery
assist" - that can simply be state=discharging,flags=external_power_present.

BUG=chrome-os-partner:18256
BRANCH=none
TEST=add AC power, UI shows charging indicator; remove AC, indicator goes away

Change-Id: I62130a4e089297fa47ab03f6a76082593c936761
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45515
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-03-15 09:07:58 -07:00