xref: /linux/arch/arm/include/asm/floppy.h (revision 6fdcba32711044c35c0e1b094cbd8f3f0b4472c9)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  *  arch/arm/include/asm/floppy.h
4  *
5  *  Copyright (C) 1996-2000 Russell King
6  *
7  *  Note that we don't touch FLOPPY_DMA nor FLOPPY_IRQ here
8  */
9 #ifndef __ASM_ARM_FLOPPY_H
10 #define __ASM_ARM_FLOPPY_H
11 #if 0
12 #include <mach/floppy.h>
13 #endif
14 
15 #define fd_outb(val,port)			\
16 	do {					\
17 		if ((port) == (u32)FD_DOR)	\
18 			fd_setdor((val));	\
19 		else				\
20 			outb((val),(port));	\
21 	} while(0)
22 
23 #define fd_inb(port)		inb((port))
24 #define fd_request_irq()	request_irq(IRQ_FLOPPYDISK,floppy_interrupt,\
25 					    0,"floppy",NULL)
26 #define fd_free_irq()		free_irq(IRQ_FLOPPYDISK,NULL)
27 #define fd_disable_irq()	disable_irq(IRQ_FLOPPYDISK)
28 #define fd_enable_irq()		enable_irq(IRQ_FLOPPYDISK)
29 
30 static inline int fd_dma_setup(void *data, unsigned int length,
31 			       unsigned int mode, unsigned long addr)
32 {
33 	set_dma_mode(DMA_FLOPPY, mode);
34 	__set_dma_addr(DMA_FLOPPY, data);
35 	set_dma_count(DMA_FLOPPY, length);
36 	virtual_dma_port = addr;
37 	enable_dma(DMA_FLOPPY);
38 	return 0;
39 }
40 #define fd_dma_setup		fd_dma_setup
41 
42 #define fd_request_dma()	request_dma(DMA_FLOPPY,"floppy")
43 #define fd_free_dma()		free_dma(DMA_FLOPPY)
44 #define fd_disable_dma()	disable_dma(DMA_FLOPPY)
45 
46 /* need to clean up dma.h */
47 #define DMA_FLOPPYDISK		DMA_FLOPPY
48 
49 /* Floppy_selects is the list of DOR's to select drive fd
50  *
51  * On initialisation, the floppy list is scanned, and the drives allocated
52  * in the order that they are found.  This is done by seeking the drive
53  * to a non-zero track, and then restoring it to track 0.  If an error occurs,
54  * then there is no floppy drive present.       [to be put back in again]
55  */
56 static unsigned char floppy_selects[2][4] =
57 {
58 	{ 0x10, 0x21, 0x23, 0x33 },
59 	{ 0x10, 0x21, 0x23, 0x33 }
60 };
61 
62 #define fd_setdor(dor)								\
63 do {										\
64 	int new_dor = (dor);							\
65 	if (new_dor & 0xf0)							\
66 		new_dor = (new_dor & 0x0c) | floppy_selects[fdc][new_dor & 3];	\
67 	else									\
68 		new_dor &= 0x0c;						\
69 	outb(new_dor, FD_DOR);							\
70 } while (0)
71 
72 /*
73  * Someday, we'll automatically detect which drives are present...
74  */
75 static inline void fd_scandrives (void)
76 {
77 #if 0
78 	int floppy, drive_count;
79 
80 	fd_disable_irq();
81 	raw_cmd = &default_raw_cmd;
82 	raw_cmd->flags = FD_RAW_SPIN | FD_RAW_NEED_SEEK;
83 	raw_cmd->track = 0;
84 	raw_cmd->rate = ?;
85 	drive_count = 0;
86 	for (floppy = 0; floppy < 4; floppy ++) {
87 		current_drive = drive_count;
88 		/*
89 		 * Turn on floppy motor
90 		 */
91 		if (start_motor(redo_fd_request))
92 			continue;
93 		/*
94 		 * Set up FDC
95 		 */
96 		fdc_specify();
97 		/*
98 		 * Tell FDC to recalibrate
99 		 */
100 		output_byte(FD_RECALIBRATE);
101 		LAST_OUT(UNIT(floppy));
102 		/* wait for command to complete */
103 		if (!successful) {
104 			int i;
105 			for (i = drive_count; i < 3; i--)
106 				floppy_selects[fdc][i] = floppy_selects[fdc][i + 1];
107 			floppy_selects[fdc][3] = 0;
108 			floppy -= 1;
109 		} else
110 			drive_count++;
111 	}
112 #else
113 	floppy_selects[0][0] = 0x10;
114 	floppy_selects[0][1] = 0x21;
115 	floppy_selects[0][2] = 0x23;
116 	floppy_selects[0][3] = 0x33;
117 #endif
118 }
119 
120 #define FDC1 (0x3f0)
121 
122 #define FLOPPY0_TYPE 4
123 #define FLOPPY1_TYPE 4
124 
125 #define N_FDC 1
126 #define N_DRIVE 4
127 
128 #define CROSS_64KB(a,s) (0)
129 
130 /*
131  * This allows people to reverse the order of
132  * fd0 and fd1, in case their hardware is
133  * strangely connected (as some RiscPCs
134  * and A5000s seem to be).
135  */
136 static void driveswap(int *ints, int dummy, int dummy2)
137 {
138 	floppy_selects[0][0] ^= floppy_selects[0][1];
139 	floppy_selects[0][1] ^= floppy_selects[0][0];
140 	floppy_selects[0][0] ^= floppy_selects[0][1];
141 }
142 
143 #define EXTRA_FLOPPY_PARAMS ,{ "driveswap", &driveswap, NULL, 0, 0 }
144 
145 #endif
146