linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/10] STM32 usart power improvements
@ 2019-06-13 13:49 Erwan Le Ray
  2019-06-13 13:49 ` [PATCH v3 01/10] dt-bindings: serial: stm32: add wakeup option Erwan Le Ray
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Erwan Le Ray @ 2019-06-13 13:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Maxime Coquelin,
	Alexandre Torgue, Rob Herring, Mark Rutland
  Cc: devicetree, linux-kernel, Erwan Le Ray, linux-serial,
	Fabrice Gasnier, linux-stm32, linux-arm-kernel

This series delivers power improvements for stm32-usart driver.

Changes in v3:
Move pinctrl/consumer.h include from "add support for no_console_suspend"
patch to "select pinctrl state" patch in order to solve a compilation 
issue.

Bich Hemon (3):
  dt-bindings: serial: add optional pinctrl states
  ARM: dts: stm32: Update pin states for uart4 on stm32mp157c-ed1
  ARM: dts: stm32: Update UART4 pin states on stm32mp157a-dk1

Erwan Le Ray (7):
  dt-bindings: serial: stm32: add wakeup option
  serial: stm32: select pinctrl state in each suspend/resume function
  serial: stm32: add pm_runtime support
  serial: stm32: Use __maybe_unused instead of #if CONFIG_PM_SLEEP
  serial: stm32: add support for no_console_suspend
  ARM: dts: stm32: update uart4 pin configurations for low power
  ARM: dts: stm32: add wakeup capability on each usart/uart on
    stm32mp157c

 .../devicetree/bindings/serial/st,stm32-usart.txt  | 19 ++++-
 arch/arm/boot/dts/stm32mp157-pinctrl.dtsi          | 17 +++++
 arch/arm/boot/dts/stm32mp157a-dk1.dts              |  5 +-
 arch/arm/boot/dts/stm32mp157c-ed1.dts              |  5 +-
 arch/arm/boot/dts/stm32mp157c.dtsi                 | 40 ++++++++--
 drivers/tty/serial/stm32-usart.c                   | 88 ++++++++++++++++++++--
 drivers/tty/serial/stm32-usart.h                   |  1 +
 7 files changed, 155 insertions(+), 20 deletions(-)

-- 
1.9.1

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

* [PATCH v3 01/10] dt-bindings: serial: stm32: add wakeup option
  2019-06-13 13:49 [PATCH v3 00/10] STM32 usart power improvements Erwan Le Ray
@ 2019-06-13 13:49 ` Erwan Le Ray
  2019-07-09 14:35   ` Rob Herring
  2019-06-13 13:49 ` [PATCH v3 02/10] dt-bindings: serial: add optional pinctrl states Erwan Le Ray
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: Erwan Le Ray @ 2019-06-13 13:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Maxime Coquelin,
	Alexandre Torgue, Rob Herring, Mark Rutland
  Cc: devicetree, linux-kernel, Erwan Le Ray, linux-serial, Bich Hemon,
	Fabrice Gasnier, linux-stm32, linux-arm-kernel

Add a note for enabling wakeup capabilities of usart

Signed-off-by: Bich Hemon <bich.hemon@st.com>
Signed-off-by: Erwan Le Ray <erwan.leray@st.com>

diff --git a/Documentation/devicetree/bindings/serial/st,stm32-usart.txt b/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
index 9d3efed..5ec80c1 100644
--- a/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
+++ b/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
@@ -19,6 +19,11 @@ Optional properties:
   linux,rs485-enabled-at-boot-time: see rs485.txt.
 - dmas: phandle(s) to DMA controller node(s). Refer to stm32-dma.txt
 - dma-names: "rx" and/or "tx"
