cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
yinlinlijuan
Adventurer
Adventurer
4,991 Views
Registered: ‎03-14-2012

Is there i2c driver in linux os for i2c interface of zynq ps ?

 

Hi,

 

I want to use PS i2c interface. I have downloaded kernel of linux-xlnx from github. Is there ps i2c driver in it ?

 

 

Addtionally, I hope that there is an introduction to the interface between i2c driver and application so that I can quickly know how can I wirte or read i2c device in my application.

 

I have know ug925 design, I only find that their is only i2c_utils.c which runs at FSBL state which is no OS. But I hope I can in my application to W/R i2c device, so I need to know the interface or usage of ps i2c driver. Can you give advice ?

 

Thans.

 

Chen.

  

0 Kudos
3 Replies
sorenb
Xilinx Employee
Xilinx Employee
4,988 Views
Registered: ‎03-13-2012

There is a driver https://github.com/Xilinx/linux-xlnx/blob/master-next/drivers/i2c/busses/i2c-cadence.c (it was renamed a few times recently though, IIRC, it was i2c-zynq before and i2c-xilinxps before that).

 

I also gave the overviewi in the wiki (http://www.wiki.xilinx.com/Linux+Drivers ) a minor update (edits welcome).

 

Regarding usage, I'm sure there are plenty of examples available in the web for how to use I2C in Linux. That is not specific to Zynq or Xilinx.

0 Kudos
asigint
Visitor
Visitor
4,959 Views
Registered: ‎10-02-2013

Look at the post zc706 - i2c Linux doesn't see port expander.

 

An easy way to use I2C is with the i2c-tools which you can download if necessary via apt-get.  Using i2cdetect, you should be able to see a map of i2c devices like in the post.  The wiki Interfacing with I2C Devices gives some user code examples but for me the i2cget and i2cset commands in i2c-tools work great.

 

Just make sure i2c support is compiled in the kernel you are using.  My kernel didn't fully support the port expander until I changed the config and rebuilt (see here).  You will also want to make sure your devicetree is setup correctly.  Here's the section of mine that I cobbled together from multiple sources:

		ps7_i2c_0: ps7-i2c@e0004000 {
			bus-id = <0>;
			clocks = <&clkc 38>;
			compatible = "xlnx,ps7-i2c-1.00.a";
			i2c-clk = <400000>;
			i2c-reset = <&ps7_gpio_0 46 0>;
			interrupt-parent = <&ps7_scugic_0>;
			interrupts = <0 25 4>;
			reg = <0xe0004000 0x1000>;
			xlnx,has-interrupt = <0x0>;
			#address-cells = <1>;
			#size-cells = <0>;
			i2cswitch@74 {
				compatible = "nxp,pca9548";
				#address-cells = <0x1>;
				#size-cells = <0x0>;
				reg = <0x74>;

				i2c@0 {
					#address-cells = <0x1>;
					#size-cells = <0x0>;
					reg = <0x0>;

					osc@5d {
						compatible = "si570";
						reg = <0x5d>;
						factory-fout = <0x9502f90>;
						initial-fout = <0x8d9ee20>;
					};
				};

				i2c@2 {
					#address-cells = <0x1>;
					#size-cells = <0x0>;
					reg = <0x2>;

					eeprom@54 {
						compatible = "at,24c08";
						reg = <0x54>;
					};
				};

				i2c@3 {
					#address-cells = <0x1>;
					#size-cells = <0x0>;
					reg = <0x3>;

					gpio@21 {
						compatible = "ti,tca6416";
						reg = <0x21>;
						gpio-controller;
						#gpio-cells = <0x2>;
					};
				};

				i2c@4 {
					#address-cells = <0x1>;
					#size-cells = <0x0>;
					reg = <0x4>;

					rtc@54 {
						compatible = "nxp,pcf8563";
						reg = <0x51>;
					};
				};

				i2c@5 {
					#address-cells = <0x1>;
					#size-cells = <0x0>;
					reg = <0x5>;

					eeprom@50 {
						compatible = "at,24c02";
						reg = <0x50>;
					};
				};

				i2c@6 {
					#address-cells = <0x1>;
					#size-cells = <0x0>;
					reg = <0x6>;

					eeprom@50 {
						compatible = "at,24c02";
						reg = <0x50>;
					};
				};

				i2c@7 {
					#address-cells = <0x1>;
					#size-cells = <0x0>;
					reg = <0x7>;

					hwmon@52 {
						compatible = "pmbus,ucd9248";
						reg = <0x34>;
					};

					hwmon@53 {
						compatible = "pmbus,ucd9248";
						reg = <0x35>;
					};

					hwmon@54 {
						compatible = "pmbus,ucd9248";
						reg = <0x36>;
					};

					hwmon@101 {
						compatible = "pmbus,ucd90120";
						reg = <0x65>;
					};
				};
			};
		} ;

 It's for a ZC706 board, so you need to make sure your file matches your board.

 

Hope all this helps!

0 Kudos
sorenb
Xilinx Employee
Xilinx Employee
4,953 Views
Registered: ‎03-13-2012


@asigint wrote:
[...]
You will also want to make sure your devicetree is setup correctly.  Here's the section of mine that I cobbled together from multiple sources:

[...]

 It's for a ZC706 board, so you need to make sure your file matches your board.



Your DT really looks "cobbled together". It probably doesn't lead to any errors, but the dts should describe your board/platform. You seem to have copied the I2C bus slaves from various sources, including devices that are not present on the zc706 (e.g. the UCD9248, I suspect you copied those from a zc702 dts).

0 Kudos