Skip to contentSkip to conversation

DA9058 REGULATOR driver

PATCH Superseded Anthony Olech 2 participants 10 messages Aug 15, 2012 – Sep 19, 2012

Subsystems (2)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 8/8 DA9058 REGULATOR driver

This is the REGULATOR component driver of the Dialog DA9058 PMIC. This driver is just one component of the whole DA9058 PMIC driver. It depends on the CORE component driver of the DA9058 MFD.

---
 drivers/regulator/Kconfig            |   11 ++
 drivers/regulator/Makefile           |    1 +
 drivers/regulator/da9058-regulator.c |  251 ++++++++++++++++++++++++++++++++++
 3 files changed, 263 insertions(+), 0 deletions(-)
 create mode 100644 drivers/regulator/da9058-regulator.c
drivers/regulator/Kconfig +11 -0
index c86b886..1fc04f9 100644
@@ -64,6 +64,17 @@ config REGULATOR_USERSPACE_CONSUMER
 
           If unsure, say no.
 
+config REGULATOR_DA9058
+	tristate "Support regulators on Dialog Semiconductor DA9058 PMIC"
+	depends on MFD_DA9058
+	help
+	  Say y here to support the BUCKs and LDOs regulators found on
+	  Dialog Semiconductor DA9058 PMIC.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called da9058-regulator.
+
+
 config REGULATOR_GPIO
 	tristate "GPIO regulator support"
 	depends on GENERIC_GPIO
drivers/regulator/Makefile +1 -0
index 977fd46..f4d0bff 100644
@@ -21,6 +21,7 @@ obj-$(CONFIG_REGULATOR_DBX500_PRCMU) += dbx500-prcmu.o
 obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
 obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o
 obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o
+obj-$(CONFIG_REGULATOR_DA9058) += da9058-regulator.o
 obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o
 obj-$(CONFIG_REGULATOR_LP3972) += lp3972.o
 obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o
drivers/regulator/da9058-regulator.c new file +251 -0

251 lines not on this page · raw message

Signature · 1 line
end-of-patch for NEW DRIVER V3
#1 lore raw

drivers/regulator/da9058-regulator.c line 54