+- wakeup-source: bool flag to indicate this device has wakeup capabilities
+- interrupt-names, if optional wake-up interrupt is used, should be:
+  - "event": the name for the interrupt line of the USART instance
+  - "wakeup" the name for the optional wake-up interrupt
+
 
 Examples:
 usart4: serial@40004c00 {
-- 
1.9.1

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

* [PATCH v3 02/10] dt-bindings: serial: add optional pinctrl states
  2019-06-13 13:49 [PATCH v3 00/10] STM32 usart power improvements Erwan Le Ray
  2019-06-13 13:49 ` [PATCH v3 01/10] dt-bindings: serial: stm32: add wakeup option Erwan Le Ray
@ 2019-06-13 13:49 ` Erwan Le Ray
  2019-07-09 14:38   ` Rob Herring
  2019-06-13 13:49 ` [PATCH v3 03/10] serial: stm32: select pinctrl state in each suspend/resume function Erwan Le Ray
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: Erwan Le Ray @ 2019-06-13 13:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Maxime Coquelin,
	Alexandre Torgue, Rob Herring, Mark Rutland
  Cc: devicetree, linux-kernel, Erwan Le Ray, linux-serial, Bich Hemon,
	Fabrice Gasnier, linux-stm32, linux-arm-kernel

From: Bich Hemon <bich.hemon@st.com>

Add options for pinctrl states:
- "sleep" for low power
- "idle" for low power and wakeup capabilities enabled
- "no_console_suspend" for enabling console messages in low power

Signed-off-by: Bich Hemon <bich.hemon@st.com>
Signed-off-by: Erwan Le Ray <erwan.leray@st.com>

diff --git a/Documentation/devicetree/bindings/serial/st,stm32-usart.txt b/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
index 5ec80c1..64a5ea9 100644
--- a/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
+++ b/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
@@ -13,7 +13,14 @@ Required properties:
 - clocks: The input clock of the USART instance
 
 Optional properties:
-- pinctrl: The reference on the pins configuration
+- pinctrl-names: Set to "default". An additional "sleep" state can be defined
+  to set pins in sleep state when in low power. In case the device is used as
+  a wakeup source, "idle" state is defined in order to keep RX pin active.
+  For a console device, an optional state "no_console_suspend" can be defined
+  to enable console messages during suspend. Typically, "no_console_suspend" and
+  "default" states can refer to the same pin configuration.
+- pinctrl-n: Phandle(s) pointing to pin configuration nodes.
+  For Pinctrl properties see ../pinctrl/pinctrl-bindings.txt
 - st,hw-flow-ctrl: bool flag to enable hardware flow control.
 - rs485-rts-delay, rs485-rx-during-tx, rs485-rts-active-low,
   linux,rs485-enabled-at-boot-time: see rs485.txt.
@@ -31,8 +38,11 @@ usart4: serial@40004c00 {
 	reg = <0x40004c00 0x400>;
 	interrupts = <52>;
 	clocks = <&clk_pclk1>;
-	pinctrl-names = "default";
+	pinctrl-names = "default", "sleep", "idle", "no_console_suspend";
 	pinctrl-0 = <&pinctrl_usart4>;
+	pinctrl-1 = <&pinctrl_usart4_sleep>;
+	pinctrl-2 = <&pinctrl_usart4_idle>;
+	pinctrl-3 = <&pinctrl_usart4>;
 };
 
 usart2: serial@40004400 {
-- 
1.9.1

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

* [PATCH v3 03/10] serial: stm32: select pinctrl state in each suspend/resume function
  2019-06-13 13:49 [PATCH v3 00/10] STM32 usart power improvements Erwan Le Ray
  2019-06-13 13:49 ` [PATCH v3 01/10] dt-bindings: serial: stm32: add wakeup option Erwan Le Ray
  2019-06-13 13:49 ` [PATCH v3 02/10] dt-bindings: serial: add optional pinctrl states Erwan Le Ray
@ 2019-06-13 13:49 ` Erwan Le Ray
  2019-06-13 13:49 ` [PATCH v3 04/10] serial: stm32: add pm_runtime support Erwan Le Ray
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Erwan Le Ray @ 2019-06-13 13:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Maxime Coquelin,
	Alexandre Torgue, Rob Herring, Mark Rutland
  Cc: devicetree, linux-kernel, Erwan Le Ray, linux-serial, Bich Hemon,
	Fabrice Gasnier, linux-stm32, linux-arm-kernel

Select either pinctrl sleep state in suspend function or default state in
resume function.

Signed-off-by: Bich Hemon <bich.hemon@st.com>
Signed-off-by: Erwan Le Ray <erwan.leray@st.com>

diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index 9c2b04e..a8f20ba 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -24,6 +24,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/pm_wakeirq.h>
@@ -1298,6 +1299,8 @@ static int stm32_serial_suspend(struct device *dev)
 	else
 		stm32_serial_enable_wakeup(port, false);
 
+	pinctrl_pm_select_sleep_state(dev);
+
 	return 0;
 }
 
@@ -1305,6 +1308,8 @@ static int stm32_serial_resume(struct device *dev)
 {
 	struct uart_port *port = dev_get_drvdata(dev);
 
+	pinctrl_pm_select_default_state(dev);
+
 	if (device_may_wakeup(dev))
 		stm32_serial_enable_wakeup(port, false);
 
-- 
1.9.1

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

* [PATCH v3 04/10] serial: stm32: add pm_runtime support
  2019-06-13 13:49 [PATCH v3 00/10] STM32 usart power improvements Erwan Le Ray
                   ` (2 preceding siblings ...)
  2019-06-13 13:49 ` [PATCH v3 03/10] serial: stm32: select pinctrl state in each suspend/resume function Erwan Le Ray
@ 2019-06-13 13:49 ` Erwan Le Ray
  2019-06-13 13:49 ` [PATCH v3 05/10] serial: stm32: Use __maybe_unused instead of #if CONFIG_PM_SLEEP Erwan Le Ray
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Erwan Le Ray @ 2019-06-13 13:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Maxime Coquelin,
	Alexandre Torgue, Rob Herring, Mark Rutland
  Cc: devicetree, linux-kernel, Erwan Le Ray, linux-serial, Bich Hemon,
	Fabrice Gasnier, linux-stm32, linux-arm-kernel

Use pm_runtime for clock management.

Signed-off-by: Bich Hemon <bich.hemon@st.com>
Signed-off-by: Erwan Le Ray <erwan.leray@st.com>

diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index a8f20ba..41898c4 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -810,13 +810,13 @@ static void stm32_pm(struct uart_port *port, unsigned int state,
 
 	switch (state) {
 	case UART_PM_STATE_ON:
-		clk_prepare_enable(stm32port->clk);
+		pm_runtime_get_sync(port->dev);
 		break;
 	case UART_PM_STATE_OFF:
 		spin_lock_irqsave(&port->lock, flags);
 		stm32_clr_bits(port, ofs->cr1, BIT(cfg->uart_enable_bit));
 		spin_unlock_irqrestore(&port->lock, flags);
-		clk_disable_unprepare(stm32port->clk);
+		pm_runtime_put_sync(port->dev);
 		break;
 	}
 }
@@ -1111,6 +1111,11 @@ static int stm32_serial_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, &stm32port->port);
 
+	pm_runtime_get_noresume(&pdev->dev);
+	pm_runtime_set_active(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
+	pm_runtime_put_sync(&pdev->dev);
+
 	return 0;
 
 err_wirq:
@@ -1132,6 +1137,9 @@ static int stm32_serial_remove(struct platform_device *pdev)
 	struct uart_port *port = platform_get_drvdata(pdev);
 	struct stm32_port *stm32_port = to_stm32_port(port);
 	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	int err;
+
+	pm_runtime_get_sync(&pdev->dev);
 
 	stm32_clr_bits(port, ofs->cr3, USART_CR3_DMAR);
 
@@ -1160,7 +1168,12 @@ static int stm32_serial_remove(struct platform_device *pdev)
 
 	clk_disable_unprepare(stm32_port->clk);
 
-	return uart_remove_one_port(&stm32_usart_driver, port);
+	err = uart_remove_one_port(&stm32_usart_driver, port);
+
+	pm_runtime_disable(&pdev->dev);
+	pm_runtime_put_noidle(&pdev->dev);
+
+	return err;
 }
 
 
@@ -1317,7 +1330,29 @@ static int stm32_serial_resume(struct device *dev)
 }
 #endif /* CONFIG_PM_SLEEP */
 
