Issues w/ I2c/TWI1 on a SAMA5D27 - Linux-AT91 Dunfell rel

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

stephendpmurphy
Contact:
Posts: 1
Joined: Wed Sep 23, 2020 4:13 pm

Issues w/ I2c/TWI1 on a SAMA5D27 - Linux-AT91 Dunfell rel

Wed Sep 23, 2020 4:46 pm

Hi all,

I am working on a board that uses the SAMA5D27 where we have previously used two I2c buses (TWI1/i2c1 and i2c3 via Flexcom4). We initially built and tested the boards using the Linux-AT91 6.1 release and with the recent addition of Dunfell and LTS, we decided we would update our build system and use the latest release. In doing so, I have encountered an issue during the upgrade process.

Previously we used the default i2c1 config found in the at91-sama5d27_som1_ek.dts and it worked great for our purposes (We even left the isc block in there for the camera, even though we were using the bus for a basic i2c interface to a few peripheral ICs). When updating the kernel branch to linux-5.4-at91, the default config for i2c1 no longer works. When executing our application, or even using i2cdetect on the bus, I get the error below.

Code: Select all

at91_i2c fc028000.i2c: controller timed out
After seeing the errors, I went through and properly updated the I2c1 dts config as seen below. As a sanity check and to validate my config, I also moved our I2c3 bus from Flexcom4 to the TWI0 module since they both map to the same pins (Thus causing it to enumerate as I2c0). That way I could compare apples to apples in terms of TWI config. Doing so, I2c0 works great just as before and I can communicate with the devices on our bus, while I2c1 still does not work even though the config matches (Other than updating the clock periph index, DMA indices, interrupt index and pin names/numbers).

Code: Select all

i2c1: i2c@fc028000 {
	compatible = "atmel,sama5d2-i2c";
	reg = <0xfc028000 0x100>;
	interrupts = <30 IRQ_TYPE_LEVEL_HIGH 7>;
	dmas = <&dma0
		(AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) |
		 AT91_XDMAC_DT_PERID(2))>,
		<&dma0
		(AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) |
		AT91_XDMAC_DT_PERID(3))>;
	dma-names = "tx", "rx";
	#address-cells = <1>;
	#size-cells = <0>;
	clocks = <&pmc PMC_TYPE_PERIPHERAL 30>;
	atmel,fifo-size = <16>;
        pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_i2c1_default>;
         status = "okay";
  };
  
  pinctrl@fc038000 {  
  	pinctrl_i2c1_default: i2c1_default {
		pinmux = <PIN_PD4__TWD1>,
			<PIN_PD5__TWCK1>;
		bias-disable;
	};
};
  
As a sanity check, I took a working (meaning both i2c buses work) SD card (FS, kernel, bootloaders, etc) running the 6.1 release, and replaced my .dtb with the newly generated .dtb and i2c config seen above. In doing so, both i2c buses still work.

This seems to point to the kernel and/or i2c drivers in the latest release. I noticed that the menu-config of the new Kernel as a couple new options in relation to i2c (The i2c driver has an option called "Atmel AT91 I2c Two-Wire interface") which further grows my suspicion that something has changed and is occurring in the driver and/or kernel.

I've noticed that on all of the dev-kits the OV-X / ISC interface is always placed on the I2c1 bus. Is it possible that Microchip/Atmel has placed something in the driver that defaults to trying to use the bus for ISC and taking precedence/causing conflicts when I try to use it in userland?

Any help or insight is appreciated. Please let me know if you need more specific information or versioning to assist.

Thanks,
Stephen
blue_z
Location: USA
Posts: 2117
Joined: Thu Apr 19, 2007 10:15 pm

Re: Issues w/ I2c/TWI1 on a SAMA5D27 - Linux-AT91 Dunfell rel

Fri Oct 02, 2020 4:02 am

stephendpmurphy wrote: Previously we used the default i2c1 config found in the at91-sama5d27_som1_ek.dts ...
...
After seeing the errors, I went through and properly updated the I2c1 dts config as seen below.
Your descriptions are not clear.
You use apple and orange combination (and comparisons) of projects and versions/releases (e.g. "Linux-AT91 Dunfell", "Linux-AT91 6.1" versus "linux-5.4-at91").
The snippet of Device Tree has no context. What file is this from? It contains properties that are already defined in the SoC-level .dtsi file that don't need to be repeated.
You're not clear as to how any of your changes to the base kernel version were transferred to the "updated" kernel version.
Are you aware that Device Tree files are specific to a kernel version, meaning that you need to port your DT customizations rather than just copy whole .dts and .dtsi files (from another kernel version)?

stephendpmurphy wrote: This seems to point to the kernel ...
You have access to the kernel source code.
If you cannot specify a commit that is problematic, then don't waste bandwidth with vague speculation.

stephendpmurphy wrote: Any help or insight is appreciated.
Since you seem to have an initialization and/or runtime issue, the first thing to consult is the syslog (which you seem to be ignoring).
Comparison with the syslog of the base kernel might be useful.

Regards

Return to “LINUX”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests