All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] support 8250-mtk uart in-band wake up
@ 2019-05-27  8:31 Claire Chang
       [not found] ` <20190527083150.220194-1-tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Claire Chang @ 2019-05-27  8:31 UTC (permalink / raw)
  To: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r
  Cc: Claire Chang, drinkcat-F7+t8E8rja9g9hUCZPvPmw,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	changqi.hu-NuS5LvNUpcJWk0Htik3J/w

changes in v3:
	1. remove an extra line in patch 2/2

changes in v2:
	1. add commit message
	2. drop return err in the resume path
	3. ignore disable_irq_wake()'s return value

Claire Chang (2):
  dt-bindings: serial: add documentation for Rx in-band wakeup support
  uart: mediatek: support Rx in-band wakeup

 .../devicetree/bindings/serial/mtk-uart.txt   | 13 ++++++++--
 drivers/tty/serial/8250/8250_mtk.c            | 24 +++++++++++++++++++
 2 files changed, 35 insertions(+), 2 deletions(-)

-- 
2.22.0.rc1.257.g3120a18244-goog

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

* [PATCH v3 1/2] dt-bindings: serial: add documentation for Rx in-band wakeup support
       [not found] ` <20190527083150.220194-1-tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2019-05-27  8:31   ` Claire Chang
       [not found]     ` <20190527083150.220194-2-tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  2019-05-27  8:31   ` [PATCH v3 2/2] uart: mediatek: support Rx in-band wakeup Claire Chang
  1 sibling, 1 reply; 7+ messages in thread
From: Claire Chang @ 2019-05-27  8:31 UTC (permalink / raw)
  To: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r
  Cc: Claire Chang, drinkcat-F7+t8E8rja9g9hUCZPvPmw,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	changqi.hu-NuS5LvNUpcJWk0Htik3J/w

To support Rx in-band wakeup, one must create an interrupt specifier with
edge sensitivity on Rx pin and an addtional pinctrl to reconfigure Rx pin
to normal GPIO in sleep state. Driver will switch to sleep mode pinctrl and
enable irq wake before suspend and restore to default settings when
resuming.

Signed-off-by: Claire Chang <tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 .../devicetree/bindings/serial/mtk-uart.txt         | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/serial/mtk-uart.txt b/Documentation/devicetree/bindings/serial/mtk-uart.txt
index c6b5262eb352..11966de2a4b3 100644
--- a/Documentation/devicetree/bindings/serial/mtk-uart.txt
+++ b/Documentation/devicetree/bindings/serial/mtk-uart.txt
@@ -23,7 +23,12 @@ Required properties:
 
 - reg: The base address of the UART register bank.
 
-- interrupts: A single interrupt specifier.
+- interrupts or interrupts-extended:
+  index 0: an interrupt specifier for the UART controller itself
+  index 1: optional, an interrupt specifier with edge sensitivity on Rx pin to
+           support Rx in-band wake up. If one would like to use this feature,
+           one must create an addtional pinctrl to reconfigure Rx pin to normal
+           GPIO before suspend.
 
 - clocks : Must contain an entry for each entry in clock-names.
   See ../clocks/clock-bindings.txt for details.
@@ -39,7 +44,11 @@ Example:
 	uart0: serial@11006000 {
 		compatible = "mediatek,mt6589-uart", "mediatek,mt6577-uart";
 		reg = <0x11006000 0x400>;
-		interrupts = <GIC_SPI 51 IRQ_TYPE_LEVEL_LOW>;
+		interrupts-extended = <&sysirq GIC_SPI 51 IRQ_TYPE_LEVEL_LOW>,
+				      <&gpio 121 IRQ_TYPE_EDGE_FALLING>;
 		clocks = <&uart_clk>, <&bus_clk>;
 		clock-names = "baud", "bus";
+		pinctrl-names = "default", "sleep";
+		pinctrl-0 = <&uart_pin>;
+		pinctrl-1 = <&uart_pin_sleep>;
 	};
-- 
2.22.0.rc1.257.g3120a18244-goog

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

* [PATCH v3 2/2] uart: mediatek: support Rx in-band wakeup
       [not found] ` <20190527083150.220194-1-tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  2019-05-27  8:31   ` [PATCH v3 1/2] dt-bindings: serial: add documentation for Rx in-band wakeup support Claire Chang
@ 2019-05-27  8:31   ` Claire Chang
       [not found]     ` <20190527083150.220194-3-tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  1 sibling, 1 reply; 7+ messages in thread
From: Claire Chang @ 2019-05-27  8:31 UTC (permalink / raw)
  To: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r
  Cc: Claire Chang, drinkcat-F7+t8E8rja9g9hUCZPvPmw,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	changqi.hu-NuS5LvNUpcJWk0Htik3J/w

In order to support Rx in-band wakeup, we need to enable irq wake on an
edge sensitive interrupt of Rx pin before suspend and disable it when
resuming.

This interrupt is used only as wake source to resume the system when
suspended. Note that the sent character will be lost as the controller is
actually suspended.

We use this to support wakeup on bluetooth. Bluetooth will repeatedly send
0xFD to wakeup host. Once host detects Rx falling, an interrupt is
triggered, and the system leaves sleep state. Then, the bluetooth driver
will send 0xFC to bluetooth and bluetooth can start to send normal HCI
packets.

Signed-off-by: Claire Chang <tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 drivers/tty/serial/8250/8250_mtk.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
index 417c7c810df9..5b94b853387d 100644
--- a/drivers/tty/serial/8250/8250_mtk.c
+++ b/drivers/tty/serial/8250/8250_mtk.c
@@ -10,6 +10,7 @@
 #include <linux/module.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/serial_8250.h>
@@ -70,6 +71,7 @@ struct mtk8250_data {
 #ifdef CONFIG_SERIAL_8250_DMA
 	enum dma_rx_status	rx_status;
 #endif
+	int			rx_wakeup_irq;
 };
 
 /* flow control mode */
@@ -551,6 +553,8 @@ static int mtk8250_probe(struct platform_device *pdev)
 	pm_runtime_set_active(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
 
+	data->rx_wakeup_irq = platform_get_irq(pdev, 1);
+
 	return 0;
 }
 
@@ -572,15 +576,35 @@ static int mtk8250_remove(struct platform_device *pdev)
 static int __maybe_unused mtk8250_suspend(struct device *dev)
 {
 	struct mtk8250_data *data = dev_get_drvdata(dev);
+	int irq = data->rx_wakeup_irq;
+	int err;
 
 	serial8250_suspend_port(data->line);
 
+	pinctrl_pm_select_sleep_state(dev);
+	if (irq >= 0) {
+		err = enable_irq_wake(irq);
+		if (err) {
+			dev_err(dev,
+				"failed to enable irq wake on IRQ %d: %d\n",
+				irq, err);
+			pinctrl_pm_select_default_state(dev);
+			serial8250_resume_port(data->line);
+			return err;
+		}
+	}
+
 	return 0;
 }
 
 static int __maybe_unused mtk8250_resume(struct device *dev)
 {
 	struct mtk8250_data *data = dev_get_drvdata(dev);
+	int irq = data->rx_wakeup_irq;
+
+	if (irq >= 0)
+		disable_irq_wake(irq);
+	pinctrl_pm_select_default_state(dev);
 
 	serial8250_resume_port(data->line);
 
-- 
2.22.0.rc1.257.g3120a18244-goog

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

* Re: [PATCH v3 2/2] uart: mediatek: support Rx in-band wakeup
       [not found]     ` <20190527083150.220194-3-tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2019-06-03  3:31       ` Nicolas Boichat
  0 siblings, 0 replies; 7+ messages in thread
From: Nicolas Boichat @ 2019-06-03  3:31 UTC (permalink / raw)
  To: Claire Chang
  Cc: Greg Kroah-Hartman, moderated list:ARM/Mediatek SoC support,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	changqi.hu-NuS5LvNUpcJWk0Htik3J/w

On Mon, May 27, 2019 at 4:32 PM Claire Chang <tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> wrote:
>
> In order to support Rx in-band wakeup, we need to enable irq wake on an
> edge sensitive interrupt of Rx pin before suspend and disable it when
> resuming.
>
> This interrupt is used only as wake source to resume the system when
> suspended. Note that the sent character will be lost as the controller is
> actually suspended.
>
> We use this to support wakeup on bluetooth. Bluetooth will repeatedly send
> 0xFD to wakeup host. Once host detects Rx falling, an interrupt is
> triggered, and the system leaves sleep state. Then, the bluetooth driver
> will send 0xFC to bluetooth and bluetooth can start to send normal HCI
> packets.
>
> Signed-off-by: Claire Chang <tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>

Reviewed-by: Nicolas Boichat <drinkcat-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>

> ---
>  drivers/tty/serial/8250/8250_mtk.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
> index 417c7c810df9..5b94b853387d 100644
> --- a/drivers/tty/serial/8250/8250_mtk.c
> +++ b/drivers/tty/serial/8250/8250_mtk.c
> @@ -10,6 +10,7 @@
>  #include <linux/module.h>
>  #include <linux/of_irq.h>
>  #include <linux/of_platform.h>
> +#include <linux/pinctrl/consumer.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/serial_8250.h>
> @@ -70,6 +71,7 @@ struct mtk8250_data {
>  #ifdef CONFIG_SERIAL_8250_DMA
>         enum dma_rx_status      rx_status;
>  #endif
> +       int                     rx_wakeup_irq;
>  };
>
>  /* flow control mode */
> @@ -551,6 +553,8 @@ static int mtk8250_probe(struct platform_device *pdev)
>         pm_runtime_set_active(&pdev->dev);
>         pm_runtime_enable(&pdev->dev);
>
> +       data->rx_wakeup_irq = platform_get_irq(pdev, 1);
> +
>         return 0;
>  }
>
> @@ -572,15 +576,35 @@ static int mtk8250_remove(struct platform_device *pdev)
>  static int __maybe_unused mtk8250_suspend(struct device *dev)
>  {
>         struct mtk8250_data *data = dev_get_drvdata(dev);
> +       int irq = data->rx_wakeup_irq;
> +       int err;
>
>         serial8250_suspend_port(data->line);
>
> +       pinctrl_pm_select_sleep_state(dev);
> +       if (irq >= 0) {
> +               err = enable_irq_wake(irq);
> +               if (err) {
> +                       dev_err(dev,
> +                               "failed to enable irq wake on IRQ %d: %d\n",
> +                               irq, err);
> +                       pinctrl_pm_select_default_state(dev);
> +                       serial8250_resume_port(data->line);
> +                       return err;
> +               }
> +       }
> +
>         return 0;
>  }
>
>  static int __maybe_unused mtk8250_resume(struct device *dev)
>  {
>         struct mtk8250_data *data = dev_get_drvdata(dev);
> +       int irq = data->rx_wakeup_irq;
> +
> +       if (irq >= 0)
> +               disable_irq_wake(irq);
> +       pinctrl_pm_select_default_state(dev);
>
>         serial8250_resume_port(data->line);
>
> --
> 2.22.0.rc1.257.g3120a18244-goog
>

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

* Re: [PATCH v3 1/2] dt-bindings: serial: add documentation for Rx in-band wakeup support
       [not found]     ` <20190527083150.220194-2-tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2019-06-11  9:53       ` Claire Chang
       [not found]         ` <CALiNf2_Kuu9agO31Wg2X4uUa0EHWYL=qG5RLQ=catn8M9XDKGQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Claire Chang @ 2019-06-11  9:53 UTC (permalink / raw)
  To: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r
  Cc: Mark Rutland, devicetree-u79uwXL29TY76Z2rM5mHXA, Nicolas Boichat,
	changqi.hu-NuS5LvNUpcJWk0Htik3J/w, Rob Herring,
	moderated list:ARM/Mediatek SoC support,
	linux-serial-u79uwXL29TY76Z2rM5mHXA

