了解platform-device及platform-drivers用法及定義
更新記錄
item | note |
---|---|
20160629 | 第一版 |
目錄
platform
- 來源, linux-3.0.y/Documentation/driver-model/platform.txt
- [platform.txt]
註冊設備:
- platform_device_register(): 註冊設備硬件,告訴kernel,當前有什麼設備
- platform_driver_register(): 註冊設備的驅動程序
程序如下:
- 當個設備connect後
- device和driver的兩條綫上都有匹配(由name來匹配)
- 匹配上(即binding),並且開始使用driver的probe等函數進行進行硬件初始化工作
platform device
1 | [rectangle setX: 10 y: 10 width: 20 height: 20]; |
- name : 在做driver及device比對時用(即是參考此name)
- platform_device.name : 用來作driver matching
- id : 當name比較相同時,在probe還可以參考id
- platform_device.id : the device instance number
- resource: SOC的IOBASE/IRQ為固定的,由此設定
platform driver
1 | struct platform_driver { |
- 提供callback function: probe, remove等
platform api
1 | extern int platform_device_register(struct platform_device *); |
- Whenever a device a registered. the driver for that bus are checked for matches.
- When ad driver is regiestered using platform_device_register.
- all unbund device on that bus are checked for matches.
- Register a driver using platform_driver_probe.
- 當device上線時第一次動作為probe
platfrom_device_register flow
platfrom_driver_register flow
hi3521 stmmac example
stmmac module
- 當module init時註冊設備
stmmac init module
- 先platform_device_register
- 再platform_drvier_register
stmmac platform device
- phy device data
- 設定相關phy0_id及interface
- ethernet device data
- 設定相關gmac的IRQ及IOBASE
stmmac platfrom driver
- 設定相關probe及remove