UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Adventurer
Adventurer
670 Views
Registered: ‎02-09-2017

how to switch i2c controller mode in the linux application?

I use zynq to connect a BMC. They use i2c channel to transfer ipmi data.

In the ipmi specifications,zynq i2c controller needs to change modes between i2c master and i2c slave.

 

I have known the i2c controller driver (i2c-cadence) supports both master and slave mode. But I do not know how to switch modes in the linux app.

 

Can someone tell me how to solve the problem?

 

Thanks very much~

0 Kudos
4 Replies
Moderator
Moderator
624 Views
Registered: ‎06-27-2017

Re: how to switch i2c controller mode in the linux application?

Hi @felven,

 

We have validated zynq i2c slave mode using aardvark adapter as master. This adapter can be configured as master/slave. in our case its a master to read/write data to i2c slave(zynq).

 

Run 'echo slave-24c02 0x10xx > /sys/bus/i2c/devices/i2c-y/new_device' on the board after
bootup.
Here xx is the 7 bit slave address configured in aardvark adapter (we have set it 0x64 for a test)
and y is the I2C device ID, where ZCU102 will be configured as I2C slave. In 2017.1 Petalinux,
ZCU102 I2C controller is on I2C-1.
We have selected slave address as 0x64 and hence, command is,
'echo slave-24c02 0x1064 > /sys/bus/i2c/devices/i2c-1/new_device'

 

Regards,

Kranthi

-------------------

Don't forget to reply, kudo, and accept as solution.

Best Regards
Kranthi
--------------------------
Don't forget to reply, kudo, and accept as solution.
0 Kudos
Adventurer
Adventurer
613 Views
Registered: ‎02-09-2017

Re: how to switch i2c controller mode in the linux application?

Thanks for your reply. But my question is how to switch i2c mode in linux app. So users can use linux app to operate the controller.
0 Kudos
Moderator
Moderator
580 Views
Registered: ‎06-27-2017

Re: how to switch i2c controller mode in the linux application?

Hi @felven,

 

In User space we have a system call called "system". you can execute Linux command from user space by passing it as argument to it.

Below are the links to few system() function examples.

https://www.codingunit.com/c-reference-stdlib-h-function-system

https://www.techonthenet.com/c_language/standard_library_functions/stdlib_h/system.php

you have to include this system function in your linux app.

 

Regards,

Kranthi

----------------------

Don't forget to reply, kudo, and accept as solution.

 

 

 

Best Regards
Kranthi
--------------------------
Don't forget to reply, kudo, and accept as solution.
0 Kudos
Adventurer
Adventurer
564 Views
Registered: ‎02-09-2017

Re: how to switch i2c controller mode in the linux application?

Could you give a more detailed description?
Do you mean I use system() function to operate the linux driver working in different modes? But I am still confused how to change the drivers operation when the linux boots up.Could you give an example? Thanks very much.
0 Kudos