(cc-ed device tree maintainers and mailing list)

The second patch in this series[1] is already in tty-next[2].

Sorry for not cc-ing device tree maintainers/mailing list at the beginning.
I can resend this patch if needed.

Thanks.

[1] https://patchwork.kernel.org/patch/10962299/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/log/?h=tty-testing

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

* Re: [PATCH v3 1/2] dt-bindings: serial: add documentation for Rx in-band wakeup support
       [not found]         ` <CALiNf2_Kuu9agO31Wg2X4uUa0EHWYL=qG5RLQ=catn8M9XDKGQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2019-06-11  9:57           ` Greg KH
       [not found]             ` <20190611095752.GA24058-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2019-06-11  9:57 UTC (permalink / raw)
  To: Claire Chang
  Cc: Mark Rutland, devicetree-u79uwXL29TY76Z2rM5mHXA, Nicolas Boichat,
	changqi.hu-NuS5LvNUpcJWk0Htik3J/w, Rob Herring,
	moderated list:ARM/Mediatek SoC support,
	linux-serial-u79uwXL29TY76Z2rM5mHXA

On Tue, Jun 11, 2019 at 05:53:54PM +0800, Claire Chang wrote:
> (cc-ed device tree maintainers and mailing list)
> 
> The second patch in this series[1] is already in tty-next[2].
> 
> Sorry for not cc-ing device tree maintainers/mailing list at the beginning.
> I can resend this patch if needed.

Please do, as it is not here for them to review :(

greg k-h

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

* Re: [PATCH v3 1/2] dt-bindings: serial: add documentation for Rx in-band wakeup support
       [not found]             ` <20190611095752.GA24058-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
