2008-03-07 06:21:20     i2c

Document created by Aaronwu Employee on Aug 5, 2013
Version 1Show Document
  • View in full screen mode

2008-03-07 06:21:20     i2c

Servaes Joordens (NETHERLANDS)

Message: 52194   

 

I have the 2008 trunk.

 

I try to include /dev/i2c-0 in the kernel. I want the normat TWI version. In the 2007 release this worked good, but in the 2008 trun it failed to make the node. i2c is listed in /proc/devices with major number 89, but there is no node in /dev/.

 

I already tried to build it as a loadable module and insmod and mknod it myself. The node is made, but I cannot open the device. It returned the error code -ENODEV.

 

Any ideas?

QuoteReplyEditDelete

 

 

2008-03-07 11:28:28     Re: i2c

Mike Frysinger (UNITED STATES)

Message: 52199    2008+ defaults to dynamic nodes which means nodes only get created as your kernel knows about it ... older versions always had static device nodes

 

if you havent loaded the device driver, then you wont get a device node ... simply creating the device node accomplishes nothing

 

you have to load the device driver first ... i2c-dev relies on both the i2c char device driver as well as the bus driver

QuoteReplyEditDelete

 

 

2008-03-07 19:05:52     Re: i2c

Servaes Joordens (NETHERLANDS)

Message: 52208   

 

I loaded the driver into the kernel with insmod. In the list when I type "cat /proc/devices" the i2c major numer 89 is mentioned. When i type "mknod /dev/i2c-0 c 89 0" the node is created, but I cannot use the node.

 

Should I load more modules into the kernel in order to let it work? If so, which ones?

 

Servaes

QuoteReplyEditDelete

 

 

2008-03-08 04:03:59     Re: i2c

Mike Frysinger (UNITED STATES)

Message: 52211    the i2c-dev is just a layer that converts userspace commands to i2c commands ... you still need to load a bus driver

QuoteReplyEditDelete

 

 

2008-03-08 15:58:44     Re: i2c

Servaes Joordens (NETHERLANDS)

Message: 52219    Can you tell me how to do that?

QuoteReplyEditDelete

 

 

2008-03-08 18:29:52     Re: i2c

Mike Frysinger (UNITED STATES)

Message: 52220    do what ?

QuoteReplyEditDelete

 

 

2008-03-10 04:15:04     Re: i2c

Servaes Joordens (NETHERLANDS)

Message: 52244   

 

How to load the bus driver. What is the name of the bus-driver?

QuoteReplyEditDelete

 

 

2008-03-10 07:43:08     Re: i2c

Servaes Joordens (NETHERLANDS)

Message: 52259   

 

Here is what I did:

 

I selected i2c device interface as a module.

I selected Blackfin TWI i2c support as a module.

 

On the target I did the following:

 

modprobe i2c-bfin-twi

modprobe i2c-dev

mknod /dev/i2c-0 c 89 0

 

When I try to open the file /dev/i2c-0 in my application it returns the error code -ENODEV.

 

What do I do wrong?

 

 

 

 

 

 

QuoteReplyEditDelete

 

 

2008-03-10 09:46:30     Re: i2c

Wei Jiang (CHINA)

Message: 52261    you also must be sure you add the resources in your linux/arch/blackfin/mach/boards/your-own.c

QuoteReplyEditDelete

 

 

2008-03-10 09:56:12     Re: i2c

Servaes Joordens (NETHERLANDS)

Message: 52262    Could you explain that to me? This is new to me.

QuoteReplyEditDelete

 

 

2008-03-10 10:56:07     Re: i2c

Mike Frysinger (UNITED STATES)

Message: 52264    only you know which bus driver you need/want.  you have some device hooked up to the Blackfin.  you should know which bus it is connected to.

 

if you're using a Blackfin with hardware I2C support, and you're hooking up to that, then load the Blackfin TWI bus driver.  you can find the module name in the help text in kconfig.  or use `find` on the board and look at the list of kernel modules.

QuoteReplyEditDelete

 

 

2008-03-10 11:09:33     Re: i2c

Mike Frysinger (UNITED STATES)

Message: 52265    if you're using mdev to manage device nodes, dont use mknod.  if the device node isnt showing up automatically, something else is wrong.  creating the device node wont help.

QuoteReplyEditDelete

 

 

2008-03-10 11:19:00     Re: i2c

Servaes Joordens (NETHERLANDS)

Message: 52268   

 

Mike,

 

As I said in my previous message, I use the bfin twi bus drivers. I selected it as a loadable module and I loaded it into the kernel by typing modprobe i2c-bfin-twi, so what is wrong with that?

 

