Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12612 Discussions

Problem using more than 2 i2c devices

Altera_Forum
Honored Contributor II
1,037 Views

We have instantiated 7 i2c controllers in our FPGA. 

 

I modified the busses/i2c-oc.c code to handle 7 of these instead of just 2. 

Basically, I just copied the two instances provided and changed their numbering so that it was 2, 3, 4, 5, and 6 in addition to 0 and 1. 

 

I also created new device file entries with "mknod /dev/i2c-N c 89 N". 

 

Basically, the driver successfully detects and adds the adapters during kernel boot. 

However, when it comes time to open the device files, it complains that it either "cannot create", or that there's "No such device". 

 

It clearly is not a device file issue. 

 

I've put some printk's throughout the driver and found that when it enters "i2c_get_adapter(), it has issues. 

Inside i2c_get_adapter(), it goes through each of the adapters in a list and tries to match it with the requested number "adapter->nr". 

 

It is failing here. 

 

printk's inside the i2c_add_adapter() function prove that they are getting added correctly. 

 

Why would they get messed up? Basically, ports 2-5 have an "adapter-nr" equalling 0. 

Port 6 is even more strange, but I'm thinking that once I've figured out ports 2-5, that port 6 might be OK, or at least I'll know where to look. 

 

 

Has anyone tried getting more than 2 i2c devices working using the Microtronix port for the OpenCores I2C controller? 

Has anyone had any issues related to this? 

 

I have a feeling that it is some simple dumb thing that I've forgotten to do, but I've spent several days now without any luck. 

 

Any help would be greatly appreciated. 

 

Thanks.
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
324 Views

I am not sure what root file system you are using. If you happen to use romfs, I would recommend to create the device nodes as /dev/i2c/N instead of /dev/i2c-N. Somehow the latter are not correctly generated for romfs because of the character '-'.

0 Kudos
Altera_Forum
Honored Contributor II
324 Views

We are using jffs2 for our filesystem. 

 

As it turns out, I had a problem with one of my entries for the last instance. It was erroneously overwriting the 2nd instance, during the part where it adds the adapter to the linked list. This caused the wierd behavior. 

 

After fixing this problem, everything worked. 

 

We have 7 working i2c ports!
0 Kudos
Altera_Forum
Honored Contributor II
324 Views

Can you post what you have done?  

Wich file's doe you mod? and what? 

I am very intrested. And maybe others?
0 Kudos
Reply