linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] regulator: core: Add regulator_set_voltage_time_sel to calculate ramp delay.
@ 2012-06-08  9:47 Yadwinder Singh Brar
  2012-06-08  9:47 ` [PATCH 2/2] regulator: Parse ramp_delay in while parsing DT for regulators Yadwinder Singh Brar
  2012-06-11  3:37 ` [PATCH 1/2] regulator: core: Add regulator_set_voltage_time_sel to calculate ramp delay Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Yadwinder Singh Brar @ 2012-06-08  9:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mark Brown, Liam Girdwood, Yadwinder Singh Brar

This patch adds regulator_set_voltage_time_sel(), to move the commonly used
code by drivers to provide the .set_voltage_time_sel callback.It will also
allow us to configure different ramp delay for different regulators easily.

Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
---
 drivers/regulator/core.c         |   24 ++++++++++++++++++++++++
 include/linux/regulator/driver.h |    5 +++++
 2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 876f5fc..1c320b1 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2289,6 +2289,30 @@ int regulator_set_voltage_time(struct regulator *regulator,
 EXPORT_SYMBOL_GPL(regulator_set_voltage_time);
 
 /**
+ *regulator_set_voltage_time_sel - get raise/fall time
+ * @regulator: regulator source
+ * @old_selector: selector for starting voltage
+ * @new_selector: selector for target voltage
+ *
+ * Provided with the starting and target voltage selectors, this function
+ * returns time in microseconds required to rise or fall to this new voltage
+ *
+ * Drivers providing uV_step in their regulator_desc and ramp_delay in
+ * regulation_constraints can use this as their set_voltage_time_sel()
+ * operation.
+ */
+int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
+				   unsigned int old_selector,
+				   unsigned int new_selector)
+{
+	if (rdev->desc->ramp_delay && rdev->desc->uV_step)
+		return DIV_ROUND_UP(rdev->desc->uV_step *
+			abs(new_selector - old_selector),
+			rdev->desc->ramp_delay);
+	return 0;
+}
+
+/**
  * regulator_sync_voltage - re-apply last regulator output voltage
  * @regulator: regulator source
  *
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 8022638..ae5c253 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -170,6 +170,7 @@ enum regulator_type {
  *
  * @min_uV: Voltage given by the lowest selector (if linear mapping)
  * @uV_step: Voltage increase with each selector (if linear mapping)
+ * @ramp_delay: Time to settle down after voltage change (unit: mV/us)
  * @volt_table: Voltage mapping table (if table based mapping)
  *
  * @vsel_reg: Register for selector when using regulator_regmap_X_voltage_
@@ -189,6 +190,7 @@ struct regulator_desc {
 
 	unsigned int min_uV;
 	unsigned int uV_step;
+	unsigned int ramp_delay;
 
 	const unsigned int *volt_table;
 
@@ -285,6 +287,9 @@ int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel);
 int regulator_is_enabled_regmap(struct regulator_dev *rdev);
 int regulator_enable_regmap(struct regulator_dev *rdev);
 int regulator_disable_regmap(struct regulator_dev *rdev);
+int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
+				   unsigned int old_selector,
+				   unsigned int new_selector);
 
 void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);
 
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] regulator: Parse ramp_delay in while parsing DT for regulators.
  2012-06-08  9:47 [PATCH 1/2] regulator: core: Add regulator_set_voltage_time_sel to calculate ramp delay Yadwinder Singh Brar
@ 2012-06-08  9:47 ` Yadwinder Singh Brar
  2012-06-11  3:37 ` [PATCH 1/2] regulator: core: Add regulator_set_voltage_time_sel to calculate ramp delay Mark Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Yadwinder Singh Brar @ 2012-06-08  9:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mark Brown, Liam Girdwood, Yadwinder Singh Brar

For some hardwares ramp_delay for BUCKs is a configurable parameter which can
be configured through DT.This patch adds support for parsing ramp_delay also
while parsing DT for regulators.

Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
---
 .../devicetree/bindings/regulator/regulator.txt    |    1 +
 drivers/regulator/of_regulator.c                   |    6 ++++++
 include/linux/regulator/machine.h                  |    2 ++
 3 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt
index 5b7a408..d0a7b12 100644
--- a/Documentation/devicetree/bindings/regulator/regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/regulator.txt
@@ -10,6 +10,7 @@ Optional properties:
 - regulator-always-on: boolean, regulator should never be disabled
 - regulator-boot-on: bootloader/firmware enabled regulator
 - <name>-supply: phandle to the parent supply/regulator node
+- regulator-ramp-delay: ramp delay for regulator(in mV/uS)
 
 Example:
 
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 56593b7..8b9cb53 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -74,6 +74,7 @@ struct regulator_init_data *of_get_regulator_init_data(struct device *dev,
 						struct device_node *node)
 {
 	struct regulator_init_data *init_data;
+	const __be32 *ramp_delay;
 
 	if (!node)
 		return NULL;
@@ -83,6 +84,11 @@ struct regulator_init_data *of_get_regulator_init_data(struct device *dev,
 		return NULL; /* Out of memory? */
 
 	of_get_regulation_constraints(node, &init_data);