Servaes

QuoteReplyEditDelete

 

 

2008-03-10 14:42:46     Re: i2c

Mike Frysinger (UNITED STATES)

Message: 52271    what board are you using ?  the default BF537-STAMP build is working fine for me using current trunk:

 

root:/> modprobe i2c-bfin-twi

i2c-bfin-twi i2c-bfin-twi.0: Blackfin BF5xx on-chip I2C TWI Contoller Driver, Version 1.8, regs_base@ffc01400

root:/> modprobe i2c-dev

i2c /dev entries driver

root:/> ls -l /dev/i2c-0

crw-rw----    1 root     root      89,   0 Jan  1 00:15 /dev/i2c-0

root:/> cat /dev/i2c-0

cat: read error: Input/output error

QuoteReplyEditDelete

 

 

2008-03-10 14:56:39     Re: i2c

Servaes Joordens (NETHERLANDS)

Message: 52273   

 

I use the Bluetechnix tcm-bf537e

 

When I do modprobe ic2-bfin-twi I get no feedback on the console like you do. So I think there is something wrong with loading that driver.

 

 

 

 

QuoteReplyEditDelete

 

 

2008-03-10 15:15:11     Re: i2c

Mike Frysinger (UNITED STATES)

Message: 52276    like Wei Jiang said, the resources are not being declared in the board resources file ... the driver is fine

QuoteReplyEditDelete

 

 

2008-03-10 15:18:37     Re: i2c

Servaes Joordens (NETHERLANDS)

Message: 52277    What is the board resource file, and what is it's use?

QuoteReplyEditDelete

 

 

2008-03-10 15:33:01     Re: i2c

Servaes Joordens (NETHERLANDS)

Message: 52278   

 

I added the twi support in the resource file. Everything is working fine now.

 

Thanks Mike and Wei!

 

What is the reason to add one extra step to enable this i2c funtionality? I already configured the kernel to use i2c over the twi interface. I also configured that it is a bf537, so why are those few line not added automatically in the resource file?

QuoteReplyEditDelete

 

 

2008-03-10 15:34:22     Re: i2c

Mike Frysinger (UNITED STATES)

Message: 52279    the board resource file is documented in our wiki in many places.  for example:

http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:customizing_for_your_board#board_resources

 

in your case, i'm guessing you're using the CM-BF537E configuration since there is no TCM version, which means you'll need to tweak cm_bf537.c

QuoteReplyEditDelete

 

 

2008-03-10 15:45:49     Re: i2c

Mike Frysinger (UNITED STATES)

Message: 52280    the resource file is maintained by hand ... nothing should be adding/removing lines to it automatically

 

we'll have to add the TWI resources to the file just like it's in the stamp

 

can you post the exact lines that you added ?  `svn diff` will show you ...

QuoteReplyEditDelete

 

 

2008-03-10 16:23:28     Re: i2c

Servaes Joordens (NETHERLANDS)

Message: 52281   

 

I see it is maintained by hand, but why?

 

It seems logical that when building a kernel for a specific board, the selected kernel options will generate a kernel that works without any manual addition.

 

diff

QuoteReplyEditDelete

 

 

2008-03-10 16:31:01     Re: i2c

Mike Frysinger (UNITED STATES)

Message: 52282    that is not the kernel paradigm ... the kernel configuration selects drivers/features, not board-specific addresses/pins.  that is what the board resource file is for.  the specific addresses/pins do not generally change for a board, so maintaining that information in the kernel configuration menu is unwieldy.

QuoteReplyEditDelete

 

 

2008-03-10 16:39:58     Re: i2c

Servaes Joordens (NETHERLANDS)

Message: 52284    OK, thanks for the info and help.

QuoteReplyEditDelete

 

 

2008-03-14 04:06:33     Re: i2c

Servaes Joordens (NETHERLANDS)

Message: 52506   

 

Ok, I can understand that the kernel configuration does not want to do hardware defining things, but let's turn it around.

 

I do not want that the kernel configuration allows certain settings that are not defined in the hardware resource file. AND I do not want the kernel to be able to compile i2c over TWI when it is not supported by the resource file. This should generate an error or at least an interactive warning.

 

What is the use of allowing certain functionality when it is not supported?

 

 

QuoteReplyEditDelete

 

 

2008-03-14 06:41:36     Re: i2c

Mike Frysinger (UNITED STATES)

Message: 52534    you're assuming everything is static ... nothing precludes you from dynamically adding platform resources at runtime

Attachments

Outcomes