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 v12 13/18] riscv: cpu: fu540: Add support for cpu fu540
Date: Mon, 25 May 2020 13:03:26 +0530	[thread overview]
Message-ID: <20200525073333.14131-14-pragnesh.patel@sifive.com> (raw)
In-Reply-To: <20200525073333.14131-1-pragnesh.patel@sifive.com>

Add SiFive fu540 cpu to support RISC-V arch

Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
Tested-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/riscv/Kconfig                       |  1 +
 arch/riscv/cpu/fu540/Kconfig             | 15 ++++++++++
 arch/riscv/cpu/fu540/Makefile            |  7 +++++
 arch/riscv/cpu/fu540/cpu.c               | 22 ++++++++++++++
 arch/riscv/cpu/fu540/dram.c              | 38 ++++++++++++++++++++++++
 arch/riscv/include/asm/arch-fu540/clk.h  | 14 +++++++++
 arch/riscv/include/asm/arch-fu540/gpio.h | 38 ++++++++++++++++++++++++
 board/sifive/fu540/Kconfig               |  2 +-
 8 files changed, 136 insertions(+), 1 deletion(-)
 create mode 100644 arch/riscv/cpu/fu540/Kconfig
 create mode 100644 arch/riscv/cpu/fu540/Makefile
 create mode 100644 arch/riscv/cpu/fu540/cpu.c
 create mode 100644 arch/riscv/cpu/fu540/dram.c
 create mode 100644 arch/riscv/include/asm/arch-fu540/clk.h
 create mode 100644 arch/riscv/include/asm/arch-fu540/gpio.h

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index fb5fe5afff..d9854f5283 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -56,6 +56,7 @@ source "board/sifive/fu540/Kconfig"
 
 # platform-specific options below
 source "arch/riscv/cpu/ax25/Kconfig"
+source "arch/riscv/cpu/fu540/Kconfig"
 source "arch/riscv/cpu/generic/Kconfig"
 
 # architecture-specific options below
diff --git a/arch/riscv/cpu/fu540/Kconfig b/arch/riscv/cpu/fu540/Kconfig
new file mode 100644
index 0000000000..e9302e87c0
--- /dev/null
+++ b/arch/riscv/cpu/fu540/Kconfig
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
+
+config SIFIVE_FU540
+	bool
+	select ARCH_EARLY_INIT_R
+	imply CPU
+	imply CPU_RISCV
+	imply RISCV_TIMER
+	imply SIFIVE_CLINT if (RISCV_MMODE || SPL_RISCV_MMODE)
+	imply CMD_CPU
+	imply SPL_CPU_SUPPORT
+	imply SPL_OPENSBI
+	imply SPL_LOAD_FIT
diff --git a/arch/riscv/cpu/fu540/Makefile b/arch/riscv/cpu/fu540/Makefile
new file mode 100644
index 0000000000..44700d998c
--- /dev/null
+++ b/arch/riscv/cpu/fu540/Makefile
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2020 SiFive, Inc
+# Pragnesh Patel <pragnesh.patel@sifive.com>
+
+obj-y += dram.o
+obj-y += cpu.o
diff --git a/arch/riscv/cpu/fu540/cpu.c b/arch/riscv/cpu/fu540/cpu.c
new file mode 100644
index 0000000000..f13c18942f
--- /dev/null
+++ b/arch/riscv/cpu/fu540/cpu.c
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
+ */
+
+#include <irq_func.h>
+#include <asm/cache.h>
+
+/*
+ * cleanup_before_linux() is called just before we call linux
+ * it prepares the processor for linux
+ *
+ * we disable interrupt and caches.
+ */
+int cleanup_before_linux(void)
+{
+	disable_interrupts();
+
+	cache_flush();
+
+	return 0;
+}
diff --git a/arch/riscv/cpu/fu540/dram.c b/arch/riscv/cpu/fu540/dram.c
new file mode 100644
index 0000000000..1dc77efeca
--- /dev/null
+++ b/arch/riscv/cpu/fu540/dram.c
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
+ */
+
+#include <common.h>
+#include <fdtdec.h>
+#include <init.h>
+#include <linux/sizes.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int dram_init(void)
+{
+	return fdtdec_setup_mem_size_base();
+}
+
+int dram_init_banksize(void)
+{
+	return fdtdec_setup_memory_banksize();
+}
+
+ulong board_get_usable_ram_top(ulong total_size)
+{
+#ifdef CONFIG_64BIT
+	/*
+	 * Ensure that we run from first 4GB so that all
+	 * addresses used by U-Boot are 32bit addresses.
+	 *
+	 * This in-turn ensures that 32bit DMA capable
+	 * devices work fine because DMA mapping APIs will
+	 * provide 32bit DMA addresses only.
+	 */
+	if (gd->ram_top > SZ_4G)
+		return SZ_4G;
+#endif
+	return gd->ram_top;
+}
diff --git a/arch/riscv/include/asm/arch-fu540/clk.h b/arch/riscv/include/asm/arch-fu540/clk.h
new file mode 100644
index 0000000000..d71ed4357c
--- /dev/null
+++ b/arch/riscv/include/asm/arch-fu540/clk.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2020 SiFive Inc
+ *
+ * Authors:
+ *   Pragnesh Patel <pragnesh.patel@sifive.com>
+ */
+
+#ifndef __CLK_SIFIVE_H
+#define __CLK_SIFIVE_H
+
+/* Note: This is a placeholder header for driver compilation. */
+
+#endif
diff --git a/arch/riscv/include/asm/arch-fu540/gpio.h b/arch/riscv/include/asm/arch-fu540/gpio.h
new file mode 100644
index 0000000000..0d16c59ca6
--- /dev/null
+++ b/arch/riscv/include/asm/arch-fu540/gpio.h
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2019 SiFive, Inc.
+ */
+
+#ifndef _GPIO_SIFIVE_H
+#define _GPIO_SIFIVE_H
+
+#define GPIO_INPUT_VAL	0x00
+#define GPIO_INPUT_EN	0x04
+#define GPIO_OUTPUT_EN	0x08
+#define GPIO_OUTPUT_VAL	0x0C
+#define GPIO_RISE_IE	0x18
+#define GPIO_RISE_IP	0x1C
+#define GPIO_FALL_IE	0x20
+#define GPIO_FALL_IP	0x24
+#define GPIO_HIGH_IE	0x28
+#define GPIO_HIGH_IP	0x2C
+#define GPIO_LOW_IE	0x30
+#define GPIO_LOW_IP	0x34
+#define GPIO_OUTPUT_XOR	0x40
+
+#define NR_GPIOS	16
+
+enum gpio_state {
+	LOW,
+	HIGH
+};
+
+/* Details about a GPIO bank */
+struct sifive_gpio_platdata {
+	void *base;     /* address of registers in physical memory */
+};
+
+#define SIFIVE_GENERIC_GPIO_NR(port, index) \
+		(((port) * NR_GPIOS) + ((index) & (NR_GPIOS - 1)))
+
+#endif /* _GPIO_SIFIVE_H */
diff --git a/board/sifive/fu540/Kconfig b/board/sifive/fu540/Kconfig
index d41c305227..eb5ba3123d 100644
--- a/board/sifive/fu540/Kconfig
+++ b/board/sifive/fu540/Kconfig
@@ -7,7 +7,7 @@ config SYS_VENDOR
 	default "sifive"
 
 config SYS_CPU
