Skip to content

Commit 13dc04d

Browse files
tmlindgregkh
authored andcommitted
serial: 8250: omap: Fix idling of clocks for unused uarts
I noticed that unused UARTs won't necessarily idle properly always unless at least one byte tx transfer is done first. After some debugging I narrowed down the problem to the scr register dma configuration bits that need to be set before softreset for the clocks to idle. Unless we do this, the module clkctrl idlest bits may be set to 1 instead of 3 meaning the clock will never idle and is blocking deeper idle states for the whole domain. This might be related to the configuration done by the bootloader or kexec booting where certain configurations cause the 8250 or the clkctrl clock to jam in a way where setting of the scr bits and reset is needed to clear it. I've tried diffing the 8250 registers for the various modes, but did not see anything specific. So far I've only seen this on omap4 but I'm suspecting this might also happen on the other clkctrl using SoCs considering they already have a quirk enabled for UART_ERRATA_CLOCK_DISABLE. Let's fix the issue by configuring scr before reset for basic dma even if we don't use it. The scr register will be reset when we do softreset few lines after, and we restore scr on resume. We should do this for all the SoCs with UART_ERRATA_CLOCK_DISABLE quirk flag set since the ones with UART_ERRATA_CLOCK_DISABLE are all based using clkctrl similar to omap4. Looks like both OMAP_UART_SCR_DMAMODE_1 | OMAP_UART_SCR_DMAMODE_CTL bits are needed for the clkctrl to idle after a softreset. And we need to add omap4 to also use the UART_ERRATA_CLOCK_DISABLE for the related workaround to be enabled. This same compatible value will also be used for omap5. Fixes: cdb929e ("serial: 8250_omap: workaround errata around idling UART after using DMA") Cc: Keerthy <j-keerthy@ti.com> Cc: Matthijs van Duin <matthijsvanduin@gmail.com> Cc: Sekhar Nori <nsekhar@ti.com> Cc: Tero Kristo <t-kristo@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fffd717 commit 13dc04d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

drivers/tty/serial/8250/8250_omap.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,13 +1110,14 @@ static int omap8250_no_handle_irq(struct uart_port *port)
11101110
return 0;
11111111
}
11121112

1113+
static const u8 omap4_habit = UART_ERRATA_CLOCK_DISABLE;
11131114
static const u8 am3352_habit = OMAP_DMA_TX_KICK | UART_ERRATA_CLOCK_DISABLE;
11141115
static const u8 dra742_habit = UART_ERRATA_CLOCK_DISABLE;
11151116

11161117
static const struct of_device_id omap8250_dt_ids[] = {
11171118
{ .compatible = "ti,omap2-uart" },
11181119
{ .compatible = "ti,omap3-uart" },
1119-
{ .compatible = "ti,omap4-uart" },
1120+
{ .compatible = "ti,omap4-uart", .data = &omap4_habit, },
11201121
{ .compatible = "ti,am3352-uart", .data = &am3352_habit, },
11211122
{ .compatible = "ti,am4372-uart", .data = &am3352_habit, },
11221123
{ .compatible = "ti,dra742-uart", .data = &dra742_habit, },
@@ -1362,6 +1363,19 @@ static int omap8250_soft_reset(struct device *dev)
13621363
int sysc;
13631364
int syss;
13641365

1366+
/*
1367+
* At least on omap4, unused uarts may not idle after reset without
1368+
* a basic scr dma configuration even with no dma in use. The
1369+
* module clkctrl status bits will be 1 instead of 3 blocking idle
1370+
* for the whole clockdomain. The softreset below will clear scr,
1371+
* and we restore it on resume so this is safe to do on all SoCs
1372+
* needing omap8250_soft_reset() quirk. Do it in two writes as
1373+
* recommended in the comment for omap8250_update_scr().
1374+
*/
1375+
serial_out(up, UART_OMAP_SCR, OMAP_UART_SCR_DMAMODE_1);
1376+
serial_out(up, UART_OMAP_SCR,
1377+
OMAP_UART_SCR_DMAMODE_1 | OMAP_UART_SCR_DMAMODE_CTL);
1378+
13651379
sysc = serial_in(up, UART_OMAP_SYSC);
13661380

13671381
/* softreset the UART */

0 commit comments

Comments
 (0)