Linux Kernel Device Tree 配置框架

    背景:基於arm平臺的soc種類繁多,硬件資源和配置各不相同。這些平臺硬件相關的信息在設備樹出現以前,是在kernel/arch/arm/plat-xxx目錄和kernel/arch/arm/mach-xxx目錄下硬編碼的。在kernel看來,這些硬件細節代碼只不過是些垃圾,須要一套框架抽象出來,屏蔽這些硬件細節。設備樹框架被提出用來統一arm平臺硬件配置,屏蔽硬件細節。node

    術語介紹:linux

    1,DTS(Device Tree Source):設備樹源碼。爲方便閱讀和修改,設備樹源文件遵循必定的格式,採用文本方式存放。數組

    2,DTB(Device Tree Blob):設備樹對象。DTS的二進制對象表示形式,經過DTC將DTS編譯成DTB。網絡

    3,DTC(Device Tree Compiler):設備樹編譯器。kernel提供的一個小工具,能夠將 DTS 編譯成 DTB。架構

    DTS爲何須要轉換成DTB?kernel在初始化階段須要從設備樹讀取平臺的各類硬件信息(如,bootargs/cpu/memory/devices等),bootloader在加載kernel image的同時,也須要加載設備樹信息。bootloader將加載後的設備樹物理地址傳遞給kernel,kernel再去配置各類硬件信息。所以,須要定義出DTB的二進制格式,經過DTC將DTS編譯成DTB,經bootloader加載,kernel解析DTB,最終在kernel中造成一套完整的device tree。app

    DTS的格式:框架

        DTS以節點和屬性的形式組織設備樹:節點是樹枝,屬性是樹葉,節點中能夠包含子節點。ide

        1,節點格式:工具

                label : name@address {源碼分析

                }

            (1)label:標籤。若是有其餘屬性須要引用該節點,能夠經過 &label 的形式直接引用該節點。

            (2)name:節點名稱。長度範圍是1~31,可使用以下字符組合:數字(0 ~ 9) 小寫字母(a ~ z) 大寫字母(A ~ Z) 逗號(,) 句號(.)下劃線(_) 加號(+) 以及 減號(-)。而且,規範要求以字母開頭。

            (3)address:節點地址。實際上是用來區分同名設備的,同一空間中的不一樣節點多是同一個名稱,能夠經過不一樣地址來區分。address並不只僅指設備地址,也多是設備編號。好比,對於cpu來講,就沒有地址,可是能夠經過 cpu@0,cpu@1來區分不一樣的cpu。

        2,屬性格式:

            property_name = value

            (1)property_name:屬性名稱。長度範圍是1~31,可使用以下字符組合:數字(0 ~ 9) 小寫字母(a ~ z)  逗號(,) 句號(.)下劃線(_) 加號(+)  減號(-) 問號(?)以及 sharp(#) 。而且,規範要求以字母開頭。

            (2)value:屬性值。標準定義的屬性值基本類型以下:<empty> <u32> <u64> <string> <prop-encoded-array> <phandle> <stringlist>。

                    <prop-encoded-array>:混合編碼,自定義property的值。

                    <phandle>:做爲一個句柄指向一個Node,用來引用Node。不多使用,通常使用 &label 方式引用node。

        3,標準屬性:

            (1)compatible:字符串數組類型。一般用來匹配driver和device,一個設備能夠定義多個匹配字符串,範圍由小到大,由具體到通常。這樣在匹配驅動程序時,優先匹配更具體的設備驅動。

            (2)model:字符串類型。用來表示設備型號。

            (3)#address-cells,#size-cells:一個cell表示32位。這兩個屬性用來定義一個node的子node中,reg屬性值的格式。好比,

                        父節點中,#address-cells = <2>; #size-cells = <1>

                        子節點中,reg = <0x00010000 0x7c004000 0x00001000 >

                    這代表,子節點reg的屬性值中前兩個cell組成設備的64位起始地址(0x000100007c004000),後一個cell是這個設備佔用的32位地址範圍(大小0x00001000)。

            (4)reg:<prop-encoded-array>類型,格式是<start-addr  size>。表示設備節點資源,通常指寄存器起始地址和範圍。見(3)中示例。

            (5)ranges:<prop-encoded-array>類型,格式是<subnode-addr  parent-node-addr  size>。subnode-addr佔用幾個cell由ranges所在的當前節點 #address-cells 決定,parent-node-addr佔用幾個cell由父節點 #address-cells 決定,size佔用幾個cell由當前節點 #size-cells 決定。

            (6)status:字符串類型。代表設備的狀態。「okay」表示設備可用,「disabled」表示設備不可用。

        4,中斷相關屬性:

            中斷節點分爲三種:中斷控制器,中斷產生設備和中斷鏈接器(nexus)。

            (1)中斷產生設備屬性:

                    interrupt-parent:<phandle>類型。指示該中斷產生設備的中斷父節點,即中斷控制器或者中斷鏈接器。

                    #interrupt:<prop-encoded-array>類型。每一箇中斷編號佔用幾個cell由中斷父節點中的 #interrupt-cells 決定。

            (2)中斷控制器屬性:

                    #interrupt-cells:指示鏈接到該中斷控制器下的設備的 #interrupt 的解析格式,即每一箇中斷編號佔用幾個cell。

                    interrupt-controller:<empty>類型。聲明該節點是一箇中斷控制器。

            (3)中斷鏈接器屬性:

                    #interrupt-cells:指示鏈接到該中斷鏈接器下的設備的 #interrupt 的解析格式,即每一箇中斷編號佔用幾個cell。

                    interrupt-map:<prop-encoded-array>類型,格式爲<child_unit_address, child_interrupt_specifier, interrupt_parent, parent_unit_address, parent_interrupt_specifier>。描述中斷鏈接器對中斷的路由。

                        其中,

                                child_unit_address:cells長度由子節點的「#address-cells」指定; 
                                child_interrupt_specifier:cells長度由子節點的「#interrupt-cells」指定; 
                                interrupt_parent:phandle指向interrupt controller的引用; 
                                parent_unit_address:cells長度由父節點的「#address-cells」指定; 
                                parent_interrupt_specifier:cells長度由父節點的「#interrupt-cells」指定;

        5,標準節點:

            (1)/  節點,即根節點:每一個設備樹有且只有一個根節點。根節點必須包含以下屬性:compatible,model,#address-cells 和 #size-cells。

            (2)/alias  節點:定義節點別名。

            (3)/memory  節點:內存節點。通常有以下屬性:device_type,reg等。

            (4)/chosen  節點:該節點並不表示某個硬件設備,而是用來傳遞內核啓動參數和定義標準輸入輸出設備。通常有以下屬性:bootargs,stdin-path 和 stdout-path。

            (5)/cpu  節點:定義cpu節點。

    DTB的格式:

        DTS通過DTC編譯以後,生成以下格式的DTB

        (1)總體結構:分爲4個block(圖片來源於網絡)。

        è¿™é‡Œå†™å›¾ç‰‡æè¿°

                    說明:(1)boot_param_header:主要定義了後面三個block的偏移。

                            (2)device-tree structure:定義了節點和屬性值的格式。

                            (3)device-tree strings:定義了屬性名。

        (2)boot_param_header結構定義:

            struct boot_param_header {
                __be32    magic;            /* magic word OF_DT_HEADER */
                __be32    totalsize;        /* total size of DT block */
                __be32    off_dt_struct;        /* offset to structure */
                __be32    off_dt_strings;        /* offset to strings */
                __be32    off_mem_rsvmap;        /* offset to memory reserve map */
                __be32    version;        /* format version */
                __be32    last_comp_version;    /* last compatible version */
                /* version 2 fields below */
                __be32    boot_cpuid_phys;    /* Physical CPU id we're booting on */
                /* version 3 fields below */
                __be32    dt_strings_size;    /* size of the DT strings block */
                /* version 17 fields below */
                __be32    dt_struct_size;        /* size of the DT structure block */
};

        (3)device-tree structure:(圖片來源於網絡)

                è¿™é‡Œå†™å›¾ç‰‡æè¿°

            說明:

                (1)FDT_BEGIN_NODE:節點開始指示符。

                (2)FDT_PROP:屬性開始指示符。

                (3)FDT_END_NODE:節點結束指示符。

                (4)每一個屬性的格式是:4字節指示屬性值的長度;接下來4字節指示屬性名在 device tree strings 塊中的偏移;再接下來就是實際的屬性值。

    源碼分析:

        kernel解析DTB分爲兩個部分,一部分是先進行DTB的解析,生成內核device_node節點樹。第二部分是根據device_node節點樹建立各個具體的設備。

        1,解析DTB

            (1)直接解析DTB,獲取機器類型,kernel啓動參數,內存配置信息等

            setup_arch() ->setup_machine_fdt(__atags_pointer): // __atags_pointer是bootloader提供給kernel的DTB起始物理地址

const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
{
    const struct machine_desc *mdesc, *mdesc_best = NULL;

#ifdef CONFIG_ARCH_MULTIPLATFORM
    DT_MACHINE_START(GENERIC_DT, "Generic DT based system")
    MACHINE_END

    mdesc_best = &__mach_desc_GENERIC_DT;
#endif

    if (!dt_phys || !early_init_dt_verify(phys_to_virt(dt_phys)))    // 物理地址轉換成內核態地址,並檢查DTB文件頭的合法性
        return NULL;

    mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach); //根據DTB配置的compatible參數,選取kernel支持的最優machine類型。

    if (!mdesc) {
        const char *prop;
        int size;
        unsigned long dt_root;

        early_print("\nError: unrecognized/unsupported "
                "device tree compatible list:\n[ ");

        dt_root = of_get_flat_dt_root();
        prop = of_get_flat_dt_prop(dt_root, "compatible", &size);
        while (size > 0) {
            early_print("'%s' ", prop);
            size -= strlen(prop) + 1;
            prop += strlen(prop) + 1;
        }
        early_print("]\n\n");

        dump_machine_table(); /* does not return */
    }

    /* We really don't want to do this, but sometimes firmware provides buggy data */
    if (mdesc->dt_fixup)
        mdesc->dt_fixup();

    early_init_dt_scan_nodes();    // 解析DTB中配置的bootargs,memory等信息

    /* Change machine number to match the mdesc we're using */
    __machine_arch_type = mdesc->nr;

    return mdesc;
}
 

