Commit 13186dae authored by Benjamin Bara's avatar Benjamin Bara Committed by Mark Brown

regulator: da9063: add voltage monitoring registers

Add the definitions for the registers responsible for voltage
monitoring. Add a voltage monitor enable bitfield per regulator.
Reviewed-by: default avatarMatti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: default avatarAdam Ward <DLG-Adam.Ward.opensource@dm.renesas.com>
Signed-off-by: default avatarBenjamin Bara <benjamin.bara@skidata.com>
Link: https://lore.kernel.org/r/20230403-da9063-disable-unused-v3-1-cc4dc698864c@skidata.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 53e59b5c
...@@ -83,6 +83,9 @@ struct da9063_regulator_info { ...@@ -83,6 +83,9 @@ struct da9063_regulator_info {
/* DA9063 event detection bit */ /* DA9063 event detection bit */
struct reg_field oc_event; struct reg_field oc_event;
/* DA9063 voltage monitor bit */
struct reg_field vmon;
}; };
/* Macros for LDO */ /* Macros for LDO */
...@@ -148,6 +151,7 @@ struct da9063_regulator { ...@@ -148,6 +151,7 @@ struct da9063_regulator {
struct regmap_field *suspend; struct regmap_field *suspend;
struct regmap_field *sleep; struct regmap_field *sleep;
struct regmap_field *suspend_sleep; struct regmap_field *suspend_sleep;
struct regmap_field *vmon;
}; };
/* Encapsulates all information for the regulators driver */ /* Encapsulates all information for the regulators driver */
...@@ -581,36 +585,42 @@ static const struct da9063_regulator_info da9063_regulator_info[] = { ...@@ -581,36 +585,42 @@ static const struct da9063_regulator_info da9063_regulator_info[] = {
da9063_buck_a_limits, da9063_buck_a_limits,
DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK), DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK),
DA9063_BUCK_COMMON_FIELDS(BCORE1), DA9063_BUCK_COMMON_FIELDS(BCORE1),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_4, DA9063_BCORE1_MON_EN),
}, },
{ {
DA9063_BUCK(DA9063, BCORE2, 300, 10, 1570, DA9063_BUCK(DA9063, BCORE2, 300, 10, 1570,
da9063_buck_a_limits, da9063_buck_a_limits,
DA9063_REG_BUCK_ILIM_C, DA9063_BCORE2_ILIM_MASK), DA9063_REG_BUCK_ILIM_C, DA9063_BCORE2_ILIM_MASK),
DA9063_BUCK_COMMON_FIELDS(BCORE2), DA9063_BUCK_COMMON_FIELDS(BCORE2),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_4, DA9063_BCORE2_MON_EN),
}, },
{ {
DA9063_BUCK(DA9063, BPRO, 530, 10, 1800, DA9063_BUCK(DA9063, BPRO, 530, 10, 1800,
da9063_buck_a_limits, da9063_buck_a_limits,
DA9063_REG_BUCK_ILIM_B, DA9063_BPRO_ILIM_MASK), DA9063_REG_BUCK_ILIM_B, DA9063_BPRO_ILIM_MASK),
DA9063_BUCK_COMMON_FIELDS(BPRO), DA9063_BUCK_COMMON_FIELDS(BPRO),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_4, DA9063_BPRO_MON_EN),
}, },
{ {
DA9063_BUCK(DA9063, BMEM, 800, 20, 3340, DA9063_BUCK(DA9063, BMEM, 800, 20, 3340,
da9063_buck_b_limits, da9063_buck_b_limits,
DA9063_REG_BUCK_ILIM_A, DA9063_BMEM_ILIM_MASK), DA9063_REG_BUCK_ILIM_A, DA9063_BMEM_ILIM_MASK),
DA9063_BUCK_COMMON_FIELDS(BMEM), DA9063_BUCK_COMMON_FIELDS(BMEM),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_4, DA9063_BMEM_MON_EN),
}, },
{ {
DA9063_BUCK(DA9063, BIO, 800, 20, 3340, DA9063_BUCK(DA9063, BIO, 800, 20, 3340,
da9063_buck_b_limits, da9063_buck_b_limits,
DA9063_REG_BUCK_ILIM_A, DA9063_BIO_ILIM_MASK), DA9063_REG_BUCK_ILIM_A, DA9063_BIO_ILIM_MASK),
DA9063_BUCK_COMMON_FIELDS(BIO), DA9063_BUCK_COMMON_FIELDS(BIO),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_4, DA9063_BIO_MON_EN),
}, },
{ {
DA9063_BUCK(DA9063, BPERI, 800, 20, 3340, DA9063_BUCK(DA9063, BPERI, 800, 20, 3340,
da9063_buck_b_limits, da9063_buck_b_limits,
DA9063_REG_BUCK_ILIM_B, DA9063_BPERI_ILIM_MASK), DA9063_REG_BUCK_ILIM_B, DA9063_BPERI_ILIM_MASK),
DA9063_BUCK_COMMON_FIELDS(BPERI), DA9063_BUCK_COMMON_FIELDS(BPERI),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_4, DA9063_BPERI_MON_EN),
}, },
{ {
DA9063_BUCK(DA9063, BCORES_MERGED, 300, 10, 1570, DA9063_BUCK(DA9063, BCORES_MERGED, 300, 10, 1570,
...@@ -618,6 +628,7 @@ static const struct da9063_regulator_info da9063_regulator_info[] = { ...@@ -618,6 +628,7 @@ static const struct da9063_regulator_info da9063_regulator_info[] = {
DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK), DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK),
/* BCORES_MERGED uses the same register fields as BCORE1 */ /* BCORES_MERGED uses the same register fields as BCORE1 */
DA9063_BUCK_COMMON_FIELDS(BCORE1), DA9063_BUCK_COMMON_FIELDS(BCORE1),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_4, DA9063_BCORE1_MON_EN),
}, },
{ {
DA9063_BUCK(DA9063, BMEM_BIO_MERGED, 800, 20, 3340, DA9063_BUCK(DA9063, BMEM_BIO_MERGED, 800, 20, 3340,
...@@ -625,47 +636,59 @@ static const struct da9063_regulator_info da9063_regulator_info[] = { ...@@ -625,47 +636,59 @@ static const struct da9063_regulator_info da9063_regulator_info[] = {
DA9063_REG_BUCK_ILIM_A, DA9063_BMEM_ILIM_MASK), DA9063_REG_BUCK_ILIM_A, DA9063_BMEM_ILIM_MASK),
/* BMEM_BIO_MERGED uses the same register fields as BMEM */ /* BMEM_BIO_MERGED uses the same register fields as BMEM */
DA9063_BUCK_COMMON_FIELDS(BMEM), DA9063_BUCK_COMMON_FIELDS(BMEM),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_4, DA9063_BMEM_MON_EN),
}, },
{ {
DA9063_LDO(DA9063, LDO3, 900, 20, 3440), DA9063_LDO(DA9063, LDO3, 900, 20, 3440),
.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO3_LIM), .oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO3_LIM),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_2, DA9063_LDO3_MON_EN),
}, },
{ {
DA9063_LDO(DA9063, LDO7, 900, 50, 3600), DA9063_LDO(DA9063, LDO7, 900, 50, 3600),
.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO7_LIM), .oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO7_LIM),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_2, DA9063_LDO7_MON_EN),
}, },
{ {
DA9063_LDO(DA9063, LDO8, 900, 50, 3600), DA9063_LDO(DA9063, LDO8, 900, 50, 3600),
.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO8_LIM), .oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO8_LIM),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_2, DA9063_LDO8_MON_EN),
}, },
{ {
DA9063_LDO(DA9063, LDO9, 950, 50, 3600), DA9063_LDO(DA9063, LDO9, 950, 50, 3600),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_3, DA9063_LDO9_MON_EN),
}, },
{ {
DA9063_LDO(DA9063, LDO11, 900, 50, 3600), DA9063_LDO(DA9063, LDO11, 900, 50, 3600),
.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO11_LIM), .oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO11_LIM),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_3, DA9063_LDO11_MON_EN),
}, },
/* The following LDOs are present only on DA9063, not on DA9063L */ /* The following LDOs are present only on DA9063, not on DA9063L */
{ {
DA9063_LDO(DA9063, LDO1, 600, 20, 1860), DA9063_LDO(DA9063, LDO1, 600, 20, 1860),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_2, DA9063_LDO1_MON_EN),
}, },
{ {
DA9063_LDO(DA9063, LDO2, 600, 20, 1860), DA9063_LDO(DA9063, LDO2, 600, 20, 1860),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_2, DA9063_LDO2_MON_EN),
}, },
{ {
DA9063_LDO(DA9063, LDO4, 900, 20, 3440), DA9063_LDO(DA9063, LDO4, 900, 20, 3440),
.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO4_LIM), .oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO4_LIM),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_2, DA9063_LDO4_MON_EN),
}, },
{ {
DA9063_LDO(DA9063, LDO5, 900, 50, 3600), DA9063_LDO(DA9063, LDO5, 900, 50, 3600),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_2, DA9063_LDO5_MON_EN),
}, },
{ {
DA9063_LDO(DA9063, LDO6, 900, 50, 3600), DA9063_LDO(DA9063, LDO6, 900, 50, 3600),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_2, DA9063_LDO6_MON_EN),
}, },
{ {
DA9063_LDO(DA9063, LDO10, 900, 50, 3600), DA9063_LDO(DA9063, LDO10, 900, 50, 3600),
.vmon = BFIELD(DA9063_BB_REG_MON_REG_3, DA9063_LDO10_MON_EN),
}, },
}; };
...@@ -932,6 +955,12 @@ static int da9063_regulator_probe(struct platform_device *pdev) ...@@ -932,6 +955,12 @@ static int da9063_regulator_probe(struct platform_device *pdev)
if (IS_ERR(regl->suspend_sleep)) if (IS_ERR(regl->suspend_sleep))
return PTR_ERR(regl->suspend_sleep); return PTR_ERR(regl->suspend_sleep);
} }
if (regl->info->vmon.reg) {
regl->vmon = devm_regmap_field_alloc(&pdev->dev,
da9063->regmap, regl->info->vmon);
if (IS_ERR(regl->vmon))
return PTR_ERR(regl->vmon);
}
/* Register regulator */ /* Register regulator */
memset(&config, 0, sizeof(config)); memset(&config, 0, sizeof(config));
......
...@@ -1040,6 +1040,29 @@ ...@@ -1040,6 +1040,29 @@
/* DA9063_REG_CONFIG_J (addr=0x10F) */ /* DA9063_REG_CONFIG_J (addr=0x10F) */
#define DA9063_TWOWIRE_TO 0x40 #define DA9063_TWOWIRE_TO 0x40
/* DA9063_REG_MON_REG_2 (addr=0x115) */
#define DA9063_LDO1_MON_EN 0x01
#define DA9063_LDO2_MON_EN 0x02
#define DA9063_LDO3_MON_EN 0x04
#define DA9063_LDO4_MON_EN 0x08
#define DA9063_LDO5_MON_EN 0x10
#define DA9063_LDO6_MON_EN 0x20
#define DA9063_LDO7_MON_EN 0x40
#define DA9063_LDO8_MON_EN 0x80
/* DA9063_REG_MON_REG_3 (addr=0x116) */
#define DA9063_LDO9_MON_EN 0x01
#define DA9063_LDO10_MON_EN 0x02
#define DA9063_LDO11_MON_EN 0x04
/* DA9063_REG_MON_REG_4 (addr=0x117) */
#define DA9063_BCORE1_MON_EN 0x04
#define DA9063_BCORE2_MON_EN 0x08
#define DA9063_BPRO_MON_EN 0x10
#define DA9063_BIO_MON_EN 0x20
#define DA9063_BMEM_MON_EN 0x40
#define DA9063_BPERI_MON_EN 0x80
/* DA9063_REG_MON_REG_5 (addr=0x116) */ /* DA9063_REG_MON_REG_5 (addr=0x116) */
#define DA9063_MON_A8_IDX_MASK 0x07 #define DA9063_MON_A8_IDX_MASK 0x07
#define DA9063_MON_A8_IDX_NONE 0x00 #define DA9063_MON_A8_IDX_NONE 0x00
......
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