Home | History | Annotate | Line # | Download | only in tc
      1  1.23    andvar /*	$NetBSD: if_le_tc.c,v 1.23 2022/02/23 21:54:41 andvar Exp $	*/
      2   1.1       cgd 
      3   1.1       cgd /*
      4   1.1       cgd  * Copyright (c) 1996 Carnegie-Mellon University.
      5   1.1       cgd  * All rights reserved.
      6   1.1       cgd  *
      7   1.1       cgd  * Author: Chris G. Demetriou
      8   1.1       cgd  *
      9   1.1       cgd  * Permission to use, copy, modify and distribute this software and
     10   1.1       cgd  * its documentation is hereby granted, provided that both the copyright
     11   1.1       cgd  * notice and this permission notice appear in all copies of the
     12   1.1       cgd  * software, derivative works or modified versions, and any portions
     13   1.1       cgd  * thereof, and that both notices appear in supporting documentation.
     14   1.1       cgd  *
     15   1.1       cgd  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16   1.1       cgd  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17   1.1       cgd  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18   1.1       cgd  *
     19   1.1       cgd  * Carnegie Mellon requests users of this software to return to
     20   1.1       cgd  *
     21   1.1       cgd  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22   1.1       cgd  *  School of Computer Science
     23   1.1       cgd  *  Carnegie Mellon University
     24   1.1       cgd  *  Pittsburgh PA 15213-3890
     25   1.1       cgd  *
     26   1.1       cgd  * any improvements or extensions that they make and grant Carnegie the
     27   1.1       cgd  * rights to redistribute these changes.
     28   1.1       cgd  */
     29   1.1       cgd 
     30   1.1       cgd /*
     31  1.22      flxd  * LANCE on TURBOchannel.
     32   1.1       cgd  */
     33  1.12     lukem 
     34  1.12     lukem #include <sys/cdefs.h>
     35  1.23    andvar __KERNEL_RCSID(0, "$NetBSD: if_le_tc.c,v 1.23 2022/02/23 21:54:41 andvar Exp $");
     36  1.12     lukem 
     37   1.8  jonathan #include "opt_inet.h"
     38   1.1       cgd 
     39   1.1       cgd #include <sys/param.h>
     40   1.1       cgd #include <sys/systm.h>
     41   1.1       cgd #include <sys/mbuf.h>
     42   1.1       cgd #include <sys/syslog.h>
     43   1.1       cgd #include <sys/socket.h>
     44   1.1       cgd #include <sys/device.h>
     45   1.1       cgd 
     46   1.1       cgd #include <net/if.h>
     47   1.5       cgd #include <net/if_ether.h>
     48   1.6   thorpej #include <net/if_media.h>
     49   1.1       cgd 
     50   1.1       cgd #ifdef INET
     51   1.1       cgd #include <netinet/in.h>
     52   1.4        is #include <netinet/if_inarp.h>
     53   1.1       cgd #endif
     54   1.1       cgd 
     55   1.9  drochner #include <dev/ic/lancereg.h>
     56   1.9  drochner #include <dev/ic/lancevar.h>
     57   1.1       cgd #include <dev/ic/am7990reg.h>
     58   1.1       cgd #include <dev/ic/am7990var.h>
     59   1.1       cgd 
     60   1.2   thorpej #include <dev/tc/if_levar.h>
     61   1.1       cgd #include <dev/tc/tcvar.h>
     62   1.1       cgd 
     63  1.21   tsutsui static int	le_tc_match(device_t, cfdata_t, void *);
     64  1.21   tsutsui static void	le_tc_attach(device_t, device_t, void *);
     65   1.1       cgd 
     66  1.21   tsutsui CFATTACH_DECL_NEW(le_tc, sizeof(struct le_softc),
     67  1.15   thorpej     le_tc_match, le_tc_attach, NULL, NULL);
     68   1.1       cgd 
     69   1.1       cgd #define	LE_OFFSET_RAM		0x0
     70   1.1       cgd #define	LE_OFFSET_LANCE		0x100000
     71   1.1       cgd #define	LE_OFFSET_ROM		0x1c0000
     72   1.1       cgd 
     73  1.20   thorpej static int
     74  1.21   tsutsui le_tc_match(device_t parent, cfdata_t cf, void *aux)
     75   1.1       cgd {
     76   1.1       cgd 	struct tc_attach_args *d = aux;
     77   1.1       cgd 
     78  1.10  nisimura 	if (strncmp("PMAD-AA ", d->ta_modname, TC_ROM_LLEN) != 0)
     79   1.1       cgd 		return (0);
     80   1.1       cgd 
     81   1.1       cgd 	return (1);
     82   1.1       cgd }
     83   1.1       cgd 
     84  1.20   thorpej static void
     85  1.21   tsutsui le_tc_attach(device_t parent, device_t self, void *aux)
     86   1.1       cgd {
     87  1.19   thorpej 	struct le_softc *lesc = device_private(self);
     88  1.11  augustss 	struct lance_softc *sc = &lesc->sc_am7990.lsc;
     89   1.1       cgd 	struct tc_attach_args *d = aux;
     90   1.1       cgd 
     91  1.21   tsutsui 	sc->sc_dev = self;
     92  1.21   tsutsui 
     93   1.1       cgd 	/*
     94  1.22      flxd 	 * It's on the TURBOchannel proper, or a kn02
     95   1.1       cgd 	 * baseboard implementation of a TC option card.
     96   1.1       cgd 	 */
     97  1.16    mhitch 	lesc->sc_r1 = (struct lereg1 *)
     98  1.16    mhitch 	    TC_DENSE_TO_SPARSE(TC_PHYS_TO_UNCACHED(d->ta_addr + LE_OFFSET_LANCE));
     99   1.1       cgd 	sc->sc_mem = (void *)(d->ta_addr + LE_OFFSET_RAM);
    100   1.1       cgd 
    101   1.9  drochner 	sc->sc_copytodesc = lance_copytobuf_contig;
    102   1.9  drochner 	sc->sc_copyfromdesc = lance_copyfrombuf_contig;
    103   1.9  drochner 	sc->sc_copytobuf = lance_copytobuf_contig;
    104   1.9  drochner 	sc->sc_copyfrombuf = lance_copyfrombuf_contig;
    105   1.9  drochner 	sc->sc_zerobuf = lance_zerobuf_contig;
    106   1.1       cgd 
    107   1.1       cgd 	/*
    108   1.1       cgd 	 * TC lance boards have onboard SRAM buffers.  DMA
    109  1.23    andvar 	 * between the onboard RAM and main memory is not possible,
    110   1.1       cgd 	 * so  DMA setup is not required.
    111   1.1       cgd 	 */
    112   1.1       cgd 
    113   1.9  drochner 	dec_le_common_attach(&lesc->sc_am7990,
    114  1.21   tsutsui 			     (uint8_t *)(d->ta_addr + LE_OFFSET_ROM + 2));
    115   1.1       cgd 
    116   1.2   thorpej 	tc_intr_establish(parent, d->ta_cookie, TC_IPL_NET, am7990_intr, sc);
    117   1.1       cgd }
    118