All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] mfd: twl4030-power: Enable off-idle configuration when booted with device tree
@ 2014-04-24  0:40 ` Tony Lindgren
  0 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-24  0:40 UTC (permalink / raw)
  To: linux-arm-kernel, linux-omap; +Cc: Lee Jones

Hi all,

One of the major blockers for making omap3 to boot in device tree
mode has been the fact that power management has not been working
as well as when booted in legacy mode.

This series when applied on top of the patches in tread
"[PATCH 00/11] Fixes for omap PM for making omap3 DT only".

This series makes the twl4030 PMIC configurations generic
so that most boards can just use one of the configurations
based on the compatible flag alone. This allows us to drop
all the related platform data once omap3 boots in device
tree only mode.

Lee, if these patches look OK to you, please feel free to
pick them, preferrably to the immutable branch you already
have set up so I can also merge them in to be able to have
things working in my branch properly for PM.

Regards,

Tony

Tony Lindgren (4):
  mfd: twl4030-power: Add recommended idle configuration
  mfd: twl4030-power: Add support for board specific configuration
  mfd: twl4030power: Add a configuration to turn off oscillator during
    off-idle
  ARM: dts: Enable twl4030 off-idle configuration for selected omaps

 .../devicetree/bindings/mfd/twl4030-power.txt      |  10 +
 arch/arm/boot/dts/omap3-evm-common.dtsi            |   7 +
 arch/arm/boot/dts/omap3-n900.dts                   |   5 +
 drivers/mfd/twl4030-power.c                        | 205 +++++++++++++++++++++
 include/linux/i2c/twl.h                            |   1 +
 5 files changed, 228 insertions(+)

-- 
1.8.1.1


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

* [PATCH 0/4] mfd: twl4030-power: Enable off-idle configuration when booted with device tree
@ 2014-04-24  0:40 ` Tony Lindgren
  0 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-24  0:40 UTC (permalink / raw)
  To: linux-arm-kernel

Hi all,

One of the major blockers for making omap3 to boot in device tree
mode has been the fact that power management has not been working
as well as when booted in legacy mode.

This series when applied on top of the patches in tread
"[PATCH 00/11] Fixes for omap PM for making omap3 DT only".

This series makes the twl4030 PMIC configurations generic
so that most boards can just use one of the configurations
based on the compatible flag alone. This allows us to drop
all the related platform data once omap3 boots in device
tree only mode.

Lee, if these patches look OK to you, please feel free to
pick them, preferrably to the immutable branch you already
have set up so I can also merge them in to be able to have
things working in my branch properly for PM.

Regards,

Tony

Tony Lindgren (4):
  mfd: twl4030-power: Add recommended idle configuration
  mfd: twl4030-power: Add support for board specific configuration
  mfd: twl4030power: Add a configuration to turn off oscillator during
    off-idle
  ARM: dts: Enable twl4030 off-idle configuration for selected omaps

 .../devicetree/bindings/mfd/twl4030-power.txt      |  10 +
 arch/arm/boot/dts/omap3-evm-common.dtsi            |   7 +
 arch/arm/boot/dts/omap3-n900.dts                   |   5 +
 drivers/mfd/twl4030-power.c                        | 205 +++++++++++++++++++++
 include/linux/i2c/twl.h                            |   1 +
 5 files changed, 228 insertions(+)

-- 
1.8.1.1

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

* [PATCH 1/4] mfd: twl4030-power: Add recommended idle configuration
  2014-04-24  0:40 ` Tony Lindgren
@ 2014-04-24  0:40   ` Tony Lindgren
  -1 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-24  0:40 UTC (permalink / raw)
  To: linux-arm-kernel, linux-omap; +Cc: Peter De Schrijver, Samuel Ortiz, Lee Jones

These settings are based on the "Recommended Sleep Sequences for
the Zoom Platform" pdf at:

http://omappedia.com/wiki/File:Recommended_Sleep_Sequences_Zoom.pdf

These settings assume most of the regulators are under control of
Linux, and cuts off VDD1 and VDD2 during off-idle as Linux cannot
do it.

For any board specific changes to these, let's patch them in as
changes to the generic data in the follow-up patches. This keeps
the board specific changes small.

Note that this does not consider the twl5030 errata 27. That
can be added later on after it has been tested.

Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 .../devicetree/bindings/mfd/twl4030-power.txt      |   4 +
 drivers/mfd/twl4030-power.c                        | 165 +++++++++++++++++++++
 2 files changed, 169 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/twl4030-power.txt b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
index b906116..bbd6603 100644
--- a/Documentation/devicetree/bindings/mfd/twl4030-power.txt
+++ b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
@@ -8,10 +8,14 @@ Required properties:
 - compatible : must be one of the following
 	"ti,twl4030-power"
 	"ti,twl4030-power-reset"
+	"ti,twl4030-power-idle"
 
 The use of ti,twl4030-power-reset is recommended at least on
 3530 that needs a special configuration for warm reset to work.
 
+When using ti,twl4030-power-idle, the TI recommended configuration
+for idle modes is loaded to the tlw4030 PMIC.
+
 Optional properties:
 - ti,use_poweroff: With this flag, the chip will initiates an ACTIVE-to-OFF or
 		   SLEEP-to-OFF transition when the system poweroffs.
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 1db0560..89a8528 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -595,11 +595,176 @@ static struct twl4030_power_data omap3_reset = {
 	.resource_config	= omap3_rconfig,
 };
 
