Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Architecture specific parts of the Floppy driver
0003  *
0004  * This file is subject to the terms and conditions of the GNU General Public
0005  * License.  See the file "COPYING" in the main directory of this archive
0006  * for more details.
0007  *
0008  * Copyright (C) 1995
0009  */
0010 #ifndef __ASM_ALPHA_FLOPPY_H
0011 #define __ASM_ALPHA_FLOPPY_H
0012 
0013 
0014 #define fd_inb(base, reg)       inb_p((base) + (reg))
0015 #define fd_outb(value, base, reg)   outb_p(value, (base) + (reg))
0016 
0017 #define fd_enable_dma()         enable_dma(FLOPPY_DMA)
0018 #define fd_disable_dma()        disable_dma(FLOPPY_DMA)
0019 #define fd_request_dma()        request_dma(FLOPPY_DMA,"floppy")
0020 #define fd_free_dma()           free_dma(FLOPPY_DMA)
0021 #define fd_clear_dma_ff()       clear_dma_ff(FLOPPY_DMA)
0022 #define fd_set_dma_mode(mode)   set_dma_mode(FLOPPY_DMA,mode)
0023 #define fd_set_dma_addr(addr)   set_dma_addr(FLOPPY_DMA,isa_virt_to_bus(addr))
0024 #define fd_set_dma_count(count) set_dma_count(FLOPPY_DMA,count)
0025 #define fd_enable_irq()         enable_irq(FLOPPY_IRQ)
0026 #define fd_disable_irq()        disable_irq(FLOPPY_IRQ)
0027 #define fd_request_irq()        request_irq(FLOPPY_IRQ, floppy_interrupt,\
0028                         0, "floppy", NULL)
0029 #define fd_free_irq()           free_irq(FLOPPY_IRQ, NULL)
0030 
0031 #ifdef CONFIG_PCI
0032 
0033 #include <linux/pci.h>
0034 
0035 #define fd_dma_setup(addr,size,mode,io) alpha_fd_dma_setup(addr,size,mode,io)
0036 
0037 static __inline__ int 
0038 alpha_fd_dma_setup(char *addr, unsigned long size, int mode, int io)
0039 {
0040     static unsigned long prev_size;
0041     static dma_addr_t bus_addr = 0;
0042     static char *prev_addr;
0043     static int prev_dir;
0044     int dir;
0045 
0046     dir = (mode != DMA_MODE_READ) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
0047 
0048     if (bus_addr 
0049         && (addr != prev_addr || size != prev_size || dir != prev_dir)) {
0050         /* different from last time -- unmap prev */
0051         dma_unmap_single(&isa_bridge->dev, bus_addr, prev_size,
0052                  prev_dir);
0053         bus_addr = 0;
0054     }
0055 
0056     if (!bus_addr)  /* need to map it */
0057         bus_addr = dma_map_single(&isa_bridge->dev, addr, size, dir);
0058 
0059     /* remember this one as prev */
0060     prev_addr = addr;
0061     prev_size = size;
0062     prev_dir = dir;
0063 
0064     fd_clear_dma_ff();
0065     fd_set_dma_mode(mode);
0066     set_dma_addr(FLOPPY_DMA, bus_addr);
0067     fd_set_dma_count(size);
0068     virtual_dma_port = io;
0069     fd_enable_dma();
0070 
0071     return 0;
0072 }
0073 
0074 #endif /* CONFIG_PCI */
0075 
0076 __inline__ void virtual_dma_init(void)
0077 {
0078     /* Nothing to do on an Alpha */
0079 }
0080 
0081 static int FDC1 = 0x3f0;
0082 static int FDC2 = -1;
0083 
0084 /*
0085  * Again, the CMOS information doesn't work on the alpha..
0086  */
0087 #define FLOPPY0_TYPE 6
0088 #define FLOPPY1_TYPE 0
0089 
0090 #define N_FDC 2
0091 #define N_DRIVE 8
0092 
0093 /*
0094  * Most Alphas have no problems with floppy DMA crossing 64k borders,
0095  * except for certain ones, like XL and RUFFIAN.
0096  *
0097  * However, the test is simple and fast, and this *is* floppy, after all,
0098  * so we do it for all platforms, just to make sure.
0099  *
0100  * This is advantageous in other circumstances as well, as in moving
0101  * about the PCI DMA windows and forcing the floppy to start doing
0102  * scatter-gather when it never had before, and there *is* a problem
0103  * on that platform... ;-}
0104  */
0105 
0106 static inline unsigned long CROSS_64KB(void *a, unsigned long s)
0107 {
0108     unsigned long p = (unsigned long)a;
0109     return ((p + s - 1) ^ p) & ~0xffffUL;
0110 }
0111 
0112 #define EXTRA_FLOPPY_PARAMS
0113 
0114 #endif /* __ASM_ALPHA_FLOPPY_H */