mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 01:50:53 +00:00
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>
64 lines
1.5 KiB
C
64 lines
1.5 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");
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|