GNU Linux-libre 4.14.265-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / sh_css_mmu.c
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, "ia_css_mmu_invalidate_cache() enter\n");
30
31         /* if the SP is not running we should not access its dmem */
32         if (sh_css_sp_is_running()) {
33                 HIVE_ADDR_ia_css_dmaproxy_sp_invalidate_tlb = fw->info.sp.invalidate_tlb;
34
35                 (void)HIVE_ADDR_ia_css_dmaproxy_sp_invalidate_tlb; /* Suppres warnings in CRUN */
36
37                 sp_dmem_store_uint32(SP0_ID,
38                         (unsigned int)sp_address_of(ia_css_dmaproxy_sp_invalidate_tlb),
39                         true);
40         }
41         ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_mmu_invalidate_cache() leave\n");
42 }
43
44 /* Deprecated, this is an HRT backend function (memory_access.h) */
45 void
46 sh_css_mmu_set_page_table_base_index(hrt_data base_index)
47 {
48         int i;
49         IA_CSS_ENTER_PRIVATE("base_index=0x%08x\n", base_index);
50         for (i = 0; i < N_MMU_ID; i++) {
51                 mmu_ID_t mmu_id = i;
52                 mmu_set_page_table_base_index(mmu_id, base_index);
53                 mmu_invalidate_cache(mmu_id);
54         }
55         IA_CSS_LEAVE_PRIVATE("");
56 }