linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] TWL6040: Regulator support
@ 2012-02-10 10:05 Peter Ujfalusi
  2012-02-10 10:05 ` [PATCH 1/7] OMAP: 4430SDP: Correct fixed regulator device ID Peter Ujfalusi
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Peter Ujfalusi @ 2012-02-10 10:05 UTC (permalink / raw)
  To: Samuel Ortiz, Tony Lindgren, Liam Girdwood, Mark Brown
  Cc: Santosh Shilimkar, Misael Lopez Cruz, linux-kernel, linux-omap,
	linux-arm-kernel

Hello,

This series depends on the V3 of MFD: twl6040: Conversion to i2c driver set.

In order to have proper regulator support for twl6040 on SDP4430, and
PandaBoards I needed to add support for the V1V8, and V2V1 SMPS supplies from
twl6030.
The configuration on both boards (and the TRM recommendations) are the same, so
it make sens to have the V1V8, V2V1 supply configured in the twl-common to avoid
duplicated code in board files.

The last patch in this series was part of the V2 of MFD: twl6040: Conversion to
i2c driver set. I have added Mark's Reviewd-by tag, and also addressed his
comment regarding to the supplies member of the twl6040 struct (no need to
allocate it separately).

Regards,
Peter
---
Peter Ujfalusi (7):
  OMAP: 4430SDP: Correct fixed regulator device ID
  regulator: twl-regulator: Add fixed LDO for V1V8, V2V1 supply
  MFD: twl-core: regulator configuration for twl6030 V1V8, V2V1 SMPS
  OMAP4: twl-common: Add twl6030 V1V8, V2V1 SMPS common configuration
  OMAP: 4430SDP: Use common configuration for V1V8, V2V1 supplies
  OMAP: omap4panda: Use common configuration for V1V8, V2V1 supplies
  MFD: TWL6040: Add regulator support for VIO, V2V1 supplies

 arch/arm/mach-omap2/board-4430sdp.c    |   11 ++++++--
 arch/arm/mach-omap2/board-omap4panda.c |    4 ++-
 arch/arm/mach-omap2/twl-common.c       |   43 ++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/twl-common.h       |    2 +
 drivers/mfd/twl-core.c                 |   10 +++++++
 drivers/mfd/twl6040-core.c             |   33 +++++++++++++++++++++---
 drivers/regulator/twl-regulator.c      |    2 +
 include/linux/i2c/twl.h                |    2 +
 include/linux/mfd/twl6040.h            |    2 +
 9 files changed, 101 insertions(+), 8 deletions(-)

-- 
1.7.8.4


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

* [PATCH 1/7] OMAP: 4430SDP: Correct fixed regulator device ID
  2012-02-10 10:05 [PATCH 0/7] TWL6040: Regulator support Peter Ujfalusi
@ 2012-02-10 10:05 ` Peter Ujfalusi
  2012-02-22 23:01   ` Tony Lindgren
  2012-02-10 10:05 ` [PATCH 2/7] regulator: twl-regulator: Add fixed LDO for V1V8, V2V1 supply Peter Ujfalusi
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Peter Ujfalusi @ 2012-02-10 10:05 UTC (permalink / raw)
  To: Samuel Ortiz, Tony Lindgren, Liam Girdwood, Mark Brown
  Cc: Santosh Shilimkar, Misael Lopez Cruz, linux-kernel, linux-omap,
	linux-arm-kernel

The board has two fixed voltage regulator. Correct the
device ID for the vbat, which used -1.
Create defines for the fixed regulator IDs so when adding new
regulators we know the next available ID to use for them.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 arch/arm/mach-omap2/board-4430sdp.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c
index f4ac553..d02172d 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -62,6 +62,9 @@
 #define GPIO_WIFI_PMENA		54
 #define GPIO_WIFI_IRQ		53
 
