1*f79ee556Stedu /* $OpenBSD: if_le.c,v 1.20 2014/12/22 02:28:51 tedu Exp $ */
29b5b98acSderaadt /* $NetBSD: if_le_isa.c,v 1.2 1996/05/12 23:52:56 mycroft Exp $ */
39b5b98acSderaadt
49b5b98acSderaadt /*-
59b5b98acSderaadt * Copyright (c) 1995 Charles M. Hannum. All rights reserved.
69b5b98acSderaadt * Copyright (c) 1992, 1993
79b5b98acSderaadt * The Regents of the University of California. All rights reserved.
89b5b98acSderaadt *
99b5b98acSderaadt * This code is derived from software contributed to Berkeley by
109b5b98acSderaadt * Ralph Campbell and Rick Macklem.
119b5b98acSderaadt *
129b5b98acSderaadt * Redistribution and use in source and binary forms, with or without
139b5b98acSderaadt * modification, are permitted provided that the following conditions
149b5b98acSderaadt * are met:
159b5b98acSderaadt * 1. Redistributions of source code must retain the above copyright
169b5b98acSderaadt * notice, this list of conditions and the following disclaimer.
179b5b98acSderaadt * 2. Redistributions in binary form must reproduce the above copyright
189b5b98acSderaadt * notice, this list of conditions and the following disclaimer in the
199b5b98acSderaadt * documentation and/or other materials provided with the distribution.
2029295d1cSmillert * 3. Neither the name of the University nor the names of its contributors
219b5b98acSderaadt * may be used to endorse or promote products derived from this software
229b5b98acSderaadt * without specific prior written permission.
239b5b98acSderaadt *
249b5b98acSderaadt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
259b5b98acSderaadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
269b5b98acSderaadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
279b5b98acSderaadt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
289b5b98acSderaadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
299b5b98acSderaadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
309b5b98acSderaadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
319b5b98acSderaadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
329b5b98acSderaadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
339b5b98acSderaadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
349b5b98acSderaadt * SUCH DAMAGE.
359b5b98acSderaadt *
369b5b98acSderaadt * @(#)if_le.c 8.2 (Berkeley) 11/16/93
379b5b98acSderaadt */
389b5b98acSderaadt
399b5b98acSderaadt #include "bpfilter.h"
409b5b98acSderaadt #include "isadma.h"
419b5b98acSderaadt
429b5b98acSderaadt #include <sys/param.h>
439b5b98acSderaadt #include <sys/systm.h>
449b5b98acSderaadt #include <sys/mbuf.h>
459b5b98acSderaadt #include <sys/syslog.h>
469b5b98acSderaadt #include <sys/socket.h>
479b5b98acSderaadt #include <sys/device.h>
489b5b98acSderaadt
499b5b98acSderaadt #include <net/if.h>
5097f4b186Sjason #include <net/if_media.h>
519b5b98acSderaadt
529b5b98acSderaadt #include <netinet/in.h>
539b5b98acSderaadt #include <netinet/if_ether.h>
549b5b98acSderaadt
559b5b98acSderaadt #include <machine/cpu.h>
569b5b98acSderaadt #include <machine/intr.h>
579b5b98acSderaadt
589b5b98acSderaadt #include <dev/isa/isareg.h>
599b5b98acSderaadt #include <dev/isa/isavar.h>
609b5b98acSderaadt #include <dev/isa/isadmavar.h>
619b5b98acSderaadt
620ec3b04cSmiod #include <dev/ic/lancereg.h>
630ec3b04cSmiod #include <dev/ic/lancevar.h>
649b5b98acSderaadt #include <dev/ic/am7990reg.h>
659b5b98acSderaadt #include <dev/ic/am7990var.h>
669b5b98acSderaadt
679b5b98acSderaadt #include <dev/isa/if_levar.h>
689b5b98acSderaadt
69899616daSderaadt void
le_isa_wrcsr(struct lance_softc * sc,uint16_t port,uint16_t val)700ec3b04cSmiod le_isa_wrcsr(struct lance_softc *sc, uint16_t port, uint16_t val)
719b5b98acSderaadt {
729b5b98acSderaadt struct le_softc *lesc = (struct le_softc *)sc;
739b5b98acSderaadt bus_space_tag_t iot = lesc->sc_iot;
749b5b98acSderaadt bus_space_handle_t ioh = lesc->sc_ioh;
759b5b98acSderaadt
769b5b98acSderaadt bus_space_write_2(iot, ioh, lesc->sc_rap, port);
779b5b98acSderaadt bus_space_write_2(iot, ioh, lesc->sc_rdp, val);
789b5b98acSderaadt }
799b5b98acSderaadt
800ec3b04cSmiod uint16_t
le_isa_rdcsr(struct lance_softc * sc,uint16_t port)810ec3b04cSmiod le_isa_rdcsr(struct lance_softc *sc, uint16_t port)
829b5b98acSderaadt {
839b5b98acSderaadt struct le_softc *lesc = (struct le_softc *)sc;
849b5b98acSderaadt bus_space_tag_t iot = lesc->sc_iot;
859b5b98acSderaadt bus_space_handle_t ioh = lesc->sc_ioh;
860ec3b04cSmiod uint16_t val;
879b5b98acSderaadt
889b5b98acSderaadt bus_space_write_2(iot, ioh, lesc->sc_rap, port);
899b5b98acSderaadt val = bus_space_read_2(iot, ioh, lesc->sc_rdp);
909b5b98acSderaadt return (val);
919b5b98acSderaadt }
929b5b98acSderaadt
939b5b98acSderaadt
949b5b98acSderaadt /*
959b5b98acSderaadt * Controller interrupt.
969b5b98acSderaadt */
979b5b98acSderaadt int
le_isa_intredge(void * arg)9830becc13Sjasper le_isa_intredge(void *arg)
999b5b98acSderaadt {
1009b5b98acSderaadt
1019b5b98acSderaadt if (am7990_intr(arg) == 0)
1029b5b98acSderaadt return (0);
1039b5b98acSderaadt for (;;)
1049b5b98acSderaadt if (am7990_intr(arg) == 0)
1059b5b98acSderaadt return (1);
1069b5b98acSderaadt }
107