summaryrefslogtreecommitdiff
path: root/lib/utils
AgeCommit message (Collapse)Author
2024-10-25lib: utils/ipi: Use sbi_domain_root_add_memrange() for ACLINT mswiAnup Patel
The sbi_domain_root_add_memrange() should be preferred for creating multiple memregions over a range. Update ACLINT mswi driver to use sbi_domain_root_add_memrange() instead of explicitly registering memregions. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Samuel Holland <[email protected]>
2024-09-27lib: utils/ipi: Fix hartid wrongly used as hart indexSamuel Holland
Since commit 78c667b6fc07 ("lib: sbi: Prefer hartindex over hartid in IPI framework"), The .ipi_clear callback functions take a hart index, not a hartid. However, these warm_init functions were never updated. Fixes: 78c667b6fc07 ("lib: sbi: Prefer hartindex over hartid in IPI framework") Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-09-26lib: sbi: Update sbi_domain_is_assigned_hart() to take a hart indexSamuel Holland
This removes redundant hartid to hartindex conversions from four call sites and provides a net reduction in code size. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-09-25lib: utils/irqchip: Look up IMSIC data by hart indexSamuel Holland
This avoids needing to map a hartid to a hart index. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-24lib: Delete redundant `ulong`Zhang RunMin
In `csr_read_allowed` and `csr_write_allowed` macros, has already converted second param to `ulong`. So delete redundant `ulong` where uses csr_read/write_allowed macros. Signed-off-by: Zhang RunMin <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-24lib: utils: fdt_domain: Make opensbi-domain optional in CPU nodeGregor Haas
The domain_support.md documentation states that "the HART to domain instance assignment can be parsed from the device tree using *optional* DT property opensbi-domain in each CPU DT node". However, the current implementation does not treat this parameter as optional when determining which HARTs to assign to a freshly discovered domain from the device tree, causing an effect where every HART in the system must be explicitly assigned to a domain only if a domain is specified in the device tree. Instead, this patch simply ignores CPUs that do not specify a domain, and does not attempt to assign them into the recently discovered domain. Signed-off-by: Gregor Haas <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-24util: atcsmu.c: modify sbi_printf() formattingYu Chien Peter Lin
Beautify multi-line printing. Signed-off-by: Leo Yu-Chi Liang <[email protected]> Reviewed-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-24util: atcsmu.c: fix typo "%s/hard/hart/"Leo Yu-Chi Liang
%s/hard/hart Signed-off-by: Leo Yu-Chi Liang <[email protected]> Reviewed-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-24lib: utils/serial: Pass the FDT to fdt_serial_init()Samuel Holland
Indicate that this function does not modify the FDT blob, and deduplicate the call to fdt_get_address(). Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-24lib: utils/reset: Pass the FDT to fdt_reset_init()Samuel Holland
Indicate that this function does not modify the FDT blob, and deduplicate the call to fdt_get_address(). Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-24lib: utils/timer: Constify FDT pointers in parsing functionsSamuel Holland
Indicate that none of these functions modify the devicetree by constifying the parameter type. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-24lib: utils/serial: Constify FDT pointers in parsing functionsSamuel Holland
Indicate that none of these functions modify the devicetree by constifying the parameter type. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-24lib: utils/reset: Constify FDT pointers in parsing functionsSamuel Holland
Indicate that none of these functions modify the devicetree by constifying the parameter type. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-24lib: utils/regmap: Constify FDT pointers in parsing functionsSamuel Holland
Indicate that none of these functions modify the devicetree by constifying the parameter type. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-24lib: utils/irqchip: Constify FDT pointers in parsing functionsSamuel Holland
Indicate that none of these functions modify the devicetree by constifying the parameter type. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-24lib: utils/ipi: Constify FDT pointers in parsing functionsSamuel Holland
Indicate that none of these functions modify the devicetree by constifying the parameter type. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-24lib: utils/i2c: Constify FDT pointers in parsing functionsSamuel Holland
Indicate that none of these functions modify the devicetree by constifying the parameter type. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-24lib: utils/gpio: Constify FDT pointers in parsing functionsSamuel Holland
Indicate that none of these functions modify the devicetree by constifying the parameter type. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-24lib: utils/fdt: Constify FDT parsing functionsSamuel Holland
Distinguish between functions which modify the devicetree and those which only extract information from it. Other than the iterators in fdt_domain.c, this is a mechanical conversion. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-23lib: utils: fdt_domain: Use consistent device-tree address when next-arg1 is ↵Yu Chien Peter Lin
missing The diagram shown below illustrates the boot-flow involving OP-TEE OS initialization. (1)-----------+ | U-Boot SPL | +------------+ | v (2)-------------------------------------------------------------+ | OpenSBI (fw_dynamic) | | (4)------------------------+ | | | optee dispatcher driver | | +-----------------+-------^---------|-------+------------------+ M-mode | | | ---------+--[trusted domain]---+----.----+--[untrusted domain]------- S-mode | (coldboot domain) | | | v | | v (3)---------------------------+ |(5)----------------------------+ | OP-TEE OS | | | U-Boot | +----------------------------+ | +-----------------------------+ | | | v |(6)----------------------------+ | | Linux | | +-----------------------------+ As OP-TEE OS has device-tree node fixups that need to be passed through to the next boot stages, e.g. the reserved memory node: reserved-memory { #address-cells = <2>; #size-cells = <2>; ranges; optee_core@f1000000 { no-map; reg = <0x0 0xf1000000 // OP-TEE OS base address 0x0 0x01000000>; }; <...> }; Instead of using 0x0 as the default value, allow identical next-arg1 to be used by non-coldboot domain (i.e., untrusted domain) when the property is not provided. Also, update the description of next-arg1 property in the document. Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Alvin Chang <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-07-23lib: utils/fdt: Add support for parsing riscv,isa-extensionsConor Dooley
A new property has been added, with an extensive rationale at [1], that can be used in place of "riscv,isa" to indicate what extensions are supported by a given platform that is a list of strings rather than a single string. There are some differences between the new property, "riscv,isa-extensions" and the incumbent "riscv,isa" - chief among them for the sake of parsing being the list of strings, as opposed to a string. Another advantage is strictly defined meanings for each string in a dt-binding, rather than deriving meaning from RVI standards. This may likely to some divergence over time, but, at least for now, there's no relevant differences between the two for an M-Mode program. Add support for the new property in OpenSBI, prioritising it, before falling back to the, now deprecated, "riscv,isa" property if it is not present. Link: https://lore.kernel.org/all/20230702-eats-scorebook-c951f170d29f@spud/ [1] Signed-off-by: Conor Dooley <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-07-04Makefile: change to using .carray.c for carray filesBen Dooks
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/[email protected]/ Reported-by: Ivan Orlov <[email protected]> Suggested-by: Andrew Jones <[email protected]> Signed-off-by: Ben Dooks <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-06-13lib: serial: fix RX path in litex-uartGabriel Somlo
When used to read characters from the terminal (e.g., when the SBI console is used via ecall from linux with `console=hvc0`), we must acknowledge receipt of each character to "pop" it off the LiteUART hardware queue, and allow the next character to be made available. Fixes: 52af6e4b ("lib: utils: Add LiteX UART support") Suggested-by: Dolu1990 <[email protected]> Signed-off-by: Gabriel Somlo <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-06-13lib: utils/reset: Try initializing all reset devices in dtXiang W
In DT, multiple reset devices may use the same driver, and they may have different priorities. If rc is returned after the first initialization, the highest priority device may be lost. Fixes: a73ff043e991 (lib: utils/reset: Fix fdt_reset to search for more dt nodes) Signed-off-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-06-13lib: utils/reset: Fix fdt_reset to search for more dt nodesXiang W
If there are multiple dt nodes, the previous code only tries to match the first one, which may lose initialization. Signed-off-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-06-13lib: utils/reset: Skip initialize reset when dt is not enabledXiang W
When the dt node has a status property and the value is not ok or okay, skip initializing reset. Signed-off-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-06-13lib: utils/serial: Fix fdt_serial to match more dt nodesXiang W
If there are multiple dt nodes, the previous code only tries to match the first one, which may lose initialization. Signed-off-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-06-13lib: utils/serial: Skip initialize serial when dt is not enabledXiang W
When the dt node has a status property and the value is not ok or okay, skip initializing serial. Signed-off-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-06-13lib: utils/irqchip: Skip initialize irqchip when dt is not enabledXiang W
When the dt node has a status property and the value is not ok or okay, skip initializing irqchip. Signed-off-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-06-13lib: utils/timer: Skip initialize timer when dt is not enabledXiang W
When the dt node has a status property and the value is not ok or okay, skip initializing timer. Signed-off-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-06-13lib: utils/ipi: Skip initialize ipi when dt is not enabledXiang W
When the dt node has a status property and the value is not ok or okay, skip initializing ipi. Signed-off-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-06-05lib: utils/fdt: Fix DT property for APLIC delegationAnup Patel
During Linux AIA driver review, the APLIC DT property for interrupt delegation was renamed to "riscv,delegation" so let's use the new DT property name and fallback to old DT property name if the new DT property name is not available. Fixes: 34612193af92 ("lib: utils/irqchip: Add FDT based driver for APLIC") Signed-off-by: Anup Patel <[email protected]>
2024-05-23lib: utils/gpio: respect flag GPIO_FLAG_ACTIVE_LOWInochi Amaoto
"gpio-poweroff" and "gpio-restart" always set gpio to high to active the function, but some chips need a low signal to active. Fortunately, it can be achieved by setting GPIO_FLAG_ACTIVE_LOW for the gpio. Implement this flag support for the gpio library so the gpio reset can function well. Signed-off-by: Inochi Amaoto <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-05-23lib: utils/irqchip: Add sanity checks in imsic_get_data() and ↵Cyan Yang
imsic_get_target_file() Add extra sanity checks to prevent the caller getting the invalid result from imsic_get_data() or imsic_get_target_file() when imsic is not initialized correctly. Signed-off-by: Cyan Yang <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-05-16lib: utils/irqchip: Check before initializing imsicCheng Yang
The current mlevel imsic check is only for the platform, which may cause hart without imsic in the platform to trigger an illegal instruction exception when initializing imsic. For example, the platform contains a management hart that only supports wired interrupts. This patch will check if each hart supports Smaia extension before doing imsic initialization to avoid triggering illegal instruction exceptions. Signed-off-by: Cheng Yang <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-05-15utils/reset: Add SG2042 hwmon MCU support.Inochi Amaoto
SG2042 uses an onboard MCU to provide reset function. Add reset driver to support this onboard MCU. Signed-off-by: Inochi Amaoto <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-04-10lib: utils: check correct value in fdt_node_offset_by_compatibleHeinrich Schuchardt
After calling fdt_node_offset_by_compatible() we must check its return value and not an unrelated value. Addresses-Coverity-ID: 1584993 Logically dead code Fixes: 67ce5a763cfb ("platform: generic: Add support for specify coldboot harts in DT") Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-04-05lib: utils/timer: Optimize current hart scratch accessSamuel Holland
The address of the local scratch area is stored in each hart's mscratch CSR. It is more efficient to read the CSR than to compute the address from the hart ID. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-03-19lib: sbi: Remove regs paramter of sbi_irqchip_process()Anup Patel
The irqchip handlers will typically not need pointer to trap registers so remove regs parameter of sbi_irqchip_process(). Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Samuel Holland <[email protected]> Tested-by: Samuel Holland <[email protected]> Reviewed-by: Clément Léger <[email protected]>
2024-02-20platform: generic: Add support for specify coldboot harts in DTCheng Yang
Added support for the generic platform to specify the set of coldboot hart in DT. If not specified in DT, all harts are allowed to coldboot as before. The functions related to sbi_hartmask are not available before coldboot, so I used bitmap, and added a new bitmap_test() function to test whether a certain bit of the bitmap is set. Signed-off-by: Cheng Yang <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-27lib: utils/timer: mtimer: only use regname for aclintInochi Amaoto
The parser will fail if the timer is clint timer and has regname property. As the regname is only meaningful for aclint, it is more robust to only check regname for aclint timer. Fixes: 6112d58 ("lib: utils/fdt: Allow to use reg-names when parsing ACLINT") 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-12-19lib: sbi: Using one array to define the name of extensionsYong-Xuan Wang
Define an array sbi_hart_ext to map extension ID and name , and use it for ISA parsing and printing out the supported extensions. Signed-off-by: Yong-Xuan Wang <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-11lib: utils/fdt: Allow to use reg-names when parsing ACLINTInochi Amaoto
Currently, the fdt_parse_aclint_node() follows a fixed order to parse ACLINT timer. This may cause the undesirable result when the ACLINT device does not support mtime without adding an empty entry for it in the DT. To be robust, make fdt_parse_aclint_node() support "reg-names" property, so it can parse the DT in an order independent way. For compatibility, fdt_parse_aclint_node() only use "reg-names" when parsing ACLINT timer, and will fallback to the old way if "reg-names" property is not found. Link: https://lore.kernel.org/all/20231114-skedaddle-precinct-66c8897227bb@squawk/ Signed-off-by: Inochi Amaoto <[email protected]> Reviewed-by: Anup patel <[email protected]>
2023-12-06lib: utils: fdt_pmu: Do not iterate over the fdt_pmu_evt_select tableYu Chien Peter Lin
The valid entry count is tracking by hw_event_count so there is no need to check the whole table. Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-06lib: utils: fdt_pmu: Make the fdt_pmu_evt_select table global variableYu Chien Peter Lin
To allow platform override pmu_init() filling the translation table fdt_pmu_evt_select[] when PMU node doesn't provide such information, we need to share the table and its entry counter with other .c file. We also define the structures of PMU property in fdt_helper.h, so we can initialize the mappings in arrays. Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-06lib: utils: fdt_fixup: Allow preserving PMU propertiesYu Chien Peter Lin
Add a Kconfig option to control PMU fixup, so the next stage software can dump the PMU node including event mapping information for debugging purposes. Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-06sbi: sbi_pmu: Improve sbi_pmu_init() error handlingYu Chien Peter Lin
This patch makes the following changes: - As sbi_platform_pmu_init() returns a negative error code on failure, let sbi_pmu_init() print out the error code with sbi_dprintf(). - In order to distinguish the SBI_EFAIL error returned by sbi_pmu_add_*_counter_map(), return SBI_ENOENT to indicate that fdt_pmu_setup() failed to locate "riscv,pmu" node, and generic_pmu_init() ignores such case. Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Reviewed-by: Lad Prabhakar <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2023-12-06lib: ipi: Adjust Andes PLICSW to single-bit-per-hart schemeLeo Yu-Chi Liang
The old scheme doesn't allow sending hart0 self-IPI as the corresponding bit on pending register is hardwired to 0, this could lead to unhandle IPIs on SMP systems, esp. on single-core. Furthermore, the limitation of old scheme is 8-core, instead of reserving source hart information, we assign bit (x + 1) as the enable and pending bit of hartx, this also expands the bootable hart number. The following diagram shows the enable bits of the new scheme on 32-core Andes platform. Pending regs: 0x1000 x---0---0---0---0------0---0 Pending hart ID: 0 1 2 3 ... 30 31 Interrupt ID: 0 1 2 3 4 ... 31 32 | | | | | | | Enable regs: 0x2000 x---1---0---0---0-...--0---0---> hart0 | | | | | | | 0x2080 x---0---1---0---0-...--0---0---> hart1 | | | | | | | 0x2100 x---0---0---1---0-...--0---0---> hart2 | | | | | | | 0x2180 x---0---0---0---1-...--0---0---> hart3 . . . . . . . . . . . . . . . . . . . . . 0x2f00 x---0---0---0---0-...--1---0---> hart30 | | | | | | | 0x2f80 x---0---0---0---0-...--0---1---> hart31 <-------- word 0 -------><--- word 1 ---> To send IPI to hart0, for example, another hart (including hart0 itself) will set bit 1 of first word on the pending register. We also fix indentation in andes_plicsw.h along with this patch. Fixes: ce7c490719ed ("lib: utils/ipi: Add Andes fdt ipi driver support") Signed-off-by: Leo Yu-Chi Liang <[email protected]> Reviewed-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Randolph <[email protected]> Reported-by: Lad Prabhakar <[email protected]> Link: https://lists.infradead.org/pipermail/opensbi/2023-October/005665.html Reviewed-by: Lad Prabhakar <[email protected]> Tested-by: Lad Prabhakar <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-11-26lib: sbi: Allow relaxed MMIO writes in device ipi_clear() callbackAnup Patel
Currently, there are no barriers before or after the ipi_clear() device callback which forces ipi_clear() device callback to always use non-relaxed MMIO writes. Instead of above, we use wmb() in after the ipi_clear() device callback which pairs with the wmb() done before the ipi_send() device callback. This also allows device ipi_clear() callback to use relaxed MMIO writes. Signed-off-by: Anup Patel <[email protected]> Reported-by: Bo Gan <[email protected]>