Dts- status

来源:互联网 发布:亚马逊kindle windows 编辑:程序博客网 时间:2024/06/02 23:02

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))---------check status属性,确保是enable或者OK的。 

        return NULL;

    of_device_alloc除了分配structplatform_device的内存,还分配了该platform device需要的resource的内存(参考struct platform_device 中的resource成员)。当然,这就需要解析该devicenode的interrupt资源以及memory address资源。

    dev = of_device_alloc(np, bus_id,parent); 

    if (!dev) 

        return NULL;

设定platform_device中的其他成员 

    dev->dev.coherent_dma_mask =DMA_BIT_MASK(32); 

    if (!dev->dev.dma_mask) 

        dev->dev.dma_mask= &dev->dev.coherent_dma_mask; 

    dev->dev.bus =&platform_bus_type; 

    dev->dev.platform_data = platform_data;

    if (of_device_add(dev) != 0){------------------把这个platform device加入统一设备模型系统中 

       platform_device_put(dev); 

        return NULL; 

    }

    return dev; 

}

 

源文档 <http://www.wowotech.net/linux_kenrel/dt-code-analysis.html> 

0 0
原创粉丝点击