summaryrefslogtreecommitdiff
path: root/platform/template
AgeCommit message (Collapse)Author
2026-06-12platform: Fix payload alignment when FW_TEXT_START isn't 2M/4M alignedAnirudh Srinivasan
The payload for FW_PAYLOAD needs to be placed at a 2M/4M aligned address (for 64/32 bit systems) and the current makefile uses FW_PAYLOAD_OFFSET to achieve this. This only works if FW_TEXT_START is already 2M/4M aligned. Most existing physical/virtual platforms have used a FW_TEXT_START of 0x0 or 0x80000000, so this hasn't been an issue so far. If, for example, FW_TEXT_START is 0x80000, the payload would end up placed at 0x280000 on a 64 bit system, which isn't a 2M aligned address. Update the makefile to use FW_PAYLOAD_ALIGN instead. This will ensure that the address picked for the payload is 2M/4M aligned irrespective of where FW_TEXT_START is. Signed-off-by: Anirudh Srinivasan <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-03-22lib: utils/irqchip: Add unique_id to plic, aplic, and imsic dataAnup Patel
Add a 32-bit unique ID to plic, aplic, and imsic data which can be used to differentiate multiple irqchip devices. Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2025-09-16include: sbi: Remove platform specific IPI initAnup Patel
The platform specfic IPI init is not need anymore because using IPI device rating multiple IPI devices can be registered in any order as part of the platform specific early init. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Samuel Holland <[email protected]> Tested-by: Nick Hu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2025-03-27lib: utils/serial: Add PXA UARTs supportJunhui Liu
The PXA variant of the uart8250 adds the UART Unit Enable bit (UUE) that needs to be set to enable the XScale PXA UART. And it is required for some RISC-V SoCs like the Spacemit K1 that implement the PXA UART. This introduces the "intel,xscale-uart" compatible to handle setting the UUE bit. Signed-off-by: Junhui Liu <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2024-11-28platform: Drop irqchip warm init and exit hooksSamuel Holland
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 <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-11-28lib: sbi_irqchip: Call driver warm_init from SBI coreSamuel Holland
Currently, each platform keeps track of which irqchip driver is in use and calls its warm init function. Since the generic platform may use multiple irqchip drivers, it has logic to track an array of drivers. The code is simplified and made common across platforms by treating warm init and exit as properties of the driver, not the platform. Then the platform's only role is to select and prepare a driver during cold boot. For now, only add a .warm_init hook, since none of the existing drivers need an .exit hook. It could be added in the future if needed. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-11-28lib: utils/irqchip: Move per-hart data from fdt_plic to plicSamuel Holland
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 <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-11-28lib: utils/irqchip: plic: Provide a hartindex to context mapSamuel Holland
This removes platform-specific arguments to plic_warm_irqchip_init(), which makes the driver independent from the platform after cold init, and allows for further refactoring. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-11-11platform: Drop IPI warm init and exit hooksSamuel Holland
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 <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-11-11lib: sbi_ipi: Move initial IPI clear to sbi_ipi_init()Samuel Holland
sbi_ipi_init() expects the platform warm init function to clear IPIs on the local hart, but there is already a generic function to do this. After this change, none of the existing drivers need a warm init callback. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-11-05platform: Drop timer warm init and exit hooksSamuel Holland
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 <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-11-05lib: sbi_timer: Call driver warm_init from SBI coreSamuel Holland
Currently, the platform's timer device is tracked in two places: the core SBI implementation has `timer_dev`, and the FDT timer layer has `current_driver`. The latter is used for warm initialization of the timer device. However, this warm init is not specific to FDT-based platforms; other platforms call exactly the same functions from the same point in the boot sequence. The code is simplified and made common across platforms by treating warm init and exit as properties of the driver, not the platform. Then the platform's only role is to select and prepare a driver during cold boot. For now, only add a .warm_init hook, since none of the existing drivers need an .exit hook. It could be added in the future if needed. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-07-24platform: Setup serial console device in early_init()Anup Patel
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 <[email protected]> Reviewed-By: Himanshu Chauhan <[email protected]>
2024-04-10firmware: remove FW_TEXT_STARTXiang W
Now opensbi can run at any address via dynamic relocation. We can remove FW_TEXT_START. Signed-off-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]> Tested-by: Anup Patel <[email protected]>
2024-02-24platform: Apply relocatable addressInochi Amaoto
Since jump and payload firmware support relocatable address, make general platform use runtime relocatable address. Signed-off-by: Inochi Amaoto <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-19lib: utils/irqchip: Add shared MMIO region for PLIC in root domainAnup Patel
On platforms with Smepmp, the MMIO regions accessed by M-mode need to be explicitly marked with M-mode only read/write or shared (both (M-mode and S-mode) read/write permission. If the above is not done then runtime PLIC access from M-mode on platforms with Smepmp will result in access fault when further results in CPU hotplug not working. Signed-off-by: Anup Patel <[email protected]>
2023-06-05platform: Allow platforms to specify heap sizeAnup Patel
We extend struct sbi_platform and struct sbi_scratch to allow platforms specify the heap size to the OpenSBI firmwares. The OpenSBI firmwares will use this information to determine the location of heap and provide heap base address in per-HART scratch space. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Andrew Jones <[email protected]>
2023-01-06treewide: Replace TRUE/FALSE with true/falseBin Meng
C language standard uses true/false for the boolean type. Let's switch to that for better language compatibility. Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Anup Patel <[email protected]> Reviewed-by: Samuel Holland <[email protected]> Tested-by: Samuel Holland <[email protected]>
2022-08-08platform: Remove redundant config.mk from all platformsAnup Patel
The options defined in config.mk can be specified in objects.mk of each platform so let us remove config.mk from all platforms. Signed-off-by: Anup Patel <[email protected]> Tested-by: Andrew Jones <[email protected]> Acked-by: Atish Patra <[email protected]> Tested-by: Atish Patra <[email protected]>
2022-08-08lib: utils/irqchip: Use kconfig for enabling/disabling driversAnup Patel
We update irqchip drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate irqchip drivers for each platform. Signed-off-by: Anup Patel <[email protected]> Tested-by: Andrew Jones <[email protected]> Acked-by: Atish Patra <[email protected]> Tested-by: Atish Patra <[email protected]>
2022-08-08lib: utils/ipi: Use kconfig for enabling/disabling driversAnup Patel
We update ipi drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate ipi drivers for each platform. Signed-off-by: Anup Patel <[email protected]> Tested-by: Andrew Jones <[email protected]> Acked-by: Atish Patra <[email protected]> Tested-by: Atish Patra <[email protected]>
2022-08-08lib: utils/timer: Use kconfig for enabling/disabling driversAnup Patel
We update timer drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate timer drivers for each platform. Signed-off-by: Anup Patel <[email protected]> Tested-by: Andrew Jones <[email protected]> Acked-by: Atish Patra <[email protected]> Tested-by: Atish Patra <[email protected]>
2022-08-08lib: utils/serial: Use kconfig for enabling/disabling driversAnup Patel
We update serial drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate serial drivers for each platform. Signed-off-by: Anup Patel <[email protected]> Tested-by: Andrew Jones <[email protected]> Acked-by: Atish Patra <[email protected]> Tested-by: Atish Patra <[email protected]>
2022-08-08Makefile: Add initial kconfig support for each platformAnup Patel
We extend the top-level makefile to allow kconfig based configuration for each platform where each platform has it's own set of configs with "defconfig" being the default config. Signed-off-by: Anup Patel <[email protected]> Tested-by: Andrew Jones <[email protected]> Acked-by: Atish Patra <[email protected]> Tested-by: Atish Patra <[email protected]>
2022-04-17lib: utils/serial: support 'reg-offset' propertyZong Li
reg-offset property is used for offset to apply to the mapbase from the start of the registers in 8250 UART. In Linux kernel, it has been handled in 8250 UART driver. dt-bindings: <linux>/Documentation/devicetree/bindings/serial/8250.yaml Signed-off-by: Zong Li <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2021-09-26lib: sbi: Add timer frequency to struct sbi_timer_deviceAnup Patel
Generic mdelay() and udelay() functions can be provided by the sbi_timer framework if timer frequency is available in the timer instance provided by the platform support or timer driver. This patch adds timer frequency (timer_freq) member in the struct sbi_timer_device for above purpose. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Xiang W <[email protected]>
2021-08-14lib: utils/timer: Allow separate base addresses for MTIME and MTIMECMPAnup Patel
We extend the ACLINT library to support separate base addresses for MTIME and MTIMECMP registers. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2021-06-24platform: Replace CLINT library usage with ACLINT libraryAnup Patel
The ACLINT devices are backward compatible with SiFive CLINT so we replace all CLINT library usage in various platforms with ACLINT library. As a result of this replacement, the CLINT library is not used by any part of OpenSBI hence we remove it. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Xiang W <[email protected]>
2021-04-28lib: sbi: Simplify system reset platform operationsAnup Patel
Instead of having system_reset_check() and system_reset() callbacks in platform operations, it will be much simpler for reset driver to directly register these operations as a device to the sbi_system implementation. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Alistair Francis <[email protected]>
2021-04-28lib: sbi: Simplify ipi platform operationsAnup Patel
Instead of having ipi_send() and ipi_clear() callbacks in platform operations, it will be much simpler for ipi driver to directly register these operations as a device to sbi_ipi implementation. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Alistair Francis <[email protected]>
2021-04-28lib: sbi: Simplify timer platform operationsAnup Patel
Instead of having timer_value(), timer_event_start(), and timer_event_stop() callbacks in platform operations, it will be much simpler for timer driver to directly register these operations as device to the sbi_timer implementation. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Alistair Francis <[email protected]>
2021-04-28lib: sbi: Simplify console platform operationsAnup Patel
Instead of having console_putc() and console_getc() callbacks in platform operations, it will be much simpler for console driver to directly register these operations as device to the sbi_console implementation. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Alistair Francis <[email protected]> Reviewed-by: Xiang W <[email protected]>
2021-01-18platform: template: Fix compile errorAnup Patel
This clint driver init functions were incorrectly used in template platform which resulted in compile error. This patch fixes clint driver function usage in template platform. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-12-01lib: sbi: Improve system reset platform operationsAnup Patel
To implement the SBI SRST extension, we need two platform operations for system reset: 1) system_reset_check() - This operation will check whether given reset type and reason are supported by the platform 2) system_reset() - This operation will do the actual platform system reset and it will not return if reset type and reason are supported by the platform This patch updates system reset related code everywhere as-per above. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-10-18firmware: Remove FW_PAYLOAD_FDT_PATH compile-time optionAnup Patel
The FW_PAYLOAD_FDT_PATH compile-time option is replaced by FW_FDT_PATH compile-time option which is more flexible and common across all OpenSBI firmwares. This patch removes FW_PAYLOAD_FDT_PATH and updates related documentation to use FW_FDT_PATH. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-06-05firmware: Remove FW_PAYLOAD_FDT and related documentationAnup Patel
Now that no platform is using FW_PAYLOAD_FDT mechanism, we remove related code from Makefile and related documentation. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-05-23lib: utils: Allow CLINT functions to be used for multiple CLINTsAnup Patel
We extend CLINT cold init function to have a "struct clint_data *" parameter pointing to CLINT details. This allows platforms to use CLINT functions for multiple CLINT instances. When multiple CLINTs are present, the platform can also provide one of the CLINT as reference CLINT for other CLINTs. This will help CLINTs to sync their time value with reference CLINT using a time_delta computed in warm init function. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-05-23lib: utils: Allow PLIC functions to be used for multiple PLICsAnup Patel
We extend all PLIC functions to have a "struct plic_data *" parameter pointing to PLIC details. This allows platforms to use these functions for multiple PLIC instances. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-05-23lib: utils: Remove redundant parameters from PLIC init functionsAnup Patel
The "target_hart" and "hart_count" parameters of PLIC cold and warm init functions are only used for sanity checks and not required in PLIC initialization. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-04-27include: sbi_platform: Combine reboot and shutdown into one callbackAnup Patel
We can achieve shutdown, cold reboot, and warm reboot using just one sbi_platform callback so we combine system_reboot() and system_shutdown() callbacks into one system_reset() callback. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-04-27lib: No need to provide default PMP region using platform callbacksAnup Patel
The default (usually last) PMP region provides S-mode access to complete memory range not covered by other PMP regions. Currently, the default PMP region is described as platform specific PMP region which is not appropriate because all platforms need it and default PMP region should be part of generic library. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2020-03-14platform: Use one unified per-HART stack size macro for all platformsBin Meng
As of today all platforms use 8KB of per-HART stack hence there is no need for each platform to define its own macro or use the magic number. Create one macro for all platforms. Platform still can use its own version if needed. Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2020-03-14platform: Set per-HART stack size to 8KB in the template platform codesBin Meng
The template platform codes should set per-HART stack size to 8KB to avoid possible mistakes of future platform ports. Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2020-03-13include: Make sbi_current_hartid() as macro in riscv_asm.hAnup Patel
The sbi_current_hartid() being a regular function is quite expensive because for callers it is a function call instead of a direct CSR read. This patch converts sbi_current_hartid() into a macro in riscv_asm.h. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-03-11include: Remove disabled_hart_mask from sbi_platformAnup Patel
The disabled_hard_mask in sbi_platform is only 64bits wide so we cannot disable a HART with HARTID > 63. To tackle this, we remove disabled_hart_mask and replace it with hart_disabled() platform callback. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-02-05platform: Add an platform ops to return platform specific tlb flush limitAtish Patra
If a platform requires to perform a tlb full flush, they should set the tlb_range_flush_limit value to zero. However, corresponding platform API ignore the value and continue to return the default value. Add a platform ops to retrieve platform specific tlb range flush limit. The platform variable becomes redundant in presence of the platform ops. Take this opportunity to remove the variable as well. The default is still set to smallest page size in RISC-V (4KB), as there is no way to figure out a best value for all platforms. Individual platform should set it to the optimal value for their platform. Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2020-01-24platform: template: typo fix in system reboot/shutdown namesJiuyang Liu (Sequencer)
This patch does minor typo fix in system reboot/shutdown names in platform operations. Signed-off-by: Jiuyang Liu (Sequencer) <[email protected]> Reviewed-by: Alistair Francis <[email protected]> Signed-off-by: Anup Patel <[email protected]>
2020-01-02lib: utils: Support CLINT with 32bit MMIO access on RV64 systemAnup Patel
It is possible to have a CLINT implementation which supports only 32bit MMIO accesses on RV64 system so this patch extends our CLINT driver such that platform code can specify whether CLINT supports 64bit MMIO access. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra<[email protected]> Reviewed-by: Zong Li <[email protected]>
2019-09-10lib: provide a platform specific tlb range flush thresholdAtish Patra
Currently, the tlb range flush threshold is fixed and set to 4k for all platforms. However, it should be platform specific as it completely depends upon how platform actually implements sfence instruction. Define a platform feature that allows every individual platform to set different values. If a platform doesn't define it, just use a page size as the threshold. Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2019-08-16platform: Remove the ipi_sync method from all platforms.Atish Patra
OpenSBI manages outstanding TLB flush requests by queueing them in a fifo synchronously. An ipi sync which uses an atomic operation on MMIO address is no longer required. Remove the ipi sync method from platform header and all usage. Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>