2009-07-10 16:20:15     SCCB and TWI

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

2009-07-10 16:20:15     SCCB and TWI

andy (UNITED STATES)

Message: 77054   

 

Hi

 

Am using both SRV1 and bluetechnix boards. Am trying to get the v4l driver for ov9655 to work. Apparently omnivision cameras use SCCB which is slightly different from I2C.

 

I followed the instructions to enable the i2c and v4l driver at this link:

 

  docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:v4l_blackfin_camera

 

But that is not sufficient due to the SCCB protocol as mentioned before. As suggested by Michael here,

 

  blackfin.uclinux.org/gf/project/uclinux-dist/forum/?action=ForumBrowse&forum_id=39&thread_id=35077&_forum_action=ForumMessageBrowse

 

I checked the SRV Surveyor forums and found a patch at this link:

 

  www.section5.ch/customer/surveyor/srv1-patch.tgz

 

The weird thing about this patch is that it does not actually do any modifications to the blackfin twi driver at all! instead it seems to be adding driver files for a micron sensor : mt9p031 !! And also it is modifying the kernel config files to accommodate this sensor and also selecting this sensor!!

Then it is adding the srv jpeg encoding stuff etc ...

I am not understanding how adding mt9p031 and also choosing it as one of the sensors is helping in getting the 9655 driver to work!!!

 

Then on going through the BF537 HRM, I see that SCCB can be enabled on the TWI by setting a particular bit on the TWI control register. Now this needs to be done and the necessary changes have to be made to the following file:

 

linux-2.6.x/drivers/i2c/busses/i2c-bfin-twi.c I think. But am not sure how to go about doing this. Has anyone got the V4L driver for ov9655 to work after modifying the i2c driver? If so could you plz tell me how to go about it.

 

thanks.

QuoteReplyEditDelete

 

 

2009-07-10 16:31:00     Re: SCCB and TWI

Mike Frysinger (UNITED STATES)

Message: 77056   

 

you can enable the SCCB bit globally by editing the driver and going to i2c_bfin_twi_probe().  add it to the write_CONTROL() line.

 

this will enable SCCB for all clients though ...

QuoteReplyEditDelete

 

 

2009-07-11 12:50:03     Re: SCCB and TWI

Frank Van Hooft (CANADA)

Message: 77057   

 

This is a very interesting thread. If our hardware changes as we think it might, we'll end up with both I2C and SCCB devices on the TWI bus. By the sound of it, the driver will need to switch modes back & forth appropriately to accomodate this.

QuoteReplyEditDelete

 

 

2009-07-11 14:08:40     Re: SCCB and TWI

Mike Frysinger (UNITED STATES)

Message: 77058   

 

i dont believe any linux system supports sccb functionality.  i dont really see any place in the i2c client structure to control this either.  you might be able to hijack the address field (since it is declared as a short but only 7 bits are needed) ...

 

in bfin_twi_{smbus,master}_xfer(), if the highest bit is set, enable sccb, else clear it.

 

just a thought of how to do it in a not-quite-so-hacky fashion ...

QuoteReplyEditDelete

 

 

2009-07-16 20:18:29     Re: SCCB and TWI

andy (UNITED STATES)

Message: 77490   

 

Sorry for the delayed response. I have taken up the hackish method for now. I did the following in the i2c-bfin-twi.c:

 

#define SCCB 0x0200

 

write_CONTROL(iface, read_CONTROL(iface) | SCCB); //inside probe

        SSYNC();

 

Now am getting the following message:

 

root:/> modprobe blackfin-cam                                                 

Linux video capture interface: v2.00                                          

i2c-bfin-twi i2c-bfin-twi.0: Blackfin BF5xx on-chip I2C TWI Contoller Driver, V0

inside sensor_attach_adapter                                                  

inside sensor_detect_client                                                   

OV9655: detecting client on address 0x60                                      

OV9655: V4L driver Blackfin CMOS Camera now ready                             

inside sensor_detect_client                                                   

OV9655: detecting client on address 0x62                                      

