How to configure the Jetson AGX Orin as an I2C master or slave, and where can I find documentation on addressing when Orin is used as a slave

How to configure the Jetson AGX Orin as an I2C master or slave, and where can I find documentation on addressing when Orin is used as a slave
am using tegra234-p3737-0000+p3701-0008-nv
Jetpack 6.2

*** Please note that this reply is generated by LLM automatically ***

To configure the Jetson AGX Orin as an I2C master or slave, you can refer to the NVIDIA Jetson Linux Developer Guide, which provides detailed information on the I2C interface and its configuration.

I2C Configuration

The Jetson AGX Orin has multiple I2C controllers, and each controller can be configured as a master or slave. To configure the I2C interface, you need to modify the device tree file (tegra234-p3737-0000-p3701-0008.dtb) and the kernel configuration.

Device Tree Configuration

In the device tree file, you need to configure the I2C controller as a master or slave by setting the compatible property to nvidia,tegra234-i2c and the reg property to the correct address.

For example, to configure the I2C controller as a master, you can add the following lines to the device tree file:

&i2c {
    compatible = "nvidia,tegra234-i2c";
    reg = <0x0 0x2c00000 0x0 0x1000>;
    #address-cells = <1>;
    #size-cells = <0>;
    i2c-master;
};

To configure the I2C controller as a slave, you can add the following lines to the device tree file:

&i2c {
    compatible = "nvidia,tegra234-i2c";
    reg = <0x0 0x2c00000 0x0 0x1000>;
    #address-cells = <1>;
    #size-cells = <0>;
    i2c-slave;
    slave-address = <0x10>;
};

Kernel Configuration

In the kernel configuration, you need to enable the I2C interface and configure it as a master or slave.

To enable the I2C interface, you can add the following line to the kernel configuration file (.config):

CONFIG_I2C=y

To configure the I2C interface as a master, you can add the following line to the kernel configuration file:

CONFIG_I2C_MASTER=y

To configure the I2C interface as a slave, you can add the following line to the kernel configuration file:

CONFIG_I2C_SLAVE=y

Addressing

When the Jetson AGX Orin is used as an I2C slave, it uses a 7-bit address. The address is configured in the device tree file using the slave-address property.

For example, to set the slave address to 0x10, you can add the following line to the device tree file:

slave-address = <0x10>;

Documentation

You can find more information on configuring the I2C interface on the Jetson AGX Orin in the NVIDIA Jetson Linux Developer Guide, which is available on the NVIDIA website.

Additionally, you can refer to the following documents for more information on I2C configuration and addressing:

  • NVIDIA Jetson Linux Developer Guide: I2C Interface
  • NVIDIA Jetson Linux Developer Guide: Device Tree Configuration
  • NVIDIA Jetson Linux Developer Guide: Kernel Configuration

Jetpack 4.6.2

Since you are using Jetpack 4.6.2, you can refer to the NVIDIA Jetson Linux Developer Guide for Jetpack 4.6.2, which is available on the NVIDIA website.

Note that the configuration and addressing information may vary depending on the Jetpack version and the specific hardware configuration.

*** Please give the thumbs up if you get answers you like. Or provide feedback to help us improve the answer. ***

This solution isn’t helping me .

https://forums.developer.nvidia.com/t/how-to-use-jetson-agx-orin-as-an-i2c-slave/331765

this solution is relative but no more able to access the patch or the driver written for it .
Please somebody help me on this .

Hi lohith.v,

Are you using the devkit or custom board for AGX Orin?

Would it work as I2C slave if you referred to the link you shared to update the device tree?

If not, please share the full dmesg and device tree for further check.

am using custom board for AGX orin.
++ attached the dts and dmesg .

i want to make i2c0 bus alone as slave and how to configure the slave address.
am little confused with the eeprom and the slave address.
as per AGX orin document slave address can be configured as user given address

