1 /* ---------------------------------------------------------------------------- 2 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 15 * Description: LingLong Interrupt Controller Driver Header 16 * Author: Huawei LiteOS Team 17 * Create: 2021-11-30 18 * Redistribution and use in source and binary forms, with or without modification, 19 * are permitted provided that the following conditions are met: 20 * 1. Redistributions of source code must retain the above copyright notice, this list of 21 * conditions and the following disclaimer. 22 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 23 * of conditions and the following disclaimer in the documentation and/or other materials 24 * provided with the distribution. 25 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 26 * to endorse or promote products derived from this software without specific prior written 27 * permission. 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 30 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 31 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 32 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 35 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 36 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 37 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 38 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 * --------------------------------------------------------------------------- */ 40 41 #ifndef _LINGLONG_IC_H 42 #define _LINGLONG_IC_H 43 44 #include "los_typedef.h" 45 #include "arch/barrier.h" 46 #include "arch/regs.h" 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif /* __cplusplus */ 51 52 #define LLIC_INT_ID_NMI 0 53 #define LLIC_INTERNAL_PI_MIN 1 54 #define LLIC_INTERNAL_PI_MAX 31 55 56 #define LLIC_INTERNAL_SWI_MIN 32 57 #define LLIC_INTERNAL_SWI_MAX 63 58 59 #define LLIC_EXTERNAL_PI_MIN 64 60 #define LLIC_EXTERNAL_PI_MAX 127 61 62 #define LLIC_EXTERNAL_SI_MIN 64 63 #define LLIC_EXTERNAL_SI_MAX 191 64 65 #ifdef LOSCFG_KERNEL_SMP 66 #define LLIC_INT_ID_PRIV_MAX LLIC_INTERNAL_SWI_MAX 67 #else 68 #define LLIC_INT_ID_PRIV_MAX LLIC_EXTERNAL_PI_MAX 69 #endif 70 71 /************************** PRIV INT ID **************************/ 72 #define LLIC_THREAD_SSP_OOR_INT_ID 1 73 #define LLIC_THREAD_TIMER0_INT_ID 14 74 #define LLIC_OCD_OV_INT_ID 22 75 76 /************************** ICU REGS **************************/ 77 78 #define ICU_BASE (DSS_PRIVATE_REGS_BASE + 0x4000) 79 80 #define ICU_SET_BASE (ICU_BASE + 0x00) 81 #define ICU_MASK_BASE (ICU_BASE + 0x40) 82 #define ICU_STATMASK_BASE (ICU_BASE + 0x80) 83 #define ICU_CLEAR_BASE (ICU_BASE + 0xC0) 84 #define ICU_PRIOLEVEL_BASE (ICU_BASE + 0x100) 85 86 #define ICU_SET(n) (ICU_SET_BASE + ((n) * 4)) 87 #define ICU_MASK(n) (ICU_MASK_BASE + ((n) * 4)) 88 #define ICU_STATMASK(n) (ICU_STATMASK_BASE + ((n) * 4)) 89 #define ICU_CLEAR(n) (ICU_CLEAR_BASE + ((n) * 4)) 90 #define ICU_PRIOLEVEL(n) (ICU_PRIOLEVEL_BASE + ((n) * 4)) 91 92 #define ICU_SET_N(id) ((id) >> 5) 93 #define ICU_MASK_N(id) ((id) >> 5) 94 #define ICU_STATMASK_N(id) ((id) >> 5) 95 #define ICU_CLEAR_N(id) ((id) >> 5) 96 #define ICU_PRIOLEVEL_N(id) ((id) >> 2) 97 98 /************************** ICD REGS **************************/ 99 100 #ifdef LOSCFG_KERNEL_SMP 101 #define ICD_BASE (MPSCU_MP_REG_BASE + 0x54000) 102 103 #define ICD_SET_BASE (ICD_BASE + 0x00) 104 #define ICD_MASK_BASE (ICD_BASE + 0x80) 105 #define ICD_STATMASK_BASE (ICD_BASE + 0x100) 106 #define ICD_SW_INT_GEN_BASE (ICD_BASE + 0x280) 107 #define ICD_LOCK_CLEAR_BASE (ICD_BASE + 0x300) 108 #define ICD_PRIOLEVEL_BASE (ICD_BASE + 0x1300) 109 #define ICD_SEMAPHORE_BASE (ICD_BASE + 0x1700) 110 #define ICD_TARGET_BASE (ICD_BASE + 0x1780) 111 112 113 #define ICD_SET(n) (ICD_SET_BASE + ((n) * 4)) 114 #define ICD_MASK(n) (ICD_MASK_BASE + ((n) * 4)) 115 #define ICD_STATMASK(n) (ICD_STATMASK_BASE + ((n) * 4)) 116 #define ICD_SW_INT_GEN (ICD_SW_INT_GEN_BASE) 117 #define ICD_LOCK_CLEAR(n) (ICD_LOCK_CLEAR_BASE + ((n) * 4)) 118 #define ICD_PRIOLEVEL(n) (ICD_PRIOLEVEL_BASE + ((n) * 4)) 119 #define ICD_SEMAPHORE(n) (ICD_SEMAPHORE_BASE + ((n) * 4)) 120 #define ICD_TARGET(n) (ICD_TARGET_BASE + ((n) * 4)) 121 122 #define ICD_SET_N(id) (((id) >> 5) - 2) 123 #define ICD_MASK_N(id) (((id) >> 5) - 2) 124 #define ICD_STATMASK_N(id) (((id) >> 5) - 2) 125 #define ICD_LOCK_CLEAR_N(id) ((id) - 64) 126 #define ICD_PRIOLEVEL_N(id) (((id) >> 2) - 16) 127 #define ICD_TARGET_N(id) (((id) >> 1) - 32) 128 129 #endif 130 131 #define LLIC_REG_WIDTH 32 132 #define LLIC_PER_PRIO_WIDTH 8 133 #define LLIC_PER_PRIO_MASK ((0x01U << LLIC_PER_PRIO_WIDTH) - 1) 134 #define LLIC_PRIO_NUM_PER_REG (LLIC_REG_WIDTH / LLIC_PER_PRIO_WIDTH) 135 136 #define ICD_SW_GEN_TARGET_POS 16 137 #define ICD_TARGET_OFFSET(id) (((id) % 2) * 16) 138 #define ICD_TARGET_MASK 0x0000000F 139 #define ICU_CLEAR_ALL_MASK 0xFFFFFFFF 140 141 #if (LOSCFG_HWI_PRIO_LIMIT > 15) 142 #error "LOSCFG_HWI_PRIO_LIMIT config error!" 143 #endif 144 145 #ifdef LOSCFG_KERNEL_SMP 146 #if (LOSCFG_PLATFORM_HWI_LIMIT > (LLIC_EXTERNAL_SI_MAX + 1)) 147 #error "LOSCFG_PLATFORM_HWI_LIMIT config error!" 148 #endif 149 #else 150 #if (LOSCFG_PLATFORM_HWI_LIMIT > (LLIC_EXTERNAL_PI_MAX + 1)) 151 #error "LOSCFG_PLATFORM_HWI_LIMIT config error!" 152 #endif 153 #endif 154 155 #ifdef __cplusplus 156 } 157 #endif /* __cplusplus */ 158 159 #endif 160