fdcvar.h revision 132286
197403Sobrien/*- 297403Sobrien * Copyright (c) 2004 M. Warner Losh. 397403Sobrien * All rights reserved. 497403Sobrien * 597403Sobrien * Redistribution and use in source and binary forms, with or without 697403Sobrien * modification, are permitted provided that the following conditions 797403Sobrien * are met: 897403Sobrien * 1. Redistributions of source code must retain the above copyright 997403Sobrien * notice, this list of conditions, and the following disclaimer, 1097403Sobrien * without modification, immediately at the beginning of the file. 1197403Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1297403Sobrien * notice, this list of conditions and the following disclaimer in 1397403Sobrien * the documentation and/or other materials provided with the 1497403Sobrien * distribution. 1597403Sobrien * 1697403Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1797403Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1897403Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1997403Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 2097403Sobrien * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2197403Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2297403Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2397403Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2497403Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2597403Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2697403Sobrien * SUCH DAMAGE. 2797403Sobrien * 2897403Sobrien * $FreeBSD: head/sys/pc98/cbus/fdcvar.h 132286 2004-07-17 10:07:19Z nyan $ 2997403Sobrien */ 3097403Sobrien 3197403Sobrien/* XXX should audit this file to see if additional copyrights needed */ 3297403Sobrien 3397403Sobrienenum fdc_type 3497403Sobrien{ 3597403Sobrien FDC_NE765, FDC_ENHANCED, FDC_UNKNOWN = -1 3697403Sobrien}; 3797403Sobrien 3897403Sobrienenum fdc_states { 3997403Sobrien DEVIDLE, 4097403Sobrien FINDWORK, 4197403Sobrien DOSEEK, 4297403Sobrien SEEKCOMPLETE , 4397403Sobrien IOCOMPLETE, 4497403Sobrien RECALCOMPLETE, 4597403Sobrien STARTRECAL, 4697403Sobrien RESETCTLR, 4797403Sobrien SEEKWAIT, 4897403Sobrien RECALWAIT, 4997403Sobrien MOTORWAIT, 5097403Sobrien IOTIMEDOUT, 5197403Sobrien RESETCOMPLETE, 5297403Sobrien PIOREAD 5397403Sobrien}; 5497403Sobrien 5597403Sobrien#ifdef FDC_DEBUG 5697403Sobrienstatic char const * const fdstates[] = { 5797403Sobrien "DEVIDLE", 5897403Sobrien "FINDWORK", 5997403Sobrien "DOSEEK", 6097403Sobrien "SEEKCOMPLETE", 6197403Sobrien "IOCOMPLETE", 6297403Sobrien "RECALCOMPLETE", 6397403Sobrien "STARTRECAL", 6497403Sobrien "RESETCTLR", 6597403Sobrien "SEEKWAIT", 6697403Sobrien "RECALWAIT", 6797403Sobrien "MOTORWAIT", 6897403Sobrien "IOTIMEDOUT", 6997403Sobrien "RESETCOMPLETE", 7097403Sobrien "PIOREAD" 7197403Sobrien}; 7297403Sobrien#endif 7397403Sobrien 7497403Sobrien/* 7597403Sobrien * Per controller structure (softc). 7697403Sobrien */ 7797403Sobrienstruct fdc_data 7897403Sobrien{ 7997403Sobrien int fdcu; /* our unit number */ 8097403Sobrien int dmacnt; 8197403Sobrien int dmachan; 8297403Sobrien int flags; 8397403Sobrien#define FDC_STAT_VALID 0x08 8497403Sobrien#define FDC_HAS_FIFO 0x10 8597403Sobrien#define FDC_NEEDS_RESET 0x20 8697403Sobrien#define FDC_NODMA 0x40 8797403Sobrien#define FDC_ISPNP 0x80 8897403Sobrien#define FDC_ISPCMCIA 0x100 8997403Sobrien struct fd_data *fd; 9097403Sobrien int fdu; /* the active drive */ 9197403Sobrien enum fdc_states state; 9297403Sobrien int retry; 9397403Sobrien#ifndef PC98 9497403Sobrien int fdout; /* mirror of the w/o digital output reg */ 9597403Sobrien#endif 9697403Sobrien u_int status[7]; /* copy of the registers */ 9797403Sobrien enum fdc_type fdct; /* chip version of FDC */ 9897403Sobrien int fdc_errs; /* number of logged errors */ 9997403Sobrien int dma_overruns; /* number of DMA overruns */ 10097403Sobrien struct bio_queue_head head; 10197403Sobrien struct bio *bp; /* active buffer */ 10297403Sobrien#ifdef PC98 10397403Sobrien struct resource *res_ioport, *res_fdsio, *res_fdemsio; 10497403Sobrien struct resource *res_irq, *res_drq; 10597403Sobrien int rid_ioport, rid_irq, rid_drq; 10697403Sobrien#else 10797403Sobrien struct resource *res_ioport, *res_ctl, *res_irq, *res_drq; 10897403Sobrien int rid_ioport, rid_ctl, rid_irq, rid_drq; 10997403Sobrien#endif 11097403Sobrien int port_off; 11197403Sobrien bus_space_tag_t portt; 11297403Sobrien bus_space_handle_t porth; 11397403Sobrien#ifdef PC98 11497403Sobrien bus_space_tag_t sc_fdsiot; 11597403Sobrien bus_space_handle_t sc_fdsioh; 11697403Sobrien bus_space_tag_t sc_fdemsiot; 11797403Sobrien bus_space_handle_t sc_fdemsioh; 11897403Sobrien#else 119 bus_space_tag_t ctlt; 120 bus_space_handle_t ctlh; 121#endif 122 void *fdc_intr; 123 struct device *fdc_dev; 124#ifndef PC98 125 void (*fdctl_wr)(struct fdc_data *fdc, u_int8_t v); 126#endif 127}; 128 129typedef int fdu_t; 130typedef int fdcu_t; 131typedef int fdsu_t; 132typedef struct fd_data *fd_p; 133typedef struct fdc_data *fdc_p; 134typedef enum fdc_type fdc_t; 135 136/* error returns for fd_cmd() */ 137#define FD_FAILED -1 138#define FD_NOT_VALID -2 139#define FDC_ERRMAX 100 /* do not log more */ 140 141extern devclass_t fdc_devclass; 142 143enum fdc_device_ivars { 144 FDC_IVAR_FDUNIT, 145 FDC_IVAR_FDTYPE, 146}; 147 148__BUS_ACCESSOR(fdc, fdunit, FDC, FDUNIT, int); 149__BUS_ACCESSOR(fdc, fdtype, FDC, FDTYPE, int); 150 151int fdc_alloc_resources(struct fdc_data *); 152#ifndef PC98 153void fdout_wr(fdc_p, u_int8_t); 154#endif 155int fd_cmd(struct fdc_data *, int, ...); 156void fdc_release_resources(struct fdc_data *); 157int fdc_attach(device_t); 158int fdc_hints_probe(device_t); 159int fdc_detach(device_t dev); 160device_t fdc_add_child(device_t, const char *, int); 161int fdc_initial_reset(struct fdc_data *); 162int fdc_print_child(device_t, device_t); 163int fdc_read_ivar(device_t, device_t, int, uintptr_t *); 164int fdc_write_ivar(device_t, device_t, int, uintptr_t); 165#ifndef PC98 166int fdc_isa_alloc_resources(device_t, struct fdc_data *); 167#endif 168