/************************************************************************** * File Name : pcmace.h * * Project: Ace BU6555xM2-300 PCMCIA interface driver for Linux * * Copyright (C) 2004 by ILC Data Device Corp. * All Rights Reserved. * * * Comments: * Make within the Linux Card Services package * usr/src/linux/pcmcia-cs-x.y.z/clients * Ignore warining for .modinfo (not implemented) * See readme.txt * * Tested Kernel Versions: * 2.6.18 * * Revision History * Date Name Version Description *-------------------------------------------------------------------------- * 18-Apr-2001 Gary Davies 1.0 Original * 04-Mar-2001 Mark Findlater 1.1 Added #defines for registers * 07-Dec-2004 ESK 1.2 Added Kernel version checks for * deprecated/changed functions * 07-Dec-2010 GLS 2.0 Ported to 2.6.18 kernels * (and deleted all old stuff) * ***************************************************************************/ #ifndef _PCMACE_H_ #define _PCMACE_H_ #include #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) #error unsupported kernel version! #endif #include #include #include #include #include #ifdef __KERNEL__ /* This section for kernel specific code only. */ #ifndef DECLARE_WAIT_QUEUE_HEAD typedef struct wait_queue *wait_queue_head_t; #define init_waitqueue_head(head) (*(head)) = NULL #endif /* ! DECLARE_WAIT_QUEUE_HEAD */ #define VMA_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT) #define cli() local_irq_disable() #define sti() local_irq_enable() #define save_flags(x) local_save_flags(x) #define restore_flags(x) local_irq_restore(x) #endif /* __KERNEL__ */ /* Name of the loadable module for internal use. */ #define MODULE_NAME "pcmace" /* Size of the tuple buffer in bytes */ /* It must be big enough to hold DDC card tuples */ /* The BU_65558M2_300 card contains long tuples */ /* A size greater than 255 seems to corrupts the tuple data */ #define TUPLE_BUFFER_SIZE 255 /* Card identifiers */ /* Values must not exceed MAX_NUM_KNOWN_CARDS */ /* Increase the value of MAX_NUM_KNOWN_CARDS if more cards are added */ #define DEVID_STRINGNDX_BU65550M2_300 0 #define DEVID_STRINGNDX_BU65550M2_602 1 #define DEVID_STRINGNDX_BU65551M2_300 2 #define DEVID_STRINGNDX_BU65552M2_300 3 #define DEVID_STRINGNDX_BU65553M2_300 4 #define DEVID_STRINGNDX_BU65550M2_605 5 #define DEVID_BU65550M2_300 0x65550230 #define DEVID_BU65550M2_602 0x65550262 #define DEVID_BU65551M2_300 0x65551230 #define DEVID_BU65552M2_300 0x65552230 #define DEVID_BU65553M2_300 0x65553230 #define DEVID_BU65550M2_605 0x65550265 #define UNKNOWN_CARD 99 /* Driver version. */ #define ACE53_VER 1 #define ACE53_REV 1 #define ACE53_REL 2 #define ACE53_VERSION (ACE53_VER<<16) | (ACE53_REV<<8) | ACE53_REL #define ACE53_VERSION_STRING "1.1.2" /* Maximum number of cards supported. */ #define ACE53_MAX_NUM_CARDS 32 #define ACE53_NUM_CHANS_PER_CARD 1 #define ACE53_MAX_NUM_DEVICES 32 #define ACE53_MAX_NUM_CHANS 32 #define ACE53_MAX_NUM_WINDOWS 64 #define ACE53_MAX_NUM_KNOWN_CARDS 6 /* Linux kernel driver reference number. */ #define MAGIC_NUM 0xDD /* Number of windows 'mmap'ped to user space. */ #define ACE53_MAX_USER_MEM_WINDOWS 2 /* Shared and FIFO windows only. */ /* Memory size of shared and FIFO windows, (Parameter for 'mmap' method). */ #define ACE53_CHAN_MEM_LENGTH 0x2000 /* 32k byte window. 64K word card has 4 pages. */ #define ACE53_CHAN_REG_LENGTH 0x1000 /* 128 bytes = 64 words = <4k */ /* Case statement labels for DeviceIoControl calls */ #define IOCTL_ACE53_GET_VERSION _IOR(MAGIC_NUM, 1, void *) #define IOCTL_ACE53_GET_CARD_INFO _IOR(MAGIC_NUM, 2, void *) #define IOCTL_ACE53_GET_CHANNEL_INFO _IOR(MAGIC_NUM, 3, void *) #define IOCTL_ACE53_BLOCK_IN_DRIVER _IOR(MAGIC_NUM, 4, void *) #define IOCTL_ACE53_BC_AUTO_FLIPSTK _IOR(MAGIC_NUM, 5, void *) #define IOCTL_ACE53_INSTALL_IRQ _IO(MAGIC_NUM, 6) #define IOCTL_ACE53_UNINSTALL_IRQ _IO(MAGIC_NUM, 7) /* Ace Registers */ /*jmf Added to remove hard coded register addresses */ #define ACE53_GLOBAL_REGISTER 0x0800 #define ACE53_INTERRUPT_MASK_REGISTER 0x0000 #define ACE53_CONFIG_REGISTER_1 0x0002 #define ACE53_CONFIG_REGISTER_2 0x0004 #define ACE53_START_RESET_REGISTER 0x0006 #define ACE53_INTERRUPT_STATUS_REGISTER 0x000C /* Driver call return values. */ #define STATUS_ACE53_SUCCESS (int)0 /* Initialization problems. These values are returned to the 'insmod' utility. */ /* It will indicate 'Device or resource busy' if initialization fails. */ #define STATUS_ACE53_INIT_TOO_MANY_PCI_CARDS (int)-102 /* General 'open' and 'close' problems. */ #define STATUS_ACE53_DEVICE_NOT_EXIST (int)-200 #define STATUS_ACE53_CARD_ALREADY_OPEN (int)-201 #define STATUS_ACE53_CARD_NOT_OPEN (int)-202 #define STATUS_ACE53_CARD_IMPROPERLY_CLOSED (int)-203 #define STATUS_ACE53_PCMCIACFG_REMAP_FAIL (int)-204 #define STATUS_ACE53_CHANNEL_NOT_AVAILABLE (int)-205 /* 'ioctl' call problems. */ #define STATUS_ACE53_IOCTL_NOT_IMPLEMENTED (int)-210 #define STATUS_ACE53_IOCTL_IRQ_ALREADY_INSTALLED (int)-211 #define STATUS_ACE53_IOCTL_IRQ_NOT_INSTALLED (int)-212 #define STATUS_ACE53_IOCTL_REQUEST_IRQ_FAIL (int)-213 #define STATUS_ACE53_IOCTL_INTERRUPT_NOT_ENABLED (int)-214 #define STATUS_ACE53_IOCTL_SLEEP_ACTIVATED (int)-215 /* 'mmap' call problems. */ #define STATUS_ACE53_MMAP_CARD_ALREADY_MMAPPED (int)-220 #define STATUS_ACE53_MMAP_SEQUENCE_ERROR (int)-221 #define STATUS_ACE53_MMAP_INVALID_WINDOW_SIZE (int)-222 #define STATUS_ACE53_MMAP_INVALID_PAGE_SIZE (int)-223 #define STATUS_ACE53_MMAP_BAD_ALIGNMENT (int)-224 #define STATUS_ACE53_MMAP_REMAP_FAIL (int)-225 /* Defines and typedef's. */ #define DWORD unsigned int /* Card Access Variable Types */ #ifndef TYPES typedef signed char S8; typedef unsigned char U8; typedef signed short int S16; typedef unsigned short int U16; typedef signed int S32; typedef unsigned int U32; #endif /* TYPES */ #define U16BIT unsigned short #define U32BIT unsigned int /* Ace CIS Structure */ typedef struct _ACE53_CIS { u_int unMemorySize; /* Size of card memory (64k) */ u_int unAccessSpeed; /* Speed of card memory access (250ns) */ u_int unConfigBase; /* Card memory Config base offset */ u_int unPresent; /* Specifies that the COR register is present */ u_char ucConfigIndex; /* Index specifying card config mode */ cistpl_manfid_t manfid; /* Card manufacturer details */ cistpl_io_t io; /* Card io port requirements */ cistpl_irq_t irq; /* Card irq requirements */ cistpl_mem_t mem; /* Card memory window requirements */ } ACE53_CIS, *pACE53_CIS; /* Ace Channel Structure */ typedef struct _ACE_CHANNEL { U8 bCardNum; /* Card Number [0-3] */ U8 bChanNum; /* Channel Number [0-1] */ U8 bSocketNum; /* Channel Number [0-1] */ U32 dwMemWndUsrAddr; /* Memory Windows in User space (1 per channel) */ U32 dwRegWndUsrAddr; /* Register Windows in User space (1 per channel) */ U32 dwIntStatus; /* Status Register of the interrupt */ U8 bBlocked; /* Blocking status of driver */ U8 bMmapWinNum; /* mmapped window count */ U8 bIsrEnabled; /* Status of driver ISR */ U16 wIrq; /* Channel's IRQ */ U8 bOpen; /* Open status flag for channels */ U8 bAutoFlipStk; /* BC Eof Auto Flip Stack */ } ACE_CHANNEL, *pACE_CHANNEL; /* Ace Card Structure */ typedef struct _ACE53_CARD { struct pcmcia_device *plink; /* PCMCIA device */ U8 bPciBusNum; /* PCI bus number */ U8 bPciDevNum; /* PCI device (slot) number */ U8 bPciFcnNum; /* PCI function number */ U8 bMajor; /* Device Major number */ U8 bMinor; /* Device Minor number */ U16 wDeviceID; /* DDC card type from CIS Card ID (always 0x0101)*/ U32 dwCardID; /* Set to the appropriate macro value eg. DEVID_BU65553M2_300 */ U32 dwChanMemLen; /* mem size of each channel on card */ U16 wIrq; /* interrupt level */ U8 bNumChnls; /* number of channels on card */ U32 dwMemWndPcmciaAddr; /* Base address of Memory Window in PCI space */ U32 dwRegWndPcmciaAddr; /* Base address of Registry Window in PCI space */ __u64 dwMemWndKrnAddr; /* Base address of Memory Window in Kernel space */ __u64 dwRegWndKrnAddr; /* Base address of Registry Window in Kernel space */ ACE_CHANNEL Channel; /* Channel Specific information */ ACE53_CIS CIS; /* Channel Specific information */ } ACE53_CARD, *pACE53_CARD; #endif /*_PCMACE_H_*/