1024b246eSLinus Torvalds /* 2024b246eSLinus Torvalds * Architecture specific parts of the Floppy driver 3024b246eSLinus Torvalds * 4024b246eSLinus Torvalds * This file is subject to the terms and conditions of the GNU General Public 5024b246eSLinus Torvalds * License. See the file "COPYING" in the main directory of this archive 6024b246eSLinus Torvalds * for more details. 7024b246eSLinus Torvalds * 8024b246eSLinus Torvalds * Copyright (C) 1995 9024b246eSLinus Torvalds */ 10024b246eSLinus Torvalds #ifndef __ASM_ALPHA_FLOPPY_H 11024b246eSLinus Torvalds #define __ASM_ALPHA_FLOPPY_H 12024b246eSLinus Torvalds 13024b246eSLinus Torvalds 14024b246eSLinus Torvalds #define fd_inb(port) inb_p(port) 15024b246eSLinus Torvalds #define fd_outb(value,port) outb_p(value,port) 16024b246eSLinus Torvalds 17024b246eSLinus Torvalds #define fd_enable_dma() enable_dma(FLOPPY_DMA) 18024b246eSLinus Torvalds #define fd_disable_dma() disable_dma(FLOPPY_DMA) 19024b246eSLinus Torvalds #define fd_request_dma() request_dma(FLOPPY_DMA,"floppy") 20024b246eSLinus Torvalds #define fd_free_dma() free_dma(FLOPPY_DMA) 21024b246eSLinus Torvalds #define fd_clear_dma_ff() clear_dma_ff(FLOPPY_DMA) 22024b246eSLinus Torvalds #define fd_set_dma_mode(mode) set_dma_mode(FLOPPY_DMA,mode) 23024b246eSLinus Torvalds #define fd_set_dma_addr(addr) set_dma_addr(FLOPPY_DMA,virt_to_bus(addr)) 24024b246eSLinus Torvalds #define fd_set_dma_count(count) set_dma_count(FLOPPY_DMA,count) 25024b246eSLinus Torvalds #define fd_enable_irq() enable_irq(FLOPPY_IRQ) 26024b246eSLinus Torvalds #define fd_disable_irq() disable_irq(FLOPPY_IRQ) 27024b246eSLinus Torvalds #define fd_cacheflush(addr,size) /* nothing */ 28024b246eSLinus Torvalds #define fd_request_irq() request_irq(FLOPPY_IRQ, floppy_interrupt,\ 29024b246eSLinus Torvalds IRQF_DISABLED, "floppy", NULL) 30*497888cfSPhil Carmody #define fd_free_irq() free_irq(FLOPPY_IRQ, NULL) 31024b246eSLinus Torvalds 32024b246eSLinus Torvalds #ifdef CONFIG_PCI 33024b246eSLinus Torvalds 34024b246eSLinus Torvalds #include <linux/pci.h> 35024b246eSLinus Torvalds 36024b246eSLinus Torvalds #define fd_dma_setup(addr,size,mode,io) alpha_fd_dma_setup(addr,size,mode,io) 37024b246eSLinus Torvalds 38024b246eSLinus Torvalds static __inline__ int 39024b246eSLinus Torvalds alpha_fd_dma_setup(char *addr, unsigned long size, int mode, int io) 40024b246eSLinus Torvalds { 41024b246eSLinus Torvalds static unsigned long prev_size; 42024b246eSLinus Torvalds static dma_addr_t bus_addr = 0; 43024b246eSLinus Torvalds static char *prev_addr; 44024b246eSLinus Torvalds static int prev_dir; 45024b246eSLinus Torvalds int dir; 46024b246eSLinus Torvalds 47024b246eSLinus Torvalds dir = (mode != DMA_MODE_READ) ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE; 48024b246eSLinus Torvalds 49024b246eSLinus Torvalds if (bus_addr 50024b246eSLinus Torvalds && (addr != prev_addr || size != prev_size || dir != prev_dir)) { 51024b246eSLinus Torvalds /* different from last time -- unmap prev */ 52024b246eSLinus Torvalds pci_unmap_single(isa_bridge, bus_addr, prev_size, prev_dir); 53024b246eSLinus Torvalds bus_addr = 0; 54024b246eSLinus Torvalds } 55024b246eSLinus Torvalds 56024b246eSLinus Torvalds if (!bus_addr) /* need to map it */ 57024b246eSLinus Torvalds bus_addr = pci_map_single(isa_bridge, addr, size, dir); 58024b246eSLinus Torvalds 59024b246eSLinus Torvalds /* remember this one as prev */ 60024b246eSLinus Torvalds prev_addr = addr; 61024b246eSLinus Torvalds prev_size = size; 62024b246eSLinus Torvalds prev_dir = dir; 63024b246eSLinus Torvalds 64024b246eSLinus Torvalds fd_clear_dma_ff(); 65024b246eSLinus Torvalds fd_cacheflush(addr, size); 66024b246eSLinus Torvalds fd_set_dma_mode(mode); 67024b246eSLinus Torvalds set_dma_addr(FLOPPY_DMA, bus_addr); 68024b246eSLinus Torvalds fd_set_dma_count(size); 69024b246eSLinus Torvalds virtual_dma_port = io; 70024b246eSLinus Torvalds fd_enable_dma(); 71024b246eSLinus Torvalds 72024b246eSLinus Torvalds return 0; 73024b246eSLinus Torvalds } 74024b246eSLinus Torvalds 75024b246eSLinus Torvalds #endif /* CONFIG_PCI */ 76024b246eSLinus Torvalds 77024b246eSLinus Torvalds __inline__ void virtual_dma_init(void) 78024b246eSLinus Torvalds { 79024b246eSLinus Torvalds /* Nothing to do on an Alpha */ 80024b246eSLinus Torvalds } 81024b246eSLinus Torvalds 82024b246eSLinus Torvalds static int FDC1 = 0x3f0; 83024b246eSLinus Torvalds static int FDC2 = -1; 84024b246eSLinus Torvalds 85024b246eSLinus Torvalds /* 86024b246eSLinus Torvalds * Again, the CMOS information doesn't work on the alpha.. 87024b246eSLinus Torvalds */ 88024b246eSLinus Torvalds #define FLOPPY0_TYPE 6 89024b246eSLinus Torvalds #define FLOPPY1_TYPE 0 90024b246eSLinus Torvalds 91024b246eSLinus Torvalds #define N_FDC 2 92024b246eSLinus Torvalds #define N_DRIVE 8 93024b246eSLinus Torvalds 94024b246eSLinus Torvalds /* 95024b246eSLinus Torvalds * Most Alphas have no problems with floppy DMA crossing 64k borders, 96024b246eSLinus Torvalds * except for certain ones, like XL and RUFFIAN. 97024b246eSLinus Torvalds * 98024b246eSLinus Torvalds * However, the test is simple and fast, and this *is* floppy, after all, 99024b246eSLinus Torvalds * so we do it for all platforms, just to make sure. 100024b246eSLinus Torvalds * 101024b246eSLinus Torvalds * This is advantageous in other circumstances as well, as in moving 102024b246eSLinus Torvalds * about the PCI DMA windows and forcing the floppy to start doing 103024b246eSLinus Torvalds * scatter-gather when it never had before, and there *is* a problem 104024b246eSLinus Torvalds * on that platform... ;-} 105024b246eSLinus Torvalds */ 106024b246eSLinus Torvalds 107024b246eSLinus Torvalds static inline unsigned long CROSS_64KB(void *a, unsigned long s) 108024b246eSLinus Torvalds { 109024b246eSLinus Torvalds unsigned long p = (unsigned long)a; 110024b246eSLinus Torvalds return ((p + s - 1) ^ p) & ~0xffffUL; 111024b246eSLinus Torvalds } 112024b246eSLinus Torvalds 113024b246eSLinus Torvalds #define EXTRA_FLOPPY_PARAMS 114024b246eSLinus Torvalds 115024b246eSLinus Torvalds #endif /* __ASM_ALPHA_FLOPPY_H */ 116