Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17977274 authored by David Collins's avatar David Collins
Browse files

regulator: add QTI fixed voltage regulator driver



Add a new QTI fixed voltage regulator driver that is derived from
the fixed voltage regulator driver.  Use this to provide support
for proxy consumer voting and debug features required on Qualcomm
Technologies, Inc. boards.  Implement this driver as a wrapper
around fixed.c with #ifdef directives so that future updates to
fixed.c are applied automatically to qti-fixed-regulator.c.

Change-Id: If4cf664b3f6a8214256a4b2de753f7ff27aa864e
Signed-off-by: default avatarDavid Collins <collinsd@codeaurora.org>
parent 7b54b39b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -46,6 +46,15 @@ config REGULATOR_FIXED_VOLTAGE
	  useful for systems which use a combination of software
	  managed regulators and simple non-configurable regulators.

config REGULATOR_QTI_FIXED_VOLTAGE
	tristate "QTI fixed voltage regulator support"
	help
	  This driver provides support for fixed voltage regulators which are
	  controlled via a GPIO.  It also supports proxy consumer voting and
	  debug features utilized on Qualcomm Technologies, Inc. boards.  Use
	  this driver in place of the fixed voltage regulator driver if these
	  additional features are required.

config REGULATOR_VIRTUAL_CONSUMER
	tristate "Virtual regulator consumer support"
	help
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
obj-$(CONFIG_REGULATOR) += core.o dummy.o fixed-helper.o helpers.o devres.o
obj-$(CONFIG_OF) += of_regulator.o
obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o
obj-$(CONFIG_REGULATOR_QTI_FIXED_VOLTAGE) += qti-fixed-regulator.o
obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o
obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o
obj-$(CONFIG_REGULATOR_PROXY_CONSUMER) += proxy-consumer.o
+39 −6
Original line number Diff line number Diff line
@@ -14,6 +14,13 @@
 * systems with no controllable regulators.
 */

/*
 * Define QTI_FIXED_REGULATOR here to avoid a loss of proxy-consumer voting
 * regression for existing fixed-regulator device tree devices.  Once such
 * devices are switched to qti-fixed-regulator, this line can be removed.
 */
#define QTI_FIXED_REGULATOR

#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/module.h>
@@ -25,7 +32,9 @@
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/regulator/of_regulator.h>
#ifdef QTI_FIXED_REGULATOR
#include <linux/regulator/proxy-consumer.h>
#endif
#include <linux/regulator/machine.h>
#include <linux/clk.h>

@@ -140,6 +149,23 @@ static struct regulator_ops fixed_voltage_clkenabled_ops = {
	.is_enabled = reg_clock_is_enabled,
};

#ifdef QTI_FIXED_REGULATOR
static void qti_reg_fixed_voltage_init(struct device *dev,
				       struct regulator_dev *rdev)
{
	int ret;

	ret = devm_regulator_proxy_consumer_register(dev, dev->of_node);
	if (ret)
		dev_err(dev, "failed to register proxy consumer, ret=%d\n",
			ret);
}
#else
static void qti_reg_fixed_voltage_init(struct device *dev,
				       struct regulator_dev *rdev)
{ }
#endif

static int reg_fixed_voltage_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
@@ -250,13 +276,10 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
		return ret;
	}

	ret = devm_regulator_proxy_consumer_register(dev, dev->of_node);
	if (ret)
		dev_err(dev, "failed to register proxy consumer, ret=%d\n",
			ret);

	platform_set_drvdata(pdev, drvdata);

	qti_reg_fixed_voltage_init(dev, drvdata->dev);

	dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name,
		drvdata->desc.fixed_uV);

@@ -265,6 +288,12 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)

#if defined(CONFIG_OF)
static const struct of_device_id fixed_of_match[] = {
#ifdef QTI_FIXED_REGULATOR
	{
		.compatible = "qti-regulator-fixed",
		.data = &fixed_voltage_data,
	},
#endif
	{
		.compatible = "regulator-fixed",
		.data = &fixed_voltage_data,
@@ -282,9 +311,13 @@ MODULE_DEVICE_TABLE(of, fixed_of_match);
static struct platform_driver regulator_fixed_voltage_driver = {
	.probe		= reg_fixed_voltage_probe,
	.driver		= {
#ifdef QTI_FIXED_REGULATOR
		.name		= "qti-reg-fixed-voltage",
		.sync_state	= regulator_proxy_consumer_sync_state,
#else
		.name		= "reg-fixed-voltage",
#endif
		.of_match_table = of_match_ptr(fixed_of_match),
		.sync_state	= regulator_proxy_consumer_sync_state,
	},
};

+5 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2020, The Linux Foundation. All rights reserved. */

#define QTI_FIXED_REGULATOR
#include "fixed.c"