From e88594005bbe474291870c1cf9ed87dc0d8b72cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Holz?= Date: Mon, 13 Jan 2025 15:33:56 +0100 Subject: [PATCH] Kernel/DeviceTree: Ignore nodes with status != "okay" status = "okay" means the device is operational. We should ignore devices that have a different status property value. The BCM2835TimerDriver force disable hack can be removed, since that timer is disabled in the Pi 4 devicetree. But we have to introduce another hack that force enables the Pi 3 system timer, as we otherwise wouldn't have any timer that we support for the Pi 3. --- Kernel/Arch/aarch64/RPi/Timer.cpp | 3 --- Kernel/Firmware/DeviceTree/Management.cpp | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Kernel/Arch/aarch64/RPi/Timer.cpp b/Kernel/Arch/aarch64/RPi/Timer.cpp index 58796264afb..b381a742c8a 100644 --- a/Kernel/Arch/aarch64/RPi/Timer.cpp +++ b/Kernel/Arch/aarch64/RPi/Timer.cpp @@ -189,9 +189,6 @@ DEVICETREE_DRIVER(BCM2835TimerDriver, compatibles_array); // https://www.kernel.org/doc/Documentation/devicetree/bindings/timer/brcm,bcm2835-system-timer.txt ErrorOr BCM2835TimerDriver::probe(DeviceTree::Device const& device, StringView) const { - if (DeviceTree::get().is_compatible_with("raspberrypi,4-model-b"sv)) - return ENOTSUP; // HACK: The Pi 4 system timer doesn't appear to work on QEMU; only the generic ARM timer does. - auto const interrupts = TRY(device.node().interrupts(DeviceTree::get())); if (interrupts.size() != 4) return EINVAL; // The devicetree binding requires 4 interrupts. diff --git a/Kernel/Firmware/DeviceTree/Management.cpp b/Kernel/Firmware/DeviceTree/Management.cpp index 27a2219164e..372ecd7e59c 100644 --- a/Kernel/Firmware/DeviceTree/Management.cpp +++ b/Kernel/Firmware/DeviceTree/Management.cpp @@ -47,15 +47,23 @@ ErrorOr Management::scan_node_for_devices(::DeviceTree::Node const& node) auto& device = m_devices.get(&child).release_value(); + auto maybe_compatible = child.get_property("compatible"sv); + if (!maybe_compatible.has_value()) + continue; + + // FIXME: The Pi 3 System Timer is disabled in the devicetree, and only the generic ARM timer is enabled. The generic Arm timer on the Pi 3 is connected to the root interrupt controller, which we currently don't support. + bool const ignore_status_disabled = DeviceTree::get().is_compatible_with("raspberrypi,3-model-b"sv) && child.is_compatible_with("brcm,bcm2835-system-timer"sv); + + // The lack of a status property should be treated as if the property existed with the value of "okay". (DTspec 0.4 "2.3.4 status") + auto maybe_status = child.get_property("status"sv); + if (maybe_status.has_value() && maybe_status->as_string() != "okay" && !ignore_status_disabled) + continue; + if (child.is_compatible_with("simple-bus"sv)) { TRY(scan_node_for_devices(child)); continue; } - auto maybe_compatible = child.get_property("compatible"sv); - if (!maybe_compatible.has_value()) - continue; - // The compatible property is ordered from most specific to least specific, so choose the first compatible we have a driver for. TRY(maybe_compatible->for_each_string([this, &device](StringView compatible_entry) -> ErrorOr { auto maybe_driver = m_driver_map.get(compatible_entry);