📄 smcfdc37b78x.c
字号:
/* smcFdc37b78x.c - a superIO (fdc37b78x) initialization source module *//* Copyright 1984-2000 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01a,28mar00,ms written.*//*DESCRIPTIONThe FDC37B78x with advanced Consumer IR and IrDA v1.0 support incorporates akeyboard interface, real-time clock, SMSC's true CMOS 765B floppy diskcontroller, advanced digital data separator, 16 byte data FIFO, two 16C550compatible UARTs, one Multi-Mode parallel port which includes ChiProtectcircuitry plus EPP and ECP support, on-chip 12 mA AT bus drivers, and twofloppy direct drive support, soft power management and SMI support andIntelligent Power Management including PME and SCI/ACPI support. The trueCMOS 765B core provides 100% compatibility with IBM PC/XT and PC/ATarchitectures in addition to providing data overflow and underflow protection.The SMSC advanced digital data separator incorporates SMSC's patented dataseparator technology, allowing for ease of testing and use. Both on-chip UARTsare compatible with the NS16C550. The parallel port, the IDE interface, andthe game port select logic are compatible with IBM PC/AT architecture,as well as EPP and ECP.The FDC37B78x incorporates sophisticated power control circuitry (PCC) whichincludes support for keyboard, mouse, modem ring, power button support andconsumer infrared wake-up events. The PCC supports multiple low power downmodes.The FDC37B78x provides features for compliance with the "Advanced Configurationand Power Interface Specification" (ACPI). These features include support ofboth legacy and ACPI power management models through the selection of SMI orSCI. It implements a power button override event (4 second button hold to turnoff the system) and either edge triggered interrupts.The FDC37B78x provides support for the ISA Plug-and-Play Standard (Version 1.0a)and provides for the recommended functionality to support Windows95, PC97 andPC98. Through internal configuration registers, each of the FDC37B78x'slogical device's I/O address, DMA channel and IRQ channel may be programmed.There are 480 I/O address location options, 12 IRQ options or Serial IRQ option,and four DMA channel options for each logical device..I USAGEThis library provides routines to intialize various logical devices on superIOchip (fdc37b78x).The functions addressed here include:.IP " -"Creating a logical device and initializing internal database accordingly..IP " -"Enabling as many device as permitted by this facility by single call. Theuser of thie facility can selectively intialize a set of devices on superIOchip..IP " -"Intializing keyboard by sending commands to its controller embedded in superIOchip..LP.I INTERNAL DATABASESThis library provides it's user to changes superIO's config, index, and dataI/O port addresses. The default I/O port addresses are defined intarget/h/drv/smcFdc37b78x.h file. These mnemonics can be overridden by definingin architecture related BSP header file. These default setting can also bechanged on-the-fly by passing in a pointer of type SMCFDC37B78X_IOPORTS withdifferent I/O port addresses. If not redefined, they take their default valuesas defined in smcFdc37b78x.h file..IP "SMCFDC37B78X_CONFIG_PORT"Defines the config I/O port for SMC-FDC37B78X superIO chip..IP "SMCFDC37B78X_INDEX_PORT"Defines the index I/O port for SMC-FDC37B78X superIO chip..IP "SMCFDC37B78X_DATA_PORT"Defines the data I/O port for SMC-FDC37B78X superIO chip..LP.I USER INTERFACE.CSVOID smcFdc37b78xDevCreate ( SMCFDC37B78X_IOPORTS *smcFdc37b78x_iop ).CEThis is a very first routine that should be called by the user of this library.This routine sets up IO port address that will subsequentally be used later on.The IO PORT setting could either be overridden by redefiningSMCFDC37B78X_CONFIG_PORT, SMCFDC37B78X_INDEX_PORT and SMCFDC37B78X_DATA_PORTor on-the-fly by passing in a pointer of type SMCFDC37B78X_IOPORTS..CSVOID smcFdc37b78xInit ( int devInitMask ).CEThis is routine intakes device intialization mask and intializes only thosedevices that are requested by user. Device initialization mask holds bitwiseORed values of all devices that are requested by user to enable on superIOdevice.The mnemonics that are supported in current version of this facility are:.IP "SMCFDC37B78X_COM1_EN"Use this mnemonic to enable COM1 only..IP "SMCFDC37B78X_COM2_EN"Use this mnemonic to enable COM2 only..IP "SMCFDC37B78X_LPT1_EN"Use this mnemonic to enable LPT1 only..IP "SMCFDC37B78X_KBD_EN"Use this mnemonic to enable KBD only..IP "SMCFDC37B78X_FDD_EN"Use this mnemonic to enable FDD only..LPThe above mentioned can be bitwise ORed to enable more than one device ata time. e.g. if you want COM1 and COM2 to be enable on superIO chip call:.CSsmcFdc37b78xInit (SMCFDC37B78X_COM1_EN | SMCFDC37B78X_COM2_EN);.CEThe prerequisites for above mentioned call, superIO chip library should beintialized using smcFdc37b78xDevCreate() with parameter as per user's need..CSSTATUS smcFdc37b78xKbdInit ( VOID ).CEThis routine sends some keyboard commands to keyboard controller embeddedin superIO chip. Call to this function is required for proper functioningof keyboard driver.INCLUDE FILES: smcFdc37b78x.h*//* includes */#include "vxWorks.h"#include "sysLib.h"#include "string.h"#include "drv/multi/smcFdc37b78x.h"/* globals */LOCAL SMCFDC37B78X_IOPORTS smcFdc37b78xIoPorts;LOCAL SMCFDC37B78X_IOPORTS * smcFdc37b78xIopPtr;/********************************************************************************* smcFdc37b78xModReg - modifies I/O port contents** This routine will modify contents of a given I/O port** RETURNS: NONE*/LOCAL VOID smcFdc37b78xModReg ( int ioPort, unsigned char value, unsigned char mask ) { unsigned char c; c = SMCFDC37B78XRD (ioPort); c &= ~mask; c |= value; SMCFDC37B78XWRT (ioPort, c); }/********************************************************************************* smcFdc37b78xEnterCfg - enter into super i/o configuration cycle** This routine will begin super i/o configuration mode** RETURNS: NONE*/LOCAL VOID smcFdc37b78xEnterCfg ( VOID ) { SMCFDC37B78XWRT (smcFdc37b78xIopPtr->config, SMCFDC37B78X_CONFIG_START); }/********************************************************************************* smcFdc37b78xExitCfg - Exits super i/o configuration cycle** This routine will exit from super i/o configuration mode** RETURNS: NONE*/LOCAL VOID smcFdc37b78xExitCfg ( VOID ) { SMCFDC37B78XWRT (smcFdc37b78xIopPtr->config, SMCFDC37B78X_CONFIG_END); }/********************************************************************************* smcFdc37b78xCfgDevReg - modifies contents of a register ** This routine will modify register content of a given logical device** RETURNS: NONE*/LOCAL VOID smcFdc37b78xCfgDevReg ( unsigned char logDevice, unsigned char regIndex, unsigned char regValue, unsigned char mask ) { unsigned char c; /* select the logical device register */ SMCFDC37B78XWRT (smcFdc37b78xIopPtr->config, SMCFDC37B7X_LOGDEVCFGREG); /* select the logical device */ SMCFDC37B78XWRT (smcFdc37b78xIopPtr->data, logDevice); /* select the index */ SMCFDC37B78XWRT (smcFdc37b78xIopPtr->index, regIndex); c = SMCFDC37B78XRD (smcFdc37b78xIopPtr->data); c &= ~mask; c |= regValue; SMCFDC37B78XWRT (smcFdc37b78xIopPtr->data, c); }/********************************************************************************* smcFdc37b78xCfgDev - configures complete device** This routine will activate logical device, sets IO register* addresses and set up an interrupt for given logical device** RETURNS: NONE*/LOCAL VOID smcFdc37b78xCfgDev ( unsigned char device, unsigned char ioBaseHigh, unsigned char ioBaseLow, unsigned char intr ) { /* activate given device */ smcFdc37b78xCfgDevReg (device, SMCFDC37B78X_LOGDEV_ACTIVATE, SMCFDC37B78X_ACT_DEV, SMCFDC37B78X_MASK_ALL); /* set HIGH BYTE of IO base address */ smcFdc37b78xCfgDevReg (device, SMCFDC37B78X_IOBASE_HIGH, ioBaseHigh, SMCFDC37B78X_MASK_ALL); /* set LOW BYTE of IO base address */ smcFdc37b78xCfgDevReg (device, SMCFDC37B78X_IOBASE_LOW, ioBaseLow, SMCFDC37B78X_MASK_ALL); /* set interrupt # for given device */ smcFdc37b78xCfgDevReg (device, SMCFDC37B78X_INTERRUPT, intr, SMCFDC37B78X_MASK_ALL); }/********************************************************************************* smcFdc37b78xKbdRdy - indicates if kbd controller is ready to accept* read or write operation** This routine checks if it's a good time to read or write to* keyboard I/O ports** RETURNS: OK/ERROR*/LOCAL STATUS smcFdc37b78xKbdRdy ( int oper ) { int retry; for (retry = 0; retry < 100; retry++) { if (SMCFDC37B78X_KBD_RD_CTLSTS() & oper) return (OK); } return (ERROR); }/********************************************************************************* smcFdc37b78xEnbKbd - enables keyboard on superIO** This routine will enable everything required for keyboard device** RETURNS: OK/ERROR*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -