1 /* $NetBSD: sableio.c,v 1.11 2005/12/11 12:16:20 christos Exp $ */
4 * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Driver glue for the Sable STDIO module.
35 * This is kind of a hack. The STDIO is really a junk I/O module with
36 * your regular ISA junk peripherals and their regular ISA I/O addresses.
37 * However, the main issue we have here is *interrupts*. Not only are
38 * devices IRQs strange (i.e. not what you would expect to find if they
39 * were attached to a real ISA) IRQs, the keyboard controller isn't even
40 * connected to the (E)ISA IRQ space at all!
42 * In short, we're gluing together the following things:
44 * - Standard ISA junk I/O chip
46 * - Pre-mapped "PCI" interrupts that are *edge triggered*
49 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
51 __KERNEL_RCSID(0, "$NetBSD: sableio.c,v 1.11 2005/12/11 12:16:20 christos Exp $");
55 #include <sys/param.h>
56 #include <sys/systm.h>
57 #include <sys/device.h>
59 #include <dev/isa/isareg.h>
60 #include <dev/isa/isavar.h>
61 #include <dev/isa/isadmavar.h>
63 #include <dev/pci/pcivar.h>
65 #include <alpha/sableio/sableiovar.h>
70 * The devices built-in to the Sable STDIO module.
72 const struct sableio_dev
{
73 const char *sd_name
; /* device name */
74 bus_addr_t sd_ioaddr
; /* I/O space address */
75 int sd_sableirq
[2]; /* Sable IRQs */
76 int sd_drq
; /* ISA DRQ */
79 * See alpha/pci/pci_2100_a500.c for interrupt information.
81 { "pckbc", IO_KBD
, { 6, 3 }, -1 },
82 { "fdc", IO_FD1
, { 7, -1 }, 2 },
83 { "com", IO_COM1
, { 15, -1 }, -1 },
84 { "com", IO_COM2
, { 8, -1 }, -1 },
85 { "lpt", IO_LPT3
, { 9, -1 }, -1 },
86 { NULL
, 0, { -1, -1 }, -1 },
89 struct sableio_softc
{
90 struct device sc_dev
; /* base device */
93 * We have to deal with ISA DMA, so that means we have to
94 * hold the ISA chipset, since we attach STDIO devices
95 * before we attach the PCI (and thus EISA) bus.
97 struct alpha_isa_chipset sc_isa_chipset
;
100 int sableio_match(struct device
*, struct cfdata
*, void *);
101 void sableio_attach(struct device
*, struct device
*, void *);
103 CFATTACH_DECL(sableio
, sizeof(struct sableio_softc
),
104 sableio_match
, sableio_attach
, NULL
, NULL
);
106 int sableio_print(void *, const char *);
108 struct sableio_softc
*sableio_attached
;
111 sableio_match(struct device
*parent
, struct cfdata
*cf
, void *aux
)
113 struct pcibus_attach_args
*pba
= aux
;
116 * These are really ISA devices, and thus must be on
119 if (cf
->cf_loc
[SABLEIOBUSCF_BUS
] != SABLEIOBUSCF_BUS_DEFAULT
&&
120 cf
->cf_loc
[SABLEIOBUSCF_BUS
] != pba
->pba_bus
)
124 if (pba
->pba_bus
!= 0)
127 /* There can be only one. */
128 if (sableio_attached
!= NULL
)
135 sableio_attach(struct device
*parent
, struct device
*self
, void *aux
)
137 struct sableio_softc
*sc
= (void *) self
;
138 struct pcibus_attach_args
*pba
= aux
;
139 struct sableio_attach_args sa
;
142 int locs
[SABLEIOCF_NLOCS
];
144 printf(": Sable STDIO module\n");
146 sableio_attached
= sc
;
148 dmat
= alphabus_dma_get_tag(pba
->pba_dmat
, ALPHA_BUS_ISA
);
152 * Initialize our DMA state.
154 isa_dmainit(&sc
->sc_isa_chipset
, pba
->pba_iot
, dmat
, self
);
157 for (i
= 0; sableio_devs
[i
].sd_name
!= NULL
; i
++) {
158 sa
.sa_name
= sableio_devs
[i
].sd_name
;
159 sa
.sa_ioaddr
= sableio_devs
[i
].sd_ioaddr
;
160 sa
.sa_sableirq
[0] = sableio_devs
[i
].sd_sableirq
[0];
161 sa
.sa_sableirq
[1] = sableio_devs
[i
].sd_sableirq
[1];
162 sa
.sa_drq
= sableio_devs
[i
].sd_drq
;
164 sa
.sa_iot
= pba
->pba_iot
;
166 sa
.sa_ic
= &sc
->sc_isa_chipset
;
167 sa
.sa_pc
= pba
->pba_pc
;
169 locs
[SABLEIOCF_PORT
] = sableio_devs
[i
].sd_ioaddr
;
171 (void) config_found_sm_loc(self
, "sableio", locs
, &sa
,
172 sableio_print
, config_stdsubmatch
);
177 sableio_print(void *aux
, const char *pnp
)
179 struct sableio_attach_args
*sa
= aux
;
182 aprint_normal("%s at %s", sa
->sa_name
, pnp
);
184 aprint_normal(" port 0x%lx", sa
->sa_ioaddr
);
189 sableio_pickisa(void)
192 if (sableio_attached
== NULL
)
193 panic("sableio_pickisa");
195 return (&sableio_attached
->sc_isa_chipset
);