+/* Recommended generic default idle configuration for off-idle */
+
+/* Broadcast message to put res to sleep */
+static struct twl4030_ins omap3_idle_sleep_on_seq[] = {
+	{ MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_ALL,
+			0, RES_STATE_SLEEP), 2 },
+};
+
+static struct twl4030_script omap3_idle_sleep_on_script = {
+	.script	= omap3_idle_sleep_on_seq,
+	.size	= ARRAY_SIZE(omap3_idle_sleep_on_seq),
+	.flags	= TWL4030_SLEEP_SCRIPT,
+};
+
+/* Broadcast message to put res to active */
+static struct twl4030_ins omap3_idle_wakeup_p12_seq[] = {
+	{ MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_ALL,
+			0, RES_STATE_ACTIVE), 2 },
+	};
+
+static struct twl4030_script omap3_idle_wakeup_p12_script = {
+	.script	= omap3_idle_wakeup_p12_seq,
+	.size	= ARRAY_SIZE(omap3_idle_wakeup_p12_seq),
+	.flags	= TWL4030_WAKEUP12_SCRIPT,
+};
+
+/* Broadcast message to put res to active */
+static struct twl4030_ins omap3_idle_wakeup_p3_seq[] = {
+	{ MSG_SINGULAR(DEV_GRP_NULL, RES_CLKEN, RES_STATE_ACTIVE), 0x37 },
+	{ MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_ALL,
+		       0, RES_STATE_ACTIVE), 2 },
+};
+
+static struct twl4030_script omap3_idle_wakeup_p3_script = {
+	.script	= omap3_idle_wakeup_p3_seq,
+	.size	= ARRAY_SIZE(omap3_idle_wakeup_p3_seq),
+	.flags	= TWL4030_WAKEUP3_SCRIPT,
+};
+
+static struct twl4030_script omap3_idle_wrst_script = {
+	.script	= omap3_wrst_seq,
+	.size	= ARRAY_SIZE(omap3_wrst_seq),
+	.flags	= TWL4030_WRST_SCRIPT,
+};
+
+static struct twl4030_script *omap3_idle_scripts[] = {
+	&omap3_idle_wakeup_p12_script,
+	&omap3_idle_wakeup_p3_script,
+	&omap3_idle_wrst_script,
+	&omap3_idle_sleep_on_script,
+};
+
+/*
+ * Usable values for .remap_sleep and .remap_off
+ * Based on table "5.3.3 Resource Operating modes"
+ */
+enum {
+	TWL_REMAP_OFF = 0,
+	TWL_REMAP_SLEEP = 8,
+	TWL_REMAP_ACTIVE = 9,
+};
+
+#define TWL_DEV_GRP_P123	(DEV_GRP_P1 | DEV_GRP_P2 | DEV_GRP_P3)
+
+/*
+ * Recommended configuration based on "Recommended Sleep
+ * Sequences for the Zoom Platform":
+ * http://omappedia.com/wiki/File:Recommended_Sleep_Sequences_Zoom.pdf
+ */
+static struct twl4030_resconfig omap3_idle_rconfig[] = {
+	{ .resource = RES_VAUX1, .devgroup = DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VAUX2, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VAUX3, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VAUX4, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VMMC1, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0,  .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VMMC2, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VPLL1, .devgroup = DEV_GRP_P1,
+	  .type = 3, .type2 = 1, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_OFF, },
+	{ .resource = RES_VPLL2, .devgroup = DEV_GRP_P1,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VSIM, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VDAC, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VINTANA1, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 1, .type2 = 2, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VINTANA2, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 0, .type2 = 2, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VINTDIG, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 1, .type2 = 2, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VIO, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 2, .type2 = 2, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VDD1, .devgroup = DEV_GRP_P1,
+	  .type = 4, .type2 = 1, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_OFF, },
+	{ .resource = RES_VDD2, .devgroup = DEV_GRP_P1,
+	  .type = 3, .type2 = 1, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_OFF, },
+	{ .resource = RES_VUSB_1V5, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VUSB_1V8, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VUSB_3V1, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	/* Resource #20 USB charge pump skipped */
+	{ .resource = RES_REGEN, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 2, .type2 = 1, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_NRES_PWRON, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 0, .type2 = 1, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP },
+	{ .resource = RES_CLKEN, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 3, .type2 = 2, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_SYSEN, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 6, .type2 = -1, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3,
+	  .type = 0, .type2 = 2, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_32KCLKOUT, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_RESET, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 6, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_MAIN_REF, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ /* Terminator */ },
+};
+
+static struct twl4030_power_data omap3_idle = {
+	.scripts		= omap3_idle_scripts,
+	.num			= ARRAY_SIZE(omap3_idle_scripts),
+	.resource_config	= omap3_idle_rconfig,
+};
+
 static struct of_device_id twl4030_power_of_match[] = {
 	{
 		.compatible = "ti,twl4030-power-reset",
 		.data = &omap3_reset,
 	},
+	{
+		.compatible = "ti,twl4030-power-idle",
+		.data = &omap3_idle,
+	},
 	{ },
 };
 MODULE_DEVICE_TABLE(of, twl4030_power_of_match);
-- 
1.8.1.1


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

* [PATCH 1/4] mfd: twl4030-power: Add recommended idle configuration
@ 2014-04-24  0:40   ` Tony Lindgren
  0 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-24  0:40 UTC (permalink / raw)
  To: linux-arm-kernel

These settings are based on the "Recommended Sleep Sequences for
the Zoom Platform" pdf at:

http://omappedia.com/wiki/File:Recommended_Sleep_Sequences_Zoom.pdf

These settings assume most of the regulators are under control of
Linux, and cuts off VDD1 and VDD2 during off-idle as Linux cannot
do it.

For any board specific changes to these, let's patch them in as
changes to the generic data in the follow-up patches. This keeps
the board specific changes small.

Note that this does not consider the twl5030 errata 27. That
can be added later on after it has been tested.

Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 .../devicetree/bindings/mfd/twl4030-power.txt      |   4 +
 drivers/mfd/twl4030-power.c                        | 165 +++++++++++++++++++++
 2 files changed, 169 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/twl4030-power.txt b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
index b906116..bbd6603 100644
--- a/Documentation/devicetree/bindings/mfd/twl4030-power.txt
+++ b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
@@ -8,10 +8,14 @@ Required properties:
 - compatible : must be one of the following
 	"ti,twl4030-power"
 	"ti,twl4030-power-reset"
+	"ti,twl4030-power-idle"
 
 The use of ti,twl4030-power-reset is recommended at least on
 3530 that needs a special configuration for warm reset to work.
 
+When using ti,twl4030-power-idle, the TI recommended configuration
+for idle modes is loaded to the tlw4030 PMIC.
+
 Optional properties:
 - ti,use_poweroff: With this flag, the chip will initiates an ACTIVE-to-OFF or
 		   SLEEP-to-OFF transition when the system poweroffs.
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 1db0560..89a8528 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -595,11 +595,176 @@ static struct twl4030_power_data omap3_reset = {
 	.resource_config	= omap3_rconfig,
 };
 
+/* Recommended generic default idle configuration for off-idle */
+
+/* Broadcast message to put res to sleep */
+static struct twl4030_ins omap3_idle_sleep_on_seq[] = {
+	{ MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_ALL,
+			0, RES_STATE_SLEEP), 2 },
+};
+
+static struct twl4030_script omap3_idle_sleep_on_script = {
+	.script	= omap3_idle_sleep_on_seq,
+	.size	= ARRAY_SIZE(omap3_idle_sleep_on_seq),
+	.flags	= TWL4030_SLEEP_SCRIPT,
+};
+
+/* Broadcast message to put res to active */
+static struct twl4030_ins omap3_idle_wakeup_p12_seq[] = {
+	{ MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_ALL,
+			0, RES_STATE_ACTIVE), 2 },
+	};
+
+static struct twl4030_script omap3_idle_wakeup_p12_script = {
+	.script	= omap3_idle_wakeup_p12_seq,
+	.size	= ARRAY_SIZE(omap3_idle_wakeup_p12_seq),
+	.flags	= TWL4030_WAKEUP12_SCRIPT,
+};
+
+/* Broadcast message to put res to active */
+static struct twl4030_ins omap3_idle_wakeup_p3_seq[] = {
+	{ MSG_SINGULAR(DEV_GRP_NULL, RES_CLKEN, RES_STATE_ACTIVE), 0x37 },
+	{ MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_ALL,
+		       0, RES_STATE_ACTIVE), 2 },
+};
+
+static struct twl4030_script omap3_idle_wakeup_p3_script = {
+	.script	= omap3_idle_wakeup_p3_seq,
+	.size	= ARRAY_SIZE(omap3_idle_wakeup_p3_seq),
+	.flags	= TWL4030_WAKEUP3_SCRIPT,
+};
+
+static struct twl4030_script omap3_idle_wrst_script = {
+	.script	= omap3_wrst_seq,
+	.size	= ARRAY_SIZE(omap3_wrst_seq),
+	.flags	= TWL4030_WRST_SCRIPT,
+};
+
+static struct twl4030_script *omap3_idle_scripts[] = {
+	&omap3_idle_wakeup_p12_script,
+	&omap3_idle_wakeup_p3_script,
+	&omap3_idle_wrst_script,
+	&omap3_idle_sleep_on_script,
+};
+
+/*
+ * Usable values for .remap_sleep and .remap_off
+ * Based on table "5.3.3 Resource Operating modes"
+ */
+enum {
+	TWL_REMAP_OFF = 0,
+	TWL_REMAP_SLEEP = 8,
+	TWL_REMAP_ACTIVE = 9,
+};
+
+#define TWL_DEV_GRP_P123	(DEV_GRP_P1 | DEV_GRP_P2 | DEV_GRP_P3)
+
+/*
+ * Recommended configuration based on "Recommended Sleep
+ * Sequences for the Zoom Platform":
+ * http://omappedia.com/wiki/File:Recommended_Sleep_Sequences_Zoom.pdf
+ */
+static struct twl4030_resconfig omap3_idle_rconfig[] = {
+	{ .resource = RES_VAUX1, .devgroup = DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VAUX2, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VAUX3, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VAUX4, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VMMC1, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0,  .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VMMC2, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VPLL1, .devgroup = DEV_GRP_P1,
+	  .type = 3, .type2 = 1, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_OFF, },
+	{ .resource = RES_VPLL2, .devgroup = DEV_GRP_P1,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VSIM, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VDAC, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VINTANA1, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 1, .type2 = 2, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VINTANA2, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 0, .type2 = 2, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VINTDIG, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 1, .type2 = 2, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VIO, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 2, .type2 = 2, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VDD1, .devgroup = DEV_GRP_P1,
+	  .type = 4, .type2 = 1, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_OFF, },
+	{ .resource = RES_VDD2, .devgroup = DEV_GRP_P1,
+	  .type = 3, .type2 = 1, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_OFF, },
+	{ .resource = RES_VUSB_1V5, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VUSB_1V8, .devgroup =  DEV_GRP_NULL,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_VUSB_3V1, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	/* Resource #20 USB charge pump skipped */
+	{ .resource = RES_REGEN, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 2, .type2 = 1, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_NRES_PWRON, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 0, .type2 = 1, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP },
+	{ .resource = RES_CLKEN, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 3, .type2 = 2, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_SYSEN, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 6, .type2 = -1, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3,
+	  .type = 0, .type2 = 2, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_32KCLKOUT, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_RESET, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 6, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ .resource = RES_MAIN_REF, .devgroup = TWL_DEV_GRP_P123,
+	  .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ /* Terminator */ },
+};
+
+static struct twl4030_power_data omap3_idle = {
+	.scripts		= omap3_idle_scripts,
+	.num			= ARRAY_SIZE(omap3_idle_scripts),
+	.resource_config	= omap3_idle_rconfig,
+};
+
 static struct of_device_id twl4030_power_of_match[] = {
 	{
 		.compatible = "ti,twl4030-power-reset",
 		.data = &omap3_reset,
 	},
+	{
+		.compatible = "ti,twl4030-power-idle",
+		.data = &omap3_idle,
+	},
 	{ },
 };
 MODULE_DEVICE_TABLE(of, twl4030_power_of_match);
-- 
1.8.1.1

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

* [PATCH 2/4] mfd: twl4030-power: Add support for board specific configuration
  2014-04-24  0:40 ` Tony Lindgren
@ 2014-04-24  0:40   ` Tony Lindgren
  -1 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-24  0:40 UTC (permalink / raw)
  To: linux-arm-kernel, linux-omap; +Cc: Peter De Schrijver, Samuel Ortiz, Lee Jones

With the recommended twl4030 configuration added, we can now add
board specific changes as modifications to the recommended
configuration.

Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/mfd/twl4030-power.c | 21 +++++++++++++++++++++
 include/linux/i2c/twl.h     |  1 +
 2 files changed, 22 insertions(+)

diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 89a8528..89c6b1a 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -511,13 +511,34 @@ twl4030_power_configure_scripts(const struct twl4030_power_data *pdata)
 	return 0;
 }
 
+static void twl4030_patch_rconfig(struct twl4030_resconfig *common,
+				  struct twl4030_resconfig *board)
+{
+	while (common->resource) {
+		struct twl4030_resconfig *b = board;
+
+		while (b->resource) {
+			if (b->resource == common->resource) {
+				*common = *b;
+				break;
+			}
+			b++;
+		}
+		common++;
+	}
+}
+
 static int
 twl4030_power_configure_resources(const struct twl4030_power_data *pdata)
 {
 	struct twl4030_resconfig *resconfig = pdata->resource_config;
+	struct twl4030_resconfig *boardconf = pdata->board_config;
 	int err;
 
 	if (resconfig) {
+		if (boardconf)
+			twl4030_patch_rconfig(resconfig, boardconf);
+
 		while (resconfig->resource) {
 			err = twl4030_configure_resource(resconfig);
 			if (err)
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index ade1c06..069f78f 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -659,6 +659,7 @@ struct twl4030_power_data {
 	struct twl4030_script **scripts;
 	unsigned num;
 	struct twl4030_resconfig *resource_config;
+	struct twl4030_resconfig *board_config;
 #define TWL4030_RESCONFIG_UNDEF	((u8)-1)
 	bool use_poweroff;	/* Board is wired for TWL poweroff */
 };
-- 
1.8.1.1


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

* [PATCH 2/4] mfd: twl4030-power: Add support for board specific configuration
@ 2014-04-24  0:40   ` Tony Lindgren
  0 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-24  0:40 UTC (permalink / raw)
  To: linux-arm-kernel

With the recommended twl4030 configuration added, we can now add
board specific changes as modifications to the recommended
configuration.

Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/mfd/twl4030-power.c | 21 +++++++++++++++++++++
 include/linux/i2c/twl.h     |  1 +
 2 files changed, 22 insertions(+)

diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 89a8528..89c6b1a 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -511,13 +511,34 @@ twl4030_power_configure_scripts(const struct twl4030_power_data *pdata)
 	return 0;
 }
 