+#define FIXED_REG_VBAT_ID	0
+#define FIXED_REG_VWLAN_ID	1
+
 static const int sdp4430_keymap[] = {
 	KEY(0, 0, KEY_E),
 	KEY(0, 1, KEY_R),
@@ -368,7 +371,7 @@ static struct fixed_voltage_config sdp4430_vbat_pdata = {
 
 static struct platform_device sdp4430_vbat = {
 	.name		= "reg-fixed-voltage",
-	.id		= -1,
+	.id		= FIXED_REG_VBAT_ID,
 	.dev = {
 		.platform_data = &sdp4430_vbat_pdata,
 	},
@@ -478,7 +481,7 @@ static struct fixed_voltage_config sdp4430_vwlan = {
 
 static struct platform_device omap_vwlan_device = {
 	.name		= "reg-fixed-voltage",
-	.id		= 1,
+	.id		= FIXED_REG_VWLAN_ID,
 	.dev = {
 		.platform_data = &sdp4430_vwlan,
 	},
-- 
1.7.8.4


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

* [PATCH 2/7] regulator: twl-regulator: Add fixed LDO for V1V8, V2V1 supply
  2012-02-10 10:05 [PATCH 0/7] TWL6040: Regulator support Peter Ujfalusi
  2012-02-10 10:05 ` [PATCH 1/7] OMAP: 4430SDP: Correct fixed regulator device ID Peter Ujfalusi
@ 2012-02-10 10:05 ` Peter Ujfalusi
  2012-02-10 11:24   ` Mark Brown
  2012-02-10 10:05 ` [PATCH 3/7] MFD: twl-core: regulator configuration for twl6030 V1V8, V2V1 SMPS Peter Ujfalusi
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Peter Ujfalusi @ 2012-02-10 10:05 UTC (permalink / raw)
  To: Samuel Ortiz, Tony Lindgren, Liam Girdwood, Mark Brown
  Cc: Santosh Shilimkar, Misael Lopez Cruz, linux-kernel, linux-omap,
	linux-arm-kernel

V1V8 supply most common use is to provide VIO for the system.
V2V1 supply is used on SDP4430/PandaBoards to provide 2.1V to
twl6040, and also as an input to VCXIO_IN, VDAC_IN of twl6030.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/regulator/twl-regulator.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 181a2cf..e4d8d3c 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -1005,6 +1005,8 @@ static struct twlreg_info twl_regs[] = {
 	TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300),
 	TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300),
 	TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300),
+	TWL6030_FIXED_LDO(V1V8, 0x16, 1800, 0),
+	TWL6030_FIXED_LDO(V2V1, 0x1c, 2100, 0),
 	TWL6030_FIXED_LDO(VANA, 0x50, 2100, 0),
 	TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 0),
 	TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 0),
-- 
1.7.8.4


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

* [PATCH 3/7] MFD: twl-core: regulator configuration for twl6030 V1V8, V2V1 SMPS
  2012-02-10 10:05 [PATCH 0/7] TWL6040: Regulator support Peter Ujfalusi
  2012-02-10 10:05 ` [PATCH 1/7] OMAP: 4430SDP: Correct fixed regulator device ID Peter Ujfalusi
  2012-02-10 10:05 ` [PATCH 2/7] regulator: twl-regulator: Add fixed LDO for V1V8, V2V1 supply Peter Ujfalusi
@ 2012-02-10 10:05 ` Peter Ujfalusi
  2012-02-23 15:22   ` Samuel Ortiz
  2012-02-10 10:05 ` [PATCH 4/7] OMAP4: twl-common: Add twl6030 V1V8, V2V1 SMPS common configuration Peter Ujfalusi
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Peter Ujfalusi @ 2012-02-10 10:05 UTC (permalink / raw)
  To: Samuel Ortiz, Tony Lindgren, Liam Girdwood, Mark Brown
  Cc: Santosh Shilimkar, Misael Lopez Cruz, linux-kernel, linux-omap,
	linux-arm-kernel

To be able to attach consumers to these supplies from board
files we need to have regulator_init_data for them.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/mfd/twl-core.c  |   10 ++++++++++
 include/linux/i2c/twl.h |    2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index ac6fdd93..0cb7511 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -937,6 +937,16 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
 	/* twl6030 regulators */
 	if (twl_has_regulator() && twl_class_is_6030() &&
 			!(features & TWL6025_SUBCLASS)) {
+		child = add_regulator(TWL6030_REG_V1V8, pdata->v1v8,
+					features);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
+
+		child = add_regulator(TWL6030_REG_V2V1, pdata->v2v1,
+					features);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
+
 		child = add_regulator(TWL6030_REG_VMMC, pdata->vmmc,
 					features);
 		if (IS_ERR(child))
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 3826a53..35b6d53 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -721,6 +721,8 @@ struct twl4030_platform_data {
 	struct regulator_init_data              *vcxio;
 	struct regulator_init_data              *vusb;
 	struct regulator_init_data		*clk32kg;
+	struct regulator_init_data              *v1v8;
+	struct regulator_init_data              *v2v1;
 	/* TWL6025 LDO regulators */
 	struct regulator_init_data		*ldo1;
 	struct regulator_init_data		*ldo2;
-- 
1.7.8.4


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

* [PATCH 4/7] OMAP4: twl-common: Add twl6030 V1V8, V2V1 SMPS common configuration
  2012-02-10 10:05 [PATCH 0/7] TWL6040: Regulator support Peter Ujfalusi
                   ` (2 preceding siblings ...)
  2012-02-10 10:05 ` [PATCH 3/7] MFD: twl-core: regulator configuration for twl6030 V1V8, V2V1 SMPS Peter Ujfalusi
@ 2012-02-10 10:05 ` Peter Ujfalusi
  2012-02-22 23:02   ` Tony Lindgren
  2012-02-10 10:05 ` [PATCH 5/7] OMAP: 4430SDP: Use common configuration for V1V8, V2V1 supplies Peter Ujfalusi
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Peter Ujfalusi @ 2012-02-10 10:05 UTC (permalink / raw)
  To: Samuel Ortiz, Tony Lindgren, Liam Girdwood, Mark Brown
  Cc: Santosh Shilimkar, Misael Lopez Cruz, linux-kernel, linux-omap,
	linux-arm-kernel

V1V8 supply from twl6030 commonly used as VIO for the machine.
V2V1 is adviced to supply the twl6040, and also to feed the twl6030's
VCXIO_IN, and VDAC_IN inputs.
Create the common regulator configurations for these regulators:
Make the V2V1 as supply_regulator for VCXIO, VDAC.
Add twl6040 (1-004b) as consumer for V1V8, and V2V1.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 arch/arm/mach-omap2/twl-common.c |   43 ++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/twl-common.h |    2 +
 2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c
index bc03154..cc9ede3 100644
--- a/arch/arm/mach-omap2/twl-common.c
+++ b/arch/arm/mach-omap2/twl-common.c
@@ -201,6 +201,7 @@ static struct regulator_init_data omap4_vdac_idata = {
 		.valid_ops_mask		= REGULATOR_CHANGE_MODE
 					| REGULATOR_CHANGE_STATUS,
 	},
+	.supply_regulator	= "V2V1",
 };
 
 static struct regulator_init_data omap4_vaux2_idata = {
@@ -291,6 +292,7 @@ static struct regulator_init_data omap4_vcxio_idata = {
 	},
 	.num_consumer_supplies	= ARRAY_SIZE(omap4_vcxio_supply),
 	.consumer_supplies	= omap4_vcxio_supply,
+	.supply_regulator	= "V2V1",
 };
 
 static struct regulator_init_data omap4_vusb_idata = {
@@ -311,6 +313,41 @@ static struct regulator_init_data omap4_clk32kg_idata = {
 	},
 };
 
