Commit 7077fb50 authored by Nuno Sá's avatar Nuno Sá Committed by Lee Jones
Browse files

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: default avatarLee Jones <lee@kernel.org>
Signed-off-by: default avatarNuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20250701-dev-adp5589-fw-v7-8-b1fcfe9e9826@analog.com


Signed-off-by: default avatarLee Jones <lee@kernel.org>
parent 0190a72f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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;
+6 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@
/* 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;
};