@@ -152,13 +152,38 @@ static const struct regmap_config adp5585_regmap_config_template = {
.num_reg_defaults_raw = ADP5585_MAX_REG + 1,
};
-static int adp5585_fill_regmap_config(const struct adp5585_dev *adp5585,
- struct regmap_config *regmap_config)
+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 int adp5585_fill_chip_configs(struct adp5585_dev *adp5585,
+ struct i2c_client *i2c,
+ struct regmap_config *regmap_config)
{
- if (adp5585->info->id == ADP5585_MAN_ID_VALUE)
+ struct adp5585_info *info;
+
+ info = (struct adp5585_info *)i2c_get_match_data(i2c);
+ if (!info)
+ return -ENODEV;
+
+ switch (info->id) {
+ case ADP5585_MAN_ID_VALUE:
*regmap_config = adp5585_regmap_config_template;
- else
+ info->regs = &adp5585_regs;
+ break;
+ case ADP5589_MAN_ID_VALUE:
*regmap_config = adp5589_regmap_config_template;
+ info->regs = &adp5589_regs;
+ break;
+ default:
+ return -ENODEV;
+ }
+
+ adp5585->info = info;
switch (adp5585->info->regmap_type) {
case ADP5585_REGMAP_00:
@@ -238,11 +263,7 @@ static int adp5585_i2c_probe(struct i2c_client *i2c)
i2c_set_clientdata(i2c, adp5585);
- adp5585->info = i2c_get_match_data(i2c);
- if (!adp5585->info)
- return -ENODEV;
-
- ret = adp5585_fill_regmap_config(adp5585, ®map_config);
+ ret = adp5585_fill_chip_configs(adp5585, i2c, ®map_config);
if (ret)
return ret;
@@ -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
@@ -134,7 +135,12 @@ enum adp5585_regmap_type {
ADP5589_REGMAP_02,
};
+struct adp5585_regs {
+ unsigned int ext_cfg;
+};
+
struct adp5585_info {
+ const struct adp5585_regs *regs;
enum adp5585_regmap_type regmap_type;
unsigned int id;
};