1132215Snjl/*- 2140469Simp * Copyright (c) 2004-2005 M. Warner Losh. 3131767Simp * All rights reserved. 4131767Simp * 5131767Simp * Redistribution and use in source and binary forms, with or without 6131767Simp * modification, are permitted provided that the following conditions 7131767Simp * are met: 8131767Simp * 1. Redistributions of source code must retain the above copyright 9140040Simp * notice, this list of conditions and the following disclaimer. 10131767Simp * 2. Redistributions in binary form must reproduce the above copyright 11140040Simp * notice, this list of conditions and the following disclaimer in the 12140040Simp * documentation and/or other materials provided with the distribution. 13131767Simp * 14131767Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15131767Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16131767Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17140040Simp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18140040Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19131767Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20131767Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21131767Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22131767Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23131767Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24131767Simp * SUCH DAMAGE. 25131767Simp * 26131767Simp * $FreeBSD$ 27131767Simp */ 28131767Simp 29131767Simp/* XXX should audit this file to see if additional copyrights needed */ 30131767Simp 31134081Sphkenum fdc_type { 32131767Simp FDC_NE765, FDC_ENHANCED, FDC_UNKNOWN = -1 33131767Simp}; 34131767Simp 35131767Simp/* 36131767Simp * Per controller structure (softc). 37131767Simp */ 38134081Sphkstruct fdc_data { 39131767Simp int fdcu; /* our unit number */ 40131767Simp int dmachan; 41131767Simp int flags; 42134081Sphk#define FDC_HASDMA 0x01 43131767Simp#define FDC_STAT_VALID 0x08 44131767Simp#define FDC_HAS_FIFO 0x10 45131767Simp#define FDC_NEEDS_RESET 0x20 46140469Simp#define FDC_NODMA 0x40 /* Don't do DMA */ 47140469Simp#define FDC_NOFAST 0x80 /* Don't register isr as a fast one */ 48135638Sjoerg#define FDC_KTHREAD_EXIT 0x1000 /* request worker thread to stop */ 49135638Sjoerg#define FDC_KTHREAD_ALIVE 0x2000 /* worker thread is alive */ 50134081Sphk struct fd_data *fd; /* The active drive */ 51131767Simp int retry; 52131767Simp int fdout; /* mirror of the w/o digital output reg */ 53131767Simp u_int status[7]; /* copy of the registers */ 54131767Simp enum fdc_type fdct; /* chip version of FDC */ 55131767Simp int fdc_errs; /* number of logged errors */ 56131767Simp struct bio_queue_head head; 57131767Simp struct bio *bp; /* active buffer */ 58140469Simp struct resource *res_irq, *res_drq; 59140469Simp int rid_irq, rid_drq; 60140469Simp#define FDC_MAXREG 8 61140469Simp int ridio[FDC_MAXREG]; 62140469Simp struct resource *resio[FDC_MAXREG]; 63140469Simp bus_space_tag_t iot; 64140469Simp bus_space_handle_t ioh[FDC_MAXREG]; 65140469Simp int ioff[FDC_MAXREG]; 66131767Simp void *fdc_intr; 67131767Simp struct device *fdc_dev; 68134081Sphk struct mtx fdc_mtx; 69134081Sphk struct proc *fdc_thread; 70131767Simp}; 71131767Simp 72131767Simpextern devclass_t fdc_devclass; 73131767Simp 74132048Snjlenum fdc_device_ivars { 75132048Snjl FDC_IVAR_FDUNIT, 76132048Snjl FDC_IVAR_FDTYPE, 77132048Snjl}; 78132048Snjl 79132048Snjl__BUS_ACCESSOR(fdc, fdunit, FDC, FDUNIT, int); 80132048Snjl__BUS_ACCESSOR(fdc, fdtype, FDC, FDTYPE, int); 81132048Snjl 82131767Simpvoid fdc_release_resources(struct fdc_data *); 83131767Simpint fdc_attach(device_t); 84132215Snjlint fdc_hints_probe(device_t); 85131767Simpint fdc_detach(device_t dev); 86132215Snjldevice_t fdc_add_child(device_t, const char *, int); 87134081Sphkint fdc_initial_reset(device_t, struct fdc_data *); 88131767Simpint fdc_print_child(device_t, device_t); 89131767Simpint fdc_read_ivar(device_t, device_t, int, uintptr_t *); 90132048Snjlint fdc_write_ivar(device_t, device_t, int, uintptr_t); 91132215Snjlint fdc_isa_alloc_resources(device_t, struct fdc_data *); 92