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

Source: Internet
Author: User


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 generally need to be registered before they can register the driver

– 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 used separate files to register devices, and now most are using the introduced virtual

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

? If you see a large section of the online registration device code, can be a simple look, 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

? The driver register uses the struct platform_driver, the struct body 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

? Device_driver two parameters of the 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

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

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

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.