Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mfd: adp5585: Add a per chip reg struture

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>

authored by

Nuno Sá and committed by
Lee Jones
7077fb50 0190a72f

+16
+10
drivers/mfd/adp5585.c
··· 163 163 .num_reg_defaults_raw = ADP5589_MAX_REG + 1, 164 164 }; 165 165 166 + static const struct adp5585_regs adp5585_regs = { 167 + .ext_cfg = ADP5585_PIN_CONFIG_C, 168 + }; 169 + 170 + static const struct adp5585_regs adp5589_regs = { 171 + .ext_cfg = ADP5589_PIN_CONFIG_D, 172 + }; 173 + 166 174 static struct regmap_config *adp5585_fill_variant_config(struct adp5585_dev *adp5585) 167 175 { 168 176 struct regmap_config *regmap_config; ··· 182 174 case ADP5585_03: 183 175 case ADP5585_04: 184 176 adp5585->id = ADP5585_MAN_ID_VALUE; 177 + adp5585->regs = &adp5585_regs; 185 178 regmap_config = devm_kmemdup(adp5585->dev, &adp5585_regmap_config_template, 186 179 sizeof(*regmap_config), GFP_KERNEL); 187 180 break; ··· 190 181 case ADP5589_01: 191 182 case ADP5589_02: 192 183 adp5585->id = ADP5589_MAN_ID_VALUE; 184 + adp5585->regs = &adp5589_regs; 193 185 regmap_config = devm_kmemdup(adp5585->dev, &adp5589_regmap_config_template, 194 186 sizeof(*regmap_config), GFP_KERNEL); 195 187 break;
+6
include/linux/mfd/adp5585.h
··· 120 120 /* ADP5589 */ 121 121 #define ADP5589_MAN_ID_VALUE 0x10 122 122 #define ADP5589_GPI_STATUS_C 0x18 123 + #define ADP5589_PIN_CONFIG_D 0x4C 123 124 #define ADP5589_INT_EN 0x4e 124 125 #define ADP5589_MAX_REG ADP5589_INT_EN 125 126 ··· 138 137 ADP5585_MAX 139 138 }; 140 139 140 + struct adp5585_regs { 141 + unsigned int ext_cfg; 142 + }; 143 + 141 144 struct adp5585_dev { 142 145 struct device *dev; 143 146 struct regmap *regmap; 147 + const struct adp5585_regs *regs; 144 148 enum adp5585_variant variant; 145 149 unsigned int id; 146 150 };