Character Device Driver note-platform device driver mechanism (1)

Source: Internet
Author: User

 

Platform device registration analysis:/* for the following resources, read the chip manual and view the schematic diagram */
---------------------------------------------------------
ARCH/ARM/plat-s3c24xx/Devs. c/* Most device controller resources are defined here */
/* LCD controller */
Static struct resource maid [] = {
[0] = {
. Start = s3c24xx_pa_ LCD,
. End = s3c24xx_pa_ LCD + s3c24xx_sz_ LCD-1,
. Flags = ioresource_mem,
},
[1] = {
. Start = irq_ LCD,
. End = irq_ LCD,
. Flags = ioresource_irq,
}
};

Static u64 maid = 0 xfffffffful;

Struct platform_device initi_device_ LCD = {
. Name = "s3c2410-lcd ",
. ID =-1,
. Num_resources = array_size (initi_ LCD _resource ),
. Resource = maid,
. Dev = {
. Dma_mask = & cloud_device_ LCD _dmamask,
. Coherent_dma_mask = 0 xfffffffful
}
};
/* The above just defines some resources. We need to register them to the linked list of platform devices */
ARCH/ARM/mach-s3c2410/mach-smdk2410.c
Static struct platform_device * smdk2410_devices [] _ initdata = {
& Initi_device_usb,
& Amp; cloud_device_ LCD,
& Amp; cloud_device_wdt,
& Amp; initi_device_i2c,
& Amp; cloud_device_iis,
& Amp; cloud_device_sdi
};
Static void _ init smdk2410_init (void)
{
S3c24xx_fb_set_platdata (& smdk2410_lcdcfg );
Platform_add_devices (smdk2410_devices, array_size (smdk2410_devices ));
......................
}
Platform_add_devices/* What does this function do */
Bytes -----------------------------------------------------------------------------------
For (I = 0; I <num; I ++ ){
Ret = platform_device_register (Devs [I]);

Platform_device_register/* this function is used to show how to load device resources to the device linked list */
Int platform_device_register (struct platform_device * pdev)
{
// Initialize device Properties
Device_initialize (& pdev-> Dev );
// Add the device to platfrom
Return platform_device_add (pdev );
}
Platform_device_add
Pdev-> Dev. Bus = & platform_bus_type;
...........
Ret = device_add (& pdev-> Dev);/* Start loading */
............../* Add device resources to the device linked list */
Bus_attach_device (Dev);/* find the driver to match */
Ret = device_attach (Dev );
/* Search for each driver in the drive list on the bus and call _ device_attach */
Ret = bus_for_each_drv (Dev-> bus, null, Dev, _ device_attach );

_ Device_attach:/* calls the same function as the driver. It calls the match function in the bus struct and matches the function by name */
------------------------------------------------------------------------------

 

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.