All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: u-boot@lists.denx.de
Subject: [PATCH v4 2/5] arm: provide a function for boards init code to modify MMU virtual-physical map
Date: Tue,  2 Jun 2020 14:04:20 +0200	[thread overview]
Message-ID: <20200602120423.6285-3-m.szyprowski@samsung.com> (raw)
In-Reply-To: <20200602120423.6285-1-m.szyprowski@samsung.com>

Provide function for setting arbitrary virtual-physical MMU mapping for the given region.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-Id: If10b06cc6edbdff311a1b6302112e8cd0bb5313f
---
 arch/arm/include/asm/mmu.h    |  8 ++++++++
 arch/arm/include/asm/system.h | 11 +++++++++++
 arch/arm/lib/cache-cp15.c     | 24 ++++++++++++++++++------
 3 files changed, 37 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/include/asm/mmu.h

diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
new file mode 100644
index 00000000000..fe3d7930790
--- /dev/null
+++ b/arch/arm/include/asm/mmu.h
@@ -0,0 +1,8 @@
+#ifndef __ASM_ARM_MMU_H
+#define __ASM_ARM_MMU_H
+
+#ifdef CONFIG_ADDR_MAP
+extern void init_addr_map(void);
+#endif
+
+#endif
diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 1e3f574403a..6b6095d78e2 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -581,6 +581,17 @@ s32 psci_features(u32 function_id, u32 psci_fid);
  */
 void save_boot_params_ret(void);
 
+/**
+ * Change the virt/phys mapping and cache settings for a region.
+ *
+ * \param virt		virtual start address of memory region to change
+ * \param phys		physical address for the memory region to set
+ * \param size		size of memory region to change
+ * \param option	dcache option to select
+ */
+void mmu_set_region_dcache_behaviour_phys(phys_addr_t virt, phys_addr_t phys,
+					size_t size, enum dcache_option option);
+
 /**
  * Change the cache settings for a region.
  *
diff --git a/arch/arm/lib/cache-cp15.c b/arch/arm/lib/cache-cp15.c
index 1da2e92fe24..39717610d41 100644
--- a/arch/arm/lib/cache-cp15.c
+++ b/arch/arm/lib/cache-cp15.c
@@ -25,7 +25,8 @@ __weak void arm_init_domains(void)
 {
 }
 
-void set_section_dcache(int section, enum dcache_option option)
+static void set_section_phys(int section, phys_addr_t phys,
+			     enum dcache_option option)
 {
 #ifdef CONFIG_ARMV7_LPAE
 	u64 *page_table = (u64 *)gd->arch.tlb_addr;
@@ -37,7 +38,7 @@ void set_section_dcache(int section, enum dcache_option option)
 #endif
 
 	/* Add the page offset */
-	value |= ((u32)section << MMU_SECTION_SHIFT);
+	value |= phys;
 
 	/* Add caching bits */
 	value |= option;
@@ -46,13 +47,18 @@ void set_section_dcache(int section, enum dcache_option option)
 	page_table[section] = value;
 }
 
+void set_section_dcache(int section, enum dcache_option option)
+{
+	set_section_phys(section, (u32)section << MMU_SECTION_SHIFT, option);
+}
+
 __weak void mmu_page_table_flush(unsigned long start, unsigned long stop)
 {
 	debug("%s: Warning: not implemented\n", __func__);
 }
 
-void mmu_set_region_dcache_behaviour(phys_addr_t start, size_t size,
-				     enum dcache_option option)
+void mmu_set_region_dcache_behaviour_phys(phys_addr_t start, phys_addr_t phys,
+					size_t size, enum dcache_option option)
 {
 #ifdef CONFIG_ARMV7_LPAE
 	u64 *page_table = (u64 *)gd->arch.tlb_addr;
@@ -74,8 +80,8 @@ void mmu_set_region_dcache_behaviour(phys_addr_t start, size_t size,
 	debug("%s: start=%pa, size=%zu, option=0x%x\n", __func__, &start, size,
 	      option);
 #endif
-	for (upto = start; upto < end; upto++)
-		set_section_dcache(upto, option);
+	for (upto = start; upto < end; upto++, phys += MMU_SECTION_SIZE)
+		set_section_phys(upto, phys, option);
 
 	/*
 	 * Make sure range is cache line aligned
@@ -90,6 +96,12 @@ void mmu_set_region_dcache_behaviour(phys_addr_t start, size_t size,
 	mmu_page_table_flush(startpt, stoppt);
 }
 
+void mmu_set_region_dcache_behaviour(phys_addr_t start, size_t size,
+				     enum dcache_option option)
+{
+	mmu_set_region_dcache_behaviour_phys(start, start, size, option);
+}
+
 __weak void dram_bank_mmu_setup(int bank)
 {
 	bd_t *bd = gd->bd;
-- 
2.17.1

  parent reply	other threads:[~2020-06-02 12:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20200602120704eucas1p29ca38e04d720f89bb6d1a099d41d9abb@eucas1p2.samsung.com>
2020-06-02 12:04 ` [PATCH v4 0/5] ARM: arbitrary virtual-physical mappings for RPi4 XHCI support Marek Szyprowski
     [not found]   ` <CGME20200602120705eucas1p208a323aa45431cf267e12ae157c507c3@eucas1p2.samsung.com>
2020-06-02 12:04     ` [PATCH v4 1/5] powerpc: move ADDR_MAP to Kconfig Marek Szyprowski
2020-06-02 14:28       ` Tom Rini
     [not found]   ` <CGME20200602120706eucas1p1d0bba520d15d775bc5d7d1928b1e5cb5@eucas1p1.samsung.com>
2020-06-02 12:04     ` Marek Szyprowski [this message]
2020-06-02 14:28       ` [PATCH v4 2/5] arm: provide a function for boards init code to modify MMU virtual-physical map Tom Rini
     [not found]   ` <CGME20200602120707eucas1p1b4e31f4f658bcf218550c483eb513705@eucas1p1.samsung.com>
2020-06-02 12:04     ` [PATCH v4 3/5] mmc: bcm283x: fix int to pointer cast Marek Szyprowski
     [not found]   ` <CGME20200602120707eucas1p1a4472732abbbf0ae089daa39ed050c3c@eucas1p1.samsung.com>
2020-06-02 12:04     ` [PATCH v4 4/5] rpi4: add a mapping for the PCIe XHCI controller MMIO registers (ARM 32bit) Marek Szyprowski
     [not found]   ` <CGME20200602120708eucas1p2e1d1b2afd0228f6568489623ec3f307c@eucas1p2.samsung.com>
2020-06-02 12:04     ` [PATCH v4 5/5] config: Enable support for the XHCI controller on RPI4 board Marek Szyprowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200602120423.6285-3-m.szyprowski@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.