@@ -1314,27 +1314,14 @@ static unsigned long get_clk_div_rate(struct clk *clk, unsigned int baud,
13141314 return ser_clk ;
13151315}
13161316
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 )
13201318{
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 ;
13301319 struct qcom_geni_serial_port * port = to_dev_port (uport );
13311320 unsigned long clk_rate ;
1332- u32 ver , sampling_rate ;
13331321 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 ;
13381325
13391326 sampling_rate = UART_OVERSAMPLING ;
13401327 /* Sampling rate is halved for IP versions >= 2.5 */
@@ -1348,7 +1335,7 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
13481335 dev_err (port -> se .dev ,
13491336 "Couldn't find suitable clock rate for %u\n" ,
13501337 baud * sampling_rate );
1351- return ;
1338+ return - EINVAL ;
13521339 }
13531340
13541341 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,
13701357 port -> se .icc_paths [CPU_TO_GENI ].avg_bw = Bps_to_icc (baud );
13711358 geni_icc_set_bw (& port -> se );
13721359
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+
13731387 /* parity */
13741388 tx_trans_cfg = readl (uport -> membase + SE_UART_TX_TRANS_CFG );
13751389 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,
14371451 writel (bits_per_char , uport -> membase + SE_UART_TX_WORD_LEN );
14381452 writel (bits_per_char , uport -> membase + SE_UART_RX_WORD_LEN );
14391453 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 );
14421454}
14431455
14441456#ifdef CONFIG_SERIAL_QCOM_GENI_CONSOLE
0 commit comments