Files
OpenCellular/include/charge_state_v2.h
Aseda Aboagye 32255f2989 chgstv2: Fix manual control via EC console.
There was a recent change to save the manual setting of charge current
and voltage, however it was done so assuming that the parameters were
set via the host command interface. (CL:922069) However, there are times
where the charge voltage/current would like to be manipulated without
booting the AP.  This commit simply makes the EC console command work
again.

BUG=None
BRANCH=None
TEST=make -j buildall
TEST=Flash nocturne, `chgstate idle on; charger current 256; charger
voltage 7400`; verify that the charge voltage and current is actually
changed.

Change-Id: Id250d9704f8509162518495556603950248fb267
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1081120
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2018-06-01 17:44:41 -07:00

114 lines
2.8 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.
*/
#include "battery.h"
#include "battery_smart.h"
#include "charger.h"
#include "ec_ec_comm_master.h"
#include "timer.h"
#ifndef __CROS_EC_CHARGE_STATE_V2_H
#define __CROS_EC_CHARGE_STATE_V2_H
#if defined(CONFIG_I2C_VIRTUAL_BATTERY) && defined(CONFIG_BATTERY_SMART)
#define VIRTUAL_BATTERY_ADDR BATTERY_ADDR
#endif
/*
* The values exported by charge_get_state() and charge_get_flags() are used
* only to control the LEDs (with one not-quite-correct exception). For V2
* we use a different set of states internally.
*/
enum charge_state_v2 {
ST_IDLE = 0,
ST_DISCHARGE,
ST_CHARGE,
ST_PRECHARGE,
NUM_STATES_V2
};
struct charge_state_data {
timestamp_t ts;
int ac;
int batt_is_charging;
struct charger_params chg;
struct batt_params batt;
enum charge_state_v2 state;
int requested_voltage;
int requested_current;
int desired_input_current;
#ifdef CONFIG_CHARGER_OTG
int output_current;
#endif
#ifdef CONFIG_EC_EC_COMM_BATTERY_MASTER
int input_voltage;
#endif
};
/**
* Set the output current limit and voltage. This is used to provide power from
* the charger chip ("OTG" mode).
*
* @param ma Maximum current to provide in mA (0 to disable output).
* @param mv Voltage in mV (ignored if ma == 0).
* @return EC_SUCCESS or error
*/
int charge_set_output_current_limit(int ma, int mv);
/**
* Set the charge input current limit. This value is stored and sent every
* time AC is applied.
*
* @param ma New input current limit in mA
* @param mv Negotiated charge voltage in mV.
* @return EC_SUCCESS or error
*/
int charge_set_input_current_limit(int ma, int mv);
/*
* Expose charge/battery related state
*
* @param param command to get corresponding data
* @param value the corresponding data
* @return EC_SUCCESS or error
*/
#ifdef CONFIG_CHARGE_STATE_DEBUG
int charge_get_charge_state_debug(int param, uint32_t *value);
#endif /* CONFIG_CHARGE_STATE_DEBUG */
/**
* Set the desired manual charge current when in idle mode.
*
* @param curr_ma: Charge current in mA.
*/
void chgstate_set_manual_current(int curr_ma);
/**
* Set the desired manual charge voltage when in idle mode.
*
* @param volt_mv: Charge voltage in mV.
*/
void chgstate_set_manual_voltage(int volt_mv);
/**
* Board-specific routine to indicate if the base is connected.
*/
int board_is_base_connected(void);
/**
* Board-specific routine to enable power distribution between lid and base
* (current can flow both ways).
*/
void board_enable_base_power(int enable);
/**
* Board-specific routine to reset the base (in case it is unresponsive, e.g.
* if we told it to hibernate).
*/
void board_base_reset(void);
#endif /* __CROS_EC_CHARGE_STATE_V2_H */