~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/powerpc/include/asm/floppy.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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  */
 10 #ifndef __ASM_POWERPC_FLOPPY_H
 11 #define __ASM_POWERPC_FLOPPY_H
 12 #ifdef __KERNEL__
 13 
 14 #include <asm/machdep.h>
 15 
 16 #define fd_inb(base, reg)               inb_p((base) + (reg))
 17 #define fd_outb(value, base, reg)       outb_p(value, (base) + (reg))
 18 
 19 #define fd_enable_dma()         enable_dma(FLOPPY_DMA)
 20 #define fd_disable_dma()         fd_ops->_disable_dma(FLOPPY_DMA)
 21 #define fd_free_dma()           fd_ops->_free_dma(FLOPPY_DMA)
 22 #define fd_clear_dma_ff()       clear_dma_ff(FLOPPY_DMA)
 23 #define fd_set_dma_mode(mode)   set_dma_mode(FLOPPY_DMA, mode)
 24 #define fd_set_dma_count(count) set_dma_count(FLOPPY_DMA, count)
 25 #define fd_get_dma_residue()    fd_ops->_get_dma_residue(FLOPPY_DMA)
 26 #define fd_enable_irq()         enable_irq(FLOPPY_IRQ)
 27 #define fd_disable_irq()        disable_irq(FLOPPY_IRQ)
 28 #define fd_free_irq()           free_irq(FLOPPY_IRQ, NULL);
 29 
 30 #include <linux/pci.h>
 31 #include <asm/ppc-pci.h>        /* for isa_bridge_pcidev */
 32 
 33 #define fd_dma_setup(addr,size,mode,io) fd_ops->_dma_setup(addr,size,mode,io)
 34 
 35 static int fd_request_dma(void);
 36 
 37 struct fd_dma_ops {
 38         void (*_disable_dma)(unsigned int dmanr);
 39         void (*_free_dma)(unsigned int dmanr);
 40         int (*_get_dma_residue)(unsigned int dummy);
 41         int (*_dma_setup)(char *addr, unsigned long size, int mode, int io);
 42 };
 43 
 44 static int virtual_dma_count;
 45 static int virtual_dma_residue;
 46 static char *virtual_dma_addr;
 47 static int virtual_dma_mode;
 48 static int doing_vdma;
 49 static struct fd_dma_ops *fd_ops;
 50 
 51 static irqreturn_t floppy_hardint(int irq, void *dev_id)
 52 {
 53         unsigned char st;
 54         int lcount;
 55         char *lptr;
 56 
 57         if (!doing_vdma)
 58                 return floppy_interrupt(irq, dev_id);
 59 
 60 
 61         st = 1;
 62         for (lcount=virtual_dma_count, lptr=virtual_dma_addr;
 63              lcount; lcount--, lptr++) {
 64                 st = inb(virtual_dma_port + FD_STATUS);
 65                 st &= STATUS_DMA | STATUS_READY;
 66                 if (st != (STATUS_DMA | STATUS_READY))
 67                         break;
 68                 if (virtual_dma_mode)
 69                         outb_p(*lptr, virtual_dma_port + FD_DATA);
 70                 else
 71                         *lptr = inb_p(virtual_dma_port + FD_DATA);
 72         }
 73         virtual_dma_count = lcount;
 74         virtual_dma_addr = lptr;
 75         st = inb(virtual_dma_port + FD_STATUS);
 76 
 77         if (st == STATUS_DMA)
 78                 return IRQ_HANDLED;
 79         if (!(st & STATUS_DMA)) {
 80                 virtual_dma_residue += virtual_dma_count;
 81                 virtual_dma_count=0;
 82                 doing_vdma = 0;
 83                 floppy_interrupt(irq, dev_id);
 84                 return IRQ_HANDLED;
 85         }
 86         return IRQ_HANDLED;
 87 }
 88 
 89 static void vdma_disable_dma(unsigned int dummy)
 90 {
 91         doing_vdma = 0;
 92         virtual_dma_residue += virtual_dma_count;
 93         virtual_dma_count=0;
 94 }
 95 
 96 static void vdma_nop(unsigned int dummy)
 97 {
 98 }
 99 
