serial: imx: ensure UCR3 and UFCR are setup correctly

Commit e61c38d85b73 ("serial: imx: setup DCEDTE early and ensure DCD and
RI irqs to be off") has a flaw: While UCR3 and UFCR were modified using
read-modify-write before it switched to write register values
independent of the previous state. That's a good idea in principle (and
that's why I did it) but needs more care.

This patch reinstates read-modify-write for UFCR and for UCR3 ensures
that RXDMUXSEL and ADNIMP are set for post imx1.

Fixes: e61c38d85b73 ("serial: imx: setup DCEDTE early and ensure DCD and RI irqs to be off")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Mika Penttilä <mika.penttila@nextfour.com>
Tested-by: Mika Penttilä <mika.penttila@nextfour.com>
Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
Tested-by: Steve Twiss <stwiss.opensource@diasemi.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by Uwe Kleine-König and committed by Greg Kroah-Hartman 6df765dc 46e3813d

Changed files
+12 -2
drivers
tty
serial
+12 -2
drivers/tty/serial/imx.c
··· 2184 2184 * and DCD (when they are outputs) or enables the respective 2185 2185 * irqs. So set this bit early, i.e. before requesting irqs. 2186 2186 */ 2187 - writel(UFCR_DCEDTE, sport->port.membase + UFCR); 2187 + reg = readl(sport->port.membase + UFCR); 2188 + if (!(reg & UFCR_DCEDTE)) 2189 + writel(reg | UFCR_DCEDTE, sport->port.membase + UFCR); 2188 2190 2189 2191 /* 2190 2192 * Disable UCR3_RI and UCR3_DCD irqs. They are also not ··· 2197 2195 sport->port.membase + UCR3); 2198 2196 2199 2197 } else { 2200 - writel(0, sport->port.membase + UFCR); 2198 + unsigned long ucr3 = UCR3_DSR; 2199 + 2200 + reg = readl(sport->port.membase + UFCR); 2201 + if (reg & UFCR_DCEDTE) 2202 + writel(reg & ~UFCR_DCEDTE, sport->port.membase + UFCR); 2203 + 2204 + if (!is_imx1_uart(sport)) 2205 + ucr3 |= IMX21_UCR3_RXDMUXSEL | UCR3_ADNIMP; 2206 + writel(ucr3, sport->port.membase + UCR3); 2201 2207 } 2202 2208 2203 2209 clk_disable_unprepare(sport->clk_ipg);