+static void twl4030_patch_rconfig(struct twl4030_resconfig *common,
+				  struct twl4030_resconfig *board)
+{
+	while (common->resource) {
+		struct twl4030_resconfig *b = board;
+
+		while (b->resource) {
+			if (b->resource == common->resource) {
+				*common = *b;
+				break;
+			}
+			b++;
+		}
+		common++;
+	}
+}
+
 static int
 twl4030_power_configure_resources(const struct twl4030_power_data *pdata)
 {
 	struct twl4030_resconfig *resconfig = pdata->resource_config;
+	struct twl4030_resconfig *boardconf = pdata->board_config;
 	int err;
 
 	if (resconfig) {
+		if (boardconf)
+			twl4030_patch_rconfig(resconfig, boardconf);
+
 		while (resconfig->resource) {
 			err = twl4030_configure_resource(resconfig);
 			if (err)
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index ade1c06..069f78f 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -659,6 +659,7 @@ struct twl4030_power_data {
 	struct twl4030_script **scripts;
 	unsigned num;
 	struct twl4030_resconfig *resource_config;
+	struct twl4030_resconfig *board_config;
 #define TWL4030_RESCONFIG_UNDEF	((u8)-1)
 	bool use_poweroff;	/* Board is wired for TWL poweroff */
 };
-- 
1.8.1.1

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

* [PATCH 3/4] mfd: twl4030power: Add a configuration to turn off oscillator during off-idle
  2014-04-24  0:40 ` Tony Lindgren
@ 2014-04-24  0:40   ` Tony Lindgren
  -1 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-24  0:40 UTC (permalink / raw)
  To: linux-arm-kernel, linux-omap; +Cc: Peter De Schrijver, Samuel Ortiz, Lee Jones

Some oscillators can be turned off during off-idle saving few
a little bit power at the cost of the oscillator start up
latency.

If you board can do this, you can now enable it by using the
ti,twl4030-power-idle-osc-off compatible flag.

Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 .../devicetree/bindings/mfd/twl4030-power.txt         |  6 ++++++
 drivers/mfd/twl4030-power.c                           | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/twl4030-power.txt b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
index bbd6603..b9ee7b9 100644
--- a/Documentation/devicetree/bindings/mfd/twl4030-power.txt
+++ b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
@@ -9,6 +9,7 @@ Required properties:
 	"ti,twl4030-power"
 	"ti,twl4030-power-reset"
 	"ti,twl4030-power-idle"
+	"ti,twl4030-power-idle-osc-off"
 
 The use of ti,twl4030-power-reset is recommended at least on
 3530 that needs a special configuration for warm reset to work.
@@ -16,6 +17,11 @@ The use of ti,twl4030-power-reset is recommended at least on
 When using ti,twl4030-power-idle, the TI recommended configuration
 for idle modes is loaded to the tlw4030 PMIC.
 
+When using ti,twl4030-power-idle-osc-off, the TI recommended
+configuration is used with the external oscillator being shut
+down during off-idle. Note that this does not work on all boards
+depending on how the external oscillator is wired.
+
 Optional properties:
 - ti,use_poweroff: With this flag, the chip will initiates an ACTIVE-to-OFF or
 		   SLEEP-to-OFF transition when the system poweroffs.
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 89c6b1a..12e4abe 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -777,6 +777,21 @@ static struct twl4030_power_data omap3_idle = {
 	.resource_config	= omap3_idle_rconfig,
 };
 
+/* Disable 32 KiHz oscillator during idle */
+static struct twl4030_resconfig osc_off_rconfig[] = {
+	{ .resource = RES_CLKEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
+	  .type = 3, .type2 = 2, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ /* Terminator */ },
+};
+
+static struct twl4030_power_data osc_off_idle = {
+	.scripts		= omap3_idle_scripts,
+	.num			= ARRAY_SIZE(omap3_idle_scripts),
+	.resource_config	= omap3_idle_rconfig,
+	.board_config		= osc_off_rconfig,
+};
+
 static struct of_device_id twl4030_power_of_match[] = {
 	{
 		.compatible = "ti,twl4030-power-reset",
@@ -786,6 +801,10 @@ static struct of_device_id twl4030_power_of_match[] = {
 		.compatible = "ti,twl4030-power-idle",
 		.data = &omap3_idle,
 	},
+	{
+		.compatible = "ti,twl4030-power-idle-osc-off",
+		.data = &osc_off_idle,
+	},
 	{ },
 };
 MODULE_DEVICE_TABLE(of, twl4030_power_of_match);
-- 
1.8.1.1


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

* [PATCH 3/4] mfd: twl4030power: Add a configuration to turn off oscillator during off-idle
@ 2014-04-24  0:40   ` Tony Lindgren
  0 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-24  0:40 UTC (permalink / raw)
  To: linux-arm-kernel

Some oscillators can be turned off during off-idle saving few
a little bit power at the cost of the oscillator start up
latency.

If you board can do this, you can now enable it by using the
ti,twl4030-power-idle-osc-off compatible flag.

Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 .../devicetree/bindings/mfd/twl4030-power.txt         |  6 ++++++
 drivers/mfd/twl4030-power.c                           | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/twl4030-power.txt b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
index bbd6603..b9ee7b9 100644
--- a/Documentation/devicetree/bindings/mfd/twl4030-power.txt
+++ b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
@@ -9,6 +9,7 @@ Required properties:
 	"ti,twl4030-power"
 	"ti,twl4030-power-reset"
 	"ti,twl4030-power-idle"
+	"ti,twl4030-power-idle-osc-off"
 
 The use of ti,twl4030-power-reset is recommended at least on
 3530 that needs a special configuration for warm reset to work.
@@ -16,6 +17,11 @@ The use of ti,twl4030-power-reset is recommended at least on
 When using ti,twl4030-power-idle, the TI recommended configuration
 for idle modes is loaded to the tlw4030 PMIC.
 
+When using ti,twl4030-power-idle-osc-off, the TI recommended
+configuration is used with the external oscillator being shut
+down during off-idle. Note that this does not work on all boards
+depending on how the external oscillator is wired.
+
 Optional properties:
 - ti,use_poweroff: With this flag, the chip will initiates an ACTIVE-to-OFF or
 		   SLEEP-to-OFF transition when the system poweroffs.
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 89c6b1a..12e4abe 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -777,6 +777,21 @@ static struct twl4030_power_data omap3_idle = {
 	.resource_config	= omap3_idle_rconfig,
 };
 
+/* Disable 32 KiHz oscillator during idle */
+static struct twl4030_resconfig osc_off_rconfig[] = {
+	{ .resource = RES_CLKEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
+	  .type = 3, .type2 = 2, .remap_off = TWL_REMAP_OFF,
+	  .remap_sleep = TWL_REMAP_SLEEP, },
+	{ /* Terminator */ },
+};
+
+static struct twl4030_power_data osc_off_idle = {
+	.scripts		= omap3_idle_scripts,
+	.num			= ARRAY_SIZE(omap3_idle_scripts),
+	.resource_config	= omap3_idle_rconfig,
+	.board_config		= osc_off_rconfig,
+};
+
 static struct of_device_id twl4030_power_of_match[] = {
 	{
 		.compatible = "ti,twl4030-power-reset",
@@ -786,6 +801,10 @@ static struct of_device_id twl4030_power_of_match[] = {
 		.compatible = "ti,twl4030-power-idle",
 		.data = &omap3_idle,
 	},
+	{
+		.compatible = "ti,twl4030-power-idle-osc-off",
+		.data = &osc_off_idle,
+	},
 	{ },
 };
 MODULE_DEVICE_TABLE(of, twl4030_power_of_match);
-- 
1.8.1.1

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

* [PATCH 4/4] ARM: dts: Enable twl4030 off-idle configuration for selected omaps
  2014-04-24  0:40 ` Tony Lindgren
@ 2014-04-24  0:40   ` Tony Lindgren
  -1 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-24  0:40 UTC (permalink / raw)
  To: linux-arm-kernel, linux-omap

At least N900 now seems to shut down the external oscillator
when hitting off-idle.

OMAP37XX EVM (TMDSEVM3730) does not seem to have twl4030 clken
pin connected, so there is no point trying to enable shutting
down of the oscillator on it for the extra latency it adds.

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/boot/dts/omap3-evm-common.dtsi | 7 +++++++
 arch/arm/boot/dts/omap3-n900.dts        | 5 +++++
 2 files changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/omap3-evm-common.dtsi b/arch/arm/boot/dts/omap3-evm-common.dtsi
index 3007e79..3d25340 100644
--- a/arch/arm/boot/dts/omap3-evm-common.dtsi
+++ b/arch/arm/boot/dts/omap3-evm-common.dtsi
@@ -45,6 +45,13 @@
 #include "twl4030.dtsi"
 #include "twl4030_omap3.dtsi"
 
+&twl {
+	twl_power: power {
+		compatible = "ti,twl4030-power-idle";
+		ti,use_poweroff;
+	};
+};
+
 &i2c2 {
 	clock-frequency = <400000>;
 };
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index bae58c0..c9ed2d4 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -269,6 +269,11 @@
 		compatible = "ti,twl4030-audio";
 		ti,enable-vibra = <1>;
 	};
+
+	twl_power: power {
+		compatible = "ti,twl4030-power-idle-osc-off";
+		ti,use_poweroff;
+	};
 };
 
 &twl_gpio {
-- 
1.8.1.1


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

* [PATCH 4/4] ARM: dts: Enable twl4030 off-idle configuration for selected omaps
@ 2014-04-24  0:40   ` Tony Lindgren
  0 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-24  0:40 UTC (permalink / raw)
  To: linux-arm-kernel

At least N900 now seems to shut down the external oscillator
when hitting off-idle.

OMAP37XX EVM (TMDSEVM3730) does not seem to have twl4030 clken
pin connected, so there is no point trying to enable shutting
down of the oscillator on it for the extra latency it adds.

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/boot/dts/omap3-evm-common.dtsi | 7 +++++++
 arch/arm/boot/dts/omap3-n900.dts        | 5 +++++
 2 files changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/omap3-evm-common.dtsi b/arch/arm/boot/dts/omap3-evm-common.dtsi
index 3007e79..3d25340 100644
--- a/arch/arm/boot/dts/omap3-evm-common.dtsi
+++ b/arch/arm/boot/dts/omap3-evm-common.dtsi
@@ -45,6 +45,13 @@
 #include "twl4030.dtsi"
 #include "twl4030_omap3.dtsi"
 
+&twl {
+	twl_power: power {
+		compatible = "ti,twl4030-power-idle";
+		ti,use_poweroff;
+	};
+};
+
 &i2c2 {
 	clock-frequency = <400000>;
 };
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index bae58c0..c9ed2d4 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -269,6 +269,11 @@
 		compatible = "ti,twl4030-audio";
 		ti,enable-vibra = <1>;
 	};
+
+	twl_power: power {
+		compatible = "ti,twl4030-power-idle-osc-off";
+		ti,use_poweroff;
+	};
 };
 
 &twl_gpio {
-- 
1.8.1.1

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

* [PATCH 1a/4] mfd: twl4030-power: Add generic reset configuration
  2014-04-24  0:40 ` Tony Lindgren
@ 2014-04-24  0:49   ` Tony Lindgren
  -1 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-24  0:49 UTC (permalink / raw)
  To: linux-arm-kernel, linux-omap
  Cc: Matthias Brugger, Robert Nelson, Peter De Schrijver,
	Samuel Ortiz, Lee Jones

The twl4030 PMIC needs to be configured properly for things like
warm reset and deeper idle states so the PMIC manages the regulators
properly based on the hardware triggers from the SoC.

For example, when rebooting an OMAP3530 at 125 MHz, it hangs.
With this patch, TWL4030 will be reset when a warm reset occures.
This way the OMAP3530 does not hang on reboot.

Let's use this as the default when compatible = "ti,twl4030-power".
Other more complicated configurations can be added to the driver
based on other compatible flags.

Based on earlier patch by Matthias Brugger <matthias.bgg@gmail.com>:

http://lists.infradead.org/pipermail/linux-arm-kernel/2013-January/144161.html

For more information about twl4030 configuration for the
"power scripts" see:

http://www.omappedia.com/wiki/TWL4030_power_scripts

Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Robert Nelson <robertcnelson@gmail.com>
Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>

---

Sorry this got accidentally left out, should be the first patch
in the series.

diff --git a/Documentation/devicetree/bindings/mfd/twl4030-power.txt b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
index 8e15ec3..b906116 100644
--- a/Documentation/devicetree/bindings/mfd/twl4030-power.txt
+++ b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
@@ -5,7 +5,12 @@ to control the power resources, including power scripts. For now, the
 binding only supports the complete shutdown of the system after poweroff.
 
 Required properties:
-- compatible : must be "ti,twl4030-power"
+- compatible : must be one of the following
+	"ti,twl4030-power"
+	"ti,twl4030-power-reset"
+
+The use of ti,twl4030-power-reset is recommended at least on
+3530 that needs a special configuration for warm reset to work.
 
 Optional properties:
 - ti,use_poweroff: With this flag, the chip will initiates an ACTIVE-to-OFF or
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 96162b6..1db0560 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -29,6 +29,7 @@
 #include <linux/i2c/twl.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 
 #include <asm/mach-types.h>
 
@@ -493,7 +494,8 @@ int twl4030_remove_script(u8 flags)
 	return err;
 }
 
-static int twl4030_power_configure_scripts(struct twl4030_power_data *pdata)
+static int
+twl4030_power_configure_scripts(const struct twl4030_power_data *pdata)
 {
 	int err;
 	int i;
@@ -509,7 +511,8 @@ static int twl4030_power_configure_scripts(struct twl4030_power_data *pdata)
 	return 0;
 }
 
-static int twl4030_power_configure_resources(struct twl4030_power_data *pdata)
+static int
+twl4030_power_configure_resources(const struct twl4030_power_data *pdata)
 {
 	struct twl4030_resconfig *resconfig = pdata->resource_config;
 	int err;
@@ -541,7 +544,7 @@ void twl4030_power_off(void)
 		pr_err("TWL4030 Unable to power off\n");
 }
 
-static bool twl4030_power_use_poweroff(struct twl4030_power_data *pdata,
+static bool twl4030_power_use_poweroff(const struct twl4030_power_data *pdata,
 					struct device_node *node)
 {
 	if (pdata && pdata->use_poweroff)
@@ -553,10 +556,60 @@ static bool twl4030_power_use_poweroff(struct twl4030_power_data *pdata,
 	return false;
 }
 
+#ifdef CONFIG_OF
+
+/* Generic warm reset configuration for omap3 */
+
+static struct twl4030_ins omap3_wrst_seq[] = {
+	{ MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_OFF), 2 },
+	{ MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_WRST), 15 },
+	{ MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_WRST), 15 },
+	{ MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_WRST), 0x60 },
+	{ MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2 },
+	{ MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_ACTIVE), 2 },
+};
+
+static struct twl4030_script omap3_wrst_script = {
+	.script	= omap3_wrst_seq,
+	.size	= ARRAY_SIZE(omap3_wrst_seq),
+	.flags	= TWL4030_WRST_SCRIPT,
+};
+
+static struct twl4030_script *omap3_reset_scripts[] = {
+	&omap3_wrst_script,
+};
+
+static struct twl4030_resconfig omap3_rconfig[] = {
+	{ .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3, .type = -1,
+	  .type2 = -1 },
+	{ .resource = RES_VDD1, .devgroup = DEV_GRP_P1, .type = -1,
+	  .type2 = -1 },
+	{ .resource = RES_VDD2, .devgroup = DEV_GRP_P1, .type = -1,
+	  .type2 = -1 },
+	{ 0, 0},
+};
+
+static struct twl4030_power_data omap3_reset = {
+	.scripts		= omap3_reset_scripts,
+	.num			= ARRAY_SIZE(omap3_reset_scripts),
+	.resource_config	= omap3_rconfig,
+};
+
+static struct of_device_id twl4030_power_of_match[] = {
+	{
+		.compatible = "ti,twl4030-power-reset",
+		.data = &omap3_reset,
+	},
+	{ },
+};
+MODULE_DEVICE_TABLE(of, twl4030_power_of_match);
+#endif	/* CONFIG_OF */
+
 static int twl4030_power_probe(struct platform_device *pdev)
 {
-	struct twl4030_power_data *pdata = dev_get_platdata(&pdev->dev);
+	const struct twl4030_power_data *pdata = dev_get_platdata(&pdev->dev);
 	struct device_node *node = pdev->dev.of_node;
+	const struct of_device_id *match;
 	int err = 0;
 	int err2 = 0;
 	u8 val;
@@ -577,8 +630,12 @@ static int twl4030_power_probe(struct platform_device *pdev)
 		return err;
 	}
 
