What is the platform in linux?

11-20-2023

Designed for programming, automatic code writing robot, free to open. This article mainly explains what the platform in linux is. The content of the article is simple and clear, and it is easy to learn and understand. Please follow the idea of Xiaobian and go deeper and deeper. Let's study and learn what the platform in linux is!

In linux, platform is a virtual bus, which corresponds to the real spi/sdio/usb/pcie bus. Platform can separate hardware from software. The resources described in platform have one thing in common: they are accessed directly on the bus of CPU, and platform devices are assigned a name and a series of resources such as address and interrupt request number.

Operating environment of this tutorial: linux7.3 system and Dell G3 computer.

What does platform mean in linux? platform is a virtual bus, which corresponds to real spi/sdio/usb/pcie buses.

An important function of the logic bus is to find the device and find the appropriate driver to operate the device.

Platform bus is a virtual logic bus, which meets the logic interconnection function. In order to manage devices in a unified way, the platform can manage a class of devices that do not have a bus physically by using the platform bus.

Common buses, such as USB, SPI, UART, PCI, I2S and so on, are physically real buses. Linux system designs a unified management method for this kind of buses, namely bus. At the same time, the platform bus is also designed for devices that don't have a bus physically, so the Linux kernel designer designed the platform bus, that is to say, the Planform bus is designed for devices that don't have a bus physically in SoC, and it belongs to the bus bus class.

The advantage of this is that the device-side code writer only cares about the specific hardware part, and the common part of the device (the stable part) is completed by the kernel designer, thus reducing the difficulty of driver writing.

Through the platform bus, device attributes (also called data) and drivers can be separated, so that different devices with the same functional core hardware can be supported by the same driver. This avoids the phenomenon that a device needs a drive, and reduces repetitive work.

Extended knowledge

Platform bus related definitions

The platform bus related objects are defined in the file drivers/base/platform.c. This file realizes the platform bus object and object operation method.

Two important data structures

1、platform_driver

This is a structure object embedded with a device_driver, in which the method of manipulating the object is defined.

2、platform_device

It is an object with embedded device structure, which defines the attributes of device description resources.

Specific objects are defined as follows:

1. platform_driver object definition

struct platform_driver  { int (*probe)(struct platform_device *); //Detect the function, install the device, initialize the device, and judge whether it can succeed (initialization success, communication success, etc.). int (*remove)(struct platform_device *); //Remove this device from the kernel. void (*shutdown)(struct platform_device *); //Turn off the device int (*suspend)(struct platform_device *, pm_message_t state); //hang int (*resume)(struct platform_device *); //wake up struct device_driver driver; //General properties of the driver const struct platform_device_id *id_table; //device id table };

Platform_device object pair definition:

struct platform_device  { const char* name; //The name of the device in the platform bus. There are multiple devices under the platform bus, and each device has its own name. intid; //Ordering of devices struct devicedev; //Properties common to all devices u32num_resources; //Device resources, such as the number of some peripherals such as IO. struct resource* resource; //The first address of the device resource, together with the number num_resources above, forms an array to represent this resource. const struct platform_device_id*id_entry; //Device ID table, which represents the ID numbers of several devices of the same type, and array representation. struct pdev_archdataarchdata; /* arch specific additions *//User-defined data, extended data. };

Register platform bus-driven functions:

int platform_driver_register(struct platform_driver *drv)

Functions for registering platform bus devices:

int platform_device_register(struct platform_device *pdev)

Thank you for reading. That's what the platform in linux is. After learning this article, I believe you have a deeper understanding of what the platform in linux is, and the specific use needs to be verified by practice. Here is Yisu Cloud, and Xiaobian will push more articles about related knowledge points for everyone. Welcome to pay attention!

Ask AI for details

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us