mfd: 88pm886: Initialize the battery page

Initialize the PMIC's battery page. The battery page registers are
shared between Vbus regulator, charger, fuelgauge and camera flash
blocks, hence the commonization of the page.

Signed-off-by: Duje Mihanović <duje@dujemihanovic.xyz>
Reviewed-by: Karel Balej <balejk@matfyz.cz>
Link: https://patch.msgid.link/20260613-88pm886-vbus-v2-2-021dfb02c6bb@dujemihanovic.xyz
Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
Duje Mihanović
2026-06-13 16:20:54 +02:00
committed by Lee Jones
parent 6ebc88313c
commit 824b2c8473
2 changed files with 25 additions and 1 deletions

View File

@@ -16,6 +16,12 @@ static const struct regmap_config pm886_regmap_config = {
.max_register = PM886_REG_RTC_SPARE6,
};
static const struct regmap_config pm886_regmap_battery_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = PM886_REG_CLS_CONFIG1,
};
static const struct regmap_irq pm886_regmap_irqs[] = {
REGMAP_IRQ_REG(PM886_IRQ_ONKEY, 0, PM886_INT_ENA1_ONKEY),
};
@@ -85,10 +91,11 @@ static int pm886_setup_irq(struct pm886_chip *chip,
static int pm886_probe(struct i2c_client *client)
{
struct regmap *regmap, *regmap_battery;
struct regmap_irq_chip_data *irq_data;
struct device *dev = &client->dev;
struct i2c_client *battery_page;
struct pm886_chip *chip;
struct regmap *regmap;
unsigned int chip_id;
int err;
@@ -112,6 +119,18 @@ static int pm886_probe(struct i2c_client *client)
if (chip->chip_id != chip_id)
return dev_err_probe(dev, -EINVAL, "Unsupported chip: 0x%x\n", chip_id);
battery_page = devm_i2c_new_dummy_device(dev, client->adapter,
client->addr + PM886_PAGE_OFFSET_BATTERY);
if (IS_ERR(battery_page))
return dev_err_probe(dev, PTR_ERR(battery_page),
"Failed to initialize battery page\n");
regmap_battery = devm_regmap_init_i2c(battery_page, &pm886_regmap_battery_config);
if (IS_ERR(regmap_battery))
return dev_err_probe(dev, PTR_ERR(regmap_battery),
"Failed to initialize battery regmap\n");
chip->regmap_battery = regmap_battery;
err = pm886_setup_irq(chip, &irq_data);
if (err)
return err;

View File

@@ -11,6 +11,7 @@
#define PM886_PAGE_OFFSET_REGULATORS 1
#define PM886_PAGE_OFFSET_GPADC 2
#define PM886_PAGE_OFFSET_BATTERY 3
#define PM886_REG_ID 0x00
@@ -128,9 +129,13 @@
#define PM886_GPADC_BIAS_LEVELS 16
#define PM886_GPADC_INDEX_TO_BIAS_uA(i) (1 + (i) * 5)
/* Battery block register definitions */
#define PM886_REG_CLS_CONFIG1 0x71
struct pm886_chip {
struct i2c_client *client;
unsigned int chip_id;
struct regmap *regmap;
struct regmap *regmap_battery;
};
#endif /* __MFD_88PM886_H */