+	match = of_match_device(of_match_ptr(twl4030_power_of_match),
+				&pdev->dev);
+	if (match && match->data)
+		pdata = match->data;
+
 	if (pdata) {
-		/* TODO: convert to device tree */
 		err = twl4030_power_configure_scripts(pdata);
 		if (err) {
 			pr_err("TWL4030 failed to load scripts\n");
@@ -628,14 +685,6 @@ static int twl4030_power_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_OF
-static const struct of_device_id twl4030_power_of_match[] = {
-	{.compatible = "ti,twl4030-power", },
-	{ },
-};
-MODULE_DEVICE_TABLE(of, twl4030_power_of_match);
-#endif
-
 static struct platform_driver twl4030_power_driver = {
 	.driver = {
 		.name	= "twl4030_power",

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

* [PATCH 1a/4] mfd: twl4030-power: Add generic reset configuration
@ 2014-04-24  0:49   ` Tony Lindgren
  0 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-24  0:49 UTC (permalink / raw)
  To: linux-arm-kernel

The twl4030 PMIC needs to be configured properly for things like
warm reset and deeper idle states so the PMIC manages the regulators
properly based on the hardware triggers from the SoC.

For example, when rebooting an OMAP3530 at 125 MHz, it hangs.
With this patch, TWL4030 will be reset when a warm reset occures.
This way the OMAP3530 does not hang on reboot.

Let's use this as the default when compatible = "ti,twl4030-power".
Other more complicated configurations can be added to the driver
based on other compatible flags.

Based on earlier patch by Matthias Brugger <matthias.bgg@gmail.com>:

http://lists.infradead.org/pipermail/linux-arm-kernel/2013-January/144161.html

For more information about twl4030 configuration for the
"power scripts" see:

http://www.omappedia.com/wiki/TWL4030_power_scripts

Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Robert Nelson <robertcnelson@gmail.com>
Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>

---

Sorry this got accidentally left out, should be the first patch
in the series.

diff --git a/Documentation/devicetree/bindings/mfd/twl4030-power.txt b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
index 8e15ec3..b906116 100644
--- a/Documentation/devicetree/bindings/mfd/twl4030-power.txt
+++ b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
@@ -5,7 +5,12 @@ to control the power resources, including power scripts. For now, the
 binding only supports the complete shutdown of the system after poweroff.
 
 Required properties:
-- compatible : must be "ti,twl4030-power"
+- compatible : must be one of the following
+	"ti,twl4030-power"
+	"ti,twl4030-power-reset"
+
+The use of ti,twl4030-power-reset is recommended at least on
+3530 that needs a special configuration for warm reset to work.
 
 Optional properties:
 - ti,use_poweroff: With this flag, the chip will initiates an ACTIVE-to-OFF or
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 96162b6..1db0560 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -29,6 +29,7 @@
 #include <linux/i2c/twl.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 
 #include <asm/mach-types.h>
 
@@ -493,7 +494,8 @@ int twl4030_remove_script(u8 flags)
 	return err;
 }
 
-static int twl4030_power_configure_scripts(struct twl4030_power_data *pdata)
+static int
+twl4030_power_configure_scripts(const struct twl4030_power_data *pdata)
 {
 	int err;
 	int i;
@@ -509,7 +511,8 @@ static int twl4030_power_configure_scripts(struct twl4030_power_data *pdata)
 	return 0;
 }
 
-static int twl4030_power_configure_resources(struct twl4030_power_data *pdata)
+static int
+twl4030_power_configure_resources(const struct twl4030_power_data *pdata)
 {
 	struct twl4030_resconfig *resconfig = pdata->resource_config;
 	int err;
@@ -541,7 +544,7 @@ void twl4030_power_off(void)
 		pr_err("TWL4030 Unable to power off\n");
 }
 
-static bool twl4030_power_use_poweroff(struct twl4030_power_data *pdata,
+static bool twl4030_power_use_poweroff(const struct twl4030_power_data *pdata,
 					struct device_node *node)
 {
 	if (pdata && pdata->use_poweroff)
@@ -553,10 +556,60 @@ static bool twl4030_power_use_poweroff(struct twl4030_power_data *pdata,
 	return false;
 }
 
+#ifdef CONFIG_OF
+
+/* Generic warm reset configuration for omap3 */
+
+static struct twl4030_ins omap3_wrst_seq[] = {
+	{ MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_OFF), 2 },
+	{ MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_WRST), 15 },
+	{ MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_WRST), 15 },
+	{ MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_WRST), 0x60 },
+	{ MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2 },
+	{ MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_ACTIVE), 2 },
+};
+
+static struct twl4030_script omap3_wrst_script = {
+	.script	= omap3_wrst_seq,
+	.size	= ARRAY_SIZE(omap3_wrst_seq),
+	.flags	= TWL4030_WRST_SCRIPT,
+};
+
+static struct twl4030_script *omap3_reset_scripts[] = {
+	&omap3_wrst_script,
+};
+
+static struct twl4030_resconfig omap3_rconfig[] = {
+	{ .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3, .type = -1,
+	  .type2 = -1 },
+	{ .resource = RES_VDD1, .devgroup = DEV_GRP_P1, .type = -1,
+	  .type2 = -1 },
+	{ .resource = RES_VDD2, .devgroup = DEV_GRP_P1, .type = -1,
+	  .type2 = -1 },
+	{ 0, 0},
+};
+
+static struct twl4030_power_data omap3_reset = {
+	.scripts		= omap3_reset_scripts,
+	.num			= ARRAY_SIZE(omap3_reset_scripts),
+	.resource_config	= omap3_rconfig,
+};
+
+static struct of_device_id twl4030_power_of_match[] = {
+	{
+		.compatible = "ti,twl4030-power-reset",
+		.data = &omap3_reset,
+	},
+	{ },
+};
+MODULE_DEVICE_TABLE(of, twl4030_power_of_match);
+#endif	/* CONFIG_OF */
+
 static int twl4030_power_probe(struct platform_device *pdev)
 {
-	struct twl4030_power_data *pdata = dev_get_platdata(&pdev->dev);
+	const struct twl4030_power_data *pdata = dev_get_platdata(&pdev->dev);
 	struct device_node *node = pdev->dev.of_node;
+	const struct of_device_id *match;
 	int err = 0;
 	int err2 = 0;
 	u8 val;
@@ -577,8 +630,12 @@ static int twl4030_power_probe(struct platform_device *pdev)
 		return err;
 	}
 
+	match = of_match_device(of_match_ptr(twl4030_power_of_match),
+				&pdev->dev);
+	if (match && match->data)
+		pdata = match->data;
+
 	if (pdata) {
-		/* TODO: convert to device tree */
 		err = twl4030_power_configure_scripts(pdata);
 		if (err) {
 			pr_err("TWL4030 failed to load scripts\n");
@@ -628,14 +685,6 @@ static int twl4030_power_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_OF
-static const struct of_device_id twl4030_power_of_match[] = {
-	{.compatible = "ti,twl4030-power", },
-	{ },
-};
-MODULE_DEVICE_TABLE(of, twl4030_power_of_match);
-#endif
-
 static struct platform_driver twl4030_power_driver = {
 	.driver = {
 		.name	= "twl4030_power",

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

* Re: [PATCH 1a/4] mfd: twl4030-power: Add generic reset configuration
  2014-04-24  0:49   ` Tony Lindgren
@ 2014-04-28 11:37     ` Lee Jones
  -1 siblings, 0 replies; 28+ messages in thread
From: Lee Jones @ 2014-04-28 11:37 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-arm-kernel, linux-omap, Matthias Brugger, Robert Nelson,
	Peter De Schrijver, Samuel Ortiz

> The twl4030 PMIC needs to be configured properly for things like
> warm reset and deeper idle states so the PMIC manages the regulators
> properly based on the hardware triggers from the SoC.
> 
> For example, when rebooting an OMAP3530 at 125 MHz, it hangs.
> With this patch, TWL4030 will be reset when a warm reset occures.
> This way the OMAP3530 does not hang on reboot.
> 
> Let's use this as the default when compatible = "ti,twl4030-power".
> Other more complicated configurations can be added to the driver
> based on other compatible flags.
> 
> Based on earlier patch by Matthias Brugger <matthias.bgg@gmail.com>:
> 
> http://lists.infradead.org/pipermail/linux-arm-kernel/2013-January/144161.html
> 
> For more information about twl4030 configuration for the
> "power scripts" see:
> 
> http://www.omappedia.com/wiki/TWL4030_power_scripts
> 
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: Robert Nelson <robertcnelson@gmail.com>
> Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> 
> ---
> 
> Sorry this got accidentally left out, should be the first patch
> in the series.
> 
> diff --git a/Documentation/devicetree/bindings/mfd/twl4030-power.txt b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
> index 8e15ec3..b906116 100644
> --- a/Documentation/devicetree/bindings/mfd/twl4030-power.txt
> +++ b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
> @@ -5,7 +5,12 @@ to control the power resources, including power scripts. For now, the
>  binding only supports the complete shutdown of the system after poweroff.
>  
>  Required properties:
> -- compatible : must be "ti,twl4030-power"
> +- compatible : must be one of the following
> +	"ti,twl4030-power"
> +	"ti,twl4030-power-reset"
> +

I think it'll be sensible to wait for a DT Ack for this kind of
change.


> +#ifdef CONFIG_OF
> +
> +/* Generic warm reset configuration for omap3 */
> +
> +static struct twl4030_ins omap3_wrst_seq[] = {
> +	{ MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_OFF), 2 },
> +	{ MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_WRST), 15 },
> +	{ MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_WRST), 15 },
> +	{ MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_WRST), 0x60 },
> +	{ MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2 },
> +	{ MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_ACTIVE), 2 },
> +};

Nit: I'd prefer the number formatting to be unified here i.e. all in
the same base, all <0x10 with leading zero.
 
> +static struct twl4030_script omap3_wrst_script = {
> +	.script	= omap3_wrst_seq,
> +	.size	= ARRAY_SIZE(omap3_wrst_seq),
> +	.flags	= TWL4030_WRST_SCRIPT,
> +};
> +
> +static struct twl4030_script *omap3_reset_scripts[] = {
> +	&omap3_wrst_script,
> +};
> +
> +static struct twl4030_resconfig omap3_rconfig[] = {
> +	{ .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3, .type = -1,
> +	  .type2 = -1 },
> +	{ .resource = RES_VDD1, .devgroup = DEV_GRP_P1, .type = -1,
> +	  .type2 = -1 },
> +	{ .resource = RES_VDD2, .devgroup = DEV_GRP_P1, .type = -1,
> +	  .type2 = -1 },
> +	{ 0, 0},
> +};

Nit: May be just my OCD, but this looks a little messy. Perhaps a
simple MACRO might tidy things up, although that seems a little
over-kill for such a small sturct[]. At the very least least please
even up the brackets in the sentinel.

/me goes to organise his soup tins into alphabetical order.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 1a/4] mfd: twl4030-power: Add generic reset configuration
@ 2014-04-28 11:37     ` Lee Jones
  0 siblings, 0 replies; 28+ messages in thread
From: Lee Jones @ 2014-04-28 11:37 UTC (permalink / raw)
  To: linux-arm-kernel

> The twl4030 PMIC needs to be configured properly for things like
> warm reset and deeper idle states so the PMIC manages the regulators
> properly based on the hardware triggers from the SoC.
> 
> For example, when rebooting an OMAP3530 at 125 MHz, it hangs.
> With this patch, TWL4030 will be reset when a warm reset occures.
> This way the OMAP3530 does not hang on reboot.
> 
> Let's use this as the default when compatible = "ti,twl4030-power".
> Other more complicated configurations can be added to the driver
> based on other compatible flags.
> 
> Based on earlier patch by Matthias Brugger <matthias.bgg@gmail.com>:
> 
> http://lists.infradead.org/pipermail/linux-arm-kernel/2013-January/144161.html
> 
> For more information about twl4030 configuration for the
> "power scripts" see:
> 
> http://www.omappedia.com/wiki/TWL4030_power_scripts
> 
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: Robert Nelson <robertcnelson@gmail.com>
> Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> 
> ---
> 
> Sorry this got accidentally left out, should be the first patch
> in the series.
> 
> diff --git a/Documentation/devicetree/bindings/mfd/twl4030-power.txt b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
> index 8e15ec3..b906116 100644
> --- a/Documentation/devicetree/bindings/mfd/twl4030-power.txt
> +++ b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
> @@ -5,7 +5,12 @@ to control the power resources, including power scripts. For now, the
>  binding only supports the complete shutdown of the system after poweroff.
>  
>  Required properties:
> -- compatible : must be "ti,twl4030-power"
> +- compatible : must be one of the following
> +	"ti,twl4030-power"
> +	"ti,twl4030-power-reset"
> +

I think it'll be sensible to wait for a DT Ack for this kind of
change.


> +#ifdef CONFIG_OF
> +
> +/* Generic warm reset configuration for omap3 */
> +
> +static struct twl4030_ins omap3_wrst_seq[] = {
> +	{ MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_OFF), 2 },
> +	{ MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_WRST), 15 },
> +	{ MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_WRST), 15 },
> +	{ MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_WRST), 0x60 },
> +	{ MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2 },
> +	{ MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_ACTIVE), 2 },
> +};

