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>
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
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>
Code cleanup: declare keyboard_scan_interrupt() once, not per board;
the implementation is common anyway.
No functional changes; just renaming.
BUG=none
BRANCH=none
TEST=build daisy,snow,spring,mccrosskey
Change-Id: I1e33cbe2c868bc47b641d36d26f07c3b5a7ba3c7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45874
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
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>
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
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
Push the PWM frequency outside the audio band to avoid audible whining.
Also fix the off-by-one in the PWM frequency computation.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=spring
BUG=chrome-os-partner:17583
TEST=manual : probe the PWM output with a scope.
Change-Id: Ie1c8c5aed72bef46c8bac16c1bf3007e8e9573bb
Reviewed-on: https://gerrit.chromium.org/gerrit/45584
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
No code changes, just renaming to make the filename more useful.
BUG=chromium-os:18256
BRANCH=none
TEST=build link. Plug in AC. See plug LED come on.
Change-Id: I00d9f222de0b097bb68ef235bc6b0015e4c62f7e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45494
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
When leaving breathing mode, we should switch yellow LED from lighting
engine back to PWM control.
BUG=chrome-os-partner:18244
TEST=Check yellow LED leaves breathing mode
BRANCH=spring
Change-Id: I39260ac9040baaf193ce95eec7941aeb6d97e7e8
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45436
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This adds a board target for McCroskey. It is loosely based on
Snow.
The clock will be set up differently and the keyboard GPIOs are
not the same, so some stm32 code needed to be updated.
BUG=none
BRANCH=none
TEST=tested on McCroskey (we get to the serial console)
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Change-Id: I5e11a3257fed1797f4cc4dcccf3530585b78da82
Reviewed-on: https://gerrit.chromium.org/gerrit/43414
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
This CL moves the keyboard port listing to board.h for each mainboard
to reduce board-specific clutter in keyboard_scan.c. Since the info
is now exposed outside of keyboard_scan.c, a more descriptive name was
chosen.
Note: GPIO_D does not need to be included in this list for any current
platform.
BUG=none
BRANCH=none
Test=tested on Snow by pressing all number and letter keys
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Change-Id: I1ce924a41cafae557467997ecba9c5abeed86211
Reviewed-on: https://gerrit.chromium.org/gerrit/45284
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
In order to update charger status we have added a virtual keystroke to
signal change to the kernel via the MKBP interface.
CL creates the virtual key press and calls it from within the
USB charging code.
Signed-off-by: Todd Broch <tbroch@chromium.org>
BUG=chrome-os-partner:17927
BRANCH=spring
TEST=manual
1. Compile for daisy,snow,spring.
2. Test on spring.
Change-Id: I0afa0fc82c96fa3fd8119523a113b5028c8f64a3
Reviewed-on: https://gerrit.chromium.org/gerrit/45126
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
This moves KB_INPUTS from keyboard_scan.c to board.h where KB_OUTPUTS
is #defined. Although we use the same 13x8 keyboard matrix on all
platforms, KB_OUTPUTS is defined on a per-board basis due to its usage
in keyboard_test.
BUG=none
BRANCH=none
TEST=locally compiled
Change-Id: I0d66705d2959c7824b96cc8aae55368eca39a21a
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44970
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This enables the EC to switch the signals to ANX7808 properly.
BUG=chrome-os-partner:18165
TEST=Manual on reworked Spring board
BRANCH=none
Change-Id: Ib3ff57e17afab9ba8fc78fdb037e65aae844f38b
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44897
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
To avoid AC bad condition when system load suddenly increase, we should:
- Keep VBUS voltage at reasonable level on battery assist
- Allow PWM to bring VBUS voltage up before asserting AC bad
BUG=chrome-os-partner:14319
TEST=Manual
BRANCH=none
Change-Id: I8058ffba9f91550f22408ea25911a1dded835584
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44612
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Measurement result for aggressive mode looks good. Let's switch to it by
default.
BUG=chrome-os-partner:14319
TEST=Boot and check current limit mode.
BRANCH=none
Change-Id: I117170aaea8c3a3304dc27815ffb429fff2f22c7
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44607
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
When in battery assit mode, show breathing yellow on battery LED slowly
to indicate battery is actually discharging.
BUG=chrome-os-partner:17561
TEST=Manual
BRANCH=none
Change-Id: I688470d8870b181bf2dd20b5ebcbd6e2d861c5b0
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44514
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
We should allow a minimum amount of current input in case the
battery is dead.
BUG=chrome-os-partner:14319
TEST=Boot with a dead battery
BRANCH=none
Change-Id: I3c172d43c8190ed2dc5d421dcf2b5aaf0e88ecd9
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44510
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
To decrease the amount of time needed for PMU ADC reads, add the option
to keep the ADC reference voltage enable as its stabilization time is
the longest pole.
Also set the stabilization time to 10ms as the max defined in the
datasheet.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=chrome-os-partner:17997
TEST=on Spring, measure EC_CMD_POWER_INFO latency and see it going from
49ms to 18ms.
Change-Id: I7ed20bcddab165250108eb9f768539b19fa251de
Reviewed-on: https://gerrit.chromium.org/gerrit/44008
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Currently we stop raising current input when a predefined limit is
reached. To take advantage of high power charger, we now push the limit
and detect over current shut off if any. This allows us to detect the
actual current limit of the charger.
BUG=chrome-os-partner:14319
TEST=Manual on Spring
BRANCH=none
Change-Id: I5aefd8c0ac02bd0ca9920e861a4fa62fc6e588e5
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43863
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
When powered device is removed, VBUS is still powered by the AP. We
should turn off power from AP and let it settle before we sense external
VBUS input.
BUG=chrome-os-partner:14319
TEST=Manual on Spring
BRANCH=none
Change-Id: Ie868a3df27e395c948ba8c6342e84764d182ce82
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43779
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Fine tune current limit and voltage threshold so that we don't hit
current limit so easily.
BUG=chrome-os-partner:14319
TEST=Manual on Spring
BRANCH=None
Change-Id: Ia9ccd13b9e7eac7cdee83d0f488a1a83c27318c0
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43716
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
The VBUS power from AP is now incorrectly recognized as AC source. Let's
gate this with device type and BOOST_EN.
BUG=chrome-os-partner:14319
TEST=Manual
BRANCH=None
Change-Id: Id8127ab6f85fb25adfadb1c2bef4c753a58cdc4f
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43709
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This tweaks initial PWM configuration so that:
- When battery is dead, more current is allowed to sustain the system.
- When EC boots with a low power charger, input current is throttled
so as not to kill the charger.
BUG=chrome-os-partner:14319
TEST=Manual
BRANCH=none
Change-Id: Ib52894b07fecdd533aecab312f40afa0b6df5676
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43600
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This monitors input voltage and adjust current limit accordingly to keep
voltage in acceptable range.
BUG=chrome-os-partner:17881
TEST=Manual on spring
BRANCH=none
Change-Id: Ie4b44844983f622ef7f648cf022c3c093597246c
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43511
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Getting voltage and current can be handy when verifying hardware design.
Let's add host command to do this.
BUG=chrome-os-partner:17880
TEST=Manual on Spring
BRANCH=none
Change-Id: I4d4f6a42a9d0f917292d092e132ccd9ce3367fd6
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43508
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
The kernel driver to control the 3G modem LDO is not submitted yet.
Let's hardcode it for now to enable RF testing and revert this patch
later.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=chrome-os-partner:17790
TEST=on Spring, boot and dump the TPS65090 configuration from the EC
command line by using "pmu" command.
See 0x1f in the register 0x11 for FET3.
Change-Id: I29aa7d1d7fb819ff1881a756e9592e272e87ad0b
Reviewed-on: https://gerrit.chromium.org/gerrit/43181
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
This uses D+/D- voltage to distinguish different Apple chargers.
BUG=chrome-os-partner:14319
TEST=Manual on Spring
BRANCH=none
Change-Id: I50075d466f6e6b1adf613748cf433d7f43c04bfe
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42850
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
When battery is nearly full, we sometimes see:
- Battery asks for no current, but slowly discharge (5-7 mA)
- Battery asks for current, but not charging.
For these cases, we consider the battery full and show green LED.
BUG=chrome-os-partner:17561
TEST=Manual
BRANCH=none
Change-Id: I2808d4c1a89d37000244fb308197cdef473ec5be
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42688
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
BUG=chrome-os-partner:14319
TEST=Attach different chargers and see corresponding PWM duty cycle set.
BRANCH=none
Change-Id: I10c6e28ddf5a959849a6f14d9ca3894be4f16e30
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42691
This implements a basic battery LED policy:
- Charged: green
- Charging: yellow
- Error: red
- No charger: off
BUG=chrome-os-partner:17561
TEST=Manual
BRANCH=none
Change-Id: I7fa8242efa4d0382d8ef0cafe80f01d44c390397
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42607
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Activate the pass-through for TPSchrome LDOs settings
and remove hard-coded values used for bring-up.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=chrome-os-partner:14314
TEST=on Spring, with an updated bootloader, see the screen is still
coming up.
Change-Id: I7fe67640e66939b1a19074b54d81d64459a34f4a
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/41296
Reviewed-by: Vic Yang <victoryang@chromium.org>