i82072.c revision 1.1
11.1Swdk/*	$NetBSD: i82072.c,v 1.1 2000/08/12 22:58:56 wdk Exp $	*/
21.1Swdk/*-
31.1Swdk * Copyright (c) 2000 The NetBSD Foundation, Inc.
41.1Swdk * All rights reserved.
51.1Swdk *
61.1Swdk * This code is derived from software contributed to The NetBSD Foundation
71.1Swdk * by Wayne Knowles
81.1Swdk *
91.1Swdk * Redistribution and use in source and binary forms, with or without
101.1Swdk * modification, are permitted provided that the following conditions
111.1Swdk * are met:
121.1Swdk * 1. Redistributions of source code must retain the above copyright
131.1Swdk *    notice, this list of conditions and the following disclaimer.
141.1Swdk * 2. Redistributions in binary form must reproduce the above copyright
151.1Swdk *    notice, this list of conditions and the following disclaimer in the
161.1Swdk *    documentation and/or other materials provided with the distribution.
171.1Swdk * 3. All advertising materials mentioning features or use of this software
181.1Swdk *    must display the following acknowledgement:
191.1Swdk *        This product includes software developed by the NetBSD
201.1Swdk *        Foundation, Inc. and its contributors.
211.1Swdk * 4. Neither the name of The NetBSD Foundation nor the names of its
221.1Swdk *    contributors may be used to endorse or promote products derived
231.1Swdk *    from this software without specific prior written permission.
241.1Swdk *
251.1Swdk * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
261.1Swdk * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
271.1Swdk * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
281.1Swdk * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
291.1Swdk * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
301.1Swdk * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
311.1Swdk * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
321.1Swdk * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
331.1Swdk * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
341.1Swdk * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
351.1Swdk * POSSIBILITY OF SUCH DAMAGE.
361.1Swdk */
371.1Swdk
381.1Swdk#include <sys/param.h>
391.1Swdk#include <sys/systm.h>
401.1Swdk#include <sys/mbuf.h>
411.1Swdk#include <sys/syslog.h>
421.1Swdk#include <sys/socket.h>
431.1Swdk#include <sys/device.h>
441.1Swdk
451.1Swdk#include <machine/cpu.h>
461.1Swdk#include <machine/autoconf.h>
471.1Swdk#include <machine/mainboard.h>
481.1Swdk#include <machine/bus.h>
491.1Swdk
501.1Swdk#define	I82072_STATUS	0x000003
511.1Swdk#define	I82072_DATA	0x000007
521.1Swdk#define	I82072_TC	0x800003
531.1Swdk
541.1Swdkstruct	fd_softc {
551.1Swdk        struct  device dev;
561.1Swdk        struct  evcnt  fd_intrcnt;
571.1Swdk	bus_space_tag_t	fd_bst;
581.1Swdk	bus_space_handle_t fd_bsh;
591.1Swdk        int     unit;
601.1Swdk};
611.1Swdk
621.1Swdkstatic int	fd_match __P((struct device *, struct cfdata *, void *));
631.1Swdkstatic void	fd_attach __P((struct device *, struct device *, void *));
641.1Swdkstatic void     fd_reset __P((struct fd_softc *));
651.1Swdk
661.1Swdkstruct cfattach fd_ca = {
671.1Swdk	sizeof(struct fd_softc), fd_match, fd_attach
681.1Swdk};
691.1Swdk
701.1Swdkint
711.1Swdkfd_match(parent, cf, aux)
721.1Swdk	struct device *parent;
731.1Swdk	struct cfdata *cf;
741.1Swdk	void *aux;
751.1Swdk{
761.1Swdk	return 1;
771.1Swdk}
781.1Swdk
791.1Swdkvoid
801.1Swdkfd_attach(parent, self, aux)
811.1Swdk	struct device *parent, *self;
821.1Swdk	void *aux;
831.1Swdk{
841.1Swdk        struct fd_softc *sc = (void *)self;
851.1Swdk	struct confargs *ca = aux;
861.1Swdk
871.1Swdk	sc->fd_bst = ca->ca_bustag;
881.1Swdk	if (bus_space_map(ca->ca_bustag, ca->ca_addr,
891.1Swdk			  0x1000000,
901.1Swdk			  BUS_SPACE_MAP_LINEAR,
911.1Swdk			  &sc->fd_bsh) != 0) {
921.1Swdk		printf("%s: cannot map registers\n", self->dv_xname);
931.1Swdk		return;
941.1Swdk	}
951.1Swdk	evcnt_attach_dynamic(&sc->fd_intrcnt, EVCNT_TYPE_INTR, NULL,
961.1Swdk			     self->dv_xname, "intr");
971.1Swdk
981.1Swdk	fd_reset(sc);
991.1Swdk	printf(": not fully implemented\n");
1001.1Swdk}
1011.1Swdk
1021.1Swdkvoid
1031.1Swdkfd_reset(sc)
1041.1Swdk        struct fd_softc *sc;
1051.1Swdk{
1061.1Swdk	/* This clears any pending interrupts from the i82072 FDC */
1071.1Swdk	bus_space_write_1(sc->fd_bst, sc->fd_bsh, I82072_STATUS, 0x80);
1081.1Swdk	DELAY(1000);
1091.1Swdk	bus_space_write_1(sc->fd_bst, sc->fd_bsh, I82072_TC, 0x01);
1101.1Swdk	DELAY(1000);
1111.1Swdk}
1121.1Swdk
1131.1Swdkvoid
1141.1Swdkfdopen()
1151.1Swdk{}
1161.1Swdk
1171.1Swdkvoid
1181.1Swdkfdclose()
1191.1Swdk{}
1201.1Swdk
1211.1Swdkvoid
1221.1Swdkfdstrategy()
1231.1Swdk{}
1241.1Swdk
1251.1Swdkvoid
1261.1Swdkfdioctl()
1271.1Swdk{}
1281.1Swdk
1291.1Swdkvoid
1301.1Swdkfddump()
1311.1Swdk{}
1321.1Swdk
1331.1Swdkvoid
1341.1Swdkfdsize()
1351.1Swdk{}
1361.1Swdk
1371.1Swdkvoid
1381.1Swdkfdintr(unit)
1391.1Swdk	int unit;
1401.1Swdk{
1411.1Swdk	struct fd_softc *sc;
1421.1Swdk	extern struct cfdriver fd_cd;
1431.1Swdk
1441.1Swdk	if (unit < fd_cd.cd_ndevs) {
1451.1Swdk		sc = fd_cd.cd_devs[unit];
1461.1Swdk		printf("stray floppy interrupt\n");
1471.1Swdk		sc->fd_intrcnt.ev_count++;
1481.1Swdk		fd_reset(sc);
1491.1Swdk	}
1501.1Swdk}
151