18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 38c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 48c2ecf20Sopenharmony_ci * for more details. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 1998, 2003 by Ralf Baechle 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci#ifndef __ASM_MACH_JAZZ_FLOPPY_H 98c2ecf20Sopenharmony_ci#define __ASM_MACH_JAZZ_FLOPPY_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/delay.h> 128c2ecf20Sopenharmony_ci#include <linux/linkage.h> 138c2ecf20Sopenharmony_ci#include <linux/types.h> 148c2ecf20Sopenharmony_ci#include <linux/mm.h> 158c2ecf20Sopenharmony_ci#include <asm/addrspace.h> 168c2ecf20Sopenharmony_ci#include <asm/jazz.h> 178c2ecf20Sopenharmony_ci#include <asm/jazzdma.h> 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_cistatic inline unsigned char fd_inb(unsigned int base, unsigned int reg) 208c2ecf20Sopenharmony_ci{ 218c2ecf20Sopenharmony_ci unsigned char c; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci c = *(volatile unsigned char *) (base + reg); 248c2ecf20Sopenharmony_ci udelay(1); 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci return c; 278c2ecf20Sopenharmony_ci} 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_cistatic inline void fd_outb(unsigned char value, unsigned int base, unsigned int reg) 308c2ecf20Sopenharmony_ci{ 318c2ecf20Sopenharmony_ci *(volatile unsigned char *) (base + reg) = value; 328c2ecf20Sopenharmony_ci} 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* 358c2ecf20Sopenharmony_ci * How to access the floppy DMA functions. 368c2ecf20Sopenharmony_ci */ 378c2ecf20Sopenharmony_cistatic inline void fd_enable_dma(void) 388c2ecf20Sopenharmony_ci{ 398c2ecf20Sopenharmony_ci vdma_enable(JAZZ_FLOPPY_DMA); 408c2ecf20Sopenharmony_ci} 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistatic inline void fd_disable_dma(void) 438c2ecf20Sopenharmony_ci{ 448c2ecf20Sopenharmony_ci vdma_disable(JAZZ_FLOPPY_DMA); 458c2ecf20Sopenharmony_ci} 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_cistatic inline int fd_request_dma(void) 488c2ecf20Sopenharmony_ci{ 498c2ecf20Sopenharmony_ci return 0; 508c2ecf20Sopenharmony_ci} 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistatic inline void fd_free_dma(void) 538c2ecf20Sopenharmony_ci{ 548c2ecf20Sopenharmony_ci} 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_cistatic inline void fd_clear_dma_ff(void) 578c2ecf20Sopenharmony_ci{ 588c2ecf20Sopenharmony_ci} 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic inline void fd_set_dma_mode(char mode) 618c2ecf20Sopenharmony_ci{ 628c2ecf20Sopenharmony_ci vdma_set_mode(JAZZ_FLOPPY_DMA, mode); 638c2ecf20Sopenharmony_ci} 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistatic inline void fd_set_dma_addr(char *a) 668c2ecf20Sopenharmony_ci{ 678c2ecf20Sopenharmony_ci vdma_set_addr(JAZZ_FLOPPY_DMA, vdma_phys2log(CPHYSADDR((unsigned long)a))); 688c2ecf20Sopenharmony_ci} 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistatic inline void fd_set_dma_count(unsigned int count) 718c2ecf20Sopenharmony_ci{ 728c2ecf20Sopenharmony_ci vdma_set_count(JAZZ_FLOPPY_DMA, count); 738c2ecf20Sopenharmony_ci} 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_cistatic inline int fd_get_dma_residue(void) 768c2ecf20Sopenharmony_ci{ 778c2ecf20Sopenharmony_ci return vdma_get_residue(JAZZ_FLOPPY_DMA); 788c2ecf20Sopenharmony_ci} 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_cistatic inline void fd_enable_irq(void) 818c2ecf20Sopenharmony_ci{ 828c2ecf20Sopenharmony_ci} 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_cistatic inline void fd_disable_irq(void) 858c2ecf20Sopenharmony_ci{ 868c2ecf20Sopenharmony_ci} 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_cistatic inline int fd_request_irq(void) 898c2ecf20Sopenharmony_ci{ 908c2ecf20Sopenharmony_ci return request_irq(FLOPPY_IRQ, floppy_interrupt, 918c2ecf20Sopenharmony_ci 0, "floppy", NULL); 928c2ecf20Sopenharmony_ci} 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_cistatic inline void fd_free_irq(void) 958c2ecf20Sopenharmony_ci{ 968c2ecf20Sopenharmony_ci free_irq(FLOPPY_IRQ, NULL); 978c2ecf20Sopenharmony_ci} 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_cistatic inline unsigned long fd_getfdaddr1(void) 1008c2ecf20Sopenharmony_ci{ 1018c2ecf20Sopenharmony_ci return JAZZ_FDC_BASE; 1028c2ecf20Sopenharmony_ci} 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_cistatic inline unsigned long fd_dma_mem_alloc(unsigned long size) 1058c2ecf20Sopenharmony_ci{ 1068c2ecf20Sopenharmony_ci unsigned long mem; 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci mem = __get_dma_pages(GFP_KERNEL, get_order(size)); 1098c2ecf20Sopenharmony_ci if(!mem) 1108c2ecf20Sopenharmony_ci return 0; 1118c2ecf20Sopenharmony_ci vdma_alloc(CPHYSADDR(mem), size); /* XXX error checking */ 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci return mem; 1148c2ecf20Sopenharmony_ci} 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_cistatic inline void fd_dma_mem_free(unsigned long addr, unsigned long size) 1178c2ecf20Sopenharmony_ci{ 1188c2ecf20Sopenharmony_ci vdma_free(vdma_phys2log(CPHYSADDR(addr))); 1198c2ecf20Sopenharmony_ci free_pages(addr, get_order(size)); 1208c2ecf20Sopenharmony_ci} 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cistatic inline unsigned long fd_drive_type(unsigned long n) 1238c2ecf20Sopenharmony_ci{ 1248c2ecf20Sopenharmony_ci /* XXX This is wrong for machines with ED 2.88mb disk drives like the 1258c2ecf20Sopenharmony_ci Olivetti M700. Anyway, we should suck this from the ARC 1268c2ecf20Sopenharmony_ci firmware. */ 1278c2ecf20Sopenharmony_ci if (n == 0) 1288c2ecf20Sopenharmony_ci return 4; /* 3,5", 1.44mb */ 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci return 0; 1318c2ecf20Sopenharmony_ci} 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci#endif /* __ASM_MACH_JAZZ_FLOPPY_H */ 134