1*b42f375bSrin /* $NetBSD: pciide_machdep.c,v 1.7 2021/03/17 14:58:16 rin Exp $ */
2d974db0aSgarbled
3d974db0aSgarbled /*
4d974db0aSgarbled * Copyright (c) 1998 Christopher G. Demetriou. All rights reserved.
5d974db0aSgarbled *
6d974db0aSgarbled * Redistribution and use in source and binary forms, with or without
7d974db0aSgarbled * modification, are permitted provided that the following conditions
8d974db0aSgarbled * are met:
9d974db0aSgarbled * 1. Redistributions of source code must retain the above copyright
10d974db0aSgarbled * notice, this list of conditions and the following disclaimer.
11d974db0aSgarbled * 2. Redistributions in binary form must reproduce the above copyright
12d974db0aSgarbled * notice, this list of conditions and the following disclaimer in the
13d974db0aSgarbled * documentation and/or other materials provided with the distribution.
14d974db0aSgarbled * 3. All advertising materials mentioning features or use of this software
15d974db0aSgarbled * must display the following acknowledgement:
16d974db0aSgarbled * This product includes software developed by Christopher G. Demetriou
17d974db0aSgarbled * for the NetBSD Project.
18d974db0aSgarbled * 4. The name of the author may not be used to endorse or promote products
19d974db0aSgarbled * derived from this software without specific prior written permission
20d974db0aSgarbled *
21d974db0aSgarbled * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22d974db0aSgarbled * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23d974db0aSgarbled * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24d974db0aSgarbled * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25d974db0aSgarbled * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26d974db0aSgarbled * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27d974db0aSgarbled * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28d974db0aSgarbled * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29d974db0aSgarbled * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30d974db0aSgarbled * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31d974db0aSgarbled */
32d974db0aSgarbled
33d974db0aSgarbled /*
34d974db0aSgarbled * PCI IDE controller driver (arm32 machine-dependent portion).
35d974db0aSgarbled *
36d974db0aSgarbled * Author: Christopher G. Demetriou, March 2, 1998 (derived from NetBSD
37d974db0aSgarbled * sys/dev/pci/ppb.c, revision 1.16).
38d974db0aSgarbled *
39d974db0aSgarbled * See "PCI IDE Controller Specification, Revision 1.0 3/4/94" from the
40d974db0aSgarbled * PCI SIG.
41d974db0aSgarbled */
42d974db0aSgarbled
43d974db0aSgarbled #include <sys/cdefs.h>
44*b42f375bSrin __KERNEL_RCSID(0, "$NetBSD: pciide_machdep.c,v 1.7 2021/03/17 14:58:16 rin Exp $");
45d974db0aSgarbled
46d974db0aSgarbled #include <sys/param.h>
47d974db0aSgarbled #include <sys/systm.h>
48d974db0aSgarbled #include <sys/device.h>
49d974db0aSgarbled
50d974db0aSgarbled #include <dev/pci/pcireg.h>
51d974db0aSgarbled #include <dev/pci/pcivar.h>
52d974db0aSgarbled #include <dev/pci/pciidereg.h>
53d974db0aSgarbled #include <dev/pci/pciidevar.h>
54d974db0aSgarbled
55d974db0aSgarbled #include <dev/isa/isavar.h>
56d974db0aSgarbled #include <machine/intr.h>
57d974db0aSgarbled #include "isa.h"
58d974db0aSgarbled
59d974db0aSgarbled void *
pciide_machdep_compat_intr_establish(device_t dev,const struct pci_attach_args * pa,int chan,int (* func)(void *),void * arg)6005b09539Smatt pciide_machdep_compat_intr_establish(device_t dev,
61d3e53912Sdyoung const struct pci_attach_args *pa, int chan, int (*func)(void *), void *arg)
62d974db0aSgarbled {
63d974db0aSgarbled #if NISA > 0
64d974db0aSgarbled int irq;
65d974db0aSgarbled void *cookie;
66*b42f375bSrin char intr_xname[INTRDEVNAMEBUF];
67d974db0aSgarbled
68d974db0aSgarbled irq = PCIIDE_COMPAT_IRQ(chan);
69*b42f375bSrin snprintf(intr_xname, sizeof(intr_xname), "%s isa", device_xname(dev));
70ac5d131cSrin cookie = isa_intr_establish_xname(NULL, irq, IST_LEVEL, IPL_BIO, func,
71*b42f375bSrin arg, intr_xname);
72d974db0aSgarbled if (cookie == NULL)
73d974db0aSgarbled return (NULL);
7405b09539Smatt aprint_normal_dev(dev, "%s channel interrupting at irq %d\n",
75d974db0aSgarbled PCIIDE_CHANNEL_NAME(chan), irq);
76d974db0aSgarbled return (cookie);
77d974db0aSgarbled #else
78d974db0aSgarbled panic("pciide_machdep_compat_intr_establish() called");
79d974db0aSgarbled #endif
80d974db0aSgarbled }
81