summaryrefslogtreecommitdiff
path: root/platform
AgeCommit message (Collapse)AuthorFilesLines
2022-07-30lib: utils/serial: Initialize platform_uart_data to zeroAndrew Jones1-1/+1
While it doesn't look like there are any current cases of using uninitialized data, let's zero all the UART data members to be safe. Zero may not actually be better than a random number in some cases, so all structure members should still be validated before use, but at least zero is usually easier to debug than some random stack garbage... Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2022-06-13platform: Add HSM implementation for Allwinner D1Samuel Holland2-0/+216
Allwinner D1 contains a "PPU" power domain controller which can automatically power down/up the CPU power domain. This power domain includes the C906 core along with its CLINT and PLIC. This HSM implementation supports non-retentive hart suspend by: 1) Saving/restoring state that is lost during hart suspend, 2) Performing cache maintenance before/after hart suspend, 3) Configuring wakeup sources before hart suspend, and 4) Asking the PPU to power down the hart when it enters WFI. Since this HSM implementation is for a single-core SoC, it does not need to worry about concurrency or saving multiple instances of state. Reviewed-by: Anup Patel <anup@brainfault.org> Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-06-13lib: irqchip/plic: Factor out a context init functionSamuel Holland2-22/+16
This simplifies both the callers and the callees by removing duplicated code and consolidating the error handling. It also fixes two bugs in the process: 1) ie_words was one too large when plic->num_src was a multiple of 32. 2) plic_set_ie takes a 32-bit mask, not a Boolean value, so the FPGA platforms previously only enabled one out of every 32 interrupts. Reviewed-by: Anup Patel <anup@brainfault.org> Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-06-13platform: generic: add overrides for vendor extensionsMayuresh Chitale2-0/+32
Allow the vendor_ext_check and vendor_ext_provider APIs of the generic platform to be overridden by other platforms Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2022-05-14platform: generic: check if CPU node is enabledJan Remes1-0/+3
Ignore CPU nodes in FDT which are not enabled. Signed-off-by: Jan Remes <jan.remes@codasip.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2022-05-13platform: generic: Move Sifive platform overrides into own directoryAnup Patel4-6/+9
Let us move SiFive platform overrides for FU540 and FU740 into a separate directory so better maintainability. Other SoC vendors can also create their own directory under platform/generic. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com>
2022-05-13platform: generic: Generate platform override module list at compile-timeAnup Patel3-9/+13
Instead of having platform override module list hard-coded in the C source, we generate it using carray.sh at compile-time. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com>
2022-04-17lib: utils/serial: support 'reg-offset' propertyZong Li5-4/+10
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 <zong.li@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2022-02-15lib: utils/irqchip: Add FDT based driver for IMSICAnup Patel1-0/+12
We add simple FDT irqchip driver for IMSIC so that generic platform (and other FDT based platforms) can utilize common IMIC library. Signed-off-by: Anup Patel <anup.patel@wdc.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com>
2022-01-21platform: sifive_fu740: fix reset when watchdog is runningAurelien Jarno1-0/+25
When the watchdog is running the HiFive Unmatched board does not reboot properly and shuts down itself a few seconds after reboot, in the early stages of the u-boot loading. On a Linux kernel this happens when the da9063_wdt module is loaded. This does not happen if the module is unloaded before reboot or if the watchdog module is loaded with "stop_on_reboot=1". Fix that by stopping the watchdog before attempting to reset the board. This is done by zeroing the TWDSCALE field of CONTROL_D register, unless it was already set to 0. Reported-by: Tianon Gravi <tianon@debian.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Reviewed-by: Nikita Shubin <n.shubin@yadro.com> Tested-by: Nikita Shubin <n.shubin@yadro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2022-01-21platform: sifive_fu740: do not use a global in da9063_reset/shutdownAurelien Jarno1-5/+5
da9063_reset() and da9063_shutdown() take the chip address in argument (like similar functions), but in practice use the da9063 global struct instead. Fix that. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Reviewed-by: Nikita Shubin <n.shubin@yadro.com> Reviewed-by: Anup Patel <anup@brainfault.org> Reviewed-by: Xiang W <wxjstz@126.com>
2021-12-02lib: sbi: Improve fatal error handlingJessica Clarke1-0/+1
BUG and BUG_ON are not informative and are rather lazy interfaces, only telling the user that something went wrong in a given function, but not what, requiring the user to find the sources corresponding to their firmware (which may not be available) and figure out how that BUG(_ON) was hit. Even SBI_ASSERT in its current form, which does include the condition that triggered it in the output, isn't necessarily very informative. In some cases, the error may be fixable by the user, but they need to know the problem in order to have any hope of fixing it. It's also a nuisance for developers, whose development trees may have changed significantly since the release in question being used, and so line numbers can make it harder for them to understand which error case a user has hit. This patch introduces a new sbi_panic function which is printf-like, allowing detailed error messages to be printed to the console. BUG and BUG_ON are removed, since the former is just a worse form of sbi_panic and the latter is a worse version of SBI_ASSERT. Finally, SBI_ASSERT is augmented to take a set of arguments to pass to sbi_panic on failure, used like so (sbi_boot_print_hart's current error case, which currently manually calls sbi_printf and sbi_hart_hang): SBI_ASSERT(xlen >= 1, ("Error %d getting MISA XLEN\n", xlen)); The existing users of BUG are replaced with calls to sbi_panic along with informative error messages. BUG_ON and SBI_ASSERT were unused (and, in the case of SBI_ASSERT, remain unused). Many existing users of sbi_hart_hang should be converted to use either sbi_panic or SBI_ASSERT after this commit. Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com> Reviewed-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Atish Patra <atishp@rivosinc.com>
2021-11-12platform: sifive_fu740: add platform reset driverNikita Shubin1-0/+194
da9063 PMIC can be used to reset/shutdown the Sifive Unmatched board. shutdown is done simply by writing SHUTDOWN bit to DA9063_REG_CONTROL_F register. reset via setting WAKEUP bit in DA9063_REG_CONTROL_F register followed by masking POWER and POWER1 domains and setting STANDBY bit in DA9063_REG_CONTROL_A, originally discovered by Alexandre Ghiti on linux-riscv maillists. Tested-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Alexandre Ghiti <alexandre.ghiti@canonical.com> Tested-by: Alexandre Ghiti <alexandre.ghiti@canonical.com> Signed-off-by: Nikita Shubin <n.shubin@yadro.com>
2021-11-08platform: generic: move fdt_reset_init to final_initHeinrich Schuchardt1-10/+5
Move the fdt_reset_init() invocation from generic_early_init() to generic_final_init(). This allows to print error messages. Ignore the return value of fdt_reset_init() as we should not stop booting due to failure to initialize reset drivers. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-11-02include: sbi_utils: Introduce an helper to get fdt base addressAlexandre Ghiti6-9/+13
This simply adds an helper to get fdt address which is more explicit than sbi_scratch_thishart_arg1_ptr. Signed-off-by: Alexandre Ghiti <alexandre.ghiti@canonical.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-10-11lib: sbi: convert reset to listNikita Shubin2-2/+2
To support different handlers for different types of resets, we are adding a sbi_list of restart handlers. Instead of sbi_system_reset_set_device we use sbi_system_reset_add_device to reflect the actual meaning. Signed-off-by: Nikita Shubin <n.shubin@yadro.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-09-26lib: sbi: Add timer frequency to struct sbi_timer_deviceAnup Patel6-1/+14
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 <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-08-14lib: utils/timer: Allow separate base addresses for MTIME and MTIMECMPAnup Patel5-11/+34
We extend the ACLINT library to support separate base addresses for MTIME and MTIMECMP registers. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2021-08-07lib: utils/fdt: Change addr and size to uint64_tBin Meng1-1/+1
The maximum address and size encoded in DT are 64-bit numbers, so we should use uint64_t for 'addr' and 'size' in fdt_get_node_addr_size(). Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-07-27generic: fu740: add workaround for CIP-1200 errataDavid Abdurachmanov3-0/+39
Instruction TLB can fail to respect a non-global SFENCE thus we need to flush the TLB using SFENCE.VMA x0, x0 See full description of CIP-1200 in Errata_FU740-C000_20210205 from https://www.sifive.com/boards/hifive-unmatched Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-07-11platform: generic: Add PMU supportAtish Patra1-0/+30
Add PMU support for generic platform. Generic platform solely relies on the device tree to parse all pmu related information. If any event is not described in device tree, generic platform will not support it. Reviewed-by: Anup Patel <anup.patel@wdc.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2021-07-06platform: generic: Terminate platform.name with nullBin Meng1-1/+1
fw_platform_init() fills platform.name without considering the ending null character. Fix it. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-06-24platform: Replace CLINT library usage with ACLINT libraryAnup Patel6-39/+107
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 <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-06-11platform: andes/ae350: Drop plicsw_ipi_sync()Bin Meng1-2/+0
plicsw_ipi_sync() is a forward declaration but without the actual implementation. Drop it. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-06-11platform: andes/ae350: Drop plicsw_get_pending()Bin Meng1-6/+0
This is not used anywhere. Drop it. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-06-11platform: andes/ae350: Cosmetic fixes in plicsw.cBin Meng1-3/+3
- %s/CLINT/PLICSW - replace '.' with a space - add a space around * in plicsw_cold_ipi_init() Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-05-06platform: Remove sifive/fu540 platformBin Meng3-225/+0
Now that SiFive HiFive Unleashed board is using the generic platform support in OpenSBI, let's remove the old non-generic one. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-04-28lib: sbi: Simplify system reset platform operationsAnup Patel5-78/+57
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 <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2021-04-28lib: sbi: Simplify ipi platform operationsAnup Patel8-34/+9
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 <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2021-04-28lib: sbi: Simplify timer platform operationsAnup Patel10-61/+14
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 <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2021-04-28lib: sbi: Simplify console platform operationsAnup Patel8-33/+0
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 <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-04-28platform: Remove platform/theadGuo Ren4-221/+0
We could use platform/generic instead, and won't use platform/thead/c910 again. Signed-off-by: Guo Ren <guoren@linux.alibaba.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-03-03platform: implement K210 system resetHeinrich Schuchardt2-0/+28
Implement rebooting the K210 via the system reset extension. All reset types are treated in the same way. A request for shutdown results in a reboot. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-01-18platform: template: Fix compile errorAnup Patel1-2/+2
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 <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2021-01-07lib: sbi: Replace args with trap registers in ecall handlerAnup Patel1-9/+10
We had added args pointer in ecall handler to ensure that ecall handler only implements functionality and does not deal with SBI calling convention. This also helped us to keep SBI calling convention related code in one place at sbi_ecall_handler(). The Keystone Enclavce project needs access to the trap regsiters in their ecall handler so that they can context switch enclaves in custom SBI calls. To help the Keystone Enclave project, we replace the args pointer in ecall handler parameter with a const pointer to trap registers. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-12-16lib: utils: Remove fdt_domain_get() functionAnup Patel1-1/+0
The fdt_domain_get() function is now redundant because the fdt_domains_populate() function can explicitly register new domains using the sbi_domain_register() function. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-12-04platform: generic: Populate domains from FDTAnup Patel1-0/+9
The generic platform should populate domains from FDT using the domain FDT helper routines. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-12-01lib: sbi: Improve system reset platform operationsAnup Patel5-12/+46
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 <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-12-01platform: Remove dummy system reset functionsAnup Patel5-49/+0
Few platforms have dummy system reset functions so let's remove these dummy system reset functions to allow generic code deal with it in the right way. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-10-18platform: kendryte/k210: Add some padding for FDT fixupsAnup Patel1-0/+1
The Kendryte K210 platform has built-in DTB and does not provides FW_PAYLOAD_FDT_ADDR. This means the FDT fixups will be done on the built-in DTB in absence of FW_PAYLOAD_FDT_ADDR. This patch adds some padding in built-in DTB for FDT fixups. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-10-18firmware: Remove FW_PAYLOAD_FDT_PATH compile-time optionAnup Patel1-1/+3
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 <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-09-16platform: generic: Don't mark non-MMU HARTs as invalidAnup Patel1-5/+1
Currently, the generic platform fw_platform_init() marks non-MMU HARTs (e.g. E-core on SiFive Unleashed) as invalid. This means such non-MMU HARTs won't be allowed to go ahead by sbi_init(). The sbi_init() now has a check for next stage privilege mode when selecting coldboot HART. This check will force non-MMU HARTS (i.e. HARTs without S-mode) to proceed in warmboot path and wait in the HSM STOPPED state. This means we don't need to mark non-MMU HARTs as invalid in generic platform fw_platform_init(). Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-08-20platform: kendryte/k210: fixup FDTHeinrich Schuchardt1-0/+18
When passing the device tree to the next stage we should apply necessary device tree fix-ups first. These include: * fix up the CPU node in the device tree * fix up the PLIC node in the device tree * fix up the reserved memory node in the device tree Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-06-29config.mk: Update QEMU run command for generic and sifive fu540 platformsBin Meng2-2/+2
Since QEMU v5.1, if there is no "-bios" option provided, the default OpenSBI firmware will be loaded by QEMU as the BIOS automatically, hence to load fw_payload type image, we should explicitly pass the "-bios" option to QEMU. Signed-off-by: Bin Meng <bin.meng@windriver.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-06-17platform: Update Nuclei ux600 platform supportHuaqi Fang2-9/+79
Changes are made to support our FPGA evaluation board, it has DDR memory(0xA0000000-0xB0000000). * Adapt the config.mk to match FPGA evaluation board DDR memory address * Since the RISC-V CPU core frequency of FPGA might change, so we use the fixed TIMER frequency to measure the real CPU core frequency. * And the UART baudrate has to set to 57600bps for Nuclei FPGA evaluation board when CPU core frequency is about 8MHz, otherwise the UART input will not work correctly. Signed-off-by: Huaqi Fang <578567190@qq.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-06-15platform/lib: Allow the OS to map the regions that are protected by PMPAlexandre Ghiti4-0/+28
This is achieved by removing the 'no-map' property from the 'reserved-memory' node when PMP is present, otherwise we keep it as it offers a small protection if the OS does not map this region at all. A new callback in platform_override is introduced and allows to fixup the device-tree. It is used here to override this new default behaviour on SiFive Fu540 platforms that has an erratum that prevents S-mode software to access a PMP protected region using 1GB page table mapping. If PMP is present, telling the OS not to map the reserved regions does not add much protection since it only avoids access to regions that are already protected by PMP. But by not allowing the OS to map those regions, it creates holes in the OS system memory map and prevents the use of hugepages which would generate, among other benefits, less TLB miss. Signed-off-by: Alexandre Ghiti <alex@ghiti.fr> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-06-10platform: Add AE350 cache control SBIsNylon Chen5-1/+186
This patch contains the following AE350 specific SBIs: - get mcache_ctl status - get mmisc_ctl status - set mcache_ctl status - set mmisc_ctl status - I-cache operation - D-cache operation - enable/disable L1-I-cache prefetch - enable/disable L1-D-cache prefetch - enable/disable non-blocking load store - enable/disable write-around Signed-off-by: Nylon Chen <nylon7@andestech.com> Reviewed-by: Anup Patel <Anup.Patel@wdc.com> Reviewed-by: Atish Patra <Atish.Patra@wdc.com>
2020-06-10platform: Add AE350 platform specific SBI handlerNylon Chen2-3/+30
We add AE350 platform specific SBI handler to implement AE350 specific SBI calls. Signed-off-by: Nylon Chen <nylon7@andestech.com> Reviewed-by: Anup Patel <Anup.Patel@wdc.com> Reviewed-by: Atish Patra <Atish.Patra@wdc.com>
2020-06-05firmware: Remove FW_PAYLOAD_FDT and related documentationAnup Patel2-5/+4
Now that no platform is using FW_PAYLOAD_FDT mechanism, we remove related code from Makefile and related documentation. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-06-05platform: kendryte/k210: Use new mechanism of builtin DTBAnup Patel3-2/+12
We update kendryte/k210 to use new mechanism of having builtin DTB where we convert k210.dts to C source and further compile-n-link it with libplatsbi.a. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>