1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2015, Intel Corporation.
5  */
6 
7 #ifndef __MMU_PUBLIC_H_INCLUDED__
8 #define __MMU_PUBLIC_H_INCLUDED__
9 
10 #include "system_local.h"
11 #include "device_access.h"
12 #include "assert_support.h"
13 
14 /*! Set the page table base index of MMU[ID]
15 
16  \param	ID[in]				MMU identifier
17  \param	base_index[in]		page table base index
18 
19  \return none, MMU[ID].page_table_base_index = base_index
20  */
21 void mmu_set_page_table_base_index(
22     const mmu_ID_t		ID,
23     const hrt_data		base_index);
24 
25 /*! Get the page table base index of MMU[ID]
26 
27  \param	ID[in]				MMU identifier
28  \param	base_index[in]		page table base index
29 
30  \return MMU[ID].page_table_base_index
31  */
32 hrt_data mmu_get_page_table_base_index(
33     const mmu_ID_t		ID);
34 
35 /*! Invalidate the page table cache of MMU[ID]
36 
37  \param	ID[in]				MMU identifier
38 
39  \return none
40  */
41 void mmu_invalidate_cache(
42     const mmu_ID_t		ID);
43 
44 /*! Invalidate the page table cache of all MMUs
45 
46  \return none
47  */
48 void mmu_invalidate_cache_all(void);
49 
50 /*! Write to a control register of MMU[ID]
51 
52  \param	ID[in]				MMU identifier
53  \param	reg[in]				register index
54  \param value[in]			The data to be written
55 
56  \return none, MMU[ID].ctrl[reg] = value
57  */
mmu_reg_store(const mmu_ID_t ID,const unsigned int reg,const hrt_data value)58 static inline void mmu_reg_store(
59     const mmu_ID_t		ID,
60     const unsigned int	reg,
61     const hrt_data		value)
62 {
63 	assert(ID < N_MMU_ID);
64 	assert(MMU_BASE[ID] != (hrt_address) - 1);
65 	ia_css_device_store_uint32(MMU_BASE[ID] + reg * sizeof(hrt_data), value);
66 	return;
67 }
68 
69 /*! Read from a control register of MMU[ID]
70 
71  \param	ID[in]				MMU identifier
72  \param	reg[in]				register index
73  \param value[in]			The data to be written
74 
75  \return MMU[ID].ctrl[reg]
76  */
mmu_reg_load(const mmu_ID_t ID,const unsigned int reg)77 static inline hrt_data mmu_reg_load(
78     const mmu_ID_t		ID,
79     const unsigned int	reg)
80 {
81 	assert(ID < N_MMU_ID);
82 	assert(MMU_BASE[ID] != (hrt_address) - 1);
83 	return ia_css_device_load_uint32(MMU_BASE[ID] + reg * sizeof(hrt_data));
84 }
85 
86 #endif /* __MMU_PUBLIC_H_INCLUDED__ */
87