void __init early_init_dt_scan_nodes(void)
{
    /* Retrieve various information from the /chosen node */
    of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line);    // 解析 /chosen 節點,獲取kernel啓動參數

    /* Initialize {size,address}-cells info */
    of_scan_flat_dt(early_init_dt_scan_root, NULL);    // 解析 根節點,獲取 #address-cells 和 #size-cells等屬性

    /* Setup memory, calling early_init_dt_add_memory_arch */
    of_scan_flat_dt(early_init_dt_scan_memory, NULL);    // 解析 /memory 節點,獲取內存配置信息,並加入kernel管理
}

            (2)根據device tree遞歸建立設備樹節點 device_node

                setup_arch() ->unflatten_device_tree():

void __init unflatten_device_tree(void)
{
    __unflatten_device_tree(initial_boot_params, &of_root,
                early_init_dt_alloc_memory_arch);    // 解析設備樹DTB,加入到of_root根節點中

    /* Get pointer to "/chosen" and "/aliases" nodes for use everywhere */
    of_alias_scan(early_init_dt_alloc_memory_arch);    // 解析 /alias 節點
}

static void __unflatten_device_tree(const void *blob,
                 struct device_node **mynodes,
                 void * (*dt_alloc)(u64 size, u64 align))
{
    unsigned long size;
    int start;
    void *mem;

    pr_debug(" -> unflatten_device_tree()\n");

    if (!blob) {
        pr_debug("No device tree pointer\n");
        return;
    }

    pr_debug("Unflattening device tree:\n");
    pr_debug("magic: %08x\n", fdt_magic(blob));
    pr_debug("size: %08x\n", fdt_totalsize(blob));
    pr_debug("version: %08x\n", fdt_version(blob));

    if (fdt_check_header(blob)) {
        pr_err("Invalid device tree blob header\n");
        return;
    }

    // 首次輪詢,設置mem爲NULL,dry_run爲true,start爲0,用來計算整棵設備樹解析後的內存大小

    /* First pass, scan for size */
    start = 0;
    size = (unsigned long)unflatten_dt_node(blob, NULL, &start, NULL, NULL, 0, true);    // 計算解析後設備樹大小
    size = ALIGN(size, 4);

    pr_debug("  size is %lx, allocating...\n", size);

    /* Allocate memory for the expanded device tree */
    mem = dt_alloc(size + 4, __alignof__(struct device_node));    // 分配解析後的設備樹內存
    memset(mem, 0, size);

    *(__be32 *)(mem + size) = cpu_to_be32(0xdeadbeef);

    pr_debug("  unflattening %p...\n", mem);

    // 再次輪詢,傳入mem,設置dry_run爲false,進行實際內存分配和設備樹加載

    /* Second pass, do actual unflattening */
    start = 0;
    unflatten_dt_node(blob, mem, &start, NULL, mynodes, 0, false);    // 設備樹解析,加載
    if (be32_to_cpup(mem + size) != 0xdeadbeef)
        pr_warning("End of tree marker overwritten: %08x\n",
               be32_to_cpup(mem + size));

    pr_debug(" <- unflatten_device_tree()\n");
}
 

static void * unflatten_dt_node(const void *blob,
                void *mem,
                int *poffset,
                struct device_node *dad,
                struct device_node **nodepp,
                unsigned long fpsize,
                bool dryrun)
{
    const __be32 *p;
    struct device_node *np;
    struct property *pp, **prev_pp = NULL;
    const char *pathp;
    unsigned int l, allocl;
    static int depth;
    int old_depth;
    int offset;
    int has_name = 0;
    int new_format = 0;

    pathp = fdt_get_name(blob, *poffset, &l);    //poffset開始爲0,獲取根節點路徑,遞歸以後,獲取各節點路徑
    if (!pathp)
        return mem;

    allocl = ++l;

    /* version 0x10 has a more compact unit name here instead of the full
     * path. we accumulate the full path size using "fpsize", we'll rebuild
     * it later. We detect this because the first character of the name is
     * not '/'.
     */

    // 根據版本的不一樣,DTB中節點名有多是絕對路徑名,也有多是相對路徑名,若是是相對路徑名,須要組合成絕對路徑名
    if ((*pathp) != '/') {
        new_format = 1;
        if (fpsize == 0) {
            /* root node: special case. fpsize accounts for path
             * plus terminating zero. root node only has '/', so
             * fpsize should be 2, but we want to avoid the first
             * level nodes to have two '/' so we use fpsize 1 here
             */
            fpsize = 1;
            allocl = 2;
            l = 1;
            pathp = "";
        } else {
            /* account for '/' and path size minus terminal 0
             * already in 'l'
             */
            fpsize += l;
            allocl = fpsize;
        }
    }

    np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl,
                __alignof__(struct device_node));    // 分配存放 device_node + 節點名稱 的內存

    if (!dryrun) {
        char *fn;
        of_node_init(np);
        np->full_name = fn = ((char *)np) + sizeof(*np);
        if (new_format) {    // new_format == 1 代表節點名稱是相對路徑名,下面的代碼用於處理合成絕對路徑名
            /* rebuild full path for new format */
            if (dad && dad->parent) {
                strcpy(fn, dad->full_name);
#ifdef DEBUG
                if ((strlen(fn) + l + 1) != allocl) {
                    pr_debug("%s: p: %d, l: %d, a: %d\n",
                        pathp, (int)strlen(fn),
                        l, allocl);
                }
#endif
                fn += strlen(fn);
            }
            *(fn++) = '/';
        }
        memcpy(fn, pathp, l);

        prev_pp = &np->properties;

        // 當前節點加入設備樹
        if (dad != NULL) {
            np->parent = dad;
            np->sibling = dad->child;
            dad->child = np;
        }
    }

    // 解析該節點下的各個屬性
    /* process properties */
    for (offset = fdt_first_property_offset(blob, *poffset);
         (offset >= 0);
         (offset = fdt_next_property_offset(blob, offset))) {
        const char *pname;
        u32 sz;

        if (!(p = fdt_getprop_by_offset(blob, offset, &pname, &sz))) {
            offset = -FDT_ERR_INTERNAL;
            break;
        }

        if (pname == NULL) {
            pr_info("Can't find property name in list !\n");
            break;
        }
        if (strcmp(pname, "name") == 0)
            has_name = 1;
        pp = unflatten_dt_alloc(&mem, sizeof(struct property),
                    __alignof__(struct property));    // 分配屬性內存

        if (!dryrun) {
            /* We accept flattened tree phandles either in
             * ePAPR-style "phandle" properties, or the
             * legacy "linux,phandle" properties.  If both
             * appear and have different values, things
             * will get weird.  Don't do that. */
            if ((strcmp(pname, "phandle") == 0) ||
                (strcmp(pname, "linux,phandle") == 0)) {
                if (np->phandle == 0)
                    np->phandle = be32_to_cpup(p);
            }
            /* And we process the "ibm,phandle" property
             * used in pSeries dynamic device tree
             * stuff */
            if (strcmp(pname, "ibm,phandle") == 0)
                np->phandle = be32_to_cpup(p);
            pp->name = (char *)pname;    // 保存屬性名
            pp->length = sz;    // 保存屬性值大小
            pp->value = (__be32 *)p;    // 保存屬性值

            // 將屬性加入當前節點
            *prev_pp = pp;
            prev_pp = &pp->next;
        }
    }
    /* with version 0x10 we may not have the name property, recreate
     * it here from the unit name if absent
     */
    if (!has_name) {
        const char *p1 = pathp, *ps = pathp, *pa = NULL;
        int sz;

        while (*p1) {
            if ((*p1) == '@')
                pa = p1;
            if ((*p1) == '/')
                ps = p1 + 1;
            p1++;
        }
        if (pa < ps)
            pa = p1;
        sz = (pa - ps) + 1;
        pp = unflatten_dt_alloc(&mem, sizeof(struct property) + sz,
                    __alignof__(struct property));
        if (!dryrun) {
            pp->name = "name";
            pp->length = sz;
            pp->value = pp + 1;
            *prev_pp = pp;
            prev_pp = &pp->next;
            memcpy(pp->value, ps, sz - 1);
            ((char *)pp->value)[sz - 1] = 0;
            pr_debug("fixed up name for %s -> %s\n", pathp,
                (char *)pp->value);
        }
    }
    if (!dryrun) {
        *prev_pp = NULL;
        np->name = of_get_property(np, "name", NULL);
        np->type = of_get_property(np, "device_type", NULL);

        if (!np->name)
            np->name = "<NULL>";
        if (!np->type)
            np->type = "<NULL>";
    }

    // 遞歸處理子節點

    old_depth = depth;
    *poffset = fdt_next_node(blob, *poffset, &depth);
    if (depth < 0)
        depth = 0;
    while (*poffset > 0 && depth > old_depth)
        mem = unflatten_dt_node(blob, mem, poffset, np, NULL,
                    fpsize, dryrun);

    if (*poffset < 0 && *poffset != -FDT_ERR_NOTFOUND)
        pr_err("unflatten: error %d processing FDT\n", *poffset);

    /*
     * Reverse the child list. Some drivers assumes node order matches .dts
     * node order
     */
    if (!dryrun && np->child) {
        struct device_node *child = np->child;
        np->child = NULL;
        while (child) {
            struct device_node *next = child->sibling;
            child->sibling = np->child;
            np->child = child;
            child = next;
        }
    }

    if (nodepp)
        *nodepp = np;

    return mem;
}
        至此,整棵設備樹的節點和屬性都都被加載進kernel中,以device_node形式保存在根節點 of_root 中。

        2,建立DT設備 platform_device

            start_kernel() -> reset_init() -> kernel_init() -> kernel_init_freeable() -> do_basic_setup() -> do_initcalls() -> customize_machine() -> of_platform_populate()

            kernel啓動階段會去建立各個配置好的platform_device,包括總線設備和總線下掛的子設備

