Platform bus, device, Driver

Source: Internet
Author: User

A real Linux Device and driver usually need to be attached to a bus. This is naturally not a problem for devices that are attached to PCI, USB, IIC, and SPI. However, in an embedded system, the independent peripheral controller integrated in the SoC system and peripherals attached to the SOC memory space are not attached to this type of bus. Based on this background, Linux invented a virtual bus called platform bus. The corresponding device is called platform_device, and the driver becomes platform_driver.In this way, all our drivers adopt the bus, device, and driver framework idea, regardless of bus (IIC/USB/PCI ...) a device driver model can be used for mounted device drivers..

Note: the so-called platform_device is not tied with character devices, Block devices, and network devices, but an additional means provided by the Linux system, the integrated IIC, RTC, SPI, LCD, and watchdog controllers are all classified as platform_device, which are character devices.

 

The concept of platform in device drivers has at least two benefits:

1. the device is mounted to a bus. Therefore, it complies with the linux2.6 device model. As a result, supporting sysfs nodes and device movie management are all possible.

2. Isolated BSP and driver. Define the resources used by platform devices and the specific configuration information of devices in BSP. In the driver, you only need to obtain resources and data through common APIs, the separation of board-related code and driver code makes the driver more scalable and cross-platform.

 

The structure of platform_driver is defined as follows:

Struct platform_driver {<br/> int (* probe) (struct platform_device *); <br/> int (* remove) (struct platform_device *); <br/> void (* shutdown) (struct platform_device *); <br/> int (* suspend) (struct platform_device *, pm_message_t State ); // mainly used for power management <br/> int (* suspend_late) (struct platform_device *, pm_message_t State); <br/> int (* resume_early) (struct platform_device *); <br/> int (* resume) (struct platform_device *); // mainly used for power management <br/> struct pm_ext_ops * PM; <br/> struct device_driver driver; <br/> };

 

The platform_device struct is defined as follows:

Struct platform_device {<br/> const char * Name; <br/> intid; <br/> struct devicedev; <br/> u32num_resources; <br/> struct resource * resource; // manage resources <br/> };

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.