Registration of Linux:platform Equipment __linux

Source: Internet
Author: User
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;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.