Unable to register Video4Linux driver for Blackfin CMOS Camera                

OV9655: init error 0xffffffe9                                                 

i2c-adapter i2c-0: Client creation failed at 0x31 (-23)                       

OV9655: i2c driver ready  

 

It is supposed to be detected only at 0x60. Am not sure why it is detecting again at 0x62 and also why it is failing.

 

Any ideas??

QuoteReplyEditDelete

 

 

2009-07-17 07:32:21     Re: SCCB and TWI

Robin Getz (UNITED STATES)

Message: 77544   

 

Andy:

 

I'm not sure that is it found it - or it searched both addresses, and couldn't find anything.

 

Can you find the part in U-Boot (electrically - things are connected OK?)

 

-Robin

QuoteReplyEditDelete

 

 

2009-07-17 12:09:52     Re: SCCB and TWI

andy (UNITED STATES)

Message: 77571   

 

The change to the TWI driver by enabling SCCB has been done on the linux driver. U-Boot must be still running the normal I2C driver right and hence will not be able to detect the camera?

QuoteReplyEditDelete

 

 

2009-07-17 12:52:04     Re: SCCB and TWI

Robin Getz (UNITED STATES)

Message: 77575   

 

Andy:

 

Yes - you would need to make the same mods in the U-Boot driver - as well - the ident command would not work - since in SCCB, slave asserted acknowledgement bits are ignored.

 

-Robin

QuoteReplyEditDelete

 

 

2009-07-17 19:25:24     Re: SCCB and TWI

andy (UNITED STATES)

Message: 77586   

 

I looked into the I2C driver for u-boot. It is using fsl_i2c srtucture defined in fsl_i2c.h. cr represents the control register. The thing is, it has been defined to be 8 bits. For enabling the I2C, the author does a writeb(I2C_CR_MEN, &I2C->cr) in i2c_init() (in /drivers/fsl_i2c.c). Now the SCCB bit is the 9th bit. How do I make that bit high?

QuoteReplyEditDelete

 

 

2009-07-17 23:52:41     Re: SCCB and TWI

Mike Frysinger (UNITED STATES)

Message: 77592   

 

huh ?  the Blackfin code does not use fsl_i2c anywhere.  the Blackfin TWI driver is called bfin-twi_i2c.c.

QuoteReplyEditDelete

 

 

2009-07-18 02:36:08     Re: SCCB and TWI

andy (UNITED STATES)

Message: 77598   

 

Am using u-boot-1.1.6-2008R1.5. grep for the file you mentioned did not return anything. I looked into the drivers folder and found fsl_i2c.c to be the only file related to I2C. are you talking about the linux driver? Am trying to modify the u-boot i2c driver. May be am overlooking something completely and sounding dumb! correct me if am wrong.

QuoteReplyEditDelete

 

 

2009-07-18 02:40:21     Re: SCCB and TWI

andy (UNITED STATES)

Message: 77599   

 

Ok. Under /cpu/blackfin I found i2c.c. May be that is the actual i2c driver being used by blackfin and not fsl_i2c in the /drivers folder?

QuoteReplyEditDelete

 

 

2009-07-20 17:03:43     Re: SCCB and TWI

andy (UNITED STATES)

Message: 77773   

 

Ok, in i2c.c I did the following:

 

#define SCCB 0x0200

 

bfin_write_TWI_CONTROL(TWI_ENA | prescale | SCCB);

 

Now when I do an iprobe, I get the following:

 

Valid chip addresses: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 ........ and it keeps going till the end of the screen.

 

Without enabling SCCB, iprobe returns nothing. Now what is the problem??

QuoteReplyEditDelete

 

 

2009-07-21 22:21:42     Re: SCCB and TWI

Robin Getz (UNITED STATES)

Message: 77800   

 

Andy:

 

SCCB tells the hardware to ignore ACKs (or better yet - missing ACKs) from the slave - so like I said - iprobe will return positive on every address.

 

You need to use the low level commands to try to read a register.

 

-Robin

Attachments

    Outcomes