Skip to content

Commit 1cf93e0

Browse files
Huang Shijiegregkh
authored andcommitted
serial: imx: remove the uart_console() check
The uart_console() check makes the clocks(clk_per and clk_ipg) opened even when we close the console uart. This patch enable/disable the clocks in imx_console_write(), so we can keep the clocks closed when the console uart is closed. Also remove the clock enable/disable oprations in the probe, we do not need them any more. Signed-off-by: Huang Shijie <[email protected]> Acked-by: Shawn Guo <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 43b829b commit 1cf93e0

File tree

1 file changed

+43
-26
lines changed

1 file changed

+43
-26
lines changed

drivers/tty/serial/imx.c

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -701,15 +701,13 @@ static int imx_startup(struct uart_port *port)
701701
int retval;
702702
unsigned long flags, temp;
703703

704-
if (!uart_console(port)) {
705-
retval = clk_prepare_enable(sport->clk_per);
706-
if (retval)
707-
goto error_out1;
708-
retval = clk_prepare_enable(sport->clk_ipg);
709-
if (retval) {
710-
clk_disable_unprepare(sport->clk_per);
711-
goto error_out1;
712-
}
704+
retval = clk_prepare_enable(sport->clk_per);
705+
if (retval)
706+
goto error_out1;
707+
retval = clk_prepare_enable(sport->clk_ipg);
708+
if (retval) {
709+
clk_disable_unprepare(sport->clk_per);
710+
goto error_out1;
713711
}
714712

715713
imx_setup_ufcr(sport, 0);
@@ -900,10 +898,8 @@ static void imx_shutdown(struct uart_port *port)
900898
writel(temp, sport->port.membase + UCR1);
901899
spin_unlock_irqrestore(&sport->port.lock, flags);
902900

903-
if (!uart_console(&sport->port)) {
904-
clk_disable_unprepare(sport->clk_per);
905-
clk_disable_unprepare(sport->clk_ipg);
906-
}
901+
clk_disable_unprepare(sport->clk_per);
902+
clk_disable_unprepare(sport->clk_ipg);
907903
}
908904

909905
static void
@@ -1250,6 +1246,16 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
12501246
unsigned int ucr1;
12511247
unsigned long flags = 0;
12521248
int locked = 1;
1249+
int retval;
1250+
1251+
retval = clk_enable(sport->clk_per);
1252+
if (retval)
1253+
return;
1254+
retval = clk_enable(sport->clk_ipg);
1255+
if (retval) {
1256+
clk_disable(sport->clk_per);
1257+
return;
1258+
}
12531259

12541260
if (sport->port.sysrq)
12551261
locked = 0;
@@ -1285,6 +1291,9 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
12851291

12861292
if (locked)
12871293
spin_unlock_irqrestore(&sport->port.lock, flags);
1294+
1295+
clk_disable(sport->clk_ipg);
1296+
clk_disable(sport->clk_per);
12881297
}
12891298

12901299
/*
@@ -1358,6 +1367,7 @@ imx_console_setup(struct console *co, char *options)
13581367
int bits = 8;
13591368
int parity = 'n';
13601369
int flow = 'n';
1370+
int retval;
13611371

13621372
/*
13631373
* Check whether an invalid uart number has been specified, and
@@ -1370,14 +1380,32 @@ imx_console_setup(struct console *co, char *options)
13701380
if (sport == NULL)
13711381
return -ENODEV;
13721382

1383+
/* For setting the registers, we only need to enable the ipg clock. */
1384+
retval = clk_prepare_enable(sport->clk_ipg);
1385+
if (retval)
1386+
goto error_console;
1387+
13731388
if (options)
13741389
uart_parse_options(options, &baud, &parity, &bits, &flow);
13751390
else
13761391
imx_console_get_options(sport, &baud, &parity, &bits);
13771392

13781393
imx_setup_ufcr(sport, 0);
13791394

1380-
return uart_set_options(&sport->port, co, baud, parity, bits, flow);
1395+
retval = uart_set_options(&sport->port, co, baud, parity, bits, flow);
1396+
1397+
clk_disable(sport->clk_ipg);
1398+
if (retval) {
1399+
clk_unprepare(sport->clk_ipg);
1400+
goto error_console;
1401+
}
1402+
1403+
retval = clk_prepare(sport->clk_per);
1404+
if (retval)
1405+
clk_disable_unprepare(sport->clk_ipg);
1406+
1407+
error_console:
1408+
return retval;
13811409
}
13821410

13831411
static struct uart_driver imx_reg;
@@ -1555,9 +1583,6 @@ static int serial_imx_probe(struct platform_device *pdev)
15551583
return ret;
15561584
}
15571585

1558-
clk_prepare_enable(sport->clk_per);
1559-
clk_prepare_enable(sport->clk_ipg);
1560-
15611586
sport->port.uartclk = clk_get_rate(sport->clk_per);
15621587

15631588
imx_ports[sport->port.line] = sport;
@@ -1566,26 +1591,18 @@ static int serial_imx_probe(struct platform_device *pdev)
15661591
if (pdata && pdata->init) {
15671592
ret = pdata->init(pdev);
15681593
if (ret)
1569-
goto clkput;
1594+
return ret;
15701595
}
15711596

15721597
ret = uart_add_one_port(&imx_reg, &sport->port);
15731598
if (ret)
15741599
goto deinit;
15751600
platform_set_drvdata(pdev, sport);
15761601

1577-
if (!uart_console(&sport->port)) {
1578-
clk_disable_unprepare(sport->clk_per);
1579-
clk_disable_unprepare(sport->clk_ipg);
1580-
}
1581-
15821602
return 0;
15831603
deinit:
15841604
if (pdata && pdata->exit)
15851605
pdata->exit(pdev);
1586-
clkput:
1587-
clk_disable_unprepare(sport->clk_per);
1588-
clk_disable_unprepare(sport->clk_ipg);
15891606
return ret;
15901607
}
15911608

0 commit comments

Comments
 (0)