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.
This commit is contained in:
Sönke Holz 2025-01-13 15:33:56 +01:00
parent 0d11e70cfe
commit e88594005b
2 changed files with 12 additions and 7 deletions

View file

@ -189,9 +189,6 @@ DEVICETREE_DRIVER(BCM2835TimerDriver, compatibles_array);
// https://www.kernel.org/doc/Documentation/devicetree/bindings/timer/brcm,bcm2835-system-timer.txt // https://www.kernel.org/doc/Documentation/devicetree/bindings/timer/brcm,bcm2835-system-timer.txt
ErrorOr<void> BCM2835TimerDriver::probe(DeviceTree::Device const& device, StringView) const ErrorOr<void> 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())); auto const interrupts = TRY(device.node().interrupts(DeviceTree::get()));
if (interrupts.size() != 4) if (interrupts.size() != 4)
return EINVAL; // The devicetree binding requires 4 interrupts. return EINVAL; // The devicetree binding requires 4 interrupts.

View file

@ -47,15 +47,23 @@ ErrorOr<void> Management::scan_node_for_devices(::DeviceTree::Node const& node)
auto& device = m_devices.get(&child).release_value(); 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)) { if (child.is_compatible_with("simple-bus"sv)) {
TRY(scan_node_for_devices(child)); TRY(scan_node_for_devices(child));
continue; 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. // 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<IterationDecision> { TRY(maybe_compatible->for_each_string([this, &device](StringView compatible_entry) -> ErrorOr<IterationDecision> {
auto maybe_driver = m_driver_map.get(compatible_entry); auto maybe_driver = m_driver_map.get(compatible_entry);