LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 05-19-2011, 06:07 AM   #1
farrukh_arshad
LQ Newbie
 
Registered: Dec 2010
Posts: 7

Rep: Reputation: 0
How to access i2c device driver node


Greetings All,

Situation 1:
============
I have an i2c chip driver as part of linux kernel. I can verify the i2c chip driver is in the kernel from kernel boot messages (my chip driver is mma8450)

dmesg:

mma8450 0-001c: uevent

I can also see this driver in (0x1c is i2c address of chip)

cat /sys/bus/i2c/devices/0-001c
mma8450

I can not see this driver node in /dev interface. My question is how can I create node of this device in /dev so that I can access this device in a user program ?

Situation 2:
============
I create the module of the same chip driver and does not make it a part of kernel. I can load this module using insmod mma8450, how can I create a node of this device as I don't have its major / minor numbers ? (I can not see major & minor numbers assigned to this driver in mma8450 source code)

Any help is appreciated

Regards,
Farrukh Arshad.
 
Old 05-20-2011, 05:15 AM   #2
bsat
Member
 
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
the command to create nodes manually is "mknod"

Code:
mknod /dev/"device name" [types of device character/block] [major number] [minor number]
The source code might not have the major number if it follows dynamic allocation of major number.
To get to know the major number assigned to your module look in /proc/devices,after insmod.
The first column lists the major numbers and the second column the name with which the module was registered.
 
Old 05-23-2011, 08:38 AM   #3
farrukh_arshad
LQ Newbie
 
Registered: Dec 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Hi Bsat,

Thanks for the response. My /proc/devices lists the i2c bus driver

89 i2c

and I can see the node of this driver in /dev/ as /dev/i2c-0 /dev/i2c-1. I can verify both these nodes from

/sys/bus/i2c/devices/i2c-0 /sys/bus/i2c/devices/i2c-1

I have another i2c chip driver which is also appearing in /sys/bus/i2c/devices/0-001c. I can verify the device of this driver (& its the same device I am trying to access) from

cat /sys/bus/i2c/devices/0-001c/name.

I don't see any node for this device in /dev/

or perhaps I am asking the wrong question or doing it the wrong way. My problem is simple (i think so). I have a i2c accelerometer attached on i2c bus of my board. I can see the driver for this i2c chip in my linux system as I have mentioned above (/sys/bus/i2c/devices/0-001c/name). Now I want to access this chip through this driver, for which I believe in need a device node in /dev/ to open from a user space program, but I can't see the node !!

I was reading an article (http://www.linuxjournal.com/article/7252?page=0,0) that i2c chip drivers expose their parameter values (readable/writable) in sysfs (each exposed parameter will create a file in sysfs). My question, should such i2c chip driver will be accessed through sysfs and if yes then how. Wouldn't my user space program will be highly dependent on one particular driver implementation.

Any thought or help is appreciated.

Regards,
Farrukh Arshad.
 
Old 05-23-2011, 08:54 AM   #4
robvoo
LQ Newbie
 
Registered: Jul 2009
Distribution: debian, ubuntu
Posts: 22

Rep: Reputation: 2
i2c-dev

Did you include/load the i2c-dev module?
Check your kernel config file, or try
"lsmod | grep i2c-dev"

This creates the /dev/ references for the i2c bus.

Search the kernel documentation for more information (have a look at this link)
http://www.mjmwired.net/kernel/Docum.../dev-interface
 
Old 06-02-2011, 04:47 PM   #5
AustinMarton
Member
 
Registered: May 2007
Location: New Zealand
Distribution: Fedora at home, Ubuntu 10.04 at work
Posts: 88

Rep: Reputation: 16
When you do
Code:
cat /proc/devices
I would expect you to see a device for the i2c bus (at 89) AND the i2c device itself. If it hasn't been done automatically, you should be able to create a device node in /dev for the i2c device driver using mknod as bsat suggested:
Code:
mknod /dev/[device name] [type] [major number] [minor number]
Does that work?

Last edited by AustinMarton; 06-02-2011 at 04:50 PM.
 
Old 06-02-2011, 05:00 PM   #6
AustinMarton
Member
 
Registered: May 2007
Location: New Zealand
Distribution: Fedora at home, Ubuntu 10.04 at work
Posts: 88

Rep: Reputation: 16
Also, where did you find the driver? Are you trying to use this recently submitted patch http://www.spinics.net/lists/lm-sensors/msg32062.html ? I can't find any mma8450 driver in the latest kernel.
 
Old 06-03-2011, 05:51 AM   #7
farrukh_arshad
LQ Newbie
 
Registered: Dec 2010
Posts: 7

Original Poster
Rep: Reputation: 0
I am bit busy in other work so I haven't tried this so far. Will let you know when I do this.

Not sure about the patch you have mentioned but I found the driver from Freescale iMX53 Quick Start Board BSP for Linux provided by Freescale. http://www.freescale.com/webapp/sps/...sign_Tools_Tab

Go to "Board Support Packages" and download the file L2.6.35_11.03_ER_SOURCE. Apply patches and you will have your driver in kernel source.
 
Old 12-19-2012, 10:05 PM   #8
garryhk
LQ Newbie
 
Registered: Nov 2012
Posts: 16

Rep: Reputation: Disabled
HI farrukh_arshad,

I ma new to device driver,,,Board is up,,,and i wanted to check the i2c devices present in the board...

Please let me know how we do it?
Regards,
Girish
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to access register set of an i2c device from user space ? tanniru Linux - Kernel 1 04-26-2011 07:22 AM
How to access register set of an i2c device from user space ? tanniru Linux - Networking 0 04-26-2011 01:57 AM
Creating A New Device Node/Not A Valid Block Device indienick Debian 4 07-13-2007 02:07 PM
I2C device driver mylinuxdna Linux - General 0 10-10-2005 02:16 AM


All times are GMT -5. The time now is 07:39 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration