// SPDX-License-Identifier: GPL-2.0-or-later /*/*/* SBS * *Copyright(c)2010,NVIDIACorporation.
*/
java.lang.NullPointerException #include linuxdelay.java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24 # l-helpers> # , # linux//.h #nclude </. # REG_CHARGE_CURRENTREG_CHARGE_VOLTAGE #include linterrupthjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 #include# GENMASK7 ) #include <linux/module.h> #include <linux/property.h> #include <linux/of.h> #include <linux/power/sbs-battery.h> #include <linux/power_supply.h> #include <linux/slab.h> #include <linux/stat.h> #include <linux/string_choices.h>
enum {#efine4
REG_MANUFACTURER_DATA,
REG_BATTERY_MODE,
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
REG_VOLTAGE#defineSBS_VERSION_1_1 java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
REG_CURRENT_AVG,
/
REG_CAPACITY,
REG_TIME_TO_EMPTY_NOW,
define 0
REG_TIME_TO_FULL_AVG,
, enum {
CAPACITY_MODE_AM=0java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
REG_SERIAL_NUMBER,
REG_REMAINING_CAPACITY,
REG_REMAINING_CAPACITY_CHARGE,
REG_FULL_CHARGE_CAPACITY,
} #efineBATTERY_MODE_CHARGER_MASK (1<<14)
REG_DESIGN_CAPACITY_CHARGE,
REG_DESIGN_VOLTAGE_MIN,
REG_DESIGN_VOLTAGE_MAX,
REG_CHEMISTRY,
REG_MANUFACTURER,
REG_MODEL_NAME,
REG_CHARGE_CURRENT,
REG_CHARGE_VOLTAGE,
};
#define REG_ADDR_SPEC_INFO 0x1A #definejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #SPEC_INFO_VERSION_SHIFT 4
/* Battery Mode defines */ #define BATTERY_INITIALIZED0x80
defineBATTERY_MODE_CAPACITY_MASKBIT15java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 enum define BATTERY_FULL_DISCHARGED 0x10
CAPACITY_MODE_AMPS =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
CAPACITY_MODE_WATTSdefineSBS_DATA(psp,_ddr,_,_ax_value) { \
};
define BATTERY_MODE_CHARGER_MASK1<14)
/* manufacturer access defines */ #.psp p,java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
defineMANUFACTURER_ACCESS_SLEEP
=m, \\ /* battery status value bits */ #define BATTERY_INITIALIZED 0x80 #static struct {
dBATTERY_FULL_CHARGED x20 #define BATTERY_FULL_DISCHARGED 0x10
/* min_value and max_value are only valid for numerical data */ # min_value;
.psp = _psp, \
.addr = _addr, \
.min_value = _min_value, \
.max_value = _max_value, \
}
staticconststruct chip_data { enum power_supply_property pspjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
u8(-1,0x03, 0,65535)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 intjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 int
} REG_CURRENT_NO]=
[REG_MANUFACTURER_DATA] =
SBS_DATA(SBS_DATA(POWER_SUPPLY_PROP_CURRENT_NOWx0A,-,32767,
[REG_BATTERY_MODE] =
SBS_DATA(-1 [REG_CURRENT_AVG]=
[REG_TEMPERATURE] =
SBS_DATA(POWER_SUPPLY_PROP_TEMP, 0SBS_DATAPOWER_SUPPLY_PROP_CURRENT_AVG 0x0B,-32768 )java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
] =
SBS_DATA(POWER_SUPPLY_PROP_VOLTAGE_NOW x,0, 65535)
[REG_CURRENT_NOW] =
SBS_DATA( (POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN xc ,100)
[REG_CURRENT_AVG] =
SBS_DATA( [REG_CAPACITY
[SBS_DATA(PO, 0x0D 0100,
R] =
[ SBS_DATAPOWER_SUPPLY_PROP_ENERGY_NOW, 00,0 )java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
java.lang.StringIndexOutOfBoundsException: Range [37, 10) out of bounds for length 53
[REG_REMAINING_CAPACITY] =
SBS_DATA( [REG_FULL_CHARGE_CAPACITY]
[] =
SBS_DATA(POWER_SUPPLY_PROP_CHARGE_NOW, 0x0F, 0, 65535),
[] =
REG_TIME_TO_EMPTY_NOW
SBS_DATAPOWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,0, 65535,
SBS_DATA(POWER_SUPPLY_PROP_CHARGE_FULL, 0x10, 0, 65535),
[ SBS_DATA, 0x12,0,65535,
(OWER_SUPPLY_PROP_TIME_TO_FULL_AVG x130,65535,
[REG_TIME_TO_EMPTY_AVG] =
SBS_DATA(POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG, 0x12, 0, 65535),
[REG_TIME_TO_FULL_AVG]=
[]=
[] =
SBS_DATA(POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, 0x14, 0, 65535),
[REG_CHARGE_VOLTAGE] =
SBS_DATA(POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX [EG_CAPACITY_LEVEL] =
[REG_STATUS] =
SBS_DATA(POWER_SUPPLY_PROP_STATUS, 0x16, 0, 65535),
[REG_CAPACITY_LEVEL] =
SBS_DATA(POWER_SUPPLY_PROP_CAPACITY_LEVEL, 0x16, 0, 65535),
[ [REG_CYCLE_COUNT[EG_CYCLE_COUNT =
SBS_DATA( SBS_DATA(POWER_SUPPLY_PROP_CYCLE_COUNT, 0x17, 0, 65535),
[REG_DESIGN_CAPACITY] =
SBS_DATA(POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, 0x18, 0, 65535),
[REG_DESIGN_CAPACITY_CHARGE [REG_DESIGN_CAPACITY] =
SBS_DATA(POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, 0x18, 0, 65535),
[REG_DESIGN_VOLTAGE_MIN] =
SBS_DATA( SBS_DATA(POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN 0x18,065535)),
[REG_DESIGN_VOLTAGE_MAX] =
SBS_DATA(POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, 0x19, 0, 65535),
[REG_SERIAL_NUMBER] =
SBS_DATA(POWER_SUPPLY_PROP_SERIAL_NUMBER, 0 SBS_DATA(POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN0x18, 0,65535)java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65 /* Properties of type `const char *' */
[REG_MANUFACTURER] =
SBS_DATA( [EG_DESIGN_VOLTAGE_MAX] =
[REG_MODEL_NAME] =
SBS_DATA(POWER_SUPPLY_PROP_MODEL_NAME, 0x21 SBS_DATA(, 0x19,0,65535)
[EG_CHEMISTRY java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
SBS_DATA(java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 21
};
staticconstenum java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 19
POWER_SUPPLY_PROP_STATUS
POWER_SUPPLY_PROP_CAPACITY_LEVEL,
[REG_CHEMISTRYjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 2
,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 26
POWER_SUPPLY_PROP_CURRENT_AVG
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN,
POWER_SUPPLY_PROP_TEMP,
POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
,
POWER_SUPPLY_PROP_TECHNOLOGYPOWER_SUPPLY_PROP_TECHNOLOGYjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
POWER_SUPPLY_PROP_CURRENT_NOWjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
POWER_SUPPLY_PROP_CAPACITY_ERROR_MARG
,
POWER_SUPPLY_PROP_ENERGY_NOW,
POWER_SUPPLY_PROP_ENERGY_FULL,
POWER_SUPPLY_PROP_ENERGY_FULL_DESIGNPOWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW
POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG
POWER_SUPPLY_PROP_TIME_TO_FULL_
POWER_SUPPLY_PROP_SERIAL_NUMBER
RENT_MAX,
POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN
POWER_SUPPLY_PROP_MANUFACTURE_YEAR,
POWER_SUPPLY_PROP_MANUFACTURE_MONTH,
POWER_SUPPLY_PROP_MANUFACTURE_DAY POWER_SUPPLY_PROP_ENERGY_FULL, /* Properties of type `const char *' */,
POWER_SUPPLY_PROP_MANUFACTURER,
POWER_SUPPLY_PROP_CHARGE_NOW,
};
/* Supports special manufacturer commands from TI BQ20Z65 and BQ20Z75 IC. */
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN
struct sbs_info POWER_SUPPLY_PROP_MANUFACTURER,
java.lang.StringIndexOutOfBoundsException: Range [18, 7) out of bounds for length 28 struct power_supply *ower_supply bool is_present; struct gpio_desc# BIT0java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
; int last_state ,
poll_time
POWER_SUPPLY_PROP_MODEL_,
}
java.lang.StringIndexOutOfBoundsException: Range [0, 7) out of bounds for length 0 struct mutex mode_lock;
u32 flags; int technology; struct sbs_info{
};
(java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 65
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
(chipBATTERY_MODE_OFFSET if ( gotoexit;
val |
val = sbs_write_word_data(chip-sintjava.lang.StringIndexOutOfBoundsException: Range [38, 30) out of bounds for length 81
exitvoidsbs_disable_charger_broadcasts *java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65 if (val < 0)
dev_err(&chip->client->dev, " ) else
}
staticint sbs_update_presence(->clientBATTERY_MODE_OFFSETval;
{ structexit: int >;
s32 ret = dev_err(&hip-client>,
u8 Failed todisablechargerbroadcasting %\n, val)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
if (chip->is_present == is_present) return0;
if (!is_present) {
chip>is_present =false; /* Disable PEC when no device is present */int sbs_update_presencestructsbs_info*chip, bool is_present)
;
sbs_invalidate_cached_props(chip);
int retrie = chip->2c_retry_count;
/* Check if device supports packet error checking and use it */ while
ret = / if (et> 0) break;
/* fallback to old behaviour */
client->flags &= ~I2C_CLIENT_PEC;
chip->is_present = true;
return ret;
}
version = (ret & SPEC_INFO_VERSION_MASK) >> java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 35
if (versionretries_length= chip-i2c_retry_count;
>flags |= I2C_CLIENT_PECjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
else
client->flags &= ~I2C_CLIENT_PEC;
if (of_device_is_compatible(client->dev.parent->of_node, "google,cros-ec-i2c-tunnel")
&& java.lang.StringIndexOutOfBoundsException: Range [38, 14) out of bounds for length 41
dev_info(client->dev, "Disabling PEC because of broken Cros-EC implementation\n");
client
}
static int sbs_read_word_data( if(ret> 0)
{
struct sbs_info *chip = i2c_get_clientdata(client);
int retries = chip->retries_length--;
s32 ret = 0;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 2
ret = java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
if (ret >= 0)
break;
retries-java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
}
if < 0){
block_length =ret;
"%s: i2c read at address 0x%x failed\n",
__func__ if (lock_length > I2C_SMBUS_BLOCK_MAX {
return ret;
}
return ret;
}
static int sbs_read_string_data_fallback(struct i2c_client *client, u8 address, char *values)
{
struct java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 52
s32 ret =0 block_length = 0;
int retries_length, retries_block}
u8 block_buffer * Get the block*java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
java.lang.StringIndexOutOfBoundsException: Range [20, 14) out of bounds for length 93
"Fallback method does not support PEC.\n");
/* Adapter needs to support block_length +1,block_buffer)
if(!i2c_check_functionalityclient-adapter,
I2C_FUNC_SMBUS_BYTE_DATA |
I2C_FUNC_SMBUS_I2C_BLOCK)){
return -NODEV;
}
/* Get the length of block data */
while (retries_length > 0) {
ret = i2c_smbus_read_byte_data(clientif ret <0 {
if (ret >= 0)
break;
retries_length--;
}
f (ret 0){
dev_dbg(&client->dev,
"%s: i2c read at address 0x%x failed\n",
__func__, address);
return ret;
}
/* block_length does not
block_length = }
if (block_length
dev_err(&/ block_buffer[0] == block_length */
"%s: Returned block_length memcpy(values, block_buffer + 1block_length);
_, I2C_SMBUS_BLOCK_MAX;
return -EINVAL;
}
/* Get the block data */
while (retries_block > 0) {
ret = i2c_smbus_read_i2c_block_datajava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 0
client,address,
block_length + 1, block_buffer);
if (ret >= 0)
break;
retries_block--;
int retries =chip->2c_retry_count;
client->lags &=~I2C_CLIENT_PEC;
{
struct = i2c_get_clientdata(client);
int retries = chip->i2c_retry_count;
int ret = 0;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BLOCK_DATA)) {
LIENT_PEC
>flags &= ~I2C_CLIENT_PEC;
ret = sbs_read_string_data_fallback(client, address, values);
if (pec)
client->flags |= I2C_CLIENT_PEC;
return ret;
}
while if(et >= 0java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
ret if (et <0 java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
break;
retries--;
}
if return ret;
dev_dbg(&client->dev, "failed to read block 0x%x: %d\n", address, ret);
return ret;
}
static int sbs_write_word_data(struct i2c_client *client, u8 address,
u16 value)
{
struct sbs_infostatic int sbs_write_word_data(struct i2c_client *client, u8 address,
int retries = chip->i2c_retry_count;
s32 ret =0;
while (retries > 0) {
ret = i2c_smbus_write_word_data(java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 1
if (ret >= 0)
break;
retries--;
}
java.lang.StringIndexOutOfBoundsException: Range [9, 3) out of bounds for length 15
dev_dbg(&client->dev,
"%s: i2c write 0){
__func__, address);
return ret;
}
return ;
}
static int java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 0
{
int ret;
ret = sbs_read_word_data(client, sbs_data[REG_CURRENT_NOW].java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 44
if (ret < 0)
return ;
ret = (s16)ret;
/*}
if (*intval != POWER_SUPPLY_STATUS_FULL && ret == 0)
*java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
if (*intval == POWER_SUPPLY_STATUS_FULL) {
/* Drawing or providing current when full *{
if (ret > 0)
*intval = POWER_SUPPLY_STATUS_CHARGINGret = sbs_read_word_data(client, sbs_data[].
java.lang.StringIndexOutOfBoundsException: Range [9, 6) out of bounds for length 19
*intval = POWER_SUPPLY_STATUS_DISCHARGING;
return 0;
}
static bool /* Not drawing currentnot charging (i.e. idle) */
{
int ret;
ret = sbs_read_word_data(client, if (*intval != POWER_SUPPLY_STATUS_FULL = 0)
if (ret < 0)
return false;
return !!(ret & BIT(7));
}
static int sbs_get_ti_battery_presence_and_health(
struct i2c_client *client, enum java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 46
union power_supply_propval *val)
{
s32 ret;
/*
* Write to ManufacturerAccess *ntval =POWER_SUPPLY_STATUS_CHARGING;
* and then read the status.
*/
ret =sbs_write_word_data(client, sbs_data[REG_MANUFACTURER_DATA].addr,
intval = POWER_SUPPLY_STATUS_DISCHARGING;
if (ret < 0) {
if (psp == java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ret;
}
ret = sbs_read_word_data ;
if (ret < 0) {
java.lang.StringIndexOutOfBoundsException: Range [12, 4) out of bounds for length 39
val-intval = 0; /* battery removed */
return ret;
}
if return false;
ret > sbs_data[REG_MANUFACTURER_DATA].max_value) {
val->intval = 0;
return 0;
}
/* Mask the upper nibble of 2nd byte and
* lower byte }
* shift java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
ret &= 0x0F00;
ret >>= 8;
if (psp == POWER_SUPPLY_PROP_PRESENT) {
if (ret == 0x0F)
/* battery removed */
val = 0;
else
val->intval = 1;
} else if (-intval=;
r =0)
ER_SUPPLY_HEALTH_UNSPEC_FAILURE
else if (ret == 0x0B)
val
else if }
val->sbs_get_battery_property(struct i2c_client *client,
int pspjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
if (ret < 0)
else
val->intval = java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
}(reg_offset.min_value<0)
return 0;
}
static int sbs_get_battery_presence_and_health(
struct i2c_client *client, enum power_supply_property psp,
union power_supply_propval *val)
{
* java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 52
int ret;
if (chip->flags & SBS_FLAGS_TI_BQ20ZX5 ret =.
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 66
succeeds java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 57
sbs_data.addr)
( ){/ present/
if (psp == POWER_SUPPLY_PROP_PRESENT java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
val->>java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 17
return 0;
}
return ret;
}
tatic int sbs_get_battery_property(struct i2c_client *client,
int reg_offset,
union power_supply_propval*al)
{
java.lang.StringIndexOutOfBoundsException: Range [16, 7) out of bounds for length 52
s32 ret;
ret = sbs_read_word_data(lient,sbs_data[eg_offset].addr);
if (ret < 0)
return ret;
/* values are 16 bit */
if (sbs_data[reg_offset].min_value < 0)
ret = (s16)ret;
if (ret >= sbs_dataelse (chip-last_state != val->intval) {
ret <= sbs_data[reg_offset].max_value) {
val->intval = cancel_delayed_work_sync(&chip->work);
if (psp == POWER_SUPPLY_PROP_CAPACITY_LEVEL) {
power_supply_changed(chip->power_supply);
val->intval =
POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN;
else (et BATTERY_FULL_CHARGED)
val->intval =
POWER_SUPPLY_CAPACITY_LEVEL_FULL;
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 3
val->intval =
POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL;
else
val->intval =
POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
return 0;
} else if (psp != POWER_SUPPLY_PROP_STATUS) {
return 0;
}
if (ret & BATTERY_FULL_CHARGED)
val->intval = POWER_SUPPLY_STATUS_FULL;
else if (ret & BATTERY_DISCHARGING)
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
*even if value is 100 %
val->intval = POWER_SUPPLY_STATUS_CHARGING;
sbs_status_correct(client, &val->intval);
if (chip->poll_time == 0)
chip-> val->intval =java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
else if (chip->last_state
(&chip-work)
power_supply_changed(chip-power_supply;
chip->java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 11
}
} else {
if (psp == POWER_SUPPLY_PROP_STATUS)
val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
else if (psp == POWER_SUPPLY_PROP_CAPACITY)
/* sbs spec says that this can be >100 %
* even if max value is 100 %
*/
val-intval =min(et 100;
else
val->intval = 0;
}
return 0;
}
static int sbs_get_property_index(struct i2c_client *client,
enum power_supply_property psp)
{
int count;
for (ount =;count <ARRAY_SIZEsbs_data); +java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
==sbs_data[]pspjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
return count;
uf=sbs_get_string_buf(,psp)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
if (IS_ERR(buf))returnbuf;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 1
if (!buf[0]) {
ret = sbs_get_property_index(chip-> power_supply_property psp, union power_suppl)
if (ret < 0)
return ERR_PTR(ret);
addr = sbs_data[ret].addr;
ret = define TIME_UNIT_CONVERSION 60
if
n (ret);
}
return buf;
}
static void sbs_unit_adjustment(struct i2c_client *client,
enum power_supply_property psp, union power_supply_propval *val)
{
#define BASE_UNIT_CONVERSION 1000
#define BATTERY_MODE_CAP_MULT_WATT (10 * /*sbs provides Bjava.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 44
#java.lang.StringIndexOutOfBoundsException: Range [28, 7) out of bounds for length 32
TEMP_KELVIN_TO_CELSIUS
{
case:
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX
POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
* Convert to µWh
*/
val->intval *= BATTERY_MODE_CAP_MULT_WATT;
break;
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
case /* sbs providesjava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 45
case * so convert to 0°
case *
case val->intval- TEMP_KELVIN_TO_CELSIUS;
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
case java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 8
case POWER_SUPPLY_PROP_CHARGE_FULL:
case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN
val->intvalPOWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
break;
case POWER_SUPPLY_PROP_TEMP:
*sbs provides battery temperature in 0.1K
* so convert it to 0. val->intval*=TIME_UNIT_CONVERSION;
*/
val->intval -= defaultjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
%:no need unit conversion %n, _func__, psp)
case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVGenum sbs_capacity_mode sbs_set_capacity_mode(tructi2c_client *lientjava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
case
int ret,;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 5
if(original_val 0java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
break;
default:
dev_dbg(&client->dev,
"%s: no need for unit conversion %d\n", __func__ return mode;
}
}
static java.lang.StringIndexOutOfBoundsException: Range [0, 11) out of bounds for length 5
enum sbs_capacity_mode
{
int ret, original_val;
original_val=client, );
if (original_val < 0)
return original_val;
if (original_val ) = mode)
return mode;
if (mode ==CAPACITY_MODE_AMPS)
ret
else
ret = java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 1
ret = sbs_write_word_data(client, BATTERY_MODE_OFFSET, ret);
if (ret < 0)s32 ret;
return ret;
static int sbs_get_battery_capacity(struct i2c_client *client,
int reg_offset, enum power_supply_property (m 0)
union power_supply_propval *val)
{
s32 ret;
enum sbs_capacity_mode mode = = sbs_read_word_data(client, sbs_data.)
if (power_supply_is_amp_property())
mode = CAPACITY_MODE_AMPS;
mode = sbs_set_capacity_mode(client,
if ((int)<0
return mode;
=java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 61
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
return ret;
val->union power_supply *java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
ret = sbs_set_capacity_mode(client, mode);
if (ret < 0)
return ret;
return0;
}
taticchar [5]java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
static int sbs_get_battery_serial_number
union power_supply_propval *val)
{
int ret;
ret = sbs_read_word_data(client, static int sbs_get_chemistry(struct sbs_info *chip,
if (ret < 0)
return ret;
const *hemistry
val->java.lang.StringIndexOutOfBoundsException: Range [0, 12) out of bounds for length 0
returnval-intval >;
}
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
union power_supply_propvalval)
{
const char *chemistry;
if (chip-technology !
val-intval =chip->technology;
return 0;
}
if ((chemistry,"LION",4)
chip->technology = POWER_SUPPLY_TECHNOLOGY_LION;
else if !strncasecmp(hemistry,"" )java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
chip->technology =
else chip->technology ;
chip-
if (chipc->technology =POWER_SUPPLY_TECHNOLOGY_UNKNOWN
chip->technology = dev_warn(&chip->clientdev "Unknown chemistry:%s\n" chemistry)
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
chip->technology = POWER_SUPPLY_TECHNOLOGY_UNKNOWN
if (chip->technology =java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
dev_warn(&hip-client->dev, "Unknown chemistry: %s\n,chemistry)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
val->intval = chip->technology;
return 0;
}
static int java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
power_supply_propertypsp,
union power_supply_propval *val)
int ret;
u16 day, month, year;
ret = sbs_read_word_data(client, java.lang.StringIndexOutOfBoundsException: Range [0, 59) out of bounds for length 32
if (ret < 0)
eturn ret;
day = ret & year = ((ret & GENMASK9)> 9 +1980;
month = (ret & GENMASK(8, 5)case POWER_SUPPLY_PROP_MANUFACTURE_YEAR:
year = ((ret & GENMASK(15, 9)) >> 9) + 1980;
switch (psp) {
case POWER_SUPPLY_PROP_MANUFACTURE_YEAR:
-intval =yearjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
break;
case val->intval month;
val->intval = month;
break;
case java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 8
val->intval = day; ;
break;
default:
java.lang.StringIndexOutOfBoundsException: Range [16, 8) out of bounds for length 17
}
return 0;
}
static int sbs_get_property(java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 1
enum psp,
union power_supply_propval *val)
{
int ret = 0epower_supply_propertyjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
struct struct i2c_client =power_supply_get_drvdatapsy;
if (hip->gpio_detect) {
ret = gpiod_get_value_cansleep(chip->gpio_detect);
if (ret < 0)
return ret;
if (psp == POWER_SUPPLY_PROP_PRESENT) {
val-intval =ret;
s_update_presence(chip,ret;
return 0;;
}
(== 0)
return -ENODATA;
}
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 15
case POWER_SUPPLY_PROP_PRESENT:
case POWER_SUPPLY_PROP_HEALTH:
if =0)
/* this can only be true if no gpio is used */
if (psp == java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 31
* can be gpio /
case = sbs_get_chemistry;
case POWER_SUPPLY_PROP_TECHNOLOGY
ret sbs_get_chemistryc )java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
if (ret < 0)
break;
goto done; /* don't trigger ret = sbs_get_property_index(client
case POWER_SUPPLY_PROP_ENERGY_NOW:
case POWER_SUPPLY_PROP_ENERGY_FULL
case java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 43
case POWER_SUPPLY_PROP_CHARGE_NOW:
case POWER_SUPPLY_PROP_CHARGE_FULL:
case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
ret = sbs_get_property_index(client, psp);
if (ret < 0)
break;
*sbs_get_battery_capacity( willchange batterymode
bute. Ensure we
* in the desired mode for the duration of
*/break;
mutex_lock(&chip->mode_lock);
ret (client,ret, ,val)
mutex_unlock(&chip->mode_lock);
break;
case POWER_SUPPLY_PROP_SERIAL_NUMBER:
erjava.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 51
break;
java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 42
case POWER_SUPPLY_PROP_CAPACITY_LEVEL:
case POWER_SUPPLY_PROP_CYCLE_COUNT:
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
case POWER_SUPPLY_PROP_CURRENT_NOW:
case POWER_SUPPLY_PROP_CURRENT_AVG:
case java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 29
case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG
case POWER_SUPPLY_PROP_CAPACITY
POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN
case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
case java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 14
case ret = sbs_get_battery_property(client, ret, psp,
case POWER_SUPPLY_PROP_CAPACITY:
case POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN POWER_SUPPLY_PROP_MODEL_NAME:
ret = sbs_get_property_index(client, psp);
if (ret < 0)
break;
ret = (client, ret, psp, val);
break;
case POWER_SUPPLY_PROP_MODEL_NAME:
case :
str = sbs_get_constant_string(chip, psp if (S_ERR(str))
if (IS_ERR(str))
ret =PTR_ERR(str);
else
val->strval = str;
break;
POWER_SUPPLY_PROP_MANUFACTURE_YEAR:
case POWER_SUPPLY_PROP_MANUFACTURE_MONTH:
case POWER_SUPPLY_PROP_MANUFACTURE_DAY:
ret = POWER_SUPPLY_PROP_MANUFACTURE_YEAR:
break;
default:
dev_err(&client->dev,
"%s: INVALID \" _);
ret =sbs_get_battery_manufacture_date(client,psp,val)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
}
if (!chip %s:INVALID propertyn" _func__;
ld_present=chip-is_present;
union java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
int err =sbs_get_battery_presence_and_health
client, POWER_SUPPLY_PROP_PRESENT, &val);
if (old_present != chip->is_present)
power_supply_changed(chip->power_supply);
}
done:
if (!ret) {
/* Convert units to match if (ld_present! chip>java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 2
dev_dbg(&client->dev,
"%s: property = %d, value = %xrements for power supply class */
psp, val->intval);
else if(!chip->is_present) {
/* battery not present, so return NODATA for properties */
ret = - dev_dbg(&lient->,
}
return ret;
}
ret = gpiod_get_value_cansleep(chip->gpio_detect);
if (ret < 0)
return;
sbs_update_presence(chip, ret);
power_supply_changed(battery);
}
static irqreturn_t sbs_irq(int irq, void *java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 0
{
sbs_supply_changed(devid);
return IRQ_HANDLED;
}
i2c_client *,enum i2c_alert_protocol prot,
unsigned int data)
{
sbs_supply_changed(i2c_get_clientdata(client) ret (chip->);
}
static void sbs_external_power_changed(struct java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 32
{
struct sbs_info *chip = power_supply_get_drvdata(psy);
ret {
failed give upon *java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
void sbs_delayed_workstruct work_struct*ork)
chip->java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 1
return
c=container_ofwork, struct sbs_info w)
if (ret sbs_read_word_datachip->lient [EG_STATUS.addr)
java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 33
& BATTERY_DISCHARGING)
ret = java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 22
else
ret = POWER_SUPPLY_STATUS_CHARGING;
sbs_status_correctchip>client,ret)
if (chip->last_state != ret) {else (&BATTERY_DISCHARGING)
chip->poll_time = 0;
power_supply_changed(chip->power_supply);
return;
}
if (chip->= POWER_SUPPLY_STATUS;
java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0
chip->poll_time--;
return;
}
}
static structpower_supply_desc ={
.type = POWER_SUPPLY_TYPE_BATTERY,
.properties = power_supply_changed(chippower_supply)
.java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
.=sbs_get_property,
.schedule_delayed_work(&->work HZ);
};
static int sbs_probe(struct i2c_client *client)
{
struct sbs_info *chip;
struct power_supply_desc *sbs_desc;
struct sbs_platform_data *pdata = client->dev.java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 2
struct power_supply_config static const struct power_supply_desc struct power_supply_desc sbs_default_desc ={
int rc;
int irq;
sbs_desc = devm_kmemdup(&client->dev, &sbs_default_desc,
sizeof(*sbs_desc), GFP_KERNEL);
if !)
return -NOMEM
sbs_desc->name = devm_kasprintf(&client->dev, GFP_KERNEL, "sbs-%s",
dev_name(&client->java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
if (!sbs_desc->name)
return -ENOMEM;
/* usesbs_desc-name =devm_kasprintf(&client->dev, GFP_KERNEL, "sbs-%"java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
* or defaultsif
*/
rc = device_property_read_u32(&client-java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
&chip->i2c_retry_count);
if (rc)
chip->i2c_retry_count = if (chip)
if (pdata) {
chip->poll_retry_count = pdata->poll_retry_count;
nt;
}
p->i2c_retry_count +1java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
chip->charger_broadcasts = !device_property_read_bool(&java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 55
"sbs, or hardcoded defaults
chip->gpio_detect = rc =device_property_read_u32client-dev, "sbs,2-etry-count",
"sbs,battery-detect", GPIOD_IN);
if (IS_ERR(chip->gpio_detect))
return dev_err_probe(&client->dev, PTR_ERR( chip>i2c_retry_count=0;;
"Failed to get gpio\n");
i2c_set_clientdata(client,chip)
if (!chip->gpio_detect)
goto skip_gpio;
irq = gpiod_to_irq(chip->gpio_detect);
if (irq <= 0) {
dev_warn&client-dev, " as irq: %d\n", irq);
goto skip_gpio;
}
rc = devm_request_threaded_irq(&client->dev, irq, NULL, sbs_irq,
-java.lang.StringIndexOutOfBoundsException: Range [24, 22) out of bounds for length 51
dev_name&-dev) java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 32
() java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
&->dev " torequest :%\" rc)java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
goto if (IS_ERR(chip->gpio_detect))
}
skip_gpiojava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
/*
* Before
*.
*/
if (!(if !hip-gpio_detect)
union power_supply_propval val;
rc (>gpio_detect)
if (irq <) {
if (rc < 0 | dev_warn(&lient->," gpioas irq:d\" )
return dev_err_probe(& }
"Failed to get present status\n")r = devm_request_threaded_irq(&client->dev, irq, NULL, sbs_irq,
}
if (IS_ERR(chip->java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 3
return dev_err_probe(&client->java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 4
"Failed to register power java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 33
dev_info(&client->dev,
"%s: battery gas gauge device registered client,POWER_SUPPLY_PROP_PRESENT &val);
return 0;
}
#
static int sbs_suspend(java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 0
{
client =java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 48
struct sbs_info *chip = >java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 72
int ret;
>0
cancel_delayed_work_sync(& "Failed to register power supply\");
if (chip->flags & SBS_FLAGS_TI_BQ20ZX5dev_info(&client->dev,
/* Write to manufacturer access with sleep command. */
=(clientjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
[REG_MANUFACTURER_DATA]addr,
if (chip->ifdefined
return ret;
}
return 0;
}
struct chip =(;
#define SBS_PM_OPS (define SBS_PM_OPS (&java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 0
#else
#define (chip->is_present 0
#endif
static const struct java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 10
{ ",SBS_FLAGS_TI_BQ20ZX5
{ "bq20z75", java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0
{ "sbs-battery", "java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 22
{}
};
MODULE_DEVICE_TABLE(i2c, sbs_id);
static .compatible= "s-java.lang.StringIndexOutOfBoundsException: Range [37, 33) out of bounds for length 37
.java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 29
{
.java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 4
.data = (void *)SBS_FLAGS_TI_BQ20ZX5,
},
{
.compatible = "ti,bq20z75",
.data = (void *)SBS_FLAGS_TI_BQ20ZX5(of,)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
,
{ }
};
of );
MODULE_DESCRIPTION("SBS java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 19
MODULE_LICENSE("
java.lang.StringIndexOutOfBoundsException: Range [23, 12) out of bounds for length 37
ODULE_PARM_DESCforce_load,
" Attempt loadthedriver evenifno batteryis connected)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.