+static int __maybe_unused stm32_serial_runtime_suspend(struct device *dev)
+{
+	struct uart_port *port = dev_get_drvdata(dev);
+	struct stm32_port *stm32port = container_of(port,
+			struct stm32_port, port);
+
+	clk_disable_unprepare(stm32port->clk);
+
+	return 0;
+}
+
+static int __maybe_unused stm32_serial_runtime_resume(struct device *dev)
+{
+	struct uart_port *port = dev_get_drvdata(dev);
+	struct stm32_port *stm32port = container_of(port,
+			struct stm32_port, port);
+
+	return clk_prepare_enable(stm32port->clk);
+}
+
 static const struct dev_pm_ops stm32_serial_pm_ops = {
+	SET_RUNTIME_PM_OPS(stm32_serial_runtime_suspend,
+			   stm32_serial_runtime_resume, NULL)
 	SET_SYSTEM_SLEEP_PM_OPS(stm32_serial_suspend, stm32_serial_resume)
 };
 
-- 
1.9.1

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

* [PATCH v3 05/10] serial: stm32: Use __maybe_unused instead of #if CONFIG_PM_SLEEP
  2019-06-13 13:49 [PATCH v3 00/10] STM32 usart power improvements Erwan Le Ray
                   ` (3 preceding siblings ...)
  2019-06-13 13:49 ` [PATCH v3 04/10] serial: stm32: add pm_runtime support Erwan Le Ray
@ 2019-06-13 13:49 ` Erwan Le Ray
  2019-06-13 13:49 ` [PATCH v3 06/10] serial: stm32: add support for no_console_suspend Erwan Le Ray
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Erwan Le Ray @ 2019-06-13 13:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Maxime Coquelin,
	Alexandre Torgue, Rob Herring, Mark Rutland
  Cc: devicetree, linux-kernel, Erwan Le Ray, linux-serial,
	Fabrice Gasnier, linux-stm32, linux-arm-kernel

