]> git.dujemihanovic.xyz Git - linux.git/commitdiff
mfd: 88pm88x: initialize the regulators regmaps
authorKarel Balej <balejk@matfyz.cz>
Wed, 27 Dec 2023 19:45:12 +0000 (20:45 +0100)
committerDuje Mihanović <duje.mihanovic@skole.hr>
Sat, 20 Jan 2024 19:52:01 +0000 (20:52 +0100)
The regulators registers are accessed via a different I2C address than
the already implemented functionality. Initialize the new regmap for the
regulator driver to use. For 88PM886 the buck regmap is the same as LDO
regmap, however this is not the case for 88PM880.

Signed-off-by: Karel Balej <balejk@matfyz.cz>
drivers/mfd/88pm88x.c
include/linux/mfd/88pm88x.h

index 3424d88a58f6be10b4b65d4847902ef5b63629ef..69a8e39d43b3809fa9e46f5d6b13d6cf3c9934cb 100644 (file)
@@ -98,6 +98,35 @@ static int pm88x_power_off_handler(struct sys_off_data *data)
        return NOTIFY_DONE;
 }
 
+static int pm88x_initialize_subregmaps(struct pm88x_chip *chip)
+{
+       struct i2c_client *page;
+       struct regmap *regmap;
+       int ret;
+
+       /* LDO page */
+       page = devm_i2c_new_dummy_device(&chip->client->dev, chip->client->adapter,
+                                       chip->client->addr + PM88X_PAGE_OFFSET_LDO);
+       if (IS_ERR(page)) {
+               ret = PTR_ERR(page);
+               dev_err(&chip->client->dev, "Failed to initialize LDO client: %d\n",
+                               ret);
+               return ret;
+       }
+       regmap = devm_regmap_init_i2c(page, &pm88x_i2c_regmap);
+       if (IS_ERR(regmap)) {
+               ret = PTR_ERR(regmap);
+               dev_err(&chip->client->dev, "Failed to initialize LDO regmap: %d\n",
+                               ret);
+               return ret;
+       }
+       chip->regmaps[PM88X_REGMAP_LDO] = regmap;
+       /* buck regmap is the same as LDO */
+       chip->regmaps[PM88X_REGMAP_BUCK] = regmap;
+
+       return 0;
+}
+
 static int pm88x_setup_irq(struct pm88x_chip *chip)
 {
        int ret;
@@ -155,6 +184,10 @@ static int pm88x_probe(struct i2c_client *client)
                return -EINVAL;
        }
 
+       ret = pm88x_initialize_subregmaps(chip);
+       if (ret)
+               return ret;
+
        ret = pm88x_setup_irq(chip);
        if (ret)
                return ret;
index 9a335f6b9c07969464bb95447e70c04b73265ee3..703e6104c1d87962ac0875699181c93ef6975f9e 100644 (file)
 
 #define PM88X_REG_AON_CTRL2            0xe2
 
+#define PM88X_PAGE_OFFSET_LDO          1
+
 enum pm88x_regmap_index {
        PM88X_REGMAP_BASE,
+       PM88X_REGMAP_LDO,
+       PM88X_REGMAP_BUCK,
 
        PM88X_REGMAP_NR
 };