131df7195SAlex Qiu.. SPDX-License-Identifier: GPL-2.0 231df7195SAlex Qiu 331df7195SAlex Qiu=============== 431df7195SAlex QiuLinux I2C Sysfs 531df7195SAlex Qiu=============== 631df7195SAlex Qiu 731df7195SAlex QiuOverview 831df7195SAlex Qiu======== 931df7195SAlex Qiu 1031df7195SAlex QiuI2C topology can be complex because of the existence of I2C MUX 1131df7195SAlex Qiu(I2C Multiplexer). The Linux 1231df7195SAlex Qiukernel abstracts the MUX channels into logical I2C bus numbers. However, there 1331df7195SAlex Qiuis a gap of knowledge to map from the I2C bus physical number and MUX topology 1431df7195SAlex Qiuto logical I2C bus number. This doc is aimed to fill in this gap, so the 1531df7195SAlex Qiuaudience (hardware engineers and new software developers for example) can learn 1631df7195SAlex Qiuthe concept of logical I2C buses in the kernel, by knowing the physical I2C 1731df7195SAlex Qiutopology and navigating through the I2C sysfs in Linux shell. This knowledge is 1831df7195SAlex Qiuuseful and essential to use ``i2c-tools`` for the purpose of development and 1931df7195SAlex Qiudebugging. 2031df7195SAlex Qiu 2131df7195SAlex QiuTarget audience 2231df7195SAlex Qiu--------------- 2331df7195SAlex Qiu 2431df7195SAlex QiuPeople who need to use Linux shell to interact with I2C subsystem on a system 2531df7195SAlex Qiuwhich the Linux is running on. 2631df7195SAlex Qiu 2731df7195SAlex QiuPrerequisites 2831df7195SAlex Qiu------------- 2931df7195SAlex Qiu 3031df7195SAlex Qiu1. Knowledge of general Linux shell file system commands and operations. 3131df7195SAlex Qiu 3231df7195SAlex Qiu2. General knowledge of I2C, I2C MUX and I2C topology. 3331df7195SAlex Qiu 3431df7195SAlex QiuLocation of I2C Sysfs 3531df7195SAlex Qiu===================== 3631df7195SAlex Qiu 3731df7195SAlex QiuTypically, the Linux Sysfs filesystem is mounted at the ``/sys`` directory, 3831df7195SAlex Qiuso you can find the I2C Sysfs under ``/sys/bus/i2c/devices`` 3931df7195SAlex Qiuwhere you can directly ``cd`` to it. 4031df7195SAlex QiuThere is a list of symbolic links under that directory. The links that 4131df7195SAlex Qiustart with ``i2c-`` are I2C buses, which may be either physical or logical. The 4231df7195SAlex Qiuother links that begin with numbers and end with numbers are I2C devices, where 4331df7195SAlex Qiuthe first number is I2C bus number, and the second number is I2C address. 4431df7195SAlex Qiu 4531df7195SAlex QiuGoogle Pixel 3 phone for example:: 4631df7195SAlex Qiu 4731df7195SAlex Qiu blueline:/sys/bus/i2c/devices $ ls 4831df7195SAlex Qiu 0-0008 0-0061 1-0028 3-0043 4-0036 4-0041 i2c-1 i2c-3 4931df7195SAlex Qiu 0-000c 0-0066 2-0049 4-000b 4-0040 i2c-0 i2c-2 i2c-4 5031df7195SAlex Qiu 5131df7195SAlex Qiu``i2c-2`` is an I2C bus whose number is 2, and ``2-0049`` is an I2C device 5231df7195SAlex Qiuon bus 2 address 0x49 bound with a kernel driver. 5331df7195SAlex Qiu 5455bdfb8bSLuca CeresoliTerminology 5555bdfb8bSLuca Ceresoli=========== 5631df7195SAlex Qiu 5755bdfb8bSLuca CeresoliFirst, let us define some terms to avoid confusion in later sections. 5831df7195SAlex Qiu 5931df7195SAlex Qiu(Physical) I2C Bus Controller 6031df7195SAlex Qiu----------------------------- 6131df7195SAlex Qiu 6231df7195SAlex QiuThe hardware system that the Linux kernel is running on may have multiple 6331df7195SAlex Qiuphysical I2C bus controllers. The controllers are hardware and physical, and the 6431df7195SAlex Qiusystem may define multiple registers in the memory space to manipulate the 6531df7195SAlex Qiucontrollers. Linux kernel has I2C bus drivers under source directory 6631df7195SAlex Qiu``drivers/i2c/busses`` to translate kernel I2C API into register 6731df7195SAlex Qiuoperations for different systems. This terminology is not limited to Linux 6831df7195SAlex Qiukernel only. 6931df7195SAlex Qiu 7031df7195SAlex QiuI2C Bus Physical Number 7131df7195SAlex Qiu----------------------- 7231df7195SAlex Qiu 7331df7195SAlex QiuFor each physical I2C bus controller, the system vendor may assign a physical 7431df7195SAlex Qiunumber to each controller. For example, the first I2C bus controller which has 7531df7195SAlex Qiuthe lowest register addresses may be called ``I2C-0``. 7631df7195SAlex Qiu 7731df7195SAlex QiuLogical I2C Bus 7831df7195SAlex Qiu--------------- 7931df7195SAlex Qiu 8031df7195SAlex QiuEvery I2C bus number you see in Linux I2C Sysfs is a logical I2C bus with a 8131df7195SAlex Qiunumber assigned. This is similar to the fact that software code is usually 8231df7195SAlex Qiuwritten upon virtual memory space, instead of physical memory space. 8331df7195SAlex Qiu 8431df7195SAlex QiuEach logical I2C bus may be an abstraction of a physical I2C bus controller, or 8531df7195SAlex Qiuan abstraction of a channel behind an I2C MUX. In case it is an abstraction of a 8631df7195SAlex QiuMUX channel, whenever we access an I2C device via a such logical bus, the kernel 8731df7195SAlex Qiuwill switch the I2C MUX for you to the proper channel as part of the 8831df7195SAlex Qiuabstraction. 8931df7195SAlex Qiu 9031df7195SAlex QiuPhysical I2C Bus 9131df7195SAlex Qiu---------------- 9231df7195SAlex Qiu 9331df7195SAlex QiuIf the logical I2C bus is a direct abstraction of a physical I2C bus controller, 9431df7195SAlex Qiulet us call it a physical I2C bus. 9531df7195SAlex Qiu 9631df7195SAlex QiuCaveat 9731df7195SAlex Qiu------ 9831df7195SAlex Qiu 9931df7195SAlex QiuThis may be a confusing part for people who only know about the physical I2C 10031df7195SAlex Qiudesign of a board. It is actually possible to rename the I2C bus physical number 10131df7195SAlex Qiuto a different number in logical I2C bus level in Device Tree Source (DTS) under 102*fe99b819SLuca Ceresolisection ``aliases``. See ``arch/arm/boot/dts/nuvoton-npcm730-gsj.dts`` 10331df7195SAlex Qiufor an example of DTS file. 10431df7195SAlex Qiu 10531df7195SAlex QiuBest Practice: **(To kernel software developers)** It is better to keep the I2C 10631df7195SAlex Qiubus physical number the same as their corresponding logical I2C bus number, 10731df7195SAlex Qiuinstead of renaming or mapping them, so that it may be less confusing to other 10831df7195SAlex Qiuusers. These physical I2C buses can be served as good starting points for I2C 10931df7195SAlex QiuMUX fanouts. For the following examples, we will assume that the physical I2C 11031df7195SAlex Qiubus has a number same as their I2C bus physical number. 11131df7195SAlex Qiu 11231df7195SAlex QiuWalk through Logical I2C Bus 11331df7195SAlex Qiu============================ 11431df7195SAlex Qiu 11531df7195SAlex QiuFor the following content, we will use a more complex I2C topology as an 11631df7195SAlex Qiuexample. Here is a brief graph for the I2C topology. If you do not understand 11755bdfb8bSLuca Ceresolithis graph at first glance, do not be afraid to continue reading this doc 11831df7195SAlex Qiuand review it when you finish reading. 11931df7195SAlex Qiu 12031df7195SAlex Qiu:: 12131df7195SAlex Qiu 12231df7195SAlex Qiu i2c-7 (physical I2C bus controller 7) 12331df7195SAlex Qiu `-- 7-0071 (4-channel I2C MUX at 0x71) 12431df7195SAlex Qiu |-- i2c-60 (channel-0) 12531df7195SAlex Qiu |-- i2c-73 (channel-1) 12631df7195SAlex Qiu | |-- 73-0040 (I2C sensor device with hwmon directory) 12731df7195SAlex Qiu | |-- 73-0070 (I2C MUX at 0x70, exists in DTS, but failed to probe) 12831df7195SAlex Qiu | `-- 73-0072 (8-channel I2C MUX at 0x72) 12931df7195SAlex Qiu | |-- i2c-78 (channel-0) 13031df7195SAlex Qiu | |-- ... (channel-1...6, i2c-79...i2c-84) 13131df7195SAlex Qiu | `-- i2c-85 (channel-7) 13231df7195SAlex Qiu |-- i2c-86 (channel-2) 13331df7195SAlex Qiu `-- i2c-203 (channel-3) 13431df7195SAlex Qiu 13531df7195SAlex QiuDistinguish Physical and Logical I2C Bus 13631df7195SAlex Qiu---------------------------------------- 13731df7195SAlex Qiu 13831df7195SAlex QiuOne simple way to distinguish between a physical I2C bus and a logical I2C bus, 13931df7195SAlex Qiuis to read the symbolic link ``device`` under the I2C bus directory by using 14031df7195SAlex Qiucommand ``ls -l`` or ``readlink``. 14131df7195SAlex Qiu 14231df7195SAlex QiuAn alternative symbolic link to check is ``mux_device``. This link only exists 14331df7195SAlex Qiuin logical I2C bus directory which is fanned out from another I2C bus. 14431df7195SAlex QiuReading this link will also tell you which I2C MUX device created 14531df7195SAlex Qiuthis logical I2C bus. 14631df7195SAlex Qiu 14731df7195SAlex QiuIf the symbolic link points to a directory ending with ``.i2c``, it should be a 14831df7195SAlex Qiuphysical I2C bus, directly abstracting a physical I2C bus controller. For 14931df7195SAlex Qiuexample:: 15031df7195SAlex Qiu 15131df7195SAlex Qiu $ readlink /sys/bus/i2c/devices/i2c-7/device 15231df7195SAlex Qiu ../../f0087000.i2c 15331df7195SAlex Qiu $ ls /sys/bus/i2c/devices/i2c-7/mux_device 15431df7195SAlex Qiu ls: /sys/bus/i2c/devices/i2c-7/mux_device: No such file or directory 15531df7195SAlex Qiu 15631df7195SAlex QiuIn this case, ``i2c-7`` is a physical I2C bus, so it does not have the symbolic 15731df7195SAlex Qiulink ``mux_device`` under its directory. And if the kernel software developer 15831df7195SAlex Qiufollows the common practice by not renaming physical I2C buses, this should also 15931df7195SAlex Qiumean the physical I2C bus controller 7 of the system. 16031df7195SAlex Qiu 16131df7195SAlex QiuOn the other hand, if the symbolic link points to another I2C bus, the I2C bus 16231df7195SAlex Qiupresented by the current directory has to be a logical bus. The I2C bus pointed 16331df7195SAlex Qiuby the link is the parent bus which may be either a physical I2C bus or a 16431df7195SAlex Qiulogical one. In this case, the I2C bus presented by the current directory 16531df7195SAlex Qiuabstracts an I2C MUX channel under the parent bus. 16631df7195SAlex Qiu 16731df7195SAlex QiuFor example:: 16831df7195SAlex Qiu 16931df7195SAlex Qiu $ readlink /sys/bus/i2c/devices/i2c-73/device 17031df7195SAlex Qiu ../../i2c-7 17131df7195SAlex Qiu $ readlink /sys/bus/i2c/devices/i2c-73/mux_device 17231df7195SAlex Qiu ../7-0071 17331df7195SAlex Qiu 17431df7195SAlex Qiu``i2c-73`` is a logical bus fanout by an I2C MUX under ``i2c-7`` 17531df7195SAlex Qiuwhose I2C address is 0x71. 17631df7195SAlex QiuWhenever we access an I2C device with bus 73, the kernel will always 17731df7195SAlex Qiuswitch the I2C MUX addressed 0x71 to the proper channel for you as part of the 17831df7195SAlex Qiuabstraction. 17931df7195SAlex Qiu 18031df7195SAlex QiuFinding out Logical I2C Bus Number 18131df7195SAlex Qiu---------------------------------- 18231df7195SAlex Qiu 18331df7195SAlex QiuIn this section, we will describe how to find out the logical I2C bus number 18431df7195SAlex Qiurepresenting certain I2C MUX channels based on the knowledge of physical 18531df7195SAlex Qiuhardware I2C topology. 18631df7195SAlex Qiu 18731df7195SAlex QiuIn this example, we have a system which has a physical I2C bus 7 and not renamed 18831df7195SAlex Qiuin DTS. There is a 4-channel MUX at address 0x71 on that bus. There is another 18931df7195SAlex Qiu8-channel MUX at address 0x72 behind the channel 1 of the 0x71 MUX. Let us 19031df7195SAlex Qiunavigate through Sysfs and find out the logical I2C bus number of the channel 3 19131df7195SAlex Qiuof the 0x72 MUX. 19231df7195SAlex Qiu 19331df7195SAlex QiuFirst of all, let us go to the directory of ``i2c-7``:: 19431df7195SAlex Qiu 19531df7195SAlex Qiu ~$ cd /sys/bus/i2c/devices/i2c-7 19631df7195SAlex Qiu /sys/bus/i2c/devices/i2c-7$ ls 19731df7195SAlex Qiu 7-0071 i2c-60 name subsystem 19831df7195SAlex Qiu delete_device i2c-73 new_device uevent 19931df7195SAlex Qiu device i2c-86 of_node 20031df7195SAlex Qiu i2c-203 i2c-dev power 20131df7195SAlex Qiu 20231df7195SAlex QiuThere, we see the 0x71 MUX as ``7-0071``. Go inside it:: 20331df7195SAlex Qiu 20431df7195SAlex Qiu /sys/bus/i2c/devices/i2c-7$ cd 7-0071/ 20531df7195SAlex Qiu /sys/bus/i2c/devices/i2c-7/7-0071$ ls -l 20631df7195SAlex Qiu channel-0 channel-3 modalias power 20731df7195SAlex Qiu channel-1 driver name subsystem 20831df7195SAlex Qiu channel-2 idle_state of_node uevent 20931df7195SAlex Qiu 21031df7195SAlex QiuRead the link ``channel-1`` using ``readlink`` or ``ls -l``:: 21131df7195SAlex Qiu 21231df7195SAlex Qiu /sys/bus/i2c/devices/i2c-7/7-0071$ readlink channel-1 21331df7195SAlex Qiu ../i2c-73 21431df7195SAlex Qiu 21531df7195SAlex QiuWe find out that the channel 1 of 0x71 MUX on ``i2c-7`` is assigned 21631df7195SAlex Qiuwith a logical I2C bus number of 73. 21731df7195SAlex QiuLet us continue the journey to directory ``i2c-73`` in either ways:: 21831df7195SAlex Qiu 21931df7195SAlex Qiu # cd to i2c-73 under I2C Sysfs root 22031df7195SAlex Qiu /sys/bus/i2c/devices/i2c-7/7-0071$ cd /sys/bus/i2c/devices/i2c-73 22131df7195SAlex Qiu /sys/bus/i2c/devices/i2c-73$ 22231df7195SAlex Qiu 22331df7195SAlex Qiu # cd the channel symbolic link 22431df7195SAlex Qiu /sys/bus/i2c/devices/i2c-7/7-0071$ cd channel-1 22531df7195SAlex Qiu /sys/bus/i2c/devices/i2c-7/7-0071/channel-1$ 22631df7195SAlex Qiu 22731df7195SAlex Qiu # cd the link content 22831df7195SAlex Qiu /sys/bus/i2c/devices/i2c-7/7-0071$ cd ../i2c-73 22931df7195SAlex Qiu /sys/bus/i2c/devices/i2c-7/i2c-73$ 23031df7195SAlex Qiu 23131df7195SAlex QiuEither ways, you will end up in the directory of ``i2c-73``. Similar to above, 23231df7195SAlex Qiuwe can now find the 0x72 MUX and what logical I2C bus numbers 23331df7195SAlex Qiuthat its channels are assigned:: 23431df7195SAlex Qiu 23531df7195SAlex Qiu /sys/bus/i2c/devices/i2c-73$ ls 23631df7195SAlex Qiu 73-0040 device i2c-83 new_device 23731df7195SAlex Qiu 73-004e i2c-78 i2c-84 of_node 23831df7195SAlex Qiu 73-0050 i2c-79 i2c-85 power 23931df7195SAlex Qiu 73-0070 i2c-80 i2c-dev subsystem 24031df7195SAlex Qiu 73-0072 i2c-81 mux_device uevent 24131df7195SAlex Qiu delete_device i2c-82 name 24231df7195SAlex Qiu /sys/bus/i2c/devices/i2c-73$ cd 73-0072 24331df7195SAlex Qiu /sys/bus/i2c/devices/i2c-73/73-0072$ ls 24431df7195SAlex Qiu channel-0 channel-4 driver of_node 24531df7195SAlex Qiu channel-1 channel-5 idle_state power 24631df7195SAlex Qiu channel-2 channel-6 modalias subsystem 24731df7195SAlex Qiu channel-3 channel-7 name uevent 24831df7195SAlex Qiu /sys/bus/i2c/devices/i2c-73/73-0072$ readlink channel-3 24931df7195SAlex Qiu ../i2c-81 25031df7195SAlex Qiu 25131df7195SAlex QiuThere, we find out the logical I2C bus number of the channel 3 of the 0x72 MUX 25231df7195SAlex Qiuis 81. We can later use this number to switch to its own I2C Sysfs directory or 25331df7195SAlex Qiuissue ``i2c-tools`` commands. 25431df7195SAlex Qiu 25531df7195SAlex QiuTip: Once you understand the I2C topology with MUX, command 25631df7195SAlex Qiu`i2cdetect -l 25731df7195SAlex Qiu<https://manpages.debian.org/unstable/i2c-tools/i2cdetect.8.en.html>`_ 25831df7195SAlex Qiuin 25931df7195SAlex Qiu`I2C Tools 26031df7195SAlex Qiu<https://i2c.wiki.kernel.org/index.php/I2C_Tools>`_ 26131df7195SAlex Qiucan give you 26231df7195SAlex Qiuan overview of the I2C topology easily, if it is available on your system. For 26331df7195SAlex Qiuexample:: 26431df7195SAlex Qiu 26531df7195SAlex Qiu $ i2cdetect -l | grep -e '\-73' -e _7 | sort -V 26631df7195SAlex Qiu i2c-7 i2c npcm_i2c_7 I2C adapter 26731df7195SAlex Qiu i2c-73 i2c i2c-7-mux (chan_id 1) I2C adapter 26831df7195SAlex Qiu i2c-78 i2c i2c-73-mux (chan_id 0) I2C adapter 26931df7195SAlex Qiu i2c-79 i2c i2c-73-mux (chan_id 1) I2C adapter 27031df7195SAlex Qiu i2c-80 i2c i2c-73-mux (chan_id 2) I2C adapter 27131df7195SAlex Qiu i2c-81 i2c i2c-73-mux (chan_id 3) I2C adapter 27231df7195SAlex Qiu i2c-82 i2c i2c-73-mux (chan_id 4) I2C adapter 27331df7195SAlex Qiu i2c-83 i2c i2c-73-mux (chan_id 5) I2C adapter 27431df7195SAlex Qiu i2c-84 i2c i2c-73-mux (chan_id 6) I2C adapter 27531df7195SAlex Qiu i2c-85 i2c i2c-73-mux (chan_id 7) I2C adapter 27631df7195SAlex Qiu 27731df7195SAlex QiuPinned Logical I2C Bus Number 27831df7195SAlex Qiu----------------------------- 27931df7195SAlex Qiu 28031df7195SAlex QiuIf not specified in DTS, when an I2C MUX driver is applied and the MUX device is 28131df7195SAlex Qiusuccessfully probed, the kernel will assign the MUX channels with a logical bus 28231df7195SAlex Qiunumber based on the current biggest logical bus number incrementally. For 28331df7195SAlex Qiuexample, if the system has ``i2c-15`` as the highest logical bus number, and a 28431df7195SAlex Qiu4-channel MUX is applied successfully, we will have ``i2c-16`` for the 28531df7195SAlex QiuMUX channel 0, and all the way to ``i2c-19`` for the MUX channel 3. 28631df7195SAlex Qiu 28731df7195SAlex QiuThe kernel software developer is able to pin the fanout MUX channels to a static 28831df7195SAlex Qiulogical I2C bus number in the DTS. This doc will not go through the details on 28931df7195SAlex Qiuhow to implement this in DTS, but we can see an example in: 290*fe99b819SLuca Ceresoli``arch/arm/boot/dts/aspeed-bmc-facebook-wedge400.dts`` 29131df7195SAlex Qiu 29231df7195SAlex QiuIn the above example, there is an 8-channel I2C MUX at address 0x70 on physical 29331df7195SAlex QiuI2C bus 2. The channel 2 of the MUX is defined as ``imux18`` in DTS, 29431df7195SAlex Qiuand pinned to logical I2C bus number 18 with the line of ``i2c18 = &imux18;`` 29531df7195SAlex Qiuin section ``aliases``. 29631df7195SAlex Qiu 29731df7195SAlex QiuTake it further, it is possible to design a logical I2C bus number schema that 29831df7195SAlex Qiucan be easily remembered by humans or calculated arithmetically. For example, we 29931df7195SAlex Qiucan pin the fanout channels of a MUX on bus 3 to start at 30. So 30 will be the 30031df7195SAlex Qiulogical bus number of the channel 0 of the MUX on bus 3, and 37 will be the 30131df7195SAlex Qiulogical bus number of the channel 7 of the MUX on bus 3. 30231df7195SAlex Qiu 30331df7195SAlex QiuI2C Devices 30431df7195SAlex Qiu=========== 30531df7195SAlex Qiu 30631df7195SAlex QiuIn previous sections, we mostly covered the I2C bus. In this section, let us see 30731df7195SAlex Qiuwhat we can learn from the I2C device directory whose link name is in the format 30831df7195SAlex Qiuof ``${bus}-${addr}``. The ``${bus}`` part in the name is a logical I2C bus 30931df7195SAlex Qiudecimal number, while the ``${addr}`` part is a hex number of the I2C address 31031df7195SAlex Qiuof each device. 31131df7195SAlex Qiu 31231df7195SAlex QiuI2C Device Directory Content 31331df7195SAlex Qiu---------------------------- 31431df7195SAlex Qiu 31531df7195SAlex QiuInside each I2C device directory, there is a file named ``name``. 31631df7195SAlex QiuThis file tells what device name it was used for the kernel driver to 31731df7195SAlex Qiuprobe this device. Use command ``cat`` to read its content. For example:: 31831df7195SAlex Qiu 31931df7195SAlex Qiu /sys/bus/i2c/devices/i2c-73$ cat 73-0040/name 32031df7195SAlex Qiu ina230 32131df7195SAlex Qiu /sys/bus/i2c/devices/i2c-73$ cat 73-0070/name 32231df7195SAlex Qiu pca9546 32331df7195SAlex Qiu /sys/bus/i2c/devices/i2c-73$ cat 73-0072/name 32431df7195SAlex Qiu pca9547 32531df7195SAlex Qiu 32631df7195SAlex QiuThere is a symbolic link named ``driver`` to tell what Linux kernel driver was 32731df7195SAlex Qiuused to probe this device:: 32831df7195SAlex Qiu 32931df7195SAlex Qiu /sys/bus/i2c/devices/i2c-73$ readlink -f 73-0040/driver 33031df7195SAlex Qiu /sys/bus/i2c/drivers/ina2xx 33131df7195SAlex Qiu /sys/bus/i2c/devices/i2c-73$ readlink -f 73-0072/driver 33231df7195SAlex Qiu /sys/bus/i2c/drivers/pca954x 33331df7195SAlex Qiu 33431df7195SAlex QiuBut if the link ``driver`` does not exist at the first place, 33531df7195SAlex Qiuit may mean that the kernel driver failed to probe this device due to 33631df7195SAlex Qiusome errors. The error may be found in ``dmesg``:: 33731df7195SAlex Qiu 33831df7195SAlex Qiu /sys/bus/i2c/devices/i2c-73$ ls 73-0070/driver 33931df7195SAlex Qiu ls: 73-0070/driver: No such file or directory 34031df7195SAlex Qiu /sys/bus/i2c/devices/i2c-73$ dmesg | grep 73-0070 34131df7195SAlex Qiu pca954x 73-0070: probe failed 34231df7195SAlex Qiu pca954x 73-0070: probe failed 34331df7195SAlex Qiu 34431df7195SAlex QiuDepending on what the I2C device is and what kernel driver was used to probe the 34531df7195SAlex Qiudevice, we may have different content in the device directory. 34631df7195SAlex Qiu 34731df7195SAlex QiuI2C MUX Device 34831df7195SAlex Qiu-------------- 34931df7195SAlex Qiu 35031df7195SAlex QiuWhile you may be already aware of this in previous sections, an I2C MUX device 35131df7195SAlex Qiuwill have symbolic link ``channel-*`` inside its device directory. 35231df7195SAlex QiuThese symbolic links point to their logical I2C bus directories:: 35331df7195SAlex Qiu 35431df7195SAlex Qiu /sys/bus/i2c/devices/i2c-73$ ls -l 73-0072/channel-* 35531df7195SAlex Qiu lrwxrwxrwx ... 73-0072/channel-0 -> ../i2c-78 35631df7195SAlex Qiu lrwxrwxrwx ... 73-0072/channel-1 -> ../i2c-79 35731df7195SAlex Qiu lrwxrwxrwx ... 73-0072/channel-2 -> ../i2c-80 35831df7195SAlex Qiu lrwxrwxrwx ... 73-0072/channel-3 -> ../i2c-81 35931df7195SAlex Qiu lrwxrwxrwx ... 73-0072/channel-4 -> ../i2c-82 36031df7195SAlex Qiu lrwxrwxrwx ... 73-0072/channel-5 -> ../i2c-83 36131df7195SAlex Qiu lrwxrwxrwx ... 73-0072/channel-6 -> ../i2c-84 36231df7195SAlex Qiu lrwxrwxrwx ... 73-0072/channel-7 -> ../i2c-85 36331df7195SAlex Qiu 36431df7195SAlex QiuI2C Sensor Device / Hwmon 36531df7195SAlex Qiu------------------------- 36631df7195SAlex Qiu 36731df7195SAlex QiuI2C sensor device is also common to see. If they are bound by a kernel hwmon 36831df7195SAlex Qiu(Hardware Monitoring) driver successfully, you will see a ``hwmon`` directory 36931df7195SAlex Qiuinside the I2C device directory. Keep digging into it, you will find the Hwmon 37031df7195SAlex QiuSysfs for the I2C sensor device:: 37131df7195SAlex Qiu 37231df7195SAlex Qiu /sys/bus/i2c/devices/i2c-73/73-0040/hwmon/hwmon17$ ls 37331df7195SAlex Qiu curr1_input in0_lcrit_alarm name subsystem 37431df7195SAlex Qiu device in1_crit power uevent 37531df7195SAlex Qiu in0_crit in1_crit_alarm power1_crit update_interval 37631df7195SAlex Qiu in0_crit_alarm in1_input power1_crit_alarm 37731df7195SAlex Qiu in0_input in1_lcrit power1_input 37831df7195SAlex Qiu in0_lcrit in1_lcrit_alarm shunt_resistor 37931df7195SAlex Qiu 38031df7195SAlex QiuFor more info on the Hwmon Sysfs, refer to the doc: 38131df7195SAlex Qiu 382*fe99b819SLuca Ceresoli../hwmon/sysfs-interface.rst 38331df7195SAlex Qiu 38431df7195SAlex QiuInstantiate I2C Devices in I2C Sysfs 38531df7195SAlex Qiu------------------------------------ 38631df7195SAlex Qiu 387*fe99b819SLuca CeresoliRefer to section "Method 4: Instantiate from user-space" of instantiating-devices.rst 388