+++ /dev/null
-From de147331681c9fb3b67469adddbcf6adbdc85b1b Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Sun, 11 Sep 2022 11:02:03 +0200
-Subject: serial: stm32: Deassert Transmit Enable on ->rs485_config()
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-From: Lukas Wunner <lukas@wunner.de>
-
-[ Upstream commit adafbbf6895eb0ce41a313c6ee68870ab9aa93cd ]
-
-The STM32 USART can control RS-485 Transmit Enable in hardware. Since
-commit 7df5081cbf5e ("serial: stm32: Add RS485 RTS GPIO control"),
-it can alternatively be controlled in software. That was done to allow
-RS-485 even if the RTS pin is unavailable because it's pinmuxed to a
-different function.
-
-However the commit neglected to deassert Transmit Enable upon invocation
-of the ->rs485_config() callback. Fix it.
-
-Avoid forward declarations by moving stm32_usart_tx_empty(),
-stm32_usart_rs485_rts_enable() and stm32_usart_rs485_rts_disable()
-further up in the driver.
-
-Fixes: 7df5081cbf5e ("serial: stm32: Add RS485 RTS GPIO control")
-Cc: stable@vger.kernel.org # v5.9+
-Cc: Marek Vasut <marex@denx.de>
-Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
-Signed-off-by: Lukas Wunner <lukas@wunner.de>
-Link: https://lore.kernel.org/r/6059eab35dba394468335ef640df8b0050fd9dbd.1662886616.git.lukas@wunner.de
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/tty/serial/stm32-usart.c | 100 ++++++++++++++++---------------
- 1 file changed, 53 insertions(+), 47 deletions(-)
-
-diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
-index 3505923947f8..da698e0cd835 100644
---- a/drivers/tty/serial/stm32-usart.c
-+++ b/drivers/tty/serial/stm32-usart.c
-@@ -61,6 +61,53 @@ static void stm32_usart_clr_bits(struct uart_port *port, u32 reg, u32 bits)
- writel_relaxed(val, port->membase + reg);
- }
-
-+static unsigned int stm32_usart_tx_empty(struct uart_port *port)
-+{
-+ struct stm32_port *stm32_port = to_stm32_port(port);
-+ const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
-+
-+ if (readl_relaxed(port->membase + ofs->isr) & USART_SR_TC)
-+ return TIOCSER_TEMT;
-+
-+ return 0;
-+}
-+
-+static void stm32_usart_rs485_rts_enable(struct uart_port *port)
-+{
-+ struct stm32_port *stm32_port = to_stm32_port(port);
-+ struct serial_rs485 *rs485conf = &port->rs485;
-+
-+ if (stm32_port->hw_flow_control ||
-+ !(rs485conf->flags & SER_RS485_ENABLED))
-+ return;
-+
-+ if (rs485conf->flags & SER_RS485_RTS_ON_SEND) {
-+ mctrl_gpio_set(stm32_port->gpios,
-+ stm32_port->port.mctrl | TIOCM_RTS);
-+ } else {
-+ mctrl_gpio_set(stm32_port->gpios,
-+ stm32_port->port.mctrl & ~TIOCM_RTS);
-+ }
-+}
-+
-+static void stm32_usart_rs485_rts_disable(struct uart_port *port)
-+{
-+ struct stm32_port *stm32_port = to_stm32_port(port);
-+ struct serial_rs485 *rs485conf = &port->rs485;
-+
-+ if (stm32_port->hw_flow_control ||
-+ !(rs485conf->flags & SER_RS485_ENABLED))
-+ return;
-+
-+ if (rs485conf->flags & SER_RS485_RTS_ON_SEND) {
-+ mctrl_gpio_set(stm32_port->gpios,
-+ stm32_port->port.mctrl & ~TIOCM_RTS);
-+ } else {
-+ mctrl_gpio_set(stm32_port->gpios,
-+ stm32_port->port.mctrl | TIOCM_RTS);
-+ }
-+}
-+
- static void stm32_usart_config_reg_rs485(u32 *cr1, u32 *cr3, u32 delay_ADE,
- u32 delay_DDE, u32 baud)
- {
-@@ -149,6 +196,12 @@ static int stm32_usart_config_rs485(struct uart_port *port,
-
- stm32_usart_set_bits(port, ofs->cr1, BIT(cfg->uart_enable_bit));
-
-+ /* Adjust RTS polarity in case it's driven in software */
-+ if (stm32_usart_tx_empty(port))
-+ stm32_usart_rs485_rts_disable(port);
-+ else
-+ stm32_usart_rs485_rts_enable(port);
-+
- return 0;
- }
-
-@@ -341,42 +394,6 @@ static void stm32_usart_tc_interrupt_disable(struct uart_port *port)
- stm32_usart_clr_bits(port, ofs->cr1, USART_CR1_TCIE);
- }
-
--static void stm32_usart_rs485_rts_enable(struct uart_port *port)
--{
-- struct stm32_port *stm32_port = to_stm32_port(port);
-- struct serial_rs485 *rs485conf = &port->rs485;
--
-- if (stm32_port->hw_flow_control ||
-- !(rs485conf->flags & SER_RS485_ENABLED))
-- return;
--
-- if (rs485conf->flags & SER_RS485_RTS_ON_SEND) {
-- mctrl_gpio_set(stm32_port->gpios,
-- stm32_port->port.mctrl | TIOCM_RTS);
-- } else {
-- mctrl_gpio_set(stm32_port->gpios,
-- stm32_port->port.mctrl & ~TIOCM_RTS);
-- }
--}
--
--static void stm32_usart_rs485_rts_disable(struct uart_port *port)
--{
-- struct stm32_port *stm32_port = to_stm32_port(port);
-- struct serial_rs485 *rs485conf = &port->rs485;
--
-- if (stm32_port->hw_flow_control ||
-- !(rs485conf->flags & SER_RS485_ENABLED))
-- return;
--
-- if (rs485conf->flags & SER_RS485_RTS_ON_SEND) {
-- mctrl_gpio_set(stm32_port->gpios,
-- stm32_port->port.mctrl & ~TIOCM_RTS);
-- } else {
-- mctrl_gpio_set(stm32_port->gpios,
-- stm32_port->port.mctrl | TIOCM_RTS);
-- }
--}
--
- static void stm32_usart_transmit_chars_pio(struct uart_port *port)
- {
- struct stm32_port *stm32_port = to_stm32_port(port);
-@@ -590,17 +607,6 @@ static irqreturn_t stm32_usart_threaded_interrupt(int irq, void *ptr)
- return IRQ_HANDLED;
- }
-
--static unsigned int stm32_usart_tx_empty(struct uart_port *port)
--{
-- struct stm32_port *stm32_port = to_stm32_port(port);
-- const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
--
-- if (readl_relaxed(port->membase + ofs->isr) & USART_SR_TC)
-- return TIOCSER_TEMT;
--
-- return 0;
--}
--
- static void stm32_usart_set_mctrl(struct uart_port *port, unsigned int mctrl)
- {
- struct stm32_port *stm32_port = to_stm32_port(port);
---
-2.35.1
-
+++ /dev/null
-From 72dc7efee51074a225b188d250ea3025bed5f36e Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Sat, 30 Apr 2022 18:28:44 +0200
-Subject: serial: stm32: Factor out GPIO RTS toggling into separate function
-
-From: Marek Vasut <marex@denx.de>
-
-[ Upstream commit 3bcea529b295a993b1b05db63f245ae8030c5acf ]
-
-Pull out the GPIO RTS enable and disable handling into separate function.
-Limit the scope of GPIO RTS toggling only to GPIO emulated RS485 too.
-
-Signed-off-by: Marek Vasut <marex@denx.de>
-Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
-Cc: Erwan Le Ray <erwan.leray@foss.st.com>
-Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Cc: Jean Philippe Romain <jean-philippe.romain@foss.st.com>
-Cc: Valentin Caron <valentin.caron@foss.st.com>
-Cc: linux-arm-kernel@lists.infradead.org
-Cc: linux-stm32@st-md-mailman.stormreply.com
-To: linux-serial@vger.kernel.org
-Link: https://lore.kernel.org/r/20220430162845.244655-1-marex@denx.de
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Stable-dep-of: adafbbf6895e ("serial: stm32: Deassert Transmit Enable on ->rs485_config()")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/tty/serial/stm32-usart.c | 59 ++++++++++++++++++++------------
- 1 file changed, 38 insertions(+), 21 deletions(-)
-
-diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
-index fc166cc2c856..a1092a8a8243 100644
---- a/drivers/tty/serial/stm32-usart.c
-+++ b/drivers/tty/serial/stm32-usart.c
-@@ -325,6 +325,42 @@ static void stm32_usart_tx_interrupt_disable(struct uart_port *port)
- stm32_usart_clr_bits(port, ofs->cr1, USART_CR1_TXEIE);
- }
-
-+static void stm32_usart_rs485_rts_enable(struct uart_port *port)
-+{
-+ struct stm32_port *stm32_port = to_stm32_port(port);
-+ struct serial_rs485 *rs485conf = &port->rs485;
-+
-+ if (stm32_port->hw_flow_control ||
-+ !(rs485conf->flags & SER_RS485_ENABLED))
-+ return;
-+
-+ if (rs485conf->flags & SER_RS485_RTS_ON_SEND) {
-+ mctrl_gpio_set(stm32_port->gpios,
-+ stm32_port->port.mctrl | TIOCM_RTS);
-+ } else {
-+ mctrl_gpio_set(stm32_port->gpios,
-+ stm32_port->port.mctrl & ~TIOCM_RTS);
-+ }
-+}
-+
-+static void stm32_usart_rs485_rts_disable(struct uart_port *port)
-+{
-+ struct stm32_port *stm32_port = to_stm32_port(port);
-+ struct serial_rs485 *rs485conf = &port->rs485;
-+
-+ if (stm32_port->hw_flow_control ||
-+ !(rs485conf->flags & SER_RS485_ENABLED))
-+ return;
-+
-+ if (rs485conf->flags & SER_RS485_RTS_ON_SEND) {
-+ mctrl_gpio_set(stm32_port->gpios,
-+ stm32_port->port.mctrl & ~TIOCM_RTS);
-+ } else {
-+ mctrl_gpio_set(stm32_port->gpios,
-+ stm32_port->port.mctrl | TIOCM_RTS);
-+ }
-+}
-+
- static void stm32_usart_transmit_chars_pio(struct uart_port *port)
- {
- struct stm32_port *stm32_port = to_stm32_port(port);
-@@ -567,40 +603,21 @@ static void stm32_usart_disable_ms(struct uart_port *port)
- static void stm32_usart_stop_tx(struct uart_port *port)
- {
- struct stm32_port *stm32_port = to_stm32_port(port);
-- struct serial_rs485 *rs485conf = &port->rs485;
-
- stm32_usart_tx_interrupt_disable(port);
-
-- if (rs485conf->flags & SER_RS485_ENABLED) {
-- if (rs485conf->flags & SER_RS485_RTS_ON_SEND) {
-- mctrl_gpio_set(stm32_port->gpios,
-- stm32_port->port.mctrl & ~TIOCM_RTS);
-- } else {
-- mctrl_gpio_set(stm32_port->gpios,
-- stm32_port->port.mctrl | TIOCM_RTS);
-- }
-- }
-+ stm32_usart_rs485_rts_disable(port);
- }
-
- /* There are probably characters waiting to be transmitted. */
- static void stm32_usart_start_tx(struct uart_port *port)
- {
-- struct stm32_port *stm32_port = to_stm32_port(port);
-- struct serial_rs485 *rs485conf = &port->rs485;
- struct circ_buf *xmit = &port->state->xmit;
-
- if (uart_circ_empty(xmit) && !port->x_char)
- return;
-
-- if (rs485conf->flags & SER_RS485_ENABLED) {
-- if (rs485conf->flags & SER_RS485_RTS_ON_SEND) {
-- mctrl_gpio_set(stm32_port->gpios,
-- stm32_port->port.mctrl | TIOCM_RTS);
-- } else {
-- mctrl_gpio_set(stm32_port->gpios,
-- stm32_port->port.mctrl & ~TIOCM_RTS);
-- }
-- }
-+ stm32_usart_rs485_rts_enable(port);
-
- stm32_usart_transmit_chars(port);
- }
---
-2.35.1
-
+++ /dev/null
-From 2169877934e06059b364f9a3dd097c7e276cb772 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Sat, 30 Apr 2022 18:28:45 +0200
-Subject: serial: stm32: Use TC interrupt to deassert GPIO RTS in RS485 mode
-
-From: Marek Vasut <marex@denx.de>
-
-[ Upstream commit d7c76716169ddc37cf6316ff381d34ea807fbfd7 ]
-
-In case the RS485 mode is emulated using GPIO RTS, use the TC interrupt
-to deassert the GPIO RTS, otherwise the GPIO RTS stays asserted after a
-transmission ended and the RS485 cannot work.
-
-Signed-off-by: Marek Vasut <marex@denx.de>
-Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
-Cc: Erwan Le Ray <erwan.leray@foss.st.com>
-Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Cc: Jean Philippe Romain <jean-philippe.romain@foss.st.com>
-Cc: Valentin Caron <valentin.caron@foss.st.com>
-Cc: linux-arm-kernel@lists.infradead.org
-Cc: linux-stm32@st-md-mailman.stormreply.com
-To: linux-serial@vger.kernel.org
-Link: https://lore.kernel.org/r/20220430162845.244655-2-marex@denx.de
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Stable-dep-of: adafbbf6895e ("serial: stm32: Deassert Transmit Enable on ->rs485_config()")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/tty/serial/stm32-usart.c | 42 ++++++++++++++++++++++++++++++--
- drivers/tty/serial/stm32-usart.h | 1 +
- 2 files changed, 41 insertions(+), 2 deletions(-)
-
-diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
-index a1092a8a8243..3505923947f8 100644
---- a/drivers/tty/serial/stm32-usart.c
-+++ b/drivers/tty/serial/stm32-usart.c
-@@ -314,6 +314,14 @@ static void stm32_usart_tx_interrupt_enable(struct uart_port *port)
- stm32_usart_set_bits(port, ofs->cr1, USART_CR1_TXEIE);
- }
-
-+static void stm32_usart_tc_interrupt_enable(struct uart_port *port)
-+{
-+ struct stm32_port *stm32_port = to_stm32_port(port);
-+ const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
-+
-+ stm32_usart_set_bits(port, ofs->cr1, USART_CR1_TCIE);
-+}
-+
- static void stm32_usart_tx_interrupt_disable(struct uart_port *port)
- {
- struct stm32_port *stm32_port = to_stm32_port(port);
-@@ -325,6 +333,14 @@ static void stm32_usart_tx_interrupt_disable(struct uart_port *port)
- stm32_usart_clr_bits(port, ofs->cr1, USART_CR1_TXEIE);
- }
-
-+static void stm32_usart_tc_interrupt_disable(struct uart_port *port)
-+{
-+ struct stm32_port *stm32_port = to_stm32_port(port);
-+ const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
-+
-+ stm32_usart_clr_bits(port, ofs->cr1, USART_CR1_TCIE);
-+}
-+
- static void stm32_usart_rs485_rts_enable(struct uart_port *port)
- {
- struct stm32_port *stm32_port = to_stm32_port(port);
-@@ -462,6 +478,13 @@ static void stm32_usart_transmit_chars(struct uart_port *port)
- u32 isr;
- int ret;
-
-+ if (!stm32_port->hw_flow_control &&
-+ port->rs485.flags & SER_RS485_ENABLED) {
-+ stm32_port->txdone = false;
-+ stm32_usart_tc_interrupt_disable(port);
-+ stm32_usart_rs485_rts_enable(port);
-+ }
-+
- if (port->x_char) {
- if (stm32_port->tx_dma_busy)
- stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAT);
-@@ -501,8 +524,14 @@ static void stm32_usart_transmit_chars(struct uart_port *port)
- if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
- uart_write_wakeup(port);
-
-- if (uart_circ_empty(xmit))
-+ if (uart_circ_empty(xmit)) {
- stm32_usart_tx_interrupt_disable(port);
-+ if (!stm32_port->hw_flow_control &&
-+ port->rs485.flags & SER_RS485_ENABLED) {
-+ stm32_port->txdone = true;
-+ stm32_usart_tc_interrupt_enable(port);
-+ }
-+ }
- }
-
- static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
-@@ -515,6 +544,13 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
-
- sr = readl_relaxed(port->membase + ofs->isr);
-
-+ if (!stm32_port->hw_flow_control &&
-+ port->rs485.flags & SER_RS485_ENABLED &&
-+ (sr & USART_SR_TC)) {
-+ stm32_usart_tc_interrupt_disable(port);
-+ stm32_usart_rs485_rts_disable(port);
-+ }
-+
- if ((sr & USART_SR_RTOF) && ofs->icr != UNDEF_REG)
- writel_relaxed(USART_ICR_RTOCF,
- port->membase + ofs->icr);
-@@ -614,8 +650,10 @@ static void stm32_usart_start_tx(struct uart_port *port)
- {
- struct circ_buf *xmit = &port->state->xmit;
-
-- if (uart_circ_empty(xmit) && !port->x_char)
-+ if (uart_circ_empty(xmit) && !port->x_char) {
-+ stm32_usart_rs485_rts_disable(port);
- return;
-+ }
-
- stm32_usart_rs485_rts_enable(port);
-
-diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h
-index 07ac291328cd..ad6335155de2 100644
---- a/drivers/tty/serial/stm32-usart.h
-+++ b/drivers/tty/serial/stm32-usart.h
-@@ -267,6 +267,7 @@ struct stm32_port {
- bool hw_flow_control;
- bool swap; /* swap RX & TX pins */
- bool fifoen;
-+ bool txdone;
- int rxftcfg; /* RX FIFO threshold CFG */
- int txftcfg; /* TX FIFO threshold CFG */
- bool wakeup_src;
---
-2.35.1
-
arm64-mte-avoid-setting-pg_mte_tagged-if-no-tags-cle.patch
-serial-stm32-factor-out-gpio-rts-toggling-into-separ.patch
-serial-stm32-use-tc-interrupt-to-deassert-gpio-rts-i.patch
-serial-stm32-deassert-transmit-enable-on-rs485_confi.patch
drm-i915-create-a-dummy-object-for-gen6-ppgtt.patch
drm-i915-gt-use-i915_vm_put-on-ppgtt_create-error-pa.patch
erofs-fix-order-max_order-warning-due-to-crafted-neg.patch