MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mtk_uart_init

Function mtk_uart_init

freebsd/mips/mediatek/uart_dev_mtk.c:94–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94static void
95mtk_uart_init(struct uart_bas *bas, int baudrate, int databits,
96 int stopbits, int parity)
97{
98 /* CLKDIV = 384000000/ 3/ 16/ br */
99 /* for 384MHz CLKDIV = 8000000 / baudrate; */
100 switch (databits) {
101 case 5:
102 databits = UART_LCR_5B;
103 break;
104 case 6:
105 databits = UART_LCR_6B;
106 break;
107 case 7:
108 databits = UART_LCR_7B;
109 break;
110 case 8:
111 databits = UART_LCR_8B;
112 break;
113 default:
114 /* Unsupported */
115 return;
116 }
117 switch (parity) {
118 case UART_PARITY_EVEN: parity = (UART_LCR_PEN|UART_LCR_EVEN); break;
119 case UART_PARITY_ODD: parity = (UART_LCR_PEN); break;
120 case UART_PARITY_NONE: parity = 0; break;
121 /* Unsupported */
122 default: return;
123 }
124
125 if (bas->rclk && baudrate) {
126 uart_setreg(bas, UART_CDDL_REG, bas->rclk/16/baudrate);
127 uart_barrier(bas);
128 }
129
130 uart_setreg(bas, UART_LCR_REG, databits |
131 (stopbits==1?0:UART_LCR_STB_15) |
132 parity);
133 uart_barrier(bas);
134}
135
136static void
137mtk_uart_term(struct uart_bas *bas)

Callers 2

mtk_uart_bus_attachFunction · 0.85
mtk_uart_bus_paramFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected