All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pragnesh Patel <pragnesh.patel@sifive.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 08/10] riscv: sifive: fu540: enable all cache ways from u-boot proper
Date: Fri, 24 Jan 2020 11:20:21 +0530	[thread overview]
Message-ID: <20200124055026.30787-9-pragnesh.patel@sifive.com> (raw)
In-Reply-To: <20200124055026.30787-1-pragnesh.patel@sifive.com>

This patch enables all cache ways from u-boot proper.

Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com>
---
 board/sifive/fu540/Makefile |  1 +
 board/sifive/fu540/cache.c  | 30 ++++++++++++++++++++++++++++++
 board/sifive/fu540/cache.h  | 13 +++++++++++++
 board/sifive/fu540/fu540.c  |  6 ++++--
 4 files changed, 48 insertions(+), 2 deletions(-)
 create mode 100644 board/sifive/fu540/cache.c
 create mode 100644 board/sifive/fu540/cache.h

diff --git a/board/sifive/fu540/Makefile b/board/sifive/fu540/Makefile
index cdcf894ade..a79928a0bf 100644
--- a/board/sifive/fu540/Makefile
+++ b/board/sifive/fu540/Makefile
@@ -3,6 +3,7 @@
 # Copyright (c) 2019 Western Digital Corporation or its affiliates.
 
 obj-y	+= fu540.o
+obj-y	+= cache.o
 
 ifdef CONFIG_SPL_BUILD
 obj-y += spl.o
diff --git a/board/sifive/fu540/cache.c b/board/sifive/fu540/cache.c
new file mode 100644
index 0000000000..c91728a678
--- /dev/null
+++ b/board/sifive/fu540/cache.c
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2019 SiFive, Inc
+ */
+#include <stdint.h>
+#include <linux/types.h>
+
+/* Register offsets */
+#define CACHE_ENABLE           0x008
+
+/* Block memory access until operation completed */
+static void cache_barrier_0(void)
+{
+	asm volatile("fence rw, io" : : : "memory");
+}
+
+static void cache_barrier_1(void)
+{
+	asm volatile("fence io, rw" : : : "memory");
+}
+
+/* Enable ways; allow cache to use these ways */
+void cache_enable_ways(u64 base_addr, u8 value)
+{
+	volatile u32 *enable = (volatile u32 *)(base_addr +
+					  CACHE_ENABLE);
+	cache_barrier_0();
+	(*enable) = value;
+	cache_barrier_1();
+}
diff --git a/board/sifive/fu540/cache.h b/board/sifive/fu540/cache.h
new file mode 100644
index 0000000000..425124a23b
--- /dev/null
+++ b/board/sifive/fu540/cache.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2019 SiFive, Inc
+ */
+
+#ifndef FU540_CACHE_H
+#define FU540_CACHE_H
+
+#define CACHE_CTRL_ADDR               _AC(0x2010000, UL)
+
+void cache_enable_ways(u64 base_addr, u8 value);
+
+#endif /* FU540_CACHE_H */
diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c
index b81003aa6f..7fde881e72 100644
--- a/board/sifive/fu540/fu540.c
+++ b/board/sifive/fu540/fu540.c
@@ -13,6 +13,8 @@
 #include <misc.h>
 #include <spl.h>
 
+#include "cache.h"
+
 /*
  * This define is a value used for error/unknown serial.
  * If we really care about distinguishing errors and 0 is
@@ -111,8 +113,8 @@ int misc_init_r(void)
 
 int board_init(void)
 {
-	/* For now nothing to do here. */
-
+	/* enable all cache ways */
+	cache_enable_ways(CACHE_CTRL_ADDR, 15);
 	return 0;
 }
 
-- 
2.17.1

  parent reply	other threads:[~2020-01-24  5:50 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24  5:50 [PATCH v3 00/10] RISC-V SiFive FU540 support SPL Pragnesh Patel
2020-01-24  5:50 ` [PATCH v3 01/10] misc: add driver for the Sifive otp controller Pragnesh Patel
2020-01-24  6:41   ` Jagan Teki
2020-01-27 10:18     ` Pragnesh Patel
2020-02-10 12:44       ` Pragnesh Patel
2020-01-24  5:50 ` [PATCH v3 02/10] riscv: Add _image_binary_end for SPL Pragnesh Patel
2020-01-24  6:44   ` Jagan Teki
2020-01-24  5:50 ` [PATCH v3 03/10] lib: Makefile: build crc7.c when CONFIG_MMC_SPI Pragnesh Patel
2020-01-24  6:27   ` Jagan Teki
2020-01-24  8:06     ` Pragnesh Patel
2020-01-27  7:58       ` Jagan Teki
2020-01-24  5:50 ` [PATCH v3 04/10] riscv: sifive: dts: fu540: Add board -u-boot.dtsi files Pragnesh Patel
2020-01-24  5:50 ` [PATCH v3 05/10] riscv: sifive: fu540: add DDR4 info Pragnesh Patel
2020-01-25  8:31   ` Anup Patel
2020-01-27  7:51   ` Jagan Teki
2020-01-28  6:41     ` Pragnesh Patel
2020-02-04 15:19       ` Bin Meng
2020-01-24  5:50 ` [PATCH v3 06/10] riscv: sifive: fu540: add SPL configuration Pragnesh Patel
2020-01-25  8:35   ` Anup Patel
2020-01-24  5:50 ` [PATCH v3 07/10] configs: fu540: Add config file for U-boot SPL Pragnesh Patel
2020-01-24  6:50   ` Jagan Teki
2020-01-25  8:41     ` Anup Patel
2020-01-27  7:49       ` Pragnesh Patel
2020-01-27 12:45         ` Anup Patel
2020-01-27  6:50     ` Pragnesh Patel
2020-01-27  7:38       ` Anup Patel
2020-01-27  7:41         ` Pragnesh Patel
2020-01-24  5:50 ` Pragnesh Patel [this message]
2020-01-25  8:36   ` [PATCH v3 08/10] riscv: sifive: fu540: enable all cache ways from u-boot proper Anup Patel
2020-01-24  5:50 ` [PATCH v3 09/10] sifive: fix palmer's email address and add sifive_fu540_spl_defconfig Pragnesh Patel
2020-01-25  8:37   ` Anup Patel
2020-01-24  5:50 ` [PATCH v3 10/10] doc: update FU540 RISC-V documentation Pragnesh Patel

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=20200124055026.30787-9-pragnesh.patel@sifive.com \
    --to=pragnesh.patel@sifive.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.