Nit: I'd prefer the number formatting to be unified here i.e. all in
the same base, all <0x10 with leading zero.
 
> +static struct twl4030_script omap3_wrst_script = {
> +	.script	= omap3_wrst_seq,
> +	.size	= ARRAY_SIZE(omap3_wrst_seq),
> +	.flags	= TWL4030_WRST_SCRIPT,
> +};
> +
> +static struct twl4030_script *omap3_reset_scripts[] = {
> +	&omap3_wrst_script,
> +};
> +
> +static struct twl4030_resconfig omap3_rconfig[] = {
> +	{ .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3, .type = -1,
> +	  .type2 = -1 },
> +	{ .resource = RES_VDD1, .devgroup = DEV_GRP_P1, .type = -1,
> +	  .type2 = -1 },
> +	{ .resource = RES_VDD2, .devgroup = DEV_GRP_P1, .type = -1,
> +	  .type2 = -1 },
> +	{ 0, 0},
> +};

Nit: May be just my OCD, but this looks a little messy. Perhaps a
simple MACRO might tidy things up, although that seems a little
over-kill for such a small sturct[]. At the very least least please
even up the brackets in the sentinel.

/me goes to organise his soup tins into alphabetical order.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 1/4] mfd: twl4030-power: Add recommended idle configuration
  2014-04-24  0:40   ` Tony Lindgren
@ 2014-04-28 11:41     ` Lee Jones
  -1 siblings, 0 replies; 28+ messages in thread
