From: Dmitry Osipenko <digetx@gmail.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Thierry Reding <thierry.reding@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
Peter De Schrijver <pdeschrijver@nvidia.com>
Cc: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH v1 1/6] regulator: core: Introduce API for machine-specific regulators coupling
Date: Sun, 14 Apr 2019 20:59:34 +0300 [thread overview]
Message-ID: <20190414175939.12368-2-digetx@gmail.com> (raw)
In-Reply-To: <20190414175939.12368-1-digetx@gmail.com>
Right now regulator core supports only one type of regulators coupling,
the "voltage max-spread" which keeps voltages of coupled regulators in a
given range. A more sophisticated coupling may be required in practice,
one example is the NVIDIA Tegra SoC's which besides the max-spreading
have other restrictions that must be adhered. Introduce API that allow
platforms to provide their own custom coupling algorithms.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/regulator/core.c | 18 ++++++++++++++++++
include/linux/regulator/machine.h | 19 +++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 186a37675b50..a98af47e0feb 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -59,6 +59,8 @@ static bool has_full_constraints;
static struct dentry *debugfs_root;
+static struct regulators_coupler *machine_regulators_coupler;
+
/*
* struct regulator_map
*
@@ -3596,6 +3598,12 @@ static int regulator_balance_voltage(struct regulator_dev *rdev,
return -EPERM;
}
+ if (n_coupled > 1 &&
+ machine_regulators_coupler &&
+ machine_regulators_coupler->balance_voltage)
+ return machine_regulators_coupler->balance_voltage(
+ machine_regulators_coupler, rdev, state);
+
for (i = 0; i < n_coupled; i++)
c_rdev_done[i] = false;
@@ -4706,6 +4714,16 @@ static int regulator_register_resolve_supply(struct device *dev, void *data)
return 0;
}
+int regulators_coupler_register(struct regulators_coupler *coupler)
+{
+ if (WARN_ON(machine_regulators_coupler))
+ return -EBUSY;
+
+ machine_regulators_coupler = coupler;
+
+ return 0;
+}
+
static void regulator_resolve_coupling(struct regulator_dev *rdev)
{
struct coupling_desc *c_desc = &rdev->coupling_desc;
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index 1d34a70ffda2..f15c8c5f7f6c 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -19,6 +19,7 @@
#include <linux/suspend.h>
struct regulator;
+struct regulator_dev;
/*
* Regulator operation constraint flags. These flags are used to enable
@@ -265,4 +266,22 @@ static inline int regulator_suspend_finish(void)
return 0;
}
+/**
+ * struct regulators_coupler - machine-specific regulators coupler
+ *
+ * A custom regulators coupler allows platform to customize coupling
+ * algorithm.
+ *
+ * @balance_voltage: Callback invoked when voltage of a coupled regulator is
+ * changing. The callee should perform voltage balancing
+ * and change voltage of the coupled regulators.
+ */
+struct regulators_coupler {
+ int (*balance_voltage)(struct regulators_coupler *coupler,
+ struct regulator_dev *rdev,
+ suspend_state_t state);
+};
+
+int regulators_coupler_register(struct regulators_coupler *coupler);
+
#endif
--
2.21.0
next prev parent reply other threads:[~2019-04-14 18:06 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-14 17:59 [RFC PATCH v1 0/6] Introduce machine-specific regulators coupling API Dmitry Osipenko
2019-04-14 17:59 ` Dmitry Osipenko [this message]
2019-05-08 7:55 ` [RFC PATCH v1 1/6] regulator: core: Introduce API for machine-specific regulators coupling Mark Brown
2019-05-08 13:05 ` Dmitry Osipenko
2019-04-14 17:59 ` [RFC PATCH v1 2/6] regulator: core: Parse max-spread value per regulator couple Dmitry Osipenko
2019-04-14 17:59 ` [RFC PATCH v1 3/6] regulator: core: Expose some of core functions Dmitry Osipenko
2019-04-14 17:59 ` [RFC PATCH v1 4/6] regulator: core Bump MAX_COUPLED to 3 Dmitry Osipenko
2019-04-14 17:59 ` [RFC PATCH v1 5/6] soc/tegra: regulators: Add regulators coupler for Tegra20 Dmitry Osipenko
2019-05-08 7:57 ` Mark Brown
2019-05-08 13:10 ` Dmitry Osipenko
2019-05-12 9:06 ` Mark Brown
2019-05-12 17:42 ` Dmitry Osipenko
2019-05-13 17:38 ` Mark Brown
2019-05-14 19:12 ` Dmitry Osipenko
2019-04-14 17:59 ` [RFC PATCH v1 6/6] soc/tegra: regulators: Add regulators coupler for Tegra30 Dmitry Osipenko
2019-05-08 7:58 ` Mark Brown
2019-05-08 13:27 ` Dmitry Osipenko
2019-05-12 9:04 ` Mark Brown
2019-05-12 18:29 ` Dmitry Osipenko
2019-05-13 17:40 ` Mark Brown
2019-05-14 18:30 ` Dmitry Osipenko
2019-05-15 9:05 ` Mark Brown
2019-05-15 11:44 ` Dmitry Osipenko
2019-05-15 14:56 ` Mark Brown
2019-05-05 14:57 ` [RFC PATCH v1 0/6] Introduce machine-specific regulators coupling API Dmitry Osipenko
2019-05-08 8:05 ` Mark Brown
2019-05-08 14:03 ` Dmitry Osipenko
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=20190414175939.12368-2-digetx@gmail.com \
--to=digetx@gmail.com \
--cc=broonie@kernel.org \
--cc=jonathanh@nvidia.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=pdeschrijver@nvidia.com \
--cc=thierry.reding@gmail.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;
as well as URLs for NNTP newsgroup(s).