18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Architecture specific parts of the Floppy driver 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 58c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 68c2ecf20Sopenharmony_ci * for more details. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Copyright (C) 1995 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci#ifndef __ASM_ALPHA_FLOPPY_H 118c2ecf20Sopenharmony_ci#define __ASM_ALPHA_FLOPPY_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#define fd_inb(base, reg) inb_p((base) + (reg)) 158c2ecf20Sopenharmony_ci#define fd_outb(value, base, reg) outb_p(value, (base) + (reg)) 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define fd_enable_dma() enable_dma(FLOPPY_DMA) 188c2ecf20Sopenharmony_ci#define fd_disable_dma() disable_dma(FLOPPY_DMA) 198c2ecf20Sopenharmony_ci#define fd_request_dma() request_dma(FLOPPY_DMA,"floppy") 208c2ecf20Sopenharmony_ci#define fd_free_dma() free_dma(FLOPPY_DMA) 218c2ecf20Sopenharmony_ci#define fd_clear_dma_ff() clear_dma_ff(FLOPPY_DMA) 228c2ecf20Sopenharmony_ci#define fd_set_dma_mode(mode) set_dma_mode(FLOPPY_DMA,mode) 238c2ecf20Sopenharmony_ci#define fd_set_dma_addr(addr) set_dma_addr(FLOPPY_DMA,virt_to_bus(addr)) 248c2ecf20Sopenharmony_ci#define fd_set_dma_count(count) set_dma_count(FLOPPY_DMA,count) 258c2ecf20Sopenharmony_ci#define fd_enable_irq() enable_irq(FLOPPY_IRQ) 268c2ecf20Sopenharmony_ci#define fd_disable_irq() disable_irq(FLOPPY_IRQ) 278c2ecf20Sopenharmony_ci#define fd_request_irq() request_irq(FLOPPY_IRQ, floppy_interrupt,\ 288c2ecf20Sopenharmony_ci 0, "floppy", NULL) 298c2ecf20Sopenharmony_ci#define fd_free_irq() free_irq(FLOPPY_IRQ, NULL) 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#include <linux/pci.h> 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define fd_dma_setup(addr,size,mode,io) alpha_fd_dma_setup(addr,size,mode,io) 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_cistatic __inline__ int 388c2ecf20Sopenharmony_cialpha_fd_dma_setup(char *addr, unsigned long size, int mode, int io) 398c2ecf20Sopenharmony_ci{ 408c2ecf20Sopenharmony_ci static unsigned long prev_size; 418c2ecf20Sopenharmony_ci static dma_addr_t bus_addr = 0; 428c2ecf20Sopenharmony_ci static char *prev_addr; 438c2ecf20Sopenharmony_ci static int prev_dir; 448c2ecf20Sopenharmony_ci int dir; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci dir = (mode != DMA_MODE_READ) ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci if (bus_addr 498c2ecf20Sopenharmony_ci && (addr != prev_addr || size != prev_size || dir != prev_dir)) { 508c2ecf20Sopenharmony_ci /* different from last time -- unmap prev */ 518c2ecf20Sopenharmony_ci pci_unmap_single(isa_bridge, bus_addr, prev_size, prev_dir); 528c2ecf20Sopenharmony_ci bus_addr = 0; 538c2ecf20Sopenharmony_ci } 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci if (!bus_addr) /* need to map it */ 568c2ecf20Sopenharmony_ci bus_addr = pci_map_single(isa_bridge, addr, size, dir); 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci /* remember this one as prev */ 598c2ecf20Sopenharmony_ci prev_addr = addr; 608c2ecf20Sopenharmony_ci prev_size = size; 618c2ecf20Sopenharmony_ci prev_dir = dir; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci fd_clear_dma_ff(); 648c2ecf20Sopenharmony_ci fd_set_dma_mode(mode); 658c2ecf20Sopenharmony_ci set_dma_addr(FLOPPY_DMA, bus_addr); 668c2ecf20Sopenharmony_ci fd_set_dma_count(size); 678c2ecf20Sopenharmony_ci virtual_dma_port = io; 688c2ecf20Sopenharmony_ci fd_enable_dma(); 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci return 0; 718c2ecf20Sopenharmony_ci} 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci#endif /* CONFIG_PCI */ 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci__inline__ void virtual_dma_init(void) 768c2ecf20Sopenharmony_ci{ 778c2ecf20Sopenharmony_ci /* Nothing to do on an Alpha */ 788c2ecf20Sopenharmony_ci} 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_cistatic int FDC1 = 0x3f0; 818c2ecf20Sopenharmony_cistatic int FDC2 = -1; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci/* 848c2ecf20Sopenharmony_ci * Again, the CMOS information doesn't work on the alpha.. 858c2ecf20Sopenharmony_ci */ 868c2ecf20Sopenharmony_ci#define FLOPPY0_TYPE 6 878c2ecf20Sopenharmony_ci#define FLOPPY1_TYPE 0 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci#define N_FDC 2 908c2ecf20Sopenharmony_ci#define N_DRIVE 8 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci/* 938c2ecf20Sopenharmony_ci * Most Alphas have no problems with floppy DMA crossing 64k borders, 948c2ecf20Sopenharmony_ci * except for certain ones, like XL and RUFFIAN. 958c2ecf20Sopenharmony_ci * 968c2ecf20Sopenharmony_ci * However, the test is simple and fast, and this *is* floppy, after all, 978c2ecf20Sopenharmony_ci * so we do it for all platforms, just to make sure. 988c2ecf20Sopenharmony_ci * 998c2ecf20Sopenharmony_ci * This is advantageous in other circumstances as well, as in moving 1008c2ecf20Sopenharmony_ci * about the PCI DMA windows and forcing the floppy to start doing 1018c2ecf20Sopenharmony_ci * scatter-gather when it never had before, and there *is* a problem 1028c2ecf20Sopenharmony_ci * on that platform... ;-} 1038c2ecf20Sopenharmony_ci */ 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_cistatic inline unsigned long CROSS_64KB(void *a, unsigned long s) 1068c2ecf20Sopenharmony_ci{ 1078c2ecf20Sopenharmony_ci unsigned long p = (unsigned long)a; 1088c2ecf20Sopenharmony_ci return ((p + s - 1) ^ p) & ~0xffffUL; 1098c2ecf20Sopenharmony_ci} 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#define EXTRA_FLOPPY_PARAMS 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#endif /* __ASM_ALPHA_FLOPPY_H */ 114