Zephyr Cadence IIC Driver Support

This page gives an overview of Cadence IIC Zephyr driver which is available as part of the zephyr-amd repo.

HW Features

  • Cadence IIC controller

Design Notes

  • NA

Implementation

Features Supported

  • Master operations

  • Slave operations

  • I2C Speeds of 100Khz and 400Khz

  • Repeated START

  • Interrupt driven

  • 7-bit addressing (Master)

  • 10-bit addressing (Master)

  • Transmit and receive FIFOs — 16 bytes (default)

  • APIs supported

    • i2c_configure - Configure operation of a host controller

    • i2c_get_config - Get configuration of a host controller

    • i2c_transfer - Perform data transfer to another I2C device in controller mode

      • synchronous transfer

    • i2c_target_register - Registers the provided config as Target device of a controller

    • i2c_target_unregister - Unregisters the provided config as Target device

Missing Features

  • Does not support I2C speeds greater than 1 Mhz.

  • APIs not supported

    • i2c_transfer_cb - Perform data transfer to another I2C device in controller mode

      • asynchronously with a callback completion

    • i2c_iodev_submit - Submit requests to an I2C device with RTIO

    • i2c_recover_bus - Recover the I2C bus

Known Issues

  • N/A

Limitations

  • N/A

Kernel Configuration

CONFIG_I2C=y
CONFIG_I2C_CADENCE=y

CONFIG_I2C_CADENCE is enabled by device tree status.

Device Tree

Iicps Node

ps_i2c1: i2c@ff030000 {
    compatible = "cdns,i2c-r1p14";
    status = "okay";
    #address-cells = <1>;
    #size-cells = <0>;
    reg = <0xff030000 0x1000>;
    interrupt-parent = <&gic>;
    interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL
                  IRQ_DEFAULT_PRIORITY>;
    clocks = <&i2c_ref_clk>;
};
  • Lopper Support to generate IICPS node is to be added

    • To be discussed

Driver Stack Size

  • 1.9 KB (Master) - i2c_cdns.c

    • 1.9 KB (Master Only)

    • 2.4 KB (Master + Debug Log)

    • 2.9 KB for Master + Debug + i2c common

      • i2c_common.c - 0.4 KB (only in debug else approx zero)

Test Platform

  • Versalnet - tenzing2 se7, se9

Test SoC Architecture

  • RPU

    • R5 core - zcu102 - Validated

    • R52 core - tenzing2 se7 - Validated

Testing Sequence

  • Build zephyr application for board

    • west build -p -b <board> <sample application path>

  • Run zephyr elf on board

Example Tests

Test Name

Example Source

Description

EEPROM Sample

samples/drivers/eeprom/

zcu102 - zephyr_zcu102_iicps_samples_drivers_eeprom.c (download)

EEPROM Write and Read Sample using I2C Driver API

IICPS Master Mode Example

tenzing2 se7 - zephyr_tenzing2_se7_iicps_master.c (download)

zcu102 - zephyr_zcu102_iicps_master.c (download)

Master Mode Write, Read, Repeated Start

  • Requires I2C Mux connected as slave

    • HW Specific MUX addr, MUX channel

