Commit 2e05b518 authored by Andrew F. Davis's avatar Andrew F. Davis Committed by Sebastian Reichel

power_supply: bq27xxx_battery: Group register mappings into one table

Currently for each device with a unique register map we have a named
array that we then merge into a multidimensional array. Skip this
middle step and apply the register arrays directly to the multi-array.
Signed-off-by: default avatarAndrew F. Davis <afd@ti.com>
Acked-by: default avatarPali Rohár <pali.rohar@gmail.com>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent 7a4f9830
......@@ -82,6 +82,7 @@
*
* These are indexes into a device's register mapping array.
*/
enum bq27xxx_reg_index {
BQ27XXX_REG_CTRL = 0, /* Control */
BQ27XXX_REG_TEMP, /* Temperature */
......@@ -100,10 +101,12 @@ enum bq27xxx_reg_index {
BQ27XXX_REG_SOC, /* State-of-Charge */
BQ27XXX_REG_DCAP, /* Design Capacity */
BQ27XXX_REG_AP, /* Average Power */
BQ27XXX_REG_MAX, /* sentinel */
};
/* Register mappings */
static u8 bq27000_regs[] = {
static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = {
[BQ27000] = {
[BQ27XXX_REG_CTRL] = 0x00,
[BQ27XXX_REG_TEMP] = 0x06,
[BQ27XXX_REG_INT_TEMP] = INVALID_REG_ADDR,
......@@ -121,9 +124,8 @@ static u8 bq27000_regs[] = {
[BQ27XXX_REG_SOC] = 0x0b,
[BQ27XXX_REG_DCAP] = 0x76,
[BQ27XXX_REG_AP] = 0x24,
};
static u8 bq27010_regs[] = {
},
[BQ27010] = {
[BQ27XXX_REG_CTRL] = 0x00,
[BQ27XXX_REG_TEMP] = 0x06,
[BQ27XXX_REG_INT_TEMP] = INVALID_REG_ADDR,
......@@ -141,9 +143,8 @@ static u8 bq27010_regs[] = {
[BQ27XXX_REG_SOC] = 0x0b,
[BQ27XXX_REG_DCAP] = 0x76,
[BQ27XXX_REG_AP] = INVALID_REG_ADDR,
};
static u8 bq27500_regs[] = {
},
[BQ27500] = {
[BQ27XXX_REG_CTRL] = 0x00,
[BQ27XXX_REG_TEMP] = 0x06,
[BQ27XXX_REG_INT_TEMP] = 0x28,
......@@ -161,9 +162,8 @@ static u8 bq27500_regs[] = {
[BQ27XXX_REG_SOC] = 0x2c,
[BQ27XXX_REG_DCAP] = 0x3c,
[BQ27XXX_REG_AP] = INVALID_REG_ADDR,
};
static u8 bq27530_regs[] = {
},
[BQ27530] = {
[BQ27XXX_REG_CTRL] = 0x00,
[BQ27XXX_REG_TEMP] = 0x06,
[BQ27XXX_REG_INT_TEMP] = 0x32,
......@@ -181,9 +181,8 @@ static u8 bq27530_regs[] = {
[BQ27XXX_REG_SOC] = 0x2c,
[BQ27XXX_REG_DCAP] = INVALID_REG_ADDR,
[BQ27XXX_REG_AP] = 0x24,
};
static u8 bq27541_regs[] = {
},
[BQ27541] = {
[BQ27XXX_REG_CTRL] = 0x00,
[BQ27XXX_REG_TEMP] = 0x06,
[BQ27XXX_REG_INT_TEMP] = 0x28,
......@@ -201,9 +200,8 @@ static u8 bq27541_regs[] = {
[BQ27XXX_REG_SOC] = 0x2c,
[BQ27XXX_REG_DCAP] = 0x3c,
[BQ27XXX_REG_AP] = 0x24,
};
static u8 bq27545_regs[] = {
},
[BQ27545] = {
[BQ27XXX_REG_CTRL] = 0x00,
[BQ27XXX_REG_TEMP] = 0x06,
[BQ27XXX_REG_INT_TEMP] = 0x28,
......@@ -221,9 +219,8 @@ static u8 bq27545_regs[] = {
[BQ27XXX_REG_SOC] = 0x2c,
[BQ27XXX_REG_DCAP] = INVALID_REG_ADDR,
[BQ27XXX_REG_AP] = 0x24,
};
static u8 bq27421_regs[] = {
},
[BQ27421] = {
[BQ27XXX_REG_CTRL] = 0x00,
[BQ27XXX_REG_TEMP] = 0x02,
[BQ27XXX_REG_INT_TEMP] = 0x1e,
......@@ -241,16 +238,7 @@ static u8 bq27421_regs[] = {
[BQ27XXX_REG_SOC] = 0x1c,
[BQ27XXX_REG_DCAP] = 0x3c,
[BQ27XXX_REG_AP] = 0x18,
};
static u8 *bq27xxx_regs[] = {
[BQ27000] = bq27000_regs,
[BQ27010] = bq27010_regs,
[BQ27500] = bq27500_regs,
[BQ27530] = bq27530_regs,
[BQ27541] = bq27541_regs,
[BQ27545] = bq27545_regs,
[BQ27421] = bq27421_regs,
},
};
static enum power_supply_property bq27000_battery_props[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment