RE: [PATCH] twl6030: regulator: Remove vsel tables and use formula for calculation

2010-05-14 Thread Nayak, Rajendra

 -Original Message-
 From: Mark Brown [mailto:broo...@opensource.wolfsonmicro.com] 
 Sent: Friday, April 23, 2010 4:49 PM
 To: Nayak, Rajendra
 Cc: linux-omap@vger.kernel.org; Liam Girdwood; Samuel Ortiz
 Subject: Re: [PATCH] twl6030: regulator: Remove vsel tables 
 and use formula for calculation
 
 On Thu, Apr 22, 2010 at 02:18:32PM +0530, Rajendra Nayak wrote:
  All twl6030 regulators can be programmed from 1.0v to 3.3v
  with 100mV steps.
  The below formula can be used to calculate the vsel values
  to be programmed in the VREG_VOLTAGE registers.
 
 Acked-by: Mark Brown broo...@opensource.wolfsonmicro.com

Liam,

Would you be queuing this up for the next merge window?

regards,
Rajendra
 --
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] twl6030: regulator: Remove vsel tables and use formula for calculation

2010-05-14 Thread Liam Girdwood
On Fri, 2010-05-14 at 11:57 +0530, Nayak, Rajendra wrote:
  -Original Message-
  From: Mark Brown [mailto:broo...@opensource.wolfsonmicro.com] 
  Sent: Friday, April 23, 2010 4:49 PM
  To: Nayak, Rajendra
  Cc: linux-omap@vger.kernel.org; Liam Girdwood; Samuel Ortiz
  Subject: Re: [PATCH] twl6030: regulator: Remove vsel tables 
  and use formula for calculation
  
  On Thu, Apr 22, 2010 at 02:18:32PM +0530, Rajendra Nayak wrote:
   All twl6030 regulators can be programmed from 1.0v to 3.3v
   with 100mV steps.
   The below formula can be used to calculate the vsel values
   to be programmed in the VREG_VOLTAGE registers.
  
  Acked-by: Mark Brown broo...@opensource.wolfsonmicro.com
 
 Liam,
 
 Would you be queuing this up for the next merge window?
 

Sorry, looks like I missed this one.

Now applied.

Thanks

Liam
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] twl6030: regulator: Remove vsel tables and use formula for calculation

2010-04-23 Thread Mark Brown
On Thu, Apr 22, 2010 at 02:18:32PM +0530, Rajendra Nayak wrote:
 All twl6030 regulators can be programmed from 1.0v to 3.3v
 with 100mV steps.
 The below formula can be used to calculate the vsel values
 to be programmed in the VREG_VOLTAGE registers.

Acked-by: Mark Brown broo...@opensource.wolfsonmicro.com
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] twl6030: regulator: Remove vsel tables and use formula for calculation

2010-04-22 Thread Rajendra Nayak
All twl6030 regulators can be programmed from 1.0v to 3.3v
with 100mV steps.
The below formula can be used to calculate the vsel values
to be programmed in the VREG_VOLTAGE registers.

Voltage(in mV) = 1000mv + 100mv * (vsel - 1)

Ex: if vsel = 0x9, mV = 1000 + 100 * (9 -1) = 1800mV.

This patch removes all existing VSEL tables for twl6030 adjustable
regulators and just uses the formula directly for vsel calculations
after verifing they fall in the allowed range.

Signed-off-by: Rajendra Nayak rna...@ti.com
Cc: Liam Girdwood l...@slimlogic.co.uk
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
---
 drivers/regulator/twl-regulator.c |  138 -
 1 files changed, 91 insertions(+), 47 deletions(-)

