]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mfd: adp5585: Add a per chip reg struture
authorNuno Sá <nuno.sa@analog.com>
Tue, 1 Jul 2025 14:32:03 +0000 (15:32 +0100)
committerLee Jones <lee@kernel.org>
Tue, 1 Jul 2025 20:50:51 +0000 (21:50 +0100)
There are some differences in the register map between the devices.
Hence, add a register structure per device. This will be needed in
following patches.

On top of that adp5585_fill_regmap_config() is renamed and reworked so
that the current struct adp5585_info act as template (they indeed
contain all the different data between variants) which can then be
complemented depending on the device (as identified by the id register).
This is done like this since a lot of the data is pretty much the same
between variants of the same device.

Reviewed-by: Lee Jones <lee@kernel.org>
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20250701-dev-adp5589-fw-v7-8-b1fcfe9e9826@analog.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/adp5585.c
include/linux/mfd/adp5585.h

index 00996571ef900bece2d634cd9d05394fa04d550a..ae12372bdde9141034b28731e22758948438cb31 100644 (file)
@@ -163,6 +163,14 @@ static const struct regmap_config adp5589_regmap_config_template = {
        .num_reg_defaults_raw = ADP5589_MAX_REG + 1,
 };
 
+static const struct adp5585_regs adp5585_regs = {
+       .ext_cfg = ADP5585_PIN_CONFIG_C,
+};
+
+static const struct adp5585_regs adp5589_regs = {
+       .ext_cfg = ADP5589_PIN_CONFIG_D,
+};
+
 static struct regmap_config *adp5585_fill_variant_config(struct adp5585_dev *adp5585)
 {
        struct regmap_config *regmap_config;
@@ -174,6 +182,7 @@ static struct regmap_config *adp5585_fill_variant_config(struct adp5585_dev *adp
        case ADP5585_03:
        case ADP5585_04:
                adp5585->id = ADP5585_MAN_ID_VALUE;
+               adp5585->regs = &adp5585_regs;
                regmap_config = devm_kmemdup(adp5585->dev, &adp5585_regmap_config_template,
                                             sizeof(*regmap_config), GFP_KERNEL);
                break;
@@ -181,6 +190,7 @@ static struct regmap_config *adp5585_fill_variant_config(struct adp5585_dev *adp
        case ADP5589_01:
        case ADP5589_02:
                adp5585->id = ADP5589_MAN_ID_VALUE;
+               adp5585->regs = &adp5589_regs;
                regmap_config = devm_kmemdup(adp5585->dev, &adp5589_regmap_config_template,
                                             sizeof(*regmap_config), GFP_KERNEL);
                break;
index 70e58122a36a7321dc95d095b806f06fa57c97c9..6ecb90a6276c0f8f2c983c62c7268505d74b6583 100644 (file)
 /* ADP5589 */
 #define                ADP5589_MAN_ID_VALUE            0x10
 #define ADP5589_GPI_STATUS_C           0x18
+#define ADP5589_PIN_CONFIG_D           0x4C
 #define ADP5589_INT_EN                 0x4e
 #define ADP5589_MAX_REG                        ADP5589_INT_EN
 
@@ -137,9 +138,14 @@ enum adp5585_variant {
        ADP5585_MAX
 };
 
+struct adp5585_regs {
+       unsigned int ext_cfg;
+};
+
 struct adp5585_dev {
        struct device *dev;
        struct regmap *regmap;
+       const struct adp5585_regs *regs;
        enum adp5585_variant variant;
        unsigned int id;
 };