From: Lee Jones @ 2014-04-28 11:41 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-arm-kernel, linux-omap, Peter De Schrijver, Samuel Ortiz

> These settings are based on the "Recommended Sleep Sequences for
> the Zoom Platform" pdf at:
> 
> http://omappedia.com/wiki/File:Recommended_Sleep_Sequences_Zoom.pdf
> 
> These settings assume most of the regulators are under control of
> Linux, and cuts off VDD1 and VDD2 during off-idle as Linux cannot
> do it.

Linux does it becuase Linux can't do it. Eh?

> For any board specific changes to these, let's patch them in as
> changes to the generic data in the follow-up patches. This keeps
> the board specific changes small.
> 
> Note that this does not consider the twl5030 errata 27. That
> can be added later on after it has been tested.
> 
> Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  .../devicetree/bindings/mfd/twl4030-power.txt      |   4 +
>  drivers/mfd/twl4030-power.c                        | 165 +++++++++++++++++++++

driver/mfd changes look good to me:
  Acked-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 1/4] mfd: twl4030-power: Add recommended idle configuration
@ 2014-04-28 11:41     ` Lee Jones
  0 siblings, 0 replies; 28+ messages in thread
From: Lee Jones @ 2014-04-28 11:41 UTC (permalink / raw)
  To: linux-arm-kernel

> These settings are based on the "Recommended Sleep Sequences for
> the Zoom Platform" pdf at:
> 
> http://omappedia.com/wiki/File:Recommended_Sleep_Sequences_Zoom.pdf
> 
> These settings assume most of the regulators are under control of
> Linux, and cuts off VDD1 and VDD2 during off-idle as Linux cannot
> do it.

Linux does it becuase Linux can't do it. Eh?

> For any board specific changes to these, let's patch them in as
> changes to the generic data in the follow-up patches. This keeps
> the board specific changes small.
> 
> Note that this does not consider the twl5030 errata 27. That
> can be added later on after it has been tested.
> 
> Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  .../devicetree/bindings/mfd/twl4030-power.txt      |   4 +
>  drivers/mfd/twl4030-power.c                        | 165 +++++++++++++++++++++

driver/mfd changes look good to me:
  Acked-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 2/4] mfd: twl4030-power: Add support for board specific configuration
  2014-04-24  0:40   ` Tony Lindgren
@ 2014-04-28 11:47     ` Lee Jones
  -1 siblings, 0 replies; 28+ messages in thread
From: Lee Jones @ 2014-04-28 11:47 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-arm-kernel, linux-omap, Peter De Schrijver, Samuel Ortiz

> With the recommended twl4030 configuration added, we can now add
> board specific changes as modifications to the recommended
> configuration.
> 
> Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/mfd/twl4030-power.c | 21 +++++++++++++++++++++
>  include/linux/i2c/twl.h     |  1 +
>  2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
> index 89a8528..89c6b1a 100644
> --- a/drivers/mfd/twl4030-power.c
> +++ b/drivers/mfd/twl4030-power.c
> @@ -511,13 +511,34 @@ twl4030_power_configure_scripts(const struct twl4030_power_data *pdata)
>  	return 0;
>  }
>  
> +static void twl4030_patch_rconfig(struct twl4030_resconfig *common,
> +				  struct twl4030_resconfig *board)
> +{
> +	while (common->resource) {
> +		struct twl4030_resconfig *b = board;
> +
> +		while (b->resource) {
> +			if (b->resource == common->resource) {
> +				*common = *b;
> +				break;
> +			}
> +			b++;
> +		}
> +		common++;
> +	}
> +}

Forgive my ignorance, as I don't know how 'common' is setup, but we
appear to move to the next 'common' reference them immediately
dereference it without checking to see if it actually exists. Same
with 'b'. What happens if we reach the end of the array? NULL
dereference or does the final element always have a NULLed resource
attribute?

>  static int
>  twl4030_power_configure_resources(const struct twl4030_power_data *pdata)
>  {
>  	struct twl4030_resconfig *resconfig = pdata->resource_config;
> +	struct twl4030_resconfig *boardconf = pdata->board_config;
>  	int err;
>  
>  	if (resconfig) {
> +		if (boardconf)
> +			twl4030_patch_rconfig(resconfig, boardconf);
> +
>  		while (resconfig->resource) {
>  			err = twl4030_configure_resource(resconfig);
>  			if (err)
> diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
> index ade1c06..069f78f 100644
> --- a/include/linux/i2c/twl.h
> +++ b/include/linux/i2c/twl.h
> @@ -659,6 +659,7 @@ struct twl4030_power_data {
>  	struct twl4030_script **scripts;
>  	unsigned num;
>  	struct twl4030_resconfig *resource_config;
> +	struct twl4030_resconfig *board_config;
>  #define TWL4030_RESCONFIG_UNDEF	((u8)-1)
>  	bool use_poweroff;	/* Board is wired for TWL poweroff */
>  };

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 2/4] mfd: twl4030-power: Add support for board specific configuration
@ 2014-04-28 11:47     ` Lee Jones
  0 siblings, 0 replies; 28+ messages in thread
From: Lee Jones @ 2014-04-28 11:47 UTC (permalink / raw)
  To: linux-arm-kernel

> With the recommended twl4030 configuration added, we can now add
> board specific changes as modifications to the recommended
> configuration.
> 
> Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/mfd/twl4030-power.c | 21 +++++++++++++++++++++
>  include/linux/i2c/twl.h     |  1 +
>  2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
> index 89a8528..89c6b1a 100644
> --- a/drivers/mfd/twl4030-power.c
> +++ b/drivers/mfd/twl4030-power.c
> @@ -511,13 +511,34 @@ twl4030_power_configure_scripts(const struct twl4030_power_data *pdata)
>  	return 0;
>  }
>  
> +static void twl4030_patch_rconfig(struct twl4030_resconfig *common,
> +				  struct twl4030_resconfig *board)
> +{
> +	while (common->resource) {
> +		struct twl4030_resconfig *b = board;
> +
> +		while (b->resource) {
> +			if (b->resource == common->resource) {
> +				*common = *b;
> +				break;
> +			}
> +			b++;
> +		}
> +		common++;
> +	}
> +}

Forgive my ignorance, as I don't know how 'common' is setup, but we
appear to move to the next 'common' reference them immediately
dereference it without checking to see if it actually exists. Same
with 'b'. What happens if we reach the end of the array? NULL
dereference or does the final element always have a NULLed resource
attribute?

>  static int
>  twl4030_power_configure_resources(const struct twl4030_power_data *pdata)
>  {
>  	struct twl4030_resconfig *resconfig = pdata->resource_config;
> +	struct twl4030_resconfig *boardconf = pdata->board_config;
>  	int err;
>  
>  	if (resconfig) {
> +		if (boardconf)
> +			twl4030_patch_rconfig(resconfig, boardconf);
> +
>  		while (resconfig->resource) {
>  			err = twl4030_configure_resource(resconfig);
>  			if (err)
> diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
> index ade1c06..069f78f 100644
> --- a/include/linux/i2c/twl.h
> +++ b/include/linux/i2c/twl.h
> @@ -659,6 +659,7 @@ struct twl4030_power_data {
>  	struct twl4030_script **scripts;
>  	unsigned num;
>  	struct twl4030_resconfig *resource_config;
> +	struct twl4030_resconfig *board_config;
>  #define TWL4030_RESCONFIG_UNDEF	((u8)-1)
>  	bool use_poweroff;	/* Board is wired for TWL poweroff */
>  };

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 3/4] mfd: twl4030power: Add a configuration to turn off oscillator during off-idle
  2014-04-24  0:40   ` Tony Lindgren
@ 2014-04-28 11:48     ` Lee Jones
  -1 siblings, 0 replies; 28+ messages in thread
From: Lee Jones @ 2014-04-28 11:48 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-arm-kernel, linux-omap, Peter De Schrijver, Samuel Ortiz

> Some oscillators can be turned off during off-idle saving few
> a little bit power at the cost of the oscillator start up
> latency.
> 
> If you board can do this, you can now enable it by using the
> ti,twl4030-power-idle-osc-off compatible flag.
> 
> Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  .../devicetree/bindings/mfd/twl4030-power.txt         |  6 ++++++
>  drivers/mfd/twl4030-power.c                           | 19 +++++++++++++++++++

Code in drivers/mfd looks scruffy but fine:
  Acked-by: Lee Jones <lee.jones@linaro.org>


-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 3/4] mfd: twl4030power: Add a configuration to turn off oscillator during off-idle
@ 2014-04-28 11:48     ` Lee Jones
  0 siblings, 0 replies; 28+ messages in thread
From: Lee Jones @ 2014-04-28 11:48 UTC (permalink / raw)
  To: linux-arm-kernel

> Some oscillators can be turned off during off-idle saving few
> a little bit power at the cost of the oscillator start up
> latency.
> 
> If you board can do this, you can now enable it by using the
> ti,twl4030-power-idle-osc-off compatible flag.
> 
> Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  .../devicetree/bindings/mfd/twl4030-power.txt         |  6 ++++++
>  drivers/mfd/twl4030-power.c                           | 19 +++++++++++++++++++

Code in drivers/mfd looks scruffy but fine:
  Acked-by: Lee Jones <lee.jones@linaro.org>


-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 1/4] mfd: twl4030-power: Add recommended idle configuration
  2014-04-28 11:41     ` Lee Jones
@ 2014-04-28 15:33       ` Tony Lindgren
  -1 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-28 15:33 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-arm-kernel, linux-omap, Peter De Schrijver, Samuel Ortiz

* Lee Jones <lee.jones@linaro.org> [140428 04:42]:
> > These settings are based on the "Recommended Sleep Sequences for
> > the Zoom Platform" pdf at:
> > 
> > http://omappedia.com/wiki/File:Recommended_Sleep_Sequences_Zoom.pdf
> > 
> > These settings assume most of the regulators are under control of
> > Linux, and cuts off VDD1 and VDD2 during off-idle as Linux cannot
> > do it.
> 
> Linux does it becuase Linux can't do it. Eh?

Heh yeah that's confusing, will update to:

These settings assume most of the regulators are under control of
Linux, and twl4030 only cuts off VDD1 and VDD2 during off-idle as
Linux cannot do it.

Regards,

Tony

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

* [PATCH 1/4] mfd: twl4030-power: Add recommended idle configuration
@ 2014-04-28 15:33       ` Tony Lindgren
  0 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-28 15:33 UTC (permalink / raw)
  To: linux-arm-kernel

* Lee Jones <lee.jones@linaro.org> [140428 04:42]:
> > These settings are based on the "Recommended Sleep Sequences for
> > the Zoom Platform" pdf at:
> > 
> > http://omappedia.com/wiki/File:Recommended_Sleep_Sequences_Zoom.pdf
> > 
> > These settings assume most of the regulators are under control of
> > Linux, and cuts off VDD1 and VDD2 during off-idle as Linux cannot
> > do it.
> 
> Linux does it becuase Linux can't do it. Eh?

Heh yeah that's confusing, will update to:

These settings assume most of the regulators are under control of
Linux, and twl4030 only cuts off VDD1 and VDD2 during off-idle as
Linux cannot do it.

Regards,

Tony

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

* Re: [PATCH 2/4] mfd: twl4030-power: Add support for board specific configuration
  2014-04-28 11:47     ` Lee Jones
@ 2014-04-28 15:36       ` Tony Lindgren
  -1 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-28 15:36 UTC (permalink / raw)
  To: Lee Jones; +Cc: Peter De Schrijver, linux-omap, Samuel Ortiz, linux-arm-kernel

* Lee Jones <lee.jones@linaro.org> [140428 04:47]:
> > With the recommended twl4030 configuration added, we can now add
> > board specific changes as modifications to the recommended
> > configuration.
> > 
> > Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
> > Cc: Samuel Ortiz <sameo@linux.intel.com>
> > Cc: Lee Jones <lee.jones@linaro.org>
> > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > ---
> >  drivers/mfd/twl4030-power.c | 21 +++++++++++++++++++++
> >  include/linux/i2c/twl.h     |  1 +
> >  2 files changed, 22 insertions(+)
> > 
> > diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
> > index 89a8528..89c6b1a 100644
> > --- a/drivers/mfd/twl4030-power.c
> > +++ b/drivers/mfd/twl4030-power.c
> > @@ -511,13 +511,34 @@ twl4030_power_configure_scripts(const struct twl4030_power_data *pdata)
> >  	return 0;
> >  }
> >  
> > +static void twl4030_patch_rconfig(struct twl4030_resconfig *common,
> > +				  struct twl4030_resconfig *board)
> > +{
> > +	while (common->resource) {
> > +		struct twl4030_resconfig *b = board;
> > +
> > +		while (b->resource) {
> > +			if (b->resource == common->resource) {
> > +				*common = *b;
> > +				break;
> > +			}
> > +			b++;
> > +		}
> > +		common++;
> > +	}
> > +}
> 
> Forgive my ignorance, as I don't know how 'common' is setup, but we
> appear to move to the next 'common' reference them immediately
> dereference it without checking to see if it actually exists. Same
> with 'b'. What happens if we reach the end of the array? NULL
> dereference or does the final element always have a NULLed resource
> attribute?