diff --git a/drivers/regulator/twl-regulator.c 
b/drivers/regulator/twl-regulator.c
index 9729d76..7e5892e 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -49,6 +49,7 @@ struct twlreg_info {
 
/* chip constraints on regulator behavior */
u16 min_mV;
+   u16 max_mV;
 
/* used by regulator core */
struct regulator_desc   desc;
@@ -318,31 +319,8 @@ static const u16 VIO_VSEL_table[] = {
 static const u16 VINTANA2_VSEL_table[] = {
2500, 2750,
 };
-static const u16 VAUX1_6030_VSEL_table[] = {
-   1000, 1300, 1800, 2500,
-   2800, 2900, 3000, 3000,
-};
-static const u16 VAUX2_6030_VSEL_table[] = {
-   1200, 1800, 2500, 2750,
-   2800, 2800, 2800, 2800,
-};
-static const u16 VAUX3_6030_VSEL_table[] = {
-   1000, 1200, 1300, 1800,
-   2500, 2800, 3000, 3000,
-};
-static const u16 VMMC_VSEL_table[] = {
-   1200, 1800, 2800, 2900,
-   3000, 3000, 3000, 3000,
-};
-static const u16 VPP_VSEL_table[] = {
-   1800, 1900, 2000, 2100,
-   2200, 2300, 2400, 2500,
-};
-static const u16 VUSIM_VSEL_table[] = {
-   1200, 1800, 2500, 2900,
-};
 
-static int twlldo_list_voltage(struct regulator_dev *rdev, unsigned index)
+static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
 {
struct twlreg_info  *info = rdev_get_drvdata(rdev);
int mV = info-table[index];
@@ -351,7 +329,7 @@ static int twlldo_list_voltage(struct regulator_dev *rdev, 
unsigned index)
 }
 
 static int
-twlldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
+twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
 {
struct twlreg_info  *info = rdev_get_drvdata(rdev);
int vsel;
@@ -375,7 +353,7 @@ twlldo_set_voltage(struct regulator_dev *rdev, int min_uV, 
int max_uV)
return -EDOM;
 }
 
-static int twlldo_get_voltage(struct regulator_dev *rdev)
+static int twl4030ldo_get_voltage(struct regulator_dev *rdev)
 {
struct twlreg_info  *info = rdev_get_drvdata(rdev);
int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
@@ -388,11 +366,67 @@ static int twlldo_get_voltage(struct regulator_dev *rdev)
return LDO_MV(info-table[vsel]) * 1000;
 }
 
-static struct regulator_ops twlldo_ops = {
-   .list_voltage   = twlldo_list_voltage,
+static struct regulator_ops twl4030ldo_ops = {
+   .list_voltage   = twl4030ldo_list_voltage,
 
-   .set_voltage= twlldo_set_voltage,
-   .get_voltage= twlldo_get_voltage,
+   .set_voltage= twl4030ldo_set_voltage,
+   .get_voltage= twl4030ldo_get_voltage,
+
+   .enable = twlreg_enable,
+   .disable= twlreg_disable,
+   .is_enabled = twlreg_is_enabled,
+
+   .set_mode   = twlreg_set_mode,
+
+   .get_status = twlreg_get_status,
+};
+
+static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
+{
+   struct twlreg_info  *info = rdev_get_drvdata(rdev);
+
+   return ((info-min_mV + (index * 100)) * 1000);
+}
+
+static int
+twl6030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
+{
+   struct twlreg_info  *info = rdev_get_drvdata(rdev);
+   int vsel;
+
+   if ((min_uV/1000  info-min_mV) || (max_uV/1000  info-max_mV))
+   return -EDOM;
+
+   /*
+* Use the below formula to calculate vsel
+* mV = 1000mv + 100mv * (vsel - 1)
+*/
+   vsel = (min_uV/1000 - 1000)/100 + 1;
+   return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel);
+
+}
+
+static int twl6030ldo_get_voltage(struct regulator_dev *rdev)
+{
+   struct twlreg_info  *info = rdev_get_drvdata(rdev);
+   int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
+   VREG_VOLTAGE);
+
+   if (vsel  0)
+   return vsel;
+
+   /*
+* Use the below formula to calculate vsel
+* mV = 1000mv + 100mv * (vsel - 1)
+*/
+   return (1000 + (100 *