WebEx for 4412 Development Board Linux Driver Tutorial--Bus _ device _ Driver Registration process detailed

Source: Internet
Author: User

This article transferred from: http://www.topeetboard.com

Video:

Driver Registration: Http://pan.baidu.com/s/1i34HcDB

Device registration: Http://pan.baidu.com/s/1kTlGkcR

Bus _ Device _ driver registration process

• Registration flowchart

• Devices are generally required to be registered before they can be registered for drive

– Now more and more hot-pluggable devices, in turn. Register the driver first, the device is registered again

Equipment

• Commands used in this section

– View the bus commands #ls/sys/bus/

– View the command for the device number #cat/proc/devices

• The device has the main device number and the secondary device number, or 255 A device number is not enough

– View the Miscellaneous device number command #cat/proc/misc

Device Registration

A little note about registering your device

• Earlier Linux uses separate files to register devices, most of which are now using the introduced virtual

Platform, using a virtual platform to enroll devices can be a lot easier

• If you see the code of a large section of registered devices on the Internet, you can get a quick look and know

There is such a thing as, do not have to delve into. Do not learn "dragon Slayer", now basically

is to register the device directly in the platform file

Registering your device

The registered device uses the struct platform_device, the struct body in the header file "vim

Include/linux/platform_device.h"in. The header file also has a registered device and an uninstall

function, you can understand.

• Operation Process

– Register the device. The device structure is placed in the platform file and the device is automatically registered without the need to adjust

Use the function that registers the device.

– Add a macro definition for the compile HELLO device in the Kconfig file (previously added in the tutorial)

– Configure the HELLO macro definition in Menuconfig to generate a new . config file

– Create a new zimage

• Registered devices can be found under virtual platform bus after registration

– ls/sys/devices/platform/

Driver Registration

• Driver Registration

– It's important to have a firm grasp of what will be used to write any Linux drive later.

• experiment

– Add the Driver Registration section on the basis of Mini_linux_module

Driver Registration--header file

• Drive registration using the struct platform_driver, the struct in the header file "vim

Include/linux/platform_device.h"in

• Driver Registration platform_driver_register, drive unload function

Platform_driver_unregister is also in this header file

– The parameters of both functions are only structure-body platform_driver

Driver Registration--registered structure

Driver Registration--registered structure

• Drive common several states, initialize, remove, hibernate, reset

– Just like a PC , some drivers are not available after hibernation, some can be used;

After waking up, the driver needs to be restarted to work properly, and it can be used directly.

• probe function

– After the Platform_match function matches, the initialization function that drives the call

• Remove function

– Removing the drive function

• suspend function

– Suspension (sleep) drive function

• Resume function

– Resume Drive after hibernation

• Two parameters of the Device_driver data structure

– name and registered device name to be consistent

– owner general assignment this_module

Experiment

• Add the driver Registration section based on the mini_linux_module

• Compile, load and unload drivers on the Development Board

WebEx for 4412 Development Board Linux Driver Tutorial--Bus _ device _ Driver Registration process detailed

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.