From 8e130374fe23a429f20a6dc55b61d9584fc3019a Mon Sep 17 00:00:00 2001 From: David Collins Date: Fri, 22 Nov 2019 16:10:42 -0800 Subject: [PATCH] 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 --- drivers/regulator/Kconfig | 9 +++++++ drivers/regulator/Makefile | 1 + drivers/regulator/fixed.c | 31 +++++++++++++++++++++++++ drivers/regulator/qti-fixed-regulator.c | 5 ++++ 4 files changed, 46 insertions(+) create mode 100644 drivers/regulator/qti-fixed-regulator.c diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index f5b383a9668d..c733985ee79e 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -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 diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 13bd525bf790..e8290e419c58 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -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 diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 599ad201dca7..4b6c5e09c04b 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -27,6 +27,9 @@ #include #include #include +#ifdef QTI_FIXED_REGULATOR +#include +#endif #include #include @@ -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), }, }; diff --git a/drivers/regulator/qti-fixed-regulator.c b/drivers/regulator/qti-fixed-regulator.c new file mode 100644 index 000000000000..7df0625b91ae --- /dev/null +++ b/drivers/regulator/qti-fixed-regulator.c @@ -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"