lkml.org 
[lkml]   [2021]   [Jun]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 2/2] regulator: da9063: Add support for full-current mode.
Date
In addition to the ability of merging some power outputs, this chip has
an overdrive/full-current mode.
BCORE1, BCORE2 and BPRO have this ability, in which case the legal
current draw is increased from 2 amps to 2.5 amps (at the expense of
a quiescent current increase), and the configurable current limits
are doubled.
So add configuration alternatives for these new combinations, with their
updated current limits.

Signed-off-by: Vincent Pelletier <plr.vincent@gmail.com>
---
V1 -> V2:
- skip DA9063_ID_BCORES_MERGED_OD when not full-current, and vice-versa
- cc linux-kernel ML
- fix subject prefix

drivers/regulator/da9063-regulator.c | 70 ++++++++++++++++++++++++++--
1 file changed, 66 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c
index 21f4ddb37b09..1193b2eb8c07 100644
--- a/drivers/regulator/da9063-regulator.c
+++ b/drivers/regulator/da9063-regulator.c
@@ -31,14 +31,19 @@
enum {
/* BUCKs */
DA9063_ID_BCORE1,
+ DA9063_ID_BCORE1_OD,
DA9063_ID_BCORE2,
+ DA9063_ID_BCORE2_OD,
DA9063_ID_BPRO,
+ DA9063_ID_BPRO_OD,
DA9063_ID_BMEM,
DA9063_ID_BIO,
DA9063_ID_BPERI,

/* BCORE1 and BCORE2 in merged mode */
DA9063_ID_BCORES_MERGED,
+ /* BCORE1 and BCORE2 in merged and full-current mode */
+ DA9063_ID_BCORES_MERGED_OD,
/* BMEM and BIO in merged mode */
DA9063_ID_BMEM_BIO_MERGED,
/* When two BUCKs are merged, they cannot be reused separately */
@@ -186,7 +191,8 @@ static const unsigned int da9063_buck_b_limits[] = {
};

/*
- * Current limits array (in uA) for merged BCORE1 and BCORE2.
+ * Current limits array (in uA) for merged BCORE1 and BCORE2, or
+ * BCORE1, BCORE2, BPRO in fullcurrent mode.
* Entry indexes corresponds to register values.
*/
static const unsigned int da9063_bcores_merged_limits[] = {
@@ -203,6 +209,16 @@ static const unsigned int da9063_bmem_bio_merged_limits[] = {
4600000, 4800000, 5000000, 5200000, 5400000, 5600000, 5800000, 6000000
};

+/*
+ * Current limits array (in uA) for merged BCORE
+ * in full-current mode.
+ * Entry indexes corresponds to register values.
+ */
+static const unsigned int da9063_bcores_merged_fullcurrent_limits[] = {
+ 2000000, 2400000, 2800000, 3200000, 3600000, 4000000, 4400000, 4800000,
+ 5200000, 5600000, 6000000, 6400000, 6800000, 7200000, 7600000, 8000000
+};
+
static int da9063_buck_set_mode(struct regulator_dev *rdev, unsigned int mode)
{
struct da9063_regulator *regl = rdev_get_drvdata(rdev);
@@ -454,18 +470,36 @@ static const struct da9063_regulator_info da9063_regulator_info[] = {
DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK),
DA9063_BUCK_COMMON_FIELDS(BCORE1),
},
+ {
+ DA9063_BUCK(DA9063, BCORE1_OD, 300, 10, 1570,
+ da9063_bcores_merged_limits,
+ DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK),
+ DA9063_BUCK_COMMON_FIELDS(BCORE1),
+ },
{
DA9063_BUCK(DA9063, BCORE2, 300, 10, 1570,
da9063_buck_a_limits,
DA9063_REG_BUCK_ILIM_C, DA9063_BCORE2_ILIM_MASK),
DA9063_BUCK_COMMON_FIELDS(BCORE2),
},
+ {
+ DA9063_BUCK(DA9063, BCORE2_OD, 300, 10, 1570,
+ da9063_bcores_merged_limits,
+ DA9063_REG_BUCK_ILIM_C, DA9063_BCORE2_ILIM_MASK),
+ DA9063_BUCK_COMMON_FIELDS(BCORE2),
+ },
{
DA9063_BUCK(DA9063, BPRO, 530, 10, 1800,
da9063_buck_a_limits,
DA9063_REG_BUCK_ILIM_B, DA9063_BPRO_ILIM_MASK),
DA9063_BUCK_COMMON_FIELDS(BPRO),
},
+ {
+ DA9063_BUCK(DA9063, BPRO_OD, 530, 10, 1800,
+ da9063_bcores_merged_limits,
+ DA9063_REG_BUCK_ILIM_B, DA9063_BPRO_ILIM_MASK),
+ DA9063_BUCK_COMMON_FIELDS(BPRO),
+ },
{
DA9063_BUCK(DA9063, BMEM, 800, 20, 3340,
da9063_buck_b_limits,
@@ -491,6 +525,13 @@ static const struct da9063_regulator_info da9063_regulator_info[] = {
/* BCORES_MERGED uses the same register fields as BCORE1 */
DA9063_BUCK_COMMON_FIELDS(BCORE1),
},
+ {
+ DA9063_BUCK(DA9063, BCORES_MERGED_OD, 300, 10, 1570,
+ da9063_bcores_merged_fullcurrent_limits,
+ DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK),
+ /* BCORES_MERGED uses the same register fields as BCORE1 */
+ DA9063_BUCK_COMMON_FIELDS(BCORE1),
+ },
{
DA9063_BUCK(DA9063, BMEM_BIO_MERGED, 800, 20, 3340,
da9063_bmem_bio_merged_limits,
@@ -545,12 +586,12 @@ static const struct da9063_regulator_info da9063_regulator_info[] = {
static struct da9063_dev_model regulators_models[] = {
{
.regulator_info = da9063_regulator_info,
- .n_regulators = ARRAY_SIZE(da9063_regulator_info),
+ .n_regulators = ARRAY_SIZE(da9063_regulator_info) - 4,
.type = PMIC_TYPE_DA9063,
},
{
.regulator_info = da9063_regulator_info,
- .n_regulators = ARRAY_SIZE(da9063_regulator_info) - 6,
+ .n_regulators = ARRAY_SIZE(da9063_regulator_info) - 4 - 6,
.type = PMIC_TYPE_DA9063L,
},
{ }
@@ -600,12 +641,16 @@ static const struct regulator_init_data *da9063_get_regulator_initdata(

static struct of_regulator_match da9063_matches[] = {
[DA9063_ID_BCORE1] = { .name = "bcore1" },
+ [DA9063_ID_BCORE1_OD] = { .name = "bcore1-od" },
[DA9063_ID_BCORE2] = { .name = "bcore2" },
+ [DA9063_ID_BCORE2_OD] = { .name = "bcore2-od" },
[DA9063_ID_BPRO] = { .name = "bpro", },
+ [DA9063_ID_BPRO_OD] = { .name = "bpro-od", },
[DA9063_ID_BMEM] = { .name = "bmem", },
[DA9063_ID_BIO] = { .name = "bio", },
[DA9063_ID_BPERI] = { .name = "bperi", },
[DA9063_ID_BCORES_MERGED] = { .name = "bcores-merged" },
+ [DA9063_ID_BCORES_MERGED_OD] = { .name = "bcores-merged-od" },
[DA9063_ID_BMEM_BIO_MERGED] = { .name = "bmem-bio-merged", },
[DA9063_ID_LDO3] = { .name = "ldo3", },
[DA9063_ID_LDO7] = { .name = "ldo7", },
@@ -685,7 +730,7 @@ static int da9063_regulator_probe(struct platform_device *pdev)
struct da9063_regulators *regulators;
struct da9063_regulator *regl;
struct regulator_config config;
- bool bcores_merged, bmem_bio_merged;
+ bool bcores_merged, bmem_bio_merged, bcore1_od, bcore2_od, bpro_od;
int id, irq, n, n_regulators, ret, val;

regl_pdata = da9063_parse_regulators_dt(pdev, &da9063_reg_matches);
@@ -714,6 +759,9 @@ static int da9063_regulator_probe(struct platform_device *pdev)
return ret;
}
bcores_merged = val & DA9063_BCORE_MERGE;
+ bpro_od = val & DA9063_BPRO_OD;
+ bcore2_od = val & DA9063_BCORE2_OD;
+ bcore1_od = val & DA9063_BCORE1_OD;
bmem_bio_merged = val & DA9063_BUCK_MERGE;

n_regulators = model->n_regulators;
@@ -768,6 +816,20 @@ static int da9063_regulator_probe(struct platform_device *pdev)
}
break;
}
+ if (
+ (id == DA9063_ID_BCORE1 && bcore1_od) ||
+ (id == DA9063_ID_BCORE1_OD && !bcore1_od) ||
+ /* BCORES_MERGED uses the same fullcurrent bit as BCORE1 */
+ (id == DA9063_ID_BCORES_MERGED && bcore1_od) ||
+ (id == DA9063_ID_BCORES_MERGED_OD && !bcore1_od) ||
+ (id == DA9063_ID_BCORE2 && bcore2_od) ||
+ (id == DA9063_ID_BCORE2_OD && !bcore2_od) ||
+ (id == DA9063_ID_BPRO && bpro_od) ||
+ (id == DA9063_ID_BPRO_OD && !bpro_od)
+ ) {
+ id++;
+ continue;
+ }

/* Initialise regulator structure */
regl = &regulators->regulator[n];
--
2.32.0
\
 
 \ /
  Last update: 2021-06-22 13:04    [W:0.034 / U:0.412 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site