Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1674752 > unrolled thread
| Started by | Bich HEMON <bich.hemon@st.com> |
|---|---|
| First post | 2017-06-26 15:00 +0200 |
| Last post | 2017-06-29 17:20 +0200 |
| Articles | 12 — 4 participants |
Back to article view | Back to linux.kernel
[PATCH 00/20] Update STM32 usart driver Bich HEMON <bich.hemon@st.com> - 2017-06-26 15:00 +0200
[PATCH 19/20] serial: stm32: add dma rx callback Bich HEMON <bich.hemon@st.com> - 2017-06-26 15:00 +0200
[PATCH 06/20] serial: stm32: fix pio transmit timeout Bich HEMON <bich.hemon@st.com> - 2017-06-26 15:00 +0200
[PATCH 14/20] dt-bindings: serial: document option wake-up interrupt for STM32 USART Bich HEMON <bich.hemon@st.com> - 2017-06-26 15:00 +0200
Re: [PATCH 14/20] dt-bindings: serial: document option wake-up interrupt for STM32 USART Rob Herring <robh@kernel.org> - 2017-06-28 20:20 +0200
Re: [PATCH 14/20] dt-bindings: serial: document option wake-up interrupt for STM32 USART Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-29 17:00 +0200
[PATCH 12/20] serial: stm32: fix last_res value Bich HEMON <bich.hemon@st.com> - 2017-06-26 15:00 +0200
[PATCH 13/20] serial: stm32: fix error handling in probe Bich HEMON <bich.hemon@st.com> - 2017-06-26 15:00 +0200
Re: [PATCH 13/20] serial: stm32: fix error handling in probe Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-29 17:00 +0200
[PATCH 04/20] serial: stm32: make fifoen as property for each port Bich HEMON <bich.hemon@st.com> - 2017-06-26 15:00 +0200
[PATCH 08/20] serial: stm32: timeout interrupt using with dma Bich HEMON <bich.hemon@st.com> - 2017-06-26 15:00 +0200
Re: [PATCH 00/20] Update STM32 usart driver Alexandre Torgue <alexandre.torgue@st.com> - 2017-06-29 17:20 +0200
| From | Bich HEMON <bich.hemon@st.com> |
|---|---|
| Date | 2017-06-26 15:00 +0200 |
| Subject | [PATCH 00/20] Update STM32 usart driver |
| Message-ID | <tWBMt-2tb-3@gated-at.bofh.it> |
From: Bich Hemon <bich.hemon@st.com> This patchset updates the stm32 usart driver. It mainly adds support for fifo, dma, debugfs anf fixes various bugs. Bich Hemon (20): serial: stm32: adding fifo support dt-bindings: serial: each stm32 usart needs an alias serial: stm32: fix multi ports management serial: stm32: make fifoen as property for each port serial: stm32: add debugfs serial: stm32: fix pio transmit timeout serial: stm32: less messages on dma alloc error serial: stm32: timeout interrupt using with dma serial: stm32: fix end of transfer serial: stm32: fix dma receive serial: stm32: add RTS support serial: stm32: fix last_res value serial: stm32: fix error handling in probe dt-bindings: serial: document option wake-up interrupt for STM32 USART serial: stm32: Add wakeup mechanism serial: stm32: fix fifo usage dt-bindings: serial: stm32: add dma using note serial: stm32: update dma buffers length serial: stm32: add dma rx callback serial: stm32: fix rx interrupt handling in startup .../devicetree/bindings/serial/st,stm32-usart.txt | 55 +++- drivers/tty/serial/stm32-usart.c | 310 ++++++++++++++++++--- drivers/tty/serial/stm32-usart.h | 51 +++- 3 files changed, 375 insertions(+), 41 deletions(-) -- 1.9.1
[toc] | [next] | [standalone]
| From | Bich HEMON <bich.hemon@st.com> |
|---|---|
| Date | 2017-06-26 15:00 +0200 |
| Subject | [PATCH 19/20] serial: stm32: add dma rx callback |
| Message-ID | <tWBMv-2tb-45@gated-at.bofh.it> |
| In reply to | #1674752 |
From: Bich Hemon <bich.hemon@st.com>
Initial usart driver behavior consists in looking for
chars received in dma rx buffer as soon as it gets the
interrupt telling that we received some data (RXNE or
RTO).
When stm32 dma is used combined with mdma, meaning that
the third dmamux property in the device tree is 0x1,
the received data are accumulated until the rx dma
transfer period (RX_BUF_L) is reached.
In that case, the usard driver will always get a maximum
residue for the rx dma transfer and its callback will
be called after each period completion to tell that
it can get a complete buffer: this is the purpose of
this patch.
Signed-off-by: Gerald Baeza <gerald.baeza@st.com>
---
drivers/tty/serial/stm32-usart.c | 39 +++++++++++++++++++++++++++++++++------
drivers/tty/serial/stm32-usart.h | 7 +++++++
2 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index d241056..06a92c8 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -124,14 +124,18 @@ static int stm32_pending_rx(struct uart_port *port, u32 *sr, int *last_res,
*sr = readl_relaxed(port->membase + ofs->isr);
if (threaded && stm32_port->rx_ch) {
+ if (stm32_port->rx_dma_cb == CALLBACK_CALLED)
+ return 1;
status = dmaengine_tx_status(stm32_port->rx_ch,
stm32_port->rx_ch->cookie,
&state);
if ((status == DMA_IN_PROGRESS) &&
- (*last_res != state.residue))
+ (*last_res != state.residue)) {
+ stm32_port->rx_dma_cb = CALLBACK_IGNORED;
return 1;
- else
+ } else {
return 0;
+ }
} else if (*sr & USART_SR_RXNE) {
return 1;
}
@@ -147,8 +151,11 @@ static int stm32_pending_rx(struct uart_port *port, u32 *sr, int *last_res,
if (stm32_port->rx_ch) {
c = stm32_port->rx_buf[RX_BUF_L - (*last_res)--];
- if ((*last_res) == 0)
+ if ((*last_res) == 0) {
*last_res = RX_BUF_L;
+ if (stm32_port->rx_dma_cb == CALLBACK_CALLED)
+ stm32_port->rx_dma_cb = CALLBACK_NOT_CALLED;
+ }
return c;
} else {
return readl_relaxed(port->membase + ofs->rdr);
@@ -238,6 +245,27 @@ static void stm32_tx_dma_complete(void *arg)
stm32_transmit_chars(port);
}
+static void stm32_rx_dma_complete(void *arg)
+{
+ struct uart_port *port = arg;
+ struct stm32_port *stm32port = to_stm32_port(port);
+ unsigned long flags;
+
+ spin_lock_irqsave(&port->lock, flags);
+
+ /*
+ * If the dma controller is sending the data on
+ * the fly then we have CALLBACK_IGNORED
+ */
+
+ if (stm32port->rx_dma_cb == CALLBACK_NOT_CALLED) {
+ stm32port->rx_dma_cb = CALLBACK_CALLED;
+ stm32_receive_chars(port, true);
+ }
+
+ spin_unlock_irqrestore(&port->lock, flags);
+}
+
static void stm32_transmit_chars_pio(struct uart_port *port)
{
struct stm32_port *stm32_port = to_stm32_port(port);
@@ -897,9 +925,8 @@ static int stm32_of_dma_rx_probe(struct stm32_port *stm32port,
goto config_err;
}
- /* No callback as dma buffer is drained on usart interrupt */
- desc->callback = NULL;
- desc->callback_param = NULL;
+ desc->callback = stm32_rx_dma_complete;
+ desc->callback_param = port;
/* Push current DMA transaction in the pending queue */
cookie = dmaengine_submit(desc);
diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h
index 5137e68..f8cad09 100644
--- a/drivers/tty/serial/stm32-usart.h
+++ b/drivers/tty/serial/stm32-usart.h
@@ -242,6 +242,12 @@ struct stm32_usart_info stm32h7_info = {
#define RX_BUF_P RX_BUF_L /* dma rx buffer period */
#define TX_BUF_L RX_BUF_L /* dma tx buffer length */
+enum dma_cb {
+ CALLBACK_NOT_CALLED,
+ CALLBACK_CALLED,
+ CALLBACK_IGNORED,
+};
+
struct stm32_port {
struct uart_port port;
struct clk *clk;
@@ -257,6 +263,7 @@ struct stm32_port {
unsigned char *tx_buf; /* dma tx buffer cpu address */
u32 rx_irq; /* USART_CR1_RXNEIE or RTOIE */
int last_res;
+ enum dma_cb rx_dma_cb; /* dma rx callback status */
bool tx_dma_busy; /* dma tx busy */
bool hw_flow_control;
bool fifoen;
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Bich HEMON <bich.hemon@st.com> |
|---|---|
| Date | 2017-06-26 15:00 +0200 |
| Subject | [PATCH 06/20] serial: stm32: fix pio transmit timeout |
| Message-ID | <tWBMv-2tb-51@gated-at.bofh.it> |
| In reply to | #1674752 |
From: Bich Hemon <bich.hemon@st.com> 100µs was too short for low speed transmission (9600bps) Signed-off-by: Gerald Baeza <gerald.baeza@st.com> --- drivers/tty/serial/stm32-usart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 3ce0f7a..79ac167 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -247,7 +247,7 @@ static void stm32_transmit_chars_pio(struct uart_port *port) ret = readl_relaxed_poll_timeout_atomic(port->membase + ofs->isr, isr, (isr & USART_SR_TXE), - 10, 100); + 10, 100000); if (ret) dev_err(port->dev, "tx empty not set\n"); -- 1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Bich HEMON <bich.hemon@st.com> |
|---|---|
| Date | 2017-06-26 15:00 +0200 |
| Subject | [PATCH 14/20] dt-bindings: serial: document option wake-up interrupt for STM32 USART |
| Message-ID | <tWBMv-2tb-53@gated-at.bofh.it> |
| In reply to | #1674752 |
From: Bich Hemon <bich.hemon@st.com>
Introduce new compatibles for "st,stm32h7-usart" and "st,stm32h7-uart".
This new compatible allow to use optional wake-up interrupt.
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
---
.../devicetree/bindings/serial/st,stm32-usart.txt | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/Documentation/devicetree/bindings/serial/st,stm32-usart.txt b/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
index a229b14..3b42138 100644
--- a/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
+++ b/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
@@ -2,11 +2,14 @@
Required properties:
- compatible: Can be either "st,stm32-usart", "st,stm32-uart",
-"st,stm32f7-usart" or "st,stm32f7-uart" depending on whether
-the device supports synchronous mode and is compatible with
-stm32(f4) or stm32f7.
+"st,stm32f7-usart", "st,stm32f7-uart", "st,stm32h7-usart" or
+st,stm32h7-uart depending on whether the device supports synchronous
+mode and is compatible with stm32(f4), stm32f7 or stm32h7.
- reg: The address and length of the peripheral registers space
-- interrupts: The interrupt line of the USART instance
+- interrupts or interrupts-extended: Must contain first, the interrupt
+ line specifier for the USART instance. An optional wake-up interrupt
+ specifier can be added. Then, -extended variant may be needed to specify
+ interrupts parent controllers.
- clocks: The input clock of the USART instance
Optional properties:
@@ -53,3 +56,12 @@ usart1: serial@40011000 {
<&dma2 7 4 0x414 0x0>;
dma-names = "rx", "tx";
};
+
+uart4: serial@40010000 {
+ compatible = "st,stm32h7-uart";
+ reg = <0x40010000 0x400>;
+ interrupts-extended = <&intc GIC_SPI 52 IRQ_TYPE_NONE>,
+ <&aiec 30 1>;
+ clocks = <&rcc UART4_K>;
+ status = "disabled";
+};
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Rob Herring <robh@kernel.org> |
|---|---|
| Date | 2017-06-28 20:20 +0200 |
| Subject | Re: [PATCH 14/20] dt-bindings: serial: document option wake-up interrupt for STM32 USART |
| Message-ID | <tXpJh-Rv-33@gated-at.bofh.it> |
| In reply to | #1674755 |
On Mon, Jun 26, 2017 at 12:49:15PM +0000, Bich HEMON wrote:
> From: Bich Hemon <bich.hemon@st.com>
>
> Introduce new compatibles for "st,stm32h7-usart" and "st,stm32h7-uart".
> This new compatible allow to use optional wake-up interrupt.
>
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
> ---
> .../devicetree/bindings/serial/st,stm32-usart.txt | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/serial/st,stm32-usart.txt b/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
> index a229b14..3b42138 100644
> --- a/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
> +++ b/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
> @@ -2,11 +2,14 @@
>
> Required properties:
> - compatible: Can be either "st,stm32-usart", "st,stm32-uart",
> -"st,stm32f7-usart" or "st,stm32f7-uart" depending on whether
> -the device supports synchronous mode and is compatible with
> -stm32(f4) or stm32f7.
> +"st,stm32f7-usart", "st,stm32f7-uart", "st,stm32h7-usart" or
> +st,stm32h7-uart depending on whether the device supports synchronous
> +mode and is compatible with stm32(f4), stm32f7 or stm32h7.
Please reformat as 1 valid set of compatibles per line.
> - reg: The address and length of the peripheral registers space
> -- interrupts: The interrupt line of the USART instance
> +- interrupts or interrupts-extended: Must contain first, the interrupt
> + line specifier for the USART instance. An optional wake-up interrupt
> + specifier can be added. Then, -extended variant may be needed to specify
> + interrupts parent controllers.
Just describe the interrupts property and what the interrupts are.
interrupts-extended is implied if it is necessary.
> - clocks: The input clock of the USART instance
>
> Optional properties:
> @@ -53,3 +56,12 @@ usart1: serial@40011000 {
> <&dma2 7 4 0x414 0x0>;
> dma-names = "rx", "tx";
> };
> +
> +uart4: serial@40010000 {
> + compatible = "st,stm32h7-uart";
> + reg = <0x40010000 0x400>;
> + interrupts-extended = <&intc GIC_SPI 52 IRQ_TYPE_NONE>,
> + <&aiec 30 1>;
> + clocks = <&rcc UART4_K>;
> + status = "disabled";
> +};
> --
> 1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2017-06-29 17:00 +0200 |
| Subject | Re: [PATCH 14/20] dt-bindings: serial: document option wake-up interrupt for STM32 USART |
| Message-ID | <tXJ5i-qk-45@gated-at.bofh.it> |
| In reply to | #1674755 |
On Mon, Jun 26, 2017 at 12:49:15PM +0000, Bich HEMON wrote: > From: Bich Hemon <bich.hemon@st.com> > > Introduce new compatibles for "st,stm32h7-usart" and "st,stm32h7-uart". > This new compatible allow to use optional wake-up interrupt. > > Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> No sign-off from you?
[toc] | [prev] | [next] | [standalone]
| From | Bich HEMON <bich.hemon@st.com> |
|---|---|
| Date | 2017-06-26 15:00 +0200 |
| Subject | [PATCH 12/20] serial: stm32: fix last_res value |
| Message-ID | <tWBMv-2tb-47@gated-at.bofh.it> |
| In reply to | #1674752 |
From: Bich Hemon <bich.hemon@st.com>
Set last_res value in each port
Signed-off-by: Bich Hemon <bich.hemon@st.com>
---
drivers/tty/serial/stm32-usart.c | 6 +++---
drivers/tty/serial/stm32-usart.h | 1 +
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index a7401b0..c54b89d 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -155,14 +155,13 @@ static void stm32_receive_chars(struct uart_port *port, bool threaded)
unsigned long c;
u32 sr;
char flag;
- static int last_res = RX_BUF_L;
if (port->irq_wake)
pm_wakeup_event(tport->tty->dev, 0);
- while (stm32_pending_rx(port, &sr, &last_res, threaded)) {
+ while (stm32_pending_rx(port, &sr, &stm32_port->last_res, threaded)) {
sr |= USART_SR_DUMMY_RX;
- c = stm32_get_char(port, &sr, &last_res);
+ c = stm32_get_char(port, &sr, &stm32_port->last_res);
flag = TTY_NORMAL;
port->icount.rx++;
@@ -808,6 +807,7 @@ static struct stm32_port *stm32_of_get_stm32_port(struct platform_device *pdev)
stm32_ports[id].port.line = id;
stm32_ports[id].fifoen = true;
stm32_ports[id].rx_irq = USART_CR1_RXNEIE;
+ stm32_ports[id].last_res = RX_BUF_L;
return &stm32_ports[id];
}
diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h
index f9fe15b..056a837 100644
--- a/drivers/tty/serial/stm32-usart.h
+++ b/drivers/tty/serial/stm32-usart.h
@@ -226,6 +226,7 @@ struct stm32_port {
dma_addr_t tx_dma_buf; /* dma tx buffer bus address */
unsigned char *tx_buf; /* dma tx buffer cpu address */
u32 rx_irq; /* USART_CR1_RXNEIE or RTOIE */
+ int last_res;
bool tx_dma_busy; /* dma tx busy */
bool hw_flow_control;
bool fifoen;
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Bich HEMON <bich.hemon@st.com> |
|---|---|
| Date | 2017-06-26 15:00 +0200 |
| Subject | [PATCH 13/20] serial: stm32: fix error handling in probe |
| Message-ID | <tWBMw-2tb-59@gated-at.bofh.it> |
| In reply to | #1674752 |
From: Bich Hemon <bich.hemon@st.com>
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
---
drivers/tty/serial/stm32-usart.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index c54b89d..a62fc95 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -779,8 +779,10 @@ static int stm32_init_port(struct stm32_port *stm32port,
return ret;
stm32port->port.uartclk = clk_get_rate(stm32port->clk);
- if (!stm32port->port.uartclk)
+ if (!stm32port->port.uartclk) {
+ clk_disable_unprepare(stm32port->clk);
ret = -EINVAL;
+ }
return ret;
}
@@ -964,7 +966,7 @@ static int stm32_serial_probe(struct platform_device *pdev)
ret = uart_add_one_port(&stm32_usart_driver, &stm32port->port);
if (ret)
- return ret;
+ goto err_uninit;
ret = stm32_of_dma_rx_probe(stm32port, pdev);
if (ret)
@@ -977,6 +979,11 @@ static int stm32_serial_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, &stm32port->port);
return 0;
+
+err_uninit:
+ clk_disable_unprepare(stm32port->clk);
+
+ return ret;
}
static int stm32_serial_remove(struct platform_device *pdev)
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2017-06-29 17:00 +0200 |
| Subject | Re: [PATCH 13/20] serial: stm32: fix error handling in probe |
| Message-ID | <tXJ5i-qk-47@gated-at.bofh.it> |
| In reply to | #1674759 |
On Mon, Jun 26, 2017 at 12:49:14PM +0000, Bich HEMON wrote: > From: Bich Hemon <bich.hemon@st.com> > > Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Again, no changelog == no patch applied. Please fix this, and the signed-off-by issues for all of these patches for your next revision of this patchset. thanks, greg k-h
[toc] | [prev] | [next] | [standalone]
| From | Bich HEMON <bich.hemon@st.com> |
|---|---|
| Date | 2017-06-26 15:00 +0200 |
| Subject | [PATCH 04/20] serial: stm32: make fifoen as property for each port |
| Message-ID | <tWBMw-2tb-61@gated-at.bofh.it> |
| In reply to | #1674752 |
From: Bich Hemon <bich.hemon@st.com>
Signed-off-by: Gerald Baeza <gerald.baeza@st.com>
---
drivers/tty/serial/stm32-usart.c | 10 +++++++---
drivers/tty/serial/stm32-usart.h | 1 +
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index c6ae4fd..34e31d1 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -453,7 +453,8 @@ static int stm32_startup(struct uart_port *port)
return ret;
val = USART_CR1_RXNEIE | USART_CR1_TE | USART_CR1_RE;
- val |= USART_CR1_FIFOEN;
+ if (stm32_port->fifoen)
+ val |= USART_CR1_FIFOEN;
stm32_set_bits(port, ofs->cr1, val);
return 0;
@@ -468,7 +469,8 @@ static void stm32_shutdown(struct uart_port *port)
val = USART_CR1_TXEIE | USART_CR1_RXNEIE | USART_CR1_TE | USART_CR1_RE;
val |= BIT(cfg->uart_enable_bit);
- val |= USART_CR1_FIFOEN;
+ if (stm32_port->fifoen)
+ val |= USART_CR1_FIFOEN;
stm32_clr_bits(port, ofs->cr1, val);
free_irq(port->irq, port);
@@ -498,7 +500,8 @@ static void stm32_set_termios(struct uart_port *port, struct ktermios *termios,
cr1 = USART_CR1_TE | USART_CR1_RE | USART_CR1_RXNEIE;
cr1 |= BIT(cfg->uart_enable_bit);
- cr1 |= USART_CR1_FIFOEN;
+ if (stm32_port->fifoen)
+ cr1 |= USART_CR1_FIFOEN;
cr2 = 0;
cr3 = 0;
@@ -707,6 +710,7 @@ static struct stm32_port *stm32_of_get_stm32_port(struct platform_device *pdev)
stm32_ports[id].hw_flow_control = of_property_read_bool(np,
"st,hw-flow-ctrl");
stm32_ports[id].port.line = id;
+ stm32_ports[id].fifoen = true;
return &stm32_ports[id];
}
diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h
index 33f1320..9429baf 100644
--- a/drivers/tty/serial/stm32-usart.h
+++ b/drivers/tty/serial/stm32-usart.h
@@ -224,6 +224,7 @@ struct stm32_port {
unsigned char *tx_buf; /* dma tx buffer cpu address */
bool tx_dma_busy; /* dma tx busy */
bool hw_flow_control;
+ bool fifoen;
};
static struct stm32_port stm32_ports[STM32_MAX_PORTS];
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Bich HEMON <bich.hemon@st.com> |
|---|---|
| Date | 2017-06-26 15:00 +0200 |
| Subject | [PATCH 08/20] serial: stm32: timeout interrupt using with dma |
| Message-ID | <tWBMw-2tb-67@gated-at.bofh.it> |
| In reply to | #1674752 |
From: Bich Hemon <bich.hemon@st.com>
Signed-off-by: Gerald Baeza <gerald.baeza@st.com>
---
drivers/tty/serial/stm32-usart.c | 25 +++++++++++++++++++------
drivers/tty/serial/stm32-usart.h | 1 +
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index dcc6d1e..ed2025b 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -371,6 +371,10 @@ static irqreturn_t stm32_interrupt(int irq, void *ptr)
sr = readl_relaxed(port->membase + ofs->isr);
+ if ((sr & USART_SR_RTOF) && (ofs->icr != UNDEF_REG))
+ writel_relaxed(USART_ICR_RTOCF,
+ port->membase + ofs->icr);
+
if ((sr & USART_SR_RXNE) && !(stm32_port->rx_ch))
stm32_receive_chars(port, false);
@@ -453,7 +457,7 @@ static void stm32_throttle(struct uart_port *port)
unsigned long flags;
spin_lock_irqsave(&port->lock, flags);
- stm32_clr_bits(port, ofs->cr1, USART_CR1_RXNEIE);
+ stm32_clr_bits(port, ofs->cr1, stm32_port->rx_irq);
spin_unlock_irqrestore(&port->lock, flags);
}
@@ -465,7 +469,7 @@ static void stm32_unthrottle(struct uart_port *port)
unsigned long flags;
spin_lock_irqsave(&port->lock, flags);
- stm32_set_bits(port, ofs->cr1, USART_CR1_RXNEIE);
+ stm32_set_bits(port, ofs->cr1, stm32_port->rx_irq);
spin_unlock_irqrestore(&port->lock, flags);
}
@@ -475,7 +479,7 @@ static void stm32_stop_rx(struct uart_port *port)
struct stm32_port *stm32_port = to_stm32_port(port);
struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
- stm32_clr_bits(port, ofs->cr1, USART_CR1_RXNEIE);
+ stm32_clr_bits(port, ofs->cr1, stm32_port->rx_irq);
}
/* Handle breaks - ignored by us */
@@ -497,7 +501,7 @@ static int stm32_startup(struct uart_port *port)
if (ret)
return ret;
- val = USART_CR1_RXNEIE | USART_CR1_TE | USART_CR1_RE;
+ val = stm32_port->rx_irq | USART_CR1_TE | USART_CR1_RE;
if (stm32_port->fifoen)
val |= USART_CR1_FIFOEN;
stm32_set_bits(port, ofs->cr1, val);
@@ -512,7 +516,8 @@ static void stm32_shutdown(struct uart_port *port)
struct stm32_usart_config *cfg = &stm32_port->info->cfg;
u32 val;
- val = USART_CR1_TXEIE | USART_CR1_RXNEIE | USART_CR1_TE | USART_CR1_RE;
+ val = USART_CR1_TXEIE | USART_CR1_TE;
+ val |= stm32_port->rx_irq | USART_CR1_RE;
val |= BIT(cfg->uart_enable_bit);
if (stm32_port->fifoen)
val |= USART_CR1_FIFOEN;
@@ -543,7 +548,7 @@ static void stm32_set_termios(struct uart_port *port, struct ktermios *termios,
/* Stop serial port and reset value */
writel_relaxed(0, port->membase + ofs->cr1);
- cr1 = USART_CR1_TE | USART_CR1_RE | USART_CR1_RXNEIE;
+ cr1 = USART_CR1_TE | USART_CR1_RE;
cr1 |= BIT(cfg->uart_enable_bit);
if (stm32_port->fifoen)
cr1 |= USART_CR1_FIFOEN;
@@ -553,6 +558,13 @@ static void stm32_set_termios(struct uart_port *port, struct ktermios *termios,
if (cflag & CSTOPB)
cr2 |= USART_CR2_STOP_2B;
+ if ((ofs->rtor != UNDEF_REG) && (stm32_port->rx_ch)) {
+ stm32_port->rx_irq = USART_CR1_RTOIE;
+ writel_relaxed(baud, port->membase + ofs->rtor);
+ cr2 |= USART_CR2_RTOEN;
+ }
+ cr1 |= stm32_port->rx_irq;
+
if (cflag & PARENB) {
cr1 |= USART_CR1_PCE;
if ((cflag & CSIZE) == CS8) {
@@ -758,6 +770,7 @@ static struct stm32_port *stm32_of_get_stm32_port(struct platform_device *pdev)
"st,hw-flow-ctrl");
stm32_ports[id].port.line = id;
stm32_ports[id].fifoen = true;
+ stm32_ports[id].rx_irq = USART_CR1_RXNEIE;
return &stm32_ports[id];
}
diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h
index a8999a1..f9fe15b 100644
--- a/drivers/tty/serial/stm32-usart.h
+++ b/drivers/tty/serial/stm32-usart.h
@@ -225,6 +225,7 @@ struct stm32_port {
struct dma_chan *tx_ch; /* dma tx channel */
dma_addr_t tx_dma_buf; /* dma tx buffer bus address */
unsigned char *tx_buf; /* dma tx buffer cpu address */
+ u32 rx_irq; /* USART_CR1_RXNEIE or RTOIE */
bool tx_dma_busy; /* dma tx busy */
bool hw_flow_control;
bool fifoen;
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Alexandre Torgue <alexandre.torgue@st.com> |
|---|---|
| Date | 2017-06-29 17:20 +0200 |
| Message-ID | <tXJoC-LR-7@gated-at.bofh.it> |
| In reply to | #1674752 |
Greg, Rob On 06/26/2017 02:49 PM, Bich HEMON wrote: > From: Bich Hemon <bich.hemon@st.com> > > This patchset updates the stm32 usart driver. It mainly adds > support for fifo, dma, debugfs anf fixes various bugs. > > Bich Hemon (20): > serial: stm32: adding fifo support > dt-bindings: serial: each stm32 usart needs an alias > serial: stm32: fix multi ports management > serial: stm32: make fifoen as property for each port > serial: stm32: add debugfs > serial: stm32: fix pio transmit timeout > serial: stm32: less messages on dma alloc error > serial: stm32: timeout interrupt using with dma > serial: stm32: fix end of transfer > serial: stm32: fix dma receive > serial: stm32: add RTS support > serial: stm32: fix last_res value > serial: stm32: fix error handling in probe > dt-bindings: serial: document option wake-up interrupt for STM32 USART > serial: stm32: Add wakeup mechanism > serial: stm32: fix fifo usage > dt-bindings: serial: stm32: add dma using note > serial: stm32: update dma buffers length > serial: stm32: add dma rx callback > serial: stm32: fix rx interrupt handling in startup > > .../devicetree/bindings/serial/st,stm32-usart.txt | 55 +++- > drivers/tty/serial/stm32-usart.c | 310 ++++++++++++++++++--- > drivers/tty/serial/stm32-usart.h | 51 +++- > 3 files changed, 375 insertions(+), 41 deletions(-) > This series have been abandoned (maybe not in correct way). Don't waste your time with that. New patches will be sent in several series and patches will be reworked. Thanks Alex
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web