Add driver for Cavium Interrupt Bus.diff -r1.3 -r1.4 src/sys/arch/evbmips/conf/OCTEON
(jmcneill)
--- src/sys/arch/evbmips/conf/OCTEON 2020/07/16 16:39:54 1.3
+++ src/sys/arch/evbmips/conf/OCTEON 2020/07/16 18:39:18 1.4
@@ -1,189 +1,190 @@ | @@ -1,189 +1,190 @@ | |||
1 | # $NetBSD: OCTEON,v 1.3 2020/07/16 16:39:54 jmcneill Exp $ | 1 | # $NetBSD: OCTEON,v 1.4 2020/07/16 18:39:18 jmcneill Exp $ | |
2 | 2 | |||
3 | include "arch/mips/conf/std.octeon" | 3 | include "arch/mips/conf/std.octeon" | |
4 | include "arch/evbmips/conf/files.octeon" | 4 | include "arch/evbmips/conf/files.octeon" | |
5 | 5 | |||
6 | #options INCLUDE_CONFIG_FILE # embed config file in kernel binary | 6 | #options INCLUDE_CONFIG_FILE # embed config file in kernel binary | |
7 | 7 | |||
8 | #ident "ERLITE-$Revision: 1.3 $" | 8 | #ident "ERLITE-$Revision: 1.4 $" | |
9 | 9 | |||
10 | maxusers 32 | 10 | maxusers 32 | |
11 | 11 | |||
12 | options FDT | 12 | options FDT | |
13 | options FDT_DEFAULT_STDOUT_PATH="\"uart0:115200n8\"" | 13 | options FDT_DEFAULT_STDOUT_PATH="\"uart0:115200n8\"" | |
14 | 14 | |||
15 | # Options for necessary to use MD | 15 | # Options for necessary to use MD | |
16 | #options MEMORY_DISK_HOOKS | 16 | #options MEMORY_DISK_HOOKS | |
17 | #options MEMORY_DISK_IS_ROOT # force root on memory disk | 17 | #options MEMORY_DISK_IS_ROOT # force root on memory disk | |
18 | #options MEMORY_DISK_SERVER=0 # no userspace memory disk support | 18 | #options MEMORY_DISK_SERVER=0 # no userspace memory disk support | |
19 | #options MEMORY_DISK_ROOT_SIZE=6144 # size of memory disk, in blocks | 19 | #options MEMORY_DISK_ROOT_SIZE=6144 # size of memory disk, in blocks | |
20 | #options MEMORY_DISK_ROOT_SIZE=16384 # size of memory disk, in blocks | 20 | #options MEMORY_DISK_ROOT_SIZE=16384 # size of memory disk, in blocks | |
21 | #options MEMORY_DISK_ROOT_SIZE=7300 | 21 | #options MEMORY_DISK_ROOT_SIZE=7300 | |
22 | 22 | |||
23 | # Size reduction options | 23 | # Size reduction options | |
24 | #options VNODE_OP_NOINLINE | 24 | #options VNODE_OP_NOINLINE | |
25 | #options PIPE_SOCKETPAIR | 25 | #options PIPE_SOCKETPAIR | |
26 | #options SOSEND_NO_LOAN | 26 | #options SOSEND_NO_LOAN | |
27 | 27 | |||
28 | # Standard system options | 28 | # Standard system options | |
29 | options KTRACE # system call tracing support | 29 | options KTRACE # system call tracing support | |
30 | options SYSVMSG # System V message queues | 30 | options SYSVMSG # System V message queues | |
31 | options SYSVSEM # System V semaphores | 31 | options SYSVSEM # System V semaphores | |
32 | options SYSVSHM # System V shared memory | 32 | options SYSVSHM # System V shared memory | |
33 | options NTP # network time protocol | 33 | options NTP # network time protocol | |
34 | 34 | |||
35 | # Debugging options | 35 | # Debugging options | |
36 | options DIAGNOSTIC # extra kernel sanity checking | 36 | options DIAGNOSTIC # extra kernel sanity checking | |
37 | #options DEBUG # extra kernel debugging support | 37 | #options DEBUG # extra kernel debugging support | |
38 | #options USERCONF # userconf(4) support | 38 | #options USERCONF # userconf(4) support | |
39 | #options SYSCTL_INCLUDE_DESCR # Include sysctl descriptions in kernel | 39 | #options SYSCTL_INCLUDE_DESCR # Include sysctl descriptions in kernel | |
40 | options DDB # kernel dynamic debugger | 40 | options DDB # kernel dynamic debugger | |
41 | options DDB_HISTORY_SIZE=100 # enable history editing in DDB | 41 | options DDB_HISTORY_SIZE=100 # enable history editing in DDB | |
42 | makeoptions DEBUG="-g" # compile full symbol table | 42 | makeoptions DEBUG="-g" # compile full symbol table | |
43 | makeoptions COPY_SYMTAB=1 # size for embedded symbol table | 43 | makeoptions COPY_SYMTAB=1 # size for embedded symbol table | |
44 | 44 | |||
45 | # Compatibility options | 45 | # Compatibility options | |
46 | 46 | |||
47 | include "conf/compat_netbsd50.config" | 47 | include "conf/compat_netbsd50.config" | |
48 | #options COMPAT_386BSD_MBRPART # recognize old partition ID | 48 | #options COMPAT_386BSD_MBRPART # recognize old partition ID | |
49 | 49 | |||
50 | #options EXEC_ECOFF # exec ECOFF binaries | 50 | #options EXEC_ECOFF # exec ECOFF binaries | |
51 | #options COMPAT_ULTRIX # binary compatibility with Ultrix | 51 | #options COMPAT_ULTRIX # binary compatibility with Ultrix | |
52 | 52 | |||
53 | # File systems | 53 | # File systems | |
54 | file-system FFS # Berkeley Fast Filesystem | 54 | file-system FFS # Berkeley Fast Filesystem | |
55 | file-system MFS # memory-based filesystem | 55 | file-system MFS # memory-based filesystem | |
56 | file-system EXT2FS # second extended file system (linux) | 56 | file-system EXT2FS # second extended file system (linux) | |
57 | file-system NFS # Sun NFS-compatible filesystem client | 57 | file-system NFS # Sun NFS-compatible filesystem client | |
58 | file-system TMPFS # Efficient memory file-system | 58 | file-system TMPFS # Efficient memory file-system | |
59 | file-system KERNFS # kernel data-structure filesystem | 59 | file-system KERNFS # kernel data-structure filesystem | |
60 | file-system NULLFS # NULL layered filesystem | 60 | file-system NULLFS # NULL layered filesystem | |
61 | #file-system OVERLAY # overlay file system | 61 | #file-system OVERLAY # overlay file system | |
62 | #file-system FDESC # user file descriptor filesystem | 62 | #file-system FDESC # user file descriptor filesystem | |
63 | #file-system UMAPFS # uid/gid remapping filesystem | 63 | #file-system UMAPFS # uid/gid remapping filesystem | |
64 | #file-system LFS # Log-based filesystem (still experimental) | 64 | #file-system LFS # Log-based filesystem (still experimental) | |
65 | file-system PROCFS # /proc | 65 | file-system PROCFS # /proc | |
66 | file-system CD9660 # ISO 9660 + Rock Ridge file system | 66 | file-system CD9660 # ISO 9660 + Rock Ridge file system | |
67 | #file-system UNION # union file system | 67 | #file-system UNION # union file system | |
68 | file-system MSDOSFS # MS-DOS FAT filesystem(s). | 68 | file-system MSDOSFS # MS-DOS FAT filesystem(s). | |
69 | #file-system CODA # Coda File System; also needs vcoda (below) | 69 | #file-system CODA # Coda File System; also needs vcoda (below) | |
70 | file-system PTYFS # /dev/pts/N support | 70 | file-system PTYFS # /dev/pts/N support | |
71 | 71 | |||
72 | # File system options | 72 | # File system options | |
73 | options NFSSERVER # Sun NFS-compatible filesystem server | 73 | options NFSSERVER # Sun NFS-compatible filesystem server | |
74 | #options QUOTA # legacy UFS quotas | 74 | #options QUOTA # legacy UFS quotas | |
75 | #options QUOTA2 # new, in-filesystem UFS quotas | 75 | #options QUOTA2 # new, in-filesystem UFS quotas | |
76 | #options DISKLABEL_EI # disklabel Endian Independent support | 76 | #options DISKLABEL_EI # disklabel Endian Independent support | |
77 | #options FFS_EI # FFS Endian Independent support | 77 | #options FFS_EI # FFS Endian Independent support | |
78 | options WAPBL # File system journaling support | 78 | options WAPBL # File system journaling support | |
79 | #options FFS_NO_SNAPSHOT # No FFS snapshot support | 79 | #options FFS_NO_SNAPSHOT # No FFS snapshot support | |
80 | #options EXT2FS_SYSTEM_FLAGS # makes ext2fs file flags (append and | 80 | #options EXT2FS_SYSTEM_FLAGS # makes ext2fs file flags (append and | |
81 | # immutable) behave as system flags. | 81 | # immutable) behave as system flags. | |
82 | 82 | |||
83 | # Alternate buffer queue strategies for better responsiveness under high | 83 | # Alternate buffer queue strategies for better responsiveness under high | |
84 | # disk I/O load. | 84 | # disk I/O load. | |
85 | #options BUFQ_READPRIO | 85 | #options BUFQ_READPRIO | |
86 | options BUFQ_PRIOCSCAN | 86 | options BUFQ_PRIOCSCAN | |
87 | 87 | |||
88 | # Networking options | 88 | # Networking options | |
89 | #options GATEWAY # IP packet forwarding | 89 | #options GATEWAY # IP packet forwarding | |
90 | options INET # Internet protocols | 90 | options INET # Internet protocols | |
91 | options INET6 # IPV6 | 91 | options INET6 # IPV6 | |
92 | #options IPSEC # IP security | 92 | #options IPSEC # IP security | |
93 | #options IPSEC_DEBUG # debug for IP security | 93 | #options IPSEC_DEBUG # debug for IP security | |
94 | #options MROUTING # packet forwarding of multicast packets | 94 | #options MROUTING # packet forwarding of multicast packets | |
95 | #options PIM # Protocol Independent Multicast | 95 | #options PIM # Protocol Independent Multicast | |
96 | #options NETATALK # AppleTalk (over Ethernet) protocol | 96 | #options NETATALK # AppleTalk (over Ethernet) protocol | |
97 | #options PPP_BSDCOMP # BSD-Compress compression support for PPP | 97 | #options PPP_BSDCOMP # BSD-Compress compression support for PPP | |
98 | #options PPP_DEFLATE # Deflate compression support for PPP | 98 | #options PPP_DEFLATE # Deflate compression support for PPP | |
99 | #options PPP_FILTER # Active filter support for PPP (requires bpf) | 99 | #options PPP_FILTER # Active filter support for PPP (requires bpf) | |
100 | options BPFJIT | 100 | options BPFJIT | |
101 | options SLJIT | 101 | options SLJIT | |
102 | 102 | |||
103 | # These options enable verbose messages for several subsystems. | 103 | # These options enable verbose messages for several subsystems. | |
104 | # Warning, these may compile large string tables into the kernel! | 104 | # Warning, these may compile large string tables into the kernel! | |
105 | options MIIVERBOSE # verbose PHY autoconfig messages | 105 | options MIIVERBOSE # verbose PHY autoconfig messages | |
106 | 106 | |||
107 | options NFS_BOOT_DHCP | 107 | options NFS_BOOT_DHCP | |
108 | 108 | |||
109 | config netbsd root on ? type ? | 109 | config netbsd root on ? type ? | |
110 | #config netbsd root on cnmac0 type nfs | 110 | #config netbsd root on cnmac0 type nfs | |
111 | 111 | |||
112 | mainbus0 at root | 112 | mainbus0 at root | |
113 | cpunode0 at mainbus? | 113 | cpunode0 at mainbus? | |
114 | cpu* at cpunode? core ? | 114 | cpu* at cpunode? core ? | |
115 | wdog0 at cpunode0 flags 0 # flags 1 will enable it on boot | 115 | wdog0 at cpunode0 flags 0 # flags 1 will enable it on boot | |
116 | 116 | |||
117 | iobus0 at mainbus? | 117 | iobus0 at mainbus? | |
118 | bootbus0 at mainbus? | 118 | bootbus0 at mainbus? | |
119 | simplebus* at fdt? pass 0 | 119 | simplebus* at fdt? pass 0 | |
120 | 120 | |||
121 | octintc* at fdt? pass 1 | 121 | octintc* at fdt? pass 1 | |
122 | octcib* at fdt? pass 2 | |||
122 | 123 | |||
123 | com* at iobus? | 124 | com* at iobus? | |
124 | com* at fdt? | 125 | com* at fdt? | |
125 | 126 | |||
126 | octsmi* at iobus? # MDIO controller | 127 | octsmi* at iobus? # MDIO controller | |
127 | octsmi* at fdt? pass 2 | 128 | octsmi* at fdt? pass 3 | |
128 | octpip* at iobus? # PIP packet processing controller | 129 | octpip* at iobus? # PIP packet processing controller | |
129 | octpip* at fdt? pass 3 | 130 | octpip* at fdt? pass 4 | |
130 | 131 | |||
131 | octgmx* at octpip? | 132 | octgmx* at octpip? | |
132 | cnmac* at octgmx? | 133 | cnmac* at octgmx? | |
133 | 134 | |||
134 | octrnm* at iobus? # Random Number Memory (and generator) | 135 | octrnm* at iobus? # Random Number Memory (and generator) | |
135 | 136 | |||
136 | dwctwo* at iobus? | 137 | dwctwo* at iobus? | |
137 | 138 | |||
138 | usb* at dwctwo? | 139 | usb* at dwctwo? | |
139 | 140 | |||
140 | uhub* at usb? | 141 | uhub* at usb? | |
141 | 142 | |||
142 | # USB Mass Storage | 143 | # USB Mass Storage | |
143 | umass* at uhub? port ? configuration ? interface ? | 144 | umass* at uhub? port ? configuration ? interface ? | |
144 | scsibus* at umass? channel ? | 145 | scsibus* at umass? channel ? | |
145 | sd* at scsibus? target ? lun ? # SCSI disk drives | 146 | sd* at scsibus? target ? lun ? # SCSI disk drives | |
146 | 147 | |||
147 | # Ethernet PHYs | 148 | # Ethernet PHYs | |
148 | atphy* at mii? phy ? # Attansic/Atheros PHYs | 149 | atphy* at mii? phy ? # Attansic/Atheros PHYs | |
149 | ukphy* at mii? phy ? # generic unknown PHYs | 150 | ukphy* at mii? phy ? # generic unknown PHYs | |
150 | 151 | |||
151 | # Pseudo-devices | 152 | # Pseudo-devices | |
152 | 153 | |||
153 | # Disk/mass storage pseudo-devices | 154 | # Disk/mass storage pseudo-devices | |
154 | #pseudo-device ccd # concatenated disk devices | 155 | #pseudo-device ccd # concatenated disk devices | |
155 | #pseudo-device raid # RAIDframe disk driver | 156 | #pseudo-device raid # RAIDframe disk driver | |
156 | #pseudo-device fss # file system snapshot device | 157 | #pseudo-device fss # file system snapshot device | |
157 | #pseudo-device md # memory disk device (ramdisk) | 158 | #pseudo-device md # memory disk device (ramdisk) | |
158 | #pseudo-device vnd # disk-like interface to files | 159 | #pseudo-device vnd # disk-like interface to files | |
159 | 160 | |||
160 | # Network pseudo-devices | 161 | # Network pseudo-devices | |
161 | pseudo-device bpfilter # Berkeley packet filter | 162 | pseudo-device bpfilter # Berkeley packet filter | |
162 | pseudo-device carp # Common Address Redundancy Protocol | 163 | pseudo-device carp # Common Address Redundancy Protocol | |
163 | pseudo-device npf # NPF packet filter | 164 | pseudo-device npf # NPF packet filter | |
164 | pseudo-device loop # network loopback | 165 | pseudo-device loop # network loopback | |
165 | pseudo-device ppp # Point-to-Point Protocol | 166 | pseudo-device ppp # Point-to-Point Protocol | |
166 | pseudo-device pppoe # Point-to-Point Protocol over Ethernet | 167 | pseudo-device pppoe # Point-to-Point Protocol over Ethernet | |
167 | #pseudo-device sl # Serial Line IP | 168 | #pseudo-device sl # Serial Line IP | |
168 | pseudo-device tun # network tunneling over tty | 169 | pseudo-device tun # network tunneling over tty | |
169 | pseudo-device tap # virtual Ethernet | 170 | pseudo-device tap # virtual Ethernet | |
170 | #pseudo-device gre # generic L3 over IP tunnel | 171 | #pseudo-device gre # generic L3 over IP tunnel | |
171 | #pseudo-device ipip # RFC 2003 IP Encapsulation | 172 | #pseudo-device ipip # RFC 2003 IP Encapsulation | |
172 | pseudo-device gif # RFC1933 tunnel | 173 | pseudo-device gif # RFC1933 tunnel | |
173 | #pseudo-device faith # IPv[46] tcp relay translation | 174 | #pseudo-device faith # IPv[46] tcp relay translation | |
174 | #pseudo-device stf # 6to4 IPv6 over IPv4 encapsulation | 175 | #pseudo-device stf # 6to4 IPv6 over IPv4 encapsulation | |
175 | pseudo-device vlan # IEEE 802.1q encapsulation | 176 | pseudo-device vlan # IEEE 802.1q encapsulation | |
176 | pseudo-device bridge # simple inter-network bridging | 177 | pseudo-device bridge # simple inter-network bridging | |
177 | 178 | |||
178 | # Miscellaneous pseudo-devices | 179 | # Miscellaneous pseudo-devices | |
179 | pseudo-device pty # pseudo-terminals | 180 | pseudo-device pty # pseudo-terminals | |
180 | pseudo-device clockctl # user control of clock subsystem | 181 | pseudo-device clockctl # user control of clock subsystem | |
181 | pseudo-device ksyms # /dev/ksyms | 182 | pseudo-device ksyms # /dev/ksyms | |
182 | pseudo-device drvctl # driver control | 183 | pseudo-device drvctl # driver control | |
183 | 184 | |||
184 | # A pseudo device needed for Coda # also needs CODA (above) | 185 | # A pseudo device needed for Coda # also needs CODA (above) | |
185 | #pseudo-device vcoda # coda minicache <-> venus comm. | 186 | #pseudo-device vcoda # coda minicache <-> venus comm. | |
186 | 187 | |||
187 | include "dev/veriexec.config" | 188 | include "dev/veriexec.config" | |
188 | 189 | |||
189 | cinclude "arch/evbmips/conf/OCTEON.local" | 190 | cinclude "arch/evbmips/conf/OCTEON.local" |
/* $NetBSD: octeon_cib.c,v 1.1 2020/07/16 18:39:19 jmcneill Exp $ */
/*-
* Copyright (c) 2020 Jared D. McNeill <jmcneill@invisible.ca>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "opt_multiprocessor.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: octeon_cib.c,v 1.1 2020/07/16 18:39:19 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/device.h>
#include <sys/intr.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/kmem.h>
#include <dev/fdt/fdtvar.h>
#include <arch/mips/cavium/octeonvar.h>
static int octeon_cib_match(device_t, cfdata_t, void *);
static void octeon_cib_attach(device_t, device_t, void *);
static void * octeon_cib_establish(device_t, u_int *, int, int,
int (*)(void *), void *);
static void octeon_cib_disestablish(device_t, void *);
static bool octeon_cib_intrstr(device_t, u_int *, char *, size_t);
static int octeon_cib_intr(void *);
struct fdtbus_interrupt_controller_func octeon_cib_funcs = {
.establish = octeon_cib_establish,
.disestablish = octeon_cib_disestablish,
.intrstr = octeon_cib_intrstr
};
struct octeon_cib_intr {
bool ih_mpsafe;
int ih_type;
int (*ih_func)(void *);
void *ih_arg;
uint64_t ih_mask;
};
struct octeon_cib_softc {
device_t sc_dev;
int sc_phandle;
bus_space_tag_t sc_bst;
bus_space_handle_t sc_bsh_raw;
bus_space_handle_t sc_bsh_en;
struct octeon_cib_intr *sc_intr;
u_int sc_nintr;
};
#define CIB_READ_RAW(sc) \
bus_space_read_8((sc)->sc_bst, (sc)->sc_bsh_raw, 0)
#define CIB_WRITE_RAW(sc, val) \
bus_space_write_8((sc)->sc_bst, (sc)->sc_bsh_raw, 0, (val))
#define CIB_READ_EN(sc) \
bus_space_read_8((sc)->sc_bst, (sc)->sc_bsh_en, 0)
#define CIB_WRITE_EN(sc, val) \
bus_space_write_8((sc)->sc_bst, (sc)->sc_bsh_en, 0, (val))
CFATTACH_DECL_NEW(octcib, sizeof(struct octeon_cib_softc),
octeon_cib_match, octeon_cib_attach, NULL, NULL);
static const struct of_compat_data compat_data[] = {
{ "cavium,octeon-7130-cib", 1 },
{ NULL }
};
static int
octeon_cib_match(device_t parent, cfdata_t cf, void *aux)
{
struct fdt_attach_args * const faa = aux;
return of_match_compat_data(faa->faa_phandle, compat_data);
}
static void
octeon_cib_attach(device_t parent, device_t self, void *aux)
{
struct octeon_cib_softc * const sc = device_private(self);
struct fdt_attach_args * const faa = aux;
const int phandle = faa->faa_phandle;
char intrstr[128];
bus_addr_t addr;
bus_size_t size;
u_int max_bits;
int error;
void *ih;
sc->sc_dev = self;
sc->sc_phandle = phandle;
sc->sc_bst = faa->faa_bst;
if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0 ||
bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh_raw) != 0) {
aprint_error(": couldn't map RAW register\n");
return;
}
if (fdtbus_get_reg(phandle, 1, &addr, &size) != 0 ||
bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh_en) != 0) {
aprint_error(": couldn't map EN register\n");
return;
}
if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) {
aprint_error(": failed to decode interrupt\n");
return;
}
if (of_getprop_uint32(phandle, "cavium,max-bits", &max_bits) != 0) {
aprint_error(": missing 'cavium,max-bits' property\n");
return;
}
if (max_bits == 0 || max_bits > 64) {
aprint_error(": 'cavium,max-bits' value out of range\n");
return;
}
sc->sc_intr = kmem_zalloc(sizeof(*sc->sc_intr) * max_bits, KM_SLEEP);
sc->sc_nintr = max_bits;
error = fdtbus_register_interrupt_controller(self, phandle,
&octeon_cib_funcs);
if (error != 0) {
aprint_error(": couldn't register with fdtbus: %d\n", error);
return;
}
aprint_naive("\n");
aprint_normal(": CIB\n");
CIB_WRITE_EN(sc, 0);
CIB_WRITE_RAW(sc, ~0ULL);
ih = fdtbus_intr_establish(phandle, 0, IPL_SCHED, FDT_INTR_MPSAFE,
octeon_cib_intr, sc);
if (ih == NULL) {
aprint_error_dev(self, "couldn't establish interrupt on %s\n",
intrstr);
return;
}
aprint_normal_dev(self, "interrupting on %s\n", intrstr);
}
static void *
octeon_cib_establish(device_t dev, u_int *specifier, int ipl, int flags,
int (*func)(void *), void *arg)
{
struct octeon_cib_softc * const sc = device_private(dev);
struct octeon_cib_intr *ih;
uint64_t val;
/* 1st cell is the bit number in the CIB* registers */
/* 2nd cell is the triggering setting */
const int bit = be32toh(specifier[0]);
const int type = (be32toh(specifier[1]) & 0x3) ? IST_EDGE : IST_LEVEL;
if (bit > sc->sc_nintr) {
aprint_error_dev(dev, "bit %d out of range\n", bit);
return NULL;
}
ih = &sc->sc_intr[bit];
ih->ih_mpsafe = (flags & FDT_INTR_MPSAFE) != 0;
ih->ih_type = type;
ih->ih_func = func;
ih->ih_arg = arg;
ih->ih_mask = __BIT(bit);
val = CIB_READ_EN(sc);
val |= ih->ih_mask;
CIB_WRITE_EN(sc, val);
return ih;
}
static void
octeon_cib_disestablish(device_t dev, void *ih_cookie)
{
struct octeon_cib_softc * const sc = device_private(dev);
struct octeon_cib_intr *ih = ih_cookie;
uint64_t val;
val = CIB_READ_EN(sc);
val &= ~ih->ih_mask;
CIB_WRITE_EN(sc, val);
}
static bool
octeon_cib_intrstr(device_t dev, u_int *specifier, char *buf,
size_t buflen)
{
/* 1st cell is the bit number in the CIB* registers */
const int bit = be32toh(specifier[0]);
snprintf(buf, buflen, "%s intr %d", device_xname(dev), bit);
return true;
}
static int
octeon_cib_intr(void *priv)
{
struct octeon_cib_softc * const sc = priv;
struct octeon_cib_intr *ih;
uint64_t pend;
int n, rv = 0;
pend = CIB_READ_RAW(sc);
pend &= CIB_READ_EN(sc);
while ((n = ffs64(pend)) != 0) {
ih = &sc->sc_intr[n - 1];
KASSERT(ih->ih_mask == __BIT(n - 1));
if (ih->ih_type == IST_EDGE)
CIB_WRITE_RAW(sc, ih->ih_mask); /* ack */
#ifdef MULTIPROCESSOR
if (!ih->ih_mpsafe) {
KERNEL_LOCK(1, NULL);
rv |= ih->ih_func(ih->ih_arg);
KERNEL_UNLOCK_ONE(NULL);
} else
#endif
rv |= ih->ih_func(ih->ih_arg);
pend &= ~ih->ih_mask;
}
return rv;
}
--- src/sys/arch/mips/conf/files.octeon 2020/07/16 11:49:38 1.10
+++ src/sys/arch/mips/conf/files.octeon 2020/07/16 18:39:19 1.11
@@ -1,131 +1,131 @@ | @@ -1,131 +1,131 @@ | |||
1 | # $NetBSD: files.octeon,v 1.10 2020/07/16 11:49:38 jmcneill Exp $ | 1 | # $NetBSD: files.octeon,v 1.11 2020/07/16 18:39:19 jmcneill Exp $ | |
2 | 2 | |||
3 | file arch/mips/mips/locore_octeon.S | 3 | file arch/mips/mips/locore_octeon.S | |
4 | file arch/mips/mips/bus_dma.c | 4 | file arch/mips/mips/bus_dma.c | |
5 | file arch/mips/mips/mips3_clock.c | 5 | file arch/mips/mips/mips3_clock.c | |
6 | file arch/mips/mips/mips3_clockintr.c | 6 | file arch/mips/mips/mips3_clockintr.c | |
7 | 7 | |||
8 | file arch/mips/cavium/octeon_dma.c | 8 | file arch/mips/cavium/octeon_dma.c | |
9 | file arch/mips/cavium/octeon_intr.c | 9 | file arch/mips/cavium/octeon_intr.c | |
10 | file arch/mips/cavium/octeon_misc.c | 10 | file arch/mips/cavium/octeon_misc.c | |
11 | 11 | |||
12 | file arch/mips/fdt/fdt_dma_machdep.c | 12 | file arch/mips/fdt/fdt_dma_machdep.c | |
13 | 13 | |||
14 | device mainbus {}: fdt | 14 | device mainbus {}: fdt | |
15 | attach mainbus at root | 15 | attach mainbus at root | |
16 | file arch/mips/cavium/mainbus.c mainbus | 16 | file arch/mips/cavium/mainbus.c mainbus | |
17 | file arch/mips/cavium/mainbus_octeon1p.c mainbus | 17 | file arch/mips/cavium/mainbus_octeon1p.c mainbus | |
18 | 18 | |||
19 | device cpunode { [core=-1] } | 19 | device cpunode { [core=-1] } | |
20 | attach cpunode at mainbus | 20 | attach cpunode at mainbus | |
21 | 21 | |||
22 | device cpu {} | 22 | device cpu {} | |
23 | attach cpu at cpunode with cpu_cpunode | 23 | attach cpu at cpunode with cpu_cpunode | |
24 | 24 | |||
25 | device wdog: sysmon_wdog | 25 | device wdog: sysmon_wdog | |
26 | attach wdog at cpunode with wdog_cpunode | 26 | attach wdog at cpunode with wdog_cpunode | |
27 | 27 | |||
28 | file arch/mips/cavium/octeon_cpunode.c cpunode | cpu | wdog needs-flag | 28 | file arch/mips/cavium/octeon_cpunode.c cpunode | cpu | wdog needs-flag | |
29 | 29 | |||
30 | # FDT | 30 | # FDT | |
31 | device octintc | 31 | device octintc | |
32 | attach octintc at fdt | 32 | attach octintc at fdt | |
33 | file arch/mips/cavium/dev/octeon_intc.c octintc | 33 | file arch/mips/cavium/dev/octeon_intc.c octintc | |
34 | 34 | |||
35 | device octcib | |||
36 | attach octcib at fdt | |||
37 | file arch/mips/cavium/dev/octeon_cib.c octcib | |||
38 | ||||
35 | # I/O Bus | 39 | # I/O Bus | |
36 | 40 | |||
37 | device iobus {} | 41 | device iobus {} | |
38 | attach iobus at mainbus | 42 | attach iobus at mainbus | |
39 | file arch/mips/cavium/octeon_iobus.c iobus | 43 | file arch/mips/cavium/octeon_iobus.c iobus | |
40 | file arch/mips/cavium/octeon1p_iobus.c iobus | 44 | file arch/mips/cavium/octeon1p_iobus.c iobus | |
41 | file arch/mips/cavium/dev/octeon_fpa.c iobus | 45 | file arch/mips/cavium/dev/octeon_fpa.c iobus | |
42 | file arch/mips/cavium/dev/octeon_pow.c iobus | 46 | file arch/mips/cavium/dev/octeon_pow.c iobus | |
43 | file arch/mips/cavium/dev/octeon_fau.c iobus | 47 | file arch/mips/cavium/dev/octeon_fau.c iobus | |
44 | file arch/mips/cavium/dev/octeon_ipd.c iobus | 48 | file arch/mips/cavium/dev/octeon_ipd.c iobus | |
45 | file arch/mips/cavium/dev/octeon_pko.c iobus | 49 | file arch/mips/cavium/dev/octeon_pko.c iobus | |
46 | file arch/mips/cavium/dev/octeon_asx.c iobus | 50 | file arch/mips/cavium/dev/octeon_asx.c iobus | |
47 | 51 | |||
48 | # I/O Bus devices | 52 | # I/O Bus devices | |
49 | 53 | |||
50 | attach com at iobus with com_iobus | 54 | attach com at iobus with com_iobus | |
51 | file arch/mips/cavium/dev/octeon_uart.c com_iobus | 55 | file arch/mips/cavium/dev/octeon_uart.c com_iobus | |
52 | options COM_REGMAP | 56 | options COM_REGMAP | |
53 | 57 | |||
54 | device octrnm | 58 | device octrnm | |
55 | attach octrnm at iobus | 59 | attach octrnm at iobus | |
56 | file arch/mips/cavium/dev/octeon_rnm.c octrnm & rnd | 60 | file arch/mips/cavium/dev/octeon_rnm.c octrnm & rnd | |
57 | 61 | |||
58 | device octtwsi: i2cbus | 62 | device octtwsi: i2cbus | |
59 | attach octtwsi at iobus | 63 | attach octtwsi at iobus | |
60 | file arch/mips/cavium/dev/octeon_twsi.c octtwsi | 64 | file arch/mips/cavium/dev/octeon_twsi.c octtwsi | |
61 | 65 | |||
62 | # XXX rename to octspi? | 66 | # XXX rename to octspi? | |
63 | device octmpi: spibus | 67 | device octmpi: spibus | |
64 | attach octmpi at iobus | 68 | attach octmpi at iobus | |
65 | file arch/mips/cavium/dev/octeon_mpi.c octmpi | 69 | file arch/mips/cavium/dev/octeon_mpi.c octmpi | |
66 | 70 | |||
67 | device octcib {} | |||
68 | attach octcib at iobus | |||
69 | file arch/mips/cavium/dev/octeon_cib.c octcib | |||
70 | ||||
71 | device octcit {} | 71 | device octcit {} | |
72 | attach octcit at iobus | 72 | attach octcit at iobus | |
73 | file arch/mips/cavium/dev/octeon_cit.c octcit | 73 | file arch/mips/cavium/dev/octeon_cit.c octcit | |
74 | 74 | |||
75 | device octciu {} | 75 | device octciu {} | |
76 | attach octciu at iobus | 76 | attach octciu at iobus | |
77 | file arch/mips/cavium/dev/octeon_ciu.c octciu | 77 | file arch/mips/cavium/dev/octeon_ciu.c octciu | |
78 | 78 | |||
79 | device octsmi {} | 79 | device octsmi {} | |
80 | attach octsmi at iobus with octsmi_iobus | 80 | attach octsmi at iobus with octsmi_iobus | |
81 | attach octsmi at fdt with octsmi_fdt | 81 | attach octsmi at fdt with octsmi_fdt | |
82 | file arch/mips/cavium/dev/octeon_smi.c octsmi_iobus | octsmi_fdt | 82 | file arch/mips/cavium/dev/octeon_smi.c octsmi_iobus | octsmi_fdt | |
83 | 83 | |||
84 | device octpip {} | 84 | device octpip {} | |
85 | attach octpip at iobus with octpip_iobus | 85 | attach octpip at iobus with octpip_iobus | |
86 | attach octpip at fdt with octpip_fdt | 86 | attach octpip at fdt with octpip_fdt | |
87 | file arch/mips/cavium/dev/octeon_pip.c octpip_iobus | octpip_fdt | 87 | file arch/mips/cavium/dev/octeon_pip.c octpip_iobus | octpip_fdt | |
88 | 88 | |||
89 | device octgmx {} | 89 | device octgmx {} | |
90 | attach octgmx at octpip | 90 | attach octgmx at octpip | |
91 | file arch/mips/cavium/dev/octeon_gmx.c octgmx | 91 | file arch/mips/cavium/dev/octeon_gmx.c octgmx | |
92 | 92 | |||
93 | # On-chip ethernet device(s) | 93 | # On-chip ethernet device(s) | |
94 | device cnmac: ether, ifnet, arp, mii | 94 | device cnmac: ether, ifnet, arp, mii | |
95 | attach cnmac at octgmx | 95 | attach cnmac at octgmx | |
96 | file arch/mips/cavium/dev/if_cnmac.c cnmac | 96 | file arch/mips/cavium/dev/if_cnmac.c cnmac | |
97 | 97 | |||
98 | # CN3xxx/CN5xxx USB | 98 | # CN3xxx/CN5xxx USB | |
99 | attach dwctwo at iobus with octdwctwo | 99 | attach dwctwo at iobus with octdwctwo | |
100 | file arch/mips/cavium/dev/octeon_dwctwo.c octdwctwo | 100 | file arch/mips/cavium/dev/octeon_dwctwo.c octdwctwo | |
101 | 101 | |||
102 | # CN6xxx USB | 102 | # CN6xxx USB | |
103 | device octuctl {} | 103 | device octuctl {} | |
104 | attach octuctl at iobus with octuctl | 104 | attach octuctl at iobus with octuctl | |
105 | file arch/mips/cavium/dev/octeon_uctl.c octuctl | 105 | file arch/mips/cavium/dev/octeon_uctl.c octuctl | |
106 | 106 | |||
107 | # CN7xxx USB | 107 | # CN7xxx USB | |
108 | device octxctl {} | 108 | device octxctl {} | |
109 | attach octxctl at iobus with octxctl | 109 | attach octxctl at iobus with octxctl | |
110 | file arch/mips/cavium/dev/octeon_xctl.c octuctl | 110 | file arch/mips/cavium/dev/octeon_xctl.c octuctl | |
111 | 111 | |||
112 | # Boot-Bus | 112 | # Boot-Bus | |
113 | 113 | |||
114 | device bootbus {} | 114 | device bootbus {} | |
115 | attach bootbus at mainbus | 115 | attach bootbus at mainbus | |
116 | file arch/mips/cavium/octeon_bootbus.c bootbus | 116 | file arch/mips/cavium/octeon_bootbus.c bootbus | |
117 | 117 | |||
118 | # Machine-independent I2O drivers. | 118 | # Machine-independent I2O drivers. | |
119 | include "dev/i2o/files.i2o" | 119 | include "dev/i2o/files.i2o" | |
120 | 120 | |||
121 | # Machine-independent SCSI drivers | 121 | # Machine-independent SCSI drivers | |
122 | include "dev/scsipi/files.scsipi" | 122 | include "dev/scsipi/files.scsipi" | |
123 | 123 | |||
124 | # Machine-independent ATA drivers | 124 | # Machine-independent ATA drivers | |
125 | include "dev/ata/files.ata" | 125 | include "dev/ata/files.ata" | |
126 | 126 | |||
127 | # Machine-independent USB device support | 127 | # Machine-independent USB device support | |
128 | include "dev/usb/files.usb" | 128 | include "dev/usb/files.usb" | |
129 | 129 | |||
130 | ## # Machine-independent PCI device support | 130 | ## # Machine-independent PCI device support | |
131 | ## include "dev/pci/files.pci" | 131 | ## include "dev/pci/files.pci" |