1283625Sdim/*	$NetBSD: if_en.c,v 1.28 2011/02/01 19:50:04 chuck Exp $	*/
2283625Sdim
3283625Sdim/*
4283625Sdim * Copyright (c) 1996 Charles D. Cranor and Washington University.
5283625Sdim * All rights reserved.
6283625Sdim *
7283625Sdim * Redistribution and use in source and binary forms, with or without
8283625Sdim * modification, are permitted provided that the following conditions
9283625Sdim * are met:
10283625Sdim * 1. Redistributions of source code must retain the above copyright
11283625Sdim *    notice, this list of conditions and the following disclaimer.
12283625Sdim * 2. Redistributions in binary form must reproduce the above copyright
13283625Sdim *    notice, this list of conditions and the following disclaimer in the
14283625Sdim *    documentation and/or other materials provided with the distribution.
15283625Sdim *
16283625Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17283625Sdim * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18283625Sdim * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19283625Sdim * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20283625Sdim * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21283625Sdim * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22283625Sdim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23283625Sdim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24283625Sdim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25283625Sdim * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26283625Sdim */
27283625Sdim
28283625Sdim/*
29283625Sdim *
30283625Sdim * i f _ e n _ s b u s . c
31283625Sdim *
32283625Sdim * author: Chuck Cranor <chuck@ccrc.wustl.edu>
33283625Sdim * started: spring, 1996.
34 *
35 * SBUS glue for the eni155s card.
36 */
37
38#include <sys/cdefs.h>
39__KERNEL_RCSID(0, "$NetBSD: if_en.c,v 1.28 2011/02/01 19:50:04 chuck Exp $");
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/device.h>
44#include <sys/mbuf.h>
45#include <sys/socket.h>
46#include <sys/socketvar.h>
47
48#include <net/if.h>
49
50#include <sys/bus.h>
51#include <sys/intr.h>
52#include <sys/cpu.h>
53
54#include <dev/sbus/sbusvar.h>
55
56#include <dev/ic/midwayreg.h>
57#include <dev/ic/midwayvar.h>
58
59
60/*
61 * prototypes
62 */
63static	int en_sbus_match(device_t, cfdata_t, void *);
64static	void en_sbus_attach(device_t, device_t, void *);
65
66/*
67 * SBus autoconfig attachments
68 */
69
70CFATTACH_DECL_NEW(en_sbus, sizeof(struct en_softc),
71    en_sbus_match, en_sbus_attach, NULL, NULL);
72
73/***********************************************************************/
74
75/*
76 * autoconfig stuff
77 */
78
79static int
80en_sbus_match(device_t parent, cfdata_t cf, void *aux)
81{
82	struct sbus_attach_args *sa = aux;
83
84	if (strcmp("ENI-155s", sa->sa_name) == 0)  {
85		if (CPU_ISSUN4M) {
86#ifdef DEBUG
87			printf("%s: sun4m DMA not supported yet\n",
88			    sa->sa_name);
89#endif
90			return (0);
91		}
92		return (1);
93	} else {
94		return (0);
95	}
96}
97
98
99static void
100en_sbus_attach(device_t parent, device_t self, void *aux)
101{
102	struct sbus_attach_args *sa = aux;
103	struct en_softc *sc = device_private(self);
104
105	sc->sc_dev = self;
106
107	printf("\n");
108
109	if (sbus_bus_map(sa->sa_bustag,
110			 sa->sa_slot,
111			 sa->sa_offset,
112			 4*1024*1024,
113			 0, &sc->en_base) != 0) {
114		aprint_error_dev(self, "cannot map registers\n");
115		return;
116	}
117
118	/* Establish interrupt handler */
119	if (sa->sa_nintr != 0)
120		(void)bus_intr_establish(sa->sa_bustag, sa->sa_pri,
121					 IPL_NET, en_intr, sc);
122
123	sc->ipl = sa->sa_pri;	/* appropriate? */
124
125	/*
126	 * done SBUS specific stuff
127	 */
128	en_attach(sc);
129}
130