/* -*- linux-c -*- * Copyright (c) 2004-2006 Winbond Electronics Corp. All rights reserved. * * The contents of this file are subject to the Open * Software License version 1.1 that can be found at * http://www.opensource.org/licenses/osl-1.1.txt and is included herein * by reference. * * Alternatively, the contents of this file may be used under the terms * of the GNU General Public License version 2 (the "GPL") as distributed * in the kernel source COPYING file, in which case the provisions of * the GPL are applicable instead of the above. If you wish to allow * the use of your version of this file only under the terms of the * GPL and not to allow others to use your version of this file under * the OSL, indicate your decision by deleting the provisions above and * replace them with the notice and other provisions required by the GPL. * If you do not delete the provisions above, a recipient may use your * version of this file under either the OSL or the GPL. * Maintained by: Weiming Shuai Jin Yuan Mu Dezheng Shen $Author: sjin $ $Id: wbmsreader528.h,v 1.10.2.6 2006/06/22 06:06:13 sjin Exp $ --- don't modify lines above --- Description: Enviornments: (1) RedHat 9 on 32-bit Intel UP/32-bit Intel dual-core (2) Fedora Core 4 (2.6.11) on 32-bit Intel/32-bit Intel dual-core/64-bit AMD/64-bit Intel dual-core (3) RedHat Enterprise Workstatin Rel 4 UP2 (2.6.9) on 32-bit Intel 32-bit Intel dual-core/64-bit AMD/64-bit Intel dual-core */ #ifndef _WB_MS_READER_528_H #define _WB_MS_READER_528_H #include #include #include #include #include #include "wbmsreader.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "wbdebug.h" #include "wbmsreader.h" #include "wbmscard.h" #define WMAX_POLLING_CMD (1000000) #define WMAX_POLLING (1000000) #define W528MS_VENDOR_ID (0x1050) #define W528MS_DEVICE_ID (0x8482) #define WPCI_ICR (0x9EC) #define WPCI_ISR (0x9F0) #define WIO_DEVICE_ISR (0x410) #define WIO_DMA_SD (0x4f0) #define WIO_DMA_MS (0x4f4) #define WIO_DMA_SX (0x4f8) #define WIO_DMA_INT_MSK (0x04) #define WIO_DMA_INT_SRC (0x0C) #define WIO_DMA_CH0_CSR (0x20) #define WIO_DMA_CH0_SZ (0x24) #define WIO_DMA_CH0_SA (0x28) #define WIO_DMA_CH0_DA (0x30) #define WIO_DMA_CH1_CSR (0x40) #define WIO_DMA_CH1_SZ (0x44) #define WIO_DMA_CH1_SA (0x48) #define WIO_DMA_CH1_DA (0x50) #define WIO_DMA_CH2_CSR (0x60) #define WIO_DMA_CH2_SZ (0x64) #define WIO_DMA_CH2_SA (0x68) #define WIO_DMA_CH2_DA (0x70) #define WIO_BASE (0x600) #define WIO_CMDR (WIO_BASE + 0x00) #define WIO_DFR (WIO_BASE + 0x04) #define WIO_MSCR1 (WIO_BASE + 0x08) #define WIO_MSCR2 (WIO_BASE + 0x0C) #define WIO_ICR (WIO_BASE + 0x10) #define WIO_ISR1 (WIO_BASE + 0x14) #define WIO_ISR2 (WIO_BASE + 0x18) #define WIO_MSSR (WIO_BASE + 0x1C) #define WPCI_ICR_INT_ENABLE (0x01) #define WPCI_ICR_SOFTWARE_RESET_ALL (0x20) #define WPCI_ICR_SOFTWARE_RESET (0x40) #define WPCI_ISR_STATUS (0x01) #define WDEVICE_ISR_DMA (0x01) #define WDEVICE_ISR_SD (0x02) #define WDEVICE_ISR_MS (0x04) #define WDEVICE_ISR_SMXD (0x08) #define WDEVICE_ISR_SDDMA_ERROR (0x10) #define WDEVICE_ISR_MSDMA_ERROR (0x20) #define WDEVICE_ISR_SMXDDMA_ERROR (0x40) #define WMSCR2_PF (0x40) #define WMSCR2_FIFORST (0x20) #define WMSCR2_SOFTRST (0x10) #define WMSCR2_PWRCTRL (0x08) #define WMSCR2_SWITCHNMOS (0x04) #define WICR_CRC (0x40) #define WICR_RDYTO (0x20) #define WICR_BS0INT (0x10) #define WICR_INSINT (0x01) #define WISR1_INTP (0x80) #define WISR1_FIFOUSED (0x78) #define WISR1_INS (0x01) #define WISR2_INTP (0x80) #define WISR2_CRC (0x40) #define WISR2_RDYTO (0x20) #define WISR2_BS0 (0x10) #define WISR2_CED (0x08) #define WISR2_ERR (0x04) #define WISR2_BREQ (0x02) #define WISR2_CMDNK (0x01) #define WMSSR_CRC (0x10) #define WMSSR_INS (0x08) #define WMSSR_DFF (0x04) #define WMSSR_DFE (0x02) #define WMSSR_RDY4CMD (0x01) #define WDMA_INT_SRC_CH0 (0x01) #define WDMA_INT_SRC_CH1 (0x02) #define WDMA_INT_SRC_CH2 (0x04) #define WDMA_CHCSR_EN (0x01) #define WDMA_CHCSR_DSTSEL (0x02) #define WDMA_CHCSR_SRCSEL (0x04) #define WDMA_CHCSR_INCDST (0x08) #define WDMA_CHCSR_INCSRC (0x10) #define WDMA_CHCSR_INTERR (0x20000) #define WDMA_CHCSR_INTDONE (0x40000) #define WDMA_CHCSR_WRITE ( WDMA_CHCSR_EN | WDMA_CHCSR_DSTSEL \ | WDMA_CHCSR_INCSRC | WDMA_CHCSR_INTERR | WDMA_CHCSR_INTDONE ) #define WDMA_CHCSR_READ ( WDMA_CHCSR_EN | WDMA_CHCSR_SRCSEL \ | WDMA_CHCSR_INCDST | WDMA_CHCSR_INTERR | WDMA_CHCSR_INTDONE ) //system status definition #define WSYS_STATUS_INTR_CARD (1) #define WSYS_STATUS_INTR_CRC (1<<1) #define WSYS_STATUS_INTR_BS0 (1<<2) #define WSYS_STATUS_INTR_BS0_TOE (1<<3) #define WSYS_STATUS_INTR_RDY_TOE (1<<4) #define WSYS_STATUS_INTR_FIFO_THRESHOLD (1<<5) #define WSYS_STATUS_INTR_TC (1<<7) #define WSYS_STATUS_INTR_DMA (1<<8) typedef struct tag_wb528ms_reader { // base io address 0 unsigned long mem_addr0; unsigned long mem_flag0; // base io address 1 unsigned long mem_addr1; unsigned long mem_flag1; struct pci_dev *pci_dev; unsigned char irq; unsigned char dma; dma_addr_t bus_addr; unsigned char card_exist; unsigned char medium_changed; unsigned char card_type; volatile unsigned int sys_status; //help thread wait queue wait_queue_head_t space_helper_thread_wait_queue; wait_queue_head_t *helper_thread_wait_queue; } wb528ms_reader_t; static unsigned int inline wb528ms_pci_inl(unsigned offset); static void inline wb528ms_pci_outl(volatile unsigned int value, unsigned offset); static unsigned int inline wb528ms_inl(unsigned offset); static void inline wb528ms_outl(volatile unsigned int value, unsigned offset); static unsigned short inline wb528ms_inw(unsigned offset); static void inline wb528ms_outw(volatile unsigned short value, unsigned offset); static unsigned char inline wb528ms_inb(unsigned offset); static void inline wb528ms_outb(volatile unsigned char value, unsigned offset); static void inline wb528ms_set_interface(unsigned int); static inline void wb528ms_power_up(void); static inline void wb528ms_power_down(void); static inline void wb528ms_fifo_reset(void); static int inline wb528ms_pio_data(unsigned char *buff, unsigned int length, unsigned char read_wrt_flag); static int inline wb528ms_dma_data(unsigned char *buff, unsigned int length, unsigned char read_wrt_flag); static void wb528ms_set_fifo_size(unsigned int length); static int wb528ms_check_cmd_ready(void); static int wb528ms_init_card(void); static int wb528ms_card_exist(void); static int wb528ms_software_reset(void); static irqreturn_t wb528ms_do_intr_handler(int irq, void *dev_id, struct pt_regs *regs); static void inline __init wb528ms_init_data(void); #endif