blob: 64276a3f6153f7ea6461233287ad9c4473f87b88 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Mackerrasc55377e2005-11-14 17:22:01 +110010#ifndef __ASM_POWERPC_FLOPPY_H
11#define __ASM_POWERPC_FLOPPY_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
13#include <linux/config.h>
14#include <asm/machdep.h>
15
Paul Mackerrasc55377e2005-11-14 17:22:01 +110016#define fd_inb(port) inb_p(port)
17#define fd_outb(value,port) outb_p(value,port)
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
19#define fd_enable_dma() enable_dma(FLOPPY_DMA)
20#define fd_disable_dma() disable_dma(FLOPPY_DMA)
Paul Mackerrasc55377e2005-11-14 17:22:01 +110021#define fd_request_dma() request_dma(FLOPPY_DMA, "floppy")
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#define fd_free_dma() free_dma(FLOPPY_DMA)
23#define fd_clear_dma_ff() clear_dma_ff(FLOPPY_DMA)
Paul Mackerrasc55377e2005-11-14 17:22:01 +110024#define fd_set_dma_mode(mode) set_dma_mode(FLOPPY_DMA, mode)
25#define fd_set_dma_count(count) set_dma_count(FLOPPY_DMA, count)
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#define fd_enable_irq() enable_irq(FLOPPY_IRQ)
27#define fd_disable_irq() disable_irq(FLOPPY_IRQ)
28#define fd_cacheflush(addr,size) /* nothing */
29#define fd_request_irq() request_irq(FLOPPY_IRQ, floppy_interrupt, \
30 SA_INTERRUPT|SA_SAMPLE_RANDOM, \
31 "floppy", NULL)
32#define fd_free_irq() free_irq(FLOPPY_IRQ, NULL);
33
34#ifdef CONFIG_PCI
35
36#include <linux/pci.h>
37
Paul Mackerrasc55377e2005-11-14 17:22:01 +110038#define fd_dma_setup(addr,size,mode,io) powerpc_fd_dma_setup(addr,size,mode,io)
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
Paul Mackerrasc55377e2005-11-14 17:22:01 +110040static __inline__ int powerpc_fd_dma_setup(char *addr, unsigned long size,
41 int mode, int io)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042{
43 static unsigned long prev_size;
44 static dma_addr_t bus_addr = 0;
45 static char *prev_addr;
46 static int prev_dir;
47 int dir;
48
49 dir = (mode == DMA_MODE_READ) ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE;
50
51 if (bus_addr
52 && (addr != prev_addr || size != prev_size || dir != prev_dir)) {
53 /* different from last time -- unmap prev */
54 pci_unmap_single(NULL, bus_addr, prev_size, prev_dir);
55 bus_addr = 0;
56 }
57
Paul Mackerrasc55377e2005-11-14 17:22:01 +110058 if (!bus_addr) /* need to map it */
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 bus_addr = pci_map_single(NULL, addr, size, dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61 /* remember this one as prev */
62 prev_addr = addr;
63 prev_size = size;
64 prev_dir = dir;
65
66 fd_clear_dma_ff();
67 fd_cacheflush(addr, size);
68 fd_set_dma_mode(mode);
69 set_dma_addr(FLOPPY_DMA, bus_addr);
70 fd_set_dma_count(size);
71 virtual_dma_port = io;
72 fd_enable_dma();
73
74 return 0;
75}
76
77#endif /* CONFIG_PCI */
78
79__inline__ void virtual_dma_init(void)
80{
81 /* Nothing to do on PowerPC */
82}
83
84static int FDC1 = 0x3f0;
85static int FDC2 = -1;
86
87/*
88 * Again, the CMOS information not available
89 */
90#define FLOPPY0_TYPE 6
91#define FLOPPY1_TYPE 0
92
93#define N_FDC 2 /* Don't change this! */
94#define N_DRIVE 8
95
96#define FLOPPY_MOTOR_MASK 0xf0
97
98/*
99 * The PowerPC has no problems with floppy DMA crossing 64k borders.
100 */
101#define CROSS_64KB(a,s) (0)
102
103#define EXTRA_FLOPPY_PARAMS
104
Paul Mackerrasc55377e2005-11-14 17:22:01 +1100105#endif /* __ASM_POWERPC_FLOPPY_H */