Tests:i2c-demux-pinctrl

This document describes testing ofI2C Demux Pinctl a facility that allows switching between I2C cores and GPIO fallback for I2C using pinctl.

Kernel Version and Configuration
I2C Demux Pinctl integration for a wide range of boards for R-Car Gen 2 SoCs which are supported in mainline is available in a topic branch:

git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git topic/i2c-demux-v3

For the tests described here the kernel was compiled with the shmobile_defconfig.

Hardware Environment
Board/Soc: Lager/r8a7790 (Gen 2 R-Car H2 SoC)

Verify I2C Demux Pinctl Support
The presence of an available_masters file in the sysfs directory for an i2c device indicates that it is a demuxer.

$ ls /sys/devices/platform/i2c-*/available_masters /sys/devices/platform/i2c-11/available_masters /sys/devices/platform/i2c-13/available_masters /sys/devices/platform/i2c-8/available_masters /sys/devices/platform/i2c-9/available_masters

The use of the I2C demux pinctl driver by an I2C demux device can be confirmed by inspecting the driver link in its sysctl directory.

e.g.: $ ls -l /sys/devices/platform/i2c-9/driver lrwxrwxrwx 1 root root 0 Jan 1 00:05 /sys/devices/platform/i2c-9/driver -> ../../../bus/platform/drivers/i2c-demux-pinctrl

Core Switching
The cores available for use by an i2c demux device may be retrieved from the available_masters file in the device's sysfs directory.

e.g.: $ cat /sys/devices/platform/i2c-9/available_masters 0:/i2c@e6510000 1:/i2c@e6518000 2:/i2c-10

The core currently used by an i2c demux device may be retrieved from the current_master file in the device's sysfs directory. The value shown is the index of the core in use.

e.g.: $ cat /sys/devices/platform/i2c-9/current_master 0

And the core may be changed by writing to the index of the core to the current_master file.

e.g.: $ # echo 1 > /sys/devices/platform/i2c-9/current_master

Exercising Core Selection
The following script may be used to exercise switching all i2c demuxers to all available cores.


 * 1) !/bin/sh

set -e

cd /sys/devices/platform/

sleep 5

for i in i2c-*; do       [ "$i" != 'i2c-*' ] || break [ -e "$i/current_master" -a -e "$i/available_masters" ] || continue echo "I2C Demux: $i" for j in $(< "$i/available_masters" tr ' ' '\n' | tac); do               idx=${j%:*} echo " Master: $j ($idx)" echo "$idx" > "$i/current_master" sleep 5 done done