fdetre
Posts: 2
Joined: Wed Jul 04, 2018 9:37 am

DT for two sc16is740 connected in the same i2c bus

Wed Jul 04, 2018 10:26 am

Hello,

I have a homeboard connected to a RPI3 with the GPIOS. Two sc16is740 are connected on this board.
The first sc16is740 has the address 0x4C and the other one 0x4D.
I created a sc16is740-overlay.dts file with the following content :

Code: Select all

/dts-v1/;
/plugin/;
/ {
	compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
	[email protected] {
		target = <&i2c_arm>;
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";
			sc16is740: [email protected] {
				compatible = "nxp,sc16is740";
				reg = <0x4C>; /* address */
				clocks = <&sc16is740_clk>;
				interrupt-parent = <&gpio>;
				interrupts = <19 2>; /* IRQ_TYPE_EDGE_FALLING */
				sc16is740_clk: sc16is740_clk {
					compatible = "fixed-clock";
					#clock-cells = <0>;
					clock-frequency = <14745600>; /* XTAL freq */
				};
			};
		};
	};
	
	[email protected] {
                target = <&gpio>;
                __overlay__ {
			sc16is740_pins: sc16is740_pins {
				brcm,pins = <19>;
                                brcm,function = <0>; /* in */
			};
		};
	};
	
	__overrides__ {
		addr = <&sc16is740>,"reg:0";
   		clkrate = <&sc16is740_clk>,"clock-frequency:0";
    		irqpin = <&sc16is740>,"interrupts:0",<&sc16is740_pins>,"brcm,pins:0";
    	};
};
When I type the command i2cdetect -y 1 I can see the UU for the address 0x4C and if I change the address to 0x4D in the dts file I can the the UU for the address 0x4D.

The problem comes when I try to make them both working.

I tried to change the dts file with the following :

Code: Select all

/dts-v1/;
/plugin/;
/ {
	compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
	[email protected] {
		target = <&i2c_arm>;
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";
			sc16is740: [email protected] {
				compatible = "nxp,sc16is740";
				reg = <0x4C>; /* address */
				clocks = <&sc16is740_clk>;
				interrupt-parent = <&gpio>;
				interrupts = <19 2>; /* IRQ_TYPE_EDGE_FALLING */
				sc16is740_clk: sc16is740_clk {
					compatible = "fixed-clock";
					#clock-cells = <0>;
					clock-frequency = <14745600>; /* XTAL freq */
				};
			};
			sc16is740_1: [email protected] {
				compatible = "nxp,sc16is740";
				reg = <0x4D>; /* address */
				clocks = <&sc16is740_1_clk>;
				interrupt-parent = <&gpio>;
				interrupts = <19 2>; /* IRQ_TYPE_EDGE_FALLING */
				sc16is740_1_clk: sc16is740_clk {
					compatible = "fixed-clock";
					#clock-cells = <0>;
					clock-frequency = <14745600>; /* XTAL freq */
				};
			};
		};
	};
	
	[email protected] {
        target = <&gpio>;
        __overlay__ {
			sc16is740_pins: sc16is740_pins {
				brcm,pins = <19>;
                		brcm,function = <0>; /* in */
			};
		};
	};
	
	__overrides__ {
		addr = <&sc16is740>,"reg:0";
		addr2 = <&sc16is740_1>,"reg:0";
        	clkrate = <&sc16is740_clk>,"clock-frequency:0";
        	clkrate2 = <&sc16is740_1_clk>,"clock-frequency:0";
        	irqpin = <&sc16is740>,"interrupts:0",<&sc16is740_pins>,"brcm,pins:0";
    };
};
But unfortunately only the 0x4D is working...
I also tried to create two different files and just changed the address inside but the result is the same.

Can anyone tell me where I made a mistake?

Have a good day!

François

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1879
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: DT for two sc16is740 connected in the same i2c bus

Wed Jul 04, 2018 11:35 am

The first step is to look at the output of the "dmesg" command for errors and warnings, but my guess is that the fact that both devices are configured to use the same GPIO for interrupts may be causing a problem. You can test this hypothesis by modifying one of the instances to use a different pin - 20, say - and seeing if that makes a difference.

I would still only expect one of the two devices to work properly because one of them is now relying on the wrong pin for interrupts, but by swapping the pin usage between the two instances you should find that both interfaces are available and that the one using GPIO 19 actually works.

fdetre
Posts: 2
Joined: Wed Jul 04, 2018 9:37 am

Re: DT for two sc16is740 connected in the same i2c bus

Wed Jul 04, 2018 2:22 pm

You're absolutely right! I just put it on another GPIO and i works great!

Thanks a lot!

Return to “Device Tree”