Yes there's always a NULL entry at the end of the list always in
this case, and the configured lists are always static in the driver.

Regards,

Tony

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

* [PATCH 2/4] mfd: twl4030-power: Add support for board specific configuration
@ 2014-04-28 15:36       ` Tony Lindgren
  0 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-28 15:36 UTC (permalink / raw)
  To: linux-arm-kernel

* Lee Jones <lee.jones@linaro.org> [140428 04:47]:
> > With the recommended twl4030 configuration added, we can now add
> > board specific changes as modifications to the recommended
> > configuration.
> > 
> > Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
> > Cc: Samuel Ortiz <sameo@linux.intel.com>
> > Cc: Lee Jones <lee.jones@linaro.org>
> > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > ---
> >  drivers/mfd/twl4030-power.c | 21 +++++++++++++++++++++
> >  include/linux/i2c/twl.h     |  1 +
> >  2 files changed, 22 insertions(+)
> > 
> > diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
> > index 89a8528..89c6b1a 100644
> > --- a/drivers/mfd/twl4030-power.c
> > +++ b/drivers/mfd/twl4030-power.c
> > @@ -511,13 +511,34 @@ twl4030_power_configure_scripts(const struct twl4030_power_data *pdata)
> >  	return 0;
> >  }
> >  
> > +static void twl4030_patch_rconfig(struct twl4030_resconfig *common,
> > +				  struct twl4030_resconfig *board)
> > +{
> > +	while (common->resource) {
> > +		struct twl4030_resconfig *b = board;
> > +
> > +		while (b->resource) {
> > +			if (b->resource == common->resource) {
> > +				*common = *b;
> > +				break;
> > +			}
> > +			b++;
> > +		}
> > +		common++;
> > +	}
> > +}
> 
> Forgive my ignorance, as I don't know how 'common' is setup, but we
> appear to move to the next 'common' reference them immediately
> dereference it without checking to see if it actually exists. Same
> with 'b'. What happens if we reach the end of the array? NULL
> dereference or does the final element always have a NULLed resource
> attribute?

Yes there's always a NULL entry at the end of the list always in
this case, and the configured lists are always static in the driver.

Regards,

Tony

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

* Re: [PATCH 1/4] mfd: twl4030-power: Add recommended idle configuration
  2014-04-28 15:33       ` Tony Lindgren
@ 2014-04-28 15:42         ` Lee Jones
  -1 siblings, 0 replies; 28+ messages in thread
From: Lee Jones @ 2014-04-28 15:42 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-arm-kernel, linux-omap, Peter De Schrijver, Samuel Ortiz

On Mon, 28 Apr 2014, Tony Lindgren wrote:

> * Lee Jones <lee.jones@linaro.org> [140428 04:42]:
> > > These settings are based on the "Recommended Sleep Sequences for
> > > the Zoom Platform" pdf at:
> > > 
> > > http://omappedia.com/wiki/File:Recommended_Sleep_Sequences_Zoom.pdf
> > > 
> > > These settings assume most of the regulators are under control of
> > > Linux, and cuts off VDD1 and VDD2 during off-idle as Linux cannot
> > > do it.
> > 
> > Linux does it becuase Linux can't do it. Eh?
> 
> Heh yeah that's confusing, will update to:
> 
> These settings assume most of the regulators are under control of
> Linux, and twl4030 only cuts off VDD1 and VDD2 during off-idle as
> Linux cannot do it.

+1, thanks.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 1/4] mfd: twl4030-power: Add recommended idle configuration
@ 2014-04-28 15:42         ` Lee Jones
  0 siblings, 0 replies; 28+ messages in thread
From: Lee Jones @ 2014-04-28 15:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 28 Apr 2014, Tony Lindgren wrote:

> * Lee Jones <lee.jones@linaro.org> [140428 04:42]:
> > > These settings are based on the "Recommended Sleep Sequences for
> > > the Zoom Platform" pdf at:
> > > 
> > > http://omappedia.com/wiki/File:Recommended_Sleep_Sequences_Zoom.pdf
> > > 
> > > These settings assume most of the regulators are under control of
> > > Linux, and cuts off VDD1 and VDD2 during off-idle as Linux cannot
> > > do it.
> > 
> > Linux does it becuase Linux can't do it. Eh?
> 
> Heh yeah that's confusing, will update to:
> 
> These settings assume most of the regulators are under control of
> Linux, and twl4030 only cuts off VDD1 and VDD2 during off-idle as
> Linux cannot do it.

+1, thanks.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 1a/4] mfd: twl4030-power: Add generic reset configuration
  2014-04-28 11:37     ` Lee Jones
@ 2014-04-28 16:01       ` Tony Lindgren
  -1 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-28 16:01 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-arm-kernel, linux-omap, Matthias Brugger, Robert Nelson,
	Peter De Schrijver, Samuel Ortiz

* Lee Jones <lee.jones@linaro.org> [140428 04:37]:
> > The twl4030 PMIC needs to be configured properly for things like
> > warm reset and deeper idle states so the PMIC manages the regulators
> > properly based on the hardware triggers from the SoC.
> > 
> > For example, when rebooting an OMAP3530 at 125 MHz, it hangs.
> > With this patch, TWL4030 will be reset when a warm reset occures.
> > This way the OMAP3530 does not hang on reboot.
> > 
> > Let's use this as the default when compatible = "ti,twl4030-power".
> > Other more complicated configurations can be added to the driver
> > based on other compatible flags.
> > 
> > Based on earlier patch by Matthias Brugger <matthias.bgg@gmail.com>:
> > 
> > http://lists.infradead.org/pipermail/linux-arm-kernel/2013-January/144161.html
> > 
> > For more information about twl4030 configuration for the
> > "power scripts" see:
> > 
> > http://www.omappedia.com/wiki/TWL4030_power_scripts
> > 
> > Cc: Matthias Brugger <matthias.bgg@gmail.com>
> > Cc: Robert Nelson <robertcnelson@gmail.com>
> > Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
> > Cc: Samuel Ortiz <sameo@linux.intel.com>
> > Cc: Lee Jones <lee.jones@linaro.org>
> > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > 
> > ---
> > 
> > Sorry this got accidentally left out, should be the first patch
> > in the series.
> > 
> > diff --git a/Documentation/devicetree/bindings/mfd/twl4030-power.txt b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
> > index 8e15ec3..b906116 100644
> > --- a/Documentation/devicetree/bindings/mfd/twl4030-power.txt
> > +++ b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
> > @@ -5,7 +5,12 @@ to control the power resources, including power scripts. For now, the
> >  binding only supports the complete shutdown of the system after poweroff.
> >  
> >  Required properties:
> > -- compatible : must be "ti,twl4030-power"
> > +- compatible : must be one of the following
> > +	"ti,twl4030-power"
> > +	"ti,twl4030-power-reset"
> > +
> 
> I think it'll be sensible to wait for a DT Ack for this kind of
> change.

Sure. This could also be board specific, for example something like
ti,twl4030-power-n900, ti,twl4030-power-panda-es and so on. But
I think we can get away with just a few generic configurations.
 
