/* Initialize the serial port with the given baudrate. The settings are always 8 data bits, no parity, 1 stop bit, no start bits.  */
static int pic32_serial_init(void __iomem *base, ulong clk, u32 baudrate)
/* Initialize the serial port with the given baudrate. The settings are always 8 data bits, no parity, 1 stop bit, no start bits.  */
static int pic32_serial_init(void __iomem *base, ulong clk, u32 baudrate)
{
	u32 div = DIV_ROUND_CLOSEST(clk, baudrate * 16);
	wait_for_bit_le32(base + U_STA, UART_TX_EMPTY,
			  true, CONFIG_SYS_HZ, false);
	writel(UART_TX_BRK, base + U_STASET);
	writel(0, base + U_MOD);
	writel(0, base + U_STA);
	writel(div - 1, base + U_BRG);
	writel(UART_TX_ENABLE | UART_RX_ENABLE, base + U_STASET);
	writel(UART_ENABLE, base + U_MODSET);
	return 0;
}