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 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 *
19 */
20 #include "type_support.h"
21 #include "mmu/isp_mmu.h"
22 #include "mmu/sh_mmu_mrfld.h"
23 #include "atomisp_compat.h"
24
25 #define MERR_VALID_PTE_MASK 0x80000000
26
27 /*
28 * include SH header file here
29 */
30
sh_phys_to_pte(struct isp_mmu * mmu,phys_addr_t phys)31 static unsigned int sh_phys_to_pte(struct isp_mmu *mmu,
32 phys_addr_t phys)
33 {
34 return phys >> ISP_PAGE_OFFSET;
35 }
36
sh_pte_to_phys(struct isp_mmu * mmu,unsigned int pte)37 static phys_addr_t sh_pte_to_phys(struct isp_mmu *mmu,
38 unsigned int pte)
39 {
40 unsigned int mask = mmu->driver->pte_valid_mask;
41
42 return (phys_addr_t)((pte & ~mask) << ISP_PAGE_OFFSET);
43 }
44
sh_get_pd_base(struct isp_mmu * mmu,phys_addr_t phys)45 static unsigned int sh_get_pd_base(struct isp_mmu *mmu,
46 phys_addr_t phys)
47 {
48 unsigned int pte = sh_phys_to_pte(mmu, phys);
49
50 return HOST_ADDRESS(pte);
51 }
52
53 /*
54 * callback to flush tlb.
55 *
56 * tlb_flush_range will at least flush TLBs containing
57 * address mapping from addr to addr + size.
58 *
59 * tlb_flush_all will flush all TLBs.
60 *
61 * tlb_flush_all is must be provided. if tlb_flush_range is
62 * not valid, it will set to tlb_flush_all by default.
63 */
sh_tlb_flush(struct isp_mmu * mmu)64 static void sh_tlb_flush(struct isp_mmu *mmu)
65 {
66 ia_css_mmu_invalidate_cache();
67 }
68
69 struct isp_mmu_client sh_mmu_mrfld = {
70 .name = "Silicon Hive ISP3000 MMU",
71 .pte_valid_mask = MERR_VALID_PTE_MASK,
72 .null_pte = ~MERR_VALID_PTE_MASK,
73 .get_pd_base = sh_get_pd_base,
74 .tlb_flush_all = sh_tlb_flush,
75 .phys_to_pte = sh_phys_to_pte,
76 .pte_to_phys = sh_pte_to_phys,
77 };
78