最終更新:2014-05-28 (水) 04:23:21 (3614d)
Linux/プラットフォームデバイス
platform 'pseudo' bus for legacy devices
メモ
- Platform devices are devices that typically appear as autonomous entities in the system.
- This includes legacy port-based devices and host bridges to peripheral buses, and most controllers integrated into system-on-chip platforms.
ドキュメント
LWN
ヘッダファイル
構造体
マクロ
- module_platform_driver - Helper macro for drivers that don't do anything special in module init/exit.
- platform_driver_register -> __platform_driver_register
関数
- __platform_driver_register - register a driver for platform-level devices
- drv->driver.probe = platform_drv_probe;
- drv->driver.remove = platform_drv_remove?;
- platform_driver_unregister?
例
sysfs
処理
init
- module_platform_driver(dwc3_driver) -> module_driver(dwc3_driver, platform_driver_register, platform_driver_unregister?)
- platform_driver_register -> __platform_driver_register(platform_driver *drv, module *owner)
probe
- dwc3_driverの例
static struct platform_driver dwc3_driver = { .probe = dwc3_probe, .remove = dwc3_remove, .driver = { .name = "dwc3", .of_match_table = of_match_ptr(of_dwc3_match), .pm = DWC3_PM_OPS, }, };
呼び出し階層
- drivers/usb/dwc3/core.cでmodule_platform_driver(dwc3_driver)
- module_driver(dwc3_driver, platform_driver_register, platform_driver_unregister?)
- __platform_driver_register(dwc3_driver)
- drv->driver.bus = &platform_bus_type;
- if (drv->probe)drv->driver.probe = platform_drv_probe; <=ここでコールバックを設定
- driver_register -> bus_add_driver -> driver_attach -> driver_probe_device -> really_probe
- device.bus.probe()
- device_driver.probe() <=ここで設定したコールバックを呼び出し。コールバック先でさらにplatform_driver.probe(dwc3_probe)が呼ばれる
その他
- init時にplatform_driver_probe(platform_driver *drv, int (*probe)(struct platform_device *))を呼び出すドライバもある (hidg_init)
- drv->probe = probe;
- platform_driver_register