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