static int __init customize_machine(void)
{
    /*
     * customizes platform devices, or adds new ones
     * On DT based machines, we fall back to populating the
     * machine from the device tree, if no callback is provided,
     * otherwise we would always need an init_machine callback.
     */
    of_iommu_init();
    if (machine_desc->init_machine)
        machine_desc->init_machine();
#ifdef CONFIG_OF
    else
        of_platform_populate(NULL, of_default_bus_match_table,
                    NULL, NULL);    // 匹配 of_default_bus_match_table的節點被認爲是總線設備,葉子設備則不該該匹配

#endif
    return 0;
}
arch_initcall(customize_machine);    // customize_machine被arch_initcall聲明,在do_initcalls()階段會被調用執行

const struct of_device_id of_default_bus_match_table[] = {    // 默認總線匹配表
    { .compatible = "simple-bus", },
    { .compatible = "simple-mfd", },
#ifdef CONFIG_ARM_AMBA
    { .compatible = "arm,amba-bus", },
#endif /* CONFIG_ARM_AMBA */
    {} /* Empty terminated list */
};

int of_platform_populate(struct device_node *root,
            const struct of_device_id *matches,
            const struct of_dev_auxdata *lookup,
            struct device *parent)
{
    struct device_node *child;
    int rc = 0;

