Platform Device Registration order
In the linux2.6 device model, care about the bus, the device, drive the three entities, the bus will be device and drive binding, in the system each register a device, will look for a matching driver. Instead, when the system registers a driver, the matching device is found, and the match is done by the bus.
A realistic Linux device and driver usually need to be hooked up on a bus, which is naturally not a problem for devices that are attached to PCI, USB, I2C, SPI, and so on, but in embedded systems, the independent peripheral controller integrated in the SOC system Peripherals such as memory space are not attached to such a bus. Based on this background, Linux invented a virtual bus, called the platform bus. The integrated independent peripheral units (LCD,RTC,WDT, etc.) in the SOC system are treated as platform devices, and they are character-type devices themselves.
Platform_driver_register (struct platform_driver *drv)--> driver_register (struct device_driver *drv)--> Bus_add _driver (struct device_driver *drv)
I. Platform equipment struct Platform_device
Take omap4430 as an example: KERNEL/ARCH/ARM/MACH-OMAP2/BOARD-4430SDP.C
static struct Platform_device sdp4430_disp_led = {
. Name = "Display_led",
. id =-1,
. Dev = {
. Platform_data = &sdp4430_disp_led_data,
},
};
struct Platform_device nec_infrared_remote = {
. Name = "Infrared-gpio",
. id =-1,
};
Add platform device devices to the system:
Platform_add_devices (struct platform_device **devs, int num);
two. Platform-driven struct platform_driver
KERNEL/DRIVERS/INPUT/IABOX-IR.C:
static struct Platform_driver Infrared_gpio_driver = {
. Probe = Infrared_gpio_probe,
. remove = Infrared_gpio_remove,
. Suspend = Infrared_gpio_suspend,
. Resume = Infrared_gpio_resume,
. Driver = {
. Owner = This_module,
. Name = "Infrared-gpio",
},
};
Driver Registration:
static int __init infrared_receiver_init (void)
{
int ret;
ret = Platform_driver_register (&infrared_gpio_driver);
if (!ret)
PRINTK (kern_info "infrared Gpio receiver driver\n");
return ret;
}