1 /* 2 * Arm SCP/MCP Software 3 * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 * 7 * Description: 8 * Application Processor address remap module for SGI/RD platforms. 9 */ 10 11 #ifndef MOD_APREMAP_H 12 #define MOD_APREMAP_H 13 14 #include <fwk_macros.h> 15 16 #include <stdint.h> 17 18 /*! 19 * \addtogroup GroupModules Modules 20 * \{ 21 */ 22 23 /*! 24 * \defgroup GroupApRemap AP Remap 25 * 26 * \brief HAL Module used to remap the Application Processor's address space to 27 * MSCP's address space. 28 * 29 * \details This module uses the AP remap address translation registers to remap 30 * the AP address space to MSCP address space including mapping the CMN 31 * configuration region in AP address space to MSCP address space. 32 * \{ 33 */ 34 35 /*! 36 * \brief AP remap register 37 */ 38 struct mod_apremap_reg { 39 /*! Address Translation register for access AP address space. */ 40 FWK_RW uint32_t ADDR_TRANS; 41 /*! Address Translation register for access debug components. */ 42 FWK_RW uint32_t DBG_ADDR_TRANS; 43 }; 44 45 /*! 46 * \brief Module configuration. 47 */ 48 struct mod_apremap_config { 49 /*! Base address of the address translation registers. */ 50 uintptr_t base; 51 }; 52 53 /*! 54 * \brief API to read/write the AP memory space. 55 */ 56 struct mod_apremap_rw_api { 57 /*! 58 * \brief Read a byte from Application Processor's address 59 * 60 * \param addr Address of the AP address space 61 * 62 * \return Byte value from the AP address 63 */ 64 uint8_t (*mmio_ap_mem_read_8)(uint64_t addr); 65 66 /*! 67 * \brief Read a halfword from Application Processor's address 68 * 69 * \param addr Address of the AP address space 70 * 71 * \return Halfword value from the AP address 72 */ 73 uint16_t (*mmio_ap_mem_read_16)(uint64_t addr); 74 75 /*! 76 * \brief Read a word from Application Processor's address 77 * 78 * \param addr Address of the AP address space 79 * 80 * \return Word value from the AP address 81 */ 82 uint32_t (*mmio_ap_mem_read_32)(uint64_t addr); 83 84 /*! 85 * \brief Read doubleword from Application Processor's address 86 * 87 * \param addr Address of the AP address space 88 * 89 * \return Doubleword value from the AP address 90 */ 91 uint64_t (*mmio_ap_mem_read_64)(uint64_t addr); 92 93 /*! 94 * \brief Write a byte to Application Processor's address 95 * 96 * \param addr Address of the AP address space 97 * \param value Byte value to be written 98 */ 99 void (*mmio_ap_mem_write_8)(uint64_t addr, uint8_t value); 100 101 /*! 102 * \brief Write a halfword to Application Processor's address 103 * 104 * \param addr Address of the AP address space 105 * \param value Halfword value to be written 106 */ 107 void (*mmio_ap_mem_write_16)(uint64_t addr, uint16_t value); 108 109 /*! 110 * \brief Write a word to Application Processor's address 111 * 112 * \param addr Address of the AP address space 113 * \param value Word value to be written 114 */ 115 void (*mmio_ap_mem_write_32)(uint64_t addr, uint32_t value); 116 117 /*! 118 * \brief Write doubleword to Application Processor's address 119 * 120 * \param addr Address of the AP address space 121 * \param value Doubleword value to be written 122 */ 123 void (*mmio_ap_mem_write_64)(uint64_t addr, uint64_t value); 124 }; 125 126 /*! 127 * \brief API to enable/disable the CMN address translation. 128 */ 129 struct mod_apremap_cmn_atrans_api { 130 /*! 131 * \brief API to enable CMN address translation 132 * 133 * \details Enables CMN Address Translation to translate MSCP address 134 * `0x6000_0000 - 0x9FFF_FFFFF` to `(4TB * CHIPID) + (CMN register offset)` 135 * 136 * \retval ::FWK_SUCCESS Operation succeeded. 137 */ 138 int (*enable)(void); 139 140 /*! 141 * \brief API to disable CMN address translation 142 * 143 * \retval ::FWK_SUCCESS Operation succeeded. 144 */ 145 int (*disable)(void); 146 }; 147 148 /*! 149 * \brief Module API indicies. 150 */ 151 enum mod_apremap_api_idx { 152 MOD_APREMAP_API_IDX_AP_MEM_RW, 153 MOD_APREMAP_API_IDX_CMN_ATRANS, 154 MOD_APREMAP_API_COUNT, 155 }; 156 157 /*! 158 * \} 159 */ 160 161 /*! 162 * \} 163 */ 164 165 #endif /* MOD_APREMAP_H */ 166