Skip to content

Commit 6dc0f59

Browse files
committed
AOSCOS: LoongArch: Add ACPI compatibility for ISA I/O space reservation
This patch adds essential compatibility support for ACPI-based systems running on older firmware. Many older computers with old firmware still rely on this mechanism and are unlikely to receive futher firmeware updates. This change ensures proper ISA I/O space reservation across for them. Signed-off-by: Yinan Qin <a.elysia@proton.me>
1 parent b0b318f commit 6dc0f59

1 file changed

Lines changed: 38 additions & 25 deletions

File tree

arch/loongarch/kernel/setup.c

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -510,36 +510,49 @@ static int __init add_legacy_isa_io(struct fwnode_handle *fwnode,
510510
static __init int arch_reserve_pio_range(void)
511511
{
512512
struct device_node *np;
513+
struct fwnode_handle *fwnode;
513514

514-
for_each_node_by_name(np, "isa") {
515-
struct of_range range;
516-
struct of_range_parser parser;
515+
if (acpi_disabled) {
516+
for_each_node_by_name(np, "isa") {
517+
struct of_range range;
518+
struct of_range_parser parser;
517519

518-
pr_info("ISA Bridge: %pOF\n", np);
520+
pr_info("ISA Bridge: %pOF\n", np);
519521

520-
if (of_range_parser_init(&parser, np)) {
521-
pr_info("Failed to parse resources.\n");
522-
of_node_put(np);
523-
break;
524-
}
525-
526-
for_each_of_range(&parser, &range) {
527-
switch (range.flags & IORESOURCE_TYPE_BITS) {
528-
case IORESOURCE_IO:
529-
pr_info(" IO 0x%016llx..0x%016llx -> 0x%016llx\n",
530-
range.cpu_addr,
531-
range.cpu_addr + range.size - 1,
532-
range.bus_addr);
533-
if (add_legacy_isa_io(&np->fwnode, range.cpu_addr, range.size))
534-
pr_warn("Failed to reserve legacy IO in Logic PIO\n");
535-
break;
536-
case IORESOURCE_MEM:
537-
pr_info(" MEM 0x%016llx..0x%016llx -> 0x%016llx\n",
538-
range.cpu_addr,
539-
range.cpu_addr + range.size - 1,
540-
range.bus_addr);
522+
if (of_range_parser_init(&parser, np)) {
523+
pr_info("Failed to parse resources.\n");
524+
of_node_put(np);
541525
break;
542526
}
527+
528+
for_each_of_range(&parser, &range) {
529+
switch (range.flags & IORESOURCE_TYPE_BITS) {
530+
case IORESOURCE_IO:
531+
pr_info(" IO 0x%016llx..0x%016llx -> 0x%016llx\n",
532+
range.cpu_addr,
533+
range.cpu_addr + range.size - 1,
534+
range.bus_addr);
535+
if (add_legacy_isa_io(&np->fwnode, range.cpu_addr, range.size))
536+
pr_warn("Failed to reserve legacy IO in Logic PIO\n");
537+
break;
538+
case IORESOURCE_MEM:
539+
pr_info(" MEM 0x%016llx..0x%016llx -> 0x%016llx\n",
540+
range.cpu_addr,
541+
range.cpu_addr + range.size - 1,
542+
range.bus_addr);
543+
break;
544+
}
545+
}
546+
}
547+
} else {
548+
fwnode = acpi_alloc_fwnode_static();
549+
if (!fwnode) {
550+
pr_warn("Failed to allocate fwnode for legacy ISA\n");
551+
return 0;
552+
}
553+
if (add_legacy_isa_io(fwnode, LOONGSON_LIO_BASE, ISA_IOSIZE)) {
554+
pr_warn("Failed to reserve legacy IO in Logic PIO\n");
555+
acpi_free_fwnode_static(fwnode);
543556
}
544557
}
545558

0 commit comments

Comments
 (0)