blob: e258778ca429ea5ccb9e90eb3672df61f821fede [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
Arnd Bergmann88ced032005-12-16 22:43:46 +010012#ifdef __KERNEL__
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
14#include <linux/config.h>
15#include <asm/machdep.h>
16
Paul Mackerrasc55377e2005-11-14 17:22:01 +110017#define fd_inb(port) inb_p(port)
18#define fd_outb(value,port) outb_p(value,port)
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20#define fd_enable_dma() enable_dma(FLOPPY_DMA)
21#define fd_disable_dma() disable_dma(FLOPPY_DMA)
Paul Mackerrasc55377e2005-11-14 17:22:01 +110022#define fd_request_dma() request_dma(FLOPPY_DMA, "floppy")
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#define fd_free_dma() free_dma(FLOPPY_DMA)
24#define fd_clear_dma_ff() clear_dma_ff(FLOPPY_DMA)
Paul Mackerrasc55377e2005-11-14 17:22:01 +110025#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 Torvalds1da177e2005-04-16 15:20:36 -070027#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>
38
Paul Mackerrasc55377e2005-11-14 17:22:01 +110039#define fd_dma_setup(addr,size,mode,io) powerpc_fd_dma_setup(addr,size,mode,io)
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Paul Mackerrasc55377e2005-11-14 17:22:01 +110041static __inline__ int powerpc_fd_dma_setup(char *addr, unsigned long size,
42 int mode, int io)
Linus Torvalds1da177e2005-04-16 15:20:36 -070043{
44 static unsigned long prev_size;
45 static dma_addr_t bus_addr = 0;
46 static char *prev_addr;
47 static int prev_dir;
48 int dir;
49
50 dir = (mode == DMA_MODE_READ) ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE;
51
52 if (bus_addr
53 && (addr != prev_addr || size != prev_size || dir != prev_dir)) {
54 /* different from last time -- unmap prev */
55 pci_unmap_single(NULL, bus_addr, prev_size, prev_dir);
56 bus_addr = 0;
57 }
58
Paul Mackerrasc55377e2005-11-14 17:22:01 +110059 if (!bus_addr) /* need to map it */
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 bus_addr = pci_map_single(NULL, addr, size, dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62 /* remember this one as prev */
63 prev_addr = addr;
64 prev_size = size;
65 prev_dir = dir;
66
67 fd_clear_dma_ff();
68 fd_cacheflush(addr, size);
69 fd_set_dma_mode(mode);
70 set_dma_addr(FLOPPY_DMA, bus_addr);
71 fd_set_dma_count(size);
72 virtual_dma_port = io;
73 fd_enable_dma();
74
75 return 0;
76}
77
78#endif /* CONFIG_PCI */
79
80__inline__ void virtual_dma_init(void)
81{
82 /* Nothing to do on PowerPC */
83}
84
85static int FDC1 = 0x3f0;
86static int FDC2 = -1;
87
88/*
89 * Again, the CMOS information not available
90 */
91#define FLOPPY0_TYPE 6
92#define FLOPPY1_TYPE 0
93
94#define N_FDC 2 /* Don't change this! */
95#define N_DRIVE 8
96
97#define FLOPPY_MOTOR_MASK 0xf0
98
99/*
100 * The PowerPC has no problems with floppy DMA crossing 64k borders.
101 */
102#define CROSS_64KB(a,s) (0)
103
104#define EXTRA_FLOPPY_PARAMS
105
Arnd Bergmann88ced032005-12-16 22:43:46 +0100106#endif /* __KERNEL__ */
Paul Mackerrasc55377e2005-11-14 17:22:01 +1100107#endif /* __ASM_POWERPC_FLOPPY_H */