Files
OpenCellular/common/host_command_pd.c
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

72 lines
1.7 KiB
C

/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Host command module for PD MCU */
#include "charge_state.h"
#include "common.h"
#include "console.h"
#include "host_command.h"
#include "task.h"
#include "timer.h"
#include "util.h"
#define CPRINTS(format, args...) cprints(CC_PD_HOST_CMD, format, ## args)
#define TASK_EVENT_EXCHANGE_PD_STATUS TASK_EVENT_CUSTOM(1)
void host_command_pd_send_status(void)
{
task_set_event(TASK_ID_PDCMD, TASK_EVENT_EXCHANGE_PD_STATUS, 0);
}
static void pd_exchange_status(void)
{
struct ec_params_pd_status ec_status;
struct ec_response_pd_status pd_status;
int rv = 0, tries = 0;
/* Send battery state of charge */
if (charge_get_flags() & CHARGE_FLAG_BATT_RESPONSIVE)
ec_status.batt_soc = charge_get_percent();
else
ec_status.batt_soc = -1;
/* Try 3 times to get the PD MCU status. */
while (tries++ < 3) {
rv = pd_host_command(EC_CMD_PD_EXCHANGE_STATUS, 0, &ec_status,
sizeof(struct ec_params_pd_status), &pd_status,
sizeof(struct ec_response_pd_status));
if (rv >= 0)
break;
task_wait_event(500*MSEC);
}
if (rv < 0) {
CPRINTS("Host command to PD MCU failed");
return;
}
/* Set input current limit */
rv = charge_set_input_current_limit(MAX(pd_status.curr_lim_ma,
CONFIG_CHARGER_INPUT_CURRENT));
if (rv < 0)
CPRINTS("Failed to set input current limit from PD MCU");
}
void pd_command_task(void)
{
while (1) {
/* Wait for the next command event */
int evt = task_wait_event(-1);
/* Process event to send status to PD */
if (evt & TASK_EVENT_EXCHANGE_PD_STATUS)
pd_exchange_status();
}
}