+static struct regulator_consumer_supply omap4_v1v8_supply[] = {
+	REGULATOR_SUPPLY("vio", "1-004b"),
+};
+
+static struct regulator_init_data omap4_v1v8_idata = {
+	.constraints = {
+		.min_uV			= 1800000,
+		.max_uV			= 1800000,
+		.valid_modes_mask	= REGULATOR_MODE_NORMAL
+					| REGULATOR_MODE_STANDBY,
+		.valid_ops_mask		= REGULATOR_CHANGE_MODE
+					| REGULATOR_CHANGE_STATUS,
+		.always_on		= true,
+	},
+	.num_consumer_supplies	= ARRAY_SIZE(omap4_v1v8_supply),
+	.consumer_supplies	= omap4_v1v8_supply,
+};
+
+static struct regulator_consumer_supply omap4_v2v1_supply[] = {
+	REGULATOR_SUPPLY("v2v1", "1-004b"),
+};
+
+static struct regulator_init_data omap4_v2v1_idata = {
+	.constraints = {
+		.min_uV			= 2100000,
+		.max_uV			= 2100000,
+		.valid_modes_mask	= REGULATOR_MODE_NORMAL
+					| REGULATOR_MODE_STANDBY,
+		.valid_ops_mask		= REGULATOR_CHANGE_MODE
+					| REGULATOR_CHANGE_STATUS,
+	},
+	.num_consumer_supplies	= ARRAY_SIZE(omap4_v2v1_supply),
+	.consumer_supplies	= omap4_v2v1_supply,
+};
+
 void __init omap4_pmic_get_config(struct twl4030_platform_data *pmic_data,
 				  u32 pdata_flags, u32 regulators_flags)
 {
@@ -351,5 +388,11 @@ void __init omap4_pmic_get_config(struct twl4030_platform_data *pmic_data,
 	if (regulators_flags & TWL_COMMON_REGULATOR_CLK32KG &&
 	    !pmic_data->clk32kg)
 		pmic_data->clk32kg = &omap4_clk32kg_idata;
+
+	if (regulators_flags & TWL_COMMON_REGULATOR_V1V8 && !pmic_data->v1v8)
+		pmic_data->v1v8 = &omap4_v1v8_idata;
+
+	if (regulators_flags & TWL_COMMON_REGULATOR_V2V1 && !pmic_data->v2v1)
+		pmic_data->v2v1 = &omap4_v2v1_idata;
 }
 #endif /* CONFIG_ARCH_OMAP4 */
diff --git a/arch/arm/mach-omap2/twl-common.h b/arch/arm/mach-omap2/twl-common.h
index 0962748..8fe71cf 100644
--- a/arch/arm/mach-omap2/twl-common.h
+++ b/arch/arm/mach-omap2/twl-common.h
@@ -22,6 +22,8 @@
 #define TWL_COMMON_REGULATOR_VCXIO	(1 << 8)
 #define TWL_COMMON_REGULATOR_VUSB	(1 << 9)
 #define TWL_COMMON_REGULATOR_CLK32KG	(1 << 10)
+#define TWL_COMMON_REGULATOR_V1V8	(1 << 11)
+#define TWL_COMMON_REGULATOR_V2V1	(1 << 12)
 
 /* TWL4030 LDO regulators */
 #define TWL_COMMON_REGULATOR_VPLL1	(1 << 4)
-- 
1.7.8.4


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

* [PATCH 5/7] OMAP: 4430SDP: Use common configuration for V1V8, V2V1 supplies
  2012-02-10 10:05 [PATCH 0/7] TWL6040: Regulator support Peter Ujfalusi
                   ` (3 preceding siblings ...)
  2012-02-10 10:05 ` [PATCH 4/7] OMAP4: twl-common: Add twl6030 V1V8, V2V1 SMPS common configuration Peter Ujfalusi
@ 2012-02-10 10:05 ` Peter Ujfalusi
  2012-02-22 23:02   ` Tony Lindgren
  2012-02-10 10:05 ` [PATCH 6/7] OMAP: omap4panda: " Peter Ujfalusi
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Peter Ujfalusi @ 2012-02-10 10:05 UTC (permalink / raw)
  To: Samuel Ortiz, Tony Lindgren, Liam Girdwood, Mark Brown
  Cc: Santosh Shilimkar, Misael Lopez Cruz, linux-kernel, linux-omap,
	linux-arm-kernel

These supplies going to be needed for the twl6040 driver.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 arch/arm/mach-omap2/board-4430sdp.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c
index d02172d..2b3ff4b 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -612,7 +612,9 @@ static int __init omap4_i2c_init(void)
 			TWL_COMMON_REGULATOR_VANA |
 			TWL_COMMON_REGULATOR_VCXIO |
 			TWL_COMMON_REGULATOR_VUSB |
-			TWL_COMMON_REGULATOR_CLK32KG);
+			TWL_COMMON_REGULATOR_CLK32KG |
+			TWL_COMMON_REGULATOR_V1V8 |
+			TWL_COMMON_REGULATOR_V2V1);
 	omap4_pmic_init("twl6030", &sdp4430_twldata,
 			&twl6040_data, OMAP44XX_IRQ_SYS_2N);
 	omap_register_i2c_bus(2, 400, NULL, 0);
-- 
1.7.8.4


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

* [PATCH 6/7] OMAP: omap4panda: Use common configuration for V1V8, V2V1 supplies
  2012-02-10 10:05 [PATCH 0/7] TWL6040: Regulator support Peter Ujfalusi
                   ` (4 preceding siblings ...)
  2012-02-10 10:05 ` [PATCH 5/7] OMAP: 4430SDP: Use common configuration for V1V8, V2V1 supplies Peter Ujfalusi
@ 2012-02-10 10:05 ` Peter Ujfalusi
  2012-02-22 23:02   ` Tony Lindgren
  2012-02-10 10:05 ` [PATCH 7/7] MFD: TWL6040: Add regulator support for VIO, " Peter Ujfalusi
  2012-02-17 11:48 ` [PATCH 0/7] TWL6040: Regulator support Peter Ujfalusi
  7 siblings, 1 reply; 15+ messages in thread
From: Peter Ujfalusi @ 2012-02-10 10:05 UTC (permalink / raw)
  To: Samuel Ortiz, Tony Lindgren, Liam Girdwood, Mark Brown
  Cc: Santosh Shilimkar, Misael Lopez Cruz, linux-kernel, linux-omap,
	linux-arm-kernel

These supplies going to be needed for the twl6040 driver.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 arch/arm/mach-omap2/board-omap4panda.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index da31a72..1e90e71 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -316,7 +316,9 @@ static int __init omap4_panda_i2c_init(void)
 			TWL_COMMON_REGULATOR_VANA |
 			TWL_COMMON_REGULATOR_VCXIO |
 			TWL_COMMON_REGULATOR_VUSB |
-			TWL_COMMON_REGULATOR_CLK32KG);
+			TWL_COMMON_REGULATOR_CLK32KG |
+			TWL_COMMON_REGULATOR_V1V8 |
+			TWL_COMMON_REGULATOR_V2V1);
 	omap4_pmic_init("twl6030", &omap4_panda_twldata,
 			&twl6040_data, OMAP44XX_IRQ_SYS_2N);
 	omap_register_i2c_bus(2, 400, NULL, 0);
-- 
1.7.8.4


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

* [PATCH 7/7] MFD: TWL6040: Add regulator support for VIO, V2V1 supplies
  2012-02-10 10:05 [PATCH 0/7] TWL6040: Regulator support Peter Ujfalusi
                   ` (5 preceding siblings ...)
  2012-02-10 10:05 ` [PATCH 6/7] OMAP: omap4panda: " Peter Ujfalusi
@ 2012-02-10 10:05 ` Peter Ujfalusi
  2012-02-17 11:48 ` [PATCH 0/7] TWL6040: Regulator support Peter Ujfalusi
  7 siblings, 0 replies; 15+ messages in thread
From: Peter Ujfalusi @ 2012-02-10 10:05 UTC (permalink / raw)
  To: Samuel Ortiz, Tony Lindgren, Liam Girdwood, Mark Brown
  Cc: Santosh Shilimkar, Misael Lopez Cruz, linux-kernel, linux-omap,
	linux-arm-kernel

twl6040 has three power supply source:
VBAT needs to be connected to VBAT, VIO, and V2V1.
Add regulator support for the VIO, V2V1 supplies.
Initially handle the two supply together with bulk commands.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/mfd/twl6040-core.c  |   33 +++++++++++++++++++++++++++++----
 include/linux/mfd/twl6040.h |    2 ++
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index ea00c69..566f6e0 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -27,6 +27,7 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/kernel.h>
+#include <linux/err.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
 #include <linux/delay.h>
@@ -35,8 +36,10 @@
 #include <linux/err.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/twl6040.h>
+#include <linux/regulator/consumer.h>
 
 #define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1)
+#define TWL6040_NUM_SUPPLIES	(2)
 
 int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg)
 {
@@ -506,6 +509,21 @@ static int __devinit twl6040_probe(struct i2c_client *client,
 
 	i2c_set_clientdata(client, twl6040);
 
+	twl6040->supplies[0].supply = "vio";
+	twl6040->supplies[1].supply = "v2v1";
+	ret = regulator_bulk_get(&client->dev, TWL6040_NUM_SUPPLIES,
+				 twl6040->supplies);
+	if (ret != 0) {
+		dev_err(&client->dev, "Failed to get supplies: %d\n", ret);
+		goto regulator_get_err;
+	}
+
+	ret = regulator_bulk_enable(TWL6040_NUM_SUPPLIES, twl6040->supplies);
+	if (ret != 0) {
+		dev_err(&client->dev, "Failed to enable supplies: %d\n", ret);
+		goto power_err;
+	}
+
 	twl6040->dev = &client->dev;
 	twl6040->irq = client->irq;
 	twl6040->irq_base = pdata->irq_base;
@@ -526,13 +544,13 @@ static int __devinit twl6040_probe(struct i2c_client *client,
 		ret = gpio_request_one(twl6040->audpwron, GPIOF_OUT_INIT_LOW,
 				       "audpwron");
 		if (ret)
-			goto gpio1_err;
+			goto gpio_err;
 	}
 
 	/* codec interrupt */
 	ret = twl6040_irq_init(twl6040);
 	if (ret)
-		goto gpio2_err;
+		goto irq_init_err;
 
 	ret = request_threaded_irq(twl6040->irq_base + TWL6040_IRQ_READY,
 				   NULL, twl6040_naudint_handler, 0,
@@ -592,10 +610,14 @@ mfd_err:
 	free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040);
 irq_err:
 	twl6040_irq_exit(twl6040);
-gpio2_err:
+irq_init_err:
 	if (gpio_is_valid(twl6040->audpwron))
 		gpio_free(twl6040->audpwron);
-gpio1_err:
+gpio_err:
+	regulator_bulk_disable(TWL6040_NUM_SUPPLIES, twl6040->supplies);
+power_err:
+	regulator_bulk_free(TWL6040_NUM_SUPPLIES, twl6040->supplies);
+regulator_get_err:
 	i2c_set_clientdata(client, NULL);
 	regmap_exit(twl6040->regmap);
 err:
@@ -619,6 +641,9 @@ static int __devexit twl6040_remove(struct i2c_client *client)
 	i2c_set_clientdata(client, NULL);
 	regmap_exit(twl6040->regmap);
 
+	regulator_bulk_disable(TWL6040_NUM_SUPPLIES, twl6040->supplies);
+	regulator_bulk_free(TWL6040_NUM_SUPPLIES, twl6040->supplies);
+
 	return 0;
 }
 
diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h
index e3ff28d..2acdd7d 100644
--- a/include/linux/mfd/twl6040.h
+++ b/include/linux/mfd/twl6040.h
@@ -27,6 +27,7 @@
 
 #include <linux/interrupt.h>
 #include <linux/mfd/core.h>
+#include <linux/regulator/consumer.h>
 
 #define TWL6040_REG_ASICID		0x01
 #define TWL6040_REG_ASICREV		0x02
@@ -203,6 +204,7 @@ struct regmap;
 struct twl6040 {
 	struct device *dev;
 	struct regmap *regmap;
+	struct regulator_bulk_data supplies[2]; /* supplies for vio, v2v1 */
 	struct mutex mutex;
 	struct mutex io_mutex;
 	struct mutex irq_mutex;
-- 
1.7.8.4


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

* Re: [PATCH 2/7] regulator: twl-regulator: Add fixed LDO for V1V8, V2V1 supply
  2012-02-10 10:05 ` [PATCH 2/7] regulator: twl-regulator: Add fixed LDO for V1V8, V2V1 supply Peter Ujfalusi
@ 2012-02-10 11:24   ` Mark Brown
  0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2012-02-10 11:24 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Samuel Ortiz, Tony Lindgren, Liam Girdwood, Santosh Shilimkar,
	Misael Lopez Cruz, linux-kernel, linux-omap, linux-arm-kernel

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

On Fri, Feb 10, 2012 at 12:05:11PM +0200, Peter Ujfalusi wrote:
> V1V8 supply most common use is to provide VIO for the system.
> V2V1 supply is used on SDP4430/PandaBoards to provide 2.1V to
> twl6040, and also as an input to VCXIO_IN, VDAC_IN of twl6030.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

I'll not apply this as it'll cause runtime breakage if it goes via a
different path to the rest of the series.  If it's getting near to the
merge window and nothing is applied please remind me and this can go in
by itself.

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

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

* Re: [PATCH 0/7] TWL6040: Regulator support
  2012-02-10 10:05 [PATCH 0/7] TWL6040: Regulator support Peter Ujfalusi
                   ` (6 preceding siblings ...)
  2012-02-10 10:05 ` [PATCH 7/7] MFD: TWL6040: Add regulator support for VIO, " Peter Ujfalusi
@ 2012-02-17 11:48 ` Peter Ujfalusi
  7 siblings, 0 replies; 15+ messages in thread
From: Peter Ujfalusi @ 2012-02-17 11:48 UTC (permalink / raw)
  To: Samuel Ortiz, Tony Lindgren, Liam Girdwood, Mark Brown
  Cc: Santosh Shilimkar, Misael Lopez Cruz, linux-kernel, linux-omap,
	linux-arm-kernel

Hi,

On 02/10/2012 12:05 PM, Peter Ujfalusi wrote:
> Hello,
> 
> This series depends on the V3 of MFD: twl6040: Conversion to i2c driver set.
> 
> In order to have proper regulator support for twl6040 on SDP4430, and
> PandaBoards I needed to add support for the V1V8, and V2V1 SMPS supplies from
> twl6030.
> The configuration on both boards (and the TRM recommendations) are the same, so
> it make sens to have the V1V8, V2V1 supply configured in the twl-common to avoid
> duplicated code in board files.
> 
> The last patch in this series was part of the V2 of MFD: twl6040: Conversion to
> i2c driver set. I have added Mark's Reviewd-by tag, and also addressed his
> comment regarding to the supplies member of the twl6040 struct (no need to
> allocate it separately).
> 
> Regards,
> Peter
> ---
> Peter Ujfalusi (7):
>   OMAP: 4430SDP: Correct fixed regulator device ID
>   regulator: twl-regulator: Add fixed LDO for V1V8, V2V1 supply
>   MFD: twl-core: regulator configuration for twl6030 V1V8, V2V1 SMPS
>   OMAP4: twl-common: Add twl6030 V1V8, V2V1 SMPS common configuration
>   OMAP: 4430SDP: Use common configuration for V1V8, V2V1 supplies
>   OMAP: omap4panda: Use common configuration for V1V8, V2V1 supplies
>   MFD: TWL6040: Add regulator support for VIO, V2V1 supplies
> 
>  arch/arm/mach-omap2/board-4430sdp.c    |   11 ++++++--
>  arch/arm/mach-omap2/board-omap4panda.c |    4 ++-
>  arch/arm/mach-omap2/twl-common.c       |   43 ++++++++++++++++++++++++++++++++
>  arch/arm/mach-omap2/twl-common.h       |    2 +
>  drivers/mfd/twl-core.c                 |   10 +++++++
>  drivers/mfd/twl6040-core.c             |   33 +++++++++++++++++++++---
>  drivers/regulator/twl-regulator.c      |    2 +
>  include/linux/i2c/twl.h                |    2 +
>  include/linux/mfd/twl6040.h            |    2 +
>  9 files changed, 101 insertions(+), 8 deletions(-)

It has been a week since I have sent this series. It would be great if
this be on time for 3.4 merge window (with the depending series which
converts the twl6040 mfd part into i2c driver).

Thank you,
Péter

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

* Re: [PATCH 1/7] OMAP: 4430SDP: Correct fixed regulator device ID
  2012-02-10 10:05 ` [PATCH 1/7] OMAP: 4430SDP: Correct fixed regulator device ID Peter Ujfalusi
@ 2012-02-22 23:01   ` Tony Lindgren
  0 siblings, 0 replies; 15+ messages in thread
From: Tony Lindgren @ 2012-02-22 23:01 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Samuel Ortiz, Liam Girdwood, Mark Brown, Santosh Shilimkar,
	Misael Lopez Cruz, linux-kernel, linux-omap, linux-arm-kernel

* Peter Ujfalusi <peter.ujfalusi@ti.com> [120210 01:34]:
> The board has two fixed voltage regulator. Correct the
> device ID for the vbat, which used -1.
> Create defines for the fixed regulator IDs so when adding new
> regulators we know the next available ID to use for them.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

Acked-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCH 4/7] OMAP4: twl-common: Add twl6030 V1V8, V2V1 SMPS common configuration
  2012-02-10 10:05 ` [PATCH 4/7] OMAP4: twl-common: Add twl6030 V1V8, V2V1 SMPS common configuration Peter Ujfalusi
@ 2012-02-22 23:02   ` Tony Lindgren
  0 siblings, 0 replies; 15+ messages in thread
