summaryrefslogtreecommitdiff
path: root/platform/generic
AgeCommit message (Collapse)AuthorFilesLines
2025-02-13lib: utils: Add MPXY RPMI mailbox driver for System MSI service groupAnup Patel1-0/+1
The supervisor software can directly receive most of the system MSIs except P2A doorbell and MSIs preferred to be handled in M-mode. Add MPXY RPMI mailbox client driver for the System MSI service group. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2025-02-13lib: utils: Split the FDT MPXY RPMI mailbox client into two partsAnup Patel1-0/+1
Instead of having one common FDT MPXY RPMI mailbox client drivers for various RPMI service groups, split this driver into two parts: 1) Common MPXY RPMI mailbox client library 2) MPXY driver for RPMI clock service group The above split enables having a separate MPXY driver for each RPMI clock service group and #1 (above) will allow code sharing between various MPXY RPMI drivers. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2025-02-12lib: utils: Initialize miscellaneous drivers in one passSamuel Holland3-14/+8
For driver subsystems that are not tightly integrated into the OpenSBI init sequence, it is not important that the drivers are initialized in any particular order. By putting all of these drivers in one array, they can all be initialized with a single pass through the devicetree. This saves about 10 ms of boot time on HiFive Unmatched. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2025-02-12platform: generic: thead: add Sophgo SG2044Inochi Amaoto1-10/+7
The Sophgo SG2044 is a new version of C920, although it supports sscofpmf, it still needs this pmu quirks its cores. Signed-off-by: Inochi Amaoto <inochiama@gmail.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2025-02-12lib: utils:Check that hartid is validRaj Vishwanathan1-2/+2
It is possible that hartid may not be sequential and it should not be validated against SBI_HARTMASK_MAX_BITS. Instead we should check the index of the hartid, hart index, against SBI_HARTMASK_MAX_BITS. Signed-off-by: Raj Vishwanathan <Raj.Vishwanathan@gmail.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2025-01-30lib: sbi: pmu: fix usage of sbi_pmu_irq_bit()Clément Léger2-2/+1
While sbi_pmu_irq_bit() was used to delegate irq to S-mode, LCOFIP usage was still hardcoded in various places. This led to change the returned value of sbi_pmu_irq_bit() to be a bit number rather than a bit mask since it returns an 'int' and we need to obtain the bit number itself to handle it in the IRQs handlers. Add a similar function to return the irq mask which can also be used where the mask is required rather than the bit itself. Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Atish Patra <atishp@rivosinc.com>
2024-12-21include: sbi: Fix compiling with C23 enabled compilersMichael Neuling1-1/+1
C23 pre-defines bool so we need to gate our defines. Signed-off-by: Michael Neuling <michaelneuling@tenstorrent.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-21platform: generic: Initialize console before other driversSamuel Holland1-5/+5
Initialize serial drivers first, so messages printed by other drivers do not need to use the early console buffer. Suggested-by: Anup Patel <anup@brainfault.org> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-06lib: utils/mpxy: Add RPMI client driver for MPXYRahul Pathak1-0/+1
Add a generic RPMI mailbox client driver which provides a MPXY channel. Initially, this driver only supports RPMI clock service group but can be extended to support multiple RPMI service groups. Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com> Co-developed-by: Anup Patel <apatel@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils: Add simple FDT based MPXY driver frameworkAnup Patel2-0/+11
The generic platform can have multiple MPXY drivers so add a simple FDT based MPXY driver framework. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils/cppc: Add RPMI CPPC driverSubrahmanya Lingappa1-0/+1
Add RPMI based driver for CPPC register read, write and probe. Signed-off-by: Subrahmanya Lingappa <slingappa@ventanamicro.com> Co-developed-by: Rahul Pathak <rpathak@ventanamicro.com> Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com> Co-developed-by: Sunil V L <sunilvl@ventanamicro.com> Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils: Add simple FDT based CPPC driver frameworkAnup Patel2-0/+3
The generic platform can have multiple CPPC drivers so add a simple FDT based CPPC driver framework. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils/hsm: Add RPMI HSM driverSubrahmanya Lingappa1-0/+1
The RPMI HSM service group provides set of routine to query and control power states of a Hart. Add RPMI based Hart State Management (HSM) driver. Signed-off-by: Subrahmanya Lingappa <slingappa@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils: Add simple FDT based HSM driver frameworkAnup Patel2-0/+3
The generic platform can have multiple HSM drivers so add a simple FDT based HSM driver framework. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: sbi: Add optional resume address to hart suspendSubrahmanya Lingappa1-1/+1
Add an optional resume address to the platform specific hart suspend call. Signed-off-by: Subrahmanya Lingappa <slingappa@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils/suspend: Add RPMI system suspend driverSubrahmanya Lingappa1-0/+1
Add RPMI based system suspend driver. To test this, execute the follwoing in Linux: $ echo mem > /sys/power/state To wake up, execute the following command on qemu monitor terminal: (qemu) system_wakeup Signed-off-by: Subrahmanya Lingappa <slingappa@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils: Add simple FDT based system suspend driver frameworkAnup Patel2-0/+3
The generic platform can have multiple system suspend drivers so add a simple FDT based system suspend driver framework. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib/utils: reset: Add RPMI System Reset driverRahul Pathak1-0/+1
Add RPMI based driver for system reset and enable it in the generic platform defconfig Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib/utils: Add RPMI messaging protocol and shared memory transport supportRahul Pathak1-0/+3
The RISC-V Platform Management Interface (RPMI) defines a messaging protocol and shared memory based transport for bi-directional communication with an on-chip or external microcontroller. To support RPMI in OpenSBI, add: 1) The RPMI messaging protocol defines and helper macros 2) A FDT mailbox driver for the RPMI shared memory transport Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com> Co-developed-by: Subrahmanya Lingappa <slingappa@ventanamicro.com> Signed-off-by: Subrahmanya Lingappa <slingappa@ventanamicro.com> Co-developed-by: Anup Patel <apatel@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-02lib: sbi_pmu: PMU raw event v2 supportAtish Patra1-1/+2
As per the updated ISA specification and SBI PMU v3.0, lower 56 bits are available for the platform to implement mhpmeventX encoding. Implement the PMU raw event V2 support defined in SBI v3.0 which allows more bits for platforms to encode the raw events. Signed-off-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-11-28lib: utils/reset: Use fdt_driver for initializationSamuel Holland2-4/+14
The reset driver subsystem does not need any extra data, so it can use `struct fdt_driver` directly. The generic fdt_reset_init() performs a best-effort initialization of all matching DT nodes. Platform-specific logic expects exactly one DT node to match a single driver. This is accomplished by using fdt_driver_init_one() with a local list containing that one driver. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-11-28treewide: Make carray arrays const and NULL-terminatedSamuel Holland1-3/+2
This allows the compiler to generate significantly better code, because it does not have to maintain either the loop counter or loop limit. Plus there are half as many symbols to relocate. This also simplifies passing carray arrays to helper functions. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-11-28platform: Drop irqchip warm init and exit hooksSamuel Holland1-1/+0
Now that driver lifecycle is managed from within the SBI irqchip core, platforms need only to initialize the driver once during cold init. Remove the remaining platform hooks that are no longer used. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-11-28lib: utils/irqchip: Move per-hart data from fdt_plic to plicSamuel Holland1-4/+4
The per-hart PLIC pointer is not really specific to FDT platforms. Move it into the main driver and drop the extra wrapper functions. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-11-28lib: utils/irqchip: plic: Common PM save/restoreSamuel Holland1-28/+6
Move the PLIC save/restore functions inside the driver, so they can be reused on any platform that needs them. The memory needed to store the PLIC context is also allocated by the driver. The PM data cannot be completely encapsulated, as some platforms (including Allwinner D1) need to program the IRQ enable status to a sideband interrupt controller for wakeup capability. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-11-11platform: Drop IPI warm init and exit hooksSamuel Holland1-1/+0
Now that the SBI IPI core clears IPIs at warm boot in a generic way, none of the drivers or platforms use these hooks, and we can remove them. Platforms need only to initialize the driver once during cold init. If other hooks are needed in the future, they can be added to struct sbi_ipi_device. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-11-11platform: introduce DT-based configurable heap sizeInochi Amaoto1-3/+25
The default heap size will work for most platforms, but for some special platforms, the heap is too small to hold all the information or is too big so that it take too much ram. Introduce configurable heap should solve this problem and make all generic platforms happy. Add DT-based heap-size for the generic platform. Signed-off-by: Inochi Amaoto <inochiama@gmail.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-11-05platform: Drop timer warm init and exit hooksSamuel Holland1-1/+0
Now that driver lifecycle is managed from within the SBI timer core, platforms need only to initialize the driver once during cold init. Remove the remaining platform hooks that are no longer used. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-09-26lib: sbi: Update sbi_{entry,init}_count() to take a hart indexSamuel Holland1-2/+4
All callers already have the hartindex available, so this removes a hartid to hartindex conversion. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-08-27platform: generic: Fix fw_platform_coldboot_harts_init() functionAnup Patel1-16/+16
It is possible that the OpenSBI config DT node is present but the "cold-boot-harts" DT property is not present. In this case, the fw_platform_coldboot_harts_init() will do nothing which in-turn causes OpenSBI firmware hang at boot time. To address the above issue, fallback to the default approach when the "cold-boot-harts" DT property is not present. Fixes: 67ce5a763cfb ("platform: generic: Add support for specify coldboot harts in DT") Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-08-24lib: utils/fdt: Add fdt_get_address_rw() helperSamuel Holland1-2/+2
Help tracking the lifecycle of the FDT blob by indicating which parts of the firmware modify it, and thus invalidate any previously-obtained offsets or pointers to data inside the blob. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-08-24lib: utils/serial: Pass the FDT to fdt_serial_init()Samuel Holland1-1/+1
Indicate that this function does not modify the FDT blob, and deduplicate the call to fdt_get_address(). Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-08-24lib: utils/reset: Pass the FDT to fdt_reset_init()Samuel Holland1-1/+1
Indicate that this function does not modify the FDT blob, and deduplicate the call to fdt_get_address(). Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-08-24platform: generic: Pass FDT to early/final_init overridesSamuel Holland11-29/+25
Several of these override functions access the FDT blob. Explicitly indicate which callbacks are allowed to modify the FDT blob by passing the parameter as a possibly-const pointer. This also reduces code size by deduplicating the call to fdt_get_address(). Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-08-24platform: generic: Constify FDT pointers in fw_platform_init()Samuel Holland3-5/+5
Indicate that none of these functions modify the devicetree by constifying the parameter type. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-08-24lib: utils/reset: Constify FDT pointers in parsing functionsSamuel Holland2-4/+4
Indicate that none of these functions modify the devicetree by constifying the parameter type. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-08-23platform: generic: andes: add a new Andes SBI call to free a PMA entryBen Zong-You Xie3-17/+67
Add a new Andes SBI call to free a PMA entry, and reset the memory attributes for the corresponding NAPOT region. Signed-off-by: Ben Zong-You Xie <ben717@andestech.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-08-23platform: generic: andes: add a new Andes SBI call to set up a PMA entryBen Zong-You Xie3-5/+138
Implement a new Andes SBI call, which is to set up a NAPOT region with given memory attributes. Signed-off-by: Ben Zong-You Xie <ben717@andestech.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-08-23platform: generic: andes: add Andes SBI call to probe Andes PMA featureBen Zong-You Xie4-2/+25
Add a new Andes SBI call to check whether PPMA is supported by hardware or not. Signed-off-by: Ben Zong-You Xie <ben717@andestech.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-08-23platform: generic: Kconfig: add the description for Andes PMA featureBen Zong-You Xie2-0/+6
Describe Andes PPMA in the config option, and select it for AE350 platform. Signed-off-by: Ben Zong-You Xie <ben717@andestech.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-07-24platform: Setup serial console device in early_init()Anup Patel1-10/+11
The sbi_console_init() does not do any special initialization so setup serial console device in early_init() so that console prints work as early as possible. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-By: Himanshu Chauhan <hchauhan@ventanamicro.com>
2024-07-04Makefile: change to using .carray.c for carray filesBen Dooks1-1/+1
We would like to clean any files generated by the carray scripts by just searching for the filename as the current make system turns f.carray into f.o. Change to make the make system turn f.carray into f.carray.o note, command to go through .mk files changing the .o in the .mk files is: find . -type f -name "*.carray" | xargs -t -I fname /bin/bash -x -c ' fn=`basename -s .carray fname`; echo "$fn"; sed -i `dirname fname `/objects.mk -e s/"$fn".o/"$fn".carray.o/g' Link: https://patchwork.ozlabs.org/project/opensbi/patch/20240401213438.590209-2-ivan.orlov0322@gmail.com/ Reported-by: Ivan Orlov <ivan.orlov0322@gmail.com> Suggested-by: Andrew Jones <ajones@ventanamicro.com> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-06-18platform: generic: andes: Add support for RV32 to set up PMABen Zong-You Xie1-1/+8
Like PMP, the behaviors to configure PMA will be different from RV64 and RV32. RV64 uses two Andes custom CSRs, pmacfg0 and pmacfg2, but RV32 uses four Andes custom CSRs, pmacfg0 ~ pmacfg3. This patch adds support to PMA for RV32. Signed-off-by: Ben Zong-You Xie <ben717@andestech.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-06-18platform: generic: andes: Refine Andes PMA related codeBen Zong-You Xie2-136/+81
This patch refines the Andes PMA related code. The main change is refactor andes_pma_[read|write]_cfg() and andes_pma_[read|write]_addr() into new functions andes_pma_[read|write]_num(). Also, fix some coding style problems. Signed-off-by: Ben Zong-You Xie <ben717@andestech.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-05-16platform: generic: thead: add Sophgo CV18XX/SG200X seriesInochi Amaoto1-0/+8
The Sophgo CV18XX/SG200X series SoCs have a standard C906 core. Add support for it. Signed-off-by: Inochi Amaoto <inochiama@outlook.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-05-15utils/reset: Add SG2042 hwmon MCU support.Inochi Amaoto1-0/+1
SG2042 uses an onboard MCU to provide reset function. Add reset driver to support this onboard MCU. Signed-off-by: Inochi Amaoto <inochiama@outlook.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-05-09platform: generic: thead: add Canaan Kendryte K230Yangyu Chen1-0/+5
Canaan Kendryte K230 SoC has T-Head C908 cores inside. The dt-binding has been merged into the linux kernel [1]. However, it has early version of C908 core which does not have Sscofpmf and need to use T-Head PMU extension. Thus, we add a K230 compatible string to thead_generic_match and set quirk for T-Head PMU. [1] https://lore.kernel.org/linux-riscv/tencent_4D85743622F39109466913393EE2F6C5980A@qq.com/ Signed-off-by: Yangyu Chen <cyy@cyyself.name> Reviewed-by: Inochi Amaoto <inochiama@outlook.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-05-09platform: generic: thead: separate T-Head PMU ErrataYangyu Chen2-2/+7
As Guo Ren said from the kernel mailing list [1], future T-Head CPUs, including the newer versions of T-Head C908, will feature standard Sscofpmf extension. For these CPUs, T-Head's implementation of PMU Overflow Interrupts may not needed anymore. In this case, we shouldn't apply T-Head PMU for all T-Head CPUs. Thus, this patch separated T-Head PMU errata. [1] https://lore.kernel.org/linux-riscv/Zh9sUUUT09LZb0MO@gmail.com/ Signed-off-by: Yangyu Chen <cyy@cyyself.name> Reviewed-by: Inochi Amaoto <inochiama@outlook.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-05-09platform: andes: Change all occurrences of andes45 to andesBen Zong-You Xie11-84/+86
To make the framework suit all Andes CPUs, change all occurrences of andes45 to andes. In addition, we fix some coding style problems and remove an unused macro in andes.h. Signed-off-by: Ben Zong-You Xie <ben717@andestech.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-05-09platform: andes: Rename files with the prefix andes45Ben Zong-You Xie3-0/+0
Rename files with the prefix andes45 to andes. Signed-off-by: Ben Zong-You Xie <ben717@andestech.com> Reviewed-by: Anup Patel <anup@brainfault.org>