pci_machdep.c revision 1.3 1 1.3 christos /* $NetBSD: pci_machdep.c,v 1.3 2014/03/29 19:28:26 christos Exp $ */
2 1.1 rkujawa
3 1.1 rkujawa /*-
4 1.1 rkujawa * Copyright (c) 2011 The NetBSD Foundation, Inc.
5 1.1 rkujawa * All rights reserved.
6 1.1 rkujawa *
7 1.1 rkujawa * This code is derived from software contributed to The NetBSD Foundation
8 1.1 rkujawa * by Radoslaw Kujawa.
9 1.1 rkujawa *
10 1.1 rkujawa * Redistribution and use in source and binary forms, with or without
11 1.1 rkujawa * modification, are permitted provided that the following conditions
12 1.1 rkujawa * are met:
13 1.1 rkujawa * 1. Redistributions of source code must retain the above copyright
14 1.1 rkujawa * notice, this list of conditions and the following disclaimer.
15 1.1 rkujawa * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 rkujawa * notice, this list of conditions and the following disclaimer in the
17 1.1 rkujawa * documentation and/or other materials provided with the distribution.
18 1.1 rkujawa *
19 1.1 rkujawa * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 rkujawa * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 rkujawa * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 rkujawa * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 rkujawa * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 rkujawa * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 rkujawa * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 rkujawa * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 rkujawa * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 rkujawa * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 rkujawa * POSSIBILITY OF SUCH DAMAGE.
30 1.1 rkujawa */
31 1.1 rkujawa
32 1.1 rkujawa /* Amiga-specific PCI MD stuff. */
33 1.1 rkujawa
34 1.1 rkujawa #include <sys/types.h>
35 1.1 rkujawa #include <sys/param.h>
36 1.1 rkujawa #include <sys/time.h>
37 1.1 rkujawa #include <sys/systm.h>
38 1.1 rkujawa #include <sys/errno.h>
39 1.1 rkujawa #include <sys/device.h>
40 1.1 rkujawa #include <sys/malloc.h>
41 1.1 rkujawa #include <sys/extent.h>
42 1.1 rkujawa #include <sys/kmem.h>
43 1.1 rkujawa
44 1.1 rkujawa #include <uvm/uvm_extern.h>
45 1.1 rkujawa
46 1.1 rkujawa #include <machine/bus.h>
47 1.1 rkujawa #include <machine/cpu.h>
48 1.1 rkujawa
49 1.1 rkujawa #include <m68k/bus_dma.h>
50 1.1 rkujawa #include <amiga/dev/zbusvar.h>
51 1.1 rkujawa #include <amiga/pci/mppbreg.h>
52 1.1 rkujawa
53 1.1 rkujawa #include <dev/pci/pcivar.h>
54 1.1 rkujawa #include <dev/pci/pcireg.h>
55 1.1 rkujawa #include <dev/pci/pcidevs.h>
56 1.1 rkujawa #include <dev/pci/pciconf.h>
57 1.1 rkujawa
58 1.1 rkujawa pcitag_t
59 1.1 rkujawa amiga_pci_make_tag(pci_chipset_tag_t pc, int bus, int device, int function)
60 1.1 rkujawa {
61 1.1 rkujawa return (bus << 16) | (device << 11) | (function << 8);
62 1.1 rkujawa }
63 1.1 rkujawa
64 1.1 rkujawa void
65 1.1 rkujawa amiga_pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag, int *bp,
66 1.1 rkujawa int *dp, int *fp)
67 1.1 rkujawa {
68 1.1 rkujawa if (bp != NULL)
69 1.1 rkujawa *bp = (tag >> 16) & 0xff;
70 1.1 rkujawa if (dp != NULL)
71 1.1 rkujawa *dp = (tag >> 11) & 0x1f;
72 1.1 rkujawa if (fp != NULL)
73 1.1 rkujawa *fp = (tag >> 8) & 0x07;
74 1.1 rkujawa }
75 1.1 rkujawa
76 1.1 rkujawa void *
77 1.1 rkujawa amiga_pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level,
78 1.1 rkujawa int (*ih_fun)(void *), void *ih_arg)
79 1.1 rkujawa {
80 1.1 rkujawa struct isr* pci_isr;
81 1.1 rkujawa pci_isr = kmem_zalloc(sizeof(struct isr), KM_SLEEP);
82 1.1 rkujawa
83 1.1 rkujawa /* TODO: check for bogus handle */
84 1.1 rkujawa
85 1.1 rkujawa pci_isr->isr_intr = ih_fun;
86 1.1 rkujawa pci_isr->isr_arg = ih_arg;
87 1.1 rkujawa pci_isr->isr_ipl = 2; /* XXX: true for all current drivers */
88 1.1 rkujawa add_isr(pci_isr);
89 1.1 rkujawa return pci_isr;
90 1.1 rkujawa }
91 1.1 rkujawa
92 1.1 rkujawa void
93 1.1 rkujawa amiga_pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie)
94 1.1 rkujawa {
95 1.1 rkujawa remove_isr(cookie);
96 1.1 rkujawa kmem_free(cookie, sizeof(struct isr));
97 1.1 rkujawa }
98 1.1 rkujawa
99 1.1 rkujawa const char *
100 1.3 christos amiga_pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih, char *buf,
101 1.3 christos size_t len)
102 1.1 rkujawa {
103 1.1 rkujawa
104 1.3 christos snprintf(buf, len, "INT%d", (int) ih);
105 1.3 christos return buf;
106 1.1 rkujawa }
107 1.1 rkujawa
108 1.1 rkujawa int
109 1.1 rkujawa amiga_pci_conf_hook(pci_chipset_tag_t pct, int bus, int dev, int func,
110 1.1 rkujawa pcireg_t id)
111 1.1 rkujawa {
112 1.1 rkujawa return PCI_CONF_DEFAULT;
113 1.1 rkujawa }
114 1.1 rkujawa
115 1.1 rkujawa void
116 1.1 rkujawa amiga_pci_conf_interrupt(pci_chipset_tag_t pc, int bus, int dev, int func,
117 1.1 rkujawa int swiz, int *iline)
118 1.1 rkujawa {
119 1.1 rkujawa }
120 1.1 rkujawa
121