From df49c60c9671e4a28e636964d744c1f59fb6cb68 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 12 Jun 2000 15:00:15 +0000 Subject: Merged from 4.5.0-beta3a --- c/src/libchip/network/Makefile.am | 4 +- c/src/libchip/network/README.dec21140 | 7 ++- c/src/libchip/network/dec21140.c | 64 ++++++++++++++++++------ c/src/libchip/rtc/Makefile.am | 16 +++--- c/src/libchip/serial/Makefile.am | 18 +++---- c/src/libchip/serial/README.ns16550 | 92 ++++++++++++++++++++++++++++++++++- c/src/libchip/serial/STATUS | 6 --- c/src/libchip/serial/ns16550.c | 10 +++- c/src/libchip/serial/ns16550_p.h | 3 +- 9 files changed, 172 insertions(+), 48 deletions(-) (limited to 'c/src/libchip') diff --git a/c/src/libchip/network/Makefile.am b/c/src/libchip/network/Makefile.am index 55962bdffe..ca22f979c3 100644 --- a/c/src/libchip/network/Makefile.am +++ b/c/src/libchip/network/Makefile.am @@ -1,6 +1,6 @@ -## +## ## $Id$ -## +## AUTOMAKE_OPTIONS = foreign 1.4 diff --git a/c/src/libchip/network/README.dec21140 b/c/src/libchip/network/README.dec21140 index 516bb5fca7..c0548a93ee 100644 --- a/c/src/libchip/network/README.dec21140 +++ b/c/src/libchip/network/README.dec21140 @@ -4,13 +4,16 @@ This TULIP driver can be used on BSPs that support PCI bus. -It can handle any DEC21140 based Ethernet controller. +It can handle any DEC21140 and DEC21143 based Ethernet controller +although the DEC21143 support has only been tested on Intel. It works on big or little endian target. -It has been tested with powerpc/mcp750 BSP (OnBoard Ethernet +The DEC21140 has been tested with powerpc/mcp750 BSP (OnBoard Ethernet controller) and i386/pc386 BSP (D-Link DFE-500TX Ethernet board). +The DEC21143 has been tested only on the i386/pc386 using +the Kingston KNE100TX with 21143PD chip. ***************************************************************** ******** *************** diff --git a/c/src/libchip/network/dec21140.c b/c/src/libchip/network/dec21140.c index 1799c1dec1..683e2bc974 100644 --- a/c/src/libchip/network/dec21140.c +++ b/c/src/libchip/network/dec21140.c @@ -8,6 +8,23 @@ * http://www.OARcorp.com/rtems/license.html. * * $Id$ + * + * ------------------------------------------------------------------------ + * [22.05.2000,StWi/CWA] added support for the DEC/Intel 21143 chip + * + * The 21143 support is (for now) only available for the __i386 target, + * because that's the only testing platform I have. It should (to my best + * knowledge) work in the same way for the "__PPC" target, but someone + * should test this first before it's put into the code. Thanks go to + * Andrew Klossner who provided the vital information about the + * Intel 21143 chip. + * (FWIW: I tested this driver using a Kingston KNE100TX with 21143PD chip) + * + * The driver will automatically detect whether there is a 21140 or 21143 + * network card in the system and activate support accordingly. It will + * look for the 21140 first. If the 21140 is not found the driver will + * look for the 21143. + * ------------------------------------------------------------------------ */ #include @@ -19,11 +36,11 @@ */ #if defined(__i386) -#define DEC21140_SUPPORTED + #define DEC21140_SUPPORTED #endif #if defined(__PPC) && (defined(mpc604) || defined(mpc750)) -#define DEC21140_SUPPORTED + #define DEC21140_SUPPORTED #endif #if defined(DEC21140_SUPPORTED) @@ -70,9 +87,11 @@ #define DEC_DEBUG +/* note: the 21143 isn't really a DEC, it's an Intel chip */ #define PCI_INVALID_VENDORDEVICEID 0xffffffff #define PCI_VENDOR_ID_DEC 0x1011 -#define PCI_DEVICE_ID_DEC_TULIP_FAST 0x0009 +#define PCI_DEVICE_ID_DEC_21140 0x0009 +#define PCI_DEVICE_ID_DEC_21143 0x0019 #define IO_MASK 0x3 #define MEM_MASK 0xF @@ -364,7 +383,7 @@ dec21140Enet_initialize_hardware (struct dec21140_softc *sc) st_le32( (tbase+memCSR0), CSR0_MODE); #ifdef DEC_DEBUG - printk("DC21140 %x:%x:%x:%x:%x:%x IRQ %d IO %x M %x .........\n", + printk("DC2114x %x:%x:%x:%x:%x:%x IRQ %d IO %x M %x .........\n", sc->arpcom.ac_enaddr[0], sc->arpcom.ac_enaddr[1], sc->arpcom.ac_enaddr[2], sc->arpcom.ac_enaddr[3], sc->arpcom.ac_enaddr[4], sc->arpcom.ac_enaddr[5], @@ -757,6 +776,7 @@ rtems_dec21140_driver_attach (struct rtems_bsdnet_ifconfig *config) struct ifnet *ifp; int mtu; int i; + int deviceId = PCI_DEVICE_ID_DEC_21140; /* network card device ID */ /* * First, find a DEC board @@ -771,16 +791,24 @@ rtems_dec21140_driver_attach (struct rtems_bsdnet_ifconfig *config) rtems_panic("PCI BIOS not found !!"); /* - * First, find a DEC board + * Try to find the network card on the PCI bus. Probe for a DEC 21140 + * card first. If not found probe the bus for a DEC/Intel 21143 card. */ - if ((diag = pcib_find_by_devid(PCI_VENDOR_ID_DEC, - PCI_DEVICE_ID_DEC_TULIP_FAST, - 0, - &signature)) != PCIB_ERR_SUCCESS) - rtems_panic("DEC PCI board not found !! (%d)\n", diag); - else { - printk("DEC PCI Device found\n"); - } + deviceId = PCI_DEVICE_ID_DEC_21140; + diag = pcib_find_by_devid( PCI_VENDOR_ID_DEC, deviceId, + 0, &signature); + if ( diag == PCIB_ERR_SUCCESS) + printk( "DEC 21140 PCI network card found\n" ); + else + { + deviceId = PCI_DEVICE_ID_DEC_21143; + diag = pcib_find_by_devid( PCI_VENDOR_ID_DEC, deviceId, + 0, &signature); + if ( diag == PCIB_ERR_SUCCESS) + printk( "DEC/Intel 21143 PCI network card found\n" ); + else + rtems_panic("DEC PCI network card not found !!\n"); + } #endif #if defined(__PPC) unsigned char ucSlotNumber, ucFnNumber; @@ -800,10 +828,10 @@ rtems_dec21140_driver_attach (struct rtems_bsdnet_ifconfig *config) */ continue; } - if (ulDeviceID == ((PCI_DEVICE_ID_DEC_TULIP_FAST<<16) + PCI_VENDOR_ID_DEC)) + if (ulDeviceID == ((PCI_DEVICE_ID_DEC_21140<<16) + PCI_VENDOR_ID_DEC)) break; } - if (ulDeviceID == ((PCI_DEVICE_ID_DEC_TULIP_FAST<<16) + PCI_VENDOR_ID_DEC)){ + if (ulDeviceID == ((PCI_DEVICE_ID_DEC_21140<<16) + PCI_VENDOR_ID_DEC)){ printk("DEC Adapter found !!\n"); break; } @@ -830,6 +858,11 @@ rtems_dec21140_driver_attach (struct rtems_bsdnet_ifconfig *config) * Process options */ #if defined(__i386) + + /* the 21143 chip must be enabled before it can be accessed */ + if ( deviceId == PCI_DEVICE_ID_DEC_21143 ) + pcib_conf_write32( signature, 0x40, 0 ); + pcib_conf_read32(signature, 16, &value); sc->port = value & ~IO_MASK; @@ -922,6 +955,7 @@ rtems_dec21140_driver_attach (struct rtems_bsdnet_ifconfig *config) if_attach (ifp); ether_ifattach (ifp); + printk( "DC2114x : driver has been attached\n" ); return 1; }; #endif /* DEC21140_SUPPORTED */ diff --git a/c/src/libchip/rtc/Makefile.am b/c/src/libchip/rtc/Makefile.am index c2ec59470d..2419c2560c 100644 --- a/c/src/libchip/rtc/Makefile.am +++ b/c/src/libchip/rtc/Makefile.am @@ -8,7 +8,8 @@ LIBNAME = librtcio LIB = ${ARCH}/${LIBNAME}.a C_FILES = rtcprobe.c icm7170.c icm7170_reg.c icm7170_reg2.c icm7170_reg4.c \ - icm7170_reg8.c m48t08.c m48t08_reg.c m48t08_reg2.c m48t08_reg4.c m48t08_reg8.c + icm7170_reg8.c m48t08.c m48t08_reg.c m48t08_reg2.c m48t08_reg4.c \ + m48t08_reg8.c C_O_FILES = $(C_FILES:%.c=${ARCH}/%.o) @@ -20,12 +21,10 @@ OBJS = $(C_O_FILES) include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg include $(top_srcdir)/../../../automake/lib.am -PREINSTALL_FILES = \ -$(PROJECT_INCLUDE)/libchip \ -$(noinst_HEADERS:%=$(PROJECT_INCLUDE)/libchip/%) +PREINSTALL_FILES += $(PROJECT_INCLUDE)/libchip \ + $(noinst_HEADERS:%=$(PROJECT_INCLUDE)/libchip/%) -TMPINSTALL_FILES += \ -$(PROJECT_RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a +TMPINSTALL_FILES += $(PROJECT_RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a $(PROJECT_INCLUDE)/libchip: @$(mkinstalldirs) $@ @@ -44,10 +43,9 @@ $(LIB): ${OBJS} $(PROJECT_RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a: $(LIB) $(INSTALL_DATA) $< $@ -all: ${ARCH} $(PREINSTALL_FILES) $(TMPINSTALL_FILES) +all-local: ${ARCH} $(PREINSTALL_FILES) $(TMPINSTALL_FILES) -DOC_FILES = \ -README.ds1643 README.icm7170 README.m48t08 README.m48t18 STATUS +DOC_FILES = README.ds1643 README.icm7170 README.m48t08 README.m48t18 STATUS EXTRA_DIST = $(C_FILES) $(DOC_FILES) diff --git a/c/src/libchip/serial/Makefile.am b/c/src/libchip/serial/Makefile.am index 3e860df828..1333ea22d7 100644 --- a/c/src/libchip/serial/Makefile.am +++ b/c/src/libchip/serial/Makefile.am @@ -8,8 +8,8 @@ LIBNAME = libserialio LIB = ${ARCH}/${LIBNAME}.a C_FILES = mc68681.c mc68681_baud.c mc68681_reg.c mc68681_reg2.c \ - mc68681_reg4.c mc68681_reg8.c ns16550.c z85c30.c z85c30_reg.c \ - serprobe.c termios_baud2index.c termios_baud2num.c + mc68681_reg4.c mc68681_reg8.c ns16550.c z85c30.c z85c30_reg.c serprobe.c \ + termios_baud2index.c termios_baud2num.c C_O_FILES = $(C_FILES:%.c=${ARCH}/%.o) H_FILES = mc68681_p.h ns16550_p.h sersupp.h z85c30_p.h @@ -21,12 +21,10 @@ OBJS = $(C_O_FILES) include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg include $(top_srcdir)/../../../automake/lib.am -PREINSTALL_FILES = \ -$(PROJECT_INCLUDE)/libchip \ -$(INSTALLED_H_FILES:%=$(PROJECT_INCLUDE)/libchip/%) +PREINSTALL_FILES += $(PROJECT_INCLUDE)/libchip \ + $(INSTALLED_H_FILES:%=$(PROJECT_INCLUDE)/libchip/%) -TMPINSTALL_FILES += \ -$(PROJECT_RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a +TMPINSTALL_FILES += $(PROJECT_RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a $(PROJECT_INCLUDE)/libchip: @$(mkinstalldirs) $@ @@ -45,10 +43,10 @@ $(LIB): ${OBJS} $(PROJECT_RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a: $(LIB) $(INSTALL_DATA) $< $@ -all: ${ARCH} $(PREINSTALL_FILES) $(TMPINSTALL_FILES) +all-local: ${ARCH} $(PREINSTALL_FILES) $(TMPINSTALL_FILES) -DOC_FILES = \ -README.mc68681 README.ns16550 README.xr88681 README.z85c30 STATUS +DOC_FILES = README.mc68681 README.ns16550 README.xr88681 README.z85c30 \ + STATUS EXTRA_DIST = $(C_FILES) $(DOC_FILES) 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. -- cgit v1.2.3