diff --git a/c/src/libchip/serial/README.ns16550 b/c/src/libchip/serial/README.ns16550 index 2956173b1b..9b49d6794b 100644 --- a/c/src/libchip/serial/README.ns16550 +++ b/c/src/libchip/serial/README.ns16550 @@ -2,4 +2,94 @@ # $Id$ # -This driver needs to be debugged before this is written. +Status +====== + +This driver appears to work OK for polled output at this point. + +It needs to be tested for: + + + polled input + + interrupt driver output + + interrupt driver input + +This driver does not support the new style RTEMS interrupt processing +used on the i386 and some PowerPC models. + +Configuration Table Use +======================= + +sDeviceName + + The name of this device. + +deviceType + + This field must be SERIAL_NS16550. + +pDeviceFns + + The device interface control table. This may be: + + ns16550_fns for interrupt driven IO + + ns16550_fns_polled for polled IO + +deviceProbe + + This is the address of the routine which probes to see if the device + is present. + +pDeviceFlow + + This field is ignored as hardware flow control is not currently supported. + +ulMargin + + This is currently unused. + +ulHysteresis + + This is currently unused. + +pDeviceParams + + This is set to the default settings. At this point, it is the default + baud rate cast as a (void *). + +ulCtrlPort1 + + This field is the base address of this port on the UART. + +ulCtrlPort2 + + This field is unused for the NS16550. + +ulDataPort + + This field is the base address of this port on the UART. + +getRegister +setRegister + + These follow standard conventions. + +getData +setData + + These are unused since the TX and RX data registers can be accessed + as regular registers. + +ulClock + + This is the clock constant which is divided by the desired baud + to get the value programmed into the part. The formula for this + for 9600 baud is: + + chip_divisor_value = ulClock / 9600. + + NOTE: When ulClock is 0, the correct value for a PC (115,200) is + used. + +ulIntVector + + This is the interrupt vector number associated with this chip. + diff --git a/c/src/libchip/serial/STATUS b/c/src/libchip/serial/STATUS index 6eb7fa4171..f9874d9a9e 100644 --- a/c/src/libchip/serial/STATUS +++ b/c/src/libchip/serial/STATUS @@ -37,12 +37,6 @@ MC68681 NS16650 ======= -+ Not tested in libchip context. Based on Radstone PPC2 driver which worked - well. - -+ Interrupt code has been reworked to not use ring buffer and may be broken - as it has not been tested since this was done. - + ns16550_set-attributes function is untested. + Hardware flow control included but is currently disabled in ISR. diff --git a/c/src/libchip/serial/ns16550.c b/c/src/libchip/serial/ns16550.c index af044eca91..d55bc65b14 100644 --- a/c/src/libchip/serial/ns16550.c +++ b/c/src/libchip/serial/ns16550.c @@ -102,7 +102,10 @@ NS16550_STATIC void ns16550_init(int minor) /* Set the divisor latch and set the baud rate. */ - ulBaudDivisor=NS16550_Baud((unsigned32)Console_Port_Tbl[minor].pDeviceParams); + ulBaudDivisor = NS16550_Baud( + (unsigned32) Console_Port_Tbl[minor].ulClock, + (unsigned32) Console_Port_Tbl[minor].pDeviceParams + ); ucDataByte = SP_LINE_DLAB; (*setReg)(pNS16550, NS16550_LINE_CONTROL, ucDataByte); @@ -363,7 +366,10 @@ NS16550_STATIC int ns16550_set_attributes( if (!baud_requested) baud_requested = B9600; /* default to 9600 baud */ - ulBaudDivisor = NS16550_Baud(termios_baud_to_number(baud_requested)); + ulBaudDivisor = NS16550_Baud( + (unsigned32) Console_Port_Tbl[minor].ulClock, + termios_baud_to_number(baud_requested) + ); ucLineControl = 0; diff --git a/c/src/libchip/serial/ns16550_p.h b/c/src/libchip/serial/ns16550_p.h index 27c3502a0d..6ed71d9c8b 100644 --- a/c/src/libchip/serial/ns16550_p.h +++ b/c/src/libchip/serial/ns16550_p.h @@ -132,7 +132,8 @@ typedef struct _SP_INTERRUPT_ID { * Line speed divisor definition. */ -#define NS16550_Baud(baud_rate) (115200/baud_rate) +#define NS16550_Baud(_clock, _baud_rate) \ + ((((_clock) == 0) ? 115200 : (_clock))/(_baud_rate)) /* * Define serial port modem control register structure.