Commit 4c58f701 authored by Dmitry Osipenko's avatar Dmitry Osipenko Committed by Lee Jones

mfd: max77620: Support Maxim 77663

Add support for Maxim 77663 using the Max77620 driver. The hardware
is very similar to Max77663/20024, although there are couple minor
differences.
Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent ea611d1c
...@@ -111,6 +111,26 @@ static const struct mfd_cell max20024_children[] = { ...@@ -111,6 +111,26 @@ static const struct mfd_cell max20024_children[] = {
}, },
}; };
static const struct mfd_cell max77663_children[] = {
{ .name = "max77620-pinctrl", },
{ .name = "max77620-clock", },
{ .name = "max77663-pmic", },
{ .name = "max77620-watchdog", },
{
.name = "max77620-gpio",
.resources = gpio_resources,
.num_resources = ARRAY_SIZE(gpio_resources),
}, {
.name = "max77620-rtc",
.resources = rtc_resources,
.num_resources = ARRAY_SIZE(rtc_resources),
}, {
.name = "max77663-power",
.resources = power_resources,
.num_resources = ARRAY_SIZE(power_resources),
},
};
static const struct regmap_range max77620_readable_ranges[] = { static const struct regmap_range max77620_readable_ranges[] = {
regmap_reg_range(MAX77620_REG_CNFGGLBL1, MAX77620_REG_DVSSD4), regmap_reg_range(MAX77620_REG_CNFGGLBL1, MAX77620_REG_DVSSD4),
}; };
...@@ -171,6 +191,35 @@ static const struct regmap_config max20024_regmap_config = { ...@@ -171,6 +191,35 @@ static const struct regmap_config max20024_regmap_config = {
.volatile_table = &max77620_volatile_table, .volatile_table = &max77620_volatile_table,
}; };
static const struct regmap_range max77663_readable_ranges[] = {
regmap_reg_range(MAX77620_REG_CNFGGLBL1, MAX77620_REG_CID5),
};
static const struct regmap_access_table max77663_readable_table = {
.yes_ranges = max77663_readable_ranges,
.n_yes_ranges = ARRAY_SIZE(max77663_readable_ranges),
};
static const struct regmap_range max77663_writable_ranges[] = {
regmap_reg_range(MAX77620_REG_CNFGGLBL1, MAX77620_REG_CID5),
};
static const struct regmap_access_table max77663_writable_table = {
.yes_ranges = max77663_writable_ranges,
.n_yes_ranges = ARRAY_SIZE(max77663_writable_ranges),
};
static const struct regmap_config max77663_regmap_config = {
.name = "power-slave",
.reg_bits = 8,
.val_bits = 8,
.max_register = MAX77620_REG_CID5 + 1,
.cache_type = REGCACHE_RBTREE,
.rd_table = &max77663_readable_table,
.wr_table = &max77663_writable_table,
.volatile_table = &max77620_volatile_table,
};
/* /*
* MAX77620 and MAX20024 has the following steps of the interrupt handling * MAX77620 and MAX20024 has the following steps of the interrupt handling
* for TOP interrupts: * for TOP interrupts:
...@@ -240,6 +289,9 @@ static int max77620_get_fps_period_reg_value(struct max77620_chip *chip, ...@@ -240,6 +289,9 @@ static int max77620_get_fps_period_reg_value(struct max77620_chip *chip,
case MAX77620: case MAX77620:
fps_min_period = MAX77620_FPS_PERIOD_MIN_US; fps_min_period = MAX77620_FPS_PERIOD_MIN_US;
break; break;
case MAX77663:
fps_min_period = MAX20024_FPS_PERIOD_MIN_US;
break;
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -274,6 +326,9 @@ static int max77620_config_fps(struct max77620_chip *chip, ...@@ -274,6 +326,9 @@ static int max77620_config_fps(struct max77620_chip *chip,
case MAX77620: case MAX77620:
fps_max_period = MAX77620_FPS_PERIOD_MAX_US; fps_max_period = MAX77620_FPS_PERIOD_MAX_US;
break; break;
case MAX77663:
fps_max_period = MAX20024_FPS_PERIOD_MAX_US;
break;
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -375,6 +430,9 @@ static int max77620_initialise_fps(struct max77620_chip *chip) ...@@ -375,6 +430,9 @@ static int max77620_initialise_fps(struct max77620_chip *chip)
} }
skip_fps: skip_fps:
if (chip->chip_id == MAX77663)
return 0;
/* Enable wake on EN0 pin */ /* Enable wake on EN0 pin */
ret = regmap_update_bits(chip->rmap, MAX77620_REG_ONOFFCNFG2, ret = regmap_update_bits(chip->rmap, MAX77620_REG_ONOFFCNFG2,
MAX77620_ONOFFCNFG2_WK_EN0, MAX77620_ONOFFCNFG2_WK_EN0,
...@@ -453,6 +511,11 @@ static int max77620_probe(struct i2c_client *client, ...@@ -453,6 +511,11 @@ static int max77620_probe(struct i2c_client *client,
n_mfd_cells = ARRAY_SIZE(max20024_children); n_mfd_cells = ARRAY_SIZE(max20024_children);
rmap_config = &max20024_regmap_config; rmap_config = &max20024_regmap_config;
break; break;
case MAX77663:
mfd_cells = max77663_children;
n_mfd_cells = ARRAY_SIZE(max77663_children);
rmap_config = &max77663_regmap_config;
break;
default: default:
dev_err(chip->dev, "ChipID is invalid %d\n", chip->chip_id); dev_err(chip->dev, "ChipID is invalid %d\n", chip->chip_id);
return -EINVAL; return -EINVAL;
...@@ -546,6 +609,9 @@ static int max77620_i2c_suspend(struct device *dev) ...@@ -546,6 +609,9 @@ static int max77620_i2c_suspend(struct device *dev)
return ret; return ret;
} }
if (chip->chip_id == MAX77663)
goto out;
/* Disable WK_EN0 */ /* Disable WK_EN0 */
ret = regmap_update_bits(chip->rmap, MAX77620_REG_ONOFFCNFG2, ret = regmap_update_bits(chip->rmap, MAX77620_REG_ONOFFCNFG2,
MAX77620_ONOFFCNFG2_WK_EN0, 0); MAX77620_ONOFFCNFG2_WK_EN0, 0);
...@@ -581,7 +647,7 @@ static int max77620_i2c_resume(struct device *dev) ...@@ -581,7 +647,7 @@ static int max77620_i2c_resume(struct device *dev)
* For MAX20024: No need to configure WKEN0 on resume as * For MAX20024: No need to configure WKEN0 on resume as
* it is configured on Init. * it is configured on Init.
*/ */
if (chip->chip_id == MAX20024) if (chip->chip_id == MAX20024 || chip->chip_id == MAX77663)
goto out; goto out;
/* Enable WK_EN0 */ /* Enable WK_EN0 */
...@@ -603,6 +669,7 @@ static int max77620_i2c_resume(struct device *dev) ...@@ -603,6 +669,7 @@ static int max77620_i2c_resume(struct device *dev)
static const struct i2c_device_id max77620_id[] = { static const struct i2c_device_id max77620_id[] = {
{"max77620", MAX77620}, {"max77620", MAX77620},
{"max20024", MAX20024}, {"max20024", MAX20024},
{"max77663", MAX77663},
{}, {},
}; };
......
...@@ -324,6 +324,7 @@ enum max77620_fps_src { ...@@ -324,6 +324,7 @@ enum max77620_fps_src {
enum max77620_chip_id { enum max77620_chip_id {
MAX77620, MAX77620,
MAX20024, MAX20024,
MAX77663,
}; };
struct max77620_chip { struct max77620_chip {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment