Files
OpenCellular/include/charge_state_v2.h
Ryan Zhang 30287d4757 charger: Add CONFIG_CHARGE_STATE_DEBUG
Servo / Suzy-Q related debugging methods is a big challenge
in factory especially after servo debug header is removed.

Expose some information to OS from EC will do a great help
for massive production.

+ expose charge/battery related state to ectool
	1. chg_ctl_mode
	2. manual_mode
	3. battery_seems_to_be_dead
	4. battery_seems_to_be_disconnected
	5. battery_was_removed
	6. disch_on_ac (learn mode state)

BUG=b:65265543
BRANCH=master
TEST=`ectool chargestate param 0x20000~0x20006 get correct state`

Change-Id: Ic2ed38e2eb9def01be29729fa1fe1959eb73fe43
Signed-off-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/646412
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-11 00:16:58 -07:00

66 lines
1.6 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 "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;
};
/**
* 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 */
#endif /* __CROS_EC_CHARGE_STATE_V2_H */