    root = root ? of_node_get(root) : of_find_node_by_path("/");    // 獲取 of_root 設備樹根節點
    if (!root)
        return -EINVAL;

    // 輪詢設備樹根節點下的子節點

    for_each_child_of_node(root, child) {
        rc = of_platform_bus_create(child, matches, lookup, parent, true);    // 檢查並建立總線設備和葉子設備
        if (rc) {
            of_node_put(child);
            break;
        }
    }
    of_node_set_flag(root, OF_POPULATED_BUS);

    of_node_put(root);
    return rc;
}

 

static int of_platform_bus_create(struct device_node *bus,
                  const struct of_device_id *matches,
                  const struct of_dev_auxdata *lookup,
                  struct device *parent, bool strict)
{
    const struct of_dev_auxdata *auxdata;
    struct device_node *child;
    struct platform_device *dev;
    const char *bus_id = NULL;
    void *platform_data = NULL;
    int rc = 0;

    /* Make sure it has a compatible property */
    if (strict && (!of_get_property(bus, "compatible", NULL))) {    // 不管是總線設備仍是葉子設備,都必須包含 compatible 屬性
        pr_debug("%s() - skipping %s, no compatible prop\n",
             __func__, bus->full_name);
        return 0;
    }

    auxdata = of_dev_lookup(lookup, bus);
    if (auxdata) {
        bus_id = auxdata->name;
        platform_data = auxdata->platform_data;
    }

