Commit Graph

13 Commits

Author SHA1 Message Date
Bill Richardson
401498bb6a lightbar: ask the PD MCU for the charge direction
This exposes the pd_exchange_status() function and lets it
return the charge port that the PD reports, so that the lightbar
TAP sequence can decide which direction to display.

BUG=chrome-os-partner:32227
BRANCH=ToT, samus
TEST=make buildall -j

Change-Id: I78b57fbeaaf38fee15c86eca4d90abce77e2f722
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/232092
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-12-11 04:23:33 +00:00
Alec Berg
eff864775f samus: exchange status with PD MCU on boot
On boot, the EC should send host command to exchange status with
PD MCU. This allows EC to get the correct input current limit
when EC reboots and PD does not.

Also had to move some of the charger state machine initialization
to run with HOOK_INIT so that it runs before the tasks run.

BUG=none
BRANCH=none
TEST=tested on EVT samus. Without this change, if you reboot
EC, and run charger command, the charger input current limit
is 512mA. with this change, when the EC reboots, it sends host
command to PD MCU to get current limit and sets it appropriately.

Change-Id: I5426f0fc3a62b6cd7a73f55cb11b895902a54903
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/216879
Reviewed-by: Todd Broch <tbroch@chromium.org>
2014-09-17 01:24:25 +00:00
Alec Berg
5bc3dc3bbe samus: add automatic retries for host commands from EC to PD
Add three retries for EC to PD host commands. With this change,
removed retry mechanism in host_command_pd.c which was a retry
only for the specific EC_CMD_PD_EXCHANGE_STATUS host command.

BUG=chrome-os-partner:32006
BRANCH=none
TEST=Loaded EC code onto samus. Added the following code
for testing failed host commands to samus_pd common/host_command.c
host_command_task():
if ((evt & TASK_EVENT_CMD_PENDING) && pending_args) {
	if (i++ != 4)
		pending_args->result =
			host_command_process(pending_args);
	else {
		pending_args->result = -7;
		i = 0;
	}
	host_send_response(pending_args);
}
This test code on samus_pd drops one in every five host commands.

With this code, from the EC, I send "pdcmd 0 0", and verified that
1 out of 5 times the EC prints a host command failed code, but then
retries successfully.

Change-Id: Ibf43feefbfc7d791c45c6689b82c66f5d71046ab
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/217461
Reviewed-by: Todd Broch <tbroch@chromium.org>
2014-09-17 01:24:05 +00:00
Shawn Nematbakhsh
9d0bb00192 host_command_pd: Fix condition for sending a PD MCU host event
PD_STATUS_HOST_EVENT is a non-zero bitmask, so use '&' to check the
proper bit(s) in the condition.

BUG=chrome-os-partner:31361
TEST=Manual on Samus. Plug + unplug zinger, verify that host events are
not set. Also, verify that 'pdevent' console command still sets the host
event.
BRANCH=None.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I15c61c3c872ce8e7425678b2c669fcfa1eec89a6
Reviewed-on: https://chromium-review.googlesource.com/214631
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-28 06:59:49 +00:00
Alec Berg
1933fb8ff7 samus: add ability for PD MCU to send host event to AP
Add host event for PD up to AP. The PD toggles a gpio line to
EC causing an interrupt on EC. The EC then sends host command
down to PD MCU to get its status. There is a new status bit for
PD host event, so when EC see's the PD host event status bit,
it sends a PD host event to the AP.

There is currently only one host event for PD to AP.

BUG=chrome-os-partner:31361
BRANCH=none
TEST=added PD console command pdevent, which initiates the host
event. when sent, verified on EC that it sets the correct host
event bit using hostevent console command

Change-Id: If1a59a3232e2f9a49f272c6dee5319254d87b9a9
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213371
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-08-27 01:29:58 +00:00
Alec Berg
f862275b9d samus: change input current limit to the real limit
Remove the hack to set the input current limit to 2/3 of the
real limit. This was a hardware limitation of p2b systems. This
change will only work on EVT.

BUG=chrome-os-partner:28532
BRANCH=none
TEST=loaded onto a samus with all of the charging circuit reworks
and tested with an EVT zinger to make sure we don't OCP the
zinger. We limit current to 2944mA and zinger reads current draw
as 3150mA. The discrepancy is a hardware problem on zinger side
measuring current, but is still comfortably below 3.6A OCP limit.

Change-Id: Ia6adc79a0c6c7599ded76fb8f48de1479f021fe1
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213772
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2014-08-26 01:06:31 +00:00
Alec Berg
283fe98939 samus: ryu: fix charge state machine init of input current
Currently charge state machine resets input current limit to default
every time AC is connected. Problem is by the time charge state machine
gets around to setting input current, it could have already been set
by successful PD negotiation, and this ends up overriding that value.
This fix has the state machine store desired input current limit, as
determined from PD negotation or any other place, and send last desired
input current limit on AC connect.

