mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
Create stub files for charge_state_v2.c
Remove copied code from V1 implementation, reduce to bare minimum needed to satisfy external dependencies. Don't actually enable it for any platforms, though. BRANCH=ToT BUG=chrome-os-partner:23776 TEST=make buildall -j It's used by anything and doesn't do anything if it was, but test compilation of the changed sources by defining CONFIG_CHARGER_V2. Change-Id: Iea37d0b4fc48c8ebf7f7088cd1674d6e275d03d4 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/190853 Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
committed by
chrome-internal-fetch
parent
a025f18673
commit
defaf5cdb5
@@ -25,6 +25,7 @@ common-$(CONFIG_BUTTON_COUNT)+=button.o
|
||||
common-$(CONFIG_CAPSENSE)+=capsense.o
|
||||
common-$(CONFIG_CHARGER)+=charger.o
|
||||
common-$(CONFIG_CHARGER_V1)+=charge_state_v1.o
|
||||
common-$(CONFIG_CHARGER_V2)+=charge_state_v2.o
|
||||
# TODO(crosbug.com/p/23815): This is really the charge state machine
|
||||
# for ARM, not the charger driver for the tps65090. Rename.
|
||||
common-$(CONFIG_CHARGER_TPS65090)+=pmu_tps65090_charger.o
|
||||
|
||||
66
common/charge_state_v2.c
Normal file
66
common/charge_state_v2.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/* 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.
|
||||
*
|
||||
* Battery charging task and state machine.
|
||||
*/
|
||||
|
||||
#include "battery.h"
|
||||
#include "charge_state.h"
|
||||
#include "charger.h"
|
||||
#include "chipset.h"
|
||||
#include "common.h"
|
||||
#include "console.h"
|
||||
#include "extpower.h"
|
||||
#include "gpio.h"
|
||||
#include "hooks.h"
|
||||
#include "host_command.h"
|
||||
#include "printf.h"
|
||||
#include "system.h"
|
||||
#include "task.h"
|
||||
#include "timer.h"
|
||||
#include "util.h"
|
||||
|
||||
/* Console output macros */
|
||||
#define CPUTS(outstr) cputs(CC_CHARGER, outstr)
|
||||
#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args)
|
||||
|
||||
|
||||
|
||||
void charger_task(void)
|
||||
{
|
||||
while (1)
|
||||
task_wait_event(-1);
|
||||
}
|
||||
|
||||
|
||||
int charge_keep_power_off(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
enum charge_state charge_get_state(void)
|
||||
{
|
||||
return PWR_STATE_INIT;
|
||||
}
|
||||
|
||||
uint32_t charge_get_flags(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int charge_get_percent(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int charge_temp_sensor_get_val(int idx, int *temp_ptr)
|
||||
{
|
||||
return EC_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
int charge_want_shutdown(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -8,6 +8,85 @@
|
||||
#include "common.h"
|
||||
|
||||
/* Stuff that's common to all charger implementations can go here. */
|
||||
/* Power states */
|
||||
enum charge_state {
|
||||
/* Meta-state; unchanged from previous time through task loop */
|
||||
PWR_STATE_UNCHANGE = 0,
|
||||
/* Initializing charge state machine at boot */
|
||||
PWR_STATE_INIT,
|
||||
/* Re-initializing charge state machine */
|
||||
PWR_STATE_REINIT,
|
||||
/* Just transitioned from init to idle */
|
||||
PWR_STATE_IDLE0,
|
||||
/* Idle; AC present */
|
||||
PWR_STATE_IDLE,
|
||||
/* Discharging */
|
||||
PWR_STATE_DISCHARGE,
|
||||
/* Charging */
|
||||
PWR_STATE_CHARGE,
|
||||
/* Charging, almost fully charged */
|
||||
PWR_STATE_CHARGE_NEAR_FULL,
|
||||
/* Charging state machine error */
|
||||
PWR_STATE_ERROR
|
||||
};
|
||||
|
||||
/* Charge state flags */
|
||||
/* Forcing idle state */
|
||||
#define CHARGE_FLAG_FORCE_IDLE (1 << 0)
|
||||
/* External (AC) power is present */
|
||||
#define CHARGE_FLAG_EXTERNAL_POWER (1 << 1)
|
||||
|
||||
/* Debugging constants, in the same order as enum charge_state. This string
|
||||
* table was moved here to sync with enum above.
|
||||
*/
|
||||
#define CHARGE_STATE_NAME_TABLE { \
|
||||
"unchange", \
|
||||
"init", \
|
||||
"reinit", \
|
||||
"idle0", \
|
||||
"idle", \
|
||||
"discharge", \
|
||||
"charge", \
|
||||
"charge_near_full", \
|
||||
"error" \
|
||||
}
|
||||
/* End of CHARGE_STATE_NAME_TABLE macro */
|
||||
|
||||
|
||||
/**
|
||||
* Return current charge state.
|
||||
*/
|
||||
enum charge_state charge_get_state(void);
|
||||
|
||||
/**
|
||||
* Return non-zero if battery is so low we want to keep AP off.
|
||||
*/
|
||||
int charge_keep_power_off(void);
|
||||
|
||||
/**
|
||||
* Return current charge state flags (CHARGE_FLAG_*)
|
||||
*/
|
||||
uint32_t charge_get_flags(void);
|
||||
|
||||
/**
|
||||
* Return current battery charge percentage.
|
||||
*/
|
||||
int charge_get_percent(void);
|
||||
|
||||
/**
|
||||
* Return non-zero if discharging and battery so low we should shut down.
|
||||
*/
|
||||
int charge_want_shutdown(void);
|
||||
|
||||
/**
|
||||
* Get the last polled battery/charger temperature.
|
||||
*
|
||||
* @param idx Sensor index to read.
|
||||
* @param temp_ptr Destination for temperature in K.
|
||||
*
|
||||
* @return EC_SUCCESS if successful, non-zero if error.
|
||||
*/
|
||||
int charge_temp_sensor_get_val(int idx, int *temp_ptr);
|
||||
|
||||
|
||||
/* Pick the right implementation */
|
||||
|
||||
@@ -40,50 +40,6 @@
|
||||
#define F_CHARGER_MASK (F_CHARGER_VOLTAGE | F_CHARGER_CURRENT | \
|
||||
F_CHARGER_INIT)
|
||||
|
||||
/* Power states */
|
||||
enum charge_state {
|
||||
/* Meta-state; unchanged from previous time through task loop */
|
||||
PWR_STATE_UNCHANGE = 0,
|
||||
/* Initializing charge state machine at boot */
|
||||
PWR_STATE_INIT,
|
||||
/* Re-initializing charge state machine */
|
||||
PWR_STATE_REINIT,
|
||||
/* Just transitioned from init to idle */
|
||||
PWR_STATE_IDLE0,
|
||||
/* Idle; AC present */
|
||||
PWR_STATE_IDLE,
|
||||
/* Discharging */
|
||||
PWR_STATE_DISCHARGE,
|
||||
/* Charging */
|
||||
PWR_STATE_CHARGE,
|
||||
/* Charging, almost fully charged */
|
||||
PWR_STATE_CHARGE_NEAR_FULL,
|
||||
/* Charging state machine error */
|
||||
PWR_STATE_ERROR
|
||||
};
|
||||
|
||||
/* Charge state flags */
|
||||
/* Forcing idle state */
|
||||
#define CHARGE_FLAG_FORCE_IDLE (1 << 0)
|
||||
/* External (AC) power is present */
|
||||
#define CHARGE_FLAG_EXTERNAL_POWER (1 << 1)
|
||||
|
||||
/* Debugging constants, in the same order as enum charge_state. This string
|
||||
* table was moved here to sync with enum above.
|
||||
*/
|
||||
#define CHARGE_STATE_NAME_TABLE { \
|
||||
"unchange", \
|
||||
"init", \
|
||||
"reinit", \
|
||||
"idle0", \
|
||||
"idle", \
|
||||
"discharge", \
|
||||
"charge", \
|
||||
"charge_near_full", \
|
||||
"error" \
|
||||
}
|
||||
/* End of CHARGE_STATE_NAME_TABLE macro */
|
||||
|
||||
/* Power state data
|
||||
* Status collection of charging state machine.
|
||||
*/
|
||||
@@ -120,40 +76,5 @@ struct charge_state_context {
|
||||
int battery_responsive;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return current charge state.
|
||||
*/
|
||||
enum charge_state charge_get_state(void);
|
||||
|
||||
/**
|
||||
* Return non-zero if battery is so low we want to keep AP off.
|
||||
*/
|
||||
int charge_keep_power_off(void);
|
||||
|
||||
/**
|
||||
* Return current charge state flags (CHARGE_FLAG_*)
|
||||
*/
|
||||
uint32_t charge_get_flags(void);
|
||||
|
||||
/**
|
||||
* Return current battery charge percentage.
|
||||
*/
|
||||
int charge_get_percent(void);
|
||||
|
||||
/**
|
||||
* Return non-zero if discharging and battery so low we should shut down.
|
||||
*/
|
||||
int charge_want_shutdown(void);
|
||||
|
||||
/**
|
||||
* Get the last polled battery/charger temperature.
|
||||
*
|
||||
* @param idx Sensor index to read.
|
||||
* @param temp_ptr Destination for temperature in K.
|
||||
*
|
||||
* @return EC_SUCCESS if successful, non-zero if error.
|
||||
*/
|
||||
int charge_temp_sensor_get_val(int idx, int *temp_ptr);
|
||||
|
||||
#endif /* __CROS_EC_CHARGE_STATE_V1_H */
|
||||
|
||||
|
||||
14
include/charge_state_v2.h
Normal file
14
include/charge_state_v2.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/* 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 "timer.h"
|
||||
|
||||
#ifndef __CROS_EC_CHARGE_STATE_V2_H
|
||||
#define __CROS_EC_CHARGE_STATE_V2_H
|
||||
|
||||
|
||||
#endif /* __CROS_EC_CHARGE_STATE_V2_H */
|
||||
|
||||
Reference in New Issue
Block a user