i82072.c revision 1.1
1/*	$NetBSD: i82072.c,v 1.1 2000/08/12 22:58:56 wdk Exp $	*/
2/*-
3 * Copyright (c) 2000 The NetBSD Foundation, Inc.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Wayne Knowles
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 *    must display the following acknowledgement:
19 *        This product includes software developed by the NetBSD
20 *        Foundation, Inc. and its contributors.
21 * 4. Neither the name of The NetBSD Foundation nor the names of its
22 *    contributors may be used to endorse or promote products derived
23 *    from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/mbuf.h>
41#include <sys/syslog.h>
42#include <sys/socket.h>
43#include <sys/device.h>
44
45#include <machine/cpu.h>
46#include <machine/autoconf.h>
47#include <machine/mainboard.h>
48#include <machine/bus.h>
49
50#define	I82072_STATUS	0x000003
51#define	I82072_DATA	0x000007
52#define	I82072_TC	0x800003
53
54struct	fd_softc {
55        struct  device dev;
56        struct  evcnt  fd_intrcnt;
57	bus_space_tag_t	fd_bst;
58	bus_space_handle_t fd_bsh;
59        int     unit;
60};
61
62static int	fd_match __P((struct device *, struct cfdata *, void *));
63static void	fd_attach __P((struct device *, struct device *, void *));
64static void     fd_reset __P((struct fd_softc *));
65
66struct cfattach fd_ca = {
67	sizeof(struct fd_softc), fd_match, fd_attach
68};
69
70int
71fd_match(parent, cf, aux)
72	struct device *parent;
73	struct cfdata *cf;
74	void *aux;
75{
76	return 1;
77}
78
79void
80fd_attach(parent, self, aux)
81	struct device *parent, *self;
82	void *aux;
83{
84        struct fd_softc *sc = (void *)self;
85	struct confargs *ca = aux;
86
87	sc->fd_bst = ca->ca_bustag;
88	if (bus_space_map(ca->ca_bustag, ca->ca_addr,
89			  0x1000000,
90			  BUS_SPACE_MAP_LINEAR,
91			  &sc->fd_bsh) != 0) {
92		printf("%s: cannot map registers\n", self->dv_xname);
93		return;
94	}
95	evcnt_attach_dynamic(&sc->fd_intrcnt, EVCNT_TYPE_INTR, NULL,
96			     self->dv_xname, "intr");
97
98	fd_reset(sc);
99	printf(": not fully implemented\n");
100}
101
102void
103fd_reset(sc)
104        struct fd_softc *sc;
105{
106	/* This clears any pending interrupts from the i82072 FDC */
107	bus_space_write_1(sc->fd_bst, sc->fd_bsh, I82072_STATUS, 0x80);
108	DELAY(1000);
109	bus_space_write_1(sc->fd_bst, sc->fd_bsh, I82072_TC, 0x01);
110	DELAY(1000);
111}
112
113void
114fdopen()
115{}
116
117void
118fdclose()
119{}
120
121void
122fdstrategy()
123{}
124
125void
126fdioctl()
127{}
128
129void
130fddump()
131{}
132
133void
134fdsize()
135{}
136
137void
138fdintr(unit)
139	int unit;
140{
141	struct fd_softc *sc;
142	extern struct cfdriver fd_cd;
143
144	if (unit < fd_cd.cd_ndevs) {
145		sc = fd_cd.cd_devs[unit];
146		printf("stray floppy interrupt\n");
147		sc->fd_intrcnt.ev_count++;
148		fd_reset(sc);
149	}
150}
151