> > +#ifdef CONFIG_OF
> > +
> > +/* Generic warm reset configuration for omap3 */
> > +
> > +static struct twl4030_ins omap3_wrst_seq[] = {
> > +	{ MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_OFF), 2 },
> > +	{ MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_WRST), 15 },
> > +	{ MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_WRST), 15 },
> > +	{ MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_WRST), 0x60 },
> > +	{ MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2 },
> > +	{ MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_ACTIVE), 2 },
> > +};
> 
> Nit: I'd prefer the number formatting to be unified here i.e. all in
> the same base, all <0x10 with leading zero.

Thanks will check those.
  
> > +static struct twl4030_script omap3_wrst_script = {
> > +	.script	= omap3_wrst_seq,
> > +	.size	= ARRAY_SIZE(omap3_wrst_seq),
> > +	.flags	= TWL4030_WRST_SCRIPT,
> > +};
> > +
> > +static struct twl4030_script *omap3_reset_scripts[] = {
> > +	&omap3_wrst_script,
> > +};
> > +
> > +static struct twl4030_resconfig omap3_rconfig[] = {
> > +	{ .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3, .type = -1,
> > +	  .type2 = -1 },
> > +	{ .resource = RES_VDD1, .devgroup = DEV_GRP_P1, .type = -1,
> > +	  .type2 = -1 },
> > +	{ .resource = RES_VDD2, .devgroup = DEV_GRP_P1, .type = -1,
> > +	  .type2 = -1 },
> > +	{ 0, 0},
> > +};
> 
> Nit: May be just my OCD, but this looks a little messy. Perhaps a
> simple MACRO might tidy things up, although that seems a little
> over-kill for such a small sturct[]. At the very least least please
> even up the brackets in the sentinel.

Yeah I was thinking about that too, but from configuring things
point of view it's essential to see what each entry is doing.
Having a macro with lots of parameters would make it a bit hard
to read the actual configuration. The macro would be something
like for the above:

RCONFIG(RES_HFCLKOUT, DEV_GRP_P3, -1, -1, 0, 0);
RCONFIG(RES_VDD1, DEV_GRP_P1, -1, -1, 0, 0);
RCONFIG(RES_VDD2, DEV_GRP_P1, -1, -1, 0, 0);

and something like this for other entries:

RCONFIG(RES_VAUX1, DEV_GRP_NULL, 0, 0, TWL_REMAP_OFF, TWL_REMAP_SLEEP); 

Personally I think it actually makes it harder to figure out what
is getting configured for the twl4030 as then it does not relate
to the documentation any longer, but I'm fine doing that if people
prefer macros here. Using macros could also be done later without
as it's all private to the driver.
 
> /me goes to organise his soup tins into alphabetical order.

I think using macros is a good comment, I always found the twl4030
configuration confusing. So if anybody has good macro ideas, I'm
open to it for sure. In this it's more like adding custom labels
to soup tins about their list of ingredients instead of sorting
the tins :) And it does not make the contents taste much better..

Regards,

Tony

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

* [PATCH 1a/4] mfd: twl4030-power: Add generic reset configuration
@ 2014-04-28 16:01       ` Tony Lindgren
  0 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2014-04-28 16:01 UTC (permalink / raw)
  To: linux-arm-kernel

* Lee Jones <lee.jones@linaro.org> [140428 04:37]:
> > The twl4030 PMIC needs to be configured properly for things like
> > warm reset and deeper idle states so the PMIC manages the regulators
> > properly based on the hardware triggers from the SoC.
> > 
> > For example, when rebooting an OMAP3530 at 125 MHz, it hangs.
> > With this patch, TWL4030 will be reset when a warm reset occures.
> > This way the OMAP3530 does not hang on reboot.
> > 
> > Let's use this as the default when compatible = "ti,twl4030-power".
> > Other more complicated configurations can be added to the driver
> > based on other compatible flags.
> > 
> > Based on earlier patch by Matthias Brugger <matthias.bgg@gmail.com>:
> > 
> > http://lists.infradead.org/pipermail/linux-arm-kernel/2013-January/144161.html
> > 
> > For more information about twl4030 configuration for the
> > "power scripts" see:
> > 
> > http://www.omappedia.com/wiki/TWL4030_power_scripts
> > 
> > Cc: Matthias Brugger <matthias.bgg@gmail.com>
> > Cc: Robert Nelson <robertcnelson@gmail.com>
> > Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
> > Cc: Samuel Ortiz <sameo@linux.intel.com>
> > Cc: Lee Jones <lee.jones@linaro.org>
> > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > 
> > ---
> > 
> > Sorry this got accidentally left out, should be the first patch
> > in the series.
> > 
> > diff --git a/Documentation/devicetree/bindings/mfd/twl4030-power.txt b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
> > index 8e15ec3..b906116 100644
> > --- a/Documentation/devicetree/bindings/mfd/twl4030-power.txt
> > +++ b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
> > @@ -5,7 +5,12 @@ to control the power resources, including power scripts. For now, the
> >  binding only supports the complete shutdown of the system after poweroff.
> >  
> >  Required properties:
> > -- compatible : must be "ti,twl4030-power"
> > +- compatible : must be one of the following
> > +	"ti,twl4030-power"
> > +	"ti,twl4030-power-reset"
> > +
> 
> I think it'll be sensible to wait for a DT Ack for this kind of
> change.

Sure. This could also be board specific, for example something like
ti,twl4030-power-n900, ti,twl4030-power-panda-es and so on. But
I think we can get away with just a few generic configurations.
 
> > +#ifdef CONFIG_OF
> > +
> > +/* Generic warm reset configuration for omap3 */
> > +
> > +static struct twl4030_ins omap3_wrst_seq[] = {
> > +	{ MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_OFF), 2 },
> > +	{ MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_WRST), 15 },
> > +	{ MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_WRST), 15 },
> > +	{ MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_WRST), 0x60 },
> > +	{ MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2 },
> > +	{ MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_ACTIVE), 2 },
> > +};
> 
> Nit: I'd prefer the number formatting to be unified here i.e. all in
> the same base, all <0x10 with leading zero.

Thanks will check those.
  
> > +static struct twl4030_script omap3_wrst_script = {
> > +	.script	= omap3_wrst_seq,
> > +	.size	= ARRAY_SIZE(omap3_wrst_seq),
> > +	.flags	= TWL4030_WRST_SCRIPT,
> > +};
> > +
> > +static struct twl4030_script *omap3_reset_scripts[] = {
> > +	&omap3_wrst_script,
> > +};
> > +
> > +static struct twl4030_resconfig omap3_rconfig[] = {
> > +	{ .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3, .type = -1,
> > +	  .type2 = -1 },
> > +	{ .resource = RES_VDD1, .devgroup = DEV_GRP_P1, .type = -1,
> > +	  .type2 = -1 },
> > +	{ .resource = RES_VDD2, .devgroup = DEV_GRP_P1, .type = -1,
> > +	  .type2 = -1 },
> > +	{ 0, 0},
> > +};
> 
> Nit: May be just my OCD, but this looks a little messy. Perhaps a
> simple MACRO might tidy things up, although that seems a little
> over-kill for such a small sturct[]. At the very least least please
> even up the brackets in the sentinel.

Yeah I was thinking about that too, but from configuring things
point of view it's essential to see what each entry is doing.
Having a macro with lots of parameters would make it a bit hard
to read the actual configuration. The macro would be something
like for the above:

RCONFIG(RES_HFCLKOUT, DEV_GRP_P3, -1, -1, 0, 0);
RCONFIG(RES_VDD1, DEV_GRP_P1, -1, -1, 0, 0);
RCONFIG(RES_VDD2, DEV_GRP_P1, -1, -1, 0, 0);

and something like this for other entries:

RCONFIG(RES_VAUX1, DEV_GRP_NULL, 0, 0, TWL_REMAP_OFF, TWL_REMAP_SLEEP); 

Personally I think it actually makes it harder to figure out what
is getting configured for the twl4030 as then it does not relate
to the documentation any longer, but I'm fine doing that if people
prefer macros here. Using macros could also be done later without
as it's all private to the driver.
 
> /me goes to organise his soup tins into alphabetical order.

I think using macros is a good comment, I always found the twl4030
configuration confusing. So if anybody has good macro ideas, I'm
open to it for sure. In this it's more like adding custom labels
to soup tins about their list of ingredients instead of sorting
the tins :) And it does not make the contents taste much better..

Regards,

Tony

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

end of thread, other threads:[~2014-04-28 16:01 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-24  0:40 [PATCH 0/4] mfd: twl4030-power: Enable off-idle configuration when booted with device tree Tony Lindgren
2014-04-24  0:40 ` Tony Lindgren
2014-04-24  0:40 ` [PATCH 1/4] mfd: twl4030-power: Add recommended idle configuration Tony Lindgren
2014-04-24  0:40   ` Tony Lindgren
2014-04-28 11:41   ` Lee Jones
2014-04-28 11:41     ` Lee Jones
2014-04-28 15:33     ` Tony Lindgren
2014-04-28 15:33       ` Tony Lindgren
2014-04-28 15:42       ` Lee Jones
2014-04-28 15:42         ` Lee Jones
2014-04-24  0:40 ` [PATCH 2/4] mfd: twl4030-power: Add support for board specific configuration Tony Lindgren
2014-04-24  0:40   ` Tony Lindgren
2014-04-28 11:47   ` Lee Jones
2014-04-28 11:47     ` Lee Jones
2014-04-28 15:36     ` Tony Lindgren
2014-04-28 15:36       ` Tony Lindgren
2014-04-24  0:40 ` [PATCH 3/4] mfd: twl4030power: Add a configuration to turn off oscillator during off-idle Tony Lindgren
2014-04-24  0:40   ` Tony Lindgren
2014-04-28 11:48   ` Lee Jones
2014-04-28 11:48     ` Lee Jones
2014-04-24  0:40 ` [PATCH 4/4] ARM: dts: Enable twl4030 off-idle configuration for selected omaps Tony Lindgren
2014-04-24  0:40   ` Tony Lindgren
2014-04-24  0:49 ` [PATCH 1a/4] mfd: twl4030-power: Add generic reset configuration Tony Lindgren
2014-04-24  0:49   ` Tony Lindgren
2014-04-28 11:37   ` Lee Jones
2014-04-28 11:37     ` Lee Jones
2014-04-28 16:01     ` Tony Lindgren
2014-04-28 16:01       ` Tony Lindgren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.