@@ -1314,27 +1314,14 @@ static unsigned long get_clk_div_rate(struct clk *clk, unsigned int baud,
1314
1314
return ser_clk ;
1315
1315
}
1316
1316
1317
- static void qcom_geni_serial_set_termios (struct uart_port * uport ,
1318
- struct ktermios * termios ,
1319
- const struct ktermios * old )
1317
+ static int geni_serial_set_rate (struct uart_port * uport , unsigned int baud )
1320
1318
{
1321
- unsigned int baud ;
1322
- u32 bits_per_char ;
1323
- u32 tx_trans_cfg ;
1324
- u32 tx_parity_cfg ;
1325
- u32 rx_trans_cfg ;
1326
- u32 rx_parity_cfg ;
1327
- u32 stop_bit_len ;
1328
- unsigned int clk_div ;
1329
- u32 ser_clk_cfg ;
1330
1319
struct qcom_geni_serial_port * port = to_dev_port (uport );
1331
1320
unsigned long clk_rate ;
1332
- u32 ver , sampling_rate ;
1333
1321
unsigned int avg_bw_core ;
1334
- unsigned long timeout ;
1335
-
1336
- /* baud rate */
1337
- baud = uart_get_baud_rate (uport , termios , old , 300 , 8000000 );
1322
+ unsigned int clk_div ;
1323
+ u32 ver , sampling_rate ;
1324
+ u32 ser_clk_cfg ;
1338
1325
1339
1326
sampling_rate = UART_OVERSAMPLING ;
1340
1327
/* Sampling rate is halved for IP versions >= 2.5 */
@@ -1348,7 +1335,7 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
1348
1335
dev_err (port -> se .dev ,
1349
1336
"Couldn't find suitable clock rate for %u\n" ,
1350
1337
baud * sampling_rate );
1351
- return ;
1338
+ return - EINVAL ;
1352
1339
}
1353
1340
1354
1341
dev_dbg (port -> se .dev , "desired_rate = %u, clk_rate = %lu, clk_div = %u\n" ,
@@ -1370,6 +1357,33 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
1370
1357
port -> se .icc_paths [CPU_TO_GENI ].avg_bw = Bps_to_icc (baud );
1371
1358
geni_icc_set_bw (& port -> se );
1372
1359
1360
+ writel (ser_clk_cfg , uport -> membase + GENI_SER_M_CLK_CFG );
1361
+ writel (ser_clk_cfg , uport -> membase + GENI_SER_S_CLK_CFG );
1362
+ return 0 ;
1363
+ }
1364
+
1365
+ static void qcom_geni_serial_set_termios (struct uart_port * uport ,
1366
+ struct ktermios * termios ,
1367
+ const struct ktermios * old )
1368
+ {
1369
+ struct qcom_geni_serial_port * port = to_dev_port (uport );
1370
+ unsigned int baud ;
1371
+ unsigned long timeout ;
1372
+ u32 bits_per_char ;
1373
+ u32 tx_trans_cfg ;
1374
+ u32 tx_parity_cfg ;
1375
+ u32 rx_trans_cfg ;
1376
+ u32 rx_parity_cfg ;
1377
+ u32 stop_bit_len ;
1378
+ int ret = 0 ;
1379
+
1380
+ /* baud rate */
1381
+ baud = uart_get_baud_rate (uport , termios , old , 300 , 8000000 );
1382
+
1383
+ ret = geni_serial_set_rate (uport , baud );
1384
+ if (ret )
1385
+ return ;
1386
+
1373
1387
/* parity */
1374
1388
tx_trans_cfg = readl (uport -> membase + SE_UART_TX_TRANS_CFG );
1375
1389
tx_parity_cfg = readl (uport -> membase + SE_UART_TX_PARITY_CFG );
@@ -1437,8 +1451,6 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
1437
1451
writel (bits_per_char , uport -> membase + SE_UART_TX_WORD_LEN );
1438
1452
writel (bits_per_char , uport -> membase + SE_UART_RX_WORD_LEN );
1439
1453
writel (stop_bit_len , uport -> membase + SE_UART_TX_STOP_BIT_LEN );
1440
- writel (ser_clk_cfg , uport -> membase + GENI_SER_M_CLK_CFG );
1441
- writel (ser_clk_cfg , uport -> membase + GENI_SER_S_CLK_CFG );
1442
1454
}
1443
1455
1444
1456
#ifdef CONFIG_SERIAL_QCOM_GENI_CONSOLE
0 commit comments