support 8250-mtk uart in-band wake up
Subsystems (3)
v3 cover support 8250-mtk uart in-band wake up
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(-)
Signature · 1 line
2.22.0.rc1.257.g3120a18244-goog
A message that is not in the archive (sent off-list or not yet received): 20190527083150.220194-1-tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org
PATCH v3 1/2 dt-bindings: serial: add documentation for Rx in-band wakeup support
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.
--- .../devicetree/bindings/serial/mtk-uart.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/serial/mtk-uart.txt +11 -2
@@ -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>; };
Signature · 1 line
2.22.0.rc1.257.g3120a18244-goog
A message that is not in the archive (sent off-list or not yet received): 20190527083150.220194-2-tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org
Re: [PATCH v3 1/2] dt-bindings: serial: add documentation for Rx in-band wakeup support
(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
A message that is not in the archive (sent off-list or not yet received): CALiNf2_Kuu9agO31Wg2X4uUa0EHWYL=qG5RLQ=catn8M9XDKGQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH v3 1/2] dt-bindings: serial: add documentation for Rx in-band wakeup support
Quoted 6 lines · Claire Chang
(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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v3 1/2] dt-bindings: serial: add documentation for Rx in-band wakeup support
resent here: https://patchwork.ozlabs.org/patch/1113768/
sorry for the inconvenience
PATCH v3 2/2 uart: mediatek: support Rx in-band wakeup
In reply to a message not in the archiveIn 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.
--- drivers/tty/serial/8250/8250_mtk.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/tty/serial/8250/8250_mtk.c +24 -0
@@ -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);
Signature · 1 line
2.22.0.rc1.257.g3120a18244-goog
A message that is not in the archive (sent off-list or not yet received): 20190527083150.220194-3-tientzu-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org
Nicolas Boichat
Reviewed-byRe: [PATCH v3 2/2] uart: mediatek: support Rx in-band wakeup
Quoted 9 lines · Claire Chang
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.
Quoted 7 lines
We use this to support wakeup on bluetooth. Bluetooth will repeatedly send
0xFDto wakeup host. Once host detects Rx falling, an interrupt is triggered, and the system leaves sleep state. Then, the bluetooth driver will send0xFCto bluetooth and bluetooth can start to send normal HCI packets.Signed-off-by Claire Chang <[email protected]>
Quoted 72 lines
--- drivers/tty/serial/8250/8250_mtk.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)drivers/tty/serial/8250/8250_mtk.c +24
-1@@ -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