分类: Android平台
2014-12-05 15:47:18
.init_machine =at91_dt_device_init,
staticvoid __init at91_dt_device_init(void)
*of_platform_populate() - Populate platform_devices from device treedata
*@parent: parent to hook devicesfrom, NULL for toplevel
*Similar to of_platform_bus_probe(), this function walks the devicetree
*and creates devices from nodes. It differs in that it follows themodern
*convention of requiring all device nodes to have a 'compatible'property,
*and it is suitable for creating devices which are children of theroot
//从devicetree数据中populateplatform devices。
intof_platform_populate(structdevice_node *root,
conststruct of_device_id *matches,
conststruct of_dev_auxdata *lookup,
*of_platform_bus_create() - Create a device for a node and itschildren.
*@bus: device node of the bus to instantiate
*@lookup: auxdata table for matching id and platform_data with devicenodes
*@parent: parent for new device, or NULL for top level.
*Creates a platform_device for the provided device_node, andoptionally
*recursively create devices for all the child nodes.
staticint of_platform_bus_create(structdevice_node *bus,
const struct of_device_id *matches,
const struct of_dev_auxdata *lookup,
struct device *parent, boolstrict)
conststruct of_dev_auxdata *auxdata;
auxdata= of_dev_lookup(lookup, bus);
if(of_device_is_compatible(bus, "arm,primecell")) {
of_amba_device_create(bus,bus_id, platform_data, parent);
dev= of_platform_device_create_pdata(bus,bus_id, platform_data, parent);
if(!dev || !of_match_node(matches, bus))
rc= of_platform_bus_create(child, matches, lookup, &dev->dev,strict);
staticstruct amba_device *of_amba_device_create(structdevice_node *node,
pr_debug("Creatingamba device %s\n", node->full_name);
if(!of_device_is_available(node))
dev= amba_device_alloc(NULL, 0, 0);
/*setup generic device info */
dev->dev.coherent_dma_mask= ~0;
dev->dev.of_node= of_node_get(node);
dev->dev.platform_data= platform_data;
*of_platform_device_create_pdata - Alloc, initialize and register anof_device
*@np: pointer to node to create device for
*@bus_id: name to assign device
*@parent: Linux device model parentdevice.
*Returns pointer to created platform device, or NULL if a device wasnot
*registered. Unavailable devices will not get registered.
structplatform_device *of_platform_device_create_pdata(
if(!of_device_is_available(np))
dev= of_device_alloc(np,bus_id, parent);
*of_device_alloc - Allocate and initialize an of_device
*@np: device node to assign to device
*@bus_id: Name to assign to the device. May be null to use defaultname.
structplatform_device *of_device_alloc(structdevice_node *np,
dev= platform_device_alloc("", -1);
dev->num_resources= num_reg + num_irq;
dev->dev.of_node= of_node_get(np);
dev->dev.dma_mask= &dev->archdata.dma_mask;
dev_set_name(&dev->dev,"%s", bus_id);
of_device_make_bus_id(&dev->dev);
总的分析:parent参数开始初始化为NULL,其中一直没有赋值,直到最后赋值给platformdevice的dev.parent属性。其中关系耐人寻味。