Files
OpenCellular/include/charger.h
Rong Chang 62df62ccd4 Add basic smart battery driver
This change adds a common part of smart battery driver. Following
features are not implemented, or in chip specific driver:
  Battery access control, authentication, factory mode
  Manufacturer access/data commands
  Block read/write, device name, flash data
  Chip specific features, per cell info/temp/capacity

Signed-off-by: Rong Chang <rongchang@google.com>
BUG=chrome-os-partner:7856
TEST=console command check battery staus
  [unplug power]
  > battery
  [check voltage,current,capacity,time to empty]
  [plug power]
  > charger voltage 8400
  > charger current 4250
  > battery
  [check current,time to full]
  > charger input 4032
  > battery
  [check current,time to full]
  [wait 130 seconds, charger watch dog timeout]
  > battery
  [check current]

Change-Id: Ifac17a0892f52e8f37eebc14b00e71f18360776c
Signed-off-by: Rong Chang <rongchang@chromium.org>
2012-02-10 16:12:56 -08:00

60 lines
1.4 KiB
C

/* Copyright (c) 2012 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.
*/
/* Charger/battery debug command module for Chrome EC */
#ifndef __CROS_EC_CHARGER_H
#define __CROS_EC_CHARGER_H
#include "common.h"
/* Charger infomation
* voltage unit: mV
* current unit: mA
*/
struct charger_info {
const char *name;
uint16_t voltage_max;
uint16_t voltage_min;
uint16_t voltage_step;
uint16_t current_max;
uint16_t current_min;
uint16_t current_step;
uint16_t input_current_max;
uint16_t input_current_min;
uint16_t input_current_step;
};
/* Initializes the charger */
int charger_init(void);
/* Power state machine post init */
int charger_post_init(void);
/* Get charger information. */
const struct charger_info *charger_get_info(void);
/* Get smart battery charger status. Supported flags:
* CHARGER_CHARGE_INHIBITED
* CHARGER_LEVEL_2
*/
int charger_get_status(int *status);
/* Set smart battery charger mode. Supported mode(s):
* CHARGER_FLAG_INHIBIT_CHARGE
*/
int charger_set_mode(int mode);
/* Get/set charge current limit in mA */
int charger_get_current(int *current);
int charger_set_current(int current);
/* Get/set charge voltage limit in mV */
int charger_get_voltage(int *voltage);
int charger_set_voltage(int voltage);
#endif /* __CROS_EC_CHARGER_H */