Linux Hacks: Platform Device and Platform Driver at Linux
Linux Hacks: Platform Device and Platform Driver at Linux
Linux Hacks: Platform Device and Platform Driver at Linux
platform data. This Platform data will pass to driver. Generally Platform data is the device specific data. Eg: Bus id,
interrupts ,etc ..
Here i have created pseudo device and driver to develop clear understanding of all these. In your board header file
declare a private data structure according to resources used by your device. Here, i am declaring test_platfrom_data.
The snippet 1 below will provide more information about members of test_platform_data.
Snippet 1
In my board c file i have created instance of this structure with appropriate data. This user defined structure will
passed to the driver w. Snippet 2 will provide you details about private data which is assigned to structure instance.
Snippet 2
Now its time to define platform device in board file. In Linux kernel struct platform_device is declared. Lets create a
instance of this structure. This will passed to kernel for registration of platform device. Snippet 3 will show you
definition of platform device.
Snippet 3
The main important point is the name of device. Here in my case name of my device is drivertest. From board init
function add line(shown by snippet 4) to register this platform device.
After this edition in board file, compile kernel using appropriate cross compiler and boot your board with this kernel.
Snippet 4
After success full booting of board, start making driver(.ko) file for your registered device. Structure platfrom_driver is
used to register platform driver. Here, snippet below shows the definition of platfrom_driver structure. Register
platform driver in init function using platfrom_driver_register.
Follow
Snippet 5
FollowLinuxhacks
Here, the impotent thing is the name of driver. Name of driver is as same as the name of device(in board file). On the
registration of new platform driver, linux kernel compare
Geteverynewpostdelivered
its name with the previously defined all platform device
name. If the match is found the probe function of thetoyourInbox.
driver is called with appropriate data which is responsible to
initialize the device. The whole device structure is passed through probe function. The snippet below shows the
subroutine for probe function.
Enteryouremailaddress
Sign me up
PoweredbyWordPress.com
Snippet 6
In the probe function of driver, i have extracted platform data from probe, which is assigned to the device at the
booting time. This platform_data contains all the low level information about device. On the basis of this data, probe
function initialize the device and irq using this data. Generally this data contains the information about module id, data
rate, interrupt etc..
I have compiled module and the output i is pasted below which shows the platform data is extracted from the probe.
output sdfdfas
Abouttheseads
YouMayLike
1.
Share this:
StumbleUpon
Like
Onebloggerlikesthis.
shah.b
May 14, 2014 at 12:58 am
Thanks Harshil Makwana.
Reply
dat
May 28, 2014 at 4:37 am
Thank you so much. I understand cleary about it from your text. ^-^
Reply
Nilesh