Embedded Linux Platform device driver (device driven model) development of the device in the Linux kernel __linux

Source: Internet
Author: User
devices in the Linux kernelFor the connection on the specific bus external devices have a struct device corresponding, such as platform equipment has platform_device corresponding to it, which platform_device structure is as follows: struct Platform_device {
const char * name; Device name to match the name of the driver and, if successful, into the driven probe function
int id;
struct device dev;
U32 num_resources;
struct resource* resource; Private resources for Devices
const struct Platform_device_id*id_entry;

/* MFD cell pointer * *
struct Mfd_cell *mfd_cell;


* Arch Specific Additions * *
struct Pdev_archdataarchdata;
};

For USB devices on the USB bus, the struct usb_device is used to represent the specific USB device or to record the specific USB information, in which the usb_device structure is as follows: struct Usb_device {
Char Path[sysfs_path_max];
Char Busid[sysfs_bus_id_size];


uint32_t BusNum;
uint32_t Devnum;
uint32_t speed;


uint16_t Idvendor;
uint16_t idproduct;
uint16_t Bcddevice;


uint8_t Bdeviceclass;
uint8_t Bdevicesubclass;
uint8_t Bdeviceprotocol;
uint8_t Bconfigurationvalue;
uint8_t bnumconfigurations;
uint8_t bnuminterfaces;
} __attribute__ ((packed));

The structure variables of the external devices represented in the Linux system are dynamically registered to the corresponding bus at the startup stage of the system. and registering to the device to the corresponding bus is achieved by calling the Device_add function. The so-called registered device bus is to load the device into the bus representing the device's linked list in central.     struct Device {struct Klist_node knode_bus;     struct Klist_node knode_driver;     struct Bus_type *bus; struct Device_driver *driver; };
struct Klist_node Knode_bus; The Linux kernel uses the member device to load the list of his linked list devices, which is to load the device onto the klist_devices list.
struct Klist_node knode_driver; Which is to load the driver into the klist_drivers.
struct Bus_type *bus; Represents the bus struct device_driver *driver on which the device is mounted; Indicates the device driver for the device
Add platform device to platform bus correlation function and peripheral function extern int Platform_device_register (struct platform_device *);
extern void Platform_device_unregister (struct platform_device *);
extern struct resource *platform_get_resource (struct platform_device *, unsigned int, unsigned int);
extern int Platform_get_irq (struct platform_device *, unsigned int);
extern struct resource *platform_get_resource_byname (struct platform_device *, unsigned int, const char *);
extern int Platform_get_irq_byname (struct platform_device *, const char *);
extern int platform_add_devices (struct platform_device * *, int);




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.