+
+	ramp_delay = of_get_property(node, "regulator-ramp_delay", NULL);
+	if (ramp_delay)
+		init_data->ramp_delay = be32_to_cpu(*ramp_delay);
+
 	return init_data;
 }
 EXPORT_SYMBOL_GPL(of_get_regulator_init_data);
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index b021084..bb29a6b 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -177,6 +177,8 @@ struct regulator_init_data {
 	int num_consumer_supplies;
 	struct regulator_consumer_supply *consumer_supplies;
 
+	int ramp_delay;		/* unit:mV/us */
+
 	/* optional regulator machine specific init */
 	int (*regulator_init)(void *driver_data);
 	void *driver_data;	/* core does not touch this */
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] regulator: core: Add regulator_set_voltage_time_sel to calculate ramp delay.
  2012-06-08  9:47 [PATCH 1/2] regulator: core: Add regulator_set_voltage_time_sel to calculate ramp delay Yadwinder Singh Brar
  2012-06-08  9:47 ` [PATCH 2/2] regulator: Parse ramp_delay in while parsing DT for regulators Yadwinder Singh Brar
@ 2012-06-11  3:37 ` Mark Brown
  2012-06-11  4:19   ` Yadwinder Singh Brar
  1 sibling, 1 reply; 5+ messages in thread
From: Mark Brown @ 2012-06-11  3:37 UTC (permalink / raw)
  To: Yadwinder Singh Brar; +Cc: linux-kernel, Liam Girdwood, Yadwinder Singh Brar

[-- Attachment #1: Type: text/plain, Size: 321 bytes --]

On Fri, Jun 08, 2012 at 03:17:30PM +0530, Yadwinder Singh Brar wrote:
> This patch adds regulator_set_voltage_time_sel(), to move the commonly used
> code by drivers to provide the .set_voltage_time_sel callback.It will also
> allow us to configure different ramp delay for different regulators easily.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] regulator: core: Add regulator_set_voltage_time_sel to calculate ramp delay.
  2012-06-11  3:37 ` [PATCH 1/2] regulator: core: Add regulator_set_voltage_time_sel to calculate ramp delay Mark Brown
@ 2012-06-11  4:19   ` Yadwinder Singh Brar
  2012-06-11  4:21     ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Yadwinder Singh Brar @ 2012-06-11  4:19 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, Liam Girdwood, Yadwinder Singh Brar

On Mon, Jun 11, 2012 at 9:07 AM, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Fri, Jun 08, 2012 at 03:17:30PM +0530, Yadwinder Singh Brar wrote:
>> This patch adds regulator_set_voltage_time_sel(), to move the commonly used
>> code by drivers to provide the .set_voltage_time_sel callback.It will also
>> allow us to configure different ramp delay for different regulators easily.
>
> Applied, thanks.

Actaully I had posted V2 for this patch with a little correction
(i.e. converting ramp_delay to uV/us before using for
DIV_ROUND_UP)
+                       rdev->desc->ramp_delay * 1000);

I missed to write it in patch summary.

Thanks,
Yadwinder.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] regulator: core: Add regulator_set_voltage_time_sel to calculate ramp delay.
  2012-06-11  4:19   ` Yadwinder Singh Brar
@ 2012-06-11  4:21     ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2012-06-11  4:21 UTC (permalink / raw)
  To: Yadwinder Singh Brar; +Cc: linux-kernel, Liam Girdwood, Yadwinder Singh Brar

[-- Attachment #1: Type: text/plain, Size: 434 bytes --]

On Mon, Jun 11, 2012 at 09:49:39AM +0530, Yadwinder Singh Brar wrote:

> 
> Actaully I had posted V2 for this patch with a little correction
> (i.e. converting ramp_delay to uV/us before using for
> DIV_ROUND_UP)
> +                       rdev->desc->ramp_delay * 1000);

> I missed to write it in patch summary.

Yeah, I did actually apply that version but picked the wrong one to
reply to when clearing out of my inbox.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-06-11  4:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-08  9:47 [PATCH 1/2] regulator: core: Add regulator_set_voltage_time_sel to calculate ramp delay Yadwinder Singh Brar
2012-06-08  9:47 ` [PATCH 2/2] regulator: Parse ramp_delay in while parsing DT for regulators Yadwinder Singh Brar
2012-06-11  3:37 ` [PATCH 1/2] regulator: core: Add regulator_set_voltage_time_sel to calculate ramp delay Mark Brown
2012-06-11  4:19   ` Yadwinder Singh Brar
2012-06-11  4:21     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).