本文介绍了设备树不匹配:.probe 从未调用过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法理解设备树是如何工作的,或者特别是为什么这个驱动程序不会初始化.这是在 android 的 Rockchip 供应商内核中,版本 3.10

I'm having trouble understanding how device-tree works, or specifically why this driver won't init. This is in the rockchip vendor kernel for android, version 3.10

drivers/watchdog/rk29_wdt.c(减少可读性)

static const struct of_device_id of_rk29_wdt_match[] = {
    { .compatible = "rockchip,watch dog" }
};
static struct platform_driver rk29_wdt_driver = {
    .probe          = rk29_wdt_probe,
    [..]
            .of_match_table = of_rk29_wdt_match,
            .name   = "rk29-wdt",
    },
};

static int __init watchdog_init(void)
{
    printk("watchdog_init\n");
    return platform_driver_register(&rk29_wdt_driver);
}

这是SOC dtsi

arch/arm/boot/dts/rk3288.dtsi

    watchdog: wdt@2004c000 {
            compatible = "rockchip,watch dog";
            reg = <0xff800000 0x100>;
            clocks = <&pclk_pd_alive>;
            clock-names = "pclk_wdt";
            interrupts = <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>;
            rockchip,irq = <0>;
            rockchip,timeout = <2>;
            rockchip,atboot = <1>;
            rockchip,debug = <0>;
            status = "okay";
    };

然而,驱动程序的 .probe 函数永远不会被调用.它被编译并调用 __init 函数.我怀疑它与设备树条目不匹配有关?也许空间是一个问题?

however, the .probe function of the driver is never called. It is compiled in and the __init function is called. I suspect it has something to do witch the device tree entry not matching? Maybe the space is an issue?

或者在 .probe 之前运行其他任何东西来确定驱动程序是否应该继续?

此外,我不确定扁平树的工作原理,所以这可能是相关的:

Also i'm not sure how a flattened tree works, so maybe this is relevant:

arch/arm/mach-rockchip/rk3288

DT_MACHINE_START(RK3288_DT, "Rockchip RK3288 (Flattened Device Tree)")
    .smp            = smp_ops(rockchip_smp_ops),
    .map_io         = rk3288_dt_map_io,
    .init_time      = rk3288_dt_init_timer,
    .dt_compat      = rk3288_dt_compat,
    .init_late      = rk3288_init_late,
    .reserve        = rk3288_reserve,
    .restart        = rk3288_restart,
MACHINE_END

推荐答案

发生这种情况的可能方式有很多种,其中大部分都与驱动程序代码本身相去甚远.首先,单独的 .dtsi 片段并不能说明整个故事 - 设备树语法是分层的,因此属性(特别是 status)可能仍会被板级 .dts 覆盖包括一个基本的 SoC .dtsi 文件.其次,编译后的 DTB 也不是最后一个词,因为引导加载程序可能会在将其传递给内核之前对其进行动态修改 - 这通常是针对内存节点和 SMP 启用方法完成的,但可能会影响任何事情.

There are a number of possible ways this might happen, and most of them are well away from the driver code itself. Firstly, a .dtsi fragment alone doesn't tell the whole story - the device tree syntax is hierarchical, so the properties (in particular the status) might still be overridden by the board-level .dts which includes a basic SoC .dtsi file. Secondly, the compiled DTB isn't the last word either, since the bootloader may dynamically modify it before passing it to the kernel - this is typically done for memory nodes and SMP enable methods, but could potentially affect anything.

这种调试通常最好反向处理,通过检查启动系统的状态,然后向后工作以找出事情是如何发展的 - 这个特定问题的细节已经排除了其中的一些,但是对于为了完整起见:

This kind of debugging is often best tackled in reverse, by examining the state of the booted system, then working backwards to figure out how things got that way - the specifics of this particular question rule some of this out already, but for the sake of completeness:

  • 如果内核知道驱动程序,并且它被加载并正确初始化,它应该出现在/sys/bus/*/drivers/的某个地方 - 否则,它可能在需要加载的模块中,或者它可能有由于对某些其他驱动程序或资源的某种未满足的依赖性而未能初始化.
  • 如果内核知道该设备,它应该显示在/sys/bus/*/devices/中的某处,如果它正确绑定到驱动程序并被探测到,那么它们之间应该有一个符号链接.
  • 如果设备无处可寻,那么在基于 DT 的系统上,下一个要检查的位置将是/proc/device-tree/(依赖于旧内核上的 CONFIG_PROC_DEVICETREE,并且在/sys/firmware/中规范地找到)devicetree/base/on newer) - 这将显示内核找到它时的 DT 视图,并且在那里进行一些探索应该可以清除任何丢失的节点或不合适的属性,例如禁用的节点导致内核完全跳过创建设备.请注意,属性文件本身只是原始数据 - 因此您可能想要使用 hexdump 而不是 cat 进行窥探 - 并且所有数字单元格都采用大端字节序.

这篇关于设备树不匹配:.probe 从未调用过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 14:21