mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vincent Pelletier <plr.vincent@gmail.com>
To: Support Opensource <support.opensource@diasemi.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	linux-kernel@vger.kernel.org,
	David Abdurachmanov <david.abdurachmanov@sifive.com>
Subject: [PATCH v2 2/2] regulator: da9063: Add support for full-current mode.
Date: Tue, 22 Jun 2021 11:03:56 +0000	[thread overview]
Message-ID: <43ed1ed9032d15077928bd04bec69d7b8ab46cb0.1624359253.git.plr.vincent@gmail.com> (raw)
In-Reply-To: <b04c90a1a1a489d980bf8c524288f71b8f0a6982.1624359253.git.plr.vincent@gmail.com>

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


  reply	other threads:[~2021-06-22 11:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <ad5355c28c25fc273a450a11bc82f201fffad8cf.1624147922.git.plr.vincent@gmail.com>
2021-06-22 11:03 ` [PATCH v2 1/2] regulator: da9063: Use __stringify_1 Vincent Pelletier
2021-06-22 11:03   ` Vincent Pelletier [this message]
2021-06-22 12:45 ` [PATCH v3 " Vincent Pelletier
2021-06-22 12:45   ` [PATCH v3 2/2] regulator: da9063: Add support for full-current mode Vincent Pelletier
2021-06-22 13:09   ` [PATCH v3 1/2] regulator: da9063: Use __stringify_1 Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43ed1ed9032d15077928bd04bec69d7b8ab46cb0.1624359253.git.plr.vincent@gmail.com \
    --to=plr.vincent@gmail.com \
    --cc=broonie@kernel.org \
    --cc=david.abdurachmanov@sifive.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=support.opensource@diasemi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®