Re: [PATCH 07/11] ARM: dts: Enable N900 keybaord sleep leds by default

2014-04-23 Thread Tony Lindgren
* Aaro Koskinen aaro.koski...@iki.fi [140411 16:39]:
 Hi,
 
 On Thu, Apr 10, 2014 at 04:47:15PM -0700, Tony Lindgren wrote:
  +leds {
  +compatible = gpio-leds;
  +heartbeat {
  +label = debug::sleep;
  +gpios = gpio6 2 GPIO_ACTIVE_HIGH;  /* gpio162 */
  +linux,default-trigger = default-on;
 
 Just some very minor nits, spaces should be converted to TABs here
 for indent, and patch title should say keyboard instead of keybaord.
 
 Acked-by: Aaro Koskinen aaro.koski...@iki.fi

Thanks and sorry for the delay, got sidetracked with some GPMC bugs.
Here's the updated version of this patch.

Tony

8 
From: Tony Lindgren t...@atomide.com
Date: Wed, 23 Apr 2014 13:59:24 -0700
Subject: [PATCH] ARM: dts: Enable N900 keyboard sleep leds by default

On N900 there are nice LEDs that show the state of the
sys_clkreq and sys_off_mode pins.

These LEDs go low when the system enters deeper idle
states. The left LED shows the state of the sys_clkreq
pin, and goes off during retention idle. The right LED
shows the state of sys_off_mode pin and both go off
during off idle.

As N900 is a battery operated device, these LEDs should
be off most of the time. So let's enable them by default
so we can make sure the system is mostly idle.

This allows the maintainers to also immediately test
patches for PM regressions by looking at the LEDs,
which certainly makes my life easier.

The LED can naturally be disabled during runtime with:

# echo none  /sys/class/leds/debug::sleep/trigger

Note that we don't currently have support for omap3
errata 1.158 that remuxes GPIO pins to INPUT_PULLUP |
MUX_MODE7 for the duration of idle. This means that the
GPIO pins set high will go down during off idle. In this
case it does not matter as the sys_off_mode goes down
too, but there's still a slim chance of false off idle
LED signals. If in doubt, false LED signals can be
verified by the sys_off_mode or vdd_core values.

Also note that to allow the UARTs to autoidle, the
following needs to be run on N900 to enable off idle:

#!/bin/sh
uarts=$(find /sys/class/tty/ttyO*/device/power/ -type d)
for uart in $uarts; do
echo 3000  $uart/autosuspend_delay_ms
done

uarts=$(find /sys/class/tty/ttyO*/power/ -type d)
for uart in $uarts; do
echo enabled  $uart/wakeup
echo auto  $uart/control
done

echo 1  /sys/kernel/debug/pm_debug/enable_off_mode

For retention idle, change the above to set 0 to
enable_off_mode.

Also note that without the twl4030 PM scripts the actual
voltage scaling won't happen for off idle so we only get
voltage scaling over I2C4 for retention idle. I'll do
some device tree patches for those also a bit later on.

Cc: Kevin Hilman khil...@linaro.org
Cc: Nishanth Menon n...@ti.com
Cc: Pali Rohár pali.ro...@gmail.com
Cc: Paul Walmsley p...@pwsan.com
Cc: Pavel Machek pa...@ucw.cz
Cc: Sebastian Reichel s...@kernel.org
Cc: Tero Kristo t-kri...@ti.com
Acked-by: Aaro Koskinen aaro.koski...@iki.fi
Signed-off-by: Tony Lindgren t...@atomide.com

--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -21,6 +21,17 @@
};
};
 
+   leds {
+   compatible = gpio-leds;
+   heartbeat {
+   label = debug::sleep;
+   gpios = gpio6 2 GPIO_ACTIVE_HIGH;  /* gpio162 */
+   linux,default-trigger = default-on;
+   pinctrl-names = default;
+   pinctrl-0 = debug_leds;
+   };
+   };
+
memory {
device_type = memory;
reg = 0x8000 0x1000; /* 256 MB */
@@ -114,6 +125,12 @@
;
};
 
+   debug_leds: pinmux_debug_led_pins {
+   pinctrl-single,pins = 
+   OMAP3_CORE1_IOPAD(0x2198, PIN_OUTPUT | MUX_MODE4)   
/* mcbsp1_clkx.gpio_162 */
+   ;
+   };
+
mmc1_pins: pinmux_mmc1_pins {
pinctrl-single,pins = 
0x114 (PIN_INPUT_PULLUP | MUX_MODE0)/* sdmmc1_clk */
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 07/11] ARM: dts: Enable N900 keybaord sleep leds by default

2014-04-11 Thread Aaro Koskinen
Hi,

On Thu, Apr 10, 2014 at 04:47:15PM -0700, Tony Lindgren wrote:
 +leds {
 +compatible = gpio-leds;
 +heartbeat {
 +label = debug::sleep;
 +gpios = gpio6 2 GPIO_ACTIVE_HIGH;  /* gpio162 */
 +linux,default-trigger = default-on;

Just some very minor nits, spaces should be converted to TABs here
for indent, and patch title should say keyboard instead of keybaord.

Acked-by: Aaro Koskinen aaro.koski...@iki.fi

 + pinctrl-names = default;
 + pinctrl-0 = debug_leds;
 +};
 +};

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


[PATCH 07/11] ARM: dts: Enable N900 keybaord sleep leds by default

