2 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Martin Husemann <martin@NetBSD.org>.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
30 #include <sys/cdefs.h>
31 __KERNEL_RCSID(0, "$NetBSD: daic_isa.c,v 1.18 2009/05/12 08:44:19 cegger Exp $");
33 #include <sys/param.h>
34 #include <sys/errno.h>
35 #include <sys/syslog.h>
36 #include <sys/device.h>
38 #if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
39 #include <sys/callout.h>
46 #include <sys/socket.h>
48 #include <dev/isa/isavar.h>
49 #include <netisdn/i4b_ioctl.h>
50 #include <netisdn/i4b_l3l4.h>
51 #include <dev/ic/daicvar.h>
54 struct daic_isa_softc
{
55 struct daic_softc sc_daic
; /* MI driver state */
56 void *sc_ih
; /* interrupt handler */
60 #ifdef __BROKEN_INDIRECT_CONFIG
61 static int daic_isa_probe(device_t
, void *, void *);
63 static int daic_isa_probe(device_t
, cfdata_t
, void *);
65 static void daic_isa_attach(device_t
, device_t
, void *);
66 static int daic_isa_intr(void *);
68 CFATTACH_DECL(daic_isa
, sizeof(struct daic_isa_softc
),
69 daic_isa_probe
, daic_isa_attach
, NULL
, NULL
);
72 #ifdef __BROKEN_INDIRECT_CONFIG
73 daic_isa_probe(parent
, match
, aux
)
75 daic_isa_probe(parent
, cf
, aux
)
78 #ifdef __BROKEN_INDIRECT_CONFIG
85 struct isa_attach_args
*ia
= aux
;
86 bus_space_tag_t memt
= ia
->ia_memt
;
87 bus_space_handle_t memh
;
88 int card
, need_unmap
= 0;
90 /* We need some controller memory to comunicate! */
91 if (ia
->ia_iomem
[0].ir_addr
== 0 || ia
->ia_iomem
[0].ir_size
== -1)
95 ia
->ia_iomem
[0].ir_size
= DAIC_ISA_MEMSIZE
;
100 if (bus_space_map(memt
, ia
->ia_iomem
[0].ir_addr
, ia
->ia_iomem
[0].ir_size
,
105 /* MI check for card at this location */
106 card
= daic_probe(memt
, memh
);
109 if (card
== DAIC_TYPE_QUAD
)
110 ia
->ia_iomem
[0].ir_size
= DAIC_ISA_QUADSIZE
;
112 bus_space_unmap(memt
, memh
, DAIC_ISA_MEMSIZE
);
116 /* unmap card RAM if already mapped */
118 bus_space_unmap(memt
, memh
, DAIC_ISA_MEMSIZE
);
123 daic_isa_attach(device_t parent
, device_t self
, void *aux
)
125 struct daic_isa_softc
*sc
= (void *)self
;
126 struct isa_attach_args
*ia
= aux
;
127 bus_space_tag_t memt
= ia
->ia_memt
;
128 bus_space_handle_t memh
;
131 if (bus_space_map(memt
, ia
->ia_iomem
[0].ir_addr
, ia
->ia_iomem
[0].ir_size
,
135 sc
->sc_daic
.sc_iot
= memt
;
136 sc
->sc_daic
.sc_ioh
= memh
;
138 /* MI initialization of card */
139 daic_attach(self
, &sc
->sc_daic
);
141 sc
->sc_ih
= isa_intr_establish(ia
->ia_ic
, ia
->ia_irq
[0].ir_irq
, IST_EDGE
,
142 IPL_NET
, daic_isa_intr
, sc
);
146 * Controller interrupt.
149 daic_isa_intr(void *arg
)
151 struct daic_isa_softc
*sc
= arg
;
152 return daic_intr(&sc
->sc_daic
);