xref: /netbsd-src/sys/arch/arm/xscale/becc_pci.c (revision f82ca6eefb335bf699131a4ebe4cc00c8911db8a)
1*f82ca6eeSskrll /*	$NetBSD: becc_pci.c,v 1.22 2022/09/27 06:36:43 skrll Exp $	*/
2b1b164a8Sthorpej 
3b1b164a8Sthorpej /*
4b1b164a8Sthorpej  * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
5b1b164a8Sthorpej  * All rights reserved.
6b1b164a8Sthorpej  *
7b1b164a8Sthorpej  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8b1b164a8Sthorpej  *
9b1b164a8Sthorpej  * Redistribution and use in source and binary forms, with or without
10b1b164a8Sthorpej  * modification, are permitted provided that the following conditions
11b1b164a8Sthorpej  * are met:
12b1b164a8Sthorpej  * 1. Redistributions of source code must retain the above copyright
13b1b164a8Sthorpej  *    notice, this list of conditions and the following disclaimer.
14b1b164a8Sthorpej  * 2. Redistributions in binary form must reproduce the above copyright
15b1b164a8Sthorpej  *    notice, this list of conditions and the following disclaimer in the
16b1b164a8Sthorpej  *    documentation and/or other materials provided with the distribution.
17b1b164a8Sthorpej  * 3. All advertising materials mentioning features or use of this software
18b1b164a8Sthorpej  *    must display the following acknowledgement:
19b1b164a8Sthorpej  *	This product includes software developed for the NetBSD Project by
20b1b164a8Sthorpej  *	Wasabi Systems, Inc.
21b1b164a8Sthorpej  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22b1b164a8Sthorpej  *    or promote products derived from this software without specific prior
23b1b164a8Sthorpej  *    written permission.
24b1b164a8Sthorpej  *
25b1b164a8Sthorpej  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26b1b164a8Sthorpej  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27b1b164a8Sthorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28b1b164a8Sthorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
29b1b164a8Sthorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30b1b164a8Sthorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31b1b164a8Sthorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32b1b164a8Sthorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33b1b164a8Sthorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34b1b164a8Sthorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35b1b164a8Sthorpej  * POSSIBILITY OF SUCH DAMAGE.
36b1b164a8Sthorpej  */
37b1b164a8Sthorpej 
38b1b164a8Sthorpej /*
39b1b164a8Sthorpej  * PCI configuration support for the ADI Engineering Big Endian Companion
40b1b164a8Sthorpej  * Chip.
41b1b164a8Sthorpej  */
42b1b164a8Sthorpej 
4308716eaeSlukem #include <sys/cdefs.h>
44*f82ca6eeSskrll __KERNEL_RCSID(0, "$NetBSD: becc_pci.c,v 1.22 2022/09/27 06:36:43 skrll Exp $");
45213e0bd3Smatt 
46213e0bd3Smatt #include "opt_pci.h"
47213e0bd3Smatt #include "pci.h"
4808716eaeSlukem 
49b1b164a8Sthorpej #include <sys/param.h>
50b1b164a8Sthorpej #include <sys/systm.h>
51b1b164a8Sthorpej #include <sys/device.h>
52213e0bd3Smatt #include <sys/bus.h>
53b1b164a8Sthorpej 
54b1b164a8Sthorpej #include <uvm/uvm_extern.h>
55b1b164a8Sthorpej 
56213e0bd3Smatt #include <dev/pci/ppbreg.h>
57213e0bd3Smatt #include <dev/pci/pcivar.h>
58213e0bd3Smatt #include <dev/pci/pciconf.h>
59213e0bd3Smatt 
60213e0bd3Smatt #include <arm/locore.h>
61b1b164a8Sthorpej 
62b1b164a8Sthorpej #include <arm/xscale/beccreg.h>
63b1b164a8Sthorpej #include <arm/xscale/beccvar.h>
64b1b164a8Sthorpej 
65a2b8c7fbSmsaitoh void		becc_pci_attach_hook(device_t, device_t,
66b1b164a8Sthorpej 		    struct pcibus_attach_args *);
67b1b164a8Sthorpej int		becc_pci_bus_maxdevs(void *, int);
68b1b164a8Sthorpej pcitag_t	becc_pci_make_tag(void *, int, int, int);
69b1b164a8Sthorpej void		becc_pci_decompose_tag(void *, pcitag_t, int *, int *,
70b1b164a8Sthorpej 		    int *);
71b1b164a8Sthorpej pcireg_t	becc_pci_conf_read(void *, pcitag_t, int);
72b1b164a8Sthorpej void		becc_pci_conf_write(void *, pcitag_t, int, pcireg_t);
73974581beSmatt void		becc_pci_conf_interrupt(void *, int, int, int, int, int *);
74b1b164a8Sthorpej 
75a184f1f4Sdyoung int		becc_pci_intr_map(const struct pci_attach_args *,
76b1b164a8Sthorpej 		    pci_intr_handle_t *);
7784439168Schristos const char	*becc_pci_intr_string(void *, pci_intr_handle_t,
7884439168Schristos 		    char *, size_t);
79b1b164a8Sthorpej const struct evcnt *becc_pci_intr_evcnt(void *, pci_intr_handle_t);
80b1b164a8Sthorpej void		*becc_pci_intr_establish(void *, pci_intr_handle_t,
81cce19cc2Sjmcneill 		    int, int (*)(void *), void *, const char *);
82b1b164a8Sthorpej void		becc_pci_intr_disestablish(void *, void *);
83b1b164a8Sthorpej 
84b1b164a8Sthorpej #define	PCI_CONF_LOCK(s)	(s) = disable_interrupts(I32_bit)
85b1b164a8Sthorpej #define	PCI_CONF_UNLOCK(s)	restore_interrupts((s))
86b1b164a8Sthorpej 
87b1b164a8Sthorpej #if 0
88b1b164a8Sthorpej #define DPRINTF(x) printf(x)
89b1b164a8Sthorpej #else
90b1b164a8Sthorpej #define DPRINTF(x)
91b1b164a8Sthorpej #endif
92b1b164a8Sthorpej 
93b1b164a8Sthorpej void
becc_pci_init(pci_chipset_tag_t pc,void * cookie)94b1b164a8Sthorpej becc_pci_init(pci_chipset_tag_t pc, void *cookie)
95b1b164a8Sthorpej {
96b1b164a8Sthorpej #if NPCI > 0 && defined(PCI_NETBSD_CONFIGURE)
97b1b164a8Sthorpej 	struct becc_softc *sc = cookie;
98ca8ce3aeSthorpej 	struct pciconf_resources *pcires;
99b1b164a8Sthorpej #endif
100b1b164a8Sthorpej 
101b1b164a8Sthorpej 	pc->pc_conf_v = cookie;
102b1b164a8Sthorpej 	pc->pc_attach_hook = becc_pci_attach_hook;
103b1b164a8Sthorpej 	pc->pc_bus_maxdevs = becc_pci_bus_maxdevs;
104b1b164a8Sthorpej 	pc->pc_make_tag = becc_pci_make_tag;
105b1b164a8Sthorpej 	pc->pc_decompose_tag = becc_pci_decompose_tag;
106b1b164a8Sthorpej 	pc->pc_conf_read = becc_pci_conf_read;
107b1b164a8Sthorpej 	pc->pc_conf_write = becc_pci_conf_write;
108974581beSmatt 	pc->pc_conf_interrupt = becc_pci_conf_interrupt;
109b1b164a8Sthorpej 
110b1b164a8Sthorpej 	pc->pc_intr_v = cookie;
111b1b164a8Sthorpej 	pc->pc_intr_map = becc_pci_intr_map;
112b1b164a8Sthorpej 	pc->pc_intr_string = becc_pci_intr_string;
113b1b164a8Sthorpej 	pc->pc_intr_evcnt = becc_pci_intr_evcnt;
114b1b164a8Sthorpej 	pc->pc_intr_establish = becc_pci_intr_establish;
115b1b164a8Sthorpej 	pc->pc_intr_disestablish = becc_pci_intr_disestablish;
116b1b164a8Sthorpej 
117b1b164a8Sthorpej #if NPCI > 0 && defined(PCI_NETBSD_CONFIGURE)
118b1b164a8Sthorpej 	/*
119b1b164a8Sthorpej 	 * Configure the PCI bus.
120b1b164a8Sthorpej 	 *
121b1b164a8Sthorpej 	 * XXX We need to revisit this.  We only configure the Secondary
122b1b164a8Sthorpej 	 * bus (and its children).  The bus configure code needs changes
123b1b164a8Sthorpej 	 * to support how the busses are arranged on this chip.  We also
124b1b164a8Sthorpej 	 * need to only configure devices in the private device space on
125b1b164a8Sthorpej 	 * the Secondary bus.
126b1b164a8Sthorpej 	 */
127b1b164a8Sthorpej 
128ca8ce3aeSthorpej 	pcires = pciconf_resource_init();
129ca8ce3aeSthorpej 
130b1b164a8Sthorpej 	/* Reserve the bottom 32K of the PCI address space. */
131ca8ce3aeSthorpej 	pciconf_resource_add(pcires, PCICONF_RESOURCE_IO,
132ca8ce3aeSthorpej 	    sc->sc_ioout_xlate + (32 * 1024), (32 * 1024));
133ca8ce3aeSthorpej 	pciconf_resource_add(pcires, PCICONF_RESOURCE_MEM,
134ca8ce3aeSthorpej 	    sc->sc_owin_xlate[0], BECC_PCI_MEM1_SIZE);
135b1b164a8Sthorpej 
136a2b8c7fbSmsaitoh 	aprint_normal("%s: configuring PCI bus\n", device_xname(sc->sc_dev));
137ca8ce3aeSthorpej 	pci_configure_bus(pc, pcires, 0, arm_dcache_align);
138b1b164a8Sthorpej 
139ca8ce3aeSthorpej 	pciconf_resource_fini(pcires);
140b1b164a8Sthorpej #endif
141b1b164a8Sthorpej }
142b1b164a8Sthorpej 
143b1b164a8Sthorpej void
becc_pci_conf_interrupt(void * v,int a,int b,int c,int d,int * p)144974581beSmatt becc_pci_conf_interrupt(void *v, int a, int b, int c, int d, int *p)
145b1b164a8Sthorpej {
146b1b164a8Sthorpej }
147b1b164a8Sthorpej 
148b1b164a8Sthorpej void
becc_pci_attach_hook(device_t parent,device_t self,struct pcibus_attach_args * pba)149a2b8c7fbSmsaitoh becc_pci_attach_hook(device_t parent, device_t self,
150b1b164a8Sthorpej     struct pcibus_attach_args *pba)
151b1b164a8Sthorpej {
152b1b164a8Sthorpej 
153b1b164a8Sthorpej 	/* Nothing to do. */
154b1b164a8Sthorpej }
155b1b164a8Sthorpej 
156b1b164a8Sthorpej int
becc_pci_bus_maxdevs(void * v,int busno)157b1b164a8Sthorpej becc_pci_bus_maxdevs(void *v, int busno)
158b1b164a8Sthorpej {
159b1b164a8Sthorpej 
160b1b164a8Sthorpej 	return (32);
161b1b164a8Sthorpej }
162b1b164a8Sthorpej 
163b1b164a8Sthorpej pcitag_t
becc_pci_make_tag(void * v,int b,int d,int f)164b1b164a8Sthorpej becc_pci_make_tag(void *v, int b, int d, int f)
165b1b164a8Sthorpej {
166b1b164a8Sthorpej 
167b1b164a8Sthorpej 	return ((b << 16) | (d << 11) | (f << 8));
168b1b164a8Sthorpej }
169b1b164a8Sthorpej 
170b1b164a8Sthorpej void
becc_pci_decompose_tag(void * v,pcitag_t tag,int * bp,int * dp,int * fp)171b1b164a8Sthorpej becc_pci_decompose_tag(void *v, pcitag_t tag, int *bp, int *dp, int *fp)
172b1b164a8Sthorpej {
173b1b164a8Sthorpej 
174b1b164a8Sthorpej 	if (bp != NULL)
175b1b164a8Sthorpej 		*bp = (tag >> 16) & 0xff;
176b1b164a8Sthorpej 	if (dp != NULL)
177b1b164a8Sthorpej 		*dp = (tag >> 11) & 0x1f;
178b1b164a8Sthorpej 	if (fp != NULL)
179b1b164a8Sthorpej 		*fp = (tag >> 8) & 0x7;
180b1b164a8Sthorpej }
181b1b164a8Sthorpej 
182b1b164a8Sthorpej struct pciconf_state {
183b1b164a8Sthorpej 	uint32_t ps_offset;
184b1b164a8Sthorpej 
185b1b164a8Sthorpej 	int ps_b, ps_d, ps_f;
186b1b164a8Sthorpej 	int ps_type;
187b1b164a8Sthorpej };
188b1b164a8Sthorpej 
189b1b164a8Sthorpej static int
becc_pci_conf_setup(struct becc_softc * sc,pcitag_t tag,int offset,struct pciconf_state * ps)190b1b164a8Sthorpej becc_pci_conf_setup(struct becc_softc *sc, pcitag_t tag, int offset,
191b1b164a8Sthorpej     struct pciconf_state *ps)
192b1b164a8Sthorpej {
193b1b164a8Sthorpej 
194605f564fSmsaitoh 	if ((unsigned int)offset >= PCI_CONF_SIZE)
195605f564fSmsaitoh 		return (1);
196605f564fSmsaitoh 
197b1b164a8Sthorpej 	becc_pci_decompose_tag(sc, tag, &ps->ps_b, &ps->ps_d, &ps->ps_f);
198b1b164a8Sthorpej 
199b1b164a8Sthorpej 	/*
200b1b164a8Sthorpej 	 * If the bus # is the same as our own, then use Type 0 cycles,
201b1b164a8Sthorpej 	 * else use Type 1.
202b1b164a8Sthorpej 	 */
203b1b164a8Sthorpej 	if (ps->ps_b == 0) {
204b1b164a8Sthorpej 		/* XXX This is a platform-specific parameter. */
205b1b164a8Sthorpej 		if (ps->ps_d > (14 - BECC_IDSEL_BIT))
206b1b164a8Sthorpej 			return (1);
207b1b164a8Sthorpej 		ps->ps_offset = (1U << (ps->ps_d + BECC_IDSEL_BIT)) |
208b1b164a8Sthorpej 		    (ps->ps_f << 8) | offset;
209b1b164a8Sthorpej 		ps->ps_type = 0;
210b1b164a8Sthorpej 	} else {
211b1b164a8Sthorpej 		/* The tag is already in the correct format. */
212b1b164a8Sthorpej 		ps->ps_offset = tag | offset | 1;
213b1b164a8Sthorpej 		ps->ps_type = 1;
214b1b164a8Sthorpej 	}
215b1b164a8Sthorpej 
216b1b164a8Sthorpej 	return (0);
217b1b164a8Sthorpej }
218b1b164a8Sthorpej 
219b1b164a8Sthorpej static int becc_pci_conf_cleanup(struct becc_softc *sc);
220b1b164a8Sthorpej static int
becc_pci_conf_cleanup(struct becc_softc * sc)221b1b164a8Sthorpej becc_pci_conf_cleanup(struct becc_softc *sc)
222b1b164a8Sthorpej {
223b1b164a8Sthorpej 	uint32_t reg;
224b1b164a8Sthorpej 	int	err=0;
225b1b164a8Sthorpej 
226b1b164a8Sthorpej 	BECC_CSR_WRITE(BECC_POCR, 0);
227b1b164a8Sthorpej 
228b1b164a8Sthorpej 	reg = becc_pcicore_read(sc, PCI_COMMAND_STATUS_REG);
229b1b164a8Sthorpej 	if (reg & 0xf9000000) {
230b1b164a8Sthorpej 		DPRINTF((" ** pci status error: %08x (%08x) **\n",
231b1b164a8Sthorpej 		    reg, reg & 0xf9000000));
232b1b164a8Sthorpej 
233b1b164a8Sthorpej 		err = 1;
234b1b164a8Sthorpej 		becc_pcicore_write(sc, PCI_COMMAND_STATUS_REG,
235b1b164a8Sthorpej 		    reg & 0xf900ffff);
236b1b164a8Sthorpej 		reg = becc_pcicore_read(sc, PCI_COMMAND_STATUS_REG);
237b1b164a8Sthorpej 
238b1b164a8Sthorpej 		DPRINTF((" ** pci status after clearing: %08x (%08x) **\n",
239b1b164a8Sthorpej 		    reg, reg & 0xf9000000));
240b1b164a8Sthorpej 	}
241b1b164a8Sthorpej 	reg = BECC_CSR_READ(BECC_PMISR);
242b1b164a8Sthorpej 	if (reg & 0x000f000d) {
243b1b164a8Sthorpej 		DPRINTF((" ** pci master isr: %08x (%08x) **\n",
244b1b164a8Sthorpej 		    reg, reg & 0x000f000d));
245b1b164a8Sthorpej 
246b1b164a8Sthorpej 		err = 1;
247b1b164a8Sthorpej 		BECC_CSR_WRITE(BECC_PMISR, reg & 0x000f000d);
248b1b164a8Sthorpej 		reg = BECC_CSR_READ(BECC_PMISR);
249b1b164a8Sthorpej 
250b1b164a8Sthorpej 		DPRINTF((" ** pci master isr after clearing: %08x (%08x) **\n",
251b1b164a8Sthorpej 		    reg, reg & 0x000f000d));
252b1b164a8Sthorpej 	}
253b1b164a8Sthorpej 	reg = BECC_CSR_READ(BECC_PSISR);
254b1b164a8Sthorpej 	if (reg & 0x000f0210) {
255b1b164a8Sthorpej 		DPRINTF((" ** pci slave isr: %08x (%08x) **\n",
256b1b164a8Sthorpej 		    reg, reg & 0x000f0210));
257b1b164a8Sthorpej 
258b1b164a8Sthorpej 		err = 1;
259b1b164a8Sthorpej 		BECC_CSR_WRITE(BECC_PSISR, reg & 0x000f0210);
260b1b164a8Sthorpej 		reg = BECC_CSR_READ(BECC_PSISR);
261b1b164a8Sthorpej 
262b1b164a8Sthorpej 		DPRINTF((" ** pci slave isr after clearing: %08x (%08x) **\n",
263b1b164a8Sthorpej 		    reg, reg & 0x000f0210));
264b1b164a8Sthorpej 	}
265b1b164a8Sthorpej 
266b1b164a8Sthorpej 	return err;
267b1b164a8Sthorpej }
268b1b164a8Sthorpej 
269b1b164a8Sthorpej pcireg_t
becc_pci_conf_read(void * v,pcitag_t tag,int offset)270b1b164a8Sthorpej becc_pci_conf_read(void *v, pcitag_t tag, int offset)
271b1b164a8Sthorpej {
272b1b164a8Sthorpej 	struct becc_softc *sc = v;
273b1b164a8Sthorpej 	struct pciconf_state ps;
274b1b164a8Sthorpej 	vaddr_t va;
275b1b164a8Sthorpej 	pcireg_t rv;
276b1b164a8Sthorpej 	u_int s;
277b1b164a8Sthorpej 
278b1b164a8Sthorpej 	if (becc_pci_conf_setup(sc, tag, offset, &ps))
279b1b164a8Sthorpej 		return ((pcireg_t) -1);
280b1b164a8Sthorpej 
281b1b164a8Sthorpej 	/*
282b1b164a8Sthorpej 	 * Skip device 0 (the BECC itself).  We don't want it
283b1b164a8Sthorpej 	 * to appear as part of the PCI device space.
284b1b164a8Sthorpej 	 */
285b1b164a8Sthorpej 	if (ps.ps_b == 0 && ps.ps_d == 0)
286b1b164a8Sthorpej 		return ((pcireg_t) -1);
287b1b164a8Sthorpej 
288b1b164a8Sthorpej 	PCI_CONF_LOCK(s);
289b1b164a8Sthorpej 
290b1b164a8Sthorpej 	va = sc->sc_pci_cfg_base + ps.ps_offset;
291b1b164a8Sthorpej 	BECC_CSR_WRITE(BECC_POCR, ps.ps_type);
292b1b164a8Sthorpej 
293b1b164a8Sthorpej 	if (badaddr_read((void *) va, sizeof(rv), &rv)) {
294b1b164a8Sthorpej 		/* XXX Check master/target abort? */
295b1b164a8Sthorpej #if 0
296b1b164a8Sthorpej 		printf("conf_read: %d/%d/%d bad address\n",
297b1b164a8Sthorpej 		    ps.ps_b, ps.ps_d, ps.ps_f);
298b1b164a8Sthorpej #endif
299b1b164a8Sthorpej 		rv = (pcireg_t) -1;
300b1b164a8Sthorpej 	}
301b1b164a8Sthorpej 
302b1b164a8Sthorpej 	if (becc_pci_conf_cleanup(sc))
303b1b164a8Sthorpej 		rv = (pcireg_t) -1;
304b1b164a8Sthorpej 
305b1b164a8Sthorpej 	PCI_CONF_UNLOCK(s);
306b1b164a8Sthorpej 
307b1b164a8Sthorpej 	return (rv);
308b1b164a8Sthorpej }
309b1b164a8Sthorpej 
310b1b164a8Sthorpej void
becc_pci_conf_write(void * v,pcitag_t tag,int offset,pcireg_t val)311b1b164a8Sthorpej becc_pci_conf_write(void *v, pcitag_t tag, int offset, pcireg_t val)
312b1b164a8Sthorpej {
313b1b164a8Sthorpej 	struct becc_softc *sc = v;
314b1b164a8Sthorpej 	struct pciconf_state ps;
315b1b164a8Sthorpej 	vaddr_t va;
316b1b164a8Sthorpej 	u_int s;
317b1b164a8Sthorpej 
318b1b164a8Sthorpej 	if (becc_pci_conf_setup(sc, tag, offset, &ps))
319b1b164a8Sthorpej 		return;
320b1b164a8Sthorpej 
321b1b164a8Sthorpej 	PCI_CONF_LOCK(s);
322b1b164a8Sthorpej 	BECC_CSR_WRITE(BECC_POCR, ps.ps_type);
323b1b164a8Sthorpej 
324b1b164a8Sthorpej 	va = sc->sc_pci_cfg_base + ps.ps_offset;
325b1b164a8Sthorpej 
3265f1c88d7Sperry 	*(volatile pcireg_t *)va = val;
327b1b164a8Sthorpej 
328b1b164a8Sthorpej 	becc_pci_conf_cleanup(sc);
329b1b164a8Sthorpej 
330b1b164a8Sthorpej 	PCI_CONF_UNLOCK(s);
331b1b164a8Sthorpej }
332b1b164a8Sthorpej 
333b1b164a8Sthorpej int
becc_pci_intr_map(const struct pci_attach_args * pa,pci_intr_handle_t * ihp)334a184f1f4Sdyoung becc_pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
335b1b164a8Sthorpej {
336b1b164a8Sthorpej 	int irq;
337b1b164a8Sthorpej 
338b1b164a8Sthorpej 	if (pa->pa_bus == 0) {
339b1b164a8Sthorpej 		switch (pa->pa_device) {
340b1b164a8Sthorpej 		case 1: irq = ICU_PCI_INTB; break; /* Ethernet #0 */
341b1b164a8Sthorpej 		case 2: irq = ICU_PCI_INTC; break; /* Ethernet #1 */
342f339e5e9Sbriggs 		case 3:				   /* Card slot */
343f339e5e9Sbriggs 			switch (pa->pa_intrpin) {
344f339e5e9Sbriggs 			case 1:		irq = ICU_PCI_INTA; break;
345f339e5e9Sbriggs 			case 2:		irq = ICU_PCI_INTB; break;
346f339e5e9Sbriggs 			case 3:		irq = ICU_PCI_INTC; break;
347f339e5e9Sbriggs 			case 4:		irq = ICU_PCI_INTD; break;
348f339e5e9Sbriggs 			default:
349f339e5e9Sbriggs 				printf("becc_pci_intr_map: bogus pin: %d\n",
350f339e5e9Sbriggs 				    pa->pa_intrpin);
351f339e5e9Sbriggs 				return (1);
352f339e5e9Sbriggs 			}
353f339e5e9Sbriggs 			break;
354b1b164a8Sthorpej 		default:
355920b229eSthorpej 			printf("becc_pci_intr_map: bogus device: %d\n",
356920b229eSthorpej 			    pa->pa_device);
357a72426faSmatt 			return (1);
358b1b164a8Sthorpej 		}
359b1b164a8Sthorpej 	} else {
360b1b164a8Sthorpej 		switch (pa->pa_intrpin) {
361b1b164a8Sthorpej 		case 1:		irq = ICU_PCI_INTA; break;
362b1b164a8Sthorpej 		case 2:		irq = ICU_PCI_INTB; break;
363b1b164a8Sthorpej 		case 3:		irq = ICU_PCI_INTC; break;
364b1b164a8Sthorpej 		case 4:		irq = ICU_PCI_INTD; break;
365b1b164a8Sthorpej 		default:
366b1b164a8Sthorpej 			printf("becc_pci_intr_map: bogus pin: %d\n",
367b1b164a8Sthorpej 			    pa->pa_intrpin);
368b1b164a8Sthorpej 			return (1);
369b1b164a8Sthorpej 		}
370b1b164a8Sthorpej 	}
371b1b164a8Sthorpej 
372b1b164a8Sthorpej 	*ihp = irq;
373b1b164a8Sthorpej 	return (0);
374b1b164a8Sthorpej }
375b1b164a8Sthorpej 
376b1b164a8Sthorpej const char *
becc_pci_intr_string(void * v,pci_intr_handle_t ih,char * buf,size_t len)377e58a356cSchristos becc_pci_intr_string(void *v, pci_intr_handle_t ih, char *buf, size_t len)
378b1b164a8Sthorpej {
379b1b164a8Sthorpej 
38022a4cbbbShtodd 	strlcpy(buf, becc_irqnames[ih], len);
381e58a356cSchristos 	return buf;
382b1b164a8Sthorpej }
383b1b164a8Sthorpej 
384b1b164a8Sthorpej const struct evcnt *
becc_pci_intr_evcnt(void * v,pci_intr_handle_t ih)385b1b164a8Sthorpej becc_pci_intr_evcnt(void *v, pci_intr_handle_t ih)
386b1b164a8Sthorpej {
387b1b164a8Sthorpej 
388b1b164a8Sthorpej 	/* XXX For now. */
389b1b164a8Sthorpej 	return (NULL);
390b1b164a8Sthorpej }
391b1b164a8Sthorpej 
392b1b164a8Sthorpej void *
becc_pci_intr_establish(void * v,pci_intr_handle_t ih,int ipl,int (* func)(void *),void * arg,const char * xname)393b1b164a8Sthorpej becc_pci_intr_establish(void *v, pci_intr_handle_t ih, int ipl,
394cce19cc2Sjmcneill     int (*func)(void *), void *arg, const char *xname)
395b1b164a8Sthorpej {
396b1b164a8Sthorpej 
397b1b164a8Sthorpej 	return (becc_intr_establish(ih, ipl, func, arg));
398b1b164a8Sthorpej }
399b1b164a8Sthorpej 
400b1b164a8Sthorpej void
becc_pci_intr_disestablish(void * v,void * cookie)401b1b164a8Sthorpej becc_pci_intr_disestablish(void *v, void *cookie)
402b1b164a8Sthorpej {
403b1b164a8Sthorpej 
404b1b164a8Sthorpej 	becc_intr_disestablish(cookie);
405b1b164a8Sthorpej }
406