1 /* 2 * Copyright (c) 2025, MediaTek Inc. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <arch_helpers.h> 8 #include <lib/mmio.h> 9 10 #include <drivers/booker.h> 11 #include <mtk_mmap_pool.h> 12 #include <platform_booker.h> 13 14 static const mmap_region_t booker_mmap[] MTK_MMAP_SECTION = { 15 MAP_REGION_FLAT(BOOKER_MAP_REGION, BOOKER_MAP_SIZE, MT_DEVICE | MT_RW | MT_SECURE), 16 {0} 17 }; 18 DECLARE_MTK_MMAP_REGIONS(booker_mmap); 19 20 static void booker_mtsx_tc_flush(uintptr_t base) 21 { 22 /* make no new lines be allocated in tag cache */ 23 mmio_setbits_64(base + MTU_AUX_CTL, BIT(TC_NO_FILL_MODE_BIT)); 24 dsb(); 25 26 /* start flush tag cache with Clean Invalid mode */ 27 mmio_setbits_64(base + MTU_TC_FLUSH_PR, BIT(TC_FLUSH_ENABLE_BIT)); 28 dsb(); 29 30 /* polling until flush completed */ 31 while (!(mmio_read_64(base + MTU_TC_FLUSH_SR) & BIT(TC_FLUSH_COMPLETE_BIT))) 32 ; 33 } 34 35 void booker_flush(void) 36 { 37 unsigned int i; 38 39 /* flush tag cache before power down booker */ 40 for (i = 0; i < ARRAY_SIZE(booker_mtsx_bases); i++) 41 booker_mtsx_tc_flush(booker_mtsx_bases[i]); 42 } 43