From: Tony Lindgren @ 2012-02-22 23:02 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Samuel Ortiz, Liam Girdwood, Mark Brown, Santosh Shilimkar,
	Misael Lopez Cruz, linux-kernel, linux-omap, linux-arm-kernel

* Peter Ujfalusi <peter.ujfalusi@ti.com> [120210 01:34]:
> V1V8 supply from twl6030 commonly used as VIO for the machine.
> V2V1 is adviced to supply the twl6040, and also to feed the twl6030's
> VCXIO_IN, and VDAC_IN inputs.
> Create the common regulator configurations for these regulators:
> Make the V2V1 as supply_regulator for VCXIO, VDAC.
> Add twl6040 (1-004b) as consumer for V1V8, and V2V1.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

Acked-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCH 5/7] OMAP: 4430SDP: Use common configuration for V1V8, V2V1 supplies
  2012-02-10 10:05 ` [PATCH 5/7] OMAP: 4430SDP: Use common configuration for V1V8, V2V1 supplies Peter Ujfalusi
@ 2012-02-22 23:02   ` Tony Lindgren
  0 siblings, 0 replies; 15+ messages in thread
From: Tony Lindgren @ 2012-02-22 23:02 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Samuel Ortiz, Liam Girdwood, Mark Brown, Santosh Shilimkar,
	Misael Lopez Cruz, linux-kernel, linux-omap, linux-arm-kernel