@ 2019-06-11 12:17               ` Claire Chang
  0 siblings, 0 replies; 7+ messages in thread
From: Claire Chang @ 2019-06-11 12:17 UTC (permalink / raw)
  To: Greg KH
  Cc: Mark Rutland, devicetree-u79uwXL29TY76Z2rM5mHXA, Nicolas Boichat,
	changqi.hu-NuS5LvNUpcJWk0Htik3J/w, Rob Herring,
	moderated list:ARM/Mediatek SoC support,
	linux-serial-u79uwXL29TY76Z2rM5mHXA

resent here: https://patchwork.ozlabs.org/patch/1113768/
sorry for the inconvenience

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

end of thread, other threads:[~2019-06-11 12:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-27  8:31 [PATCH v3 0/2] support 8250-mtk uart in-band wake up Claire Chang
     [not found] ` <20190527083150.220194-1-tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2019-05-27  8:31   ` [PATCH v3 1/2] dt-bindings: serial: add documentation for Rx in-band wakeup support Claire Chang
     [not found]     ` <20190527083150.220194-2-tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2019-06-11  9:53       ` Claire Chang
     [not found]         ` <CALiNf2_Kuu9agO31Wg2X4uUa0EHWYL=qG5RLQ=catn8M9XDKGQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-06-11  9:57           ` Greg KH
     [not found]             ` <20190611095752.GA24058-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2019-06-11 12:17               ` Claire Chang
2019-05-27  8:31   ` [PATCH v3 2/2] uart: mediatek: support Rx in-band wakeup Claire Chang
     [not found]     ` <20190527083150.220194-3-tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2019-06-03  3:31       ` Nicolas Boichat

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.