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.

Add support to enforce proxy consumer requests defined in device
tree for qti-fixed-regulator devices.  These can be used to ensure
that regulators are not accidentally disabled before all consumers
have had a chance to make their own requests.

Change-Id: If4cf664b3f6a8214256a4b2de753f7ff27aa864e
Signed-off-by: David Collins <collinsd@codeaurora.org>
This commit is contained in:
David Collins 2019-11-22 16:10:42 -08:00 committed by David Collins
parent 507aaefcf7
commit 8e130374fe
4 changed files with 46 additions and 0 deletions

View File

@ -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

View File

@ -7,6 +7,7 @@
obj-$(CONFIG_REGULATOR) += core.o dummy.o fixed-helper.o helpers.o devres.o irq_helpers.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

View File

@ -27,6 +27,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>
@ -172,6 +175,19 @@ static const struct regulator_ops fixed_voltage_domain_ops = {
.is_enabled = reg_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);
}
#endif
static int reg_fixed_voltage_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@ -295,6 +311,10 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, drvdata);
#ifdef QTI_FIXED_REGULATOR
qti_reg_fixed_voltage_init(dev, drvdata->dev);
#endif
dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name,
drvdata->desc.fixed_uV);
@ -315,6 +335,12 @@ static const struct fixed_dev_type fixed_domain_data = {
};
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,
@ -336,7 +362,12 @@ 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),
},
};

View File

@ -0,0 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2020, The Linux Foundation. All rights reserved. */
#define QTI_FIXED_REGULATOR
#include "fixed.c"