    if (of_device_is_compatible(bus, "arm,primecell")) {
        /*
         * Don't return an error here to keep compatibility with older
         * device tree files.
         */
        of_amba_device_create(bus, bus_id, platform_data, parent);
        return 0;
    }

    dev = of_platform_device_create_pdata(bus, bus_id, platform_data, parent);    // 建立總線設備或者葉子設備的platform_device
    if (!dev || !of_match_node(matches, bus))    // 若是不匹配,說明該設備是個葉子設備,遞歸結束;若是匹配,說明該設備是個總線設備,須要繼續遞歸輪詢其下掛的子設備
        return 0;

    // 循環建立該總線下的全部子總線設備

    for_each_child_of_node(bus, child) {
        pr_debug("   create child: %s\n", child->full_name);
        rc = of_platform_bus_create(child, matches, lookup, &dev->dev, strict);    // 建立總線下的子總線設備
        if (rc) {
            of_node_put(child);
            break;
        }
    }
    of_node_set_flag(bus, OF_POPULATED_BUS);
    return rc;
}

static struct platform_device *of_platform_device_create_pdata(
                    struct device_node *np,
                    const char *bus_id,
                    void *platform_data,
                    struct device *parent)
{
    struct platform_device *dev;

    if (!of_device_is_available(np) ||
        of_node_test_and_set_flag(np, OF_POPULATED))
        return NULL;

    dev = of_device_alloc(np, bus_id, parent);    // 分配 platform_device,並從 node_device 中獲取reg和irq信息
    if (!dev)
        goto err_clear_flag;

    dev->dev.bus = &platform_bus_type;    // bus type 爲 platform_bus_type
    dev->dev.platform_data = platform_data;
    of_dma_configure(&dev->dev, dev->dev.of_node);
    of_msi_configure(&dev->dev, dev->dev.of_node);

    if (of_device_add(dev) != 0) {
        of_dma_deconfigure(&dev->dev);
        platform_device_put(dev);
        goto err_clear_flag;
    }

    return dev;

err_clear_flag:     of_node_clear_flag(np, OF_POPULATED);     return NULL; }     至此,從DTS到DTB,從kernel加載DTB,到整個DTB被轉換成由of_root引用的device_node tree,最後到整個platform_bus總線的建立過程已經很是清晰明瞭了。整個arm架構的設備註冊部分已經完成,剩下的就是後續各個platform_driver的register,match和probe了。

相關文章
相關標籤/搜索