public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Abner Chang" <abner.chang@hpe.com>
To: devel@edk2.groups.io
Cc: abner.chang@hpe.com, Daniel Schaefer <daniel.schaefer@hpe.com>,
	Sunil V L <sunilvl@ventanamicro.com>
Subject: [edk2-platforms][PATCH 04/14] RiscVPlatformPkg/U500: Use generic platform library
Date: Mon, 15 Nov 2021 10:56:30 +0800	[thread overview]
Message-ID: <20211115025640.12897-5-abner.chang@hpe.com> (raw)
In-Reply-To: <20211115025640.12897-1-abner.chang@hpe.com>

Also removed the one under U500 package.

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Daniel Schaefer <daniel.schaefer@hpe.com>
Cc: Sunil V L <sunilvl@ventanamicro.com>
---
 .../FreedomU500VC707Board/U500.dsc            |   2 +-
 .../OpensbiPlatformLib/OpensbiPlatformLib.inf |  54 -----
 .../Library/OpensbiPlatformLib/Platform.c     | 206 ------------------
 3 files changed, 1 insertion(+), 261 deletions(-)
 delete mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/OpensbiPlatformLib/OpensbiPlatformLib.inf
 delete mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/OpensbiPlatformLib/Platform.c

diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc
index e59fdda59f..fb1b5b5d22 100644
--- a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc
@@ -172,7 +172,7 @@
 #
 # OpenSBi Platform Library
 #
