17315b7b4SJens Wiklander /* 27315b7b4SJens Wiklander * Copyright (c) 2016, Linaro Limited 37315b7b4SJens Wiklander * All rights reserved. 47315b7b4SJens Wiklander * 57315b7b4SJens Wiklander * Redistribution and use in source and binary forms, with or without 67315b7b4SJens Wiklander * modification, are permitted provided that the following conditions are met: 77315b7b4SJens Wiklander * 87315b7b4SJens Wiklander * 1. Redistributions of source code must retain the above copyright notice, 97315b7b4SJens Wiklander * this list of conditions and the following disclaimer. 107315b7b4SJens Wiklander * 117315b7b4SJens Wiklander * 2. Redistributions in binary form must reproduce the above copyright notice, 127315b7b4SJens Wiklander * this list of conditions and the following disclaimer in the documentation 137315b7b4SJens Wiklander * and/or other materials provided with the distribution. 147315b7b4SJens Wiklander * 157315b7b4SJens Wiklander * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 167315b7b4SJens Wiklander * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 177315b7b4SJens Wiklander * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 187315b7b4SJens Wiklander * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 197315b7b4SJens Wiklander * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 207315b7b4SJens Wiklander * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 217315b7b4SJens Wiklander * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 227315b7b4SJens Wiklander * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 237315b7b4SJens Wiklander * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 247315b7b4SJens Wiklander * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 257315b7b4SJens Wiklander * POSSIBILITY OF SUCH DAMAGE. 267315b7b4SJens Wiklander */ 277315b7b4SJens Wiklander #ifndef __KERNEL_INTERRUPT_H 287315b7b4SJens Wiklander #define __KERNEL_INTERRUPT_H 297315b7b4SJens Wiklander 307315b7b4SJens Wiklander #include <types_ext.h> 317315b7b4SJens Wiklander #include <sys/queue.h> 327315b7b4SJens Wiklander 337315b7b4SJens Wiklander #define ITRF_TRIGGER_LEVEL (1 << 0) 347315b7b4SJens Wiklander 357315b7b4SJens Wiklander struct itr_chip { 367315b7b4SJens Wiklander const struct itr_ops *ops; 377315b7b4SJens Wiklander }; 387315b7b4SJens Wiklander 397315b7b4SJens Wiklander struct itr_ops { 407315b7b4SJens Wiklander void (*add)(struct itr_chip *chip, size_t it, uint32_t flags); 417315b7b4SJens Wiklander void (*enable)(struct itr_chip *chip, size_t it); 427315b7b4SJens Wiklander void (*disable)(struct itr_chip *chip, size_t it); 43*26ed70ecSGuanchao Liang void (*raise_pi)(struct itr_chip *chip, size_t it); 44*26ed70ecSGuanchao Liang void (*raise_sgi)(struct itr_chip *chip, size_t it, 45*26ed70ecSGuanchao Liang uint8_t cpu_mask); 46*26ed70ecSGuanchao Liang void (*set_affinity)(struct itr_chip *chip, size_t it, 47*26ed70ecSGuanchao Liang uint8_t cpu_mask); 487315b7b4SJens Wiklander }; 497315b7b4SJens Wiklander 507315b7b4SJens Wiklander enum itr_return { 517315b7b4SJens Wiklander ITRR_NONE, 527315b7b4SJens Wiklander ITRR_HANDLED, 537315b7b4SJens Wiklander }; 547315b7b4SJens Wiklander 557315b7b4SJens Wiklander struct itr_handler { 567315b7b4SJens Wiklander size_t it; 577315b7b4SJens Wiklander uint32_t flags; 587315b7b4SJens Wiklander enum itr_return (*handler)(struct itr_handler *h); 597315b7b4SJens Wiklander void *data; 607315b7b4SJens Wiklander SLIST_ENTRY(itr_handler) link; 617315b7b4SJens Wiklander }; 627315b7b4SJens Wiklander 637315b7b4SJens Wiklander void itr_init(struct itr_chip *data); 647315b7b4SJens Wiklander void itr_handle(size_t it); 657315b7b4SJens Wiklander 667315b7b4SJens Wiklander void itr_add(struct itr_handler *handler); 67*26ed70ecSGuanchao Liang void itr_enable(size_t it); 68*26ed70ecSGuanchao Liang void itr_disable(size_t it); 69*26ed70ecSGuanchao Liang /* raise the Peripheral Interrupt corresponding to the interrupt ID */ 70*26ed70ecSGuanchao Liang void itr_raise_pi(size_t it); 71*26ed70ecSGuanchao Liang /* 72*26ed70ecSGuanchao Liang * raise the Software Generated Interrupt corresponding to the interrupt ID, 73*26ed70ecSGuanchao Liang * the cpu_mask represents which cpu interface to forward. 74*26ed70ecSGuanchao Liang */ 75*26ed70ecSGuanchao Liang void itr_raise_sgi(size_t it, uint8_t cpu_mask); 76*26ed70ecSGuanchao Liang /* 77*26ed70ecSGuanchao Liang * let corresponding interrupt forward to the cpu interface 78*26ed70ecSGuanchao Liang * according to the cpu_mask. 79*26ed70ecSGuanchao Liang */ 80*26ed70ecSGuanchao Liang void itr_set_affinity(size_t it, uint8_t cpu_mask); 817315b7b4SJens Wiklander 827315b7b4SJens Wiklander #endif /*__KERNEL_INTERRUPT_H*/ 83