"Das U-Boot" Source Tree

riscv: Fallback to riscv,isa

Update the cpu probing to fallback to "riscv,isa" property if
"riscv,isa-extensions" is not available and modify the riscv CMO code
to use the block size that was probed during cpu setup.

Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>

authored by

Mayuresh Chitale and committed by
Leo Yu-Chi Liang
4492c8db ab15e20e

+25 -72
+21 -50
arch/riscv/cpu/cpu.c
··· 595 595 #if CONFIG_IS_ENABLED(RISCV_MMODE) 596 596 return csr_read(CSR_MISA) & (1 << (ext - 'a')); 597 597 #elif CONFIG_CPU 598 - char sext[2] = {ext}; 599 - struct udevice *dev; 600 - const char *isa; 601 - int ret, i; 602 - 603 - uclass_find_first_device(UCLASS_CPU, &dev); 604 - if (!dev) { 605 - debug("unable to find the RISC-V cpu device\n"); 606 - return false; 607 - } 608 - 609 - ret = dev_read_stringlist_search(dev, "riscv,isa-extensions", sext); 610 - if (ret >= 0) 611 - return true; 612 - 613 - /* 614 - * Only if the property is not found (ENODATA) is the fallback to 615 - * riscv,isa used, otherwise the extension is not present in this 616 - * CPU. 617 - */ 618 - if (ret != -ENODATA) 619 - return false; 620 - 621 - isa = dev_read_string(dev, "riscv,isa"); 622 - if (!isa) 623 - return false; 624 - 625 - /* 626 - * Skip the first 4 characters (rv32|rv64). 627 - */ 628 - for (i = 4; i < sizeof(isa); i++) { 629 - switch (isa[i]) { 630 - case 's': 631 - case 'x': 632 - case 'z': 633 - case '_': 634 - case '\0': 635 - /* 636 - * Any of these characters mean the single 637 - * letter extensions have all been consumed. 638 - */ 639 - return false; 640 - default: 641 - if (isa[i] == ext) 642 - return true; 643 - } 644 - } 645 - 646 - return false; 598 + return __riscv_isa_extension_available(ext); 647 599 #else /* !CONFIG_CPU */ 648 600 #warning "There is no way to determine the available extensions in S-mode." 649 601 #warning "Please convert your board to use the RISC-V CPU driver." ··· 679 631 680 632 int riscv_cpu_setup(void) 681 633 { 682 - int __maybe_unused ret; 634 + int ret = -ENODEV, ext_count, i; 635 + const char *isa, **exts; 636 + struct udevice *dev; 637 + 638 + uclass_find_first_device(UCLASS_CPU, &dev); 639 + if (!dev) { 640 + debug("unable to find the RISC-V cpu device\n"); 641 + return ret; 642 + } 643 + 644 + ext_count = dev_read_string_list(dev, "riscv,isa-extensions", &exts); 645 + if (ext_count > 0) { 646 + for (i = 0; i < ext_count; i++) 647 + match_isa_ext(exts[i], exts[i] + strlen(exts[i])); 648 + } else { 649 + isa = dev_read_string(dev, "riscv,isa"); 650 + if (!isa) 651 + return ret; 652 + riscv_parse_isa_string(isa); 653 + } 683 654 684 655 /* Enable FPU */ 685 656 if (supports_extension('d') || supports_extension('f')) {
+4 -22
arch/riscv/lib/cache.c
··· 24 24 CBO_INVAL 25 25 } riscv_cbo_ops; 26 26 static int zicbom_block_size; 27 - 27 + extern unsigned int riscv_get_cbom_block_size(void); 28 28 static inline void do_cbo_clean(unsigned long base) 29 29 { 30 30 asm volatile ("add a0, %0, zero\n" CBO_CLEAN(%0) :: ··· 79 79 cbo_op(CBO_INVAL, start, end); 80 80 } 81 81 82 - static int riscv_zicbom_init(void) 83 - { 84 - struct udevice *dev; 85 - 86 - if (!CONFIG_IS_ENABLED(RISCV_ISA_ZICBOM) || zicbom_block_size) 87 - return 1; 88 - 89 - uclass_first_device(UCLASS_CPU, &dev); 90 - if (!dev) { 91 - log_debug("Failed to get cpu device!\n"); 92 - return 0; 93 - } 94 - 95 - if (dev_read_u32(dev, "riscv,cbom-block-size", &zicbom_block_size)) 96 - log_debug("riscv,cbom-block-size DT property not present\n"); 97 - 98 - return zicbom_block_size; 99 - } 100 - 101 82 void invalidate_icache_all(void) 102 83 { 103 84 asm volatile ("fence.i" ::: "memory"); ··· 166 147 167 148 __weak void enable_caches(void) 168 149 { 169 - if (!riscv_zicbom_init()) 170 - log_info("Zicbom not initialized.\n"); 150 + zicbom_block_size = riscv_get_cbom_block_size(); 151 + if (!zicbom_block_size) 152 + log_debug("Zicbom not initialized.\n"); 171 153 }