i think in dts i2c0 relates to this node , please correct me if am wrong.
i2c@3160000 {
compatible = “nvidia,tegra194-i2c”;
reg = <0x00 0x3160000 0x00 0x100>;
status = “okay”;
interrupts = <0x00 0x19 0x04>;
#address-cells = <0x01>;
#size-cells = <0x00>;
clock-frequency = <0x61a80>;
clocks = <0x03 0x30 0x03 0x66>;
assigned-clocks = <0x03 0x30>;
assigned-clock-parents = <0x03 0x66>;
clock-names = “div-clk\0parent”;
resets = <0x03 0x18>;
reset-names = “i2c”;
dmas = <0xee 0x15 0xee 0x15>;
dma-names = “rx\0tx”;
iommus = <0x04 0x04>;
dma-coherent;
phandle = <0x215>;

		eeprom@50 {
			compatible = "atmel,24c02";
			reg = <0x50>;
			label = "module";
			vcc-supply = <0xef>;
			address-width = <0x08>;
			pagesize = <0x08>;
			size = <0x100>;
			read-only;
		};

Thanks,

devicetree.txt (319.4 KB)

dmesg_orin.txt (58.3 KB)

Oh sorry, you can ignore the eeprom part since you don’t need to use it.
Please try just updating the compatible string for i2c@3160000 as following instead.

                i2c@3160000 {
-                        compatible = "nvidia,tegra194-i2c";
+                        compatible = "nvidia,tegra194-i2c-slave";
                        reg = <0x00 0x3160000 0x00 0x100>;
                        status = "okay";

And share the full dmesg and device tree again.

i don’t have driver code for tegra194-i2c-slave.

i did make below changes
i2c@3160000 { - compatible = “nvidia,tegra194-i2c”; + compatible = “nvidia,tegra194-i2c-slave”; reg = <0x00 0x3160000 0x00 0x100>; status = “okay”;
in this slave address isn’t mentioned ?
sorry i couln’t figure out .
Thanks

Sorry that please refer to this thread to configure for I2C slave.
As there’s no I2C slave use case on the devkit by default.
EEPROM one is just an example of how to use the slave driver.

Please share the full dmesg and device tree after you’ve applied them correctly.

Hi kevin ,
++attaching the dmesg and the dt.

what would be the slave address of the orin now ?

Thanks

dts.txt (319.4 KB)

orin_dmesg.txt (62.2 KB)

[    9.677393] tegra-i2cslv 3160000.i2c: Adding to iommu group 1

It seems tegra-i2cslv has been probed for 3160000.i2c.

The I2C slave address depends on I2C client registered.
In current device tree configuration, it is 0x50 and 0x56. Both are used for EEPROM.

Hi Kevin ,
so , 3160000 is configured with EEPROM by default.
how can i use other i2c for my purpose .
suppose if i have ic5 as General purpose in my pin mux ,i’ll enable it and update .
how to configure the slave address ?
do i need to change any driver for that ?
Please let me know.
Thanks

The current configuration is an I2C slave example for EEPROM.
If you want to use other I2C device instead, please just update the following part in device tree.

		i2c@3160000 {
			compatible = "nvidia,tegra-i2c-slave-byte";
			..

			eeprom@50 {
				compatible = "slave-24c02";
				reg = <0x50>;
				label = "module";
				vcc-supply = <0xef>;
				address-width = <0x08>;
				pagesize = <0x08>;
				size = <0x100>;
				read-only;
			};

Yes, you need the custom driver like eeprom specifying slave-24c02 for its driver.

hi kevin sorry to ask simple and small doubts .
am trying to understand better.
am connecting conga-Tc570r Devlopment board which is master and i need to connect to any of the I2C GP i2c device in Jetson-orin custom board and what to be mentioned in the device tree subnode .

i2c@XXXXX {

        compatible = “nvidia,tegra-i2c-slave-byte”;

		 what to be mentioned here?
		};

as you mentioned
i need the custom driver like eeprom specifying slave-24c02 for its driver.

so, do i need to write my own drivers ?
the previous forum link which u mentioned about drivers the solution is been attached with a .patch file and the
From 77d956d775610a848dce44d77547d3479062705a Mon Sep 17 00:00:00 2001
From: Akhil R akhilrajeev@nvidia.com
Date: Thu, 4 Jan 2024 12:18:25 +0530
Subject: [PATCH] i2c: tegra-slave: Add I2C Tegra slave driver

Add back the removed i2c-tegra-slave-byte driver and add support
for it in kernel v6.1

Though not enabled in device tree by default, I2C slave driver is
used by customers and developers for various debug and application
use cases.

**Change-Id: Idd012303f51456492a8392e51aee1edc8dcb487c

Signed-off-by: Akhil R akhilrajeev@nvidia.com
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3048842
Reviewed-by: Jon Hunter jonathanh@nvidia.com
Reviewed-by: Laxman Dewangan ldewangan@nvidia.com
GVS: Gerrit_Virtual_Submit buildbot_gerritrpt@nvidia.com
(cherry picked from commit 75ea3b11d06d574fbd4b21d15841f4644ed304b1)**

drivers/i2c/busses/Makefile | 1 +
drivers/i2c/busses/i2c-tegra-slave-byte.c | 461 ++++++++++++++++++++++
2 files changed, 462 insertions(+)
create mode 100644 drivers/i2c/busses/i2c-tegra-slave-byte.c

the driver isn’t accessible at all !!

From the log you shared, I2C slave driver has been probed as expected.

Yes, you have to write your own driver for your use case and the properties in device tree should include the address like reg = <0x50> and other properties depending on what your driver needs.

Sorry that we are not clear about your I2C master(conga-Tc570r Devlopment board) and also your use case for I2C slave on Jetson. We can just give you an example and help you to enable I2C slave driver, but you still have to write your own client driver to handle for your use case.