From: Alina Yu <alina_yu@richtek.com>
To: <lgirdwood@gmail.com>, <broonie@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <alina_yu@richtek.com>,
<johnny_lai@richtek.com>, <cy_huang@richtek.com>
Subject: [PATCH v2 2/4] regulator: rtq2208: Fix LDO to be compatible with both fixed and adjustable vout
Date: Tue, 30 Apr 2024 17:58:25 +0800 [thread overview]
Message-ID: <ffeecd61c194df1f7f049bd50cb2bbbad3cf1025.1714467553.git.alina_yu@richtek.com> (raw)
In-Reply-To: <cover.1714467553.git.alina_yu@richtek.com>
In this patch, LDO's adjustable and fixed Vout settings are compatible.
The LDO Vout ability depends on the init_data->constraints.
If adjustable, the Vout can be set to either 1800mV or 3300mV.
Signed-off-by: Alina Yu <alina_yu@richtek.com>
---
drivers/regulator/rtq2208-regulator.c | 41 +++++++++++++++++++++++++++--------
1 file changed, 32 insertions(+), 9 deletions(-)
diff --git a/drivers/regulator/rtq2208-regulator.c b/drivers/regulator/rtq2208-regulator.c
index 63d4037..80a4d2f 100644
--- a/drivers/regulator/rtq2208-regulator.c
+++ b/drivers/regulator/rtq2208-regulator.c
@@ -220,7 +220,7 @@ static const struct regulator_ops rtq2208_regulator_buck_ops = {
.set_suspend_mode = rtq2208_set_suspend_mode,
};
-static const struct regulator_ops rtq2208_regulator_ldo_ops = {
+static const struct regulator_ops rtq2208_regulator_ldo_fix_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
@@ -229,6 +229,23 @@ static const struct regulator_ops rtq2208_regulator_ldo_ops = {
.set_suspend_disable = rtq2208_set_suspend_disable,
};
+static const struct regulator_ops rtq2208_regulator_ldo_adj_ops = {
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
+ .list_voltage = regulator_list_voltage_table,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_active_discharge = regulator_set_active_discharge_regmap,
+ .set_suspend_enable = rtq2208_set_suspend_enable,
+ .set_suspend_disable = rtq2208_set_suspend_disable,
+};
+
+static const unsigned int rtq2208_ldo_volt_table[] = {
+ 1800000,
+ 3300000,
+};
+
static unsigned int rtq2208_of_map_mode(unsigned int mode)
{
switch (mode) {
@@ -323,12 +340,12 @@ static irqreturn_t rtq2208_irq_handler(int irqno, void *devid)
return IRQ_HANDLED;
}
-static int rtq2208_of_get_fixed_voltage(struct device *dev,
+static int rtq2208_of_get_ldo_dvs_ability(struct device *dev,
struct of_regulator_match *rtq2208_ldo_match, int n_fixed)
{
struct device_node *np;
struct of_regulator_match *match;
- struct rtq2208_regulator_desc *rdesc;
+ struct regulator_desc *desc;
struct regulator_init_data *init_data;
int ret, i;
@@ -349,13 +366,20 @@ static int rtq2208_of_get_fixed_voltage(struct device *dev,
for (i = 0; i < n_fixed; i++) {
match = rtq2208_ldo_match + i;
init_data = match->init_data;
- rdesc = (struct rtq2208_regulator_desc *)match->driver_data;
+ desc = (struct regulator_desc *)match->desc;
- if (!init_data || !rdesc)
+ if (!init_data || !desc)
continue;
- if (init_data->constraints.min_uV == init_data->constraints.max_uV)
- rdesc->desc.fixed_uV = init_data->constraints.min_uV;
+ if (init_data->constraints.min_uV == init_data->constraints.max_uV) {
+ desc->n_voltages = 1;
+ desc->fixed_uV = init_data->constraints.min_uV;
+ desc->ops = &rtq2208_regulator_ldo_fix_ops;
+ } else {
+ desc->n_voltages = ARRAY_SIZE(rtq2208_ldo_volt_table);
+ desc->volt_table = rtq2208_ldo_volt_table;
+ desc->ops = &rtq2208_regulator_ldo_adj_ops;
+ }
}
return 0;
@@ -482,8 +506,7 @@ static int rtq2208_parse_regulator_dt_data(int n_regulator, const unsigned int *
rtq2208_ldo_match[idx - RTQ2208_LDO2].desc = &rdesc[i]->desc;
}
- /* init ldo fixed_uV */
- ret = rtq2208_of_get_fixed_voltage(dev, rtq2208_ldo_match, ldo_idx);
+ ret = rtq2208_of_get_ldo_dvs_ability(dev, rtq2208_ldo_match, ldo_idx);
if (ret)
return dev_err_probe(dev, ret, "Failed to get ldo fixed_uV\n");
--
2.7.4
next prev parent reply other threads:[~2024-04-30 9:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-30 9:58 [PATCH v2 0/4] Fix rtq2208 BUCK ramp_delay and LDO dvs setting Alina Yu
2024-04-30 9:58 ` [PATCH v2 1/4] regulator: rtq2208: Fix LDO discharge register and add vsel setting Alina Yu
2024-05-01 14:14 ` Mark Brown
2024-04-30 9:58 ` Alina Yu [this message]
2024-05-01 2:19 ` [PATCH v2 2/4] regulator: rtq2208: Fix LDO to be compatible with both fixed and adjustable vout Mark Brown
2024-05-02 7:30 ` Alina Yu
2024-05-02 9:26 ` Alina Yu
2024-05-03 1:41 ` Mark Brown
2024-05-03 7:35 ` Alina Yu
2024-05-06 14:58 ` Mark Brown
2024-05-08 6:54 ` Alina Yu
2024-05-08 11:53 ` Mark Brown
2024-05-09 9:15 ` Alina Yu
2024-05-09 15:40 ` Mark Brown
2024-05-10 12:12 ` Alina Yu
2024-05-03 1:37 ` Mark Brown
2024-04-30 9:58 ` [PATCH v2 3/4] regulator: rtq2208: Fix invalid memory access when devm_of_regulator_put_matches is called Alina Yu
2024-05-01 2:19 ` Mark Brown
2024-04-30 9:58 ` [PATCH v2 4/4] regulator: rtq2208: Fix the BUCK ramp_delay range to maximum of 16mVstep/us Alina Yu
2024-05-03 1:32 ` (subset) [PATCH v2 0/4] Fix rtq2208 BUCK ramp_delay and LDO dvs setting 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=ffeecd61c194df1f7f049bd50cb2bbbad3cf1025.1714467553.git.alina_yu@richtek.com \
--to=alina_yu@richtek.com \
--cc=broonie@kernel.org \
--cc=cy_huang@richtek.com \
--cc=johnny_lai@richtek.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.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®