Expected Output

  • R52: tenzing2 se7 test log:

    • tenzing2 se7 IICPS master log
      .126]Platform Version: v2.0 PMC: v2.0, PS: v2.0
      [0.171]BOOTMODE: 0x0, MULTIBOOT: 0x0
      [0.203]****************************************
      [0.386]Non Secure Boot
      [0.415]Device key init is skipped as no valid CDI is found
      [4.127]PLM Initialization Time
      [4.157]***********Boot PDI Load: Started***********
      [4.200]Loading PDI from SBI
      [4.228]Monolithic/Master Device
      [4.486]0.283 ms: PDI initialization time
      [4.527]+++Loading Image#: 0x1, Name: lpd, Id: 0x04210002
      [4.576]---Loading Partition#: 0x1, Id: 0xC
      [12.025]LPD power up. Version 0.84
      [70.994]Done LPD power up.
      [73.359] 68.735 ms for Partition#: 0x1, Size: 14976 Bytes
      [78.401]---Loading Partition#: 0x2, Id: 0xB
      [135.512] 53.249 ms for Partition#: 0x2, Size: 83792 Bytes
      [137.869]+++Loading Image#: 0x2, Name: pl_cfi, Id: 0x18700000
      [143.220]---Loading Partition#: 0x3, Id: 0x3
      [165.516]NPD power up.
      [167.144]Efuse transfer generic...
      [168.061]Done NPD power up.
      [170.321]HNICX power up. Version 1.2
      [174.041]Efuse transfer generic...
      [177.882]Done HNICX power up.
      [179.308]PLPD power up.
      [187.714]Efuse transfer generic...
      [188.002]Done PLPD power up.
      [677.956] 530.789 ms for Partition#: 0x3, Size: 803488 Bytes
      [680.444]---Loading Partition#: 0x4, Id: 0x5
      [1413.570] 729.178 ms for Partition#: 0x4, Size: 607216 Bytes
      [1416.160]+++Loading Image#: 0x3, Name: fpd, Id: 0x0420C003
      [1421.371]---Loading Partition#: 0x5, Id: 0x8
      [1435.056]FPD power up. Version 0.86
      WARN XPmRail_IdentifyVendor: Unable to Identify Regulator Vendor of Rail 0x432802C.		Using default Regulator: 0x0
      [1450.935]Done FPD power up.
      [1450.985] 25.580 ms for Partition#: 0x5, Size: 17488 Bytes
      [1455.945]***********Boot PDI Load: Done***********
      [1460.463]144299.473 ms: ROM Time
      [1463.451]Total PLM Boot Time
      I: 100 KHz mmio f1940000
      *** Booting Zephyr OS build 98620ef82c12 ***
      I: IIC-PS: master mode test: Start
      I: IIC-PS: master: configure-test: Start
      I: PS-I2C: device READY
      I: PS-I2C: master: i2c_configure: Progress
      I: PS-I2C: master: i2c_configure: Success
      I: PS-I2C: master: i2c_get_config: Progress
      I: PS-I2C: master: i2c_get_config: Success
      I: IIC-PS: master: configure-test: PASSED
      I: IIC-PS: master: transfer-test: Start
      I: PS-I2C: i2c_transfer: write: Progress
      I: PS-I2C: master: i2c_transfer: write data: 00h
      I: PS-I2C: i2c_transfer: write: PASSED
      I: PS-I2C: i2c_transfer: read: PASSED
      I: PS-I2C: i2c_transfer: multi-msg: Progress
      I: PS-I2C: i2c_transfer: multi-msg: PASSED
      I: IIC-PS: master: transfer-test: PASSED
      I: IIC-PS: master: rep-start-test: Start
      I: PS-I2C: master: write-read-rep-start: SLAVE:EEPROM Progress
      I: PS-I2C: master: write-read-rep-start: write data: 00h
      I: PS-I2C: master: write-read-rep-start: SLAVE:EEPROM success
      I: PS-I2C: master: write-read-rep-start: read data: 0Ch 0Dh 0Eh
      I: IIC-PS: master: rep-start-test: PASSED
      I: IIC-PS: master mode test: PASSED
      
    • Download zephyr_tenzing2_se7_iicps_master.log

  • R5: zcu102 r5 test log:

    • zcu102 R5 IICPS master log
      I: 400 KHz mmio ff020000
      I: 100 KHz mmio ff030000
      *** Booting Zephyr OS build 98620ef82c12 ***
      I: IIC-PS: master mode test: Start
      I: IIC-PS: master: configure-test: Start
      I: PS-I2C: device READY
      I: PS-I2C: master: i2c_configure: Progress
      I: PS-I2C: master: i2c_configure: Success
      I: PS-I2C: master: i2c_get_config: Progress
      I: PS-I2C: master: i2c_get_config: Success
      I: IIC-PS: master: configure-test: PASSED
      I: IIC-PS: master: transfer-test: Start
      I: PS-I2C: i2c_transfer: write: Progress
      I: PS-I2C: i2c_transfer: write: PASSED
      I: PS-I2C: i2c_transfer: read: PASSED
      I: PS-I2C: i2c_transfer: multi-msg: Progress
      I: PS-I2C: i2c_transfer: multi-msg: PASSED
      I: IIC-PS: master: transfer-test: PASSED
      I: IIC-PS: master: rep-start-test: Start
      I: PS-I2C: master: write-read-rep-start: SLAVE:IIC-MUX Progress
      I: PS-I2C: master: write-read-rep-start: write data: 01h
      I: PS-I2C: master: write-read-rep-start: SLAVE:IIC-MUX success
      I: PS-I2C: master: write-read-rep-start: read data: 01h
      I: IIC-PS: master: rep-start-test: PASSED
      I: IIC-PS: master mode test: PASSED
      
    • Download zephyr_zcu102_r5_iicps_master.log

Code Coverage

Performance Metric

  • TBA

Mainline Status

Driver Source Path

  • drivers/i2c/i2c_cdns.c

Misra C Report

File

Required

Advisory

i2c_cdns.c

7

26

  • Detailed breakup

misra-c rule

(zephyr guideline)

Severity

Actual File

Violations

Kernel Utility

Violations

Dir 4.8

Advisory

0

7

Dir 4.9

Advisory

0

3

Rule 1.2

Advisory

0

16

Rule 10.4

Required

0

1

Rule 21.2

Required

0

6

Total violations

0

33