Use __maybe_unused for power management related functionsinstead of

fixes: 270e5a74fe4c ("serial: stm32: add wakeup mechanism")
Signed-off-by: Erwan Le Ray <erwan.leray@st.com>

diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index 41898c4..b0fb420 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -1276,8 +1276,8 @@ static int stm32_console_setup(struct console *co, char *options)
 	.cons		= STM32_SERIAL_CONSOLE,
 };
 
-#ifdef CONFIG_PM_SLEEP
-static void stm32_serial_enable_wakeup(struct uart_port *port, bool enable)
+static void __maybe_unused stm32_serial_enable_wakeup(struct uart_port *port,
+						      bool enable)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
 	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
@@ -1301,7 +1301,7 @@ static void stm32_serial_enable_wakeup(struct uart_port *port, bool enable)
 	}
 }
 
-static int stm32_serial_suspend(struct device *dev)
+static int __maybe_unused stm32_serial_suspend(struct device *dev)
 {
 	struct uart_port *port = dev_get_drvdata(dev);
 
@@ -1317,7 +1317,7 @@ static int stm32_serial_suspend(struct device *dev)
 	return 0;
 }
 
-static int stm32_serial_resume(struct device *dev)
+static int __maybe_unused stm32_serial_resume(struct device *dev)
 {
 	struct uart_port *port = dev_get_drvdata(dev);
 
@@ -1328,7 +1328,6 @@ static int stm32_serial_resume(struct device *dev)
 
 	return uart_resume_port(&stm32_usart_driver, port);
 }