2014-04-10 Thread Tony Lindgren
On N900 there are nice LEDs that show the state of the
sys_clkreq and sys_off_mode pins.

These LEDs go low when the system enters deeper idle
states. The left LED shows the state of the sys_clkreq
pin, and goes off during retention idle. The right LED
shows the state of sys_off_mode pin and both go off
during off idle.

As N900 is a battery operated device, these LEDs should
be off most of the time. So let's enable them by default
so we can make sure the system is mostly idle.

This allows the maintainers to also immediately test
patches for PM regressions by looking at the LEDs,
which certainly makes my life easier.

The LED can naturally be disabled during runtime with:

# echo none  /sys/class/leds/debug::sleep/trigger

Note that we don't currently have support for omap3
errata 1.158 that remuxes GPIO pins to INPUT_PULLUP |
MUX_MODE7 for the duration of idle. This means that the
GPIO pins set high will go down during off idle. In this
case it does not matter as the sys_off_mode goes down
too, but there's still a slim chance of false off idle
LED signals. If in doubt, false LED signals can be
verified by the sys_off_mode or vdd_core values.

Also note that to allow the UARTs to autoidle, the
following needs to be run on N900 to enable off idle:

#!/bin/sh
uarts=$(find /sys/class/tty/ttyO*/device/power/ -type d)
for uart in $uarts; do
echo 3000  $uart/autosuspend_delay_ms
done

uarts=$(find /sys/class/tty/ttyO*/power/ -type d)
for uart in $uarts; do
echo enabled  $uart/wakeup
echo auto  $uart/control
done

echo 1  /sys/kernel/debug/pm_debug/enable_off_mode

For retention idle, change the above to set 0 to
enable_off_mode.

Also note that without the twl4030 PM scripts the actual
voltage scaling won't happen for off idle so we only get
voltage scaling over I2C4 for retention idle. I'll do
some device tree patches for those also a bit later on.

Cc: Aaro Koskinen aaro.koski...@iki.fi
Cc: Kevin Hilman khil...@linaro.org
Cc: Nishanth Menon n...@ti.com
Cc: Pali Rohár pali.ro...@gmail.com
Cc: Paul Walmsley p...@pwsan.com
Cc: Pavel Machek pa...@ucw.cz
Cc: Sebastian Reichel s...@kernel.org
Cc: Tero Kristo t-kri...@ti.com
Signed-off-by: Tony Lindgren t...@atomide.com
---
 arch/arm/boot/dts/omap3-n900.dts | 17 +
 1 file changed, 17 insertions(+)

diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index 0bf40c9..0d34201 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -21,6 +21,17 @@
};
};
 
+leds {
+compatible = gpio-leds;
+heartbeat {
+label = debug::sleep;
+gpios = gpio6 2 GPIO_ACTIVE_HIGH;  /* gpio162 */
+linux,default-trigger = default-on;
+   pinctrl-names = default;
+   pinctrl-0 = debug_leds;
+};
+};
+
memory {
device_type = memory;
reg = 0x8000 0x1000; /* 256 MB */
@@ -114,6 +125,12 @@
;
};
 
+   debug_leds: pinmux_debug_led_pins {
+   pinctrl-single,pins = 
+   OMAP3_CORE1_IOPAD(0x2198, PIN_OUTPUT | MUX_MODE4)   
/* mcbsp1_clkx.gpio_162 */
+   ;
+   };
+
mmc1_pins: pinmux_mmc1_pins {
pinctrl-single,pins = 
0x114 (PIN_INPUT_PULLUP | MUX_MODE0)/* sdmmc1_clk */
-- 
1.8.1.1

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


Re: [PATCH 07/11] ARM: dts: Enable N900 keybaord sleep leds by default

2014-04-10 Thread Tony Lindgren
* Tony Lindgren t...@atomide.com [140410 16:52]:
 On N900 there are nice LEDs that show the state of the
 sys_clkreq and sys_off_mode pins.

Here's a work in progress related twl4030 script for N900
to play with, I think it can be made more generic though.
This scales vdd_core to zero during off idle for me with
this series.

Regards,

Tony

8 
diff --git a/Documentation/devicetree/bindings/mfd/twl4030-power.txt 
b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
index 8e15ec3..35b2b5f 100644
--- a/Documentation/devicetree/bindings/mfd/twl4030-power.txt
+++ b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
@@ -5,7 +5,9 @@ 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 : Needs to be one of the following
+   ti,twl4030-power-n900
+   ti,twl4030-power
 
 Optional properties:
 - ti,use_poweroff: With this flag, the chip will initiates an ACTIVE-to-OFF or
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index c5db0af..3ac2b2d 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-n900;
+   ti,use_poweroff;
+   };
 };
 
 twl_gpio {
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 96162b6..d6b05eb 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,227 @@ 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,
+};
+
+/* Configuration for Nokia N900 */
+
+static struct twl4030_ins n900_sleep_on_seq[] = {
+/*
+ * Turn off everything
+ */
+   {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_SLEEP), 2},
+};
+
+static struct twl4030_script n900_sleep_on_script = {
+   .script = n900_sleep_on_seq,
+   .size   = ARRAY_SIZE(n900_sleep_on_seq),
+   .flags  = TWL4030_SLEEP_SCRIPT,
+};
+
+static struct twl4030_ins n900_wakeup_seq[] = {
+/*
+ * Reenable everything
+ */
+   {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
+};
+
+static struct twl4030_script n900_wakeup_script = {
+