@@ -701,15 +701,13 @@ static int imx_startup(struct uart_port *port)
701
701
int retval ;
702
702
unsigned long flags , temp ;
703
703
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 ;
713
711
}
714
712
715
713
imx_setup_ufcr (sport , 0 );
@@ -900,10 +898,8 @@ static void imx_shutdown(struct uart_port *port)
900
898
writel (temp , sport -> port .membase + UCR1 );
901
899
spin_unlock_irqrestore (& sport -> port .lock , flags );
902
900
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 );
907
903
}
908
904
909
905
static void
@@ -1250,6 +1246,16 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
1250
1246
unsigned int ucr1 ;
1251
1247
unsigned long flags = 0 ;
1252
1248
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
+ }
1253
1259
1254
1260
if (sport -> port .sysrq )
1255
1261
locked = 0 ;
@@ -1285,6 +1291,9 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
1285
1291
1286
1292
if (locked )
1287
1293
spin_unlock_irqrestore (& sport -> port .lock , flags );
1294
+
1295
+ clk_disable (sport -> clk_ipg );
1296
+ clk_disable (sport -> clk_per );
1288
1297
}
1289
1298
1290
1299
/*
@@ -1358,6 +1367,7 @@ imx_console_setup(struct console *co, char *options)
1358
1367
int bits = 8 ;
1359
1368
int parity = 'n' ;
1360
1369
int flow = 'n' ;
1370
+ int retval ;
1361
1371
1362
1372
/*
1363
1373
* Check whether an invalid uart number has been specified, and
@@ -1370,14 +1380,32 @@ imx_console_setup(struct console *co, char *options)
1370
1380
if (sport == NULL )
1371
1381
return - ENODEV ;
1372
1382
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
+
1373
1388
if (options )
1374
1389
uart_parse_options (options , & baud , & parity , & bits , & flow );
1375
1390
else
1376
1391
imx_console_get_options (sport , & baud , & parity , & bits );
1377
1392
1378
1393
imx_setup_ufcr (sport , 0 );
1379
1394
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 ;
1381
1409
}
1382
1410
1383
1411
static struct uart_driver imx_reg ;
@@ -1555,9 +1583,6 @@ static int serial_imx_probe(struct platform_device *pdev)
1555
1583
return ret ;
1556
1584
}
1557
1585
1558
- clk_prepare_enable (sport -> clk_per );
1559
- clk_prepare_enable (sport -> clk_ipg );
1560
-
1561
1586
sport -> port .uartclk = clk_get_rate (sport -> clk_per );
1562
1587
1563
1588
imx_ports [sport -> port .line ] = sport ;
@@ -1566,26 +1591,18 @@ static int serial_imx_probe(struct platform_device *pdev)
1566
1591
if (pdata && pdata -> init ) {
1567
1592
ret = pdata -> init (pdev );
1568
1593
if (ret )
1569
- goto clkput ;
1594
+ return ret ;
1570
1595
}
1571
1596
1572
1597
ret = uart_add_one_port (& imx_reg , & sport -> port );
1573
1598
if (ret )
1574
1599
goto deinit ;
1575
1600
platform_set_drvdata (pdev , sport );
1576
1601
1577
- if (!uart_console (& sport -> port )) {
1578
- clk_disable_unprepare (sport -> clk_per );
1579
- clk_disable_unprepare (sport -> clk_ipg );
1580
- }
1581
-
1582
1602
return 0 ;
1583
1603
deinit :
1584
1604
if (pdata && pdata -> exit )
1585
1605
pdata -> exit (pdev );
1586
- clkput :
1587
- clk_disable_unprepare (sport -> clk_per );
1588
- clk_disable_unprepare (sport -> clk_ipg );
1589
1606
return ret ;
1590
1607
}
1591
1608
0 commit comments