From: Vladimir 'phcoder' Serbinenko Date: Sun, 18 Jul 2010 13:00:50 +0000 (+0200) Subject: Support variable speed X-Git-Tag: 1.99~654^2~29 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=91d135a12c6be53cd67f9b45b7c4d9c6f957aea7;p=thirdparty%2Fgrub.git Support variable speed --- diff --git a/term/ns8250.c b/term/ns8250.c index a69c683f2..9677913be 100644 --- a/term/ns8250.c +++ b/term/ns8250.c @@ -61,7 +61,7 @@ serial_get_divisor (unsigned int speed) }; /* Set the baud rate. */ - for (i = 0; i < sizeof (divisor_tab) / sizeof (divisor_tab[0]); i++) + for (i = 0; i < ARRAY_SIZE (divisor_tab); i++) if (divisor_tab[i].speed == speed) /* UART in Yeeloong runs twice the usual rate. */ #ifdef GRUB_MACHINE_MIPS_YEELOONG diff --git a/term/usbserial.c b/term/usbserial.c index b2a89d56c..7a5aead2c 100644 --- a/term/usbserial.c +++ b/term/usbserial.c @@ -48,13 +48,20 @@ get_divisor (unsigned int speed) }; /* The table which lists common configurations. */ + /* Computed with a division formula with 3MHz as base frequency. */ static struct divisor divisor_tab[] = { + { 2400, 0x04e2 }, + { 4800, 0x0271 }, { 9600, 0x4138 }, + { 19200, 0x809c }, + { 38400, 0xc04e }, + { 57600, 0xc034 }, + { 115200, 0x001a } }; /* Set the baud rate. */ - for (i = 0; i < sizeof (divisor_tab) / sizeof (divisor_tab[0]); i++) + for (i = 0; i < ARRAY_SIZE (divisor_tab); i++) if (divisor_tab[i].speed == speed) return divisor_tab[i].div; return 0;