Soby Mathew | 50f6fe4 | 2016-02-01 17:59:22 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are met: |
| 6 | * |
| 7 | * Redistributions of source code must retain the above copyright notice, this |
| 8 | * list of conditions and the following disclaimer. |
| 9 | * |
| 10 | * Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * Neither the name of ARM nor the names of its contributors may be used |
| 15 | * to endorse or promote products derived from this software without specific |
| 16 | * prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 | * POSSIBILITY OF SUCH DAMAGE. |
| 29 | */ |
| 30 | |
| 31 | #ifndef GIC_COMMON_PRIVATE_H_ |
| 32 | #define GIC_COMMON_PRIVATE_H_ |
| 33 | |
| 34 | #include <gic_common.h> |
| 35 | #include <mmio.h> |
| 36 | #include <stdint.h> |
| 37 | |
| 38 | /******************************************************************************* |
| 39 | * GIC Distributor interface register accessors that are common to GICv3 & GICv2 |
| 40 | ******************************************************************************/ |
| 41 | static inline unsigned int gicd_read_ctlr(uintptr_t base) |
| 42 | { |
| 43 | return mmio_read_32(base + GICD_CTLR); |
| 44 | } |
| 45 | |
| 46 | static inline unsigned int gicd_read_typer(uintptr_t base) |
| 47 | { |
| 48 | return mmio_read_32(base + GICD_TYPER); |
| 49 | } |
| 50 | |
| 51 | static inline unsigned int gicd_read_iidr(uintptr_t base) |
| 52 | { |
| 53 | return mmio_read_32(base + GICD_IIDR); |
| 54 | } |
| 55 | |
| 56 | static inline void gicd_write_ctlr(uintptr_t base, unsigned int val) |
| 57 | { |
| 58 | mmio_write_32(base + GICD_CTLR, val); |
| 59 | } |
| 60 | |
| 61 | /******************************************************************************* |
| 62 | * GIC Distributor function prototypes for accessing entire registers. |
| 63 | * Note: The raw register values correspond to multiple interrupt IDs and |
| 64 | * the number of interrupt IDs involved depends on the register accessed. |
| 65 | ******************************************************************************/ |
| 66 | unsigned int gicd_read_igroupr(uintptr_t base, unsigned int id); |
| 67 | unsigned int gicd_read_isenabler(uintptr_t base, unsigned int id); |
| 68 | unsigned int gicd_read_icenabler(uintptr_t base, unsigned int id); |
| 69 | unsigned int gicd_read_ispendr(uintptr_t base, unsigned int id); |
| 70 | unsigned int gicd_read_icpendr(uintptr_t base, unsigned int id); |
| 71 | unsigned int gicd_read_isactiver(uintptr_t base, unsigned int id); |
| 72 | unsigned int gicd_read_icactiver(uintptr_t base, unsigned int id); |
| 73 | unsigned int gicd_read_ipriorityr(uintptr_t base, unsigned int id); |
| 74 | unsigned int gicd_read_icfgr(uintptr_t base, unsigned int id); |
| 75 | unsigned int gicd_read_nsacr(uintptr_t base, unsigned int id); |
| 76 | void gicd_write_igroupr(uintptr_t base, unsigned int id, unsigned int val); |
| 77 | void gicd_write_isenabler(uintptr_t base, unsigned int id, unsigned int val); |
| 78 | void gicd_write_icenabler(uintptr_t base, unsigned int id, unsigned int val); |
| 79 | void gicd_write_ispendr(uintptr_t base, unsigned int id, unsigned int val); |
| 80 | void gicd_write_icpendr(uintptr_t base, unsigned int id, unsigned int val); |
| 81 | void gicd_write_isactiver(uintptr_t base, unsigned int id, unsigned int val); |
| 82 | void gicd_write_icactiver(uintptr_t base, unsigned int id, unsigned int val); |
| 83 | void gicd_write_ipriorityr(uintptr_t base, unsigned int id, unsigned int val); |
| 84 | void gicd_write_icfgr(uintptr_t base, unsigned int id, unsigned int val); |
| 85 | void gicd_write_nsacr(uintptr_t base, unsigned int id, unsigned int val); |
| 86 | |
| 87 | /******************************************************************************* |
| 88 | * GIC Distributor function prototypes for accessing the GIC registers |
| 89 | * corresponding to a single interrupt ID. These functions use bitwise |
| 90 | * operations or appropriate register accesses to modify or return |
| 91 | * the bit-field corresponding the single interrupt ID. |
| 92 | ******************************************************************************/ |
| 93 | unsigned int gicd_get_igroupr(uintptr_t base, unsigned int id); |
| 94 | void gicd_set_igroupr(uintptr_t base, unsigned int id); |
| 95 | void gicd_clr_igroupr(uintptr_t base, unsigned int id); |
| 96 | void gicd_set_isenabler(uintptr_t base, unsigned int id); |
| 97 | void gicd_set_icenabler(uintptr_t base, unsigned int id); |
| 98 | void gicd_set_ispendr(uintptr_t base, unsigned int id); |
| 99 | void gicd_set_icpendr(uintptr_t base, unsigned int id); |
| 100 | void gicd_set_isactiver(uintptr_t base, unsigned int id); |
| 101 | void gicd_set_icactiver(uintptr_t base, unsigned int id); |
| 102 | void gicd_set_ipriorityr(uintptr_t base, unsigned int id, unsigned int pri); |
| 103 | |
| 104 | #endif /* GIC_COMMON_PRIVATE_H_ */ |