diff mbox series

[v3,1/7] regulator: qcom-labibb: Implement voltage selector ops

Message ID 20210117220830.150948-2-angelogioacchino.delregno@somainline.org
State Accepted
Commit dd582369c6c1f39ec475af6191a934f3e57fda35
Headers show
Series Really implement Qualcomm LAB/IBB regulators | expand

Commit Message

AngeloGioacchino Del Regno Jan. 17, 2021, 10:08 p.m. UTC
Implement {get,set}_voltage_sel, list_voltage, map_voltage with
the useful regulator regmap helpers in order to be able to manage
the voltage of LAB (positive) and IBB (negative) regulators.

In particular, the supported ranges are the following:
- LAB (pos):  4600mV to  6100mV with 100mV stepping,
- IBB (neg): -7700mV to -1400mV with 100mV stepping.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/regulator/qcom-labibb-regulator.c | 24 +++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Mark Brown Jan. 18, 2021, 12:04 p.m. UTC | #1
On Sun, Jan 17, 2021 at 11:08:24PM +0100, AngeloGioacchino Del Regno wrote:
> Implement {get,set}_voltage_sel, list_voltage, map_voltage with
> the useful regulator regmap helpers in order to be able to manage
> the voltage of LAB (positive) and IBB (negative) regulators.

Please do not submit new versions of already applied patches, please
submit incremental updates to the existing code.  Modifying existing
commits creates problems for other users building on top of those
commits so it's best practice to only change pubished git commits if
absolutely essential.
AngeloGioacchino Del Regno Jan. 18, 2021, 5:54 p.m. UTC | #2
Il 18/01/21 13:04, Mark Brown ha scritto:
> On Sun, Jan 17, 2021 at 11:08:24PM +0100, AngeloGioacchino Del Regno wrote:

>> Implement {get,set}_voltage_sel, list_voltage, map_voltage with

>> the useful regulator regmap helpers in order to be able to manage

>> the voltage of LAB (positive) and IBB (negative) regulators.

> 

> Please do not submit new versions of already applied patches, please

> submit incremental updates to the existing code.  Modifying existing

> commits creates problems for other users building on top of those

> commits so it's best practice to only change pubished git commits if

> absolutely essential.

> 


Sorry for that. Should I send a v4 to fix that?

- Angelo
Mark Brown Jan. 18, 2021, 5:57 p.m. UTC | #3
On Mon, Jan 18, 2021 at 06:54:26PM +0100, AngeloGioacchino Del Regno wrote:
> Il 18/01/21 13:04, Mark Brown ha scritto:


> > Please do not submit new versions of already applied patches, please

> > submit incremental updates to the existing code.  Modifying existing

> > commits creates problems for other users building on top of those

> > commits so it's best practice to only change pubished git commits if

> > absolutely essential.


> Sorry for that. Should I send a v4 to fix that?


If there are any changes in this version then yes, if it's identical no.
AngeloGioacchino Del Regno Jan. 18, 2021, 6 p.m. UTC | #4
Il 18/01/21 18:57, Mark Brown ha scritto:
> On Mon, Jan 18, 2021 at 06:54:26PM +0100, AngeloGioacchino Del Regno wrote:
>> Il 18/01/21 13:04, Mark Brown ha scritto:
> 
>>> Please do not submit new versions of already applied patches, please
>>> submit incremental updates to the existing code.  Modifying existing
>>> commits creates problems for other users building on top of those
>>> commits so it's best practice to only change pubished git commits if
>>> absolutely essential.
> 
>> Sorry for that. Should I send a v4 to fix that?
> 
> If there are any changes in this version then yes, if it's identical no.
> 

Yes as I wrote in the cover letter, I have changed it to use
regulator_{list,map}_voltage_linear instead of linear_range, as you
asked in v1.

I will send a v4 with the aforemenetioned fix as a separated commit!

- Angelo
diff mbox series

Patch

diff --git a/drivers/regulator/qcom-labibb-regulator.c b/drivers/regulator/qcom-labibb-regulator.c
index 8ccf572394a2..0fe0f6bce4cf 100644
--- a/drivers/regulator/qcom-labibb-regulator.c
+++ b/drivers/regulator/qcom-labibb-regulator.c
@@ -19,6 +19,12 @@ 
 #define PMI8998_IBB_REG_BASE		0xdc00
 
 #define REG_LABIBB_STATUS1		0x08
+
+#define REG_LABIBB_VOLTAGE		0x41
+ #define LABIBB_VOLTAGE_OVERRIDE_EN	BIT(7)
+ #define LAB_VOLTAGE_SET_MASK		GENMASK(3, 0)
+ #define IBB_VOLTAGE_SET_MASK		GENMASK(5, 0)
+
 #define REG_LABIBB_ENABLE_CTL		0x46
 #define LABIBB_STATUS1_VREG_OK_BIT	BIT(7)
 #define LABIBB_CONTROL_ENABLE		BIT(7)
@@ -51,6 +57,10 @@  static const struct regulator_ops qcom_labibb_ops = {
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
 	.is_enabled		= regulator_is_enabled_regmap,
+	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
+	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
+	.list_voltage		= regulator_list_voltage_linear,
+	.map_voltage		= regulator_map_voltage_linear,
 };
 
 static const struct regulator_desc pmi8998_lab_desc = {
@@ -59,9 +69,16 @@  static const struct regulator_desc pmi8998_lab_desc = {
 	.enable_val		= LABIBB_CONTROL_ENABLE,
 	.enable_time		= LAB_ENABLE_TIME,
 	.poll_enabled_time	= LABIBB_POLL_ENABLED_TIME,
+	.vsel_reg		= (PMI8998_LAB_REG_BASE + REG_LABIBB_VOLTAGE),
+	.vsel_mask		= LAB_VOLTAGE_SET_MASK,
+	.apply_reg		= (PMI8998_LAB_REG_BASE + REG_LABIBB_VOLTAGE),
+	.apply_bit		= LABIBB_VOLTAGE_OVERRIDE_EN,
 	.off_on_delay		= LABIBB_OFF_ON_DELAY,
 	.owner			= THIS_MODULE,
 	.type			= REGULATOR_VOLTAGE,
+	.min_uV			= 4600000,
+	.uV_step		= 100000,
+	.n_voltages		= 16,
 	.ops			= &qcom_labibb_ops,
 };
 
@@ -71,9 +88,16 @@  static const struct regulator_desc pmi8998_ibb_desc = {
 	.enable_val		= LABIBB_CONTROL_ENABLE,
 	.enable_time		= IBB_ENABLE_TIME,
 	.poll_enabled_time	= LABIBB_POLL_ENABLED_TIME,
+	.vsel_reg		= (PMI8998_IBB_REG_BASE + REG_LABIBB_VOLTAGE),
+	.vsel_mask		= IBB_VOLTAGE_SET_MASK,
+	.apply_reg		= (PMI8998_IBB_REG_BASE + REG_LABIBB_VOLTAGE),
+	.apply_bit		= LABIBB_VOLTAGE_OVERRIDE_EN,
 	.off_on_delay		= LABIBB_OFF_ON_DELAY,
 	.owner			= THIS_MODULE,
 	.type			= REGULATOR_VOLTAGE,
+	.min_uV			= 1400000,
+	.uV_step		= 100000,
+	.n_voltages		= 64,
 	.ops			= &qcom_labibb_ops,
 };