1 /* $NetBSD: if_sm_nubus.c,v 1.4.6.5 2005/11/10 13:57:13 skrll Exp $ */
4 * Copyright (c) 2000 Allen Briggs.
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. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include <sys/cdefs.h>
31 __KERNEL_RCSID(0, "$NetBSD: if_sm_nubus.c,v 1.4.6.5 2005/11/10 13:57:13 skrll Exp $");
35 #include <sys/param.h>
36 #include <sys/device.h>
37 #include <sys/errno.h>
38 #include <sys/ioctl.h>
39 #include <sys/socket.h>
40 #include <sys/syslog.h>
41 #include <sys/systm.h>
44 #include <net/if_ether.h>
45 #include <net/if_media.h>
47 #include <machine/bus.h>
48 #include <machine/viareg.h>
50 #include <dev/mii/mii.h>
51 #include <dev/mii/miivar.h>
53 #include <dev/ic/smc91cxxreg.h>
54 #include <dev/ic/smc91cxxvar.h>
56 #include <mac68k/nubus/nubus.h>
58 static int sm_nubus_match(struct device
*, struct cfdata
*, void *);
59 static void sm_nubus_attach(struct device
*, struct device
*, void *);
61 CFATTACH_DECL(sm_nubus
, sizeof(struct smc91cxx_softc
),
62 sm_nubus_match
, sm_nubus_attach
, NULL
, NULL
);
65 sm_nubus_match(struct device
*parent
, struct cfdata
*cf
, void *aux
)
67 struct nubus_attach_args
*na
= (struct nubus_attach_args
*) aux
;
68 bus_space_handle_t bsh
;
71 if (bus_space_map(na
->na_tag
,
72 NUBUS_SLOT2PA(na
->slot
), NBMEMSIZE
, 0, &bsh
))
77 if (na
->category
== NUBUS_CATEGORY_NETWORK
&&
78 na
->type
== NUBUS_TYPE_ETHERNET
) {
80 case NUBUS_DRSW_FOCUS
:
81 case NUBUS_DRSW_ASANTEF
:
90 bus_space_unmap(na
->na_tag
, bsh
, NBMEMSIZE
);
96 * Install interface into kernel networking data structures
99 sm_nubus_attach(struct device
*parent
, struct device
*self
, void *aux
)
101 struct smc91cxx_softc
*smc
= (struct smc91cxx_softc
*) self
;
102 struct nubus_attach_args
*na
= (struct nubus_attach_args
*)aux
;
103 bus_space_tag_t bst
= na
->na_tag
;
104 bus_space_handle_t bsh
, prom_bsh
;
105 u_int8_t myaddr
[ETHER_ADDR_LEN
];
107 const char *cardtype
;
110 if (bus_space_map(bst
, NUBUS_SLOT2PA(na
->slot
), NBMEMSIZE
, 0, &bsh
)) {
111 printf(": failed to map memory space.\n");
115 mac68k_bus_space_handle_swapped(bst
, &bsh
);
120 cardtype
= nubus_get_card_name(bst
, bsh
, na
->fmt
);
125 case NUBUS_DRSW_FOCUS
:
126 if (bus_space_subregion(bst
, bsh
, 0xFF8000, 0x20, &prom_bsh
)) {
127 printf(": failed to map EEPROM space.\n");
133 case NUBUS_DRSW_ASANTEF
:
134 if (bus_space_subregion(bst
, bsh
, 0xFE0000, 0x20, &prom_bsh
)) {
135 printf(": failed to map EEPROM space.\n");
144 bus_space_unmap(bst
, bsh
, NBMEMSIZE
);
147 for (i
=0 ; i
<6 ; i
++) {
148 myaddr
[i
] = bus_space_read_1(bst
, prom_bsh
, i
*4);
151 smc
->sc_flags
|= SMC_FLAGS_ENABLED
;
153 printf(": %s\n", cardtype
);
155 smc91cxx_attach(smc
, myaddr
);
157 add_nubus_intr(na
->slot
, (void (*)(void *))smc91cxx_intr
, smc
);