100 
101 static int vdma_get_dma_residue(unsigned int dummy)
102 {
103         return virtual_dma_count + virtual_dma_residue;
104 }
105 
106 
107 static int fd_request_irq(void)
108 {
109         if (can_use_virtual_dma)
110                 return request_irq(FLOPPY_IRQ, floppy_hardint,
111                                    0, "floppy", NULL);
112         else
113                 return request_irq(FLOPPY_IRQ, floppy_interrupt,
114                                    0, "floppy", NULL);
115 }
116 
117 static int vdma_dma_setup(char *addr, unsigned long size, int mode, int io)
118 {
119         doing_vdma = 1;
120         virtual_dma_port = io;
121         virtual_dma_mode = (mode  == DMA_MODE_WRITE);
122         virtual_dma_addr = addr;
123         virtual_dma_count = size;
124         virtual_dma_residue = 0;
125         return 0;
126 }
127 
128 static int hard_dma_setup(char *addr, unsigned long size, int mode, int io)
129 {
130         static unsigned long prev_size;
131         static dma_addr_t bus_addr = 0;
132         static char *prev_addr;
133         static int prev_dir;
134         int dir;
135 
136         doing_vdma = 0;
137         dir = (mode == DMA_MODE_READ) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
138 
139         if (bus_addr 
140             && (addr != prev_addr || size != prev_size || dir != prev_dir)) {
141                 /* different from last time -- unmap prev */
142                 dma_unmap_single(&isa_bridge_pcidev->dev, bus_addr, prev_size,
143                                  prev_dir);
144                 bus_addr = 0;
145         }
146 
147         if (!bus_addr)  /* need to map it */
148                 bus_addr = dma_map_single(&isa_bridge_pcidev->dev, addr, size,
149                                           dir);
150 
151         /* remember this one as prev */
152         prev_addr = addr;
153         prev_size = size;
154         prev_dir = dir;
155 
156         fd_clear_dma_ff();
157         fd_set_dma_mode(mode);
158         set_dma_addr(FLOPPY_DMA, bus_addr);
159         fd_set_dma_count(size);
160         virtual_dma_port = io;
161         fd_enable_dma();
162 
163         return 0;
164 }
165 
166 static struct fd_dma_ops real_dma_ops =
167 {
168         ._disable_dma = disable_dma,
169         ._free_dma = free_dma,
170         ._get_dma_residue = get_dma_residue,
171         ._dma_setup = hard_dma_setup
172 };
173 
174 static struct fd_dma_ops virt_dma_ops =
175 {
176         ._disable_dma = vdma_disable_dma,
177         ._free_dma = vdma_nop,
178         ._get_dma_residue = vdma_get_dma_residue,
179         ._dma_setup = vdma_dma_setup
180 };
181 
182 static int fd_request_dma(void)
183 {
184         if (can_use_virtual_dma & 1) {
185                 fd_ops = &virt_dma_ops;
186                 return 0;
187         }
188         else {
189                 fd_ops = &real_dma_ops;
190                 return request_dma(FLOPPY_DMA, "floppy");
191         }
192 }
193 
194 static int FDC1 = 0x3f0;
195 static int FDC2 = -1;
196 
197 /*
198  * Again, the CMOS information not available
199  */
200 #define FLOPPY0_TYPE 6
201 #define FLOPPY1_TYPE 0
202 
203 #define N_FDC 2                 /* Don't change this! */
204 #define N_DRIVE 8
205 
206 /*
207  * The PowerPC has no problems with floppy DMA crossing 64k borders.
208  */
209 #define CROSS_64KB(a,s) (0)
210 
211 #define EXTRA_FLOPPY_PARAMS
212 
213 #endif /* __KERNEL__ */
214 #endif /* __ASM_POWERPC_FLOPPY_H */
215 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php