-  RiscVOpensbiPlatformLib|Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/OpensbiPlatformLib/OpensbiPlatformLib.inf
+  RiscVOpensbiPlatformLib|Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/OpensbiPlatformLib.inf
 
 [LibraryClasses.common.PEI_CORE]
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/OpensbiPlatformLib/OpensbiPlatformLib.inf b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/OpensbiPlatformLib/OpensbiPlatformLib.inf
deleted file mode 100644
index f38b339770..0000000000
--- a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/OpensbiPlatformLib/OpensbiPlatformLib.inf
+++ /dev/null
@@ -1,54 +0,0 @@
-## @file
-#  RISC-V OpenSBI Platform Library
-#  This is the the library which provides platform
-#  level opensbi functions follow RISC-V OpenSBI implementation.
-#
-#  Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
-#
-#  SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
-  INF_VERSION                    = 0x0001001b
-  BASE_NAME                      = RiscVOpensbiPlatformLib
-  FILE_GUID                      = 9424ED54-EBDA-4FB5-8FF6-8291B07BB151
-  MODULE_TYPE                    = SEC
-  VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = RiscVOpensbiPlatformLib
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-#  VALID_ARCHITECTURES           = RISCV64
-#
-
-[Sources]
-  Platform.c
-
-[Packages]
-  EmbeddedPkg/EmbeddedPkg.dec
-  MdeModulePkg/MdeModulePkg.dec
-  MdePkg/MdePkg.dec
-  Platform/SiFive/U5SeriesPkg/U5SeriesPkg.dec
-  Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dec
-  Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dec
-
-[LibraryClasses]
-  BaseLib
-  BaseMemoryLib
-  DebugLib
-  DebugAgentLib
-  FdtLib
-  PcdLib
-  PrintLib
-  RiscVCpuLib
-
-[FixedPcd]
-  gUefiRiscVPlatformPkgTokenSpaceGuid.PcdBootHartId
-  gUefiRiscVPlatformPkgTokenSpaceGuid.PcdHartCount
-  gUefiRiscVPlatformPkgTokenSpaceGuid.PcdBootableHartNumber
-  gUefiRiscVPlatformPkgTokenSpaceGuid.PcdOpenSbiStackSize
-
-  gSiFiveU5SeriesPlatformsPkgTokenSpaceGuid.PcdU5UartBase
-  gSiFiveU5SeriesPlatformsPkgTokenSpaceGuid.PcdU5PlatformSystemClock
diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/OpensbiPlatformLib/Platform.c b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/OpensbiPlatformLib/Platform.c
deleted file mode 100644
index b346eccaf0..0000000000
--- a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/OpensbiPlatformLib/Platform.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- *
- * Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2019 Western Digital Corporation or its affiliates.
- *
- * Authors:
- *   Atish Patra <atish.patra@wdc.com>
- */
-
-#include <libfdt.h>
-#include <sbi/riscv_asm.h>
-#include <sbi/riscv_io.h>
-#include <sbi/riscv_encoding.h>
-#include <sbi/sbi_console.h>
-#include <sbi/sbi_const.h>
-#include <sbi/sbi_platform.h>
-#include <sbi_utils/fdt/fdt_fixup.h>
-#include <sbi_utils/irqchip/plic.h>
-#include <sbi_utils/serial/sifive-uart.h>
-#include <sbi_utils/sys/clint.h>
-#include <U5Clint.h>
-
-#define U500_HART_COUNT          FixedPcdGet32(PcdHartCount)
-#define U500_BOOTABLE_HART_COUNT FixedPcdGet32(PcdBootableHartNumber)
-#define U500_HART_STACK_SIZE     FixedPcdGet32(PcdOpenSbiStackSize)
-#define U500_BOOT_HART_ID        FixedPcdGet32(PcdBootHartId)
-
-#define U500_SYS_CLK             FixedPcdGet32(PcdU5PlatformSystemClock)
-
-#define U500_PLIC_ADDR              0xc000000
-#define U500_PLIC_NUM_SOURCES       0x35
-#define U500_PLIC_NUM_PRIORITIES    7
-
-#define U500_UART_ADDR              FixedPcdGet32(PcdU5UartBase)
-
-#define U500_UART_BAUDRATE          115200
-
-/* PRCI clock related macros */
-//TODO: Do we need a separate driver for this ?
-#define U500_PRCI_BASE_ADDR                 0x10000000
-#define U500_PRCI_CLKMUXSTATUSREG           0x002C
-#define U500_PRCI_CLKMUX_STATUS_TLCLKSEL    (0x1 << 1)
-
-/* Full tlb flush always */
-#define U500_TLB_RANGE_FLUSH_LIMIT		0
-
-unsigned long log2roundup(unsigned long x);
-
-static struct plic_data plic = {
-    .addr = U500_PLIC_ADDR,
-    .num_src = U500_PLIC_NUM_SOURCES,
-};
-
-static struct clint_data clint = {
-    .addr = CLINT_REG_BASE_ADDR,
-    .first_hartid = 0,
-    .hart_count = U500_HART_COUNT,
-    .has_64bit_mmio = TRUE,
-};
-
-static void U500_modify_dt(void *fdt)
-{
-    u32 i, size;
-    int chosen_offset, err;
-    int cpu_offset;
-    char cpu_node[32] = "";
-    const char *mmu_type;
-
-    for (i = 0; i < U500_HART_COUNT; i++) {
-        sbi_sprintf(cpu_node, "/cpus/cpu@%d", i);
-        cpu_offset = fdt_path_offset(fdt, cpu_node);
-        mmu_type = fdt_getprop(fdt, cpu_offset, "mmu-type", NULL);
-        if (mmu_type && (!AsciiStrCmp(mmu_type, "riscv,sv39") ||
-            !AsciiStrCmp(mmu_type,"riscv,sv48")))
-            continue;
-        else
-            fdt_setprop_string(fdt, cpu_offset, "status", "masked");
-        memset(cpu_node, 0, sizeof(cpu_node));
-    }
-    size = fdt_totalsize(fdt);
-    err = fdt_open_into(fdt, fdt, size + 256);
-    if (err < 0)
-        sbi_printf("Device Tree can't be expanded to accmodate new node");
-
-    chosen_offset = fdt_path_offset(fdt, "/chosen");
-    fdt_setprop_string(fdt, chosen_offset, "stdout-path",
-               "/soc/serial@10010000:115200");
-
-    fdt_plic_fixup(fdt, "riscv,plic0");
-}
-
-static int U500_final_init(bool cold_boot)
-{
-    void *fdt;
-    struct sbi_scratch *ThisScratch;
-
-    if (!cold_boot)
-        return 0;
-
-    fdt = sbi_scratch_thishart_arg1_ptr();
-    U500_modify_dt(fdt);
-    //
-    // Set PMP of firmware regions to R and X. We will lock this in the end of PEI.
-    // This region only protects SEC, PEI and Scratch buffer.
-    //
-    ThisScratch = sbi_scratch_thishart_ptr ();
-    pmp_set(0, PMP_R | PMP_X | PMP_W, ThisScratch->fw_start, log2roundup (ThisScratch->fw_size));
-    return 0;
-}
-
-static int U500_console_init(void)
-{
-    unsigned long peri_in_freq;
-
-    peri_in_freq = U500_SYS_CLK/2;
-    return sifive_uart_init(U500_UART_ADDR, peri_in_freq, U500_UART_BAUDRATE);
-}
-
-static int U500_irqchip_init(bool cold_boot)
-{
-    int rc;
-    u32 hartid = current_hartid();
-
-    if (cold_boot) {
-        rc = plic_cold_irqchip_init(&plic);
-        if (rc)
-            return rc;
-    }
-
-    return plic_warm_irqchip_init(&plic,
-            (hartid) ? (2 * hartid - 1) : 0,
-            (hartid) ? (2 * hartid) : -1);
-}
-
-static int U500_ipi_init(bool cold_boot)
-{
-    int rc;
-
-    if (cold_boot) {
-        rc = clint_cold_ipi_init(&clint);
-        if (rc)
-            return rc;
-
-    }
-
-    return clint_warm_ipi_init();
-}
-
-static u64 U500_get_tlbr_flush_limit(void)
-{
-    return U500_TLB_RANGE_FLUSH_LIMIT;
-}
-
-static int U500_timer_init(bool cold_boot)
-{
-    int rc;
-
-    if (cold_boot) {
-        rc = clint_cold_timer_init(&clint, NULL);
-        if (rc)
-            return rc;
-    }
-
-    return clint_warm_timer_init();
-}
-/**
- * The U500 SoC has 4 HARTs, Boot HART ID is determined by
- * PcdBootHartId.
- */
-static u32 u500_hart_index2id[U500_BOOTABLE_HART_COUNT] = {0, 1, 2, 3};
-
-static void U500_system_reset(u32 type, u32 second_param)
-{
-    /* For now nothing to do. */
-}
-
-const struct sbi_platform_operations platform_ops = {
-    .final_init = U500_final_init,
-    .console_putc = sifive_uart_putc,
-    .console_getc = sifive_uart_getc,
-    .console_init = U500_console_init,
-    .irqchip_init = U500_irqchip_init,
-    .ipi_send = clint_ipi_send,
-    .ipi_clear = clint_ipi_clear,
-    .ipi_init = U500_ipi_init,
-    .get_tlbr_flush_limit = U500_get_tlbr_flush_limit,
-    .timer_value = clint_timer_value,
-    .timer_event_stop = clint_timer_event_stop,
-    .timer_event_start = clint_timer_event_start,
-    .timer_init = U500_timer_init,
-    .system_reset = U500_system_reset
-};
-
-const struct sbi_platform platform = {
-    .opensbi_version    = OPENSBI_VERSION,                      // The OpenSBI version this platform table is built bassed on.
-    .platform_version   = SBI_PLATFORM_VERSION(0x0001, 0x0000), // SBI Platform version 1.0
-    .name               = "SiFive Freedom U500",
-    .features           = SBI_PLATFORM_DEFAULT_FEATURES,
-    .hart_count         = U500_BOOTABLE_HART_COUNT,
-    .hart_index2id      = u500_hart_index2id,
-    .hart_stack_size    = U500_HART_STACK_SIZE,
-    .platform_ops_addr  = (unsigned long)&platform_ops
-};
-- 
2.31.1


  parent reply	other threads:[~2021-11-15  3:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15  2:56 [edk2-platforms][PATCH 00/14] Revise U500 for the latest RISC-V packages Abner Chang
2021-11-15  2:56 ` [edk2-platforms][PATCH 01/14] RiscVPlatformPkg/U500: Pass DTB from PEI to DXE Abner Chang
2021-11-15  2:56 ` [edk2-platforms][PATCH 02/14] RiscVPlatformPkg/U500: Fix up FDT and install into config table Abner Chang
2021-11-15  2:56 ` [edk2-platforms][PATCH 03/14] RiscVPlatformPkg/U500: Use FirmwareContext library Abner Chang
2021-11-15  2:56 ` Abner Chang [this message]
2021-11-15  2:56 ` [edk2-platforms][PATCH 05/14] RiscVPlatformPkg/U500: Creates opensbi firmware domains Abner Chang
2021-11-15  2:56 ` [edk2-platforms][PATCH 06/14] RiscVPlatformPkg/U500: Uses RISC-V PeiCoreEntryPoint library Abner Chang
2021-11-15  2:56 ` [edk2-platforms][PATCH 07/14] RiscVPlatformPkg/U500: Use PlatormSecPpiLib Abner Chang
2021-11-15  2:56 ` [edk2-platforms][PATCH 08/14] RiscVPlatformPkg/U500: U500 uses mtime CSR library Abner Chang
2021-11-15  2:56 ` [edk2-platforms][PATCH 09/14] RiscVPlatformPkg/U500: Determines hart number from DTB Abner Chang
2021-11-15  2:56 ` [edk2-platforms][PATCH 10/14] RiscVPlatformPkg/U500: Use NULL instance of RiscVSpecialPlatformLib Abner Chang
2021-11-15  2:56 ` [edk2-platforms][PATCH 11/14] RiscVPlatformPkg/U500: Add device tree for U500 platform Abner Chang
2021-11-15  2:56 ` [edk2-platforms][PATCH 12/14] RiscVPlatformPkg/U500: Add device tree to build Abner Chang
2021-11-15  2:56 ` [edk2-platforms][PATCH 13/14] Platform/RISC-V: Add debug message to SecMain.c Abner Chang
2021-11-15  2:56 ` [edk2-platforms][PATCH 14/14] Platform/RISC-V: Initialize variable to zero Abner Chang
2021-11-22 11:40 ` [edk2-platforms][PATCH 00/14] Revise U500 for the latest RISC-V packages Daniel Schaefer

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-list 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=20211115025640.12897-5-abner.chang@hpe.com \
    --to=devel@edk2.groups.io \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox