1 /* 2 * Copyright (c) 2023 Texas Instruments Incorporated 3 * Copyright (c) 2023 L Lakshmanan 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 #ifndef ZEPHYR_INCLUDE_RAT_H_ 9 #define ZEPHYR_INCLUDE_RAT_H_ 10 11 #ifdef __cplusplus 12 extern "C" { 13 #endif 14 15 #include <stdint.h> 16 17 #define ADDR_TRANSLATE_MAX_REGIONS (16u) 18 #define RAT_CTRL(base_addr, i) (base_addr + 0x20 + 0x10 * (i)) 19 #define RAT_BASE(base_addr, i) (base_addr + 0x24 + 0x10 * (i)) 20 #define RAT_TRANS_L(base_addr, i) (base_addr + 0x28 + 0x10 * (i)) 21 #define RAT_TRANS_H(base_addr, i) (base_addr + 0x2C + 0x10 * (i)) 22 #define RAT_CTRL_W(enable, size) (((enable & 0x1) << 31u) | (size & 0x3F)) 23 24 /** 25 * @brief Enum's to represent different possible region size for the address translate module 26 */ 27 enum address_trans_region_size { 28 address_trans_region_size_1 = 0x0, 29 address_trans_region_size_2, 30 address_trans_region_size_4, 31 address_trans_region_size_8, 32 address_trans_region_size_16, 33 address_trans_region_size_32, 34 address_trans_region_size_64, 35 address_trans_region_size_128, 36 address_trans_region_size_256, 37 address_trans_region_size_512, 38 address_trans_region_size_1K, 39 address_trans_region_size_2K, 40 address_trans_region_size_4K, 41 address_trans_region_size_8K, 42 address_trans_region_size_16K, 43 address_trans_region_size_32K, 44 address_trans_region_size_64K, 45 address_trans_region_size_128K, 46 address_trans_region_size_256K, 47 address_trans_region_size_512K, 48 address_trans_region_size_1M, 49 address_trans_region_size_2M, 50 address_trans_region_size_4M, 51 address_trans_region_size_8M, 52 address_trans_region_size_16M, 53 address_trans_region_size_32M, 54 address_trans_region_size_64M, 55 address_trans_region_size_128M, 56 address_trans_region_size_256M, 57 address_trans_region_size_512M, 58 address_trans_region_size_1G, 59 address_trans_region_size_2G, 60 address_trans_region_size_4G 61 }; 62 63 /** 64 * @brief Region config structure 65 */ 66 struct address_trans_region_config { 67 uint64_t system_addr; 68 uint32_t local_addr; 69 uint32_t size; 70 }; 71 72 /** 73 * @brief Parameters for address_trans_init 74 */ 75 struct address_trans_params { 76 uint32_t num_regions; 77 uint32_t rat_base_addr; 78 struct address_trans_region_config *region_config; 79 }; 80 81 void sys_mm_drv_ti_rat_init(void *region_config, uint64_t rat_base_addr, uint8_t translate_regions); 82 83 #ifdef __cplusplus 84 } 85 #endif 86 87 #endif /* ZEPHYR_INCLUDE_RAT_H_ */ 88