Soby Mathew | 50f6fe4 | 2016-02-01 17:59:22 +0000 | [diff] [blame] | 1 | /* |
Roberto Vargas | 0571270 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 2 | * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. |
Soby Mathew | 50f6fe4 | 2016-02-01 17:59:22 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Soby Mathew | 50f6fe4 | 2016-02-01 17:59:22 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef GIC_COMMON_PRIVATE_H_ |
| 8 | #define GIC_COMMON_PRIVATE_H_ |
| 9 | |
| 10 | #include <gic_common.h> |
| 11 | #include <mmio.h> |
| 12 | #include <stdint.h> |
| 13 | |
| 14 | /******************************************************************************* |
| 15 | * GIC Distributor interface register accessors that are common to GICv3 & GICv2 |
| 16 | ******************************************************************************/ |
| 17 | static inline unsigned int gicd_read_ctlr(uintptr_t base) |
| 18 | { |
| 19 | return mmio_read_32(base + GICD_CTLR); |
| 20 | } |
| 21 | |
| 22 | static inline unsigned int gicd_read_typer(uintptr_t base) |
| 23 | { |
| 24 | return mmio_read_32(base + GICD_TYPER); |
| 25 | } |
| 26 | |
| 27 | static inline unsigned int gicd_read_iidr(uintptr_t base) |
| 28 | { |
| 29 | return mmio_read_32(base + GICD_IIDR); |
| 30 | } |
| 31 | |
| 32 | static inline void gicd_write_ctlr(uintptr_t base, unsigned int val) |
| 33 | { |
| 34 | mmio_write_32(base + GICD_CTLR, val); |
| 35 | } |
| 36 | |
| 37 | /******************************************************************************* |
| 38 | * GIC Distributor function prototypes for accessing entire registers. |
| 39 | * Note: The raw register values correspond to multiple interrupt IDs and |
| 40 | * the number of interrupt IDs involved depends on the register accessed. |
| 41 | ******************************************************************************/ |
| 42 | unsigned int gicd_read_igroupr(uintptr_t base, unsigned int id); |
| 43 | unsigned int gicd_read_isenabler(uintptr_t base, unsigned int id); |
| 44 | unsigned int gicd_read_icenabler(uintptr_t base, unsigned int id); |
| 45 | unsigned int gicd_read_ispendr(uintptr_t base, unsigned int id); |
| 46 | unsigned int gicd_read_icpendr(uintptr_t base, unsigned int id); |
| 47 | unsigned int gicd_read_isactiver(uintptr_t base, unsigned int id); |
| 48 | unsigned int gicd_read_icactiver(uintptr_t base, unsigned int id); |
| 49 | unsigned int gicd_read_ipriorityr(uintptr_t base, unsigned int id); |
| 50 | unsigned int gicd_read_icfgr(uintptr_t base, unsigned int id); |
| 51 | unsigned int gicd_read_nsacr(uintptr_t base, unsigned int id); |
Roberto Vargas | 0571270 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 52 | unsigned int gicd_read_spendsgir(uintptr_t base, unsigned int id); |
| 53 | unsigned int gicd_read_cpendsgir(uintptr_t base, unsigned int id); |
| 54 | unsigned int gicd_read_itargetsr(uintptr_t base, unsigned int id); |
Soby Mathew | 50f6fe4 | 2016-02-01 17:59:22 +0000 | [diff] [blame] | 55 | void gicd_write_igroupr(uintptr_t base, unsigned int id, unsigned int val); |
| 56 | void gicd_write_isenabler(uintptr_t base, unsigned int id, unsigned int val); |
| 57 | void gicd_write_icenabler(uintptr_t base, unsigned int id, unsigned int val); |
| 58 | void gicd_write_ispendr(uintptr_t base, unsigned int id, unsigned int val); |
| 59 | void gicd_write_icpendr(uintptr_t base, unsigned int id, unsigned int val); |
| 60 | void gicd_write_isactiver(uintptr_t base, unsigned int id, unsigned int val); |
| 61 | void gicd_write_icactiver(uintptr_t base, unsigned int id, unsigned int val); |
| 62 | void gicd_write_ipriorityr(uintptr_t base, unsigned int id, unsigned int val); |
| 63 | void gicd_write_icfgr(uintptr_t base, unsigned int id, unsigned int val); |
| 64 | void gicd_write_nsacr(uintptr_t base, unsigned int id, unsigned int val); |
Roberto Vargas | 0571270 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 65 | void gicd_write_spendsgir(uintptr_t base, unsigned int id, unsigned int val); |
| 66 | void gicd_write_cpendsgir(uintptr_t base, unsigned int id, unsigned int val); |
| 67 | void gicd_write_itargetsr(uintptr_t base, unsigned int id, unsigned int val); |
Soby Mathew | 50f6fe4 | 2016-02-01 17:59:22 +0000 | [diff] [blame] | 68 | |
| 69 | /******************************************************************************* |
| 70 | * GIC Distributor function prototypes for accessing the GIC registers |
| 71 | * corresponding to a single interrupt ID. These functions use bitwise |
| 72 | * operations or appropriate register accesses to modify or return |
| 73 | * the bit-field corresponding the single interrupt ID. |
| 74 | ******************************************************************************/ |
| 75 | unsigned int gicd_get_igroupr(uintptr_t base, unsigned int id); |
| 76 | void gicd_set_igroupr(uintptr_t base, unsigned int id); |
| 77 | void gicd_clr_igroupr(uintptr_t base, unsigned int id); |
| 78 | void gicd_set_isenabler(uintptr_t base, unsigned int id); |
| 79 | void gicd_set_icenabler(uintptr_t base, unsigned int id); |
| 80 | void gicd_set_ispendr(uintptr_t base, unsigned int id); |
| 81 | void gicd_set_icpendr(uintptr_t base, unsigned int id); |
Jeenu Viswambharan | 24e7029 | 2017-09-22 08:32:09 +0100 | [diff] [blame] | 82 | unsigned int gicd_get_isactiver(uintptr_t base, unsigned int id); |
Soby Mathew | 50f6fe4 | 2016-02-01 17:59:22 +0000 | [diff] [blame] | 83 | void gicd_set_isactiver(uintptr_t base, unsigned int id); |
| 84 | void gicd_set_icactiver(uintptr_t base, unsigned int id); |
| 85 | void gicd_set_ipriorityr(uintptr_t base, unsigned int id, unsigned int pri); |
Jeenu Viswambharan | 4684bce | 2017-09-22 08:32:09 +0100 | [diff] [blame] | 86 | void gicd_set_icfgr(uintptr_t base, unsigned int id, unsigned int cfg); |
Soby Mathew | 50f6fe4 | 2016-02-01 17:59:22 +0000 | [diff] [blame] | 87 | |
| 88 | #endif /* GIC_COMMON_PRIVATE_H_ */ |