mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-06 23:51:28 +00:00
Add smart battery functions read ascii info
Signed-off-by: Rong Chang <rongchang@chromium.org> BUG=chrome-os-partner:8321 TEST=manual: type 'battery' in EC serial console, check following fields: Manufacturer Device name Device chemistry CQ-DEPEND:I0ad3ad45b796d9ec03d8fbc1d643aa6a92d6343f Change-Id: Iad4d63c996272568b5a661a6716790ef151b29c5
This commit is contained in:
@@ -113,6 +113,7 @@ static int command_battery(int argc, char **argv)
|
||||
int rv;
|
||||
int d;
|
||||
int hour, minute;
|
||||
char text[32];
|
||||
const char *unit;
|
||||
|
||||
uart_puts("Reading battery...\n");
|
||||
@@ -123,6 +124,18 @@ static int command_battery(int argc, char **argv)
|
||||
uart_printf(" Temperature: 0x%04x = %d x 0.1K (%d C)\n",
|
||||
d, d, (d-2731)/10);
|
||||
|
||||
uart_printf(" Manufacturer: %s\n",
|
||||
battery_manufacturer_name(text, sizeof(text)) == EC_SUCCESS ?
|
||||
text : "(error)");
|
||||
|
||||
uart_printf(" Device: %s\n",
|
||||
battery_device_name(text, sizeof(text)) == EC_SUCCESS ?
|
||||
text : "(error)");
|
||||
|
||||
uart_printf(" Chemistry: %s\n",
|
||||
battery_device_chemistry(text, sizeof(text)) == EC_SUCCESS ?
|
||||
text : "(error)");
|
||||
|
||||
battery_serial_number(&d);
|
||||
uart_printf(" Serial number: 0x%04x\n", d);
|
||||
|
||||
|
||||
@@ -225,6 +225,28 @@ static inline int battery_design_voltage(int *voltage)
|
||||
static inline int battery_serial_number(int *serial)
|
||||
{ return sb_read(SB_SERIAL_NUMBER, serial); }
|
||||
|
||||
/* Read manufacturer name */
|
||||
static inline int battery_manufacturer_name(char *manufacturer_name,
|
||||
int buf_size)
|
||||
{
|
||||
return i2c_read_string(I2C_PORT_BATTERY, BATTERY_ADDR,
|
||||
SB_MANUFACTURER_NAME, manufacturer_name, buf_size);
|
||||
}
|
||||
|
||||
/* Read device name */
|
||||
static inline int battery_device_name(char *device_name, int buf_size)
|
||||
{
|
||||
return i2c_read_string(I2C_PORT_BATTERY, BATTERY_ADDR,
|
||||
SB_DEVICE_NAME, device_name, buf_size);
|
||||
}
|
||||
|
||||
/* Read battery type/chemistry */
|
||||
static inline int battery_device_chemistry(char *device_chemistry, int buf_size)
|
||||
{
|
||||
return i2c_read_string(I2C_PORT_BATTERY, BATTERY_ADDR,
|
||||
SB_DEVICE_CHEMISTRY, device_chemistry, buf_size);
|
||||
}
|
||||
|
||||
/* Read battery discharging current
|
||||
* unit: mA
|
||||
* negative value: charging
|
||||
|
||||
Reference in New Issue
Block a user