summaryrefslogtreecommitdiff
path: root/lib/utils/reset
AgeCommit message (Collapse)AuthorFilesLines
2022-01-11lib: utils/sys: Extend HTIF library to allow custom base addressSDK_v2.0.0Anup Patel1-1/+11
Some of RISC-V emulators provide HTIF at fixed base address so for such emulators users have to hard-code HTIF base address in the linker script. To address this problem, we let users optionally provide fixed HTIF base address via platform support (or device tree). Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by: Atish Patra <atishp@rivosinc.com>
2021-11-12lib: utils/reset: separate driver init funcNikita Shubin1-16/+21
Move driver init code to separate function, so it can be reused elsewhere. 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-12lib: utils/reset: add priority to gpio resetNikita Shubin1-2/+8
Make gpio_system_reset_check return priority instead of just true/false. Make default 128 priority for reset/shutdown. 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-08lib: sbi: error handling in fdt_reset_init()Heinrich Schuchardt1-7/+6
The initialization of a reset driver may fail for various reasons, like a PMIC based reset driver not finding the required I2C driver. The return code of the init routine may take other error values than -ENODEV. If the initialization of a reset driver fails, this should not lead to the board hanging. It is enough that the reset driver does not call sbi_system_reset_add_device() to avoid invoking the driver for a device that could not be initialized. Change the return type of fdt_reset_init() to void. Print a message if an error occurs. 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 Ghiti1-1/+1
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-11-02lib: utils/reset: Register separate GPIO system reset devicesAnup Patel1-19/+41
Now that sbi_system support multiple system reset devices, we should register separate devices for GPIO restart and GPIO poweroff because DT describes these as separate devices with different compatible strings. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Dong Du <Dd_nirvana@sjtu.edu.cn>
2021-10-21lib: utils/irqchip: Automatically delegate T-HEAD PLIC accessOpenSBI-v0.9-78c2b19Samuel Holland1-8/+0
The T-HEAD PLIC implementation requires setting a delegation bit to allow access from S-mode. Now that the T-HEAD PLIC has its own compatible string, set this bit automatically from the PLIC driver, instead of reaching into the PLIC's MMIO space from another driver. Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-10-11lib: sbi: convert reset to listNikita Shubin3-3/+3
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-10-01lib: utils: identify supported GPIO reset methodsHeinrich Schuchardt1-23/+21
The GPIO reset driver supports reset and poweroff. But not all boards support both. gpio_system_reset_check() must detect this situation. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-09-26lib: utils/reset: use sbi_timer_mdelay() in gpio reset driverAnup Patel1-10/+3
We should use sbi_timer_mdelay() instead of custom gpio_mdelay() in the gpio reset driver. 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-09-14lib: utils/reset: Add a sunxi watchdog reset driverOpenSBI-v0.9-395ff7eSamuel Holland3-0/+80
One of the watchdogs in the D1 SoC provides a "soft reset" function, which allows software to immediately reset the entire SoC. Add a driver so it can implement the SBI system reset function. Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-09-14lib: utils/reset: Sort fdt_reset driver listSamuel Holland2-3/+3
In preparation for adding a new fdt_reset driver, ensure the existing lists are sorted alphabetically. Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-08-14lib: utils: Extend fdt_get_node_addr_size() for multiple register setsAnup Patel1-1/+1
We add "index" parameter to fdt_get_node_addr_size() API so that calling function can specify index of desired register set. This will allow fdt_get_node_addr_size() to handle DT nodes with multiple register sets. 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-27lib: utils: support both of gpio-poweroff, gpio-resetHeinrich Schuchardt2-2/+12
The generic GPIO reset driver has two entries in the match table: "gpio-poweroff", "gpio-reset". Only the first entry is considered by fdt_reset_init(). Define "gpio-poweroff" and "gpio-reset" as compatibility strings of two separate reset drivers. They still can share code. Fixes: e3d6919d10d7 ("lib: utils/reset: Add generic GPIO reset driver") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2021-07-27lib: utils: remove unused variable in fdt_reset_initHeinrich Schuchardt1-3/+0
The value of variable current_driver is unused. Remove the variable. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2021-07-17lib: utils/reset: Add generic GPIO reset driverGreen Wan3-0/+144
We add generic GPIO reset driver inspired from gpio-restart and gpio-poweroff drivers of Linux kernel. Signed-off-by: Green Wan <green.wan@sifive.com> Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2021-07-05lib: utils: reset: unify naming of 'sifive_test' deviceGreen Wan3-4/+4
Unify all the file and function names of 'sifive_test' device, to use the same prefix. This is also a preparatory patch for upcoming sifive reset device. Signed-off-by: Green Wan <green.wan@sifive.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-06-11lib: utils: missing initialization in thead_reset_initHeinrich Schuchardt1-4/+6
If property csr-copy does not exist, fdt_getprop() will return NULL and cnt will have a random value from the stack. Call clone_csrs() only if cnt is initialized to a non-zero value. Fixes: 49e422c5ad7a ("lib: utils: reset: Add T-HEAD sample platform reset driver") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-05-24lib: utils: Try other FDT drivers when we see SBI_ENODEVAnup Patel1-0/+3
We should try other FDT drivers when we see SBI_ENODEV returned by cold_init() of FDT driver. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-04-28lib: sbi: Simplify system reset platform operationsAnup Patel4-31/+28
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-22lib: utils: reset: Add T-HEAD sample platform reset driverGuo Ren5-0/+206
This driver is for T-HEAD test chip, fpga. It could work with all T-HEAD riscv processors: C9xx series. example1: (Using io-regs for reset) reset: reset-sample { compatible = "thead,reset-sample"; plic-delegate = <0xff 0xd81ffffc>; entry-reg = <0xff 0xff019050>; entry-cnt = <4>; control-reg = <0xff 0xff015004>; control-val = <0x1c>; csr-copy = <0x7f3 0x7c0 0x7c1 0x7c2 0x7c3 0x7c5 0x7cc>; }; example2: (Using csr-regs for reset) reset: reset-sample { compatible = "thead,reset-sample"; plic-delegate = <0xff 0xd81ffffc>; using-csr-reset; csr-copy = <0x7c0 0x7c1 0x7c2 0x7c3 0x7c5 0x7cc 0x3b0 0x3b1 0x3b2 0x3b3 0x3b4 0x3b5 0x3b6 0x3b7 0x3a0>; }; example3: (Only delegate plic enable to S-mode) reset: reset-sample { compatible = "thead,reset-sample"; plic-delegate = <0xff 0xd81ffffc>; }; After this patch, all T-HEAD c9xx would use platform/generic with fw_dynamic as default: CROSS_COMPILE=riscv64-linux-gnu- PLATFORM=generic FW_PIC=y /usr/bin/make The platform/thead will be deprecated. Signed-off-by: Guo Ren <guoren@linux.alibaba.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-12-01lib: sbi: Improve system reset platform operationsAnup Patel3-3/+12
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-05-23lib: utils: Extend fdt_find_match() ImplementationAnup Patel1-1/+1
We extend fdt_find_match() implementation by adding node offset parameter which represents the first node to match from. The improved fdt_find_match() can be used to find multiple match nodes. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-01lib: utils: Add simple FDT reset frameworkAnup Patel4-0/+126
We add simple reset framework which will select and use reset driver based on details in FDT passed by previous booting stage. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>