fdcvar.h revision 134081
1269601Snwhitehorn/*-
2269601Snwhitehorn * Copyright (c) 2004 M. Warner Losh.
3269601Snwhitehorn * All rights reserved.
4269601Snwhitehorn *
5269601Snwhitehorn * Redistribution and use in source and binary forms, with or without
6269601Snwhitehorn * modification, are permitted provided that the following conditions
7269601Snwhitehorn * are met:
8269601Snwhitehorn * 1. Redistributions of source code must retain the above copyright
9269601Snwhitehorn *    notice, this list of conditions, and the following disclaimer,
10269601Snwhitehorn *    without modification, immediately at the beginning of the file.
11269601Snwhitehorn * 2. Redistributions in binary form must reproduce the above copyright
12269601Snwhitehorn *    notice, this list of conditions and the following disclaimer in
13269601Snwhitehorn *    the documentation and/or other materials provided with the
14269601Snwhitehorn *    distribution.
15269601Snwhitehorn *
16269601Snwhitehorn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17269601Snwhitehorn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18269601Snwhitehorn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19269601Snwhitehorn * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
20269601Snwhitehorn * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21269601Snwhitehorn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22269601Snwhitehorn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23269601Snwhitehorn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24269601Snwhitehorn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25269601Snwhitehorn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26269601Snwhitehorn * SUCH DAMAGE.
27269601Snwhitehorn *
28269601Snwhitehorn * $FreeBSD: head/sys/dev/fdc/fdcvar.h 134081 2004-08-20 15:14:25Z phk $
29269601Snwhitehorn */
30269601Snwhitehorn
31269601Snwhitehorn/* XXX should audit this file to see if additional copyrights needed */
32269601Snwhitehorn
33269601Snwhitehornenum fdc_type {
34269601Snwhitehorn	FDC_NE765, FDC_ENHANCED, FDC_UNKNOWN = -1
35269601Snwhitehorn};
36269601Snwhitehorn
37269601Snwhitehorn/*
38269601Snwhitehorn * Per controller structure (softc).
39269601Snwhitehorn */
40269601Snwhitehornstruct fdc_data {
41269601Snwhitehorn	int	fdcu;		/* our unit number */
42269601Snwhitehorn	int	dmacnt;
43269601Snwhitehorn	int	dmachan;
44269601Snwhitehorn	int	flags;
45269601Snwhitehorn#define FDC_HASDMA	0x01
46269601Snwhitehorn#define FDC_STAT_VALID	0x08
47269601Snwhitehorn#define FDC_HAS_FIFO	0x10
48270412Sdumbbell#define FDC_NEEDS_RESET	0x20
49270431Sdumbbell#define FDC_NODMA	0x40
50269601Snwhitehorn#define FDC_ISPNP	0x80
51269601Snwhitehorn#define FDC_ISPCMCIA	0x100
52269601Snwhitehorn	struct	fd_data *fd;	/* The active drive */
53269601Snwhitehorn	int	retry;
54269601Snwhitehorn	int	fdout;		/* mirror of the w/o digital output reg */
55269601Snwhitehorn	u_int	status[7];	/* copy of the registers */
56270412Sdumbbell	enum	fdc_type fdct;	/* chip version of FDC */
57270431Sdumbbell	int	fdc_errs;	/* number of logged errors */
58269601Snwhitehorn	struct	bio_queue_head head;
59269601Snwhitehorn	struct	bio *bp;	/* active buffer */
60269601Snwhitehorn	struct	resource *res_ioport, *res_ctl, *res_irq, *res_drq;
61269601Snwhitehorn	int	rid_ioport, rid_ctl, rid_irq, rid_drq;
62269601Snwhitehorn	int	port_off;
63269601Snwhitehorn	bus_space_tag_t portt;
64269601Snwhitehorn	bus_space_handle_t porth;
65269601Snwhitehorn	bus_space_tag_t ctlt;
66269601Snwhitehorn	bus_space_handle_t ctlh;
67269601Snwhitehorn	int	ctl_off;
68269601Snwhitehorn	void	*fdc_intr;
69269601Snwhitehorn	struct	device *fdc_dev;
70269601Snwhitehorn	struct mtx fdc_mtx;
71269601Snwhitehorn	struct proc *fdc_thread;
72269601Snwhitehorn};
73269601Snwhitehorn
74269601Snwhitehornextern devclass_t fdc_devclass;
75269601Snwhitehorn
76269601Snwhitehornenum fdc_device_ivars {
77269601Snwhitehorn	FDC_IVAR_FDUNIT,
78269601Snwhitehorn	FDC_IVAR_FDTYPE,
79269601Snwhitehorn};
80269601Snwhitehorn
81269601Snwhitehorn__BUS_ACCESSOR(fdc, fdunit, FDC, FDUNIT, int);
82269601Snwhitehorn__BUS_ACCESSOR(fdc, fdtype, FDC, FDTYPE, int);
83269601Snwhitehorn
84269601Snwhitehornvoid fdc_release_resources(struct fdc_data *);
85269601Snwhitehornint fdc_attach(device_t);
86269601Snwhitehornint fdc_hints_probe(device_t);
87269601Snwhitehornint fdc_detach(device_t dev);
88269601Snwhitehorndevice_t fdc_add_child(device_t, const char *, int);
89269601Snwhitehornint fdc_initial_reset(device_t, struct fdc_data *);
90269601Snwhitehornint fdc_print_child(device_t, device_t);
91269601Snwhitehornint fdc_read_ivar(device_t, device_t, int, uintptr_t *);
92269601Snwhitehornint fdc_write_ivar(device_t, device_t, int, uintptr_t);
93269601Snwhitehornint fdc_isa_alloc_resources(device_t, struct fdc_data *);
94269601Snwhitehorn