diff options
author | Qipan Li <Qipan.Li@csr.com> | 2013-08-25 08:18:40 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-27 19:25:44 -0400 |
commit | 459f15c45eee9136c3ceb7d9c1f88d5f2f225689 (patch) | |
tree | 0f3c0517ec348f2b59af699ec20fc67a0ae3b732 /drivers/tty | |
parent | 4f03ffcd3e8a8860c9adc153f03bf2ed7d428f2b (diff) |
serial: sirf: define macro for some magic numbers of USP
this patch clears some magic numbers for offset and bitshift
of USP registers.
Signed-off-by: Qipan Li <Qipan.Li@csr.com>
Signed-off-by: Barry Song <Baohua.Song@csr.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/serial/sirfsoc_uart.c | 37 | ||||
-rw-r--r-- | drivers/tty/serial/sirfsoc_uart.h | 15 |
2 files changed, 37 insertions, 15 deletions
diff --git a/drivers/tty/serial/sirfsoc_uart.c b/drivers/tty/serial/sirfsoc_uart.c index 96304cdc4745..aaa3ce22b5b8 100644 --- a/drivers/tty/serial/sirfsoc_uart.c +++ b/drivers/tty/serial/sirfsoc_uart.c | |||
@@ -951,11 +951,11 @@ static void sirfsoc_uart_set_termios(struct uart_port *port, | |||
951 | set_baud = ((ioclk_rate / (clk_div_reg+1) - 1) / | 951 | set_baud = ((ioclk_rate / (clk_div_reg+1) - 1) / |
952 | (sample_div_reg + 1)); | 952 | (sample_div_reg + 1)); |
953 | /* setting usp mode 2 */ | 953 | /* setting usp mode 2 */ |
954 | len_val = ((1 << 0) | (1 << 8)); | 954 | len_val = ((1 << SIRFSOC_USP_MODE2_RXD_DELAY_OFFSET) | |
955 | len_val |= ((clk_div_reg & 0x3ff) << 21); | 955 | (1 << SIRFSOC_USP_MODE2_TXD_DELAY_OFFSET)); |
956 | wr_regl(port, ureg->sirfsoc_mode2, | 956 | len_val |= ((clk_div_reg & SIRFSOC_USP_MODE2_CLK_DIVISOR_MASK) |
957 | len_val); | 957 | << SIRFSOC_USP_MODE2_CLK_DIVISOR_OFFSET); |
958 | 958 | wr_regl(port, ureg->sirfsoc_mode2, len_val); | |
959 | } | 959 | } |
960 | if (tty_termios_baud_rate(termios)) | 960 | if (tty_termios_baud_rate(termios)) |
961 | tty_termios_encode_baud_rate(termios, set_baud, set_baud); | 961 | tty_termios_encode_baud_rate(termios, set_baud, set_baud); |
@@ -963,7 +963,7 @@ static void sirfsoc_uart_set_termios(struct uart_port *port, | |||
963 | rx_time_out = SIRFSOC_UART_RX_TIMEOUT(set_baud, 20000); | 963 | rx_time_out = SIRFSOC_UART_RX_TIMEOUT(set_baud, 20000); |
964 | rx_time_out = SIRFUART_RECV_TIMEOUT_VALUE(rx_time_out); | 964 | rx_time_out = SIRFUART_RECV_TIMEOUT_VALUE(rx_time_out); |
965 | txfifo_op_reg = rd_regl(port, ureg->sirfsoc_tx_fifo_op); | 965 | txfifo_op_reg = rd_regl(port, ureg->sirfsoc_tx_fifo_op); |
966 | wr_regl(port, ureg->sirfsoc_rx_fifo_op, 0); | 966 | wr_regl(port, ureg->sirfsoc_rx_fifo_op, SIRFUART_FIFO_STOP); |
967 | wr_regl(port, ureg->sirfsoc_tx_fifo_op, | 967 | wr_regl(port, ureg->sirfsoc_tx_fifo_op, |
968 | (txfifo_op_reg & ~SIRFUART_FIFO_START)); | 968 | (txfifo_op_reg & ~SIRFUART_FIFO_START)); |
969 | if (sirfport->uart_reg->uart_type == SIRF_REAL_UART) { | 969 | if (sirfport->uart_reg->uart_type == SIRF_REAL_UART) { |
@@ -971,21 +971,28 @@ static void sirfsoc_uart_set_termios(struct uart_port *port, | |||
971 | wr_regl(port, ureg->sirfsoc_line_ctrl, config_reg); | 971 | wr_regl(port, ureg->sirfsoc_line_ctrl, config_reg); |
972 | } else { | 972 | } else { |
973 | /*tx frame ctrl*/ | 973 | /*tx frame ctrl*/ |
974 | len_val = (data_bit_len - 1) << 0; | 974 | len_val = (data_bit_len - 1) << SIRFSOC_USP_TX_DATA_LEN_OFFSET; |
975 | len_val |= (data_bit_len + 1 + stop_bit_len - 1) << 16; | 975 | len_val |= (data_bit_len + 1 + stop_bit_len - 1) << |
976 | len_val |= ((data_bit_len - 1) << 24); | 976 | SIRFSOC_USP_TX_FRAME_LEN_OFFSET; |
977 | len_val |= (((clk_div_reg & 0xc00) >> 10) << 30); | 977 | len_val |= ((data_bit_len - 1) << |
978 | SIRFSOC_USP_TX_SHIFTER_LEN_OFFSET); | ||
979 | len_val |= (((clk_div_reg & 0xc00) >> 10) << | ||
980 | SIRFSOC_USP_TX_CLK_DIVISOR_OFFSET); | ||
978 | wr_regl(port, ureg->sirfsoc_tx_frame_ctrl, len_val); | 981 | wr_regl(port, ureg->sirfsoc_tx_frame_ctrl, len_val); |
979 | /*rx frame ctrl*/ | 982 | /*rx frame ctrl*/ |
980 | len_val = (data_bit_len - 1) << 0; | 983 | len_val = (data_bit_len - 1) << SIRFSOC_USP_RX_DATA_LEN_OFFSET; |
981 | len_val |= (data_bit_len + 1 + stop_bit_len - 1) << 8; | 984 | len_val |= (data_bit_len + 1 + stop_bit_len - 1) << |
982 | len_val |= (data_bit_len - 1) << 16; | 985 | SIRFSOC_USP_RX_FRAME_LEN_OFFSET; |
983 | len_val |= (((clk_div_reg & 0xf000) >> 12) << 24); | 986 | len_val |= (data_bit_len - 1) << |
987 | SIRFSOC_USP_RX_SHIFTER_LEN_OFFSET; | ||
988 | len_val |= (((clk_div_reg & 0xf000) >> 12) << | ||
989 | SIRFSOC_USP_RX_CLK_DIVISOR_OFFSET); | ||
984 | wr_regl(port, ureg->sirfsoc_rx_frame_ctrl, len_val); | 990 | wr_regl(port, ureg->sirfsoc_rx_frame_ctrl, len_val); |
985 | /*async param*/ | 991 | /*async param*/ |
986 | wr_regl(port, ureg->sirfsoc_async_param_reg, | 992 | wr_regl(port, ureg->sirfsoc_async_param_reg, |
987 | (SIRFUART_RECV_TIMEOUT(port, rx_time_out)) | | 993 | (SIRFUART_RECV_TIMEOUT(port, rx_time_out)) | |
988 | (sample_div_reg & 0x3f) << 16); | 994 | (sample_div_reg & SIRFSOC_USP_ASYNC_DIV2_MASK) << |
995 | SIRFSOC_USP_ASYNC_DIV2_OFFSET); | ||
989 | } | 996 | } |
990 | if (IS_DMA_CHAN_VALID(sirfport->tx_dma_no)) | 997 | if (IS_DMA_CHAN_VALID(sirfport->tx_dma_no)) |
991 | wr_regl(port, ureg->sirfsoc_tx_dma_io_ctrl, SIRFUART_DMA_MODE); | 998 | wr_regl(port, ureg->sirfsoc_tx_dma_io_ctrl, SIRFUART_DMA_MODE); |
diff --git a/drivers/tty/serial/sirfsoc_uart.h b/drivers/tty/serial/sirfsoc_uart.h index 173e00f84c67..c43333dfab4a 100644 --- a/drivers/tty/serial/sirfsoc_uart.h +++ b/drivers/tty/serial/sirfsoc_uart.h | |||
@@ -311,6 +311,21 @@ struct sirfsoc_uart_register sirfsoc_uart = { | |||
311 | /* USP SPEC */ | 311 | /* USP SPEC */ |
312 | #define SIRFSOC_USP_ENDIAN_CTRL_LSBF BIT(4) | 312 | #define SIRFSOC_USP_ENDIAN_CTRL_LSBF BIT(4) |
313 | #define SIRFSOC_USP_EN BIT(5) | 313 | #define SIRFSOC_USP_EN BIT(5) |
314 | #define SIRFSOC_USP_MODE2_RXD_DELAY_OFFSET 0 | ||
315 | #define SIRFSOC_USP_MODE2_TXD_DELAY_OFFSET 8 | ||
316 | #define SIRFSOC_USP_MODE2_CLK_DIVISOR_MASK 0x3ff | ||
317 | #define SIRFSOC_USP_MODE2_CLK_DIVISOR_OFFSET 21 | ||
318 | #define SIRFSOC_USP_TX_DATA_LEN_OFFSET 0 | ||
319 | #define SIRFSOC_USP_TX_SYNC_LEN_OFFSET 8 | ||
320 | #define SIRFSOC_USP_TX_FRAME_LEN_OFFSET 16 | ||
321 | #define SIRFSOC_USP_TX_SHIFTER_LEN_OFFSET 24 | ||
322 | #define SIRFSOC_USP_TX_CLK_DIVISOR_OFFSET 30 | ||
323 | #define SIRFSOC_USP_RX_DATA_LEN_OFFSET 0 | ||
324 | #define SIRFSOC_USP_RX_FRAME_LEN_OFFSET 8 | ||
325 | #define SIRFSOC_USP_RX_SHIFTER_LEN_OFFSET 16 | ||
326 | #define SIRFSOC_USP_RX_CLK_DIVISOR_OFFSET 24 | ||
327 | #define SIRFSOC_USP_ASYNC_DIV2_MASK 0x3f | ||
328 | #define SIRFSOC_USP_ASYNC_DIV2_OFFSET 16 | ||
314 | 329 | ||
315 | /* USP-UART Common */ | 330 | /* USP-UART Common */ |
316 | #define SIRFSOC_UART_RX_TIMEOUT(br, to) (((br) * (((to) + 999) / 1000)) / 1000) | 331 | #define SIRFSOC_UART_RX_TIMEOUT(br, to) (((br) * (((to) + 999) / 1000)) / 1000) |