1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Support for Merrifield PNW Camera Imaging ISP subsystem.
4 *
5 * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
6 *
7 * Copyright (c) 2012 Silicon Hive www.siliconhive.com.
8 */
9 #include "type_support.h"
10 #include "mmu/isp_mmu.h"
11 #include "mmu/sh_mmu_mrfld.h"
12 #include "atomisp_compat.h"
13
14 #define MERR_VALID_PTE_MASK 0x80000000
15
16 /*
17 * include SH header file here
18 */
19
sh_phys_to_pte(struct isp_mmu * mmu,phys_addr_t phys)20 static unsigned int sh_phys_to_pte(struct isp_mmu *mmu,
21 phys_addr_t phys)
22 {
23 return phys >> ISP_PAGE_OFFSET;
24 }
25
sh_pte_to_phys(struct isp_mmu * mmu,unsigned int pte)26 static phys_addr_t sh_pte_to_phys(struct isp_mmu *mmu,
27 unsigned int pte)
28 {
29 unsigned int mask = mmu->driver->pte_valid_mask;
30
31 return (phys_addr_t)((pte & ~mask) << ISP_PAGE_OFFSET);
32 }
33
sh_get_pd_base(struct isp_mmu * mmu,phys_addr_t phys)34 static unsigned int sh_get_pd_base(struct isp_mmu *mmu,
35 phys_addr_t phys)
36 {
37 unsigned int pte = sh_phys_to_pte(mmu, phys);
38
39 return HOST_ADDRESS(pte);
40 }
41
42 /*
43 * callback to flush tlb.
44 *
45 * tlb_flush_range will at least flush TLBs containing
46 * address mapping from addr to addr + size.
47 *
48 * tlb_flush_all will flush all TLBs.
49 *
50 * tlb_flush_all is must be provided. if tlb_flush_range is
51 * not valid, it will set to tlb_flush_all by default.
52 */
sh_tlb_flush(struct isp_mmu * mmu)53 static void sh_tlb_flush(struct isp_mmu *mmu)
54 {
55 ia_css_mmu_invalidate_cache();
56 }
57
58 struct isp_mmu_client sh_mmu_mrfld = {
59 .name = "Silicon Hive ISP3000 MMU",
60 .pte_valid_mask = MERR_VALID_PTE_MASK,
61 .null_pte = ~MERR_VALID_PTE_MASK,
62 .get_pd_base = sh_get_pd_base,
63 .tlb_flush_all = sh_tlb_flush,
64 .phys_to_pte = sh_phys_to_pte,
65 .pte_to_phys = sh_pte_to_phys,
66 };
67