* Peter Ujfalusi <peter.ujfalusi@ti.com> [120210 01:34]:
> These supplies going to be needed for the twl6040 driver.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

Acked-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCH 6/7] OMAP: omap4panda: Use common configuration for V1V8, V2V1 supplies
  2012-02-10 10:05 ` [PATCH 6/7] OMAP: omap4panda: " Peter Ujfalusi
@ 2012-02-22 23:02   ` Tony Lindgren
  0 siblings, 0 replies; 15+ messages in thread
From: Tony Lindgren @ 2012-02-22 23:02 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Samuel Ortiz, Liam Girdwood, Mark Brown, Santosh Shilimkar,
	Misael Lopez Cruz, linux-kernel, linux-omap, linux-arm-kernel

* Peter Ujfalusi <peter.ujfalusi@ti.com> [120210 01:34]:
> These supplies going to be needed for the twl6040 driver.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

Acked-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCH 3/7] MFD: twl-core: regulator configuration for twl6030 V1V8, V2V1 SMPS
  2012-02-10 10:05 ` [PATCH 3/7] MFD: twl-core: regulator configuration for twl6030 V1V8, V2V1 SMPS Peter Ujfalusi
@ 2012-02-23 15:22   ` Samuel Ortiz
  0 siblings, 0 replies; 15+ messages in thread
