void uart_setbrg() { unsigned int byte,speed; unsigned int highspeed; unsigned int quot, divisor, remainder; unsigned int uartclk; unsigned short data, high_speed_div, sample_count, sample_point; unsigned int tmp_div; speed = g_brg; uartclk = (unsigned int)(mt6575_get_bus_freq()*1000/4); if (speed <= 115200 ) { highspeed = 0; quot = 16; } else { highspeed = 3; quot = 1; } if (highspeed < 3) { /*0~2*/ /* Set divisor DLL and DLH */ divisor = uartclk / (quot * speed); remainder = uartclk % (quot * speed); if (remainder >= (quot / 2) * speed) divisor += 1; DRV_WriteReg16(UART_HIGHSPEED(g_uart),highspeed); byte = DRV_Reg32(UART_LCR(g_uart)); /* DLAB start */ DRV_WriteReg32( UART_LCR(g_uart),(byte | UART_LCR_DLAB)); DRV_WriteReg32( UART_DLL(g_uart),(divisor & 0x00ff)); DRV_WriteReg32( UART_DLH(g_uart),((divisor >> 8)&0x00ff)); DRV_WriteReg32( UART_LCR(g_uart),byte); /* DLAB end */ }
void serial_setbrg() { unsigned int byte,speed; unsigned int highspeed; unsigned int quot, divisor, remainder; //unsigned int ratefix; unsigned int uartclk; //unsigned int highclk = (UART_SRC_CLK/(speed*4)) > 10 ? (1) : 0; unsigned short data, high_speed_div, sample_count, sample_point; unsigned int tmp_div; speed = g_brg; //uartclk = UART_SRC_CLK; uartclk = (unsigned int)(mt6575_get_bus_freq()*1000/4); if (speed <= 115200 ) { highspeed = 0; quot = 16; } else { highspeed = 3; quot = 1; } if (highspeed < 3) { /*0~2*/ /* Set divisor DLL and DLH */ divisor = uartclk / (quot * speed); remainder = uartclk % (quot * speed); if (remainder >= (quot / 2) * speed) divisor += 1; UART_WRITE16(highspeed, UART_HIGHSPEED(g_uart)); byte = UART_READ32(UART_LCR(g_uart)); /* DLAB start */ UART_WRITE32((byte | UART_LCR_DLAB), UART_LCR(g_uart)); UART_WRITE32((divisor & 0x00ff), UART_DLL(g_uart)); UART_WRITE32(((divisor >> 8)&0x00ff), UART_DLH(g_uart)); UART_WRITE32(byte, UART_LCR(g_uart)); /* DLAB end */ } else {