Quoted 12 lines · Anthony Olech
drivers/regulator/da9058-regulator.c new file +10 -0
+static int da9058_buck_ramp_voltage(struct regulator_dev *rdev,
+					unsigned int old_selector,
+					unsigned int new_selector)
+{
 
+	ret = da9058_set_bits(da9058, regulator->ramp_register,
+					regulator->ramp_enable_mask);
+
+	if (ret)
+		return ret;
 
+	return 2200; /* micro Seconds needed to ramp to new voltage*/

Why is this function writing to the hardware, especially writing the same value every time?

drivers/regulator/da9058-regulator.c line 65

Quoted 9 lines
drivers/regulator/da9058-regulator.c new file +9 -0
+static int da9058_get_fixed_regulator_voltage(struct regulator_dev *rdev)
+{
+	struct da9058_regulator *regulator = rdev_get_drvdata(rdev);
+
+	if (regulator_is_enabled_regmap(rdev))
+		return regulator->fixed_voltage;
+	else
+		return 0;
+}

list_voltage_linear()

#2 lore raw
Quoted 8 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: 27 August 2012 17:51
To: Opensource [Anthony Olech]
Cc: Liam Girdwood; Guenter Roeck; Jean Delvare; Randy Dunlap; LKML; David Dajun Chen
Subject: Re: [NEW DRIVER V3 8/8] DA9058 REGULATOR driver
On Wed, Aug 15, 2012 at 04:05:25PM +0100, Anthony Olech wrote:

Quoted 11 lines

drivers/regulator/da9058-regulator.c line 54

Quoted 9 lines
drivers/regulator/da9058-regulator.c new file +9 -0
+static int da9058_buck_ramp_voltage(struct regulator_dev *rdev,
+					unsigned int old_selector,
+					unsigned int new_selector)
+{
+	ret = da9058_set_bits(da9058, regulator->ramp_register,
+					regulator->ramp_enable_mask);
+	if (ret)
+		return ret;
+	return 2200; /* micro Seconds needed to ramp to new voltage*/

Why is this function writing to the hardware, especially writing the same value every time?

the ramp_register is DA9058_SUPPLY_REG and it is marked as volitile. Writing to the ramp enable bit starts the voltage change. When the PMIC has finished making the change it resets the bit. Thus to make another voltage change the bit needs to be set again.

Quoted 10 lines

drivers/regulator/da9058-regulator.c line 65

Quoted 9 lines
drivers/regulator/da9058-regulator.c new file +9 -0
+static int da9058_get_fixed_regulator_voltage(struct regulator_dev
+*rdev) {
+	struct da9058_regulator *regulator = rdev_get_drvdata(rdev);
+
+	if (regulator_is_enabled_regmap(rdev))
+		return regulator->fixed_voltage;
+	else
+		return 0;
+}

list_voltage_linear()

#3 lore raw
Quoted 7 lines · Opensource [Anthony Olech]
Quoted 2 lines

Why is this function writing to the hardware, especially writing the same value every time?

the ramp_register is DA9058_SUPPLY_REG and it is marked as volitile. Writing to the ramp enable bit starts the voltage change. When the PMIC has finished making the change it resets the bit. Thus to make another voltage change the bit needs to be set again.

This function is retrieving the amount of time it would take to set the voltage. Why would it be starting a voltage ramp? The fact that it's not setting the new voltage in the hardware ought to be a warning sign here...

#4 lore raw
Quoted 11 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: 17 September 2012 11:40
To: Opensource [Anthony Olech]
Cc: Liam Girdwood; Guenter Roeck; Jean Delvare; Randy Dunlap; LKML; David Dajun Chen
Subject: Re: [NEW DRIVER V3 8/8] DA9058 REGULATOR driver

Quoted 2 lines · Opensource [Anthony Olech]
Quoted 2 lines

Why is this function writing to the hardware, especially writing the same value every time?

Quoted 7 lines
Quoted 4 lines

the ramp_register is DA9058_SUPPLY_REG and it is marked as volitile. Writing to the ramp enable bit starts the voltage change. When the PMIC has finished making the change it resets the bit. Thus to make another voltage change the bit needs to be set again.

This function is retrieving the amount of time it would take to set the voltage. Why would it be starting a voltage ramp? The fact that it's not setting the new voltage in the hardware ought to be a warning sign here...

Thanks for the quick response Mark,

I thought that the set_voltage_sel = regulator_set_voltage_sel_regmap callback first set the target voltage, and that the set_voltage_time_sel = da9058_buck_ramp_voltage callback was called afterwards?

was I wrong?

#5 lore raw
Quoted 5 lines · Opensource [Anthony Olech]

I thought that the set_voltage_sel = regulator_set_voltage_sel_regmap callback first set the target voltage, and that the set_voltage_time_sel = da9058_buck_ramp_voltage callback was called afterwards?

was I wrong?

That will currently happen but we might also decide to query the ramp time first, or we might decide to query the ramp time totally separately to actually changing the voltage (to decide when we will want to change the voltage in DVFS situations for example).

#6 lore raw
Quoted 12 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: 17 September 2012 12:16
To: Opensource [Anthony Olech]
Cc: Liam Girdwood; Guenter Roeck; Jean Delvare; Randy Dunlap; LKML; David Dajun Chen
Subject: Re: [NEW DRIVER V3 8/8] DA9058 REGULATOR driver

Quoted 3 lines · Opensource [Anthony Olech]

I thought that the set_voltage_sel = regulator_set_voltage_sel_regmap callback first set the target voltage, and that the set_voltage_time_sel = da9058_buck_ramp_voltage callback was called

Quoted 6 lines

afterwards?

Quoted 1 line

was I wrong?

That will currently happen but we might also decide to query the ramp time first, or we might decide to query the ramp time totally separately to actually changing the voltage (to decide when we will want to change the voltage in DVFS situations for example).

Can you suggest a future proofed way of using the new regulator API that would solve my problem?

#7 lore raw
Quoted 2 lines · Opensource [Anthony Olech]

Can you suggest a future proofed way of using the new regulator API that would solve my problem?

As I said you should set the voltage as part of the set voltage operation.

#8 lore raw
Quoted 9 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: 17 September 2012 12:33
To: Opensource [Anthony Olech]
Cc: Liam Girdwood; Guenter Roeck; Jean Delvare; Randy Dunlap; LKML; David Dajun Chen
Subject: Re: [NEW DRIVER V3 8/8] DA9058 REGULATOR driver
On Mon, Sep 17, 2012 at 11:23:54AM +0000, Opensource [Anthony Olech] wrote:

Quoted 3 lines
Quoted 2 lines

Can you suggest a future proofed way of using the new regulator API that would solve my problem?

As I said you should set the voltage as part of the set voltage operation.

So I will have to write my own set_voltage_sel() callback instead of using the default regulator_set_voltage_sel_regmap() ??

Well, I did try hard to use your defaults, but I suppose there is nothing to stop me calling regulator_set_voltage_sel_regmap() explicitly as the first part of my set_voltage_sel() callback before setting the ramp_enable bit. Then my implemenation of the set_voltage_time_sel() callback needs to just simply return the ramp time.

#9 lore raw
Quoted 7 lines · Opensource [Anthony Olech]
Quoted 4 lines
Quoted 2 lines

Can you suggest a future proofed way of using the new regulator API that would solve my problem?

As I said you should set the voltage as part of the set voltage operation.

So I will have to write my own set_voltage_sel() callback instead of using the default regulator_set_voltage_sel_regmap() ??

Yes.

Quoted 5 lines

Well, I did try hard to use your defaults, but I suppose there is nothing to stop me calling regulator_set_voltage_sel_regmap() explicitly as the first part of my set_voltage_sel() callback before setting the ramp_enable bit. Then my implemenation of the set_voltage_time_sel() callback needs to just simply return the ramp time.

The point with using the framework stuff is that you should factor out common code, if what you have is not common code then don't do crazy things in other ops to try to paper over that.