This changes current TASK() syntax to TASK_BASE() and TASK_NORMAL(),
where TASK_BASE is necessary for the EC to boot on a board and
TASK_NORMAL represents the task that can be removed in a test binary.
Tasks introduced by a test should be listed as TASK_TEST().
Note that this CL breaks current tests (many of them are broken anyway),
which will be fixed in up coming CLs.
BUG=chrome-os-partner:18598
TEST=Build link/bds/spring/snow/daisy/mccroskey. (mccroskey failed for
unrelated issue)
BRANCH=none
Change-Id: Ic645cdae0906ed21dc473553f1f43c2537ec4bb9
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47531
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
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>
There's no chipset for mccroskey, so its keyboard code stopped compiling.
BUG=chrome-os-partner:18343
BRANCH=none
TEST=build mccroskey, spring, link
Change-Id: If94dfaf2819f047a6aa825ee10aa1d320c8ca882
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47566
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
GPIO mapping is correct for current schematics.
Things to fix are #ifdef'd out with PORT_TO_PIT, but those require
changing other files (which is most tidily done in separate CLs).
BUG=chrome-os-partner:18657
BRANCH=pit
TEST=build pit (can't test the binary yet; no hardware)
Change-Id: Id1d1bb0c2925cfc0c21ee2d91666028aa6d2a707
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47599
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
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
Much of the board init duplicated stuff already done in gpio init, so remove it.
Powering the SPI module should be done in spi.c, not board.c.
BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms; boot EC on daisy
Change-Id: I9a99eeeb971ebbf7de5b9c0548153684fbb7fff6
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47469
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
And remove the daisy power button LED task for now. Since daisy
didn't have a board.c implementation (or a power button LED), its
power LED task did nothing.
BUG=chrome-os-partner:18343
BRANCH=none
TEST=build daisy, snow, spring
Change-Id: I1eb3d0bd038d88685e7caad087eb1a1d1495ef9a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47442
Reviewed-by: Vic Yang <victoryang@chromium.org>
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
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
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
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>
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>
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>
There's no need for it to be initalized in board_init(); it just needs
to be done before ADC / I2C / SPI initialize.
BUG=chrome-os-partner:18343
BRANCH=none
TEST=boot spring; verify EC communication and 'adc' console command still work
Change-Id: I6039848fe031222d5ca59b459adfe18fc3e8ef08
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47182
Reviewed-by: Vic Yang <victoryang@chromium.org>
This is useful for debugging and the factory.
BUG=chrome-os-partner:18530
TEST=On spring, check we can set PWM duty cycle and can go back to
automatic control.
BRANCH=spring
Change-Id: I3da75f0a356cc0f21d748bf135e3b95fbd9c465b
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47105
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
When we detect over current event, it might be a genuine over current
event or the user messing with the charger. Let's add retry machinism to
reduce the probability that a user re-plugging adapter causes charging
current to be limited.
BUG=chrome-os-partner:18527
TEST=Manual
BRANCH=spring
Change-Id: I2b55a9eae39c56ada929e167cf09c4e91a32a55e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47107
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This was left over from the way we reported keyboard recovery early in
link/snow, before we had host events. No shipping EC ever reported it.
Coreboot and u-boot look for this flag, so we can't repurpose it until
they ignore it too.
BUG=chrome-os-partner:18512
BRANCH=none
TEST=compile link,spring
Change-Id: I38fbf0fa7d958c3774c8b293d4be25faaecdadea
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47058
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
This mode was disabled initially to make sure it didn't side-effect
things during early development. Now that branch is cut lets
re-enable and backport when stability is proven.
Signed-off-by: Todd Broch <tbroch@chromium.org>
BRANCH=spring
BUG=chrome-os-partner:17587
TEST=manual, install & run on Spring ... system functions.
When device is plugged stays awake regardless of battery state.
When device is unplugged sleeps and power is saved.
When device is re-plugged awakes.
Change-Id: I9a85fa7376d1a94c9864beed3d053e8b49480959
Reviewed-on: https://gerrit.chromium.org/gerrit/45594
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
This more closely emulates what LM4 does if it hibernates and then
immediately wakes. Keeps the system from becoming silently
unresponsive if a hibernate is triggered on STM32.
BUG=chrome-os-partner:18371
BRANCH=none
TEST=from ec console, 'hibernate' reboots instead of hanging
Change-Id: I031f79239725d69ba054323e4fbf8f59133f2093
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46286
Reviewed-by: Vic Yang <victoryang@chromium.org>
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
This is the low-level platform-dependent interface to drive keyboard
columns, read rows, and handle keyboard interrupts.
Both lm4 and stm32 had something like this before, but the interfaces
weren't fully explicit or compatible.
BUG=chrome-os-partner:18360
BRANCH=none
TEST=manual
- Build all platforms.
- Boot system and test typing on keyboard.
- Hold power+refresh+esc to test boot key detection; should go to recovery.
Change-Id: Ie3bcc1d066a4da5204f0e236daeb52c4064a6213
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46156
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>
No functionality change.
This includes:
- Breaking the way-too-long function into multiple functions
- Less verbose logging code
BUG=none
TEST=Build and check USB charging still works.
BRANCH=spring
Change-Id: I8524cb3da9a0e90427664e839ce33d3abe0263a0
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45842
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
When AP is off and no charger is attached, we can safely disable boost
to save power.
BUG=chrome-os-partner:18305
TEST=1. AP off, no charger -> BOOST_EN 0
2. AP off, with charger -> BOOST_EN 1
3. AP on, no charger -> BOOST_EN 1
4. AP on, with charger -> BOOST_EN 1
5. AP on->off, no charger -> BOOST_EN 1->0
6. AP off->on, no charger -> BOOST_EN 0->1
BRANCH=spring
Change-Id: I7ff49e51057126490d09a3f0b1be2c60ca6a9bd3
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45830
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
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>
The implementation is identical on all stm32 hardware, so remove all
the duplicate copies from board.c files. mccrosskey doesn't have
GPIO_EC_INT so stub it out like we do on bds.
No functional change, just moving code.
BUG=none
BRANCH=none
TEST=build mccrosskey,daisy,snow,spring
Change-Id: I7d4378650d7b4c640c15180c41459a41620f5bd3
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45920
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
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
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
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
Apparently the presubmit queue isn't building Spring firmware? My
change and Vic's collided and TOT doesn't compile. This fixes it.
BUG=none
BRANCH=none
TEST=build spring
Change-Id: I3903c7dce741d4395d0d71585da4332b47f62aba
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45901
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>