-	default "generic"
+	default "fu540"
 
 config SYS_CONFIG_NAME
 	default "sifive-fu540"
-- 
2.17.1

  parent reply	other threads:[~2020-05-25  7:33 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-25  7:33 [PATCH v12 00/18] RISC-V SiFive FU540 support SPL Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 01/18] misc: add driver for the SiFive otp controller Pragnesh Patel
2020-05-25 21:44   ` Simon Glass
2020-05-26  5:10     ` Pragnesh Patel
2020-05-28  3:08       ` Simon Glass
2020-05-29  7:18         ` Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 02/18] riscv: sifive: fu540: Use OTP DM driver for serial environment variable Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 03/18] riscv: Add _image_binary_end for SPL Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 04/18] lib: Makefile: build crc7.c when CONFIG_MMC_SPI Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 05/18] riscv: sifive: dts: fu540: Add board -u-boot.dtsi files Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 06/18] sifive: fu540: add ddr driver Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 07/18] sifive: dts: fu540: Add DDR controller and phy register settings Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 08/18] riscv: sifive: dts: fu540: add U-Boot dmc node Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 09/18] clk: sifive: fu540-prci: Add clock enable and disable ops Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 10/18] clk: sifive: fu540-prci: Add ddr clock initialization Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 11/18] clk: sifive: fu540-prci: Release ethernet clock reset Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 12/18] riscv: dts: sifive: Sync hifive-unleashed-a00 dts from linux Pragnesh Patel
2020-05-25  7:33 ` Pragnesh Patel [this message]
2020-05-25  7:33 ` [PATCH v12 14/18] riscv: sifive: fu540: add SPL configuration Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 15/18] sifive: fu540: Add sample SD gpt partition layout Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 16/18] sifive: fu540: Add U-Boot proper sector start Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 17/18] configs: fu540: Add config options for U-Boot SPL Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 18/18] doc: sifive: fu540: Add description for OpenSBI generic platform Pragnesh Patel
2020-05-25 13:12 ` [PATCH v12 00/18] RISC-V SiFive FU540 support SPL Bin Meng
2020-05-25 14:22   ` Pragnesh Patel
2020-05-26  8:05     ` Jagan Teki
2020-05-26  8:08       ` Bin Meng
2020-05-26  8:10         ` Jagan Teki
2020-05-26  8:53       ` Jagan Teki

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=20200525073333.14131-14-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.