1 /* $NetBSD: if_ze.c,v 1.14 2008/03/14 20:49:29 jkunz Exp $ */
3 * Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed at Ludd, University of
16 * Lule}, Sweden and its contributors.
17 * 4. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: if_ze.c,v 1.14 2008/03/14 20:49:29 jkunz Exp $");
35 #include "opt_cputype.h"
37 #include <sys/param.h>
38 #include <sys/socket.h>
39 #include <sys/device.h>
40 #include <sys/systm.h>
41 #include <sys/sockio.h>
44 #include <net/if_ether.h>
45 #include <net/if_dl.h>
47 #include <netinet/in.h>
48 #include <netinet/if_inarp.h>
52 #include <net/bpfdesc.h>
55 #include <machine/bus.h>
56 #include <machine/nexus.h>
57 #include <machine/cpu.h>
58 #include <machine/scb.h>
59 #include <machine/sid.h>
60 #include <machine/mainbus.h>
62 #include <dev/ic/sgecreg.h>
63 #include <dev/ic/sgecvar.h>
70 #define SGECADDR 0x20008000
71 #define NISA_ROM 0x20084000
72 #define NISA_ROM_VXT 0x200c4000
73 #define NISA_ROM_VSBUS 0x27800000
76 static int ze_mainbus_match(device_t
, cfdata_t
, void *);
77 static void ze_mainbus_attach(device_t
, device_t
, void *);
79 static const struct sgec_data
{
80 uint32_t sd_boardtype
;
86 { VAX_BTYP_660
, SGECADDR
, NISA_ROM
, SGECVEC
, 24, },
88 { VAX_BTYP_VXT
, SGECADDR
, NISA_ROM_VXT
, 0x200, 0, },
90 { VAX_BTYP_670
, SGECADDR
, NISA_ROM
, SGECVEC
, 8, },
91 { VAX_BTYP_680
, SGECADDR
, NISA_ROM
, SGECVEC
, 8, },
92 { VAX_BTYP_681
, SGECADDR
, NISA_ROM
, SGECVEC
, 8, },
93 { VAX_BTYP_48
, SGECADDR
, NISA_ROM_VSBUS
, SGECVEC
, 0, },
94 { VAX_BTYP_49
, SGECADDR
, NISA_ROM_VSBUS
, SGECVEC
, 0, },
95 { VAX_BTYP_53
, SGECADDR
, NISA_ROM
, SGECVEC
, 8, },
98 static const struct sgec_data
*
102 const struct sgec_data
*sd
;
103 for (i
= 0, sd
= sgec_data
; i
< __arraycount(sgec_data
); i
++, sd
++) {
104 if (vax_boardtype
== sd
->sd_boardtype
)
111 CFATTACH_DECL_NEW(ze_mainbus
, sizeof(struct ze_softc
),
112 ze_mainbus_match
, ze_mainbus_attach
, NULL
, NULL
);
115 * Check for present SGEC.
118 ze_mainbus_match(device_t parent
, cfdata_t cf
, void *aux
)
120 struct mainbus_attach_args
* const ma
= aux
;
123 * Should some more intelligent checking be done???
125 if (strcmp(ma
->ma_type
, "sgec"))
128 return ze_find() != NULL
;
132 * Interface exists: make available by filling in network interface
133 * record. System will initialize the interface when it is ready
137 ze_mainbus_attach(device_t parent
, device_t self
, void *aux
)
139 struct mainbus_attach_args
* const ma
= aux
;
140 struct ze_softc
* const sc
= device_private(self
);
141 const struct sgec_data
* const sd
= ze_find();
149 * Map in SGEC registers.
151 sc
->sc_dmat
= ma
->ma_dmat
;
152 sc
->sc_iot
= ma
->ma_iot
;
153 sc
->sc_intvec
= sd
->sd_intvec
;
154 error
= bus_space_map(sc
->sc_iot
, sd
->sd_addr
, PAGE_SIZE
, 0,
157 aprint_error(": failed to map %#lx: %d\n", sd
->sd_addr
, error
);
162 * Map in, read and release ethernet rom address.
164 ea
= (uint32_t *)vax_map_physmem(sd
->sd_rom
, 1);
165 for (i
= 0; i
< ETHER_ADDR_LEN
; i
++)
166 sc
->sc_enaddr
[i
] = (ea
[i
] >> sd
->sd_romshift
) & 0377;
167 vax_unmap_physmem((vaddr_t
)ea
, 1);
169 scb_vecalloc(sc
->sc_intvec
, (void (*)(void *)) sgec_intr
, sc
,
170 SCB_ISTACK
, &sc
->sc_intrcnt
);