Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Architecture specific parts of the Floppy driver |
| 3 | * |
| 4 | * This file is subject to the terms and conditions of the GNU General Public |
| 5 | * License. See the file "COPYING" in the main directory of this archive |
| 6 | * for more details. |
| 7 | * |
| 8 | * Copyright (C) 1995 |
| 9 | */ |
Paul Mackerras | c55377e | 2005-11-14 17:22:01 +1100 | [diff] [blame] | 10 | #ifndef __ASM_POWERPC_FLOPPY_H |
| 11 | #define __ASM_POWERPC_FLOPPY_H |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 12 | #ifdef __KERNEL__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
| 14 | #include <linux/config.h> |
| 15 | #include <asm/machdep.h> |
| 16 | |
Paul Mackerras | c55377e | 2005-11-14 17:22:01 +1100 | [diff] [blame] | 17 | #define fd_inb(port) inb_p(port) |
| 18 | #define fd_outb(value,port) outb_p(value,port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | #define fd_enable_dma() enable_dma(FLOPPY_DMA) |
| 21 | #define fd_disable_dma() disable_dma(FLOPPY_DMA) |
Paul Mackerras | c55377e | 2005-11-14 17:22:01 +1100 | [diff] [blame] | 22 | #define fd_request_dma() request_dma(FLOPPY_DMA, "floppy") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #define fd_free_dma() free_dma(FLOPPY_DMA) |
| 24 | #define fd_clear_dma_ff() clear_dma_ff(FLOPPY_DMA) |
Paul Mackerras | c55377e | 2005-11-14 17:22:01 +1100 | [diff] [blame] | 25 | #define fd_set_dma_mode(mode) set_dma_mode(FLOPPY_DMA, mode) |
| 26 | #define fd_set_dma_count(count) set_dma_count(FLOPPY_DMA, count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #define fd_enable_irq() enable_irq(FLOPPY_IRQ) |
| 28 | #define fd_disable_irq() disable_irq(FLOPPY_IRQ) |
| 29 | #define fd_cacheflush(addr,size) /* nothing */ |
| 30 | #define fd_request_irq() request_irq(FLOPPY_IRQ, floppy_interrupt, \ |
| 31 | SA_INTERRUPT|SA_SAMPLE_RANDOM, \ |
| 32 | "floppy", NULL) |
| 33 | #define fd_free_irq() free_irq(FLOPPY_IRQ, NULL); |
| 34 | |
| 35 | #ifdef CONFIG_PCI |
| 36 | |
| 37 | #include <linux/pci.h> |
Stephen Rothwell | b239cbe | 2006-03-28 14:40:58 +1100 | [diff] [blame^] | 38 | #include <asm/ppc-pci.h> /* for ppc64_isabridge_dev */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
Paul Mackerras | c55377e | 2005-11-14 17:22:01 +1100 | [diff] [blame] | 40 | #define fd_dma_setup(addr,size,mode,io) powerpc_fd_dma_setup(addr,size,mode,io) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
Paul Mackerras | c55377e | 2005-11-14 17:22:01 +1100 | [diff] [blame] | 42 | static __inline__ int powerpc_fd_dma_setup(char *addr, unsigned long size, |
| 43 | int mode, int io) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | { |
| 45 | static unsigned long prev_size; |
| 46 | static dma_addr_t bus_addr = 0; |
| 47 | static char *prev_addr; |
| 48 | static int prev_dir; |
| 49 | int dir; |
| 50 | |
| 51 | dir = (mode == DMA_MODE_READ) ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE; |
| 52 | |
| 53 | if (bus_addr |
| 54 | && (addr != prev_addr || size != prev_size || dir != prev_dir)) { |
| 55 | /* different from last time -- unmap prev */ |
Stephen Rothwell | b239cbe | 2006-03-28 14:40:58 +1100 | [diff] [blame^] | 56 | pci_unmap_single(ppc64_isabridge_dev, bus_addr, prev_size, prev_dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | bus_addr = 0; |
| 58 | } |
| 59 | |
Paul Mackerras | c55377e | 2005-11-14 17:22:01 +1100 | [diff] [blame] | 60 | if (!bus_addr) /* need to map it */ |
Stephen Rothwell | b239cbe | 2006-03-28 14:40:58 +1100 | [diff] [blame^] | 61 | bus_addr = pci_map_single(ppc64_isabridge_dev, addr, size, dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | /* remember this one as prev */ |
| 64 | prev_addr = addr; |
| 65 | prev_size = size; |
| 66 | prev_dir = dir; |
| 67 | |
| 68 | fd_clear_dma_ff(); |
| 69 | fd_cacheflush(addr, size); |
| 70 | fd_set_dma_mode(mode); |
| 71 | set_dma_addr(FLOPPY_DMA, bus_addr); |
| 72 | fd_set_dma_count(size); |
| 73 | virtual_dma_port = io; |
| 74 | fd_enable_dma(); |
| 75 | |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | #endif /* CONFIG_PCI */ |
| 80 | |
| 81 | __inline__ void virtual_dma_init(void) |
| 82 | { |
| 83 | /* Nothing to do on PowerPC */ |
| 84 | } |
| 85 | |
| 86 | static int FDC1 = 0x3f0; |
| 87 | static int FDC2 = -1; |
| 88 | |
| 89 | /* |
| 90 | * Again, the CMOS information not available |
| 91 | */ |
| 92 | #define FLOPPY0_TYPE 6 |
| 93 | #define FLOPPY1_TYPE 0 |
| 94 | |
| 95 | #define N_FDC 2 /* Don't change this! */ |
| 96 | #define N_DRIVE 8 |
| 97 | |
| 98 | #define FLOPPY_MOTOR_MASK 0xf0 |
| 99 | |
| 100 | /* |
| 101 | * The PowerPC has no problems with floppy DMA crossing 64k borders. |
| 102 | */ |
| 103 | #define CROSS_64KB(a,s) (0) |
| 104 | |
| 105 | #define EXTRA_FLOPPY_PARAMS |
| 106 | |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 107 | #endif /* __KERNEL__ */ |
Paul Mackerras | c55377e | 2005-11-14 17:22:01 +1100 | [diff] [blame] | 108 | #endif /* __ASM_POWERPC_FLOPPY_H */ |