Chinaunix首页 | 论坛 | 博客
  • 博客访问: 790159
  • 博文数量: 264
  • 博客积分: 592
  • 博客等级: 中士
  • 技术积分: 1574
  • 用 户 组: 普通用户
  • 注册时间: 2011-10-24 22:02
文章分类

全部博文(264)

文章存档

2019年(2)

2018年(1)

2017年(1)

2016年(4)

2015年(14)

2014年(57)

2013年(88)

2012年(97)

分类: LINUX

2012-12-09 17:44:56

1 dtb文件解析,生成资源单项列表。

start_kernel à setup_arch à unflatten_device_tree

该函数可以解析dtb文件,构建一个由device_node结构连接而成的单项链表。如下在此函数执行过后,在内存中会存在一个如下的链表:

后面所有的函数,如果需要从of tree结构上读取设备资料的,都将从这个链表中遍历并读取。

2 Of_platform总线的注册:

Arch/powerpc/kernel/of_platform.c

postcore_initcall(of_bus_driver_init);

of_bus_type_init(&of_platform_bus_type, "of_platform")

à bus_register(of_platform_bus_type)

同时:bus->match = of_platform_bus_match;

bus->probe = of_platform_device_probe;

of_platform_bus_type总线注册完毕。

3 mdio总线的注册

/driver/net/Phy_device.c

subsys_initcall(phy_init)

phy_init à mdio_bus_init à bus_register(&mdio_bus_type)

总线注册后,在总线上注册了一个默认的phy的驱动 genphy_driver

.phy_id = 0xffffffff,

.phy_id_mask = 0xffffffff,

.name = "Generic PHY",

Mdio总线注册完毕。

4 of_platform总线上的设备注册:

Arch/powerpc/platform/83xx/Mpc831x_rdb.c

machine_device_initcall(mpc831x_rdb, declare_of_platform_devices);

declare_of_platform_devices à of_platform_bus_probe(NULL, of_bus_ids, NULL)

Arch/powerpc/kernel/of_platform.c

遍历第一步中在内存中生成链表的所有soc的子节点,将所有的soc子节点设备添加到of_platform总线。

of_platform_bus_probe à of_platform_device_create à of_device_register à device_add

of_platform总线上的所有设备添加完毕,e0024000.ethernete0024520.mdio等设备现在都在总线上。

5 mdio总线上驱动的添加

/driver/net/phy/marvell.c

module_init(marvell_init)

marvell_init à phy_driver_register(&marvell_drivers[i]) à driver_register

前面第三步,注册mdio总线后,已经添加了一个默认的phy的驱动,现在要将所有的phy驱动添加到总线上,这里将所有的marvellphy都添加。

这步过后,内核的/sys/bus/mdio/driver里面就有了各种phy的驱动,但这时还没有和具体的设备绑定。

6 of_platform总线上Mdio设备驱动(该驱动的目的是在mdio总线上添加PHY设备)的添加,并绑定设备:e0024520.mdioe0025520.mdio

/driver/net/fsl_pq_mdio.c

module_init(fsl_pq_mdio_init)

fsl_pq_mdio_init à of_register_platform_driver(&fsl_pq_mdio_driver) à of_register_driver à driver_register à bus_add_driver à driver_attach

遍历整个of_platform总线,寻找与之相匹配的设备,找到e0024520.mdio

driver_attach à __driver_attach à driver_match_device

drivermatch_table里的信息和dev_nod中的做比较,若符合就进入driverprobe,也就是fsl_pq_mdio_probe

现在of_platform总线上的设备e0024520.mdioe0025520.mdio已经绑定了驱动。

7 Mdio总线上的设备的添加,寻找并绑定相应的驱动。

/driver/net/fsl_pq_mdio.c

fsl_pq_mdio_probe à of_mdiobus_register à phy_device_register à device_register(&phydev->dev) à device_add à bus_probe_device à device_attach àbus_for_each_drv

扫描mdio总线上的所有的驱动,若找到匹配的,就绑定,并probe

__device_attach à driver_probe_device à really_probe à phy_probe

将所有的phytbi-phy的设备都添加到mdio总线上,并且两个phy设备和两个tbi-phy设备都会根据其自己的PHYID找到各自的驱动

阅读(1293) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~