1 /* $NetBSD: if_fta.c,v 1.26 2009/05/12 13:21:22 cegger Exp $ */
4 * Copyright (c) 1996 Matt Thomas <matt@3am-software.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. The name of the author may not be used to endorse or promote products
13 * derived from this software without specific prior written permission
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * Id: if_fta.c,v 1.4 1997/03/21 13:45:45 thomas Exp
31 * DEC TurboChannel FDDI Controller; code for BSD derived operating systems
33 * Written by Matt Thomas
35 * This module supports the DEC DEFTA TurboChannel FDDI Controller
38 #include <sys/cdefs.h>
39 __KERNEL_RCSID(0, "$NetBSD: if_fta.c,v 1.26 2009/05/12 13:21:22 cegger Exp $");
43 #include <sys/param.h>
44 #include <sys/kernel.h>
46 #include <sys/protosw.h>
47 #include <sys/socket.h>
48 #include <sys/ioctl.h>
49 #include <sys/errno.h>
50 #include <sys/malloc.h>
51 #include <sys/device.h>
54 #include <net/if_types.h>
55 #include <net/if_fddi.h>
58 #include <netinet/in.h>
59 #include <netinet/if_inarp.h>
62 #include <dev/tc/tcvar.h>
63 #include <dev/ic/pdqvar.h>
64 #include <dev/ic/pdqreg.h>
72 struct tc_attach_args
*ta
= (struct tc_attach_args
*) aux
;
74 if (strncmp("PMAF-F", ta
->ta_modname
, 6) == 0)
82 device_t
const parent
,
86 pdq_softc_t
* const sc
= device_private(self
);
87 struct tc_attach_args
* const ta
= (struct tc_attach_args
*) aux
;
90 * NOTE: sc_bc is an alias for sc_csrtag and sc_membase is an
91 * alias for sc_csrhandle. sc_iobase is not used in this front-end.
93 sc
->sc_dmatag
= ta
->ta_dmat
;
94 sc
->sc_csrtag
= ta
->ta_memt
;
95 memcpy(sc
->sc_if
.if_xname
, device_xname(&sc
->sc_dev
), IFNAMSIZ
);
96 sc
->sc_if
.if_flags
= 0;
97 sc
->sc_if
.if_softc
= sc
;
99 if (bus_space_map(sc
->sc_csrtag
, ta
->ta_addr
+ PDQ_TC_CSR_OFFSET
,
100 PDQ_TC_CSR_SPACE
, 0, &sc
->sc_membase
)) {
102 aprint_error_dev(&sc
->sc_dev
, "can't map card memory!\n");
106 sc
->sc_pdq
= pdq_initialize(sc
->sc_csrtag
, sc
->sc_membase
,
107 sc
->sc_if
.if_xname
, 0,
108 (void *) sc
, PDQ_DEFTA
);
109 if (sc
->sc_pdq
== NULL
) {
110 aprint_error_dev(&sc
->sc_dev
, "initialization failed\n");
114 pdq_ifattach(sc
, NULL
);
116 tc_intr_establish(parent
, ta
->ta_cookie
, TC_IPL_NET
,
117 (int (*)(void *)) pdq_interrupt
, sc
->sc_pdq
);
119 sc
->sc_ats
= shutdownhook_establish((void (*)(void *)) pdq_hwreset
, sc
->sc_pdq
);
120 if (sc
->sc_ats
== NULL
)
121 aprint_error_dev(self
, "warning: couldn't establish shutdown hook\n");
124 CFATTACH_DECL(fta
, sizeof(pdq_softc_t
),
125 pdq_tc_match
, pdq_tc_attach
, NULL
, NULL
);