From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web11.18025.1636948550698590155 for ; Sun, 14 Nov 2021 19:55:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=X3LBBIZT; spf=temperror, err=temporary DNS error (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=0953f1bc5c=abner.chang@hpe.com) Received: from pps.filterd (m0150244.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AEIWNn5007567; Mon, 15 Nov 2021 03:55:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pps0720; bh=drqP4OisdBfPDr+qdkb7CrU1/gvKabV+ctfryFNa+OM=; b=X3LBBIZT3BhyAfpU/GNX9m2FCuzL9uJ96tKWFMRkJpQ5XVJyDKwtfq/HspI5kD8M0IOa hRi083OPvlQtLE4nE2j2le3cvdkOQ9IHTObBKSHtXdm1Wa8RaLjQGDdUyE5VosnA6bqj d1Ptf7fPsbBieZCBLMNIIoGJkrFehpwk3RLhKQA9o4vPQsg2tpuSl3cPGZ1ZrieOpDP5 90Row3Ebp1M72nSAQ8u0LCvA/QG4dyzG0mEF4xr6r9nmpEaBaJJHoF3vRjljaixhQxG3 Olu43QT0MHr4qtFZ7AMLTPhi9Tsl8B/MI31iX6DvELZNcchxLNu4ZOCWoaP2Vyk7K6ZB cA== Received: from g2t2353.austin.hpe.com (g2t2353.austin.hpe.com [15.233.44.26]) by mx0b-002e3701.pphosted.com with ESMTP id 3ca617kanm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Nov 2021 03:55:49 +0000 Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2353.austin.hpe.com (Postfix) with ESMTP id A58BB6D; Mon, 15 Nov 2021 03:55:48 +0000 (UTC) Received: from UB16Abner.asiapacific.hpqcorp.net (ub16abner.asiapacific.hpqcorp.net [15.119.209.229]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id 96B6D36; Mon, 15 Nov 2021 03:55:47 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: abner.chang@hpe.com, Daniel Schaefer , Sunil V L Subject: [edk2-platforms][PATCH 04/14] RiscVPlatformPkg/U500: Use generic platform library Date: Mon, 15 Nov 2021 10:56:30 +0800 Message-Id: <20211115025640.12897-5-abner.chang@hpe.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115025640.12897-1-abner.chang@hpe.com> References: <20211115025640.12897-1-abner.chang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: eNp1QjZ_WKnUsIiF0DJRkfYkvGoB7U2j X-Proofpoint-ORIG-GUID: eNp1QjZ_WKnUsIiF0DJRkfYkvGoB7U2j X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-15_02,2021-11-12_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 phishscore=0 spamscore=0 impostorscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111150021 Content-Transfer-Encoding: quoted-printable Also removed the one under U500 package. Signed-off-by: Abner Chang Cc: Daniel Schaefer Cc: Sunil V L --- .../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/Libra= ry/OpensbiPlatformLib/OpensbiPlatformLib.inf delete mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Libra= ry/OpensbiPlatformLib/Platform.c diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc b/P= latform/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 @@ #=0D # OpenSBi Platform Library=0D #=0D - RiscVOpensbiPlatformLib|Platform/SiFive/U5SeriesPkg/FreedomU500VC707Boar= d/Library/OpensbiPlatformLib/OpensbiPlatformLib.inf=0D + RiscVOpensbiPlatformLib|Platform/RISC-V/PlatformPkg/Library/OpensbiPlatf= ormLib/OpensbiPlatformLib.inf=0D =0D [LibraryClasses.common.PEI_CORE]=0D HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf=0D diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/Open= sbiPlatformLib/OpensbiPlatformLib.inf b/Platform/SiFive/U5SeriesPkg/Freedom= U500VC707Board/Library/OpensbiPlatformLib/OpensbiPlatformLib.inf deleted file mode 100644 index f38b339770..0000000000 --- a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/OpensbiPlat= formLib/OpensbiPlatformLib.inf +++ /dev/null @@ -1,54 +0,0 @@ -## @file=0D -# RISC-V OpenSBI Platform Library=0D -# This is the the library which provides platform=0D -# level opensbi functions follow RISC-V OpenSBI implementation.=0D -#=0D -# Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All righ= ts reserved.
=0D -#=0D -# SPDX-License-Identifier: BSD-2-Clause-Patent=0D -#=0D -##=0D -=0D -[Defines]=0D - INF_VERSION =3D 0x0001001b=0D - BASE_NAME =3D RiscVOpensbiPlatformLib=0D - FILE_GUID =3D 9424ED54-EBDA-4FB5-8FF6-8291B07BB151= =0D - MODULE_TYPE =3D SEC=0D - VERSION_STRING =3D 1.0=0D - LIBRARY_CLASS =3D RiscVOpensbiPlatformLib=0D -=0D -#=0D -# The following information is for reference only and not required by the = build tools.=0D -#=0D -# VALID_ARCHITECTURES =3D RISCV64=0D -#=0D -=0D -[Sources]=0D - Platform.c=0D -=0D -[Packages]=0D - EmbeddedPkg/EmbeddedPkg.dec=0D - MdeModulePkg/MdeModulePkg.dec=0D - MdePkg/MdePkg.dec=0D - Platform/SiFive/U5SeriesPkg/U5SeriesPkg.dec=0D - Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dec=0D - Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dec=0D -=0D -[LibraryClasses]=0D - BaseLib=0D - BaseMemoryLib=0D - DebugLib=0D - DebugAgentLib=0D - FdtLib=0D - PcdLib=0D - PrintLib=0D - RiscVCpuLib=0D -=0D -[FixedPcd]=0D - gUefiRiscVPlatformPkgTokenSpaceGuid.PcdBootHartId=0D - gUefiRiscVPlatformPkgTokenSpaceGuid.PcdHartCount=0D - gUefiRiscVPlatformPkgTokenSpaceGuid.PcdBootableHartNumber=0D - gUefiRiscVPlatformPkgTokenSpaceGuid.PcdOpenSbiStackSize=0D -=0D - gSiFiveU5SeriesPlatformsPkgTokenSpaceGuid.PcdU5UartBase=0D - gSiFiveU5SeriesPlatformsPkgTokenSpaceGuid.PcdU5PlatformSystemClock=0D diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/Open= sbiPlatformLib/Platform.c b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Boa= rd/Library/OpensbiPlatformLib/Platform.c deleted file mode 100644 index b346eccaf0..0000000000 --- a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/OpensbiPlat= formLib/Platform.c +++ /dev/null @@ -1,206 +0,0 @@ -/*=0D - *=0D - * Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All righ= ts reserved.
=0D - *=0D - * SPDX-License-Identifier: BSD-2-Clause=0D - *=0D - * Copyright (c) 2019 Western Digital Corporation or its affiliates.=0D - *=0D - * Authors:=0D - * Atish Patra =0D - */=0D -=0D -#include =0D -#include =0D -#include =0D -#include =0D -#include =0D -#include =0D -#include =0D -#include =0D -#include =0D -#include =0D -#include =0D -#include =0D -=0D -#define U500_HART_COUNT FixedPcdGet32(PcdHartCount)=0D -#define U500_BOOTABLE_HART_COUNT FixedPcdGet32(PcdBootableHartNumber)=0D -#define U500_HART_STACK_SIZE FixedPcdGet32(PcdOpenSbiStackSize)=0D -#define U500_BOOT_HART_ID FixedPcdGet32(PcdBootHartId)=0D -=0D -#define U500_SYS_CLK FixedPcdGet32(PcdU5PlatformSystemClock)=0D -=0D -#define U500_PLIC_ADDR 0xc000000=0D -#define U500_PLIC_NUM_SOURCES 0x35=0D -#define U500_PLIC_NUM_PRIORITIES 7=0D -=0D -#define U500_UART_ADDR FixedPcdGet32(PcdU5UartBase)=0D -=0D -#define U500_UART_BAUDRATE 115200=0D -=0D -/* PRCI clock related macros */=0D -//TODO: Do we need a separate driver for this ?=0D -#define U500_PRCI_BASE_ADDR 0x10000000=0D -#define U500_PRCI_CLKMUXSTATUSREG 0x002C=0D -#define U500_PRCI_CLKMUX_STATUS_TLCLKSEL (0x1 << 1)=0D -=0D -/* Full tlb flush always */=0D -#define U500_TLB_RANGE_FLUSH_LIMIT 0=0D -=0D -unsigned long log2roundup(unsigned long x);=0D -=0D -static struct plic_data plic =3D {=0D - .addr =3D U500_PLIC_ADDR,=0D - .num_src =3D U500_PLIC_NUM_SOURCES,=0D -};=0D -=0D -static struct clint_data clint =3D {=0D - .addr =3D CLINT_REG_BASE_ADDR,=0D - .first_hartid =3D 0,=0D - .hart_count =3D U500_HART_COUNT,=0D - .has_64bit_mmio =3D TRUE,=0D -};=0D -=0D -static void U500_modify_dt(void *fdt)=0D -{=0D - u32 i, size;=0D - int chosen_offset, err;=0D - int cpu_offset;=0D - char cpu_node[32] =3D "";=0D - const char *mmu_type;=0D -=0D - for (i =3D 0; i < U500_HART_COUNT; i++) {=0D - sbi_sprintf(cpu_node, "/cpus/cpu@%d", i);=0D - cpu_offset =3D fdt_path_offset(fdt, cpu_node);=0D - mmu_type =3D fdt_getprop(fdt, cpu_offset, "mmu-type", NULL);=0D - if (mmu_type && (!AsciiStrCmp(mmu_type, "riscv,sv39") ||=0D - !AsciiStrCmp(mmu_type,"riscv,sv48")))=0D - continue;=0D - else=0D - fdt_setprop_string(fdt, cpu_offset, "status", "masked");=0D - memset(cpu_node, 0, sizeof(cpu_node));=0D - }=0D - size =3D fdt_totalsize(fdt);=0D - err =3D fdt_open_into(fdt, fdt, size + 256);=0D - if (err < 0)=0D - sbi_printf("Device Tree can't be expanded to accmodate new node");= =0D -=0D - chosen_offset =3D fdt_path_offset(fdt, "/chosen");=0D - fdt_setprop_string(fdt, chosen_offset, "stdout-path",=0D - "/soc/serial@10010000:115200");=0D -=0D - fdt_plic_fixup(fdt, "riscv,plic0");=0D -}=0D -=0D -static int U500_final_init(bool cold_boot)=0D -{=0D - void *fdt;=0D - struct sbi_scratch *ThisScratch;=0D -=0D - if (!cold_boot)=0D - return 0;=0D -=0D - fdt =3D sbi_scratch_thishart_arg1_ptr();=0D - U500_modify_dt(fdt);=0D - //=0D - // Set PMP of firmware regions to R and X. We will lock this in the en= d of PEI.=0D - // This region only protects SEC, PEI and Scratch buffer.=0D - //=0D - ThisScratch =3D sbi_scratch_thishart_ptr ();=0D - pmp_set(0, PMP_R | PMP_X | PMP_W, ThisScratch->fw_start, log2roundup (= ThisScratch->fw_size));=0D - return 0;=0D -}=0D -=0D -static int U500_console_init(void)=0D -{=0D - unsigned long peri_in_freq;=0D -=0D - peri_in_freq =3D U500_SYS_CLK/2;=0D - return sifive_uart_init(U500_UART_ADDR, peri_in_freq, U500_UART_BAUDRA= TE);=0D -}=0D -=0D -static int U500_irqchip_init(bool cold_boot)=0D -{=0D - int rc;=0D - u32 hartid =3D current_hartid();=0D -=0D - if (cold_boot) {=0D - rc =3D plic_cold_irqchip_init(&plic);=0D - if (rc)=0D - return rc;=0D - }=0D -=0D - return plic_warm_irqchip_init(&plic,=0D - (hartid) ? (2 * hartid - 1) : 0,=0D - (hartid) ? (2 * hartid) : -1);=0D -}=0D -=0D -static int U500_ipi_init(bool cold_boot)=0D -{=0D - int rc;=0D -=0D - if (cold_boot) {=0D - rc =3D clint_cold_ipi_init(&clint);=0D - if (rc)=0D - return rc;=0D -=0D - }=0D -=0D - return clint_warm_ipi_init();=0D -}=0D -=0D -static u64 U500_get_tlbr_flush_limit(void)=0D -{=0D - return U500_TLB_RANGE_FLUSH_LIMIT;=0D -}=0D -=0D -static int U500_timer_init(bool cold_boot)=0D -{=0D - int rc;=0D -=0D - if (cold_boot) {=0D - rc =3D clint_cold_timer_init(&clint, NULL);=0D - if (rc)=0D - return rc;=0D - }=0D -=0D - return clint_warm_timer_init();=0D -}=0D -/**=0D - * The U500 SoC has 4 HARTs, Boot HART ID is determined by=0D - * PcdBootHartId.=0D - */=0D -static u32 u500_hart_index2id[U500_BOOTABLE_HART_COUNT] =3D {0, 1, 2, 3};= =0D -=0D -static void U500_system_reset(u32 type, u32 second_param)=0D -{=0D - /* For now nothing to do. */=0D -}=0D -=0D -const struct sbi_platform_operations platform_ops =3D {=0D - .final_init =3D U500_final_init,=0D - .console_putc =3D sifive_uart_putc,=0D - .console_getc =3D sifive_uart_getc,=0D - .console_init =3D U500_console_init,=0D - .irqchip_init =3D U500_irqchip_init,=0D - .ipi_send =3D clint_ipi_send,=0D - .ipi_clear =3D clint_ipi_clear,=0D - .ipi_init =3D U500_ipi_init,=0D - .get_tlbr_flush_limit =3D U500_get_tlbr_flush_limit,=0D - .timer_value =3D clint_timer_value,=0D - .timer_event_stop =3D clint_timer_event_stop,=0D - .timer_event_start =3D clint_timer_event_start,=0D - .timer_init =3D U500_timer_init,=0D - .system_reset =3D U500_system_reset=0D -};=0D -=0D -const struct sbi_platform platform =3D {=0D - .opensbi_version =3D OPENSBI_VERSION, // The O= penSBI version this platform table is built bassed on.=0D - .platform_version =3D SBI_PLATFORM_VERSION(0x0001, 0x0000), // SBI P= latform version 1.0=0D - .name =3D "SiFive Freedom U500",=0D - .features =3D SBI_PLATFORM_DEFAULT_FEATURES,=0D - .hart_count =3D U500_BOOTABLE_HART_COUNT,=0D - .hart_index2id =3D u500_hart_index2id,=0D - .hart_stack_size =3D U500_HART_STACK_SIZE,=0D - .platform_ops_addr =3D (unsigned long)&platform_ops=0D -};=0D --=20 2.31.1