1/*	$NetBSD: eisa_machdep.c,v 1.6 2022/06/18 22:11:00 andvar Exp $	*/
2
3/*-
4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 *    notice, this list of conditions and the following disclaimer in the
18 *    documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33/*
34 * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 *    notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 *    notice, this list of conditions and the following disclaimer in the
43 *    documentation and/or other materials provided with the distribution.
44 * 3. All advertising materials mentioning features or use of this software
45 *    must display the following acknowledgement:
46 *      This product includes software developed by Christopher G. Demetriou
47 *	for the NetBSD Project.
48 * 4. The name of the author may not be used to endorse or promote products
49 *    derived from this software without specific prior written permission
50 *
51 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
52 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
53 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
54 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
55 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
56 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
60 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 */
62
63/*
64 * Machine-specific functions for EISA autoconfiguration.
65 */
66
67#include <sys/cdefs.h>
68__KERNEL_RCSID(0, "$NetBSD: eisa_machdep.c,v 1.6 2022/06/18 22:11:00 andvar Exp $");
69
70#include <sys/types.h>
71#include <sys/param.h>
72#include <sys/time.h>
73#include <sys/systm.h>
74#include <sys/errno.h>
75#include <sys/device.h>
76#include <sys/extent.h>
77
78#define _POWERPC_BUS_DMA_PRIVATE
79#include <sys/bus.h>
80#include <machine/pio.h>
81#include <machine/intr.h>
82
83#include <dev/isa/isareg.h>
84#include <dev/isa/isavar.h>
85#include <dev/eisa/eisavar.h>
86
87/*
88 * EISA doesn't have any special needs; just use the generic versions
89 * of these functions.
90 */
91struct powerpc_bus_dma_tag eisa_bus_dma_tag = {
92	0,			/* _bounce_thresh */
93	_bus_dmamap_create,
94	_bus_dmamap_destroy,
95	_bus_dmamap_load,
96	_bus_dmamap_load_mbuf,
97	_bus_dmamap_load_uio,
98	_bus_dmamap_load_raw,
99	_bus_dmamap_unload,
100	NULL,			/* _dmamap_sync */
101	_bus_dmamem_alloc,
102	_bus_dmamem_free,
103	_bus_dmamem_map,
104	_bus_dmamem_unmap,
105	_bus_dmamem_mmap,
106};
107
108void
109eisa_attach_hook(device_t parent, device_t self,
110    struct eisabus_attach_args *eba)
111{
112	/* Nothing to do. */
113}
114
115int
116eisa_maxslots(eisa_chipset_tag_t ec)
117{
118
119	/*
120	 * Always try 16 slots.
121	 */
122	return (16);
123}
124
125int
126eisa_intr_map(eisa_chipset_tag_t ec, u_int irq, eisa_intr_handle_t *ihp)
127{
128	if (irq >= I8259_INTR_NUM) {
129		printf("eisa_intr_map: bad IRQ %d\n", irq);
130		*ihp = -1;
131		return 1;
132	}
133	if (irq == 2) {
134		printf("eisa_intr_map: changed IRQ 2 to IRQ 9\n");
135		irq = 9;
136	}
137
138	*ihp = irq;
139	return 0;
140}
141
142const char *
143eisa_intr_string(eisa_chipset_tag_t ec, eisa_intr_handle_t ih, char *buf,
144    size_t len)
145{
146	if (ih == 0 || (ih & 0xff) >= I8259_INTR_NUM || ih == 2)
147		panic("eisa_intr_string: bogus handle 0x%x", ih);
148
149	snprintf(buf, len, "irq %d", ih);
150	return buf;
151
152}
153
154const struct evcnt *
155eisa_intr_evcnt(eisa_chipset_tag_t ec, eisa_intr_handle_t ih)
156{
157
158	/* XXX for now, no evcnt parent reported */
159	return NULL;
160}
161
162void *
163eisa_intr_establish(eisa_chipset_tag_t ec, eisa_intr_handle_t ih,
164    int type, int level, int (*func)(void *), void *arg)
165{
166	int irq;
167
168	irq = ih;
169	return (void *)intr_establish(irq, type, level, func, arg);
170}
171
172void
173eisa_intr_disestablish(eisa_chipset_tag_t ec, void *cookie)
174{
175
176	intr_disestablish(cookie);
177}
178
179int
180eisa_conf_read_mem(eisa_chipset_tag_t ec, int slot, int func, int entry,
181    struct eisa_cfg_mem *ecm)
182{
183
184	/* XXX XXX XXX */
185	return (ENOENT);
186}
187
188int
189eisa_conf_read_irq(eisa_chipset_tag_t ec, int slot, int func, int entry,
190    struct eisa_cfg_irq *eci)
191{
192
193	/* XXX XXX XXX */
194	return (ENOENT);
195}
196
197int
198eisa_conf_read_dma(eisa_chipset_tag_t ec, int slot, int func, int entry,
199    struct eisa_cfg_dma *ecd)
200{
201
202	/* XXX XXX XXX */
203	return (ENOENT);
204}
205
206int
207eisa_conf_read_io(eisa_chipset_tag_t ec, int slot, int func, int entry,
208    struct eisa_cfg_io *ecio)
209{
210
211	/* XXX XXX XXX */
212	return (ENOENT);
213}
214