mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zev Weiss <zev@bewilderbeest.net>
To: Mark Brown <broonie@kernel.org>, Liam Girdwood <lgirdwood@gmail.com>
Cc: Zev Weiss <zev@bewilderbeest.net>,
	linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	openbmc@lists.ozlabs.org
Subject: [PATCH 6/6] regulator: core: Add external-consumer driver
Date: Tue,  3 May 2022 23:52:52 -0700	[thread overview]
Message-ID: <20220504065252.6955-6-zev@bewilderbeest.net> (raw)
In-Reply-To: <20220504065252.6955-1-zev@bewilderbeest.net>

An external consumer is a dummy device representing a device external
to the system that is supplied by a regulator designated for external
output.  It is purely a virtual placeholder to instantiate a regulator
by calling regulator_get() on it from its probe function.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
---
 drivers/regulator/Kconfig |  9 +++++++++
 drivers/regulator/core.c  | 28 ++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 5ef2306fce04..5ec390687a81 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -56,6 +56,15 @@ config REGULATOR_USERSPACE_CONSUMER
 
 	  If unsure, say no.
 
+config REGULATOR_EXTERNAL_CONSUMER
+	bool "External regulator consumer support"
+	help
+	  Some regulators supply devices that are entirely external to
+	  the system.  This driver provides a placeholder consumer
+	  representing such devices.
+
+	  If unsure, say no.
+
 config REGULATOR_88PG86X
 	tristate "Marvell 88PG86X voltage regulators"
 	depends on I2C
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index d873606eb41f..4f348b3d5290 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -19,6 +19,7 @@
 #include <linux/delay.h>
 #include <linux/gpio/consumer.h>
 #include <linux/of.h>
+#include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/regulator/of_regulator.h>
 #include <linux/regulator/consumer.h>
@@ -6070,6 +6071,33 @@ static int regulator_summary_show(struct seq_file *s, void *data)
 DEFINE_SHOW_ATTRIBUTE(regulator_summary);
 #endif /* CONFIG_DEBUG_FS */
 
+#ifdef CONFIG_REGULATOR_EXTERNAL_CONSUMER
+static int regulator_external_output_probe(struct platform_device *pdev)
+{
+	struct regulator *reg;
+
+	reg = devm_regulator_get_external(&pdev->dev, "vout");
+	if (IS_ERR(reg))
+		return PTR_ERR(reg);
+
+	return 0;
+}
+
+static const struct of_device_id reg_external_consumer_of_match_table[] = {
+	{ .compatible = "regulator-external-output" },
+	{ },
+};
+
+static struct platform_driver reg_external_consumer_driver = {
+	.driver = {
+		.name = "reg-external-consumer",
+		.of_match_table = reg_external_consumer_of_match_table,
+	},
+	.probe = regulator_external_output_probe,
+};
+builtin_platform_driver(reg_external_consumer_driver);
+#endif /* CONFIG_REGULATOR_EXTERNAL_CONSUMER */
+
 static int __init regulator_init(void)
 {
 	int ret;
-- 
2.36.0


  parent reply	other threads:[~2022-05-04  6:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04  6:52 [PATCH 1/6] dt-bindings: regulator: Add regulator-external-output property Zev Weiss
2022-05-04  6:52 ` [PATCH 2/6] dt-bindings: regulator: Add reg-external-output binding Zev Weiss
2022-05-04 12:55   ` Mark Brown
2022-05-04 20:33     ` Zev Weiss
2022-05-04 20:49       ` Mark Brown
2022-05-04 21:35         ` Zev Weiss
2022-05-05 12:05           ` Mark Brown
2022-05-05  8:33       ` Krzysztof Kozlowski
2022-05-04  6:52 ` [PATCH 3/6] regulator: core: Add error flags to sysfs attributes Zev Weiss
2022-05-04  6:52 ` [PATCH 4/6] regulator: core: Add external-output support Zev Weiss
2022-05-04 13:06   ` Mark Brown
2022-05-04  6:52 ` [PATCH 5/6] regulator: core: Add external get type Zev Weiss
2022-05-04  6:52 ` Zev Weiss [this message]
2022-05-04 12:36 ` [PATCH 1/6] dt-bindings: regulator: Add regulator-external-output property Mark Brown
2022-05-04 20:54 ` (subset) " 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=20220504065252.6955-6-zev@bewilderbeest.net \
    --to=zev@bewilderbeest.net \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=openbmc@lists.ozlabs.org \
    /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®