2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2013 Rui Paulo <rpaulo@FreeBSD.org>
5 * Copyright (c) 2017 Manuel Stuehn
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/fcntl.h>
40 #include <sys/kernel.h>
42 #include <sys/module.h>
43 #include <sys/malloc.h>
44 #include <sys/mutex.h>
46 #include <sys/types.h>
47 #include <sys/sysctl.h>
48 #include <sys/event.h>
49 #include <sys/selinfo.h>
50 #include <machine/bus.h>
51 #include <machine/cpu.h>
52 #include <machine/frame.h>
53 #include <machine/intr.h>
54 #include <machine/atomic.h>
56 #include <dev/ofw/openfirm.h>
57 #include <dev/ofw/ofw_bus.h>
58 #include <dev/ofw/ofw_bus_subr.h>
60 #include <arm/ti/ti_prcm.h>
61 #include <arm/ti/ti_pruss.h>
64 #define DPRINTF(fmt, ...) do { \
65 printf("%s: ", __func__); \
66 printf(fmt, __VA_ARGS__); \
69 #define DPRINTF(fmt, ...)
72 static d_open_t ti_pruss_irq_open;
73 static d_read_t ti_pruss_irq_read;
74 static d_poll_t ti_pruss_irq_poll;
76 static device_probe_t ti_pruss_probe;
77 static device_attach_t ti_pruss_attach;
78 static device_detach_t ti_pruss_detach;
79 static void ti_pruss_intr(void *);
80 static d_open_t ti_pruss_open;
81 static d_mmap_t ti_pruss_mmap;
82 static void ti_pruss_irq_kqread_detach(struct knote *);
83 static int ti_pruss_irq_kqevent(struct knote *, long);
84 static d_kqfilter_t ti_pruss_irq_kqfilter;
85 static void ti_pruss_privdtor(void *data);
87 #define TI_PRUSS_PRU_IRQS 2
88 #define TI_PRUSS_HOST_IRQS 8
89 #define TI_PRUSS_IRQS (TI_PRUSS_HOST_IRQS+TI_PRUSS_PRU_IRQS)
90 #define TI_PRUSS_EVENTS 64
91 #define NOT_SET_STR "NONE"
92 #define TI_TS_ARRAY 16
103 uint64_t ts[TI_TS_ARRAY];
106 struct ti_pruss_irqsc
109 struct cdev *sc_pdev;
110 struct selinfo sc_selinfo;
115 struct ts_ring_buf tstamps;
118 static struct cdevsw ti_pruss_cdevirq = {
119 .d_version = D_VERSION,
120 .d_name = "ti_pruss_irq",
121 .d_open = ti_pruss_irq_open,
122 .d_read = ti_pruss_irq_read,
123 .d_poll = ti_pruss_irq_poll,
124 .d_kqfilter = ti_pruss_irq_kqfilter,
127 struct ti_pruss_softc {
129 struct resource *sc_mem_res;
130 struct resource *sc_irq_res[TI_PRUSS_HOST_IRQS];
131 void *sc_intr[TI_PRUSS_HOST_IRQS];
132 struct ti_pruss_irqsc sc_irq_devs[TI_PRUSS_IRQS];
133 bus_space_tag_t sc_bt;
134 bus_space_handle_t sc_bh;
135 struct cdev *sc_pdev;
136 struct selinfo sc_selinfo;
140 static struct cdevsw ti_pruss_cdevsw = {
141 .d_version = D_VERSION,
142 .d_name = "ti_pruss",
143 .d_open = ti_pruss_open,
144 .d_mmap = ti_pruss_mmap,
147 static device_method_t ti_pruss_methods[] = {
148 DEVMETHOD(device_probe, ti_pruss_probe),
149 DEVMETHOD(device_attach, ti_pruss_attach),
150 DEVMETHOD(device_detach, ti_pruss_detach),
155 static driver_t ti_pruss_driver = {
158 sizeof(struct ti_pruss_softc)
161 static devclass_t ti_pruss_devclass;
163 DRIVER_MODULE(ti_pruss, simplebus, ti_pruss_driver, ti_pruss_devclass, 0, 0);
164 MODULE_DEPEND(ti_pruss, ti_prcm, 1, 1, 1);
166 static struct resource_spec ti_pruss_irq_spec[] = {
167 { SYS_RES_IRQ, 0, RF_ACTIVE },
168 { SYS_RES_IRQ, 1, RF_ACTIVE },
169 { SYS_RES_IRQ, 2, RF_ACTIVE },
170 { SYS_RES_IRQ, 3, RF_ACTIVE },
171 { SYS_RES_IRQ, 4, RF_ACTIVE },
172 { SYS_RES_IRQ, 5, RF_ACTIVE },
173 { SYS_RES_IRQ, 6, RF_ACTIVE },
174 { SYS_RES_IRQ, 7, RF_ACTIVE },
177 CTASSERT(TI_PRUSS_HOST_IRQS == nitems(ti_pruss_irq_spec) - 1);
180 ti_pruss_irq_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
183 struct ti_pruss_irqsc *sc;
186 irqs = malloc(sizeof(struct ctl), M_DEVBUF, M_WAITOK);
190 irqs->cnt = sc->tstamps.ctl.cnt;
191 irqs->idx = sc->tstamps.ctl.idx;
193 return devfs_set_cdevpriv(irqs, ti_pruss_privdtor);
197 ti_pruss_privdtor(void *data)
199 free(data, M_DEVBUF);
203 ti_pruss_irq_poll(struct cdev *dev, int events, struct thread *td)
206 struct ti_pruss_irqsc *sc;
209 devfs_get_cdevpriv((void**)&irqs);
211 if (events & (POLLIN | POLLRDNORM)) {
212 if (sc->tstamps.ctl.cnt != irqs->cnt)
213 return events & (POLLIN | POLLRDNORM);
215 selrecord(td, &sc->sc_selinfo);
221 ti_pruss_irq_read(struct cdev *cdev, struct uio *uio, int ioflag)
223 const size_t ts_len = sizeof(uint64_t);
224 struct ti_pruss_irqsc* irq;
232 if (uio->uio_resid < ts_len)
235 error = devfs_get_cdevpriv((void**)&priv);
239 mtx_lock(&irq->sc_mtx);
241 if (irq->tstamps.ctl.cnt - priv->cnt > TI_TS_ARRAY)
243 priv->cnt = irq->tstamps.ctl.cnt;
244 priv->idx = irq->tstamps.ctl.idx;
245 mtx_unlock(&irq->sc_mtx);
251 level = irq->tstamps.ctl.idx - idx;
253 level += TI_TS_ARRAY;
256 if (ioflag & O_NONBLOCK) {
257 mtx_unlock(&irq->sc_mtx);
258 return (EWOULDBLOCK);
261 error = msleep(irq, &irq->sc_mtx, PCATCH | PDROP,
266 mtx_lock(&irq->sc_mtx);
270 mtx_unlock(&irq->sc_mtx);
272 error = uiomove(&irq->tstamps.ts[idx], ts_len, uio);
274 if (++idx == TI_TS_ARRAY)
278 atomic_add_32(&priv->cnt, 1);
283 static struct ti_pruss_irq_arg {
285 struct ti_pruss_softc *sc;
286 } ti_pruss_irq_args[TI_PRUSS_IRQS];
288 static __inline uint32_t
289 ti_pruss_reg_read(struct ti_pruss_softc *sc, uint32_t reg)
291 return (bus_space_read_4(sc->sc_bt, sc->sc_bh, reg));
295 ti_pruss_reg_write(struct ti_pruss_softc *sc, uint32_t reg, uint32_t val)
297 bus_space_write_4(sc->sc_bt, sc->sc_bh, reg, val);
301 ti_pruss_interrupts_clear(struct ti_pruss_softc *sc)
303 /* disable global interrupt */
304 ti_pruss_reg_write(sc, PRUSS_INTC_GER, 0 );
306 /* clear all events */
307 ti_pruss_reg_write(sc, PRUSS_INTC_SECR0, 0xFFFFFFFF);
308 ti_pruss_reg_write(sc, PRUSS_INTC_SECR1, 0xFFFFFFFF);
310 /* disable all host interrupts */
311 ti_pruss_reg_write(sc, PRUSS_INTC_HIER, 0);
315 ti_pruss_interrupts_enable(struct ti_pruss_softc *sc, int8_t irq, bool enable)
317 if (enable && ((sc->sc_irq_devs[irq].channel == -1) ||
318 (sc->sc_irq_devs[irq].event== -1)))
320 device_printf( sc->sc_pdev->si_drv1,
321 "Interrupt chain not fully configured, not possible to enable\n" );
325 sc->sc_irq_devs[irq].enable = enable;
327 if (sc->sc_irq_devs[irq].sc_pdev) {
328 destroy_dev(sc->sc_irq_devs[irq].sc_pdev);
329 sc->sc_irq_devs[irq].sc_pdev = NULL;
333 sc->sc_irq_devs[irq].sc_pdev = make_dev(&ti_pruss_cdevirq, 0, UID_ROOT, GID_WHEEL,
334 0600, "pruss%d.irq%d", device_get_unit(sc->sc_pdev->si_drv1), irq);
335 sc->sc_irq_devs[irq].sc_pdev->si_drv1 = &sc->sc_irq_devs[irq];
337 sc->sc_irq_devs[irq].tstamps.ctl.idx = 0;
340 uint32_t reg = enable ? PRUSS_INTC_HIEISR : PRUSS_INTC_HIDISR;
341 ti_pruss_reg_write(sc, reg, sc->sc_irq_devs[irq].channel);
343 reg = enable ? PRUSS_INTC_EISR : PRUSS_INTC_EICR;
344 ti_pruss_reg_write(sc, reg, sc->sc_irq_devs[irq].event );
350 ti_pruss_map_write(struct ti_pruss_softc *sc, uint32_t basereg, uint8_t index, uint8_t content)
352 const size_t regadr = basereg + index & ~0x03;
353 const size_t bitpos = (index & 0x03) * 8;
354 uint32_t rmw = ti_pruss_reg_read(sc, regadr);
355 rmw = (rmw & ~( 0xF << bitpos)) | ( (content & 0xF) << bitpos);
356 ti_pruss_reg_write(sc, regadr, rmw);
360 ti_pruss_event_map( SYSCTL_HANDLER_ARGS )
362 struct ti_pruss_softc *sc;
363 const int8_t irq = arg2;
365 char event[sizeof(NOT_SET_STR)];
369 if(sc->sc_irq_devs[irq].event == -1)
370 bcopy(NOT_SET_STR, event, sizeof(event));
372 snprintf(event, sizeof(event), "%d", sc->sc_irq_devs[irq].event);
374 err = sysctl_handle_string(oidp, event, sizeof(event), req);
378 if (req->newptr) { // write event
379 if (strcmp(NOT_SET_STR, event) == 0) {
380 ti_pruss_interrupts_enable(sc, irq, false);
381 sc->sc_irq_devs[irq].event = -1;
383 if (sc->sc_irq_devs[irq].channel == -1) {
384 device_printf( sc->sc_pdev->si_drv1,
385 "corresponding channel not configured\n");
389 const int8_t channelnr = sc->sc_irq_devs[irq].channel;
390 const int8_t eventnr = strtol( event, NULL, 10 ); // TODO: check if strol is valid
391 if (eventnr > TI_PRUSS_EVENTS || eventnr < 0) {
392 device_printf( sc->sc_pdev->si_drv1,
393 "Event number %d not valid (0 - %d)",
394 channelnr, TI_PRUSS_EVENTS -1);
398 sc->sc_irq_devs[irq].channel = channelnr;
399 sc->sc_irq_devs[irq].event = eventnr;
401 // event[nr] <= channel
402 ti_pruss_map_write(sc, PRUSS_INTC_CMR_BASE,
410 ti_pruss_channel_map(SYSCTL_HANDLER_ARGS)
412 struct ti_pruss_softc *sc;
414 char channel[sizeof(NOT_SET_STR)];
415 const int8_t irq = arg2;
419 if (sc->sc_irq_devs[irq].channel == -1)
420 bcopy(NOT_SET_STR, channel, sizeof(channel));
422 snprintf(channel, sizeof(channel), "%d", sc->sc_irq_devs[irq].channel);
424 err = sysctl_handle_string(oidp, channel, sizeof(channel), req);
428 if (req->newptr) { // write event
429 if (strcmp(NOT_SET_STR, channel) == 0) {
430 ti_pruss_interrupts_enable(sc, irq, false);
431 ti_pruss_reg_write(sc, PRUSS_INTC_HIDISR,
432 sc->sc_irq_devs[irq].channel);
433 sc->sc_irq_devs[irq].channel = -1;
435 const int8_t channelnr = strtol(channel, NULL, 10); // TODO: check if strol is valid
436 if (channelnr > TI_PRUSS_IRQS || channelnr < 0)
438 device_printf(sc->sc_pdev->si_drv1,
439 "Channel number %d not valid (0 - %d)",
440 channelnr, TI_PRUSS_IRQS-1);
444 sc->sc_irq_devs[irq].channel = channelnr;
445 sc->sc_irq_devs[irq].last = -1;
447 // channel[nr] <= irqnr
448 ti_pruss_map_write(sc, PRUSS_INTC_HMR_BASE,
457 ti_pruss_interrupt_enable(SYSCTL_HANDLER_ARGS)
459 struct ti_pruss_softc *sc;
462 const int8_t irq = arg2;
465 irqenable = sc->sc_irq_devs[arg2].enable;
467 err = sysctl_handle_bool(oidp, &irqenable, arg2, req);
471 if (req->newptr) // write enable
472 return ti_pruss_interrupts_enable(sc, irq, irqenable);
478 ti_pruss_global_interrupt_enable(SYSCTL_HANDLER_ARGS)
480 struct ti_pruss_softc *sc;
485 glob_irqen = sc->sc_glob_irqen;
487 err = sysctl_handle_bool(oidp, &glob_irqen, arg2, req);
492 sc->sc_glob_irqen = glob_irqen;
493 ti_pruss_reg_write(sc, PRUSS_INTC_GER, glob_irqen);
499 ti_pruss_probe(device_t dev)
502 if (!ofw_bus_status_okay(dev))
505 if (ofw_bus_is_compatible(dev, "ti,pruss-v1") ||
506 ofw_bus_is_compatible(dev, "ti,pruss-v2")) {
507 device_set_desc(dev, "TI Programmable Realtime Unit Subsystem");
508 return (BUS_PROBE_DEFAULT);
515 ti_pruss_attach(device_t dev)
517 struct ti_pruss_softc *sc;
520 if (ti_prcm_clk_enable(PRUSS_CLK) != 0) {
521 device_printf(dev, "could not enable PRUSS clock\n");
524 sc = device_get_softc(dev);
526 mtx_init(&sc->sc_mtx, "TI PRUSS", NULL, MTX_DEF);
527 sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
529 if (sc->sc_mem_res == NULL) {
530 device_printf(dev, "could not allocate memory resource\n");
534 struct sysctl_ctx_list *clist = device_get_sysctl_ctx(dev);
538 struct sysctl_oid *poid;
539 poid = device_get_sysctl_tree( dev );
543 sc->sc_glob_irqen = false;
544 struct sysctl_oid *irq_root = SYSCTL_ADD_NODE(clist, SYSCTL_CHILDREN(poid),
545 OID_AUTO, "irq", CTLFLAG_RD, 0,
546 "PRUSS Host Interrupts");
547 SYSCTL_ADD_PROC(clist, SYSCTL_CHILDREN(poid), OID_AUTO,
548 "global_interrupt_enable", CTLFLAG_RW | CTLTYPE_U8,
549 sc, 0, ti_pruss_global_interrupt_enable,
550 "CU", "Global interrupt enable");
552 sc->sc_bt = rman_get_bustag(sc->sc_mem_res);
553 sc->sc_bh = rman_get_bushandle(sc->sc_mem_res);
554 if (bus_alloc_resources(dev, ti_pruss_irq_spec, sc->sc_irq_res) != 0) {
555 device_printf(dev, "could not allocate interrupt resource\n");
556 ti_pruss_detach(dev);
560 ti_pruss_interrupts_clear(sc);
562 for (i = 0; i < TI_PRUSS_IRQS; i++) {
564 snprintf(name, sizeof(name), "%d", i);
566 struct sysctl_oid *irq_nodes = SYSCTL_ADD_NODE(clist, SYSCTL_CHILDREN(irq_root),
567 OID_AUTO, name, CTLFLAG_RD, 0,
569 SYSCTL_ADD_PROC(clist, SYSCTL_CHILDREN(irq_nodes), OID_AUTO,
570 "channel", CTLFLAG_RW | CTLTYPE_STRING, sc, i, ti_pruss_channel_map,
571 "A", "Channel attached to this irq");
572 SYSCTL_ADD_PROC(clist, SYSCTL_CHILDREN(irq_nodes), OID_AUTO,
573 "event", CTLFLAG_RW | CTLTYPE_STRING, sc, i, ti_pruss_event_map,
574 "A", "Event attached to this irq");
575 SYSCTL_ADD_PROC(clist, SYSCTL_CHILDREN(irq_nodes), OID_AUTO,
576 "enable", CTLFLAG_RW | CTLTYPE_U8, sc, i, ti_pruss_interrupt_enable,
577 "CU", "Enable/Disable interrupt");
579 sc->sc_irq_devs[i].event = -1;
580 sc->sc_irq_devs[i].channel = -1;
581 sc->sc_irq_devs[i].tstamps.ctl.idx = 0;
583 if (i < TI_PRUSS_HOST_IRQS) {
584 ti_pruss_irq_args[i].irq = i;
585 ti_pruss_irq_args[i].sc = sc;
586 if (bus_setup_intr(dev, sc->sc_irq_res[i],
587 INTR_MPSAFE | INTR_TYPE_MISC,
588 NULL, ti_pruss_intr, &ti_pruss_irq_args[i],
589 &sc->sc_intr[i]) != 0) {
591 "unable to setup the interrupt handler\n");
592 ti_pruss_detach(dev);
596 mtx_init(&sc->sc_irq_devs[i].sc_mtx, "TI PRUSS IRQ", NULL, MTX_DEF);
597 knlist_init_mtx(&sc->sc_irq_devs[i].sc_selinfo.si_note, &sc->sc_irq_devs[i].sc_mtx);
601 if (ti_pruss_reg_read(sc, PRUSS_AM33XX_INTC) == PRUSS_AM33XX_REV)
602 device_printf(dev, "AM33xx PRU-ICSS\n");
604 sc->sc_pdev = make_dev(&ti_pruss_cdevsw, 0, UID_ROOT, GID_WHEEL,
605 0600, "pruss%d", device_get_unit(dev));
606 sc->sc_pdev->si_drv1 = dev;
608 /* Acc. to datasheet always write 1 to polarity registers */
609 ti_pruss_reg_write(sc, PRUSS_INTC_SIPR0, 0xFFFFFFFF);
610 ti_pruss_reg_write(sc, PRUSS_INTC_SIPR1, 0xFFFFFFFF);
612 /* Acc. to datasheet always write 0 to event type registers */
613 ti_pruss_reg_write(sc, PRUSS_INTC_SITR0, 0);
614 ti_pruss_reg_write(sc, PRUSS_INTC_SITR1, 0);
620 ti_pruss_detach(device_t dev)
622 struct ti_pruss_softc *sc = device_get_softc(dev);
624 ti_pruss_interrupts_clear(sc);
626 for (int i = 0; i < TI_PRUSS_HOST_IRQS; i++) {
627 ti_pruss_interrupts_enable( sc, i, false );
630 bus_teardown_intr(dev, sc->sc_irq_res[i], sc->sc_intr[i]);
631 if (sc->sc_irq_res[i])
632 bus_release_resource(dev, SYS_RES_IRQ,
633 rman_get_rid(sc->sc_irq_res[i]),
635 knlist_clear(&sc->sc_irq_devs[i].sc_selinfo.si_note, 0);
636 mtx_lock(&sc->sc_irq_devs[i].sc_mtx);
637 if (!knlist_empty(&sc->sc_irq_devs[i].sc_selinfo.si_note))
638 printf("IRQ %d KQueue not empty!\n", i );
639 mtx_unlock(&sc->sc_irq_devs[i].sc_mtx);
640 knlist_destroy(&sc->sc_irq_devs[i].sc_selinfo.si_note);
641 mtx_destroy(&sc->sc_irq_devs[i].sc_mtx);
644 mtx_destroy(&sc->sc_mtx);
646 bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(sc->sc_mem_res),
649 destroy_dev(sc->sc_pdev);
655 ti_pruss_intr(void *arg)
658 struct ti_pruss_irq_arg *iap = arg;
659 struct ti_pruss_softc *sc = iap->sc;
661 * Interrupts pr1_host_intr[0:7] are mapped to
662 * Host-2 to Host-9 of PRU-ICSS IRQ-controller.
664 const int pru_int = iap->irq + TI_PRUSS_PRU_IRQS;
665 const int pru_int_mask = (1 << pru_int);
666 const int pru_channel = sc->sc_irq_devs[pru_int].channel;
667 const int pru_event = sc->sc_irq_devs[pru_channel].event;
669 val = ti_pruss_reg_read(sc, PRUSS_INTC_HIER);
670 if (!(val & pru_int_mask))
673 ti_pruss_reg_write(sc, PRUSS_INTC_HIDISR, pru_int);
674 ti_pruss_reg_write(sc, PRUSS_INTC_SICR, pru_event);
675 ti_pruss_reg_write(sc, PRUSS_INTC_HIEISR, pru_int);
677 struct ti_pruss_irqsc* irq = &sc->sc_irq_devs[pru_channel];
678 size_t wr = irq->tstamps.ctl.idx;
682 irq->tstamps.ts[wr] = ts.tv_sec * 1000000000 + ts.tv_nsec;
684 if (++wr == TI_TS_ARRAY)
686 atomic_add_32(&irq->tstamps.ctl.cnt, 1);
688 irq->tstamps.ctl.idx = wr;
690 KNOTE_UNLOCKED(&irq->sc_selinfo.si_note, pru_int);
692 selwakeup(&irq->sc_selinfo);
696 ti_pruss_open(struct cdev *cdev __unused, int oflags __unused,
697 int devtype __unused, struct thread *td __unused)
703 ti_pruss_mmap(struct cdev *cdev, vm_ooffset_t offset, vm_paddr_t *paddr,
704 int nprot, vm_memattr_t *memattr)
706 device_t dev = cdev->si_drv1;
707 struct ti_pruss_softc *sc = device_get_softc(dev);
709 if (offset >= rman_get_size(sc->sc_mem_res))
711 *paddr = rman_get_start(sc->sc_mem_res) + offset;
712 *memattr = VM_MEMATTR_UNCACHEABLE;
717 static struct filterops ti_pruss_kq_read = {
719 .f_detach = ti_pruss_irq_kqread_detach,
720 .f_event = ti_pruss_irq_kqevent,
724 ti_pruss_irq_kqread_detach(struct knote *kn)
726 struct ti_pruss_irqsc *sc = kn->kn_hook;
728 knlist_remove(&sc->sc_selinfo.si_note, kn, 0);
732 ti_pruss_irq_kqevent(struct knote *kn, long hint)
734 struct ti_pruss_irqsc* irq_sc;
737 irq_sc = kn->kn_hook;
740 kn->kn_data = hint - 2;
742 if (hint > 0 || irq_sc->last > 0)
753 ti_pruss_irq_kqfilter(struct cdev *cdev, struct knote *kn)
755 struct ti_pruss_irqsc *sc = cdev->si_drv1;
757 switch (kn->kn_filter) {
760 kn->kn_fop = &ti_pruss_kq_read;
761 knlist_add(&sc->sc_selinfo.si_note, kn, 0);