-#endif /* CONFIG_PM_SLEEP */
 
 static int __maybe_unused stm32_serial_runtime_suspend(struct device *dev)
 {
-- 
1.9.1

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

* [PATCH v3 06/10] serial: stm32: add support for no_console_suspend
  2019-06-13 13:49 [PATCH v3 00/10] STM32 usart power improvements Erwan Le Ray
                   ` (4 preceding siblings ...)
  2019-06-13 13:49 ` [PATCH v3 05/10] serial: stm32: Use __maybe_unused instead of #if CONFIG_PM_SLEEP Erwan Le Ray
@ 2019-06-13 13:49 ` Erwan Le Ray
  2019-06-13 13:49 ` [PATCH v3 07/10] ARM: dts: stm32: update uart4 pin configurations for low power Erwan Le Ray
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Erwan Le Ray @ 2019-06-13 13:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Maxime Coquelin,
	Alexandre Torgue, Rob Herring, Mark Rutland
  Cc: devicetree, linux-kernel, Erwan Le Ray, linux-serial, Bich Hemon,
	Fabrice Gasnier, linux-stm32, linux-arm-kernel

In order to display console messages in low power mode, console pins
must be kept active after suspend call.

Signed-off-by: Bich Hemon <bich.hemon@st.com>
Signed-off-by: Erwan Le Ray <erwan.leray@st.com>

Conflicts:
	drivers/tty/serial/stm32-usart.c

diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index b0fb420..00e4d7a 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -25,6 +25,7 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/pinctrl/devinfo.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/pm_wakeirq.h>
@@ -847,6 +848,7 @@ static int stm32_init_port(struct stm32_port *stm32port,
 {
 	struct uart_port *port = &stm32port->port;
 	struct resource *res;
+	struct pinctrl *uart_pinctrl;
 	int ret;
 
 	port->iotype	= UPIO_MEM;
@@ -880,6 +882,24 @@ static int stm32_init_port(struct stm32_port *stm32port,
 
 	stm32port->fifoen = stm32port->info->cfg.has_fifo;
 
+	uart_pinctrl = devm_pinctrl_get(&pdev->dev);
+	if (IS_ERR(uart_pinctrl)) {
+		ret = PTR_ERR(uart_pinctrl);
+		if (ret != -ENODEV) {
+			dev_err(&pdev->dev, "Can't get pinctrl, error %d\n",
+				ret);
+			return ret;
+		}
+		stm32port->console_pins = ERR_PTR(-ENODEV);
+	} else {
+		stm32port->console_pins = pinctrl_lookup_state
+			(uart_pinctrl, "no_console_suspend");
+	}
+
+	if (IS_ERR(stm32port->console_pins) && PTR_ERR(stm32port->console_pins)
+	    != -ENODEV)
+		return PTR_ERR(stm32port->console_pins);
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	port->membase = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(port->membase))
@@ -1304,6 +1324,7 @@ static void __maybe_unused stm32_serial_enable_wakeup(struct uart_port *port,
 static int __maybe_unused stm32_serial_suspend(struct device *dev)
 {
 	struct uart_port *port = dev_get_drvdata(dev);
+	struct stm32_port *stm32_port = to_stm32_port(port);
 
 	uart_suspend_port(&stm32_usart_driver, port);
 
@@ -1312,7 +1333,19 @@ static int __maybe_unused stm32_serial_suspend(struct device *dev)
 	else
 		stm32_serial_enable_wakeup(port, false);
 
-	pinctrl_pm_select_sleep_state(dev);
+	if (uart_console(port) && !console_suspend_enabled) {
+		if (IS_ERR(stm32_port->console_pins)) {
+			dev_err(dev, "no_console_suspend pinctrl not found\n");
+			return PTR_ERR(stm32_port->console_pins);
+		}
+
+		pinctrl_select_state(dev->pins->p, stm32_port->console_pins);
+	} else {
+		if (device_may_wakeup(dev))
+			pinctrl_pm_select_idle_state(dev);
+		else
+			pinctrl_pm_select_sleep_state(dev);
+	}
 
 	return 0;
 }
diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h
index 30d2433..050fe04 100644
--- a/drivers/tty/serial/stm32-usart.h
+++ b/drivers/tty/serial/stm32-usart.h
@@ -255,6 +255,7 @@ struct stm32_port {
 	bool fifoen;
 	int wakeirq;
 	int rdr_mask;		/* receive data register mask */
+	struct pinctrl_state *console_pins;
 };
 
 static struct stm32_port stm32_ports[STM32_MAX_PORTS];
-- 
1.9.1

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

* [PATCH v3 07/10] ARM: dts: stm32: update uart4 pin configurations for low power
  2019-06-13 13:49 [PATCH v3 00/10] STM32 usart power improvements Erwan Le Ray
                   ` (5 preceding siblings ...)
  2019-06-13 13:49 ` [PATCH v3 06/10] serial: stm32: add support for no_console_suspend Erwan Le Ray
@ 2019-06-13 13:49 ` Erwan Le Ray
  2019-06-13 13:49 ` [PATCH v3 08/10] ARM: dts: stm32: Update pin states for uart4 on stm32mp157c-ed1 Erwan Le Ray
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Erwan Le Ray @ 2019-06-13 13:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Maxime Coquelin,
	Alexandre Torgue, Rob Herring, Mark Rutland
  Cc: devicetree, linux-kernel, Erwan Le Ray, linux-serial, Bich Hemon,
	Fabrice Gasnier, linux-stm32, linux-arm-kernel

Currently, pinctrl states defines only one "sleep" configuration for pins,
no matter the possible uart low power modes (Rx pin always kept active).

Sleep pin configuration is refined for low power modes:
- "sleep" (no wakeup & console suspend enabled): put pins in analog state
  to optimize power
- "idle" (wakeup capability): keep Rx pin in alternate function
- "default" state remains untouched, to be used while the UART is active
  or in case the no_console_suspend mode is enabled

Signed-off-by: Bich Hemon <bich.hemon@st.com>
Signed-off-by: Erwan Le Ray <erwan.leray@st.com>

diff --git a/arch/arm/boot/dts/stm32mp157-pinctrl.dtsi b/arch/arm/boot/dts/stm32mp157-pinctrl.dtsi
index 85c417d..2e1ab1b 100644
--- a/arch/arm/boot/dts/stm32mp157-pinctrl.dtsi
+++ b/arch/arm/boot/dts/stm32mp157-pinctrl.dtsi
@@ -599,6 +599,23 @@
 					bias-disable;
 				};
 			};
+
+			uart4_idle_pins_a: uart4-idle-0 {
+				pins1 {
+					pinmux = <STM32_PINMUX('G', 11, ANALOG)>; /* UART4_TX */
+				};
+				pins2 {
+					pinmux = <STM32_PINMUX('B', 2, AF8)>; /* UART4_RX */
+					bias-disable;
+				};
+			};
+
+			uart4_sleep_pins_a: uart4-sleep-0 {
+				pins {
+					pinmux = <STM32_PINMUX('G', 11, ANALOG)>, /* UART4_TX */
+						 <STM32_PINMUX('B', 2, ANALOG)>; /* UART4_RX */
+				};
+			};
 		};
 
 		pinctrl_z: pin-controller-z@54004000 {
-- 
1.9.1

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

* [PATCH v3 08/10] ARM: dts: stm32: Update pin states for uart4 on stm32mp157c-ed1
  2019-06-13 13:49 [PATCH v3 00/10] STM32 usart power improvements Erwan Le Ray
                   ` (6 preceding siblings ...)
  2019-06-13 13:49 ` [PATCH v3 07/10] ARM: dts: stm32: update uart4 pin configurations for low power Erwan Le Ray
@ 2019-06-13 13:49 ` Erwan Le Ray
  2019-06-13 13:49 ` [PATCH v3 09/10] ARM: dts: stm32: Update UART4 pin states on stm32mp157a-dk1 Erwan Le Ray
  2019-06-13 13:50 ` [PATCH v3 10/10] ARM: dts: stm32: add wakeup capability on each usart/uart on stm32mp157c Erwan Le Ray
  9 siblings, 0 replies; 13+ messages in thread
From: Erwan Le Ray @ 2019-06-13 13:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Maxime Coquelin,
	Alexandre Torgue, Rob Herring, Mark Rutland
  Cc: devicetree, linux-kernel, Erwan Le Ray, linux-serial, Bich Hemon,
	Fabrice Gasnier, linux-stm32, linux-arm-kernel

From: Bich Hemon <bich.hemon@st.com>

Add idle and no_console_suspend states to uart4 pin configuration

Signed-off-by: Bich Hemon <bich.hemon@st.com>
Signed-off-by: Erwan Le Ray <erwan.leray@st.com>

diff --git a/arch/arm/boot/dts/stm32mp157c-ed1.dts b/arch/arm/boot/dts/stm32mp157c-ed1.dts
index 62a8c78..34cc847 100644
--- a/arch/arm/boot/dts/stm32mp157c-ed1.dts
+++ b/arch/arm/boot/dts/stm32mp157c-ed1.dts
@@ -251,8 +251,11 @@
 };
 
 &uart4 {
-	pinctrl-names = "default";
+	pinctrl-names = "default", "sleep", "idle", "no_console_suspend";
 	pinctrl-0 = <&uart4_pins_a>;
+	pinctrl-1 = <&uart4_sleep_pins_a>;
+	pinctrl-2 = <&uart4_idle_pins_a>;
+	pinctrl-3 = <&uart4_pins_a>;
 	status = "okay";
 };
 
-- 
1.9.1

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

* [PATCH v3 09/10] ARM: dts: stm32: Update UART4 pin states on stm32mp157a-dk1
  2019-06-13 13:49 [PATCH v3 00/10] STM32 usart power improvements Erwan Le Ray
                   ` (7 preceding siblings ...)
  2019-06-13 13:49 ` [PATCH v3 08/10] ARM: dts: stm32: Update pin states for uart4 on stm32mp157c-ed1 Erwan Le Ray
@ 2019-06-13 13:49 ` Erwan Le Ray
  2019-06-13 13:50 ` [PATCH v3 10/10] ARM: dts: stm32: add wakeup capability on each usart/uart on stm32mp157c Erwan Le Ray
  9 siblings, 0 replies; 13+ messages in thread
From: Erwan Le Ray @ 2019-06-13 13:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Maxime Coquelin,
	Alexandre Torgue, Rob Herring, Mark Rutland
  Cc: devicetree, linux-kernel, Erwan Le Ray, linux-serial, Bich Hemon,
	Fabrice Gasnier, linux-stm32, linux-arm-kernel

From: Bich Hemon <bich.hemon@st.com>

Add idle and no_console_suspend states to uart4 pin configuration.

Signed-off-by: Bich Hemon <bich.hemon@st.com>
Signed-off-by: Erwan Le Ray <erwan.leray@st.com>

diff --git a/arch/arm/boot/dts/stm32mp157a-dk1.dts b/arch/arm/boot/dts/stm32mp157a-dk1.dts
index 098dbfb..b851f80 100644
--- a/arch/arm/boot/dts/stm32mp157a-dk1.dts
+++ b/arch/arm/boot/dts/stm32mp157a-dk1.dts
@@ -244,7 +244,10 @@
 };
 
 &uart4 {
-	pinctrl-names = "default";
+	pinctrl-names = "default", "sleep", "idle", "no_console_suspend";
 	pinctrl-0 = <&uart4_pins_a>;
+	pinctrl-1 = <&uart4_sleep_pins_a>;
+	pinctrl-2 = <&uart4_idle_pins_a>;
+	pinctrl-3 = <&uart4_pins_a>;
 	status = "okay";
 };
-- 
1.9.1

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

* [PATCH v3 10/10] ARM: dts: stm32: add wakeup capability on each usart/uart on stm32mp157c
  2019-06-13 13:49 [PATCH v3 00/10] STM32 usart power improvements Erwan Le Ray
                   ` (8 preceding siblings ...)
  2019-06-13 13:49 ` [PATCH v3 09/10] ARM: dts: stm32: Update UART4 pin states on stm32mp157a-dk1 Erwan Le Ray
@ 2019-06-13 13:50 ` Erwan Le Ray
  9 siblings, 0 replies; 13+ messages in thread
From: Erwan Le Ray @ 2019-06-13 13:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Maxime Coquelin,
	Alexandre Torgue, Rob Herring, Mark Rutland
  Cc: devicetree, linux-kernel, Erwan Le Ray, linux-serial,
	Fabrice Gasnier, linux-stm32, linux-arm-kernel

- Mark all usart/uart devices as wakeup source.
- Identify all dedicated interrupts with a specific interrupt name (either
 "event" or "wakeup").
- add interrupts-extended wakeup interrupt

Signed-off-by: Erwan Le Ray <erwan.leray@st.com>

diff --git a/arch/arm/boot/dts/stm32mp157c.dtsi b/arch/arm/boot/dts/stm32mp157c.dtsi
index 2afeee6..de5b1bf 100644
--- a/arch/arm/boot/dts/stm32mp157c.dtsi
+++ b/arch/arm/boot/dts/stm32mp157c.dtsi
@@ -395,32 +395,44 @@
 		usart2: serial@4000e000 {
 			compatible = "st,stm32h7-uart";
 			reg = <0x4000e000 0x400>;
-			interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "event", "wakeup";
+			interrupts-extended = <&intc GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>,
+					      <&exti 27 1>;
 			clocks = <&rcc USART2_K>;
+			wakeup-source;
 			status = "disabled";
 		};
 
 		usart3: serial@4000f000 {
 			compatible = "st,stm32h7-uart";
 			reg = <0x4000f000 0x400>;
-			interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "event", "wakeup";
+			interrupts-extended = <&intc GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>,
+					      <&exti 28 1>;
 			clocks = <&rcc USART3_K>;
+			wakeup-source;
 			status = "disabled";
 		};
 
 		uart4: serial@40010000 {
 			compatible = "st,stm32h7-uart";
 			reg = <0x40010000 0x400>;
-			interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "event", "wakeup";
+			interrupts-extended = <&intc GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>,
+					      <&exti 30 1>;
 			clocks = <&rcc UART4_K>;
+			wakeup-source;
 			status = "disabled";
 		};
 
 		uart5: serial@40011000 {
 			compatible = "st,stm32h7-uart";
 			reg = <0x40011000 0x400>;
-			interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "event", "wakeup";
+			interrupts-extended = <&intc GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>,
+					      <&exti 31 1>;
 			clocks = <&rcc UART5_K>;
+			wakeup-source;
 			status = "disabled";
 		};
 
@@ -512,16 +524,22 @@
 		uart7: serial@40018000 {
 			compatible = "st,stm32h7-uart";
 			reg = <0x40018000 0x400>;
-			interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "event", "wakeup";
+			interrupts-extended = <&intc GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>,
+					      <&exti 32 1>;
 			clocks = <&rcc UART7_K>;
+			wakeup-source;
 			status = "disabled";
 		};
 
 		uart8: serial@40019000 {
 			compatible = "st,stm32h7-uart";
 			reg = <0x40019000 0x400>;
-			interrupts = <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "event", "wakeup";
+			interrupts-extended = <&intc GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>,
+					      <&exti 33 1>;
 			clocks = <&rcc UART8_K>;
+			wakeup-source;
 			status = "disabled";
 		};
 
@@ -588,8 +606,11 @@
 		usart6: serial@44003000 {
 			compatible = "st,stm32h7-uart";
 			reg = <0x44003000 0x400>;
-			interrupts = <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "event", "wakeup";
+			interrupts-extended = <&intc GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>,
+					      <&exti 29 1>;
 			clocks = <&rcc USART6_K>;
+			wakeup-source;
 			status = "disabled";
 		};
 
@@ -1201,8 +1222,11 @@
 		usart1: serial@5c000000 {
 			compatible = "st,stm32h7-uart";
 			reg = <0x5c000000 0x400>;
-			interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "event", "wakeup";
+			interrupts-extended = <&intc GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>,
+					      <&exti 26 1>;
 			clocks = <&rcc USART1_K>;
+			wakeup-source;
 			status = "disabled";
 		};
 
-- 
1.9.1

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

* Re: [PATCH v3 01/10] dt-bindings: serial: stm32: add wakeup option
  2019-06-13 13:49 ` [PATCH v3 01/10] dt-bindings: serial: stm32: add wakeup option Erwan Le Ray
@ 2019-07-09 14:35   ` Rob Herring
  0 siblings, 0 replies; 13+ messages in thread
From: Rob Herring @ 2019-07-09 14:35 UTC (permalink / raw)
  Cc: Greg Kroah-Hartman, Jiri Slaby, Maxime Coquelin,
	Alexandre Torgue, Mark Rutland, linux-serial, linux-stm32,
	linux-arm-kernel, linux-kernel, devicetree, Erwan Le Ray,
	Fabrice Gasnier, Bich Hemon

On Thu, 13 Jun 2019 15:49:51 +0200, Erwan Le Ray wrote:
> Add a note for enabling wakeup capabilities of usart
> 
> Signed-off-by: Bich Hemon <bich.hemon@st.com>
> Signed-off-by: Erwan Le Ray <erwan.leray@st.com>
> 

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v3 02/10] dt-bindings: serial: add optional pinctrl states
  2019-06-13 13:49 ` [PATCH v3 02/10] dt-bindings: serial: add optional pinctrl states Erwan Le Ray
@ 2019-07-09 14:38   ` Rob Herring
  0 siblings, 0 replies; 13+ messages in thread
From: Rob Herring @ 2019-07-09 14:38 UTC (permalink / raw)
  To: Erwan Le Ray
  Cc: Greg Kroah-Hartman, Jiri Slaby, Maxime Coquelin,
	Alexandre Torgue, Mark Rutland, linux-serial, linux-stm32,
	linux-arm-kernel, linux-kernel, devicetree, Fabrice Gasnier,
	Bich Hemon

On Thu, Jun 13, 2019 at 03:49:52PM +0200, Erwan Le Ray wrote:
> From: Bich Hemon <bich.hemon@st.com>
> 
> Add options for pinctrl states:
> - "sleep" for low power
> - "idle" for low power and wakeup capabilities enabled
> - "no_console_suspend" for enabling console messages in low power
> 
> Signed-off-by: Bich Hemon <bich.hemon@st.com>
> Signed-off-by: Erwan Le Ray <erwan.leray@st.com>
> 
> diff --git a/Documentation/devicetree/bindings/serial/st,stm32-usart.txt b/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
> index 5ec80c1..64a5ea9 100644
> --- a/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
> +++ b/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
> @@ -13,7 +13,14 @@ Required properties:
>  - clocks: The input clock of the USART instance
>  
>  Optional properties:
> -- pinctrl: The reference on the pins configuration
> +- pinctrl-names: Set to "default". An additional "sleep" state can be defined
> +  to set pins in sleep state when in low power. In case the device is used as
> +  a wakeup source, "idle" state is defined in order to keep RX pin active.
> +  For a console device, an optional state "no_console_suspend" can be defined
> +  to enable console messages during suspend. Typically, "no_console_suspend" and
> +  "default" states can refer to the same pin configuration.

no_console_suspend is a linux thing and doesn't belong in DT.

Rob

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

end of thread, other threads:[~2019-07-09 14:38 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-13 13:49 [PATCH v3 00/10] STM32 usart power improvements Erwan Le Ray
2019-06-13 13:49 ` [PATCH v3 01/10] dt-bindings: serial: stm32: add wakeup option Erwan Le Ray
2019-07-09 14:35   ` Rob Herring
2019-06-13 13:49 ` [PATCH v3 02/10] dt-bindings: serial: add optional pinctrl states Erwan Le Ray
2019-07-09 14:38   ` Rob Herring
2019-06-13 13:49 ` [PATCH v3 03/10] serial: stm32: select pinctrl state in each suspend/resume function Erwan Le Ray
2019-06-13 13:49 ` [PATCH v3 04/10] serial: stm32: add pm_runtime support Erwan Le Ray
2019-06-13 13:49 ` [PATCH v3 05/10] serial: stm32: Use __maybe_unused instead of #if CONFIG_PM_SLEEP Erwan Le Ray
2019-06-13 13:49 ` [PATCH v3 06/10] serial: stm32: add support for no_console_suspend Erwan Le Ray
2019-06-13 13:49 ` [PATCH v3 07/10] ARM: dts: stm32: update uart4 pin configurations for low power Erwan Le Ray
2019-06-13 13:49 ` [PATCH v3 08/10] ARM: dts: stm32: Update pin states for uart4 on stm32mp157c-ed1 Erwan Le Ray
2019-06-13 13:49 ` [PATCH v3 09/10] ARM: dts: stm32: Update UART4 pin states on stm32mp157a-dk1 Erwan Le Ray
2019-06-13 13:50 ` [PATCH v3 10/10] ARM: dts: stm32: add wakeup capability on each usart/uart on stm32mp157c Erwan Le Ray

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