From: Samuel Ortiz @ 2012-02-23 15:22 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Tony Lindgren, Liam Girdwood, Mark Brown, Santosh Shilimkar,
	Misael Lopez Cruz, linux-kernel, linux-omap, linux-arm-kernel

Hi Peter,

On Fri, Feb 10, 2012 at 12:05:12PM +0200, Peter Ujfalusi wrote:
> To be able to attach consumers to these supplies from board
> files we need to have regulator_init_data for them.
If I understand correctly, this should also go through Liam's tree. If that's
so, please add my:

Acked-by: Samuel Ortiz <sameo@linux.intel.com>

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

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

end of thread, other threads:[~2012-02-23 15:22 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-10 10:05 [PATCH 0/7] TWL6040: Regulator support Peter Ujfalusi
2012-02-10 10:05 ` [PATCH 1/7] OMAP: 4430SDP: Correct fixed regulator device ID Peter Ujfalusi
2012-02-22 23:01   ` Tony Lindgren
2012-02-10 10:05 ` [PATCH 2/7] regulator: twl-regulator: Add fixed LDO for V1V8, V2V1 supply Peter Ujfalusi
2012-02-10 11:24   ` Mark Brown
2012-02-10 10:05 ` [PATCH 3/7] MFD: twl-core: regulator configuration for twl6030 V1V8, V2V1 SMPS Peter Ujfalusi
2012-02-23 15:22   ` Samuel Ortiz
2012-02-10 10:05 ` [PATCH 4/7] OMAP4: twl-common: Add twl6030 V1V8, V2V1 SMPS common configuration Peter Ujfalusi
2012-02-22 23:02   ` Tony Lindgren
2012-02-10 10:05 ` [PATCH 5/7] OMAP: 4430SDP: Use common configuration for V1V8, V2V1 supplies Peter Ujfalusi
2012-02-22 23:02   ` Tony Lindgren
2012-02-10 10:05 ` [PATCH 6/7] OMAP: omap4panda: " Peter Ujfalusi
2012-02-22 23:02   ` Tony Lindgren
2012-02-10 10:05 ` [PATCH 7/7] MFD: TWL6040: Add regulator support for VIO, " Peter Ujfalusi
2012-02-17 11:48 ` [PATCH 0/7] TWL6040: Regulator support Peter Ujfalusi

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).