BUG=chrome-os-partner:24461
BRANCH=none
TEST=load on samus, test toggling between "pd 0 dev 5" and "pd 0 dev 20",
and test plugging and unplugging zinger numerous times, and verify charger
command always gives the expected input current limit based on PD
negotiation.

Change-Id: I18d8acc9e2085739e783c9c70c682d46bcce7fdb
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/211639
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-08-12 05:11:39 +00:00
Alec Berg
0815df9cbf samus: ryu: set input current limit based on PD negotiation
Set input current limit based on the max current from the
PD negotiation. For samus, this information is passed to
the EC as a host command. For ryu, the max current is set
directly following a negotiation.

CONFIG_CHARGER_INPUT_CURRENT is now just the default limit,
but after a successful PD negotiation, the limit can be
raised.

Note, for now the input current limit for samus is set to
2/3 of the value negotiated for. This is due to hardware
problems measuring input current on p2b boards.

BUG=chrome-os-partner:28532, chrome-os-partner:24461
BRANCH=none
TEST=tested on a samus. Verified input current limit using
"charger" console command from EC. Input current limit
after a reboot is 512. When zinger is plugged in, it jumps
to the appropriate value (currently 1280mA), and when
the negotiation is changed using the "pd 0 dev 5" command
on the PD console, the input current limit is adjusted to
match (2000mA).

Change-Id: Iab9186a0f9814655e3240217a9baf4a38f15f84d
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/211023
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-08-09 00:20:06 +00:00
Alec Berg
02d313201f samus_pd: remove dead code around allowing PD negotiation
Remove code for preventing PD negotiation until the battery
is at some minimum SOC. This was originally necessary because
transitioning voltages would cause the source voltage to go
briefly to 0V, which would kill power to the system unless
the battery was at some minimum level of charge. But, that
isn't true anymore. It is safe to transition up or down in
voltage and the source voltage should never drop to 0V.

BUG=chrome-os-partner:29499
BRANCH=none
TEST=make -j buildall. No need to do any more testing because
this code has been disabled for a while.

Change-Id: I8a3dca117f01f0f9c7d04b5d489e4a8588a89be6
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/211021
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-08-06 04:36:44 +00:00
Alec Berg
6ab38d8715 samus: use real AC_PRESENT signal
Revert
- https://chromium-review.googlesource.com/#/c/205145/2
- https://chromium-review.googlesource.com/#/c/205147/4

Now using the real AC_PRESENT gpio signal instead of whether or
not the PD MCU negotiated for 20V.

BUG=chrome-os-partner:29841, chrome-os-partner:29842
BRANCH=none
TEST=tested on a board with reworked AC_PRESENT signal. Verified
that gpio is correctly reporting state of AC and is charging when
AC is plugged in. Tested the no battery case to make sure
board powers on and stays on with just a charger. Also tested the
dead battery case by plugging in a dead battery, then plugging in
a charger and making sure system powers on and starts charging.

Change-Id: I4424771c91c8a2aa19eda68a8b5194e9265d529c
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/206598
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-07-11 01:55:13 +00:00
Alec Berg
d7c19b0236 samus: add retry mechanism for EC to PD host commands
Add a retry mechanism for EC to PD host commands to make the
communication channel more robust.

BUG=none
BRANCH=none
TEST=run on system to verify that we don't drop host commands
to PD MCU.

Change-Id: Ida6f02a149e4dd9e85a5aac21790928b16864104
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/205148
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-28 00:55:35 +00:00
Duncan Laurie
635a57eede samus: hack to read AC present state from PD
The ACOK input to the EC is not connected to the charger so
that signal cannot be relied on for AC presence.  Instead
have the PD report when it negotiates to 20V and when it
disconnects and have the EC use that for AC presence.

BUG=chrome-os-partner:29841
BRANCH=none
TEST=test charging with zinger on samus system.

Change-Id: Ia9096a24ab05d110e31910218dc8c214a846a9a4
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/205145
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-27 18:31:31 +00:00
Alec Berg
72357cd1ed samus: Allow samus to charge w/o battery or with dead battery
Use a EC to PD host command to notify the PD MCU when a battery
is present and charged enough that it is ok to negotiate for a
higher power. The PD MCU will not negotiate until the host command
is received, which allows the system to be powered without a
battery or with a dead battery with 5V.

BUG=chrome-os-partner:28611
BRANCH=none
TEST=Tested on a samus:

1) Tested the normal case of battery charged and plugged in. When
charger is plugged in, the device immediately starts negotiating
for 20V and starts charging.
2) Tested with no battery. Plug in a charger, samus boots and stays
alive. VBUS measured at 5V. When a battery is plugged in, device
negotiates for 20V and starts charging.
3) Tested dead battery by taking a battery with no charge, and
plugging in zinger. Everything boots, but PD does not negotiate
for power. Then when battery reaches 1%, PD negotiates and zinger
switches to 20V without causing a reboot.

Change-Id: Iaa451403674e86cddbd3fe80e9503584910be576
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/201958
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-09 22:20:48 +00:00