1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2015, Intel Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  */
15 
16 #include "ia_css_mmu.h"
17 #include "ia_css_mmu_private.h"
18 #include <ia_css_debug.h>
19 #include "sh_css_sp.h"
20 #include "sh_css_firmware.h"
21 #include "sp.h"
22 #include "mmu_device.h"
23 
24 void
ia_css_mmu_invalidate_cache(void)25 ia_css_mmu_invalidate_cache(void)
26 {
27 	const struct ia_css_fw_info *fw = &sh_css_sp_fw;
28 	unsigned int HIVE_ADDR_ia_css_dmaproxy_sp_invalidate_tlb;
29 
30 	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
31 			    "ia_css_mmu_invalidate_cache() enter\n");
32 
33 	/* if the SP is not running we should not access its dmem */
34 	if (sh_css_sp_is_running()) {
35 		HIVE_ADDR_ia_css_dmaproxy_sp_invalidate_tlb = fw->info.sp.invalidate_tlb;
36 
37 		(void)HIVE_ADDR_ia_css_dmaproxy_sp_invalidate_tlb; /* Suppres warnings in CRUN */
38 
39 		sp_dmem_store_uint32(SP0_ID,
40 				     (unsigned int)sp_address_of(ia_css_dmaproxy_sp_invalidate_tlb),
41 				     true);
42 	}
43 	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
44 			    "ia_css_mmu_invalidate_cache() leave\n");
45 }
46 
47 void
sh_css_mmu_set_page_table_base_index(hrt_data base_index)48 sh_css_mmu_set_page_table_base_index(hrt_data base_index)
49 {
50 	int i;
51 
52 	IA_CSS_ENTER_PRIVATE("base_index=0x%08x\n", base_index);
53 	for (i = 0; i < N_MMU_ID; i++) {
54 		mmu_ID_t mmu_id = i;
55 
56 		mmu_set_page_table_base_index(mmu_id, base_index);
57 		mmu_invalidate_cache(mmu_id);
58 	}
59 	IA_CSS_LEAVE_PRIVATE("");
60 }
61