Change pd_transmit() to wait specifically for the TX complete
event using task_wait_event_mask(). This fixes a bug that if
another event, it will now restore that event instead of
consuming it.
BUG=chrome-os-partner:40920, chrome-os-partner:41290
BRANCH=smaug
TEST=load onto glados and zinger and attach them a bunch of
times and get stable contract with no hard resets.
Change-Id: I36514ea45b5e2b5fd42acdad94e5786da5bd90b6
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276745
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Add task_wait_event_mask() function to core/cortex-m0, core/host
and board/zinger/runtime in order to delay a task until a specific
event occurs.
BUG=none
BRANCH=smaug
TEST=make -j buildall
Change-Id: Ic89487fcae5352eec53b745179c7f0d5893ad3e0
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276744
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
The in_stream and out_stream interfaces were a first attempt
at providing an abstraction for multiple stream like devices
(usart, USB, I2C/LPC host interfaces...). But, by baking
the queue into the device it proved to be hard to use and
required additional resources (task or deferred hook) to handle
passing data from one stream to another.
Since then the queue policy and producer/consumer interfaces
have replaced the stream interfaces. This CL removes the old
stream interfaces and updates the only users (deleting the
test echo code from the discovery-stm32f072 board and updating
the mcdp28x0 driver to use the queue interfaces).
Signed-off-by: Anton Staaf <robotboy@chromium.org>
BRANCH=None
BUG=None
TEST=make buildall -j
Change-Id: Ic0d2abf81eafc4fb2e61172540151f2d0ba45caf
Reviewed-on: https://chromium-review.googlesource.com/276163
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
According to the datasheet, PIN should not be set in the CTRL register.
BUG=none
TEST=Verify with I2C analyzer that no error is observed.
BRANCH=none
Change-Id: Ifed58b413151b40ed951cb71b1164432fea28eca
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/276672
Reviewed-by: Shawn N <shawnn@chromium.org>
Add battery cutoff functionality to glados.
BUG=none
BRANCH=none
TEST=use console cutoff command to verify that it cuts off
battery and plug in zinger to verify that it comes out of it
when AC is applied.
Change-Id: I71ae113c398278ad9f67f3a4cedf6885754a5a72
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276690
Reviewed-by: Rong Chang <rongchang@chromium.org>
Move the task responsible for detection of USB chargers to common code
to reduce code duplication.
BUG=chrome-os-partner:40920
TEST=Manual on samus_pd. Plug USB charger, verify detection is correct
on both charge ports.
BRANCH=None
Change-Id: I362f8b5b51741509e459c66928131f1f6d2a3b1d
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276210
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Change battery temperature ADC into an input with a
pull-up and use it for battery detection.
BUG=none
BRANCH=none
TEST=boot with and without battery and check gpio
accurately reflects battery status.
Change-Id: Id30a6c2d7eaad2e6f3c69be4bab33dbcf0682e29
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276650
Reviewed-by: Rong Chang <rongchang@chromium.org>
Per discussion in CL:274728, hardware revision numbers are integer. So
the previous rev1.5 becomes rev2. And the previous rev2 is now rev3.
BRANCH=none
BUG=none
TEST=none
Change-Id: Ic7a1a60ce0b17a3469965cdca99332df0243ce2a
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276577
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Now that we've removed boards from ToT, also delete board-specific
code used only by the removed boards.
There are still more things to remove (unused charging chips, LED
drivers, COMx support). More CLs coming.
BUG=chromium:493866
BRANCH=none
TEST=make buildall -j
Change-Id: Ie6bdeaf96e61cadd77e3f6336c73b9b54ff4eabb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276524
Reviewed-by: Alec Berg <alecaberg@chromium.org>
When EC boots up on type-C port 1 VBUS power, it shouldn't turn off
CHARGE_L control.
BRANCH=none
BUG=chrome-os-partner:41167
TEST=manual
remove battery, plug type-C charger to port 1.
check charging LED.
Change-Id: I360715b2f81df5eba0901b854d2dd8e2f0a23651
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276589
Reviewed-by: Alec Berg <alecaberg@chromium.org>
This change continues porting CL:275686 to oak. Since oak didn't connect
VBUS wake signals to EC, it checks Pericom BC1.2 status on initialize VBUS
suppliers.
BRANCH=none
BUG=chrome-os-partner:41167
TEST=none
Change-Id: Idbc7032329f7c46aee8f35c3fdd1e8e4aa9c001c
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276587
Reviewed-by: Alec Berg <alecaberg@chromium.org>
This CL copies CL:275686 that enables charge manager to handle charging
on two ports.
Since oak has the same PD design, so both CHARGE_L controls need to be
enabled to detect VBUS when no charger is plugged in. That means if
you set chgoverride -1, this actually enable charging on both ports.
BRANCH=none
BUG=chrome-os-partner:41167
TEST=manual
plug in zinger and donette onto both ports. verify that we charge from
the first one plugged in.
Change-Id: If5ed360e55f6c6b1a0315a68a5a6d924ae856c6d
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/275853
Reviewed-by: Alec Berg <alecaberg@chromium.org>
This change syncs oak with glados change CL:275296.
BRANCH=none
BUG=chrome-os-partner:41167
TEST=manual
load on oak and plug zinger in both ports many times.
Change-Id: Idc00a50c2d7b7a865e70762e91b2e7a82c6e6896
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/275852
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Port CL:275072 to oak. Oak rev1 and rev1.5 type-C VBUS input controls
are connected to PD phy instead of EC. This change wakes both USB PD
task to handle power status change. This issue will be fixed in next
hardware revision, or enable TCPC power status alert.
BRANCH=none
BUG=chrome-os-partner:41167
BUG=chrome-os-partner:41226
TEST=manual
plug type-C charger into port 1
Change-Id: Ifea19276d0eb74f3e4cac509abece362e6e8af17
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/275851
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
hdctools adds an alias ec_boot_mode and remaps spi1_vref with onoff
control. This change switches ARM systems with STM32 EC from
spi1_vref:pp3300 to ec_boot_mode:on.
CQ-DEPEND=CL:275251
BRANCH=none
BUG=chrome-os-partner:40479
TEST=manual
cd ~/trunk/platform/ec
util/flash_ec --board oak --image oak_ec.bin
util/flash_ec --board oak_pd --image oak_pd.bin
Change-Id: I0f3a74eaa7fc937d1372cd51124c6b3d23351581
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/274770
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Move control of CHARGE_EN from the PD state machine, where it
was tied to our CC termination value, to charge manager when
charge manager sets the active charge port. This allows ryu
to charge from debug accessory where we advertise Rp but still
want to charge.
BUG=none
BRANCH=smaug
TEST=load onto ryu and plug in zinger, hoho, and suzyQ and make
sure we negotiate a contract with PD partners, and that we
charge from power supplies.
Change-Id: I81d9997c011eac6d5136fca8e97a5da3470a8e8a
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276543
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Enable charging through debug accessory by setting input
current limit to 3A when debug accessory is detected.
Add new dual-role toggling state for stay sink unless VBUS
is detected, which allows us to detect debug accessory
when we are not normally dual-role toggling.
BUG=none
BRANCH=smaug
TEST=plug suzyQ into ryu in S0 and in S5 and make sure that
we go to the SRC_ACCESSORY state and set charger input
current limit appropriately.
Change-Id: I6262c9d6cd0ae7159f343d36e19d290c2f2e0181
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276368
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Change charging workaround on glados to limit the max input voltage
to 5V. This provides more reliable charging by reducing the noise
on the i2c bus to battery and charger. Note, this limits charging
power to 15W.
BUG=none
BRANCH=none
TEST=load onto 3 different glados boards and charge for 10 minutes
with no i2c errors causing charging to stop.
Change-Id: I4d67b62a18cf40d645b132081a431f9ce187168b
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276366
Reviewed-by: Shawn N <shawnn@chromium.org>
Add queue_peek_memcpy to peek at queue and move the element using
specific memcpy function.
Also change memcpy prototype argument from void const * to const void*.
BUG=none
BRANCH=none
TEST=Compile and use.
Change-Id: I8c582563e7d204ee5568637f819d63404624faf6
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/274226
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Anton Staaf <robotboy@chromium.org>
Add workaround to limit the max input current to 1.5A due to
i2c communication problems at higher currents. Note that this
max should be removed when possible.
This introduces a new CONFIG option to define the maximum input
current limit for a board, as opposed to the already existing
default input current limit.
BUG=none
BRANCH=none
TEST=load on glados, charge with zinger, make sure input current
is set to 1.5A and no recurring i2c errors talking to battery
and charger.
Change-Id: Ib7070772e1bf5475e98a2dc946ae75bf08047b70
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276169
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
ISL9237 is a buck-boost narrow output voltage DC charger. This change
provides interfaces to satisfy external dependencies for
charge_state_v2.
ISL9237's charging voltage control is different from smart battery
chargers. And there's no SBC compatible charging mode and status. So
this CL modified charger_set_voltage() behavior by controlling VSYS
voltage.
BRANCH=none
BUG=none
TEST=ran on reworked glados
Signed-off-by: Rong Chang <rongchang@chromium.org>
Change-Id: Ibbbf805bbbe1ee06f87a41cde3e39acbf2e105b4
Reviewed-on: https://chromium-review.googlesource.com/272882
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Aaron Durbin <adurbin@chromium.org>
Trybot-Ready: Aaron Durbin <adurbin@chromium.org>
Tested-by: Aaron Durbin <adurbin@chromium.org>
Enable CONFIG_CHARGE_MANAGER to handle charging on two ports.
For now, we only use the type-C pull-up supplier and the PD supplier.
This adds Pericom BC1.2 suppliers as well even though we aren't
using them.
Currently, on Glados, we can't detect VBUS unless charge_en GPIO is
asserted. This means, when no charger is plugged in, we must have
both ports enabled. And when one charger is plugged in, we must
disable the other port. Practically, this means we always charge
from first charger plugged in since we can't detect the second one.
And, this means that if you do chgoverride -1, which normally stops
charging, this will actually enable charging on both ports.
BUG=chrome-os-partner:40920
BRANCH=none
TEST=load onto glados and plug in zinger and donette onto both
ports. verify that we always charge from first charger plugged in.
plug in hoho to either port and make sure it gets VBUS.
Change-Id: Ia5d5725ee86b25f6fec0f276d4c471f533c81112
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/275686
Reviewed-by: Shawn N <shawnn@chromium.org>
Enable ADC channels on Glados. For now only VBUS is scaled
accurately into mV, the rest are ADC counts.
BUG=none
BRANCH=none
TEST="adc" from EC console and verify VBUS measurement matches
for zinger at 20V and donette at 5V.
Change-Id: I1af70df5b851ba654c8feb7c97d190d393421a29
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/275685
Reviewed-by: Shawn N <shawnn@chromium.org>
Use the PDCMD task to handle PD MCU interrupts, and use it
to trigger the tcpc_alert().
Note this fixes bug on Glados and Oak that could cause watchdog
reset because tcpc_alert() which uses i2c to talk to tcpc was
called from hooks task and can delay tickling watchdog.
BUG=chrome-os-partner:40920
BRANCH=none
TEST=load on glados and plug zinger into both ports many times.
make sure we get a stable contract and no watchdog reset.
Change-Id: I37625fae2ca0057d2ee8fa1eea6974f2d26d1b91
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/275296
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
This is needed to allow cleanup and refactoring of the EC codebase in
ToT. All of these boards use firmware from branches and uploaded to
BCS, so they don't actually care that ToT can't build their firmware.
BUG=chromium:493866
TEST=build on the following using cbuildbot:
daisy-paladin
falco-paladin
link-paladin
nyan-paladin
peppy-paladin
samus-paladin
squawks-paladin
daisy_spring-paladin
CQ-DEPEND=CL:274121,CL:274127
BRANCH=none
Change-Id: I19598843755ded7b2385cc712ef463e5de4411b8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/274121
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
sysjump could happen anytime during an I2C transaction. After sysjump and EC
reset, I2C pin will be programmed back as GPIO instead of alternate function,
which will cause the I2C transacation to failed.
MEC1322 I2C also depends on interrupt to handle the I2C transaction, however,
sysjump will disable interrupt, which will cause watchdog timeout/reset since
interupt for I2C transaction are disabled.
BUG=none
TEST=After "sysjump <RO/RW>", "i2cscan" is functional and no watchdog reset.
BRANCH=none
Change-Id: I181084822f0769173c724e48afb59d7099fa1566
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/273710
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alexandru Stan <amstan@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Divya Jyothi <divya.jyothi@intel.com>
Commit-Queue: Divya Jyothi <divya.jyothi@intel.com>
Add USB PD support for port 1 (on the flex cable).
BUG=chrome-os-partner:40920
BRANCH=none
TEST=load onto glados and test zinger and hoho in both
polarities on both ports and verify PD contract established.
Change-Id: Ib7ac2e630c0a8f278c8b74c348cc6dc7183f53ec
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/275072
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This enables the USB blob interface. Due to partner issue 40693,
we have to disable one of the other interfaces, instead of just
adding this one.
BUG=chrome-os-partner:40969
BRANCH=none
TEST=make buildall
Also, connect to the Cr50 via USB and run
cd extra/usb_console
make
./usb_console -p 5014 -e 1
Strings typed into this application will be case-swapped and
returned.
Change-Id: If94006490ec9c6033e8520297aa42ed623d4daf6
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/275132
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
This adds a new task and endpoints to handle large opaque (to the
USB) chunks of data. The expected use case is that the USB
endpoint accepts bytes from the host and passes them blindly to
the blob-handling task. At some point, the blob-handling task may
wish to send bytes back to the host. What those bytes are and
what they mean is determined at higher levels of abstraction.
BUG=chrome-os-partner:40969
BRANCH=none
TEST=make buildall
This CL doesn't enable the blob-handler; it just makes it
available. The next CL will enable and test it.
Change-Id: I6eba8e8010466e71efe9c5e06848b9f403df835f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/275131
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Holding the power button is currently the best known way to bring the AP
back to a state where it is shutdown and not powered.
BUG=chrome-os-partner:40826, chrome-os-partner:40677
TEST=Run `apshutdown` on glados, verify that power state machine transitions
to G3 after several seconds. Run `powerbtn`, verify that state machine
transitions back to S0.
BRANCH=None
Change-Id: Ia799c5f199127f31bd24907b93946c6289d381f8
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/275060
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Ensure that we put a proper start bit if the transfer only contains a
read but has the start flag set.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=smaug
BUG=chrome-os-partner:40919
TEST=On Smaug (P6), at the Linux prompt, do
"cat /sys/class/power_supply/bq27742-0/current_now" and see a proper
value rather than an error.
Change-Id: I10cc9907476b3cfb006f2c1540688139366c9195
Reviewed-on: https://chromium-review.googlesource.com/275079
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Puthikorn Voravootivat <puthik@chromium.org>
Charger task is overflowing and causing crash.
Increased charger task stack size by 128 bytes.
Also increased console/hook by 128 bytes as these
are also close to its limit.
BRANCH=None
BUG=chrome-os-partner:40766
TEST=1.Program EC image.
2. Run various tests to verify charger stack doesn't
overflow.
Change-Id: I6e350584508fa3a47769982b1e0cf3e3aea9ded6
Signed-off-by: Chiranjeevi Rapolu <chiranjeevi.rapolu@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/274204
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Divya Jyothi <divya.jyothi@intel.com>
Allow timeout to be set at runtime by controller.
BUG=chrome-os-partner:40780
TEST=Manual on Glados. Verify PD I2C communication is functional.
BRANCH=None
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I582e47c7bebfed7a639789c90064d86ffe1a5401
Reviewed-on: https://chromium-review.googlesource.com/274967
Reviewed-by: Alec Berg <alecaberg@chromium.org>
MOTIONSENSE_CMD_DATA return the value of a sinlge sensor.
BRANCH=none
BUG=chrome-os-partner:39900
TEST=On Smaug, using the new cros-ec-sensors driver,
check sensors data using iio sysfs interface.
Change-Id: I618ff050e0c7b4247ac56cfb0ca25e351270e1d6
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/274824
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Clean up pd_tx_disable() so that it doesn't toggle a couple times
when we stop transmitting. Need to first set the CC pin to Hi-Z
and then the TX_DATA line since the CC pin is normally held low
during transmission.
BUG=none
BRANCH=none
TEST=test on glados. use twinkie to capture traffic and note that
without this change, the CC line toggles an extra time at the end
of each transmission. With this change it is a lot cleaner.
Change-Id: If26c7a10bbb08bc55b972bb0145115836579d37b
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/274884
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Implement the TCPC RX Detect register and use it for the TCPM to
enable and disable PD communication. When no type-C connection,
disable TCPC RX so that we don't send goodCRC when we are not
ready. Once TCPM establishes a type-C connection, enable TCPC RX.
BUG=none
BRANCH=none
TEST=tested on glados and on samus. On glados, without this change,
sometimes when you plug in zinger, we get into a hard reset loop
because TCPC is sending goodCRC to source cap while TCPM is still
debouncing CC and is not ready. With this change, we reliably form
PD contract.
Also tested enabling and disabling PD comms from the TCPM console
with "pd enable 0|1".
Change-Id: I8c9e696f2597978436f6ceccfe06ffb021c95ea3
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/274811
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Copy task stack sizes from Samus. These can be tuned later if necessary.
BUG=chrome-os-partner:40790,chrome-os-partner:40677
TEST=`make buildall -j`
BRANCH=None
Change-Id: I862c55ca924879ffb08062eaf1466fd3d4a3090c
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/274415
Reviewed-by: Alec Berg <alecaberg@chromium.org>