zoukankan      html  css  js  c++  java
  • 设备树和Platform架构--5--platform_device创建 (转)

    https://blog.csdn.net/u010961173/article/details/94297632

    platform_device的建立包含两种方式:

    (1)在内核初始化时通过device_node转换为platform_device,这种是最新的实现方式,基于设备树,在内核初始化时将设备树中的节点转化为platform_device;

    (2)使用platform_device_register注册platform_device;

    内核启动时自动将device_node转换为platform_device

    分析内核运行时调用of_platform_default_populate_init

    start_kernel
    >>>rest_init();/* Do the rest non-__init'ed, we're now alive */
    >>>pid = kernel_thread(kernel_init, NULL, CLONE_FS);
    >>>kernel_init
    >>>kernel_init_freeable();
    >>>do_basic_setup();
    >>>do_initcalls();
    for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++)
    >>>do_initcall_level(level);
    for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
    >>>do_one_initcall(initcall_from_entry(fn));
    // 就是调用"arch_initcall_sync(fn)"中定义的fn函数

    分析of_platform_default_populate_init注册platform_device


    driver/of/platform.c
    of_platform_default_populate_init
    of_platform_default_populate(NULL, NULL, NULL);/* Populate everything else. */
    of_platform_populate(root, of_default_bus_match_table, lookup,parent);
    for_each_child_of_node(root, child) {
    of_platform_bus_create(child, matches, lookup, parent, true);
    //节点必须包含compatible属性,才能创建platform_device
    if (strict && (!of_get_property(bus, "compatible", NULL))) {
    return 0;
    }
    //如果bus节点的compatile属性不吻合matches成表, 就不处理它的子节点
    dev = of_platform_device_create_pdata(bus, bus_id, platform_data, parent);
    if (!dev || !of_match_node(matches, bus))
    return 0;
    --------------------------------------------------------------------
    //如果bus节点的compatile属性吻合matches成表, 就处理它的子节点
    of_platform_device_create_pdata(bus, bus_id, platform_data, parent);
    //处理它的子节点, of_platform_bus_create是一个递归调用
    --------------------------------------------------------------------
    }
    通过以上分析总结:

    a. 内核函数of_platform_default_populate_init, 遍历device_node树, 生成platform_device
    b. 并非所有的device_node都会转换为platform_device,只有以下的device_node会转换:
            b.1 该节点必须含有compatible属性
            b.2 根节点的子节点(节点必须含有compatible属性)
            b.3 含有特殊compatible属性的节点的子节点(子节点必须含有compatible属性):
                    这些特殊的compatilbe属性为: "simple-bus","simple-mfd","isa","arm,amba-bus"

    注意:

    转换完成后,此时,所有的platform_deivce仅仅是以链表的形式添加到platform bus中。

    ————————————————
    版权声明:本文为CSDN博主「huofengfeihu」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/u010961173/java/article/details/94297632

  • 相关阅读:
    织梦后台如何安装
    Java JFrame实现无边框无标题
    SharePoint 2013的100个新功能之网站管理(一)
    cvFindContours之轮廓个数
    RequireJS 入门指南
    RESTFUL Service : based on Jersey
    hdu 1548 A strange lift(优先队列)
    SharePoint 用户配置文件服务
    SharePoint Foundation 搜索-PowerShell
    SharePoint 企业搜索-PowerShell
  • 原文地址:https://www.cnblogs.com/idyllcheung/p/13279476.html
Copyright © 2011-2022 走看看