LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-25-2018, 09:11 PM   #1
rksyeung
Member
 
Registered: Feb 2018
Posts: 71

Rep: Reputation: Disabled
How to port I2C Device Driver


[My apology - this editor apparently removes all the blank spaces, thus messing up the simple diagram. Just note there're two dashed lines each representing an I2C bus. And there're two I2C devices mentioned: dev-1 and dev-m, representing 'm' devices on the 2nd I2C bus]

First let me depict the system blocks:

I2C-0 I2C
CPU ------------- uC ---+------------+----
| |
dev-1 ..... dev-m

There is an I2C bus master on the CPU. It's already UP and running, and shows up as /dev/i2c-0. There is another micro-controller (uC) connected to the CPU, and it implements another I2C bus. The driver (.ko and .so) running on CPU is already available for this I2C bus. Hanging off it is a bunch of I2C devices we already supported on a different platform.

We want to reuse much of these I2C device drivers and application codes. Where should we make change to integrate the .ko and .so to port these drivers over with minimal code changes, and without destroying the /dev/i2c-0 functionalities?

By the same token, and hopefully, public domain utilities like i2cget, i2cset could also be used to access this 2nd i2c bus.

Last edited by rksyeung; 07-25-2018 at 09:17 PM. Reason: Clarify system diagram
 
Old 07-27-2018, 12:04 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Configure your Linux system to add the second I2C bus and then use the applications code you have. You do not need to port a driver.
 
Old 07-27-2018, 01:35 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,009

Rep: Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629
When you say port, where did you get the source from? That is really the key to what you need to do.

Does this setup work on any OS?



Some version of linux or what. Some of these devices have some support by the OEM's too.

Plenty of sites have help.
https://www.kernel.org/doc/Documenta.../dev-interface
https://elinux.org/Interfacing_with_I2C_Devices
 
Old 07-27-2018, 01:45 PM   #4
rksyeung
Member
 
Registered: Feb 2018
Posts: 71

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rtmistler View Post
Configure your Linux system to add the second I2C bus and then use the applications code you have. You do not need to port a driver.
Maybe there is misunderstanding. We already have a lot of codes, drivers and applications, sitting on all the I2C devices from another platform. This new platform copies a lot of those hardware design, except the I2C controller is replaced. If we try to simply use the new driver directly, we could be changing a lot of codes, as the signatures of the drivers are different. Alternative is to write wrappers.
 
Old 07-27-2018, 01:49 PM   #5
rksyeung
Member
 
Registered: Feb 2018
Posts: 71

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jefro View Post
When you say port, where did you get the source from? That is really the key to what you need to do.

Does this setup work on any OS?



Some version of linux or what. Some of these devices have some support by the OEM's too.

Plenty of sites have help.
https://www.kernel.org/doc/Documenta.../dev-interface
https://elinux.org/Interfacing_with_I2C_Devices
The new I2C driver (.ko and .so) is released by the vendor providing us the CPU module. I'm thinking about "plug and play" - plugging in the new I2C driver somewhere, and the rest of the I2C dependent codes simply work. I've been looking into the I2C driver architecture, in which they talk about Client, Core, Adaptor, Bus, Class, Algorithm etc., along the line of the Linux Kernel Driver Model. At this point, I've a feeling we may need to look into defining wrapping for the bus/algorithm objects.

To answer your specific question - this 3rd party driver is proven to work on Linux (YP), as we run its demo code, and had implemented some i2cget/i2cset utilities on top of it.
Thoughts?

Last edited by rksyeung; 07-27-2018 at 01:51 PM.
 
Old 07-28-2018, 09:32 AM   #6
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
Your question is rather broad. Is there anything more specific?
 
Old 07-29-2018, 01:05 PM   #7
rksyeung
Member
 
Registered: Feb 2018
Posts: 71

Original Poster
Rep: Reputation: Disabled
Hi AwesomMachine, have you read my original post? I thought all needed background information is there, and the specific question is also there.
 
  


Reply



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 write new i2c device driver? pilliskanth Linux - Software 4 04-17-2015 06:02 PM
how to implement new i2c device driver? pilliskanth *BSD 1 04-16-2015 07:06 AM
How to access i2c device driver node farrukh_arshad Linux - Kernel 7 12-19-2012 10:05 PM
I2C device driver mylinuxdna Linux - General 0 10-10-2005 02:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:02 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