Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1213097/?format=api
{ "id": 1213097, "url": "http://patchwork.ozlabs.org/api/patches/1213097/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-gpio/patch/151b68f40a85ba8418efdba136c5925ffa7ee3e8.1576745635.git.matti.vaittinen@fi.rohmeurope.com/", "project": { "id": 42, "url": "http://patchwork.ozlabs.org/api/projects/42/?format=api", "name": "Linux GPIO development", "link_name": "linux-gpio", "list_id": "linux-gpio.vger.kernel.org", "list_email": "linux-gpio@vger.kernel.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<151b68f40a85ba8418efdba136c5925ffa7ee3e8.1576745635.git.matti.vaittinen@fi.rohmeurope.com>", "list_archive_url": null, "date": "2019-12-19T09:52:39", "name": "[v7,08/12] regulator: bd718x7: Split driver to common and bd718x7 specific parts", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "ed352385a739e85cd6e2e6f7c7538a1c47b98ce4", "submitter": { "id": 74146, "url": "http://patchwork.ozlabs.org/api/people/74146/?format=api", "name": "Matti Vaittinen", "email": "matti.vaittinen@fi.rohmeurope.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-gpio/patch/151b68f40a85ba8418efdba136c5925ffa7ee3e8.1576745635.git.matti.vaittinen@fi.rohmeurope.com/mbox/", "series": [ { "id": 149534, "url": "http://patchwork.ozlabs.org/api/series/149534/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-gpio/list/?series=149534", "date": "2019-12-19T09:44:08", "name": "Support ROHM BD71828 PMIC", "version": 7, "mbox": "http://patchwork.ozlabs.org/series/149534/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1213097/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1213097/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linux-gpio-owner@vger.kernel.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org; spf=none (no SPF record)\n\tsmtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67;\n\thelo=vger.kernel.org;\n\tenvelope-from=linux-gpio-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org; dmarc=none (p=none dis=none)\n\theader.from=fi.rohmeurope.com" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 47dnHW2nFwz9sQp\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 19 Dec 2019 20:52:55 +1100 (AEDT)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1726759AbfLSJwu (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tThu, 19 Dec 2019 04:52:50 -0500", "from mail-lj1-f195.google.com ([209.85.208.195]:43616 \"EHLO\n\tmail-lj1-f195.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1726599AbfLSJwu (ORCPT\n\t<rfc822; linux-gpio@vger.kernel.org>); Thu, 19 Dec 2019 04:52:50 -0500", "by mail-lj1-f195.google.com with SMTP id a13so5501406ljm.10;\n\tThu, 19 Dec 2019 01:52:47 -0800 (PST)", "from localhost.localdomain\n\t(dyt4gctb359myxd0pkwmt-4.rev.dnainternet.fi.\n\t[2001:14bb:430:5140:37cf:5409:8fcc:4495])\n\tby smtp.gmail.com with ESMTPSA id\n\tn11sm2595981ljg.15.2019.12.19.01.52.45\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 19 Dec 2019 01:52:46 -0800 (PST)" ], "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:in-reply-to:user-agent;\n\tbh=djMRt0CEVSZEysZxbEXpXkJ/id1+axKQ146EGBhy4Yo=;\n\tb=JcGngKbiNsilA/5yTKqcI1Z3Fwo5G+hjzIvyZTEeeMm3UiTX/+t5rjAiVK++mVWVWf\n\t0ONsKGkBztyLy4Tr2G509asLTyJH0YPbuIP2IaeFymE1WjJh6xPk2PML6I/7hEXZuiIS\n\ty8avyYOZK4kwjttHI0xO7XU67Xg1+XvpmqDDadGJjTR0zzz0ppapuTUphGiR/pWN/vn0\n\tmjFhi0SyTD0dqPmFhUP9InLWd9haoCzdm+WMUM2n31q5uQvLm99YnJtWFsdlPlLkD7K9\n\tf6zJpljsGAMlXlHse4XX86dIBZ68Z2wGktIuxNJF/Kf+TlNHUeSYrbwOUs3SR14kpy03\n\thmxA==", "X-Gm-Message-State": "APjAAAXg+FFAhB82pJZWXNSVMXg6SFTYjWLpQ14H5V7ngw2Bh8xsmf+o\n\tuhShqORb2R6svQIbAOPWaj8=", "X-Google-Smtp-Source": "APXvYqx8SvCYZ2LYDAg1m8EFZxgHpWKZI6o7pxJx0ODYuMGcE3teWIjg6QlA5XdJOlaCxBd8Uf/htQ==", "X-Received": "by 2002:a2e:b0c9:: with SMTP id g9mr5181622ljl.134.1576749166952;\n\tThu, 19 Dec 2019 01:52:46 -0800 (PST)", "Date": "Thu, 19 Dec 2019 11:52:39 +0200", "From": "Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>", "To": "matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com", "Cc": "Jacek Anaszewski <jacek.anaszewski@gmail.com>,\n\tPavel Machek <pavel@ucw.cz>, Dan Murphy <dmurphy@ti.com>,\n\tRob Herring <robh+dt@kernel.org>, Mark Rutland <mark.rutland@arm.com>,\n\tLee Jones <lee.jones@linaro.org>,\n\tMichael Turquette <mturquette@baylibre.com>,\n\tStephen Boyd <sboyd@kernel.org>,\n\tLinus Walleij <linus.walleij@linaro.org>,\n\tBartosz Golaszewski <bgolaszewski@baylibre.com>,\n\tLiam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>,\n\tAlessandro Zummo <a.zummo@towertech.it>,\n\tAlexandre Belloni <alexandre.belloni@bootlin.com>,\n\tlinux-leds@vger.kernel.org, devicetree@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,\n\tlinux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org", "Subject": "[PATCH v7 08/12] regulator: bd718x7: Split driver to common and\n\tbd718x7 specific parts", "Message-ID": "<151b68f40a85ba8418efdba136c5925ffa7ee3e8.1576745635.git.matti.vaittinen@fi.rohmeurope.com>", "References": "<cover.1576745635.git.matti.vaittinen@fi.rohmeurope.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=us-ascii", "Content-Disposition": "inline", "In-Reply-To": "<cover.1576745635.git.matti.vaittinen@fi.rohmeurope.com>", "User-Agent": "Mutt/1.12.1 (2019-06-15)", "Sender": "linux-gpio-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<linux-gpio.vger.kernel.org>", "X-Mailing-List": "linux-gpio@vger.kernel.org" }, "content": "Few ROHM PMICs allow setting the voltage states for different system states\nlike RUN, IDLE, SUSPEND and LPSR. States are then changed via SoC specific\nmechanisms. bd718x7 driver implemented device-tree parsing functions for\nthese state specific voltages. The parsing functions can be re-used by\nother ROHM chip drivers like bd71828. Split the generic functions from\nbd718x7-regulator.c to rohm-regulator.c and export them for other modules\nto use.\n\nSigned-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>\nAcked-by: Mark Brown <broonie@kernel.org>\n---\n\nNo changes since v6\n\n drivers/regulator/Kconfig | 4 +\n drivers/regulator/Makefile | 1 +\n drivers/regulator/bd718x7-regulator.c | 183 ++++++++------------------\n drivers/regulator/rohm-regulator.c | 95 +++++++++++++\n include/linux/mfd/rohm-generic.h | 44 +++++++\n 5 files changed, 199 insertions(+), 128 deletions(-)\n create mode 100644 drivers/regulator/rohm-regulator.c", "diff": "diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig\nindex 74eb5af7295f..a4897ae52f14 100644\n--- a/drivers/regulator/Kconfig\n+++ b/drivers/regulator/Kconfig\n@@ -197,6 +197,7 @@ config REGULATOR_BD70528\n config REGULATOR_BD718XX\n \ttristate \"ROHM BD71837 Power Regulator\"\n \tdepends on MFD_ROHM_BD718XX\n+\tselect REGULATOR_ROHM\n \thelp\n \t This driver supports voltage regulators on ROHM BD71837 PMIC.\n \t This will enable support for the software controllable buck\n@@ -790,6 +791,9 @@ config REGULATOR_RN5T618\n \t Say y here to support the regulators found on Ricoh RN5T567,\n \t RN5T618 or RC5T619 PMIC.\n \n+config REGULATOR_ROHM\n+\ttristate\n+\n config REGULATOR_RT5033\n \ttristate \"Richtek RT5033 Regulators\"\n \tdepends on MFD_RT5033\ndiff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile\nindex 2210ba56f9bd..6bcab72c1fc7 100644\n--- a/drivers/regulator/Makefile\n+++ b/drivers/regulator/Makefile\n@@ -99,6 +99,7 @@ obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o\n obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o\n obj-$(CONFIG_REGULATOR_RK808) += rk808-regulator.o\n obj-$(CONFIG_REGULATOR_RN5T618) += rn5t618-regulator.o\n+obj-$(CONFIG_REGULATOR_ROHM)\t+= rohm-regulator.o\n obj-$(CONFIG_REGULATOR_RT5033)\t+= rt5033-regulator.o\n obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o\n obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o\ndiff --git a/drivers/regulator/bd718x7-regulator.c b/drivers/regulator/bd718x7-regulator.c\nindex 6beaf867d9cb..55decb58c777 100644\n--- a/drivers/regulator/bd718x7-regulator.c\n+++ b/drivers/regulator/bd718x7-regulator.c\n@@ -318,6 +318,7 @@ struct reg_init {\n };\n struct bd718xx_regulator_data {\n \tstruct regulator_desc desc;\n+\tconst struct rohm_dvs_config dvs;\n \tconst struct reg_init init;\n \tconst struct reg_init *additional_inits;\n \tint additional_init_amnt;\n@@ -349,133 +350,15 @@ static const struct reg_init bd71837_ldo6_inits[] = {\n \t},\n };\n \n-#define NUM_DVS_BUCKS 4\n-\n-struct of_dvs_setting {\n-\tconst char *prop;\n-\tunsigned int reg;\n-};\n-\n-static int set_dvs_levels(const struct of_dvs_setting *dvs,\n-\t\t\t struct device_node *np,\n-\t\t\t const struct regulator_desc *desc,\n-\t\t\t struct regmap *regmap)\n-{\n-\tint ret, i;\n-\tunsigned int uv;\n-\n-\tret = of_property_read_u32(np, dvs->prop, &uv);\n-\tif (ret) {\n-\t\tif (ret != -EINVAL)\n-\t\t\treturn ret;\n-\t\treturn 0;\n-\t}\n-\n-\tfor (i = 0; i < desc->n_voltages; i++) {\n-\t\tret = regulator_desc_list_voltage_linear_range(desc, i);\n-\t\tif (ret < 0)\n-\t\t\tcontinue;\n-\t\tif (ret == uv) {\n-\t\t\ti <<= ffs(desc->vsel_mask) - 1;\n-\t\t\tret = regmap_update_bits(regmap, dvs->reg,\n-\t\t\t\t\t\t DVS_BUCK_RUN_MASK, i);\n-\t\t\tbreak;\n-\t\t}\n-\t}\n-\treturn ret;\n-}\n-\n-static int buck4_set_hw_dvs_levels(struct device_node *np,\n+static int buck_set_hw_dvs_levels(struct device_node *np,\n \t\t\t const struct regulator_desc *desc,\n \t\t\t struct regulator_config *cfg)\n {\n-\tint ret, i;\n-\tconst struct of_dvs_setting dvs[] = {\n-\t\t{\n-\t\t\t.prop = \"rohm,dvs-run-voltage\",\n-\t\t\t.reg = BD71837_REG_BUCK4_VOLT_RUN,\n-\t\t},\n-\t};\n+\tstruct bd718xx_regulator_data *data;\n \n-\tfor (i = 0; i < ARRAY_SIZE(dvs); i++) {\n-\t\tret = set_dvs_levels(&dvs[i], np, desc, cfg->regmap);\n-\t\tif (ret)\n-\t\t\tbreak;\n-\t}\n-\treturn ret;\n-}\n-static int buck3_set_hw_dvs_levels(struct device_node *np,\n-\t\t\t const struct regulator_desc *desc,\n-\t\t\t struct regulator_config *cfg)\n-{\n-\tint ret, i;\n-\tconst struct of_dvs_setting dvs[] = {\n-\t\t{\n-\t\t\t.prop = \"rohm,dvs-run-voltage\",\n-\t\t\t.reg = BD71837_REG_BUCK3_VOLT_RUN,\n-\t\t},\n-\t};\n+\tdata = container_of(desc, struct bd718xx_regulator_data, desc);\n \n-\tfor (i = 0; i < ARRAY_SIZE(dvs); i++) {\n-\t\tret = set_dvs_levels(&dvs[i], np, desc, cfg->regmap);\n-\t\tif (ret)\n-\t\t\tbreak;\n-\t}\n-\treturn ret;\n-}\n-\n-static int buck2_set_hw_dvs_levels(struct device_node *np,\n-\t\t\t const struct regulator_desc *desc,\n-\t\t\t struct regulator_config *cfg)\n-{\n-\tint ret, i;\n-\tconst struct of_dvs_setting dvs[] = {\n-\t\t{\n-\t\t\t.prop = \"rohm,dvs-run-voltage\",\n-\t\t\t.reg = BD718XX_REG_BUCK2_VOLT_RUN,\n-\t\t},\n-\t\t{\n-\t\t\t.prop = \"rohm,dvs-idle-voltage\",\n-\t\t\t.reg = BD718XX_REG_BUCK2_VOLT_IDLE,\n-\t\t},\n-\t};\n-\n-\n-\n-\tfor (i = 0; i < ARRAY_SIZE(dvs); i++) {\n-\t\tret = set_dvs_levels(&dvs[i], np, desc, cfg->regmap);\n-\t\tif (ret)\n-\t\t\tbreak;\n-\t}\n-\treturn ret;\n-}\n-\n-static int buck1_set_hw_dvs_levels(struct device_node *np,\n-\t\t\t const struct regulator_desc *desc,\n-\t\t\t struct regulator_config *cfg)\n-{\n-\tint ret, i;\n-\tconst struct of_dvs_setting dvs[] = {\n-\t\t{\n-\t\t\t.prop = \"rohm,dvs-run-voltage\",\n-\t\t\t.reg = BD718XX_REG_BUCK1_VOLT_RUN,\n-\t\t},\n-\t\t{\n-\t\t\t.prop = \"rohm,dvs-idle-voltage\",\n-\t\t\t.reg = BD718XX_REG_BUCK1_VOLT_IDLE,\n-\t\t},\n-\t\t{\n-\t\t\t.prop = \"rohm,dvs-suspend-voltage\",\n-\t\t\t.reg = BD718XX_REG_BUCK1_VOLT_SUSP,\n-\t\t},\n-\t};\n-\n-\tfor (i = 0; i < ARRAY_SIZE(dvs); i++) {\n-\t\tret = set_dvs_levels(&dvs[i], np, desc, cfg->regmap);\n-\t\tif (ret)\n-\t\t\tbreak;\n-\t}\n-\treturn ret;\n+\treturn rohm_regulator_set_dvs_levels(&data->dvs, np, desc, cfg->regmap);\n }\n \n static const struct bd718xx_regulator_data bd71847_regulators[] = {\n@@ -496,7 +379,17 @@ static const struct bd718xx_regulator_data bd71847_regulators[] = {\n \t\t\t.enable_reg = BD718XX_REG_BUCK1_CTRL,\n \t\t\t.enable_mask = BD718XX_BUCK_EN,\n \t\t\t.owner = THIS_MODULE,\n-\t\t\t.of_parse_cb = buck1_set_hw_dvs_levels,\n+\t\t\t.of_parse_cb = buck_set_hw_dvs_levels,\n+\t\t},\n+\t\t.dvs = {\n+\t\t\t.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |\n+\t\t\t\t ROHM_DVS_LEVEL_SUSPEND,\n+\t\t\t.run_reg = BD718XX_REG_BUCK1_VOLT_RUN,\n+\t\t\t.run_mask = DVS_BUCK_RUN_MASK,\n+\t\t\t.idle_reg = BD718XX_REG_BUCK1_VOLT_IDLE,\n+\t\t\t.idle_mask = DVS_BUCK_RUN_MASK,\n+\t\t\t.suspend_reg = BD718XX_REG_BUCK1_VOLT_SUSP,\n+\t\t\t.suspend_mask = DVS_BUCK_RUN_MASK,\n \t\t},\n \t\t.init = {\n \t\t\t.reg = BD718XX_REG_BUCK1_CTRL,\n@@ -520,7 +413,14 @@ static const struct bd718xx_regulator_data bd71847_regulators[] = {\n \t\t\t.enable_reg = BD718XX_REG_BUCK2_CTRL,\n \t\t\t.enable_mask = BD718XX_BUCK_EN,\n \t\t\t.owner = THIS_MODULE,\n-\t\t\t.of_parse_cb = buck2_set_hw_dvs_levels,\n+\t\t\t.of_parse_cb = buck_set_hw_dvs_levels,\n+\t\t},\n+\t\t.dvs = {\n+\t\t\t.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE,\n+\t\t\t.run_reg = BD718XX_REG_BUCK2_VOLT_RUN,\n+\t\t\t.run_mask = DVS_BUCK_RUN_MASK,\n+\t\t\t.idle_reg = BD718XX_REG_BUCK2_VOLT_IDLE,\n+\t\t\t.idle_mask = DVS_BUCK_RUN_MASK,\n \t\t},\n \t\t.init = {\n \t\t\t.reg = BD718XX_REG_BUCK2_CTRL,\n@@ -792,7 +692,17 @@ static const struct bd718xx_regulator_data bd71837_regulators[] = {\n \t\t\t.enable_reg = BD718XX_REG_BUCK1_CTRL,\n \t\t\t.enable_mask = BD718XX_BUCK_EN,\n \t\t\t.owner = THIS_MODULE,\n-\t\t\t.of_parse_cb = buck1_set_hw_dvs_levels,\n+\t\t\t.of_parse_cb = buck_set_hw_dvs_levels,\n+\t\t},\n+\t\t.dvs = {\n+\t\t\t.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |\n+\t\t\t\t ROHM_DVS_LEVEL_SUSPEND,\n+\t\t\t.run_reg = BD718XX_REG_BUCK1_VOLT_RUN,\n+\t\t\t.run_mask = DVS_BUCK_RUN_MASK,\n+\t\t\t.idle_reg = BD718XX_REG_BUCK1_VOLT_IDLE,\n+\t\t\t.idle_mask = DVS_BUCK_RUN_MASK,\n+\t\t\t.suspend_reg = BD718XX_REG_BUCK1_VOLT_SUSP,\n+\t\t\t.suspend_mask = DVS_BUCK_RUN_MASK,\n \t\t},\n \t\t.init = {\n \t\t\t.reg = BD718XX_REG_BUCK1_CTRL,\n@@ -816,7 +726,14 @@ static const struct bd718xx_regulator_data bd71837_regulators[] = {\n \t\t\t.enable_reg = BD718XX_REG_BUCK2_CTRL,\n \t\t\t.enable_mask = BD718XX_BUCK_EN,\n \t\t\t.owner = THIS_MODULE,\n-\t\t\t.of_parse_cb = buck2_set_hw_dvs_levels,\n+\t\t\t.of_parse_cb = buck_set_hw_dvs_levels,\n+\t\t},\n+\t\t.dvs = {\n+\t\t\t.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE,\n+\t\t\t.run_reg = BD718XX_REG_BUCK2_VOLT_RUN,\n+\t\t\t.run_mask = DVS_BUCK_RUN_MASK,\n+\t\t\t.idle_reg = BD718XX_REG_BUCK2_VOLT_IDLE,\n+\t\t\t.idle_mask = DVS_BUCK_RUN_MASK,\n \t\t},\n \t\t.init = {\n \t\t\t.reg = BD718XX_REG_BUCK2_CTRL,\n@@ -840,7 +757,12 @@ static const struct bd718xx_regulator_data bd71837_regulators[] = {\n \t\t\t.enable_reg = BD71837_REG_BUCK3_CTRL,\n \t\t\t.enable_mask = BD718XX_BUCK_EN,\n \t\t\t.owner = THIS_MODULE,\n-\t\t\t.of_parse_cb = buck3_set_hw_dvs_levels,\n+\t\t\t.of_parse_cb = buck_set_hw_dvs_levels,\n+\t\t},\n+\t\t.dvs = {\n+\t\t\t.level_map = ROHM_DVS_LEVEL_RUN,\n+\t\t\t.run_reg = BD71837_REG_BUCK3_VOLT_RUN,\n+\t\t\t.run_mask = DVS_BUCK_RUN_MASK,\n \t\t},\n \t\t.init = {\n \t\t\t.reg = BD71837_REG_BUCK3_CTRL,\n@@ -864,7 +786,12 @@ static const struct bd718xx_regulator_data bd71837_regulators[] = {\n \t\t\t.enable_reg = BD71837_REG_BUCK4_CTRL,\n \t\t\t.enable_mask = BD718XX_BUCK_EN,\n \t\t\t.owner = THIS_MODULE,\n-\t\t\t.of_parse_cb = buck4_set_hw_dvs_levels,\n+\t\t\t.of_parse_cb = buck_set_hw_dvs_levels,\n+\t\t},\n+\t\t.dvs = {\n+\t\t\t.level_map = ROHM_DVS_LEVEL_RUN,\n+\t\t\t.run_reg = BD71837_REG_BUCK4_VOLT_RUN,\n+\t\t\t.run_mask = DVS_BUCK_RUN_MASK,\n \t\t},\n \t\t.init = {\n \t\t\t.reg = BD71837_REG_BUCK4_CTRL,\ndiff --git a/drivers/regulator/rohm-regulator.c b/drivers/regulator/rohm-regulator.c\nnew file mode 100644\nindex 000000000000..ca368ada53c6\n--- /dev/null\n+++ b/drivers/regulator/rohm-regulator.c\n@@ -0,0 +1,95 @@\n+// SPDX-License-Identifier: GPL-2.0\n+// Copyright (C) 2018 ROHM Semiconductors\n+\n+#include <linux/errno.h>\n+#include <linux/mfd/rohm-generic.h>\n+#include <linux/module.h>\n+#include <linux/of.h>\n+#include <linux/regmap.h>\n+#include <linux/regulator/driver.h>\n+\n+static int set_dvs_level(const struct regulator_desc *desc,\n+\t\t\t struct device_node *np, struct regmap *regmap,\n+\t\t\t char *prop, unsigned int reg, unsigned int mask,\n+\t\t\t unsigned int omask, unsigned int oreg)\n+{\n+\tint ret, i;\n+\tuint32_t uv;\n+\n+\tret = of_property_read_u32(np, prop, &uv);\n+\tif (ret) {\n+\t\tif (ret != -EINVAL)\n+\t\t\treturn ret;\n+\t\treturn 0;\n+\t}\n+\n+\tif (uv == 0) {\n+\t\tif (omask)\n+\t\t\treturn regmap_update_bits(regmap, oreg, omask, 0);\n+\t}\n+\tfor (i = 0; i < desc->n_voltages; i++) {\n+\t\tret = regulator_desc_list_voltage_linear_range(desc, i);\n+\t\tif (ret < 0)\n+\t\t\tcontinue;\n+\t\tif (ret == uv) {\n+\t\t\ti <<= ffs(desc->vsel_mask) - 1;\n+\t\t\tret = regmap_update_bits(regmap, reg, mask, i);\n+\t\t\tif (omask && !ret)\n+\t\t\t\tret = regmap_update_bits(regmap, oreg, omask,\n+\t\t\t\t\t\t\t omask);\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\treturn ret;\n+}\n+\n+int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs,\n+\t\t\t struct device_node *np,\n+\t\t\t const struct regulator_desc *desc,\n+\t\t\t struct regmap *regmap)\n+{\n+\tint i, ret = 0;\n+\tchar *prop;\n+\tunsigned int reg, mask, omask, oreg = desc->enable_reg;\n+\n+\tfor (i = 0; i < ROHM_DVS_LEVEL_MAX && !ret; i++) {\n+\t\tif (dvs->level_map & (1 << i)) {\n+\t\t\tswitch (i + 1) {\n+\t\t\tcase ROHM_DVS_LEVEL_RUN:\n+\t\t\t\tprop = \"rohm,dvs-run-voltage\";\n+\t\t\t\treg = dvs->run_reg;\n+\t\t\t\tmask = dvs->run_mask;\n+\t\t\t\tomask = dvs->run_on_mask;\n+\t\t\t\tbreak;\n+\t\t\tcase ROHM_DVS_LEVEL_IDLE:\n+\t\t\t\tprop = \"rohm,dvs-idle-voltage\";\n+\t\t\t\treg = dvs->idle_reg;\n+\t\t\t\tmask = dvs->idle_mask;\n+\t\t\t\tomask = dvs->idle_on_mask;\n+\t\t\t\tbreak;\n+\t\t\tcase ROHM_DVS_LEVEL_SUSPEND:\n+\t\t\t\tprop = \"rohm,dvs-suspend-voltage\";\n+\t\t\t\treg = dvs->suspend_reg;\n+\t\t\t\tmask = dvs->suspend_mask;\n+\t\t\t\tomask = dvs->suspend_on_mask;\n+\t\t\t\tbreak;\n+\t\t\tcase ROHM_DVS_LEVEL_LPSR:\n+\t\t\t\tprop = \"rohm,dvs-lpsr-voltage\";\n+\t\t\t\treg = dvs->lpsr_reg;\n+\t\t\t\tmask = dvs->lpsr_mask;\n+\t\t\t\tomask = dvs->lpsr_on_mask;\n+\t\t\t\tbreak;\n+\t\t\tdefault:\n+\t\t\t\treturn -EINVAL;\n+\t\t\t}\n+\t\t\tret = set_dvs_level(desc, np, regmap, prop, reg, mask,\n+\t\t\t\t\t omask, oreg);\n+\t\t}\n+\t}\n+\treturn ret;\n+}\n+EXPORT_SYMBOL(rohm_regulator_set_dvs_levels);\n+\n+MODULE_LICENSE(\"GPL v2\");\n+MODULE_AUTHOR(\"Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>\");\n+MODULE_DESCRIPTION(\"Generic helpers for ROHM PMIC regulator drivers\");\ndiff --git a/include/linux/mfd/rohm-generic.h b/include/linux/mfd/rohm-generic.h\nindex ff3dd7578fd3..8037421cc6a1 100644\n--- a/include/linux/mfd/rohm-generic.h\n+++ b/include/linux/mfd/rohm-generic.h\n@@ -4,6 +4,9 @@\n #ifndef __LINUX_MFD_ROHM_H__\n #define __LINUX_MFD_ROHM_H__\n \n+#include <linux/regmap.h>\n+#include <linux/regulator/driver.h>\n+\n enum rohm_chip_type {\n \tROHM_CHIP_TYPE_BD71837 = 0,\n \tROHM_CHIP_TYPE_BD71847,\n@@ -17,4 +20,45 @@ struct rohm_regmap_dev {\n \tstruct regmap *regmap;\n };\n \n+enum {\n+\tROHM_DVS_LEVEL_UNKNOWN,\n+\tROHM_DVS_LEVEL_RUN,\n+\tROHM_DVS_LEVEL_IDLE,\n+\tROHM_DVS_LEVEL_SUSPEND,\n+\tROHM_DVS_LEVEL_LPSR,\n+#define ROHM_DVS_LEVEL_MAX ROHM_DVS_LEVEL_LPSR\n+};\n+\n+struct rohm_dvs_config {\n+\tuint64_t level_map;\n+\tunsigned int run_reg;\n+\tunsigned int run_mask;\n+\tunsigned int run_on_mask;\n+\tunsigned int idle_reg;\n+\tunsigned int idle_mask;\n+\tunsigned int idle_on_mask;\n+\tunsigned int suspend_reg;\n+\tunsigned int suspend_mask;\n+\tunsigned int suspend_on_mask;\n+\tunsigned int lpsr_reg;\n+\tunsigned int lpsr_mask;\n+\tunsigned int lpsr_on_mask;\n+};\n+\n+#if IS_ENABLED(CONFIG_REGULATOR_ROHM)\n+int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs,\n+\t\t\t\t struct device_node *np,\n+\t\t\t\t const struct regulator_desc *desc,\n+\t\t\t\t struct regmap *regmap);\n+\n+#else\n+static inline int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs,\n+\t\t\t\t\t\tstruct device_node *np,\n+\t\t\t\t\t\tconst struct regulator_desc *desc,\n+\t\t\t\t\t\tstruct regmap *regmap)\n+{\n+\treturn 0;\n+}\n+#endif //IS_ENABLED(CONFIG_REGULATOR_ROHM)\n+\n #endif\n", "prefixes": [ "v7", "08/12" ] }