LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-17-2015, 07:52 AM   #1
Tom68
LQ Newbie
 
Registered: Jun 2015
Posts: 3

Rep: Reputation: Disabled
User Space I2C Access Arbitration


If this is not the correct forum for this question please direct me.

I have an I2C port connected to two devices: a touch screen and a temperature sensor. The touch screen has a kernel driver accessing it.

I want to access the temp sensor from user space by directly accessing the I2C bus via a file in the /dev directory. This seems to work OK.

My question is does the kernel arbitrate access to the I2C port? In other words, what if my process tries to access the temp sensor at the same time the touch screen driver is accessing the touch screen?

Will the kernel queue up the requests?

Thanks
 
Old 06-22-2015, 06:46 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,876
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
It might be better to ask a moderator if this could be placed into one of the forums for Linux Kernel, or Linux Hardware.

My first take on this would be that I'd assume the touch screen programs and whatever programming you'd be doing would both be using the Linux kernel based I2C driver, and likely the same driver in both cases.

You wouldn't be writing within that driver, you'd just be using the one which is in the kernel and accessible for when you have a program which requests I2C access.

Therefore "that I2C driver" would be the component in this which would take care of both programming resource arbitration as well as I2C bus arbitration.

I2C bus arbitration always exists with the assumption that you need to use a start sequence to get on the bus and then put out the address of the device you wish to speak too. You are not supposed to issue the start sequence if the bus is in a certain condition, such as you cannot bring the bus signal high for some reason, I forget the actual signal state but it is standard I2C bus arbitration which is electrical signaling. And further, once you've detected that you're out of sequence, or have lost arbitration, you're supposed to detect a future I2C stop condition, which is a reversion of the signal to the opposite sense from where it's at, as an indicator that you can now have access. For instance, you can check to see if the bus is high, if so, you can proceed. If it's low, you can try to bring it high, and if that works, you can proceed. If it's low, you can also just wait for it to go high. Or if it's low and you try to bring it high, but are unsuccessful, you have to conclude that you can't have the bus, and then continue to wait. Problems would be if there were failing hardware grounding the bus all the time, then communications would never work. But that's understood and there would have to be a hardware fix to resolve that problem.
 
Old 06-22-2015, 07:01 AM   #3
Tom68
LQ Newbie
 
Registered: Jun 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thank you for your response.

Yes, like you, I'm thinking that both the touch screen driver and the second process will ultimately get at the I2C port through the same driver and at that point they would be arbitrated.

I was hoping for a definite confirmation, but I sincerely do appreciate your response.

In all my searching and reading, I can't find any info that delves that low into how Linux works. I don't currently have the time to start working on learning Linux low level drivers.

Can anyone else confirm or direct me toward more information?
 
Old 06-22-2015, 07:05 AM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,876
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
To be more clear, the I2C kernel driver is only ever going to serve one I2C process at a time. The actions are atomic, in that you'll have i2c_read() or i2c_write() and those will be protected from being interfered with until they are complete. But you can have interleaved reads and writes for the various devices.
 
Old 06-22-2015, 07:16 AM   #5
Tom68
LQ Newbie
 
Registered: Jun 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
OK, great. That's how I expected it might work. I was looking for someone to confirm it. Thanks.

I'm perfectly fine with interleaved access as long as either process doesn't cancel the others transaction. So I should be OK.

Thanks again.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading via I2C from User Space very CPU consumimg tj62 Linux - Embedded & Single-board computer 2 03-24-2014 04:09 AM
user space I2C in Pandaboard sskece Linux - Newbie 0 03-20-2013 04:44 PM
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

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:50 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration