/* Convert speed to divisor. */
static unsigned short
-serial_get_divisor (unsigned int speed)
+serial_get_divisor (const struct grub_serial_port *port,
+ const struct grub_serial_config *config)
{
unsigned int i;
/* Set the baud rate. */
for (i = 0; i < ARRAY_SIZE (divisor_tab); i++)
- if (divisor_tab[i].speed == speed)
- /* UART in Yeeloong runs twice the usual rate. */
+ if (divisor_tab[i].speed == config->speed)
+ {
+ /* internal UART in Yeeloong runs twice the usual rate. */
#ifdef GRUB_MACHINE_MIPS_YEELOONG
- return 2 * divisor_tab[i].div;
-#else
- return divisor_tab[i].div;
+ if (port->port == 0xbff003f8)
+ return 2 * divisor_tab[i].div;
+ else
#endif
+ return divisor_tab[i].div;
+ }
return 0;
}
port->broken = 0;
- divisor = serial_get_divisor (port->config.speed);
+ divisor = serial_get_divisor (port, &port->config);
/* Turn off the interrupt. */
grub_outb (0, port->port + UART_IER);
{
unsigned short divisor;
- divisor = serial_get_divisor (config->speed);
+ divisor = serial_get_divisor (port, config);
if (divisor == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "bad speed");