Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

docs: i2c: convert to ReST and add to driver-api bookset

Convert each file at I2C subsystem, renaming them to .rst and
adding to the driver-api book.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
ccf988b6 09f4c750

+4539 -4233
+1 -1
Documentation/devicetree/bindings/i2c/i2c-mux-gpmux.txt
··· 42 42 This means that no unrelated I2C transactions are allowed on the parent I2C 43 43 adapter for the complete multiplexed I2C transaction. 44 44 The properties of mux-locked and parent-locked multiplexers are discussed 45 - in more detail in Documentation/i2c/i2c-topology. 45 + in more detail in Documentation/i2c/i2c-topology.rst. 46 46 47 47 For each i2c child node, an I2C child bus will be created. They will 48 48 be numbered based on their order in the device tree.
+1 -1
Documentation/driver-api/ipmb.rst
··· 83 83 ---------------------- 84 84 85 85 After loading the driver, you can instantiate the device as 86 - described in 'Documentation/i2c/instantiating-devices'. 86 + described in 'Documentation/i2c/instantiating-devices.rst'. 87 87 If you have multiple BMCs, each connected to your Satellite MC via 88 88 a different I2C bus, you can instantiate a device for each of 89 89 those BMCs.
+1 -1
Documentation/hwmon/adm1021.rst
··· 142 142 If nothing happens when loading the adm1021 module, and you are certain 143 143 that your specific Xeon processor model includes compatible sensors, you 144 144 will have to explicitly instantiate the sensor chips from user-space. See 145 - method 4 in Documentation/i2c/instantiating-devices. Possible slave 145 + method 4 in Documentation/i2c/instantiating-devices.rst. Possible slave 146 146 addresses are 0x18, 0x1a, 0x29, 0x2b, 0x4c, or 0x4e. It is likely that 147 147 only temp2 will be correct and temp1 will have to be ignored. 148 148
+1 -1
Documentation/hwmon/adm1275.rst
··· 75 75 ----------- 76 76 77 77 This driver does not auto-detect devices. You will have to instantiate the 78 - devices explicitly. Please see Documentation/i2c/instantiating-devices for 78 + devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for 79 79 details. 80 80 81 81 The ADM1075, unlike many other PMBus devices, does not support internal voltage
+1 -1
Documentation/hwmon/hih6130.rst
··· 27 27 I2C address 0x27 by default, so an entry with I2C_BOARD_INFO("hih6130", 0x27) 28 28 can be used in the board setup code. 29 29 30 - Please see Documentation/i2c/instantiating-devices for details on how to 30 + Please see Documentation/i2c/instantiating-devices.rst for details on how to 31 31 instantiate I2C devices. 32 32 33 33 sysfs-Interface
+1 -1
Documentation/hwmon/ibm-cffps.rst
··· 17 17 ----------- 18 18 19 19 This driver does not auto-detect devices. You will have to instantiate the 20 - devices explicitly. Please see Documentation/i2c/instantiating-devices for 20 + devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for 21 21 details. 22 22 23 23 Sysfs entries
+1 -1
Documentation/hwmon/lm25066.rst
··· 76 76 ----------- 77 77 78 78 This driver does not auto-detect devices. You will have to instantiate the 79 - devices explicitly. Please see Documentation/i2c/instantiating-devices for 79 + devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for 80 80 details. 81 81 82 82
+1 -1
Documentation/hwmon/max16064.rst
··· 28 28 ----------- 29 29 30 30 This driver does not auto-detect devices. You will have to instantiate the 31 - devices explicitly. Please see Documentation/i2c/instantiating-devices for 31 + devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for 32 32 details. 33 33 34 34
+1 -1
Documentation/hwmon/max16065.rst
··· 79 79 80 80 This driver does not probe for devices, since there is no register which 81 81 can be safely used to identify the chip. You will have to instantiate 82 - the devices explicitly. Please see Documentation/i2c/instantiating-devices for 82 + the devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for 83 83 details. 84 84 85 85 WARNING: Do not access chip registers using the i2cdump command, and do not use
+1 -1
Documentation/hwmon/max20751.rst
··· 30 30 ----------- 31 31 32 32 This driver does not auto-detect devices. You will have to instantiate the 33 - devices explicitly. Please see Documentation/i2c/instantiating-devices for 33 + devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for 34 34 details. 35 35 36 36
+1 -1
Documentation/hwmon/max34440.rst
··· 83 83 ----------- 84 84 85 85 This driver does not auto-detect devices. You will have to instantiate the 86 - devices explicitly. Please see Documentation/i2c/instantiating-devices for 86 + devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for 87 87 details. 88 88 89 89 For MAX34446, the value of the currX_crit attribute determines if current or
+1 -1
Documentation/hwmon/max6650.rst
··· 55 55 ----------- 56 56 57 57 This driver does not auto-detect devices. You will have to instantiate the 58 - devices explicitly. Please see Documentation/i2c/instantiating-devices for 58 + devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for 59 59 details. 60 60 61 61 Module parameters
+1 -1
Documentation/hwmon/max8688.rst
··· 28 28 ----------- 29 29 30 30 This driver does not auto-detect devices. You will have to instantiate the 31 - devices explicitly. Please see Documentation/i2c/instantiating-devices for 31 + devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for 32 32 details. 33 33 34 34
+1 -1
Documentation/hwmon/menf21bmc.rst
··· 28 28 This driver is part of the MFD driver named "menf21bmc" and does 29 29 not auto-detect devices. 30 30 You will have to instantiate the MFD driver explicitly. 31 - Please see Documentation/i2c/instantiating-devices for 31 + Please see Documentation/i2c/instantiating-devices.rst for 32 32 details. 33 33 34 34 Sysfs entries
+1 -1
Documentation/hwmon/pcf8591.rst
··· 68 68 The PCF8591 is plainly impossible to detect! Thus the driver won't even 69 69 try. You have to explicitly instantiate the device at the relevant 70 70 address (in the interval [0x48..0x4f]) either through platform data, or 71 - using the sysfs interface. See Documentation/i2c/instantiating-devices 71 + using the sysfs interface. See Documentation/i2c/instantiating-devices.rst 72 72 for details. 73 73 74 74 Directories are being created for each instantiated PCF8591:
+1 -1
Documentation/hwmon/sht3x.rst
··· 26 26 27 27 The device communicates with the I2C protocol. Sensors can have the I2C 28 28 addresses 0x44 or 0x45, depending on the wiring. See 29 - Documentation/i2c/instantiating-devices for methods to instantiate the device. 29 + Documentation/i2c/instantiating-devices.rst for methods to instantiate the device. 30 30 31 31 There are two options configurable by means of sht3x_platform_data: 32 32
+1 -1
Documentation/hwmon/shtc1.rst
··· 36 36 chip, which has the same electrical interface. 37 37 38 38 The device communicates with the I2C protocol. All sensors are set to I2C 39 - address 0x70. See Documentation/i2c/instantiating-devices for methods to 39 + address 0x70. See Documentation/i2c/instantiating-devices.rst for methods to 40 40 instantiate the device. 41 41 42 42 There are two options configurable by means of shtc1_platform_data:
+1 -1
Documentation/hwmon/tmp103.rst
··· 30 30 Documentation/hwmon/sysfs-interface.rst under Temperatures). 31 31 32 32 Please refer how to instantiate this driver: 33 - Documentation/i2c/instantiating-devices 33 + Documentation/i2c/instantiating-devices.rst
+1 -1
Documentation/hwmon/tps40422.rst
··· 28 28 ----------- 29 29 30 30 This driver does not auto-detect devices. You will have to instantiate the 31 - devices explicitly. Please see Documentation/i2c/instantiating-devices for 31 + devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for 32 32 details. 33 33 34 34
+1 -1
Documentation/hwmon/ucd9000.rst
··· 64 64 ----------- 65 65 66 66 This driver does not auto-detect devices. You will have to instantiate the 67 - devices explicitly. Please see Documentation/i2c/instantiating-devices for 67 + devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for 68 68 details. 69 69 70 70
+1 -1
Documentation/hwmon/ucd9200.rst
··· 40 40 ----------- 41 41 42 42 This driver does not auto-detect devices. You will have to instantiate the 43 - devices explicitly. Please see Documentation/i2c/instantiating-devices for 43 + devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for 44 44 details. 45 45 46 46
+1 -1
Documentation/hwmon/via686a.rst
··· 40 40 41 41 The Via 686a southbridge has integrated hardware monitor functionality. 42 42 It also has an I2C bus, but this driver only supports the hardware monitor. 43 - For the I2C bus driver, see <file:Documentation/i2c/busses/i2c-viapro> 43 + For the I2C bus driver, see <file:Documentation/i2c/busses/i2c-viapro.rst> 44 44 45 45 The Via 686a implements three temperature sensors, two fan rotation speed 46 46 sensors, five voltage sensors and alarms.
+1 -1
Documentation/hwmon/zl6100.rst
··· 121 121 ----------- 122 122 123 123 This driver does not auto-detect devices. You will have to instantiate the 124 - devices explicitly. Please see Documentation/i2c/instantiating-devices for 124 + devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for 125 125 details. 126 126 127 127 .. warning::
Documentation/i2c/DMA-considerations Documentation/i2c/dma-considerations.rst
-42
Documentation/i2c/busses/i2c-ali1535
··· 1 - Kernel driver i2c-ali1535 2 - 3 - Supported adapters: 4 - * Acer Labs, Inc. ALI 1535 (south bridge) 5 - Datasheet: Now under NDA 6 - http://www.ali.com.tw/ 7 - 8 - Authors: 9 - Frodo Looijaard <frodol@dds.nl>, 10 - Philip Edelbrock <phil@netroedge.com>, 11 - Mark D. Studebaker <mdsxyz123@yahoo.com>, 12 - Dan Eaton <dan.eaton@rocketlogix.com>, 13 - Stephen Rousset<stephen.rousset@rocketlogix.com> 14 - 15 - Description 16 - ----------- 17 - 18 - This is the driver for the SMB Host controller on Acer Labs Inc. (ALI) 19 - M1535 South Bridge. 20 - 21 - The M1535 is a South bridge for portable systems. It is very similar to the 22 - M15x3 South bridges also produced by Acer Labs Inc. Some of the registers 23 - within the part have moved and some have been redefined slightly. 24 - Additionally, the sequencing of the SMBus transactions has been modified to 25 - be more consistent with the sequencing recommended by the manufacturer and 26 - observed through testing. These changes are reflected in this driver and 27 - can be identified by comparing this driver to the i2c-ali15x3 driver. For 28 - an overview of these chips see http://www.acerlabs.com 29 - 30 - The SMB controller is part of the M7101 device, which is an ACPI-compliant 31 - Power Management Unit (PMU). 32 - 33 - The whole M7101 device has to be enabled for the SMB to work. You can't 34 - just enable the SMB alone. The SMB and the ACPI have separate I/O spaces. 35 - We make sure that the SMB is enabled. We leave the ACPI alone. 36 - 37 - 38 - Features 39 - -------- 40 - 41 - This driver controls the SMB Host only. This driver does not use 42 - interrupts.
+45
Documentation/i2c/busses/i2c-ali1535.rst
··· 1 + ========================= 2 + Kernel driver i2c-ali1535 3 + ========================= 4 + 5 + Supported adapters: 6 + * Acer Labs, Inc. ALI 1535 (south bridge) 7 + 8 + Datasheet: Now under NDA 9 + http://www.ali.com.tw/ 10 + 11 + Authors: 12 + - Frodo Looijaard <frodol@dds.nl>, 13 + - Philip Edelbrock <phil@netroedge.com>, 14 + - Mark D. Studebaker <mdsxyz123@yahoo.com>, 15 + - Dan Eaton <dan.eaton@rocketlogix.com>, 16 + - Stephen Rousset<stephen.rousset@rocketlogix.com> 17 + 18 + Description 19 + ----------- 20 + 21 + This is the driver for the SMB Host controller on Acer Labs Inc. (ALI) 22 + M1535 South Bridge. 23 + 24 + The M1535 is a South bridge for portable systems. It is very similar to the 25 + M15x3 South bridges also produced by Acer Labs Inc. Some of the registers 26 + within the part have moved and some have been redefined slightly. 27 + Additionally, the sequencing of the SMBus transactions has been modified to 28 + be more consistent with the sequencing recommended by the manufacturer and 29 + observed through testing. These changes are reflected in this driver and 30 + can be identified by comparing this driver to the i2c-ali15x3 driver. For 31 + an overview of these chips see http://www.acerlabs.com 32 + 33 + The SMB controller is part of the M7101 device, which is an ACPI-compliant 34 + Power Management Unit (PMU). 35 + 36 + The whole M7101 device has to be enabled for the SMB to work. You can't 37 + just enable the SMB alone. The SMB and the ACPI have separate I/O spaces. 38 + We make sure that the SMB is enabled. We leave the ACPI alone. 39 + 40 + 41 + Features 42 + -------- 43 + 44 + This driver controls the SMB Host only. This driver does not use 45 + interrupts.
-27
Documentation/i2c/busses/i2c-ali1563
··· 1 - Kernel driver i2c-ali1563 2 - 3 - Supported adapters: 4 - * Acer Labs, Inc. ALI 1563 (south bridge) 5 - Datasheet: Now under NDA 6 - http://www.ali.com.tw/ 7 - 8 - Author: Patrick Mochel <mochel@digitalimplant.org> 9 - 10 - Description 11 - ----------- 12 - 13 - This is the driver for the SMB Host controller on Acer Labs Inc. (ALI) 14 - M1563 South Bridge. 15 - 16 - For an overview of these chips see http://www.acerlabs.com 17 - 18 - The M1563 southbridge is deceptively similar to the M1533, with a few 19 - notable exceptions. One of those happens to be the fact they upgraded the 20 - i2c core to be SMBus 2.0 compliant, and happens to be almost identical to 21 - the i2c controller found in the Intel 801 south bridges. 22 - 23 - Features 24 - -------- 25 - 26 - This driver controls the SMB Host only. This driver does not use 27 - interrupts.
+30
Documentation/i2c/busses/i2c-ali1563.rst
··· 1 + ========================= 2 + Kernel driver i2c-ali1563 3 + ========================= 4 + 5 + Supported adapters: 6 + * Acer Labs, Inc. ALI 1563 (south bridge) 7 + 8 + Datasheet: Now under NDA 9 + http://www.ali.com.tw/ 10 + 11 + Author: Patrick Mochel <mochel@digitalimplant.org> 12 + 13 + Description 14 + ----------- 15 + 16 + This is the driver for the SMB Host controller on Acer Labs Inc. (ALI) 17 + M1563 South Bridge. 18 + 19 + For an overview of these chips see http://www.acerlabs.com 20 + 21 + The M1563 southbridge is deceptively similar to the M1533, with a few 22 + notable exceptions. One of those happens to be the fact they upgraded the 23 + i2c core to be SMBus 2.0 compliant, and happens to be almost identical to 24 + the i2c controller found in the Intel 801 south bridges. 25 + 26 + Features 27 + -------- 28 + 29 + This driver controls the SMB Host only. This driver does not use 30 + interrupts.
-112
Documentation/i2c/busses/i2c-ali15x3
··· 1 - Kernel driver i2c-ali15x3 2 - 3 - Supported adapters: 4 - * Acer Labs, Inc. ALI 1533 and 1543C (south bridge) 5 - Datasheet: Now under NDA 6 - http://www.ali.com.tw/ 7 - 8 - Authors: 9 - Frodo Looijaard <frodol@dds.nl>, 10 - Philip Edelbrock <phil@netroedge.com>, 11 - Mark D. Studebaker <mdsxyz123@yahoo.com> 12 - 13 - Module Parameters 14 - ----------------- 15 - 16 - * force_addr: int 17 - Initialize the base address of the i2c controller 18 - 19 - 20 - Notes 21 - ----- 22 - 23 - The force_addr parameter is useful for boards that don't set the address in 24 - the BIOS. Does not do a PCI force; the device must still be present in 25 - lspci. Don't use this unless the driver complains that the base address is 26 - not set. 27 - 28 - Example: 'modprobe i2c-ali15x3 force_addr=0xe800' 29 - 30 - SMBus periodically hangs on ASUS P5A motherboards and can only be cleared 31 - by a power cycle. Cause unknown (see Issues below). 32 - 33 - 34 - Description 35 - ----------- 36 - 37 - This is the driver for the SMB Host controller on Acer Labs Inc. (ALI) 38 - M1541 and M1543C South Bridges. 39 - 40 - The M1543C is a South bridge for desktop systems. 41 - The M1541 is a South bridge for portable systems. 42 - They are part of the following ALI chipsets: 43 - 44 - * "Aladdin Pro 2" includes the M1621 Slot 1 North bridge with AGP and 45 - 100MHz CPU Front Side bus 46 - * "Aladdin V" includes the M1541 Socket 7 North bridge with AGP and 100MHz 47 - CPU Front Side bus 48 - Some Aladdin V motherboards: 49 - Asus P5A 50 - Atrend ATC-5220 51 - BCM/GVC VP1541 52 - Biostar M5ALA 53 - Gigabyte GA-5AX (** Generally doesn't work because the BIOS doesn't 54 - enable the 7101 device! **) 55 - Iwill XA100 Plus 56 - Micronics C200 57 - Microstar (MSI) MS-5169 58 - 59 - * "Aladdin IV" includes the M1541 Socket 7 North bridge 60 - with host bus up to 83.3 MHz. 61 - 62 - For an overview of these chips see http://www.acerlabs.com. At this time the 63 - full data sheets on the web site are password protected, however if you 64 - contact the ALI office in San Jose they may give you the password. 65 - 66 - The M1533/M1543C devices appear as FOUR separate devices on the PCI bus. An 67 - output of lspci will show something similar to the following: 68 - 69 - 00:02.0 USB Controller: Acer Laboratories Inc. M5237 (rev 03) 70 - 00:03.0 Bridge: Acer Laboratories Inc. M7101 <= THIS IS THE ONE WE NEED 71 - 00:07.0 ISA bridge: Acer Laboratories Inc. M1533 (rev c3) 72 - 00:0f.0 IDE interface: Acer Laboratories Inc. M5229 (rev c1) 73 - 74 - ** IMPORTANT ** 75 - ** If you have a M1533 or M1543C on the board and you get 76 - ** "ali15x3: Error: Can't detect ali15x3!" 77 - ** then run lspci. 78 - ** If you see the 1533 and 5229 devices but NOT the 7101 device, 79 - ** then you must enable ACPI, the PMU, SMB, or something similar 80 - ** in the BIOS. 81 - ** The driver won't work if it can't find the M7101 device. 82 - 83 - The SMB controller is part of the M7101 device, which is an ACPI-compliant 84 - Power Management Unit (PMU). 85 - 86 - The whole M7101 device has to be enabled for the SMB to work. You can't 87 - just enable the SMB alone. The SMB and the ACPI have separate I/O spaces. 88 - We make sure that the SMB is enabled. We leave the ACPI alone. 89 - 90 - Features 91 - -------- 92 - 93 - This driver controls the SMB Host only. The SMB Slave 94 - controller on the M15X3 is not enabled. This driver does not use 95 - interrupts. 96 - 97 - 98 - Issues 99 - ------ 100 - 101 - This driver requests the I/O space for only the SMB 102 - registers. It doesn't use the ACPI region. 103 - 104 - On the ASUS P5A motherboard, there are several reports that 105 - the SMBus will hang and this can only be resolved by 106 - powering off the computer. It appears to be worse when the board 107 - gets hot, for example under heavy CPU load, or in the summer. 108 - There may be electrical problems on this board. 109 - On the P5A, the W83781D sensor chip is on both the ISA and 110 - SMBus. Therefore the SMBus hangs can generally be avoided 111 - by accessing the W83781D on the ISA bus only. 112 -
+122
Documentation/i2c/busses/i2c-ali15x3.rst
··· 1 + ========================= 2 + Kernel driver i2c-ali15x3 3 + ========================= 4 + 5 + Supported adapters: 6 + * Acer Labs, Inc. ALI 1533 and 1543C (south bridge) 7 + 8 + Datasheet: Now under NDA 9 + http://www.ali.com.tw/ 10 + 11 + Authors: 12 + - Frodo Looijaard <frodol@dds.nl>, 13 + - Philip Edelbrock <phil@netroedge.com>, 14 + - Mark D. Studebaker <mdsxyz123@yahoo.com> 15 + 16 + Module Parameters 17 + ----------------- 18 + 19 + * force_addr: int 20 + Initialize the base address of the i2c controller 21 + 22 + 23 + Notes 24 + ----- 25 + 26 + The force_addr parameter is useful for boards that don't set the address in 27 + the BIOS. Does not do a PCI force; the device must still be present in 28 + lspci. Don't use this unless the driver complains that the base address is 29 + not set. 30 + 31 + Example:: 32 + 33 + modprobe i2c-ali15x3 force_addr=0xe800 34 + 35 + SMBus periodically hangs on ASUS P5A motherboards and can only be cleared 36 + by a power cycle. Cause unknown (see Issues below). 37 + 38 + 39 + Description 40 + ----------- 41 + 42 + This is the driver for the SMB Host controller on Acer Labs Inc. (ALI) 43 + M1541 and M1543C South Bridges. 44 + 45 + The M1543C is a South bridge for desktop systems. 46 + 47 + The M1541 is a South bridge for portable systems. 48 + 49 + They are part of the following ALI chipsets: 50 + 51 + * "Aladdin Pro 2" includes the M1621 Slot 1 North bridge with AGP and 52 + 100MHz CPU Front Side bus 53 + * "Aladdin V" includes the M1541 Socket 7 North bridge with AGP and 100MHz 54 + CPU Front Side bus 55 + 56 + Some Aladdin V motherboards: 57 + - Asus P5A 58 + - Atrend ATC-5220 59 + - BCM/GVC VP1541 60 + - Biostar M5ALA 61 + - Gigabyte GA-5AX (Generally doesn't work because the BIOS doesn't 62 + enable the 7101 device!) 63 + - Iwill XA100 Plus 64 + - Micronics C200 65 + - Microstar (MSI) MS-5169 66 + 67 + * "Aladdin IV" includes the M1541 Socket 7 North bridge 68 + with host bus up to 83.3 MHz. 69 + 70 + For an overview of these chips see http://www.acerlabs.com. At this time the 71 + full data sheets on the web site are password protected, however if you 72 + contact the ALI office in San Jose they may give you the password. 73 + 74 + The M1533/M1543C devices appear as FOUR separate devices on the PCI bus. An 75 + output of lspci will show something similar to the following:: 76 + 77 + 00:02.0 USB Controller: Acer Laboratories Inc. M5237 (rev 03) 78 + 00:03.0 Bridge: Acer Laboratories Inc. M7101 <= THIS IS THE ONE WE NEED 79 + 00:07.0 ISA bridge: Acer Laboratories Inc. M1533 (rev c3) 80 + 00:0f.0 IDE interface: Acer Laboratories Inc. M5229 (rev c1) 81 + 82 + .. important:: 83 + 84 + If you have a M1533 or M1543C on the board and you get 85 + "ali15x3: Error: Can't detect ali15x3!" 86 + then run lspci. 87 + 88 + If you see the 1533 and 5229 devices but NOT the 7101 device, 89 + then you must enable ACPI, the PMU, SMB, or something similar 90 + in the BIOS. 91 + 92 + The driver won't work if it can't find the M7101 device. 93 + 94 + The SMB controller is part of the M7101 device, which is an ACPI-compliant 95 + Power Management Unit (PMU). 96 + 97 + The whole M7101 device has to be enabled for the SMB to work. You can't 98 + just enable the SMB alone. The SMB and the ACPI have separate I/O spaces. 99 + We make sure that the SMB is enabled. We leave the ACPI alone. 100 + 101 + Features 102 + -------- 103 + 104 + This driver controls the SMB Host only. The SMB Slave 105 + controller on the M15X3 is not enabled. This driver does not use 106 + interrupts. 107 + 108 + 109 + Issues 110 + ------ 111 + 112 + This driver requests the I/O space for only the SMB 113 + registers. It doesn't use the ACPI region. 114 + 115 + On the ASUS P5A motherboard, there are several reports that 116 + the SMBus will hang and this can only be resolved by 117 + powering off the computer. It appears to be worse when the board 118 + gets hot, for example under heavy CPU load, or in the summer. 119 + There may be electrical problems on this board. 120 + On the P5A, the W83781D sensor chip is on both the ISA and 121 + SMBus. Therefore the SMBus hangs can generally be avoided 122 + by accessing the W83781D on the ISA bus only.
-23
Documentation/i2c/busses/i2c-amd-mp2
··· 1 - Kernel driver i2c-amd-mp2 2 - 3 - Supported adapters: 4 - * AMD MP2 PCIe interface 5 - 6 - Datasheet: not publicly available. 7 - 8 - Authors: 9 - Shyam Sundar S K <Shyam-sundar.S-k@amd.com> 10 - Nehal Shah <nehal-bakulchandra.shah@amd.com> 11 - Elie Morisse <syniurge@gmail.com> 12 - 13 - Description 14 - ----------- 15 - 16 - The MP2 is an ARM processor programmed as an I2C controller and communicating 17 - with the x86 host through PCI. 18 - 19 - If you see something like this: 20 - 21 - 03:00.7 MP2 I2C controller: Advanced Micro Devices, Inc. [AMD] Device 15e6 22 - 23 - in your 'lspci -v', then this driver is for your device.
+25
Documentation/i2c/busses/i2c-amd-mp2.rst
··· 1 + ========================= 2 + Kernel driver i2c-amd-mp2 3 + ========================= 4 + 5 + Supported adapters: 6 + * AMD MP2 PCIe interface 7 + 8 + Datasheet: not publicly available. 9 + 10 + Authors: 11 + - Shyam Sundar S K <Shyam-sundar.S-k@amd.com> 12 + - Nehal Shah <nehal-bakulchandra.shah@amd.com> 13 + - Elie Morisse <syniurge@gmail.com> 14 + 15 + Description 16 + ----------- 17 + 18 + The MP2 is an ARM processor programmed as an I2C controller and communicating 19 + with the x86 host through PCI. 20 + 21 + If you see something like this:: 22 + 23 + 03:00.7 MP2 I2C controller: Advanced Micro Devices, Inc. [AMD] Device 15e6 24 + 25 + in your ``lspci -v``, then this driver is for your device.
-25
Documentation/i2c/busses/i2c-amd756
··· 1 - Kernel driver i2c-amd756 2 - 3 - Supported adapters: 4 - * AMD 756 5 - * AMD 766 6 - * AMD 768 7 - * AMD 8111 8 - Datasheets: Publicly available on AMD website 9 - 10 - * nVidia nForce 11 - Datasheet: Unavailable 12 - 13 - Authors: 14 - Frodo Looijaard <frodol@dds.nl>, 15 - Philip Edelbrock <phil@netroedge.com> 16 - 17 - Description 18 - ----------- 19 - 20 - This driver supports the AMD 756, 766, 768 and 8111 Peripheral Bus 21 - Controllers, and the nVidia nForce. 22 - 23 - Note that for the 8111, there are two SMBus adapters. The SMBus 1.0 adapter 24 - is supported by this driver, and the SMBus 2.0 adapter is supported by the 25 - i2c-amd8111 driver.
+29
Documentation/i2c/busses/i2c-amd756.rst
··· 1 + ======================== 2 + Kernel driver i2c-amd756 3 + ======================== 4 + 5 + Supported adapters: 6 + * AMD 756 7 + * AMD 766 8 + * AMD 768 9 + * AMD 8111 10 + 11 + Datasheets: Publicly available on AMD website 12 + 13 + * nVidia nForce 14 + 15 + Datasheet: Unavailable 16 + 17 + Authors: 18 + - Frodo Looijaard <frodol@dds.nl>, 19 + - Philip Edelbrock <phil@netroedge.com> 20 + 21 + Description 22 + ----------- 23 + 24 + This driver supports the AMD 756, 766, 768 and 8111 Peripheral Bus 25 + Controllers, and the nVidia nForce. 26 + 27 + Note that for the 8111, there are two SMBus adapters. The SMBus 1.0 adapter 28 + is supported by this driver, and the SMBus 2.0 adapter is supported by the 29 + i2c-amd8111 driver.
-41
Documentation/i2c/busses/i2c-amd8111
··· 1 - Kernel driver i2c-adm8111 2 - 3 - Supported adapters: 4 - * AMD-8111 SMBus 2.0 PCI interface 5 - 6 - Datasheets: 7 - AMD datasheet not yet available, but almost everything can be found 8 - in the publicly available ACPI 2.0 specification, which the adapter 9 - follows. 10 - 11 - Author: Vojtech Pavlik <vojtech@suse.cz> 12 - 13 - Description 14 - ----------- 15 - 16 - If you see something like this: 17 - 18 - 00:07.2 SMBus: Advanced Micro Devices [AMD] AMD-8111 SMBus 2.0 (rev 02) 19 - Subsystem: Advanced Micro Devices [AMD] AMD-8111 SMBus 2.0 20 - Flags: medium devsel, IRQ 19 21 - I/O ports at d400 [size=32] 22 - 23 - in your 'lspci -v', then this driver is for your chipset. 24 - 25 - Process Call Support 26 - -------------------- 27 - 28 - Supported. 29 - 30 - SMBus 2.0 Support 31 - ----------------- 32 - 33 - Supported. Both PEC and block process call support is implemented. Slave 34 - mode or host notification are not yet implemented. 35 - 36 - Notes 37 - ----- 38 - 39 - Note that for the 8111, there are two SMBus adapters. The SMBus 2.0 adapter 40 - is supported by this driver, and the SMBus 1.0 adapter is supported by the 41 - i2c-amd756 driver.
+43
Documentation/i2c/busses/i2c-amd8111.rst
··· 1 + ========================= 2 + Kernel driver i2c-adm8111 3 + ========================= 4 + 5 + Supported adapters: 6 + * AMD-8111 SMBus 2.0 PCI interface 7 + 8 + Datasheets: 9 + AMD datasheet not yet available, but almost everything can be found 10 + in the publicly available ACPI 2.0 specification, which the adapter 11 + follows. 12 + 13 + Author: Vojtech Pavlik <vojtech@suse.cz> 14 + 15 + Description 16 + ----------- 17 + 18 + If you see something like this:: 19 + 20 + 00:07.2 SMBus: Advanced Micro Devices [AMD] AMD-8111 SMBus 2.0 (rev 02) 21 + Subsystem: Advanced Micro Devices [AMD] AMD-8111 SMBus 2.0 22 + Flags: medium devsel, IRQ 19 23 + I/O ports at d400 [size=32] 24 + 25 + in your ``lspci -v``, then this driver is for your chipset. 26 + 27 + Process Call Support 28 + -------------------- 29 + 30 + Supported. 31 + 32 + SMBus 2.0 Support 33 + ----------------- 34 + 35 + Supported. Both PEC and block process call support is implemented. Slave 36 + mode or host notification are not yet implemented. 37 + 38 + Notes 39 + ----- 40 + 41 + Note that for the 8111, there are two SMBus adapters. The SMBus 2.0 adapter 42 + is supported by this driver, and the SMBus 1.0 adapter is supported by the 43 + i2c-amd756 driver.
-26
Documentation/i2c/busses/i2c-diolan-u2c
··· 1 - Kernel driver i2c-diolan-u2c 2 - 3 - Supported adapters: 4 - * Diolan U2C-12 I2C-USB adapter 5 - Documentation: 6 - http://www.diolan.com/i2c/u2c12.html 7 - 8 - Author: Guenter Roeck <linux@roeck-us.net> 9 - 10 - Description 11 - ----------- 12 - 13 - This is the driver for the Diolan U2C-12 USB-I2C adapter. 14 - 15 - The Diolan U2C-12 I2C-USB Adapter provides a low cost solution to connect 16 - a computer to I2C slave devices using a USB interface. It also supports 17 - connectivity to SPI devices. 18 - 19 - This driver only supports the I2C interface of U2C-12. The driver does not use 20 - interrupts. 21 - 22 - 23 - Module parameters 24 - ----------------- 25 - 26 - * frequency: I2C bus frequency
+29
Documentation/i2c/busses/i2c-diolan-u2c.rst
··· 1 + ============================ 2 + Kernel driver i2c-diolan-u2c 3 + ============================ 4 + 5 + Supported adapters: 6 + * Diolan U2C-12 I2C-USB adapter 7 + 8 + Documentation: 9 + http://www.diolan.com/i2c/u2c12.html 10 + 11 + Author: Guenter Roeck <linux@roeck-us.net> 12 + 13 + Description 14 + ----------- 15 + 16 + This is the driver for the Diolan U2C-12 USB-I2C adapter. 17 + 18 + The Diolan U2C-12 I2C-USB Adapter provides a low cost solution to connect 19 + a computer to I2C slave devices using a USB interface. It also supports 20 + connectivity to SPI devices. 21 + 22 + This driver only supports the I2C interface of U2C-12. The driver does not use 23 + interrupts. 24 + 25 + 26 + Module parameters 27 + ----------------- 28 + 29 + * frequency: I2C bus frequency
-173
Documentation/i2c/busses/i2c-i801
··· 1 - Kernel driver i2c-i801 2 - 3 - Supported adapters: 4 - * Intel 82801AA and 82801AB (ICH and ICH0 - part of the 5 - '810' and '810E' chipsets) 6 - * Intel 82801BA (ICH2 - part of the '815E' chipset) 7 - * Intel 82801CA/CAM (ICH3) 8 - * Intel 82801DB (ICH4) (HW PEC supported) 9 - * Intel 82801EB/ER (ICH5) (HW PEC supported) 10 - * Intel 6300ESB 11 - * Intel 82801FB/FR/FW/FRW (ICH6) 12 - * Intel 82801G (ICH7) 13 - * Intel 631xESB/632xESB (ESB2) 14 - * Intel 82801H (ICH8) 15 - * Intel 82801I (ICH9) 16 - * Intel EP80579 (Tolapai) 17 - * Intel 82801JI (ICH10) 18 - * Intel 5/3400 Series (PCH) 19 - * Intel 6 Series (PCH) 20 - * Intel Patsburg (PCH) 21 - * Intel DH89xxCC (PCH) 22 - * Intel Panther Point (PCH) 23 - * Intel Lynx Point (PCH) 24 - * Intel Avoton (SOC) 25 - * Intel Wellsburg (PCH) 26 - * Intel Coleto Creek (PCH) 27 - * Intel Wildcat Point (PCH) 28 - * Intel BayTrail (SOC) 29 - * Intel Braswell (SOC) 30 - * Intel Sunrise Point (PCH) 31 - * Intel Kaby Lake (PCH) 32 - * Intel DNV (SOC) 33 - * Intel Broxton (SOC) 34 - * Intel Lewisburg (PCH) 35 - * Intel Gemini Lake (SOC) 36 - * Intel Cannon Lake (PCH) 37 - * Intel Cedar Fork (PCH) 38 - * Intel Ice Lake (PCH) 39 - * Intel Comet Lake (PCH) 40 - * Intel Elkhart Lake (PCH) 41 - * Intel Tiger Lake (PCH) 42 - Datasheets: Publicly available at the Intel website 43 - 44 - On Intel Patsburg and later chipsets, both the normal host SMBus controller 45 - and the additional 'Integrated Device Function' controllers are supported. 46 - 47 - Authors: 48 - Mark Studebaker <mdsxyz123@yahoo.com> 49 - Jean Delvare <jdelvare@suse.de> 50 - 51 - 52 - Module Parameters 53 - ----------------- 54 - 55 - * disable_features (bit vector) 56 - Disable selected features normally supported by the device. This makes it 57 - possible to work around possible driver or hardware bugs if the feature in 58 - question doesn't work as intended for whatever reason. Bit values: 59 - 0x01 disable SMBus PEC 60 - 0x02 disable the block buffer 61 - 0x08 disable the I2C block read functionality 62 - 0x10 don't use interrupts 63 - 0x20 disable SMBus Host Notify 64 - 65 - 66 - Description 67 - ----------- 68 - 69 - The ICH (properly known as the 82801AA), ICH0 (82801AB), ICH2 (82801BA), 70 - ICH3 (82801CA/CAM) and later devices (PCH) are Intel chips that are a part of 71 - Intel's '810' chipset for Celeron-based PCs, '810E' chipset for 72 - Pentium-based PCs, '815E' chipset, and others. 73 - 74 - The ICH chips contain at least SEVEN separate PCI functions in TWO logical 75 - PCI devices. An output of lspci will show something similar to the 76 - following: 77 - 78 - 00:1e.0 PCI bridge: Intel Corporation: Unknown device 2418 (rev 01) 79 - 00:1f.0 ISA bridge: Intel Corporation: Unknown device 2410 (rev 01) 80 - 00:1f.1 IDE interface: Intel Corporation: Unknown device 2411 (rev 01) 81 - 00:1f.2 USB Controller: Intel Corporation: Unknown device 2412 (rev 01) 82 - 00:1f.3 Unknown class [0c05]: Intel Corporation: Unknown device 2413 (rev 01) 83 - 84 - The SMBus controller is function 3 in device 1f. Class 0c05 is SMBus Serial 85 - Controller. 86 - 87 - The ICH chips are quite similar to Intel's PIIX4 chip, at least in the 88 - SMBus controller. 89 - 90 - 91 - Process Call Support 92 - -------------------- 93 - 94 - Block process call is supported on the 82801EB (ICH5) and later chips. 95 - 96 - 97 - I2C Block Read Support 98 - ---------------------- 99 - 100 - I2C block read is supported on the 82801EB (ICH5) and later chips. 101 - 102 - 103 - SMBus 2.0 Support 104 - ----------------- 105 - 106 - The 82801DB (ICH4) and later chips support several SMBus 2.0 features. 107 - 108 - 109 - Interrupt Support 110 - ----------------- 111 - 112 - PCI interrupt support is supported on the 82801EB (ICH5) and later chips. 113 - 114 - 115 - Hidden ICH SMBus 116 - ---------------- 117 - 118 - If your system has an Intel ICH south bridge, but you do NOT see the 119 - SMBus device at 00:1f.3 in lspci, and you can't figure out any way in the 120 - BIOS to enable it, it means it has been hidden by the BIOS code. Asus is 121 - well known for first doing this on their P4B motherboard, and many other 122 - boards after that. Some vendor machines are affected as well. 123 - 124 - The first thing to try is the "i2c-scmi" ACPI driver. It could be that the 125 - SMBus was hidden on purpose because it'll be driven by ACPI. If the 126 - i2c-scmi driver works for you, just forget about the i2c-i801 driver and 127 - don't try to unhide the ICH SMBus. Even if i2c-scmi doesn't work, you 128 - better make sure that the SMBus isn't used by the ACPI code. Try loading 129 - the "fan" and "thermal" drivers, and check in /sys/class/thermal. If you 130 - find a thermal zone with type "acpitz", it's likely that the ACPI is 131 - accessing the SMBus and it's safer not to unhide it. Only once you are 132 - certain that ACPI isn't using the SMBus, you can attempt to unhide it. 133 - 134 - In order to unhide the SMBus, we need to change the value of a PCI 135 - register before the kernel enumerates the PCI devices. This is done in 136 - drivers/pci/quirks.c, where all affected boards must be listed (see 137 - function asus_hides_smbus_hostbridge.) If the SMBus device is missing, 138 - and you think there's something interesting on the SMBus (e.g. a 139 - hardware monitoring chip), you need to add your board to the list. 140 - 141 - The motherboard is identified using the subvendor and subdevice IDs of the 142 - host bridge PCI device. Get yours with "lspci -n -v -s 00:00.0": 143 - 144 - 00:00.0 Class 0600: 8086:2570 (rev 02) 145 - Subsystem: 1043:80f2 146 - Flags: bus master, fast devsel, latency 0 147 - Memory at fc000000 (32-bit, prefetchable) [size=32M] 148 - Capabilities: [e4] #09 [2106] 149 - Capabilities: [a0] AGP version 3.0 150 - 151 - Here the host bridge ID is 2570 (82865G/PE/P), the subvendor ID is 1043 152 - (Asus) and the subdevice ID is 80f2 (P4P800-X). You can find the symbolic 153 - names for the bridge ID and the subvendor ID in include/linux/pci_ids.h, 154 - and then add a case for your subdevice ID at the right place in 155 - drivers/pci/quirks.c. Then please give it very good testing, to make sure 156 - that the unhidden SMBus doesn't conflict with e.g. ACPI. 157 - 158 - If it works, proves useful (i.e. there are usable chips on the SMBus) 159 - and seems safe, please submit a patch for inclusion into the kernel. 160 - 161 - Note: There's a useful script in lm_sensors 2.10.2 and later, named 162 - unhide_ICH_SMBus (in prog/hotplug), which uses the fakephp driver to 163 - temporarily unhide the SMBus without having to patch and recompile your 164 - kernel. It's very convenient if you just want to check if there's 165 - anything interesting on your hidden ICH SMBus. 166 - 167 - 168 - ********************** 169 - The lm_sensors project gratefully acknowledges the support of Texas 170 - Instruments in the initial development of this driver. 171 - 172 - The lm_sensors project gratefully acknowledges the support of Intel in the 173 - development of SMBus 2.0 / ICH4 features of this driver.
+182
Documentation/i2c/busses/i2c-i801.rst
··· 1 + ====================== 2 + Kernel driver i2c-i801 3 + ====================== 4 + 5 + 6 + Supported adapters: 7 + * Intel 82801AA and 82801AB (ICH and ICH0 - part of the 8 + '810' and '810E' chipsets) 9 + * Intel 82801BA (ICH2 - part of the '815E' chipset) 10 + * Intel 82801CA/CAM (ICH3) 11 + * Intel 82801DB (ICH4) (HW PEC supported) 12 + * Intel 82801EB/ER (ICH5) (HW PEC supported) 13 + * Intel 6300ESB 14 + * Intel 82801FB/FR/FW/FRW (ICH6) 15 + * Intel 82801G (ICH7) 16 + * Intel 631xESB/632xESB (ESB2) 17 + * Intel 82801H (ICH8) 18 + * Intel 82801I (ICH9) 19 + * Intel EP80579 (Tolapai) 20 + * Intel 82801JI (ICH10) 21 + * Intel 5/3400 Series (PCH) 22 + * Intel 6 Series (PCH) 23 + * Intel Patsburg (PCH) 24 + * Intel DH89xxCC (PCH) 25 + * Intel Panther Point (PCH) 26 + * Intel Lynx Point (PCH) 27 + * Intel Avoton (SOC) 28 + * Intel Wellsburg (PCH) 29 + * Intel Coleto Creek (PCH) 30 + * Intel Wildcat Point (PCH) 31 + * Intel BayTrail (SOC) 32 + * Intel Braswell (SOC) 33 + * Intel Sunrise Point (PCH) 34 + * Intel Kaby Lake (PCH) 35 + * Intel DNV (SOC) 36 + * Intel Broxton (SOC) 37 + * Intel Lewisburg (PCH) 38 + * Intel Gemini Lake (SOC) 39 + * Intel Cannon Lake (PCH) 40 + * Intel Cedar Fork (PCH) 41 + * Intel Ice Lake (PCH) 42 + * Intel Comet Lake (PCH) 43 + * Intel Elkhart Lake (PCH) 44 + * Intel Tiger Lake (PCH) 45 + 46 + Datasheets: Publicly available at the Intel website 47 + 48 + On Intel Patsburg and later chipsets, both the normal host SMBus controller 49 + and the additional 'Integrated Device Function' controllers are supported. 50 + 51 + Authors: 52 + - Mark Studebaker <mdsxyz123@yahoo.com> 53 + - Jean Delvare <jdelvare@suse.de> 54 + 55 + 56 + Module Parameters 57 + ----------------- 58 + 59 + * disable_features (bit vector) 60 + 61 + Disable selected features normally supported by the device. This makes it 62 + possible to work around possible driver or hardware bugs if the feature in 63 + question doesn't work as intended for whatever reason. Bit values: 64 + 65 + ==== ========================================= 66 + 0x01 disable SMBus PEC 67 + 0x02 disable the block buffer 68 + 0x08 disable the I2C block read functionality 69 + 0x10 don't use interrupts 70 + 0x20 disable SMBus Host Notify 71 + ==== ========================================= 72 + 73 + 74 + Description 75 + ----------- 76 + 77 + The ICH (properly known as the 82801AA), ICH0 (82801AB), ICH2 (82801BA), 78 + ICH3 (82801CA/CAM) and later devices (PCH) are Intel chips that are a part of 79 + Intel's '810' chipset for Celeron-based PCs, '810E' chipset for 80 + Pentium-based PCs, '815E' chipset, and others. 81 + 82 + The ICH chips contain at least SEVEN separate PCI functions in TWO logical 83 + PCI devices. An output of lspci will show something similar to the 84 + following:: 85 + 86 + 00:1e.0 PCI bridge: Intel Corporation: Unknown device 2418 (rev 01) 87 + 00:1f.0 ISA bridge: Intel Corporation: Unknown device 2410 (rev 01) 88 + 00:1f.1 IDE interface: Intel Corporation: Unknown device 2411 (rev 01) 89 + 00:1f.2 USB Controller: Intel Corporation: Unknown device 2412 (rev 01) 90 + 00:1f.3 Unknown class [0c05]: Intel Corporation: Unknown device 2413 (rev 01) 91 + 92 + The SMBus controller is function 3 in device 1f. Class 0c05 is SMBus Serial 93 + Controller. 94 + 95 + The ICH chips are quite similar to Intel's PIIX4 chip, at least in the 96 + SMBus controller. 97 + 98 + 99 + Process Call Support 100 + -------------------- 101 + 102 + Block process call is supported on the 82801EB (ICH5) and later chips. 103 + 104 + 105 + I2C Block Read Support 106 + ---------------------- 107 + 108 + I2C block read is supported on the 82801EB (ICH5) and later chips. 109 + 110 + 111 + SMBus 2.0 Support 112 + ----------------- 113 + 114 + The 82801DB (ICH4) and later chips support several SMBus 2.0 features. 115 + 116 + 117 + Interrupt Support 118 + ----------------- 119 + 120 + PCI interrupt support is supported on the 82801EB (ICH5) and later chips. 121 + 122 + 123 + Hidden ICH SMBus 124 + ---------------- 125 + 126 + If your system has an Intel ICH south bridge, but you do NOT see the 127 + SMBus device at 00:1f.3 in lspci, and you can't figure out any way in the 128 + BIOS to enable it, it means it has been hidden by the BIOS code. Asus is 129 + well known for first doing this on their P4B motherboard, and many other 130 + boards after that. Some vendor machines are affected as well. 131 + 132 + The first thing to try is the "i2c-scmi" ACPI driver. It could be that the 133 + SMBus was hidden on purpose because it'll be driven by ACPI. If the 134 + i2c-scmi driver works for you, just forget about the i2c-i801 driver and 135 + don't try to unhide the ICH SMBus. Even if i2c-scmi doesn't work, you 136 + better make sure that the SMBus isn't used by the ACPI code. Try loading 137 + the "fan" and "thermal" drivers, and check in /sys/class/thermal. If you 138 + find a thermal zone with type "acpitz", it's likely that the ACPI is 139 + accessing the SMBus and it's safer not to unhide it. Only once you are 140 + certain that ACPI isn't using the SMBus, you can attempt to unhide it. 141 + 142 + In order to unhide the SMBus, we need to change the value of a PCI 143 + register before the kernel enumerates the PCI devices. This is done in 144 + drivers/pci/quirks.c, where all affected boards must be listed (see 145 + function asus_hides_smbus_hostbridge.) If the SMBus device is missing, 146 + and you think there's something interesting on the SMBus (e.g. a 147 + hardware monitoring chip), you need to add your board to the list. 148 + 149 + The motherboard is identified using the subvendor and subdevice IDs of the 150 + host bridge PCI device. Get yours with ``lspci -n -v -s 00:00.0``:: 151 + 152 + 00:00.0 Class 0600: 8086:2570 (rev 02) 153 + Subsystem: 1043:80f2 154 + Flags: bus master, fast devsel, latency 0 155 + Memory at fc000000 (32-bit, prefetchable) [size=32M] 156 + Capabilities: [e4] #09 [2106] 157 + Capabilities: [a0] AGP version 3.0 158 + 159 + Here the host bridge ID is 2570 (82865G/PE/P), the subvendor ID is 1043 160 + (Asus) and the subdevice ID is 80f2 (P4P800-X). You can find the symbolic 161 + names for the bridge ID and the subvendor ID in include/linux/pci_ids.h, 162 + and then add a case for your subdevice ID at the right place in 163 + drivers/pci/quirks.c. Then please give it very good testing, to make sure 164 + that the unhidden SMBus doesn't conflict with e.g. ACPI. 165 + 166 + If it works, proves useful (i.e. there are usable chips on the SMBus) 167 + and seems safe, please submit a patch for inclusion into the kernel. 168 + 169 + Note: There's a useful script in lm_sensors 2.10.2 and later, named 170 + unhide_ICH_SMBus (in prog/hotplug), which uses the fakephp driver to 171 + temporarily unhide the SMBus without having to patch and recompile your 172 + kernel. It's very convenient if you just want to check if there's 173 + anything interesting on your hidden ICH SMBus. 174 + 175 + 176 + ---------------------------------------------------------------------------- 177 + 178 + The lm_sensors project gratefully acknowledges the support of Texas 179 + Instruments in the initial development of this driver. 180 + 181 + The lm_sensors project gratefully acknowledges the support of Intel in the 182 + development of SMBus 2.0 / ICH4 features of this driver.
-36
Documentation/i2c/busses/i2c-ismt
··· 1 - Kernel driver i2c-ismt 2 - 3 - Supported adapters: 4 - * Intel S12xx series SOCs 5 - 6 - Authors: 7 - Bill Brown <bill.e.brown@intel.com> 8 - 9 - 10 - Module Parameters 11 - ----------------- 12 - 13 - * bus_speed (unsigned int) 14 - Allows changing of the bus speed. Normally, the bus speed is set by the BIOS 15 - and never needs to be changed. However, some SMBus analyzers are too slow for 16 - monitoring the bus during debug, thus the need for this module parameter. 17 - Specify the bus speed in kHz. 18 - Available bus frequency settings: 19 - 0 no change 20 - 80 kHz 21 - 100 kHz 22 - 400 kHz 23 - 1000 kHz 24 - 25 - 26 - Description 27 - ----------- 28 - 29 - The S12xx series of SOCs have a pair of integrated SMBus 2.0 controllers 30 - targeted primarily at the microserver and storage markets. 31 - 32 - The S12xx series contain a pair of PCI functions. An output of lspci will show 33 - something similar to the following: 34 - 35 - 00:13.0 System peripheral: Intel Corporation Centerton SMBus 2.0 Controller 0 36 - 00:13.1 System peripheral: Intel Corporation Centerton SMBus 2.0 Controller 1
+44
Documentation/i2c/busses/i2c-ismt.rst
··· 1 + ====================== 2 + Kernel driver i2c-ismt 3 + ====================== 4 + 5 + 6 + Supported adapters: 7 + * Intel S12xx series SOCs 8 + 9 + Authors: 10 + Bill Brown <bill.e.brown@intel.com> 11 + 12 + 13 + Module Parameters 14 + ----------------- 15 + 16 + * bus_speed (unsigned int) 17 + 18 + Allows changing of the bus speed. Normally, the bus speed is set by the BIOS 19 + and never needs to be changed. However, some SMBus analyzers are too slow for 20 + monitoring the bus during debug, thus the need for this module parameter. 21 + Specify the bus speed in kHz. 22 + 23 + Available bus frequency settings: 24 + 25 + ==== ========= 26 + 0 no change 27 + 80 kHz 28 + 100 kHz 29 + 400 kHz 30 + 1000 kHz 31 + ==== ========= 32 + 33 + 34 + Description 35 + ----------- 36 + 37 + The S12xx series of SOCs have a pair of integrated SMBus 2.0 controllers 38 + targeted primarily at the microserver and storage markets. 39 + 40 + The S12xx series contain a pair of PCI functions. An output of lspci will show 41 + something similar to the following:: 42 + 43 + 00:13.0 System peripheral: Intel Corporation Centerton SMBus 2.0 Controller 0 44 + 00:13.1 System peripheral: Intel Corporation Centerton SMBus 2.0 Controller 1
-51
Documentation/i2c/busses/i2c-mlxcpld
··· 1 - Driver i2c-mlxcpld 2 - 3 - Author: Michael Shych <michaelsh@mellanox.com> 4 - 5 - This is the Mellanox I2C controller logic, implemented in Lattice CPLD 6 - device. 7 - Device supports: 8 - - Master mode. 9 - - One physical bus. 10 - - Polling mode. 11 - 12 - This controller is equipped within the next Mellanox systems: 13 - "msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410", "msb7800", 14 - "msn2740", "msn2100". 15 - 16 - The next transaction types are supported: 17 - - Receive Byte/Block. 18 - - Send Byte/Block. 19 - - Read Byte/Block. 20 - - Write Byte/Block. 21 - 22 - Registers: 23 - CPBLTY 0x0 - capability reg. 24 - Bits [6:5] - transaction length. b01 - 72B is supported, 25 - 36B in other case. 26 - Bit 7 - SMBus block read support. 27 - CTRL 0x1 - control reg. 28 - Resets all the registers. 29 - HALF_CYC 0x4 - cycle reg. 30 - Configure the width of I2C SCL half clock cycle (in 4 LPC_CLK 31 - units). 32 - I2C_HOLD 0x5 - hold reg. 33 - OE (output enable) is delayed by value set to this register 34 - (in LPC_CLK units) 35 - CMD 0x6 - command reg. 36 - Bit 0, 0 = write, 1 = read. 37 - Bits [7:1] - the 7bit Address of the I2C device. 38 - It should be written last as it triggers an I2C transaction. 39 - NUM_DATA 0x7 - data size reg. 40 - Number of data bytes to write in read transaction 41 - NUM_ADDR 0x8 - address reg. 42 - Number of address bytes to write in read transaction. 43 - STATUS 0x9 - status reg. 44 - Bit 0 - transaction is completed. 45 - Bit 4 - ACK/NACK. 46 - DATAx 0xa - 0x54 - 68 bytes data buffer regs. 47 - For write transaction address is specified in four first bytes 48 - (DATA1 - DATA4), data starting from DATA4. 49 - For read transactions address is sent in a separate transaction and 50 - specified in the four first bytes (DATA0 - DATA3). Data is read 51 - starting from DATA0.
+57
Documentation/i2c/busses/i2c-mlxcpld.rst
··· 1 + ================== 2 + Driver i2c-mlxcpld 3 + ================== 4 + 5 + Author: Michael Shych <michaelsh@mellanox.com> 6 + 7 + This is the Mellanox I2C controller logic, implemented in Lattice CPLD 8 + device. 9 + 10 + Device supports: 11 + - Master mode. 12 + - One physical bus. 13 + - Polling mode. 14 + 15 + This controller is equipped within the next Mellanox systems: 16 + "msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410", "msb7800", 17 + "msn2740", "msn2100". 18 + 19 + The next transaction types are supported: 20 + - Receive Byte/Block. 21 + - Send Byte/Block. 22 + - Read Byte/Block. 23 + - Write Byte/Block. 24 + 25 + Registers: 26 + 27 + =============== === ======================================================================= 28 + CPBLTY 0x0 - capability reg. 29 + Bits [6:5] - transaction length. b01 - 72B is supported, 30 + 36B in other case. 31 + Bit 7 - SMBus block read support. 32 + CTRL 0x1 - control reg. 33 + Resets all the registers. 34 + HALF_CYC 0x4 - cycle reg. 35 + Configure the width of I2C SCL half clock cycle (in 4 LPC_CLK 36 + units). 37 + I2C_HOLD 0x5 - hold reg. 38 + OE (output enable) is delayed by value set to this register 39 + (in LPC_CLK units) 40 + CMD 0x6 - command reg. 41 + Bit 0, 0 = write, 1 = read. 42 + Bits [7:1] - the 7bit Address of the I2C device. 43 + It should be written last as it triggers an I2C transaction. 44 + NUM_DATA 0x7 - data size reg. 45 + Number of data bytes to write in read transaction 46 + NUM_ADDR 0x8 - address reg. 47 + Number of address bytes to write in read transaction. 48 + STATUS 0x9 - status reg. 49 + Bit 0 - transaction is completed. 50 + Bit 4 - ACK/NACK. 51 + DATAx 0xa - 0x54 - 68 bytes data buffer regs. 52 + For write transaction address is specified in four first bytes 53 + (DATA1 - DATA4), data starting from DATA4. 54 + For read transactions address is sent in a separate transaction and 55 + specified in the four first bytes (DATA0 - DATA3). Data is read 56 + starting from DATA0. 57 + =============== === =======================================================================
-50
Documentation/i2c/busses/i2c-nforce2
··· 1 - Kernel driver i2c-nforce2 2 - 3 - Supported adapters: 4 - * nForce2 MCP 10de:0064 5 - * nForce2 Ultra 400 MCP 10de:0084 6 - * nForce3 Pro150 MCP 10de:00D4 7 - * nForce3 250Gb MCP 10de:00E4 8 - * nForce4 MCP 10de:0052 9 - * nForce4 MCP-04 10de:0034 10 - * nForce MCP51 10de:0264 11 - * nForce MCP55 10de:0368 12 - * nForce MCP61 10de:03EB 13 - * nForce MCP65 10de:0446 14 - * nForce MCP67 10de:0542 15 - * nForce MCP73 10de:07D8 16 - * nForce MCP78S 10de:0752 17 - * nForce MCP79 10de:0AA2 18 - 19 - Datasheet: not publicly available, but seems to be similar to the 20 - AMD-8111 SMBus 2.0 adapter. 21 - 22 - Authors: 23 - Hans-Frieder Vogt <hfvogt@gmx.net>, 24 - Thomas Leibold <thomas@plx.com>, 25 - Patrick Dreker <patrick@dreker.de> 26 - 27 - Description 28 - ----------- 29 - 30 - i2c-nforce2 is a driver for the SMBuses included in the nVidia nForce2 MCP. 31 - 32 - If your 'lspci -v' listing shows something like the following, 33 - 34 - 00:01.1 SMBus: nVidia Corporation: Unknown device 0064 (rev a2) 35 - Subsystem: Asustek Computer, Inc.: Unknown device 0c11 36 - Flags: 66Mhz, fast devsel, IRQ 5 37 - I/O ports at c000 [size=32] 38 - Capabilities: <available only to root> 39 - 40 - then this driver should support the SMBuses of your motherboard. 41 - 42 - 43 - Notes 44 - ----- 45 - 46 - The SMBus adapter in the nForce2 chipset seems to be very similar to the 47 - SMBus 2.0 adapter in the AMD-8111 south bridge. However, I could only get 48 - the driver to work with direct I/O access, which is different to the EC 49 - interface of the AMD-8111. Tested on Asus A7N8X. The ACPI DSDT table of the 50 - Asus A7N8X lists two SMBuses, both of which are supported by this driver.
+53
Documentation/i2c/busses/i2c-nforce2.rst
··· 1 + ========================= 2 + Kernel driver i2c-nforce2 3 + ========================= 4 + 5 + Supported adapters: 6 + * nForce2 MCP 10de:0064 7 + * nForce2 Ultra 400 MCP 10de:0084 8 + * nForce3 Pro150 MCP 10de:00D4 9 + * nForce3 250Gb MCP 10de:00E4 10 + * nForce4 MCP 10de:0052 11 + * nForce4 MCP-04 10de:0034 12 + * nForce MCP51 10de:0264 13 + * nForce MCP55 10de:0368 14 + * nForce MCP61 10de:03EB 15 + * nForce MCP65 10de:0446 16 + * nForce MCP67 10de:0542 17 + * nForce MCP73 10de:07D8 18 + * nForce MCP78S 10de:0752 19 + * nForce MCP79 10de:0AA2 20 + 21 + Datasheet: 22 + not publicly available, but seems to be similar to the 23 + AMD-8111 SMBus 2.0 adapter. 24 + 25 + Authors: 26 + - Hans-Frieder Vogt <hfvogt@gmx.net>, 27 + - Thomas Leibold <thomas@plx.com>, 28 + - Patrick Dreker <patrick@dreker.de> 29 + 30 + Description 31 + ----------- 32 + 33 + i2c-nforce2 is a driver for the SMBuses included in the nVidia nForce2 MCP. 34 + 35 + If your ``lspci -v`` listing shows something like the following:: 36 + 37 + 00:01.1 SMBus: nVidia Corporation: Unknown device 0064 (rev a2) 38 + Subsystem: Asustek Computer, Inc.: Unknown device 0c11 39 + Flags: 66Mhz, fast devsel, IRQ 5 40 + I/O ports at c000 [size=32] 41 + Capabilities: <available only to root> 42 + 43 + then this driver should support the SMBuses of your motherboard. 44 + 45 + 46 + Notes 47 + ----- 48 + 49 + The SMBus adapter in the nForce2 chipset seems to be very similar to the 50 + SMBus 2.0 adapter in the AMD-8111 south bridge. However, I could only get 51 + the driver to work with direct I/O access, which is different to the EC 52 + interface of the AMD-8111. Tested on Asus A7N8X. The ACPI DSDT table of the 53 + Asus A7N8X lists two SMBuses, both of which are supported by this driver.
-18
Documentation/i2c/busses/i2c-nvidia-gpu
··· 1 - Kernel driver i2c-nvidia-gpu 2 - 3 - Datasheet: not publicly available. 4 - 5 - Authors: 6 - Ajay Gupta <ajayg@nvidia.com> 7 - 8 - Description 9 - ----------- 10 - 11 - i2c-nvidia-gpu is a driver for I2C controller included in NVIDIA Turing 12 - and later GPUs and it is used to communicate with Type-C controller on GPUs. 13 - 14 - If your 'lspci -v' listing shows something like the following, 15 - 16 - 01:00.3 Serial bus controller [0c80]: NVIDIA Corporation Device 1ad9 (rev a1) 17 - 18 - then this driver should support the I2C controller of your GPU.
+20
Documentation/i2c/busses/i2c-nvidia-gpu.rst
··· 1 + ============================ 2 + Kernel driver i2c-nvidia-gpu 3 + ============================ 4 + 5 + Datasheet: not publicly available. 6 + 7 + Authors: 8 + Ajay Gupta <ajayg@nvidia.com> 9 + 10 + Description 11 + ----------- 12 + 13 + i2c-nvidia-gpu is a driver for I2C controller included in NVIDIA Turing 14 + and later GPUs and it is used to communicate with Type-C controller on GPUs. 15 + 16 + If your ``lspci -v`` listing shows something like the following:: 17 + 18 + 01:00.3 Serial bus controller [0c80]: NVIDIA Corporation Device 1ad9 (rev a1) 19 + 20 + then this driver should support the I2C controller of your GPU.
-68
Documentation/i2c/busses/i2c-ocores
··· 1 - Kernel driver i2c-ocores 2 - 3 - Supported adapters: 4 - * OpenCores.org I2C controller by Richard Herveille (see datasheet link) 5 - https://opencores.org/project/i2c/overview 6 - 7 - Author: Peter Korsgaard <peter@korsgaard.com> 8 - 9 - Description 10 - ----------- 11 - 12 - i2c-ocores is an i2c bus driver for the OpenCores.org I2C controller 13 - IP core by Richard Herveille. 14 - 15 - Usage 16 - ----- 17 - 18 - i2c-ocores uses the platform bus, so you need to provide a struct 19 - platform_device with the base address and interrupt number. The 20 - dev.platform_data of the device should also point to a struct 21 - ocores_i2c_platform_data (see linux/platform_data/i2c-ocores.h) describing the 22 - distance between registers and the input clock speed. 23 - There is also a possibility to attach a list of i2c_board_info which 24 - the i2c-ocores driver will add to the bus upon creation. 25 - 26 - E.G. something like: 27 - 28 - static struct resource ocores_resources[] = { 29 - [0] = { 30 - .start = MYI2C_BASEADDR, 31 - .end = MYI2C_BASEADDR + 8, 32 - .flags = IORESOURCE_MEM, 33 - }, 34 - [1] = { 35 - .start = MYI2C_IRQ, 36 - .end = MYI2C_IRQ, 37 - .flags = IORESOURCE_IRQ, 38 - }, 39 - }; 40 - 41 - /* optional board info */ 42 - struct i2c_board_info ocores_i2c_board_info[] = { 43 - { 44 - I2C_BOARD_INFO("tsc2003", 0x48), 45 - .platform_data = &tsc2003_platform_data, 46 - .irq = TSC_IRQ 47 - }, 48 - { 49 - I2C_BOARD_INFO("adv7180", 0x42 >> 1), 50 - .irq = ADV_IRQ 51 - } 52 - }; 53 - 54 - static struct ocores_i2c_platform_data myi2c_data = { 55 - .regstep = 2, /* two bytes between registers */ 56 - .clock_khz = 50000, /* input clock of 50MHz */ 57 - .devices = ocores_i2c_board_info, /* optional table of devices */ 58 - .num_devices = ARRAY_SIZE(ocores_i2c_board_info), /* table size */ 59 - }; 60 - 61 - static struct platform_device myi2c = { 62 - .name = "ocores-i2c", 63 - .dev = { 64 - .platform_data = &myi2c_data, 65 - }, 66 - .num_resources = ARRAY_SIZE(ocores_resources), 67 - .resource = ocores_resources, 68 - };
+70
Documentation/i2c/busses/i2c-ocores.rst
··· 1 + ======================== 2 + Kernel driver i2c-ocores 3 + ======================== 4 + 5 + Supported adapters: 6 + * OpenCores.org I2C controller by Richard Herveille (see datasheet link) 7 + https://opencores.org/project/i2c/overview 8 + 9 + Author: Peter Korsgaard <peter@korsgaard.com> 10 + 11 + Description 12 + ----------- 13 + 14 + i2c-ocores is an i2c bus driver for the OpenCores.org I2C controller 15 + IP core by Richard Herveille. 16 + 17 + Usage 18 + ----- 19 + 20 + i2c-ocores uses the platform bus, so you need to provide a struct 21 + platform_device with the base address and interrupt number. The 22 + dev.platform_data of the device should also point to a struct 23 + ocores_i2c_platform_data (see linux/platform_data/i2c-ocores.h) describing the 24 + distance between registers and the input clock speed. 25 + There is also a possibility to attach a list of i2c_board_info which 26 + the i2c-ocores driver will add to the bus upon creation. 27 + 28 + E.G. something like:: 29 + 30 + static struct resource ocores_resources[] = { 31 + [0] = { 32 + .start = MYI2C_BASEADDR, 33 + .end = MYI2C_BASEADDR + 8, 34 + .flags = IORESOURCE_MEM, 35 + }, 36 + [1] = { 37 + .start = MYI2C_IRQ, 38 + .end = MYI2C_IRQ, 39 + .flags = IORESOURCE_IRQ, 40 + }, 41 + }; 42 + 43 + /* optional board info */ 44 + struct i2c_board_info ocores_i2c_board_info[] = { 45 + { 46 + I2C_BOARD_INFO("tsc2003", 0x48), 47 + .platform_data = &tsc2003_platform_data, 48 + .irq = TSC_IRQ 49 + }, 50 + { 51 + I2C_BOARD_INFO("adv7180", 0x42 >> 1), 52 + .irq = ADV_IRQ 53 + } 54 + }; 55 + 56 + static struct ocores_i2c_platform_data myi2c_data = { 57 + .regstep = 2, /* two bytes between registers */ 58 + .clock_khz = 50000, /* input clock of 50MHz */ 59 + .devices = ocores_i2c_board_info, /* optional table of devices */ 60 + .num_devices = ARRAY_SIZE(ocores_i2c_board_info), /* table size */ 61 + }; 62 + 63 + static struct platform_device myi2c = { 64 + .name = "ocores-i2c", 65 + .dev = { 66 + .platform_data = &myi2c_data, 67 + }, 68 + .num_resources = ARRAY_SIZE(ocores_resources), 69 + .resource = ocores_resources, 70 + };
-178
Documentation/i2c/busses/i2c-parport
··· 1 - Kernel driver i2c-parport 2 - 3 - Author: Jean Delvare <jdelvare@suse.de> 4 - 5 - This is a unified driver for several i2c-over-parallel-port adapters, 6 - such as the ones made by Philips, Velleman or ELV. This driver is 7 - meant as a replacement for the older, individual drivers: 8 - * i2c-philips-par 9 - * i2c-elv 10 - * i2c-velleman 11 - * video/i2c-parport (NOT the same as this one, dedicated to home brew 12 - teletext adapters) 13 - 14 - It currently supports the following devices: 15 - * (type=0) Philips adapter 16 - * (type=1) home brew teletext adapter 17 - * (type=2) Velleman K8000 adapter 18 - * (type=3) ELV adapter 19 - * (type=4) Analog Devices ADM1032 evaluation board 20 - * (type=5) Analog Devices evaluation boards: ADM1025, ADM1030, ADM1031 21 - * (type=6) Barco LPT->DVI (K5800236) adapter 22 - * (type=7) One For All JP1 parallel port adapter 23 - * (type=8) VCT-jig 24 - 25 - These devices use different pinout configurations, so you have to tell 26 - the driver what you have, using the type module parameter. There is no 27 - way to autodetect the devices. Support for different pinout configurations 28 - can be easily added when needed. 29 - 30 - Earlier kernels defaulted to type=0 (Philips). But now, if the type 31 - parameter is missing, the driver will simply fail to initialize. 32 - 33 - SMBus alert support is available on adapters which have this line properly 34 - connected to the parallel port's interrupt pin. 35 - 36 - 37 - Building your own adapter 38 - ------------------------- 39 - 40 - If you want to build you own i2c-over-parallel-port adapter, here is 41 - a sample electronics schema (credits go to Sylvain Munaut): 42 - 43 - Device PC 44 - Side ___________________Vdd (+) Side 45 - | | | 46 - --- --- --- 47 - | | | | | | 48 - |R| |R| |R| 49 - | | | | | | 50 - --- --- --- 51 - | | | 52 - | | /| | 53 - SCL ----------x--------o |-----------x------------------- pin 2 54 - | \| | | 55 - | | | 56 - | |\ | | 57 - SDA ----------x----x---| o---x--------------------------- pin 13 58 - | |/ | 59 - | | 60 - | /| | 61 - ---------o |----------------x-------------- pin 3 62 - \| | | 63 - | | 64 - --- --- 65 - | | | | 66 - |R| |R| 67 - | | | | 68 - --- --- 69 - | | 70 - ### ### 71 - GND GND 72 - 73 - Remarks: 74 - - This is the exact pinout and electronics used on the Analog Devices 75 - evaluation boards. 76 - /| 77 - - All inverters -o |- must be 74HC05, they must be open collector output. 78 - \| 79 - - All resitors are 10k. 80 - - Pins 18-25 of the parallel port connected to GND. 81 - - Pins 4-9 (D2-D7) could be used as VDD is the driver drives them high. 82 - The ADM1032 evaluation board uses D4-D7. Beware that the amount of 83 - current you can draw from the parallel port is limited. Also note that 84 - all connected lines MUST BE driven at the same state, else you'll short 85 - circuit the output buffers! So plugging the I2C adapter after loading 86 - the i2c-parport module might be a good safety since data line state 87 - prior to init may be unknown. 88 - - This is 5V! 89 - - Obviously you cannot read SCL (so it's not really standard-compliant). 90 - Pretty easy to add, just copy the SDA part and use another input pin. 91 - That would give (ELV compatible pinout): 92 - 93 - 94 - Device PC 95 - Side ______________________________Vdd (+) Side 96 - | | | | 97 - --- --- --- --- 98 - | | | | | | | | 99 - |R| |R| |R| |R| 100 - | | | | | | | | 101 - --- --- --- --- 102 - | | | | 103 - | | |\ | | 104 - SCL ----------x--------x--| o---x------------------------ pin 15 105 - | | |/ | 106 - | | | 107 - | | /| | 108 - | ---o |-------------x-------------- pin 2 109 - | \| | | 110 - | | | 111 - | | | 112 - | |\ | | 113 - SDA ---------------x---x--| o--------x------------------- pin 10 114 - | |/ | 115 - | | 116 - | /| | 117 - ---o |------------------x--------- pin 3 118 - \| | | 119 - | | 120 - --- --- 121 - | | | | 122 - |R| |R| 123 - | | | | 124 - --- --- 125 - | | 126 - ### ### 127 - GND GND 128 - 129 - 130 - If possible, you should use the same pinout configuration as existing 131 - adapters do, so you won't even have to change the code. 132 - 133 - 134 - Similar (but different) drivers 135 - ------------------------------- 136 - 137 - This driver is NOT the same as the i2c-pport driver found in the i2c 138 - package. The i2c-pport driver makes use of modern parallel port features so 139 - that you don't need additional electronics. It has other restrictions 140 - however, and was not ported to Linux 2.6 (yet). 141 - 142 - This driver is also NOT the same as the i2c-pcf-epp driver found in the 143 - lm_sensors package. The i2c-pcf-epp driver doesn't use the parallel port as 144 - an I2C bus directly. Instead, it uses it to control an external I2C bus 145 - master. That driver was not ported to Linux 2.6 (yet) either. 146 - 147 - 148 - Legacy documentation for Velleman adapter 149 - ----------------------------------------- 150 - 151 - Useful links: 152 - Velleman http://www.velleman.be/ 153 - Velleman K8000 Howto http://howto.htlw16.ac.at/k8000-howto.html 154 - 155 - The project has lead to new libs for the Velleman K8000 and K8005: 156 - LIBK8000 v1.99.1 and LIBK8005 v0.21 157 - With these libs, you can control the K8000 interface card and the K8005 158 - stepper motor card with the simple commands which are in the original 159 - Velleman software, like SetIOchannel, ReadADchannel, SendStepCCWFull and 160 - many more, using /dev/velleman. 161 - http://home.wanadoo.nl/hihihi/libk8000.htm 162 - http://home.wanadoo.nl/hihihi/libk8005.htm 163 - http://struyve.mine.nu:8080/index.php?block=k8000 164 - http://sourceforge.net/projects/libk8005/ 165 - 166 - 167 - One For All JP1 parallel port adapter 168 - ------------------------------------- 169 - 170 - The JP1 project revolves around a set of remote controls which expose 171 - the I2C bus their internal configuration EEPROM lives on via a 6 pin 172 - jumper in the battery compartment. More details can be found at: 173 - 174 - http://www.hifi-remote.com/jp1/ 175 - 176 - Details of the simple parallel port hardware can be found at: 177 - 178 - http://www.hifi-remote.com/jp1/hardware.shtml
-22
Documentation/i2c/busses/i2c-parport-light
··· 1 - Kernel driver i2c-parport-light 2 - 3 - Author: Jean Delvare <jdelvare@suse.de> 4 - 5 - This driver is a light version of i2c-parport. It doesn't depend 6 - on the parport driver, and uses direct I/O access instead. This might be 7 - preferred on embedded systems where wasting memory for the clean but heavy 8 - parport handling is not an option. The drawback is a reduced portability 9 - and the impossibility to daisy-chain other parallel port devices. 10 - 11 - Please see i2c-parport for documentation. 12 - 13 - Module parameters: 14 - 15 - * type: type of adapter (see i2c-parport or modinfo) 16 - 17 - * base: base I/O address 18 - Default is 0x378 which is fairly common for parallel ports, at least on PC. 19 - 20 - * irq: optional IRQ 21 - This must be passed if you want SMBus alert support, assuming your adapter 22 - actually supports this.
+24
Documentation/i2c/busses/i2c-parport-light.rst
··· 1 + =============================== 2 + Kernel driver i2c-parport-light 3 + =============================== 4 + 5 + Author: Jean Delvare <jdelvare@suse.de> 6 + 7 + This driver is a light version of i2c-parport. It doesn't depend 8 + on the parport driver, and uses direct I/O access instead. This might be 9 + preferred on embedded systems where wasting memory for the clean but heavy 10 + parport handling is not an option. The drawback is a reduced portability 11 + and the impossibility to daisy-chain other parallel port devices. 12 + 13 + Please see i2c-parport for documentation. 14 + 15 + Module parameters: 16 + 17 + * type: type of adapter (see i2c-parport or modinfo) 18 + 19 + * base: base I/O address 20 + Default is 0x378 which is fairly common for parallel ports, at least on PC. 21 + 22 + * irq: optional IRQ 23 + This must be passed if you want SMBus alert support, assuming your adapter 24 + actually supports this.
+190
Documentation/i2c/busses/i2c-parport.rst
··· 1 + ========================= 2 + Kernel driver i2c-parport 3 + ========================= 4 + 5 + Author: Jean Delvare <jdelvare@suse.de> 6 + 7 + This is a unified driver for several i2c-over-parallel-port adapters, 8 + such as the ones made by Philips, Velleman or ELV. This driver is 9 + meant as a replacement for the older, individual drivers: 10 + 11 + * i2c-philips-par 12 + * i2c-elv 13 + * i2c-velleman 14 + * video/i2c-parport 15 + (NOT the same as this one, dedicated to home brew teletext adapters) 16 + 17 + It currently supports the following devices: 18 + 19 + * (type=0) Philips adapter 20 + * (type=1) home brew teletext adapter 21 + * (type=2) Velleman K8000 adapter 22 + * (type=3) ELV adapter 23 + * (type=4) Analog Devices ADM1032 evaluation board 24 + * (type=5) Analog Devices evaluation boards: ADM1025, ADM1030, ADM1031 25 + * (type=6) Barco LPT->DVI (K5800236) adapter 26 + * (type=7) One For All JP1 parallel port adapter 27 + * (type=8) VCT-jig 28 + 29 + These devices use different pinout configurations, so you have to tell 30 + the driver what you have, using the type module parameter. There is no 31 + way to autodetect the devices. Support for different pinout configurations 32 + can be easily added when needed. 33 + 34 + Earlier kernels defaulted to type=0 (Philips). But now, if the type 35 + parameter is missing, the driver will simply fail to initialize. 36 + 37 + SMBus alert support is available on adapters which have this line properly 38 + connected to the parallel port's interrupt pin. 39 + 40 + 41 + Building your own adapter 42 + ------------------------- 43 + 44 + If you want to build you own i2c-over-parallel-port adapter, here is 45 + a sample electronics schema (credits go to Sylvain Munaut):: 46 + 47 + Device PC 48 + Side ___________________Vdd (+) Side 49 + | | | 50 + --- --- --- 51 + | | | | | | 52 + |R| |R| |R| 53 + | | | | | | 54 + --- --- --- 55 + | | | 56 + | | /| | 57 + SCL ----------x--------o |-----------x------------------- pin 2 58 + | \| | | 59 + | | | 60 + | |\ | | 61 + SDA ----------x----x---| o---x--------------------------- pin 13 62 + | |/ | 63 + | | 64 + | /| | 65 + ---------o |----------------x-------------- pin 3 66 + \| | | 67 + | | 68 + --- --- 69 + | | | | 70 + |R| |R| 71 + | | | | 72 + --- --- 73 + | | 74 + ### ### 75 + GND GND 76 + 77 + Remarks: 78 + - This is the exact pinout and electronics used on the Analog Devices 79 + evaluation boards. 80 + - All inverters:: 81 + 82 + /| 83 + -o |- 84 + \| 85 + 86 + must be 74HC05, they must be open collector output. 87 + - All resitors are 10k. 88 + - Pins 18-25 of the parallel port connected to GND. 89 + - Pins 4-9 (D2-D7) could be used as VDD is the driver drives them high. 90 + The ADM1032 evaluation board uses D4-D7. Beware that the amount of 91 + current you can draw from the parallel port is limited. Also note that 92 + all connected lines MUST BE driven at the same state, else you'll short 93 + circuit the output buffers! So plugging the I2C adapter after loading 94 + the i2c-parport module might be a good safety since data line state 95 + prior to init may be unknown. 96 + - This is 5V! 97 + - Obviously you cannot read SCL (so it's not really standard-compliant). 98 + Pretty easy to add, just copy the SDA part and use another input pin. 99 + That would give (ELV compatible pinout):: 100 + 101 + 102 + Device PC 103 + Side ______________________________Vdd (+) Side 104 + | | | | 105 + --- --- --- --- 106 + | | | | | | | | 107 + |R| |R| |R| |R| 108 + | | | | | | | | 109 + --- --- --- --- 110 + | | | | 111 + | | |\ | | 112 + SCL ----------x--------x--| o---x------------------------ pin 15 113 + | | |/ | 114 + | | | 115 + | | /| | 116 + | ---o |-------------x-------------- pin 2 117 + | \| | | 118 + | | | 119 + | | | 120 + | |\ | | 121 + SDA ---------------x---x--| o--------x------------------- pin 10 122 + | |/ | 123 + | | 124 + | /| | 125 + ---o |------------------x--------- pin 3 126 + \| | | 127 + | | 128 + --- --- 129 + | | | | 130 + |R| |R| 131 + | | | | 132 + --- --- 133 + | | 134 + ### ### 135 + GND GND 136 + 137 + 138 + If possible, you should use the same pinout configuration as existing 139 + adapters do, so you won't even have to change the code. 140 + 141 + 142 + Similar (but different) drivers 143 + ------------------------------- 144 + 145 + This driver is NOT the same as the i2c-pport driver found in the i2c 146 + package. The i2c-pport driver makes use of modern parallel port features so 147 + that you don't need additional electronics. It has other restrictions 148 + however, and was not ported to Linux 2.6 (yet). 149 + 150 + This driver is also NOT the same as the i2c-pcf-epp driver found in the 151 + lm_sensors package. The i2c-pcf-epp driver doesn't use the parallel port as 152 + an I2C bus directly. Instead, it uses it to control an external I2C bus 153 + master. That driver was not ported to Linux 2.6 (yet) either. 154 + 155 + 156 + Legacy documentation for Velleman adapter 157 + ----------------------------------------- 158 + 159 + Useful links: 160 + 161 + - Velleman http://www.velleman.be/ 162 + - Velleman K8000 Howto http://howto.htlw16.ac.at/k8000-howto.html 163 + 164 + The project has lead to new libs for the Velleman K8000 and K8005: 165 + 166 + LIBK8000 v1.99.1 and LIBK8005 v0.21 167 + 168 + With these libs, you can control the K8000 interface card and the K8005 169 + stepper motor card with the simple commands which are in the original 170 + Velleman software, like SetIOchannel, ReadADchannel, SendStepCCWFull and 171 + many more, using /dev/velleman. 172 + 173 + - http://home.wanadoo.nl/hihihi/libk8000.htm 174 + - http://home.wanadoo.nl/hihihi/libk8005.htm 175 + - http://struyve.mine.nu:8080/index.php?block=k8000 176 + - http://sourceforge.net/projects/libk8005/ 177 + 178 + 179 + One For All JP1 parallel port adapter 180 + ------------------------------------- 181 + 182 + The JP1 project revolves around a set of remote controls which expose 183 + the I2C bus their internal configuration EEPROM lives on via a 6 pin 184 + jumper in the battery compartment. More details can be found at: 185 + 186 + http://www.hifi-remote.com/jp1/ 187 + 188 + Details of the simple parallel port hardware can be found at: 189 + 190 + http://www.hifi-remote.com/jp1/hardware.shtml
-23
Documentation/i2c/busses/i2c-pca-isa
··· 1 - Kernel driver i2c-pca-isa 2 - 3 - Supported adapters: 4 - This driver supports ISA boards using the Philips PCA 9564 5 - Parallel bus to I2C bus controller 6 - 7 - Author: Ian Campbell <icampbell@arcom.com>, Arcom Control Systems 8 - 9 - Module Parameters 10 - ----------------- 11 - 12 - * base int 13 - I/O base address 14 - * irq int 15 - IRQ interrupt 16 - * clock int 17 - Clock rate as described in table 1 of PCA9564 datasheet 18 - 19 - Description 20 - ----------- 21 - 22 - This driver supports ISA boards using the Philips PCA 9564 23 - Parallel bus to I2C bus controller
+26
Documentation/i2c/busses/i2c-pca-isa.rst
··· 1 + ========================= 2 + Kernel driver i2c-pca-isa 3 + ========================= 4 + 5 + Supported adapters: 6 + 7 + This driver supports ISA boards using the Philips PCA 9564 8 + Parallel bus to I2C bus controller 9 + 10 + Author: Ian Campbell <icampbell@arcom.com>, Arcom Control Systems 11 + 12 + Module Parameters 13 + ----------------- 14 + 15 + * base int 16 + I/O base address 17 + * irq int 18 + IRQ interrupt 19 + * clock int 20 + Clock rate as described in table 1 of PCA9564 datasheet 21 + 22 + Description 23 + ----------- 24 + 25 + This driver supports ISA boards using the Philips PCA 9564 26 + Parallel bus to I2C bus controller
-112
Documentation/i2c/busses/i2c-piix4
··· 1 - Kernel driver i2c-piix4 2 - 3 - Supported adapters: 4 - * Intel 82371AB PIIX4 and PIIX4E 5 - * Intel 82443MX (440MX) 6 - Datasheet: Publicly available at the Intel website 7 - * ServerWorks OSB4, CSB5, CSB6, HT-1000 and HT-1100 southbridges 8 - Datasheet: Only available via NDA from ServerWorks 9 - * ATI IXP200, IXP300, IXP400, SB600, SB700 and SB800 southbridges 10 - Datasheet: Not publicly available 11 - SB700 register reference available at: 12 - http://support.amd.com/us/Embedded_TechDocs/43009_sb7xx_rrg_pub_1.00.pdf 13 - * AMD SP5100 (SB700 derivative found on some server mainboards) 14 - Datasheet: Publicly available at the AMD website 15 - http://support.amd.com/us/Embedded_TechDocs/44413.pdf 16 - * AMD Hudson-2, ML, CZ 17 - Datasheet: Not publicly available 18 - * Hygon CZ 19 - Datasheet: Not publicly available 20 - * Standard Microsystems (SMSC) SLC90E66 (Victory66) southbridge 21 - Datasheet: Publicly available at the SMSC website http://www.smsc.com 22 - 23 - Authors: 24 - Frodo Looijaard <frodol@dds.nl> 25 - Philip Edelbrock <phil@netroedge.com> 26 - 27 - 28 - Module Parameters 29 - ----------------- 30 - 31 - * force: int 32 - Forcibly enable the PIIX4. DANGEROUS! 33 - * force_addr: int 34 - Forcibly enable the PIIX4 at the given address. EXTREMELY DANGEROUS! 35 - 36 - 37 - Description 38 - ----------- 39 - 40 - The PIIX4 (properly known as the 82371AB) is an Intel chip with a lot of 41 - functionality. Among other things, it implements the PCI bus. One of its 42 - minor functions is implementing a System Management Bus. This is a true 43 - SMBus - you can not access it on I2C levels. The good news is that it 44 - natively understands SMBus commands and you do not have to worry about 45 - timing problems. The bad news is that non-SMBus devices connected to it can 46 - confuse it mightily. Yes, this is known to happen... 47 - 48 - Do 'lspci -v' and see whether it contains an entry like this: 49 - 50 - 0000:00:02.3 Bridge: Intel Corp. 82371AB/EB/MB PIIX4 ACPI (rev 02) 51 - Flags: medium devsel, IRQ 9 52 - 53 - Bus and device numbers may differ, but the function number must be 54 - identical (like many PCI devices, the PIIX4 incorporates a number of 55 - different 'functions', which can be considered as separate devices). If you 56 - find such an entry, you have a PIIX4 SMBus controller. 57 - 58 - On some computers (most notably, some Dells), the SMBus is disabled by 59 - default. If you use the insmod parameter 'force=1', the kernel module will 60 - try to enable it. THIS IS VERY DANGEROUS! If the BIOS did not set up a 61 - correct address for this module, you could get in big trouble (read: 62 - crashes, data corruption, etc.). Try this only as a last resort (try BIOS 63 - updates first, for example), and backup first! An even more dangerous 64 - option is 'force_addr=<IOPORT>'. This will not only enable the PIIX4 like 65 - 'force' foes, but it will also set a new base I/O port address. The SMBus 66 - parts of the PIIX4 needs a range of 8 of these addresses to function 67 - correctly. If these addresses are already reserved by some other device, 68 - you will get into big trouble! DON'T USE THIS IF YOU ARE NOT VERY SURE 69 - ABOUT WHAT YOU ARE DOING! 70 - 71 - The PIIX4E is just an new version of the PIIX4; it is supported as well. 72 - The PIIX/PIIX3 does not implement an SMBus or I2C bus, so you can't use 73 - this driver on those mainboards. 74 - 75 - The ServerWorks Southbridges, the Intel 440MX, and the Victory66 are 76 - identical to the PIIX4 in I2C/SMBus support. 77 - 78 - The AMD SB700, SB800, SP5100 and Hudson-2 chipsets implement two 79 - PIIX4-compatible SMBus controllers. If your BIOS initializes the 80 - secondary controller, it will be detected by this driver as 81 - an "Auxiliary SMBus Host Controller". 82 - 83 - If you own Force CPCI735 motherboard or other OSB4 based systems you may need 84 - to change the SMBus Interrupt Select register so the SMBus controller uses 85 - the SMI mode. 86 - 87 - 1) Use lspci command and locate the PCI device with the SMBus controller: 88 - 00:0f.0 ISA bridge: ServerWorks OSB4 South Bridge (rev 4f) 89 - The line may vary for different chipsets. Please consult the driver source 90 - for all possible PCI ids (and lspci -n to match them). Lets assume the 91 - device is located at 00:0f.0. 92 - 2) Now you just need to change the value in 0xD2 register. Get it first with 93 - command: lspci -xxx -s 00:0f.0 94 - If the value is 0x3 then you need to change it to 0x1 95 - setpci -s 00:0f.0 d2.b=1 96 - 97 - Please note that you don't need to do that in all cases, just when the SMBus is 98 - not working properly. 99 - 100 - 101 - Hardware-specific issues 102 - ------------------------ 103 - 104 - This driver will refuse to load on IBM systems with an Intel PIIX4 SMBus. 105 - Some of these machines have an RFID EEPROM (24RF08) connected to the SMBus, 106 - which can easily get corrupted due to a state machine bug. These are mostly 107 - Thinkpad laptops, but desktop systems may also be affected. We have no list 108 - of all affected systems, so the only safe solution was to prevent access to 109 - the SMBus on all IBM systems (detected using DMI data.) 110 - 111 - For additional information, read: 112 - http://www.lm-sensors.org/browser/lm-sensors/trunk/README
+114
Documentation/i2c/busses/i2c-piix4.rst
··· 1 + ======================= 2 + Kernel driver i2c-piix4 3 + ======================= 4 + 5 + Supported adapters: 6 + * Intel 82371AB PIIX4 and PIIX4E 7 + * Intel 82443MX (440MX) 8 + Datasheet: Publicly available at the Intel website 9 + * ServerWorks OSB4, CSB5, CSB6, HT-1000 and HT-1100 southbridges 10 + Datasheet: Only available via NDA from ServerWorks 11 + * ATI IXP200, IXP300, IXP400, SB600, SB700 and SB800 southbridges 12 + Datasheet: Not publicly available 13 + SB700 register reference available at: 14 + http://support.amd.com/us/Embedded_TechDocs/43009_sb7xx_rrg_pub_1.00.pdf 15 + * AMD SP5100 (SB700 derivative found on some server mainboards) 16 + Datasheet: Publicly available at the AMD website 17 + http://support.amd.com/us/Embedded_TechDocs/44413.pdf 18 + * AMD Hudson-2, ML, CZ 19 + Datasheet: Not publicly available 20 + * Hygon CZ 21 + Datasheet: Not publicly available 22 + * Standard Microsystems (SMSC) SLC90E66 (Victory66) southbridge 23 + Datasheet: Publicly available at the SMSC website http://www.smsc.com 24 + 25 + Authors: 26 + - Frodo Looijaard <frodol@dds.nl> 27 + - Philip Edelbrock <phil@netroedge.com> 28 + 29 + 30 + Module Parameters 31 + ----------------- 32 + 33 + * force: int 34 + Forcibly enable the PIIX4. DANGEROUS! 35 + * force_addr: int 36 + Forcibly enable the PIIX4 at the given address. EXTREMELY DANGEROUS! 37 + 38 + 39 + Description 40 + ----------- 41 + 42 + The PIIX4 (properly known as the 82371AB) is an Intel chip with a lot of 43 + functionality. Among other things, it implements the PCI bus. One of its 44 + minor functions is implementing a System Management Bus. This is a true 45 + SMBus - you can not access it on I2C levels. The good news is that it 46 + natively understands SMBus commands and you do not have to worry about 47 + timing problems. The bad news is that non-SMBus devices connected to it can 48 + confuse it mightily. Yes, this is known to happen... 49 + 50 + Do ``lspci -v`` and see whether it contains an entry like this:: 51 + 52 + 0000:00:02.3 Bridge: Intel Corp. 82371AB/EB/MB PIIX4 ACPI (rev 02) 53 + Flags: medium devsel, IRQ 9 54 + 55 + Bus and device numbers may differ, but the function number must be 56 + identical (like many PCI devices, the PIIX4 incorporates a number of 57 + different 'functions', which can be considered as separate devices). If you 58 + find such an entry, you have a PIIX4 SMBus controller. 59 + 60 + On some computers (most notably, some Dells), the SMBus is disabled by 61 + default. If you use the insmod parameter 'force=1', the kernel module will 62 + try to enable it. THIS IS VERY DANGEROUS! If the BIOS did not set up a 63 + correct address for this module, you could get in big trouble (read: 64 + crashes, data corruption, etc.). Try this only as a last resort (try BIOS 65 + updates first, for example), and backup first! An even more dangerous 66 + option is 'force_addr=<IOPORT>'. This will not only enable the PIIX4 like 67 + 'force' foes, but it will also set a new base I/O port address. The SMBus 68 + parts of the PIIX4 needs a range of 8 of these addresses to function 69 + correctly. If these addresses are already reserved by some other device, 70 + you will get into big trouble! DON'T USE THIS IF YOU ARE NOT VERY SURE 71 + ABOUT WHAT YOU ARE DOING! 72 + 73 + The PIIX4E is just an new version of the PIIX4; it is supported as well. 74 + The PIIX/PIIX3 does not implement an SMBus or I2C bus, so you can't use 75 + this driver on those mainboards. 76 + 77 + The ServerWorks Southbridges, the Intel 440MX, and the Victory66 are 78 + identical to the PIIX4 in I2C/SMBus support. 79 + 80 + The AMD SB700, SB800, SP5100 and Hudson-2 chipsets implement two 81 + PIIX4-compatible SMBus controllers. If your BIOS initializes the 82 + secondary controller, it will be detected by this driver as 83 + an "Auxiliary SMBus Host Controller". 84 + 85 + If you own Force CPCI735 motherboard or other OSB4 based systems you may need 86 + to change the SMBus Interrupt Select register so the SMBus controller uses 87 + the SMI mode. 88 + 89 + 1) Use lspci command and locate the PCI device with the SMBus controller: 90 + 00:0f.0 ISA bridge: ServerWorks OSB4 South Bridge (rev 4f) 91 + The line may vary for different chipsets. Please consult the driver source 92 + for all possible PCI ids (and lspci -n to match them). Lets assume the 93 + device is located at 00:0f.0. 94 + 2) Now you just need to change the value in 0xD2 register. Get it first with 95 + command: lspci -xxx -s 00:0f.0 96 + If the value is 0x3 then you need to change it to 0x1: 97 + setpci -s 00:0f.0 d2.b=1 98 + 99 + Please note that you don't need to do that in all cases, just when the SMBus is 100 + not working properly. 101 + 102 + 103 + Hardware-specific issues 104 + ------------------------ 105 + 106 + This driver will refuse to load on IBM systems with an Intel PIIX4 SMBus. 107 + Some of these machines have an RFID EEPROM (24RF08) connected to the SMBus, 108 + which can easily get corrupted due to a state machine bug. These are mostly 109 + Thinkpad laptops, but desktop systems may also be affected. We have no list 110 + of all affected systems, so the only safe solution was to prevent access to 111 + the SMBus on all IBM systems (detected using DMI data.) 112 + 113 + For additional information, read: 114 + http://www.lm-sensors.org/browser/lm-sensors/trunk/README
-59
Documentation/i2c/busses/i2c-sis5595
··· 1 - Kernel driver i2c-sis5595 2 - 3 - Authors: 4 - Frodo Looijaard <frodol@dds.nl>, 5 - Mark D. Studebaker <mdsxyz123@yahoo.com>, 6 - Philip Edelbrock <phil@netroedge.com> 7 - 8 - Supported adapters: 9 - * Silicon Integrated Systems Corp. SiS5595 Southbridge 10 - Datasheet: Publicly available at the Silicon Integrated Systems Corp. site. 11 - 12 - Note: all have mfr. ID 0x1039. 13 - 14 - SUPPORTED PCI ID 15 - 5595 0008 16 - 17 - Note: these chips contain a 0008 device which is incompatible with the 18 - 5595. We recognize these by the presence of the listed 19 - "blacklist" PCI ID and refuse to load. 20 - 21 - NOT SUPPORTED PCI ID BLACKLIST PCI ID 22 - 540 0008 0540 23 - 550 0008 0550 24 - 5513 0008 5511 25 - 5581 0008 5597 26 - 5582 0008 5597 27 - 5597 0008 5597 28 - 5598 0008 5597/5598 29 - 630 0008 0630 30 - 645 0008 0645 31 - 646 0008 0646 32 - 648 0008 0648 33 - 650 0008 0650 34 - 651 0008 0651 35 - 730 0008 0730 36 - 735 0008 0735 37 - 745 0008 0745 38 - 746 0008 0746 39 - 40 - Module Parameters 41 - ----------------- 42 - 43 - * force_addr=0xaddr Set the I/O base address. Useful for boards 44 - that don't set the address in the BIOS. Does not do a 45 - PCI force; the device must still be present in lspci. 46 - Don't use this unless the driver complains that the 47 - base address is not set. 48 - 49 - Description 50 - ----------- 51 - 52 - i2c-sis5595 is a true SMBus host driver for motherboards with the SiS5595 53 - southbridges. 54 - 55 - WARNING: If you are trying to access the integrated sensors on the SiS5595 56 - chip, you want the sis5595 driver for those, not this driver. This driver 57 - is a BUS driver, not a CHIP driver. A BUS driver is used by other CHIP 58 - drivers to access chips on the bus. 59 -
+68
Documentation/i2c/busses/i2c-sis5595.rst
··· 1 + ========================= 2 + Kernel driver i2c-sis5595 3 + ========================= 4 + 5 + Authors: 6 + - Frodo Looijaard <frodol@dds.nl>, 7 + - Mark D. Studebaker <mdsxyz123@yahoo.com>, 8 + - Philip Edelbrock <phil@netroedge.com> 9 + 10 + Supported adapters: 11 + * Silicon Integrated Systems Corp. SiS5595 Southbridge 12 + Datasheet: Publicly available at the Silicon Integrated Systems Corp. site. 13 + 14 + Note: all have mfr. ID 0x1039. 15 + 16 + ========= ====== 17 + SUPPORTED PCI ID 18 + ========= ====== 19 + 5595 0008 20 + ========= ====== 21 + 22 + Note: these chips contain a 0008 device which is incompatible with the 23 + 5595. We recognize these by the presence of the listed 24 + "blacklist" PCI ID and refuse to load. 25 + 26 + ============= ====== ================ 27 + NOT SUPPORTED PCI ID BLACKLIST PCI ID 28 + ============= ====== ================ 29 + 540 0008 0540 30 + 550 0008 0550 31 + 5513 0008 5511 32 + 5581 0008 5597 33 + 5582 0008 5597 34 + 5597 0008 5597 35 + 5598 0008 5597/5598 36 + 630 0008 0630 37 + 645 0008 0645 38 + 646 0008 0646 39 + 648 0008 0648 40 + 650 0008 0650 41 + 651 0008 0651 42 + 730 0008 0730 43 + 735 0008 0735 44 + 745 0008 0745 45 + 746 0008 0746 46 + ============= ====== ================ 47 + 48 + Module Parameters 49 + ----------------- 50 + 51 + ================== ===================================================== 52 + force_addr=0xaddr Set the I/O base address. Useful for boards 53 + that don't set the address in the BIOS. Does not do a 54 + PCI force; the device must still be present in lspci. 55 + Don't use this unless the driver complains that the 56 + base address is not set. 57 + ================== ===================================================== 58 + 59 + Description 60 + ----------- 61 + 62 + i2c-sis5595 is a true SMBus host driver for motherboards with the SiS5595 63 + southbridges. 64 + 65 + WARNING: If you are trying to access the integrated sensors on the SiS5595 66 + chip, you want the sis5595 driver for those, not this driver. This driver 67 + is a BUS driver, not a CHIP driver. A BUS driver is used by other CHIP 68 + drivers to access chips on the bus.
-58
Documentation/i2c/busses/i2c-sis630
··· 1 - Kernel driver i2c-sis630 2 - 3 - Supported adapters: 4 - * Silicon Integrated Systems Corp (SiS) 5 - 630 chipset (Datasheet: available at http://www.sfr-fresh.com/linux) 6 - 730 chipset 7 - 964 chipset 8 - * Possible other SiS chipsets ? 9 - 10 - Author: Alexander Malysh <amalysh@web.de> 11 - Amaury Decrême <amaury.decreme@gmail.com> - SiS964 support 12 - 13 - Module Parameters 14 - ----------------- 15 - 16 - * force = [1|0] Forcibly enable the SIS630. DANGEROUS! 17 - This can be interesting for chipsets not named 18 - above to check if it works for you chipset, but DANGEROUS! 19 - 20 - * high_clock = [1|0] Forcibly set Host Master Clock to 56KHz (default, 21 - what your BIOS use). DANGEROUS! This should be a bit 22 - faster, but freeze some systems (i.e. my Laptop). 23 - SIS630/730 chip only. 24 - 25 - 26 - Description 27 - ----------- 28 - 29 - This SMBus only driver is known to work on motherboards with the above 30 - named chipsets. 31 - 32 - If you see something like this: 33 - 34 - 00:00.0 Host bridge: Silicon Integrated Systems [SiS] 630 Host (rev 31) 35 - 00:01.0 ISA bridge: Silicon Integrated Systems [SiS] 85C503/5513 36 - 37 - or like this: 38 - 39 - 00:00.0 Host bridge: Silicon Integrated Systems [SiS] 730 Host (rev 02) 40 - 00:01.0 ISA bridge: Silicon Integrated Systems [SiS] 85C503/5513 41 - 42 - or like this: 43 - 44 - 00:00.0 Host bridge: Silicon Integrated Systems [SiS] 760/M760 Host (rev 02) 45 - 00:02.0 ISA bridge: Silicon Integrated Systems [SiS] SiS964 [MuTIOL Media IO] 46 - LPC Controller (rev 36) 47 - 48 - in your 'lspci' output , then this driver is for your chipset. 49 - 50 - Thank You 51 - --------- 52 - Philip Edelbrock <phil@netroedge.com> 53 - - testing SiS730 support 54 - Mark M. Hoffman <mhoffman@lightlink.com> 55 - - bug fixes 56 - 57 - To anyone else which I forgot here ;), thanks! 58 -
+63
Documentation/i2c/busses/i2c-sis630.rst
··· 1 + ======================== 2 + Kernel driver i2c-sis630 3 + ======================== 4 + 5 + Supported adapters: 6 + * Silicon Integrated Systems Corp (SiS) 7 + 630 chipset (Datasheet: available at http://www.sfr-fresh.com/linux) 8 + 730 chipset 9 + 964 chipset 10 + * Possible other SiS chipsets ? 11 + 12 + Author: 13 + - Alexander Malysh <amalysh@web.de> 14 + - Amaury Decrême <amaury.decreme@gmail.com> - SiS964 support 15 + 16 + Module Parameters 17 + ----------------- 18 + 19 + ================== ===================================================== 20 + force = [1|0] Forcibly enable the SIS630. DANGEROUS! 21 + This can be interesting for chipsets not named 22 + above to check if it works for you chipset, 23 + but DANGEROUS! 24 + 25 + high_clock = [1|0] Forcibly set Host Master Clock to 56KHz (default, 26 + what your BIOS use). DANGEROUS! This should be a bit 27 + faster, but freeze some systems (i.e. my Laptop). 28 + SIS630/730 chip only. 29 + ================== ===================================================== 30 + 31 + 32 + Description 33 + ----------- 34 + 35 + This SMBus only driver is known to work on motherboards with the above 36 + named chipsets. 37 + 38 + If you see something like this:: 39 + 40 + 00:00.0 Host bridge: Silicon Integrated Systems [SiS] 630 Host (rev 31) 41 + 00:01.0 ISA bridge: Silicon Integrated Systems [SiS] 85C503/5513 42 + 43 + or like this:: 44 + 45 + 00:00.0 Host bridge: Silicon Integrated Systems [SiS] 730 Host (rev 02) 46 + 00:01.0 ISA bridge: Silicon Integrated Systems [SiS] 85C503/5513 47 + 48 + or like this:: 49 + 50 + 00:00.0 Host bridge: Silicon Integrated Systems [SiS] 760/M760 Host (rev 02) 51 + 00:02.0 ISA bridge: Silicon Integrated Systems [SiS] SiS964 [MuTIOL Media IO] 52 + LPC Controller (rev 36) 53 + 54 + in your ``lspci`` output , then this driver is for your chipset. 55 + 56 + Thank You 57 + --------- 58 + Philip Edelbrock <phil@netroedge.com> 59 + - testing SiS730 support 60 + Mark M. Hoffman <mhoffman@lightlink.com> 61 + - bug fixes 62 + 63 + To anyone else which I forgot here ;), thanks!
-73
Documentation/i2c/busses/i2c-sis96x
··· 1 - Kernel driver i2c-sis96x 2 - 3 - Replaces 2.4.x i2c-sis645 4 - 5 - Supported adapters: 6 - * Silicon Integrated Systems Corp (SiS) 7 - Any combination of these host bridges: 8 - 645, 645DX (aka 646), 648, 650, 651, 655, 735, 745, 746 9 - and these south bridges: 10 - 961, 962, 963(L) 11 - 12 - Author: Mark M. Hoffman <mhoffman@lightlink.com> 13 - 14 - Description 15 - ----------- 16 - 17 - This SMBus only driver is known to work on motherboards with the above 18 - named chipset combinations. The driver was developed without benefit of a 19 - proper datasheet from SiS. The SMBus registers are assumed compatible with 20 - those of the SiS630, although they are located in a completely different 21 - place. Thanks to Alexander Malysh <amalysh@web.de> for providing the 22 - SiS630 datasheet (and driver). 23 - 24 - The command "lspci" as root should produce something like these lines: 25 - 26 - 00:00.0 Host bridge: Silicon Integrated Systems [SiS]: Unknown device 0645 27 - 00:02.0 ISA bridge: Silicon Integrated Systems [SiS] 85C503/5513 28 - 00:02.1 SMBus: Silicon Integrated Systems [SiS]: Unknown device 0016 29 - 30 - or perhaps this... 31 - 32 - 00:00.0 Host bridge: Silicon Integrated Systems [SiS]: Unknown device 0645 33 - 00:02.0 ISA bridge: Silicon Integrated Systems [SiS]: Unknown device 0961 34 - 00:02.1 SMBus: Silicon Integrated Systems [SiS]: Unknown device 0016 35 - 36 - (kernel versions later than 2.4.18 may fill in the "Unknown"s) 37 - 38 - If you can't see it please look on quirk_sis_96x_smbus 39 - (drivers/pci/quirks.c) (also if southbridge detection fails) 40 - 41 - I suspect that this driver could be made to work for the following SiS 42 - chipsets as well: 635, and 635T. If anyone owns a board with those chips 43 - AND is willing to risk crashing & burning an otherwise well-behaved kernel 44 - in the name of progress... please contact me at <mhoffman@lightlink.com> or 45 - via the linux-i2c mailing list: <linux-i2c@vger.kernel.org>. Please send bug 46 - reports and/or success stories as well. 47 - 48 - 49 - TO DOs 50 - ------ 51 - 52 - * The driver does not support SMBus block reads/writes; I may add them if a 53 - scenario is found where they're needed. 54 - 55 - 56 - Thank You 57 - --------- 58 - 59 - Mark D. Studebaker <mdsxyz123@yahoo.com> 60 - - design hints and bug fixes 61 - Alexander Maylsh <amalysh@web.de> 62 - - ditto, plus an important datasheet... almost the one I really wanted 63 - Hans-Günter Lütke Uphues <hg_lu@t-online.de> 64 - - patch for SiS735 65 - Robert Zwerus <arzie@dds.nl> 66 - - testing for SiS645DX 67 - Kianusch Sayah Karadji <kianusch@sk-tech.net> 68 - - patch for SiS645DX/962 69 - Ken Healy 70 - - patch for SiS655 71 - 72 - To anyone else who has written w/ feedback, thanks! 73 -
+82
Documentation/i2c/busses/i2c-sis96x.rst
··· 1 + ======================== 2 + Kernel driver i2c-sis96x 3 + ======================== 4 + 5 + Replaces 2.4.x i2c-sis645 6 + 7 + Supported adapters: 8 + 9 + * Silicon Integrated Systems Corp (SiS) 10 + 11 + Any combination of these host bridges: 12 + 645, 645DX (aka 646), 648, 650, 651, 655, 735, 745, 746 13 + 14 + and these south bridges: 15 + 961, 962, 963(L) 16 + 17 + Author: Mark M. Hoffman <mhoffman@lightlink.com> 18 + 19 + Description 20 + ----------- 21 + 22 + This SMBus only driver is known to work on motherboards with the above 23 + named chipset combinations. The driver was developed without benefit of a 24 + proper datasheet from SiS. The SMBus registers are assumed compatible with 25 + those of the SiS630, although they are located in a completely different 26 + place. Thanks to Alexander Malysh <amalysh@web.de> for providing the 27 + SiS630 datasheet (and driver). 28 + 29 + The command ``lspci`` as root should produce something like these lines:: 30 + 31 + 00:00.0 Host bridge: Silicon Integrated Systems [SiS]: Unknown device 0645 32 + 00:02.0 ISA bridge: Silicon Integrated Systems [SiS] 85C503/5513 33 + 00:02.1 SMBus: Silicon Integrated Systems [SiS]: Unknown device 0016 34 + 35 + or perhaps this:: 36 + 37 + 00:00.0 Host bridge: Silicon Integrated Systems [SiS]: Unknown device 0645 38 + 00:02.0 ISA bridge: Silicon Integrated Systems [SiS]: Unknown device 0961 39 + 00:02.1 SMBus: Silicon Integrated Systems [SiS]: Unknown device 0016 40 + 41 + (kernel versions later than 2.4.18 may fill in the "Unknown"s) 42 + 43 + If you can't see it please look on quirk_sis_96x_smbus 44 + (drivers/pci/quirks.c) (also if southbridge detection fails) 45 + 46 + I suspect that this driver could be made to work for the following SiS 47 + chipsets as well: 635, and 635T. If anyone owns a board with those chips 48 + AND is willing to risk crashing & burning an otherwise well-behaved kernel 49 + in the name of progress... please contact me at <mhoffman@lightlink.com> or 50 + via the linux-i2c mailing list: <linux-i2c@vger.kernel.org>. Please send bug 51 + reports and/or success stories as well. 52 + 53 + 54 + TO DOs 55 + ------ 56 + 57 + * The driver does not support SMBus block reads/writes; I may add them if a 58 + scenario is found where they're needed. 59 + 60 + 61 + Thank You 62 + --------- 63 + 64 + Mark D. Studebaker <mdsxyz123@yahoo.com> 65 + - design hints and bug fixes 66 + 67 + Alexander Maylsh <amalysh@web.de> 68 + - ditto, plus an important datasheet... almost the one I really wanted 69 + 70 + Hans-Günter Lütke Uphues <hg_lu@t-online.de> 71 + - patch for SiS735 72 + 73 + Robert Zwerus <arzie@dds.nl> 74 + - testing for SiS645DX 75 + 76 + Kianusch Sayah Karadji <kianusch@sk-tech.net> 77 + - patch for SiS645DX/962 78 + 79 + Ken Healy 80 + - patch for SiS655 81 + 82 + To anyone else who has written w/ feedback, thanks!
-46
Documentation/i2c/busses/i2c-taos-evm
··· 1 - Kernel driver i2c-taos-evm 2 - 3 - Author: Jean Delvare <jdelvare@suse.de> 4 - 5 - This is a driver for the evaluation modules for TAOS I2C/SMBus chips. 6 - The modules include an SMBus master with limited capabilities, which can 7 - be controlled over the serial port. Virtually all evaluation modules 8 - are supported, but a few lines of code need to be added for each new 9 - module to instantiate the right I2C chip on the bus. Obviously, a driver 10 - for the chip in question is also needed. 11 - 12 - Currently supported devices are: 13 - 14 - * TAOS TSL2550 EVM 15 - 16 - For additional information on TAOS products, please see 17 - http://www.taosinc.com/ 18 - 19 - 20 - Using this driver 21 - ----------------- 22 - 23 - In order to use this driver, you'll need the serport driver, and the 24 - inputattach tool, which is part of the input-utils package. The following 25 - commands will tell the kernel that you have a TAOS EVM on the first 26 - serial port: 27 - 28 - # modprobe serport 29 - # inputattach --taos-evm /dev/ttyS0 30 - 31 - 32 - Technical details 33 - ----------------- 34 - 35 - Only 4 SMBus transaction types are supported by the TAOS evaluation 36 - modules: 37 - * Receive Byte 38 - * Send Byte 39 - * Read Byte 40 - * Write Byte 41 - 42 - The communication protocol is text-based and pretty simple. It is 43 - described in a PDF document on the CD which comes with the evaluation 44 - module. The communication is rather slow, because the serial port has 45 - to operate at 1200 bps. However, I don't think this is a big concern in 46 - practice, as these modules are meant for evaluation and testing only.
+48
Documentation/i2c/busses/i2c-taos-evm.rst
··· 1 + ========================== 2 + Kernel driver i2c-taos-evm 3 + ========================== 4 + 5 + Author: Jean Delvare <jdelvare@suse.de> 6 + 7 + This is a driver for the evaluation modules for TAOS I2C/SMBus chips. 8 + The modules include an SMBus master with limited capabilities, which can 9 + be controlled over the serial port. Virtually all evaluation modules 10 + are supported, but a few lines of code need to be added for each new 11 + module to instantiate the right I2C chip on the bus. Obviously, a driver 12 + for the chip in question is also needed. 13 + 14 + Currently supported devices are: 15 + 16 + * TAOS TSL2550 EVM 17 + 18 + For additional information on TAOS products, please see 19 + http://www.taosinc.com/ 20 + 21 + 22 + Using this driver 23 + ----------------- 24 + 25 + In order to use this driver, you'll need the serport driver, and the 26 + inputattach tool, which is part of the input-utils package. The following 27 + commands will tell the kernel that you have a TAOS EVM on the first 28 + serial port:: 29 + 30 + # modprobe serport 31 + # inputattach --taos-evm /dev/ttyS0 32 + 33 + 34 + Technical details 35 + ----------------- 36 + 37 + Only 4 SMBus transaction types are supported by the TAOS evaluation 38 + modules: 39 + * Receive Byte 40 + * Send Byte 41 + * Read Byte 42 + * Write Byte 43 + 44 + The communication protocol is text-based and pretty simple. It is 45 + described in a PDF document on the CD which comes with the evaluation 46 + module. The communication is rather slow, because the serial port has 47 + to operate at 1200 bps. However, I don't think this is a big concern in 48 + practice, as these modules are meant for evaluation and testing only.
-34
Documentation/i2c/busses/i2c-via
··· 1 - Kernel driver i2c-via 2 - 3 - Supported adapters: 4 - * VIA Technologies, InC. VT82C586B 5 - Datasheet: Publicly available at the VIA website 6 - 7 - Author: Kyösti Mälkki <kmalkki@cc.hut.fi> 8 - 9 - Description 10 - ----------- 11 - 12 - i2c-via is an i2c bus driver for motherboards with VIA chipset. 13 - 14 - The following VIA pci chipsets are supported: 15 - - MVP3, VP3, VP2/97, VPX/97 16 - - others with South bridge VT82C586B 17 - 18 - Your lspci listing must show this : 19 - 20 - Bridge: VIA Technologies, Inc. VT82C586B ACPI (rev 10) 21 - 22 - Problems? 23 - 24 - Q: You have VT82C586B on the motherboard, but not in the listing. 25 - 26 - A: Go to your BIOS setup, section PCI devices or similar. 27 - Turn USB support on, and try again. 28 - 29 - Q: No error messages, but still i2c doesn't seem to work. 30 - 31 - A: This can happen. This driver uses the pins VIA recommends in their 32 - datasheets, but there are several ways the motherboard manufacturer 33 - can actually wire the lines. 34 -
+40
Documentation/i2c/busses/i2c-via.rst
··· 1 + ===================== 2 + Kernel driver i2c-via 3 + ===================== 4 + 5 + Supported adapters: 6 + * VIA Technologies, InC. VT82C586B 7 + Datasheet: Publicly available at the VIA website 8 + 9 + Author: Kyösti Mälkki <kmalkki@cc.hut.fi> 10 + 11 + Description 12 + ----------- 13 + 14 + i2c-via is an i2c bus driver for motherboards with VIA chipset. 15 + 16 + The following VIA pci chipsets are supported: 17 + - MVP3, VP3, VP2/97, VPX/97 18 + - others with South bridge VT82C586B 19 + 20 + Your ``lspci`` listing must show this :: 21 + 22 + Bridge: VIA Technologies, Inc. VT82C586B ACPI (rev 10) 23 + 24 + Problems? 25 + --------- 26 + 27 + Q: 28 + You have VT82C586B on the motherboard, but not in the listing. 29 + 30 + A: 31 + Go to your BIOS setup, section PCI devices or similar. 32 + Turn USB support on, and try again. 33 + 34 + Q: 35 + No error messages, but still i2c doesn't seem to work. 36 + 37 + A: 38 + This can happen. This driver uses the pins VIA recommends in their 39 + datasheets, but there are several ways the motherboard manufacturer 40 + can actually wire the lines.
-73
Documentation/i2c/busses/i2c-viapro
··· 1 - Kernel driver i2c-viapro 2 - 3 - Supported adapters: 4 - * VIA Technologies, Inc. VT82C596A/B 5 - Datasheet: Sometimes available at the VIA website 6 - 7 - * VIA Technologies, Inc. VT82C686A/B 8 - Datasheet: Sometimes available at the VIA website 9 - 10 - * VIA Technologies, Inc. VT8231, VT8233, VT8233A 11 - Datasheet: available on request from VIA 12 - 13 - * VIA Technologies, Inc. VT8235, VT8237R, VT8237A, VT8237S, VT8251 14 - Datasheet: available on request and under NDA from VIA 15 - 16 - * VIA Technologies, Inc. CX700 17 - Datasheet: available on request and under NDA from VIA 18 - 19 - * VIA Technologies, Inc. VX800/VX820 20 - Datasheet: available on http://linux.via.com.tw 21 - 22 - * VIA Technologies, Inc. VX855/VX875 23 - Datasheet: available on http://linux.via.com.tw 24 - 25 - * VIA Technologies, Inc. VX900 26 - Datasheet: available on http://linux.via.com.tw 27 - 28 - Authors: 29 - Kyösti Mälkki <kmalkki@cc.hut.fi>, 30 - Mark D. Studebaker <mdsxyz123@yahoo.com>, 31 - Jean Delvare <jdelvare@suse.de> 32 - 33 - Module Parameters 34 - ----------------- 35 - 36 - * force: int 37 - Forcibly enable the SMBus controller. DANGEROUS! 38 - * force_addr: int 39 - Forcibly enable the SMBus at the given address. EXTREMELY DANGEROUS! 40 - 41 - Description 42 - ----------- 43 - 44 - i2c-viapro is a true SMBus host driver for motherboards with one of the 45 - supported VIA south bridges. 46 - 47 - Your lspci -n listing must show one of these : 48 - 49 - device 1106:3050 (VT82C596A function 3) 50 - device 1106:3051 (VT82C596B function 3) 51 - device 1106:3057 (VT82C686 function 4) 52 - device 1106:3074 (VT8233) 53 - device 1106:3147 (VT8233A) 54 - device 1106:8235 (VT8231 function 4) 55 - device 1106:3177 (VT8235) 56 - device 1106:3227 (VT8237R) 57 - device 1106:3337 (VT8237A) 58 - device 1106:3372 (VT8237S) 59 - device 1106:3287 (VT8251) 60 - device 1106:8324 (CX700) 61 - device 1106:8353 (VX800/VX820) 62 - device 1106:8409 (VX855/VX875) 63 - device 1106:8410 (VX900) 64 - 65 - If none of these show up, you should look in the BIOS for settings like 66 - enable ACPI / SMBus or even USB. 67 - 68 - Except for the oldest chips (VT82C596A/B, VT82C686A and most probably 69 - VT8231), this driver supports I2C block transactions. Such transactions 70 - are mainly useful to read from and write to EEPROMs. 71 - 72 - The CX700/VX800/VX820 additionally appears to support SMBus PEC, although 73 - this driver doesn't implement it yet.
+77
Documentation/i2c/busses/i2c-viapro.rst
··· 1 + ======================== 2 + Kernel driver i2c-viapro 3 + ======================== 4 + 5 + Supported adapters: 6 + * VIA Technologies, Inc. VT82C596A/B 7 + Datasheet: Sometimes available at the VIA website 8 + 9 + * VIA Technologies, Inc. VT82C686A/B 10 + Datasheet: Sometimes available at the VIA website 11 + 12 + * VIA Technologies, Inc. VT8231, VT8233, VT8233A 13 + Datasheet: available on request from VIA 14 + 15 + * VIA Technologies, Inc. VT8235, VT8237R, VT8237A, VT8237S, VT8251 16 + Datasheet: available on request and under NDA from VIA 17 + 18 + * VIA Technologies, Inc. CX700 19 + Datasheet: available on request and under NDA from VIA 20 + 21 + * VIA Technologies, Inc. VX800/VX820 22 + Datasheet: available on http://linux.via.com.tw 23 + 24 + * VIA Technologies, Inc. VX855/VX875 25 + Datasheet: available on http://linux.via.com.tw 26 + 27 + * VIA Technologies, Inc. VX900 28 + Datasheet: available on http://linux.via.com.tw 29 + 30 + Authors: 31 + - Kyösti Mälkki <kmalkki@cc.hut.fi>, 32 + - Mark D. Studebaker <mdsxyz123@yahoo.com>, 33 + - Jean Delvare <jdelvare@suse.de> 34 + 35 + Module Parameters 36 + ----------------- 37 + 38 + * force: int 39 + Forcibly enable the SMBus controller. DANGEROUS! 40 + * force_addr: int 41 + Forcibly enable the SMBus at the given address. EXTREMELY DANGEROUS! 42 + 43 + Description 44 + ----------- 45 + 46 + i2c-viapro is a true SMBus host driver for motherboards with one of the 47 + supported VIA south bridges. 48 + 49 + Your ``lspci -n`` listing must show one of these : 50 + 51 + ================ ====================== 52 + device 1106:3050 (VT82C596A function 3) 53 + device 1106:3051 (VT82C596B function 3) 54 + device 1106:3057 (VT82C686 function 4) 55 + device 1106:3074 (VT8233) 56 + device 1106:3147 (VT8233A) 57 + device 1106:8235 (VT8231 function 4) 58 + device 1106:3177 (VT8235) 59 + device 1106:3227 (VT8237R) 60 + device 1106:3337 (VT8237A) 61 + device 1106:3372 (VT8237S) 62 + device 1106:3287 (VT8251) 63 + device 1106:8324 (CX700) 64 + device 1106:8353 (VX800/VX820) 65 + device 1106:8409 (VX855/VX875) 66 + device 1106:8410 (VX900) 67 + ================ ====================== 68 + 69 + If none of these show up, you should look in the BIOS for settings like 70 + enable ACPI / SMBus or even USB. 71 + 72 + Except for the oldest chips (VT82C596A/B, VT82C686A and most probably 73 + VT8231), this driver supports I2C block transactions. Such transactions 74 + are mainly useful to read from and write to EEPROMs. 75 + 76 + The CX700/VX800/VX820 additionally appears to support SMBus PEC, although 77 + this driver doesn't implement it yet.
+33
Documentation/i2c/busses/index.rst
··· 1 + . SPDX-License-Identifier: GPL-2.0 2 + 3 + =============== 4 + I2C Bus Drivers 5 + =============== 6 + 7 + .. toctree:: 8 + :maxdepth: 1 9 + 10 + i2c-ali1535 11 + i2c-ali1563 12 + i2c-ali15x3 13 + i2c-amd756 14 + i2c-amd8111 15 + i2c-amd-mp2 16 + i2c-diolan-u2c 17 + i2c-i801 18 + i2c-ismt 19 + i2c-mlxcpld 20 + i2c-nforce2 21 + i2c-nvidia-gpu 22 + i2c-ocores 23 + i2c-parport-light 24 + i2c-parport 25 + i2c-pca-isa 26 + i2c-piix4 27 + i2c-sis5595 28 + i2c-sis630 29 + i2c-sis96x 30 + i2c-taos-evm 31 + i2c-viapro 32 + i2c-via 33 + scx200_acb
-32
Documentation/i2c/busses/scx200_acb
··· 1 - Kernel driver scx200_acb 2 - 3 - Author: Christer Weinigel <wingel@nano-system.com> 4 - 5 - The driver supersedes the older, never merged driver named i2c-nscacb. 6 - 7 - Module Parameters 8 - ----------------- 9 - 10 - * base: up to 4 ints 11 - Base addresses for the ACCESS.bus controllers on SCx200 and SC1100 devices 12 - 13 - By default the driver uses two base addresses 0x820 and 0x840. 14 - If you want only one base address, specify the second as 0 so as to 15 - override this default. 16 - 17 - Description 18 - ----------- 19 - 20 - Enable the use of the ACCESS.bus controller on the Geode SCx200 and 21 - SC1100 processors and the CS5535 and CS5536 Geode companion devices. 22 - 23 - Device-specific notes 24 - --------------------- 25 - 26 - The SC1100 WRAP boards are known to use base addresses 0x810 and 0x820. 27 - If the scx200_acb driver is built into the kernel, add the following 28 - parameter to your boot command line: 29 - scx200_acb.base=0x810,0x820 30 - If the scx200_acb driver is built as a module, add the following line to 31 - a configuration file in /etc/modprobe.d/ instead: 32 - options scx200_acb base=0x810,0x820
+37
Documentation/i2c/busses/scx200_acb.rst
··· 1 + ======================== 2 + Kernel driver scx200_acb 3 + ======================== 4 + 5 + Author: Christer Weinigel <wingel@nano-system.com> 6 + 7 + The driver supersedes the older, never merged driver named i2c-nscacb. 8 + 9 + Module Parameters 10 + ----------------- 11 + 12 + * base: up to 4 ints 13 + Base addresses for the ACCESS.bus controllers on SCx200 and SC1100 devices 14 + 15 + By default the driver uses two base addresses 0x820 and 0x840. 16 + If you want only one base address, specify the second as 0 so as to 17 + override this default. 18 + 19 + Description 20 + ----------- 21 + 22 + Enable the use of the ACCESS.bus controller on the Geode SCx200 and 23 + SC1100 processors and the CS5535 and CS5536 Geode companion devices. 24 + 25 + Device-specific notes 26 + --------------------- 27 + 28 + The SC1100 WRAP boards are known to use base addresses 0x810 and 0x820. 29 + If the scx200_acb driver is built into the kernel, add the following 30 + parameter to your boot command line:: 31 + 32 + scx200_acb.base=0x810,0x820 33 + 34 + If the scx200_acb driver is built as a module, add the following line to 35 + a configuration file in /etc/modprobe.d/ instead:: 36 + 37 + options scx200_acb base=0x810,0x820
-213
Documentation/i2c/dev-interface
··· 1 - Usually, i2c devices are controlled by a kernel driver. But it is also 2 - possible to access all devices on an adapter from userspace, through 3 - the /dev interface. You need to load module i2c-dev for this. 4 - 5 - Each registered i2c adapter gets a number, counting from 0. You can 6 - examine /sys/class/i2c-dev/ to see what number corresponds to which adapter. 7 - Alternatively, you can run "i2cdetect -l" to obtain a formatted list of all 8 - i2c adapters present on your system at a given time. i2cdetect is part of 9 - the i2c-tools package. 10 - 11 - I2C device files are character device files with major device number 89 12 - and a minor device number corresponding to the number assigned as 13 - explained above. They should be called "i2c-%d" (i2c-0, i2c-1, ..., 14 - i2c-10, ...). All 256 minor device numbers are reserved for i2c. 15 - 16 - 17 - C example 18 - ========= 19 - 20 - So let's say you want to access an i2c adapter from a C program. 21 - First, you need to include these two headers: 22 - 23 - #include <linux/i2c-dev.h> 24 - #include <i2c/smbus.h> 25 - 26 - Now, you have to decide which adapter you want to access. You should 27 - inspect /sys/class/i2c-dev/ or run "i2cdetect -l" to decide this. 28 - Adapter numbers are assigned somewhat dynamically, so you can not 29 - assume much about them. They can even change from one boot to the next. 30 - 31 - Next thing, open the device file, as follows: 32 - 33 - int file; 34 - int adapter_nr = 2; /* probably dynamically determined */ 35 - char filename[20]; 36 - 37 - snprintf(filename, 19, "/dev/i2c-%d", adapter_nr); 38 - file = open(filename, O_RDWR); 39 - if (file < 0) { 40 - /* ERROR HANDLING; you can check errno to see what went wrong */ 41 - exit(1); 42 - } 43 - 44 - When you have opened the device, you must specify with what device 45 - address you want to communicate: 46 - 47 - int addr = 0x40; /* The I2C address */ 48 - 49 - if (ioctl(file, I2C_SLAVE, addr) < 0) { 50 - /* ERROR HANDLING; you can check errno to see what went wrong */ 51 - exit(1); 52 - } 53 - 54 - Well, you are all set up now. You can now use SMBus commands or plain 55 - I2C to communicate with your device. SMBus commands are preferred if 56 - the device supports them. Both are illustrated below. 57 - 58 - __u8 reg = 0x10; /* Device register to access */ 59 - __s32 res; 60 - char buf[10]; 61 - 62 - /* Using SMBus commands */ 63 - res = i2c_smbus_read_word_data(file, reg); 64 - if (res < 0) { 65 - /* ERROR HANDLING: i2c transaction failed */ 66 - } else { 67 - /* res contains the read word */ 68 - } 69 - 70 - /* 71 - * Using I2C Write, equivalent of 72 - * i2c_smbus_write_word_data(file, reg, 0x6543) 73 - */ 74 - buf[0] = reg; 75 - buf[1] = 0x43; 76 - buf[2] = 0x65; 77 - if (write(file, buf, 3) != 3) { 78 - /* ERROR HANDLING: i2c transaction failed */ 79 - } 80 - 81 - /* Using I2C Read, equivalent of i2c_smbus_read_byte(file) */ 82 - if (read(file, buf, 1) != 1) { 83 - /* ERROR HANDLING: i2c transaction failed */ 84 - } else { 85 - /* buf[0] contains the read byte */ 86 - } 87 - 88 - Note that only a subset of the I2C and SMBus protocols can be achieved by 89 - the means of read() and write() calls. In particular, so-called combined 90 - transactions (mixing read and write messages in the same transaction) 91 - aren't supported. For this reason, this interface is almost never used by 92 - user-space programs. 93 - 94 - IMPORTANT: because of the use of inline functions, you *have* to use 95 - '-O' or some variation when you compile your program! 96 - 97 - 98 - Full interface description 99 - ========================== 100 - 101 - The following IOCTLs are defined: 102 - 103 - ioctl(file, I2C_SLAVE, long addr) 104 - Change slave address. The address is passed in the 7 lower bits of the 105 - argument (except for 10 bit addresses, passed in the 10 lower bits in this 106 - case). 107 - 108 - ioctl(file, I2C_TENBIT, long select) 109 - Selects ten bit addresses if select not equals 0, selects normal 7 bit 110 - addresses if select equals 0. Default 0. This request is only valid 111 - if the adapter has I2C_FUNC_10BIT_ADDR. 112 - 113 - ioctl(file, I2C_PEC, long select) 114 - Selects SMBus PEC (packet error checking) generation and verification 115 - if select not equals 0, disables if select equals 0. Default 0. 116 - Used only for SMBus transactions. This request only has an effect if the 117 - the adapter has I2C_FUNC_SMBUS_PEC; it is still safe if not, it just 118 - doesn't have any effect. 119 - 120 - ioctl(file, I2C_FUNCS, unsigned long *funcs) 121 - Gets the adapter functionality and puts it in *funcs. 122 - 123 - ioctl(file, I2C_RDWR, struct i2c_rdwr_ioctl_data *msgset) 124 - Do combined read/write transaction without stop in between. 125 - Only valid if the adapter has I2C_FUNC_I2C. The argument is 126 - a pointer to a 127 - 128 - struct i2c_rdwr_ioctl_data { 129 - struct i2c_msg *msgs; /* ptr to array of simple messages */ 130 - int nmsgs; /* number of messages to exchange */ 131 - } 132 - 133 - The msgs[] themselves contain further pointers into data buffers. 134 - The function will write or read data to or from that buffers depending 135 - on whether the I2C_M_RD flag is set in a particular message or not. 136 - The slave address and whether to use ten bit address mode has to be 137 - set in each message, overriding the values set with the above ioctl's. 138 - 139 - ioctl(file, I2C_SMBUS, struct i2c_smbus_ioctl_data *args) 140 - If possible, use the provided i2c_smbus_* methods described below instead 141 - of issuing direct ioctls. 142 - 143 - You can do plain i2c transactions by using read(2) and write(2) calls. 144 - You do not need to pass the address byte; instead, set it through 145 - ioctl I2C_SLAVE before you try to access the device. 146 - 147 - You can do SMBus level transactions (see documentation file smbus-protocol 148 - for details) through the following functions: 149 - __s32 i2c_smbus_write_quick(int file, __u8 value); 150 - __s32 i2c_smbus_read_byte(int file); 151 - __s32 i2c_smbus_write_byte(int file, __u8 value); 152 - __s32 i2c_smbus_read_byte_data(int file, __u8 command); 153 - __s32 i2c_smbus_write_byte_data(int file, __u8 command, __u8 value); 154 - __s32 i2c_smbus_read_word_data(int file, __u8 command); 155 - __s32 i2c_smbus_write_word_data(int file, __u8 command, __u16 value); 156 - __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value); 157 - __s32 i2c_smbus_read_block_data(int file, __u8 command, __u8 *values); 158 - __s32 i2c_smbus_write_block_data(int file, __u8 command, __u8 length, 159 - __u8 *values); 160 - All these transactions return -1 on failure; you can read errno to see 161 - what happened. The 'write' transactions return 0 on success; the 162 - 'read' transactions return the read value, except for read_block, which 163 - returns the number of values read. The block buffers need not be longer 164 - than 32 bytes. 165 - 166 - The above functions are made available by linking against the libi2c library, 167 - which is provided by the i2c-tools project. See: 168 - https://git.kernel.org/pub/scm/utils/i2c-tools/i2c-tools.git/. 169 - 170 - 171 - Implementation details 172 - ====================== 173 - 174 - For the interested, here's the code flow which happens inside the kernel 175 - when you use the /dev interface to I2C: 176 - 177 - 1* Your program opens /dev/i2c-N and calls ioctl() on it, as described in 178 - section "C example" above. 179 - 180 - 2* These open() and ioctl() calls are handled by the i2c-dev kernel 181 - driver: see i2c-dev.c:i2cdev_open() and i2c-dev.c:i2cdev_ioctl(), 182 - respectively. You can think of i2c-dev as a generic I2C chip driver 183 - that can be programmed from user-space. 184 - 185 - 3* Some ioctl() calls are for administrative tasks and are handled by 186 - i2c-dev directly. Examples include I2C_SLAVE (set the address of the 187 - device you want to access) and I2C_PEC (enable or disable SMBus error 188 - checking on future transactions.) 189 - 190 - 4* Other ioctl() calls are converted to in-kernel function calls by 191 - i2c-dev. Examples include I2C_FUNCS, which queries the I2C adapter 192 - functionality using i2c.h:i2c_get_functionality(), and I2C_SMBUS, which 193 - performs an SMBus transaction using i2c-core-smbus.c:i2c_smbus_xfer(). 194 - 195 - The i2c-dev driver is responsible for checking all the parameters that 196 - come from user-space for validity. After this point, there is no 197 - difference between these calls that came from user-space through i2c-dev 198 - and calls that would have been performed by kernel I2C chip drivers 199 - directly. This means that I2C bus drivers don't need to implement 200 - anything special to support access from user-space. 201 - 202 - 5* These i2c.h functions are wrappers to the actual implementation of 203 - your I2C bus driver. Each adapter must declare callback functions 204 - implementing these standard calls. i2c.h:i2c_get_functionality() calls 205 - i2c_adapter.algo->functionality(), while 206 - i2c-core-smbus.c:i2c_smbus_xfer() calls either 207 - adapter.algo->smbus_xfer() if it is implemented, or if not, 208 - i2c-core-smbus.c:i2c_smbus_xfer_emulated() which in turn calls 209 - i2c_adapter.algo->master_xfer(). 210 - 211 - After your I2C bus driver has processed these requests, execution runs 212 - up the call chain, with almost no processing done, except by i2c-dev to 213 - package the returned data, if any, in suitable format for the ioctl.
+219
Documentation/i2c/dev-interface.rst
··· 1 + ==================== 2 + I2C Device Interface 3 + ==================== 4 + 5 + Usually, i2c devices are controlled by a kernel driver. But it is also 6 + possible to access all devices on an adapter from userspace, through 7 + the /dev interface. You need to load module i2c-dev for this. 8 + 9 + Each registered i2c adapter gets a number, counting from 0. You can 10 + examine /sys/class/i2c-dev/ to see what number corresponds to which adapter. 11 + Alternatively, you can run "i2cdetect -l" to obtain a formatted list of all 12 + i2c adapters present on your system at a given time. i2cdetect is part of 13 + the i2c-tools package. 14 + 15 + I2C device files are character device files with major device number 89 16 + and a minor device number corresponding to the number assigned as 17 + explained above. They should be called "i2c-%d" (i2c-0, i2c-1, ..., 18 + i2c-10, ...). All 256 minor device numbers are reserved for i2c. 19 + 20 + 21 + C example 22 + ========= 23 + 24 + So let's say you want to access an i2c adapter from a C program. 25 + First, you need to include these two headers:: 26 + 27 + #include <linux/i2c-dev.h> 28 + #include <i2c/smbus.h> 29 + 30 + Now, you have to decide which adapter you want to access. You should 31 + inspect /sys/class/i2c-dev/ or run "i2cdetect -l" to decide this. 32 + Adapter numbers are assigned somewhat dynamically, so you can not 33 + assume much about them. They can even change from one boot to the next. 34 + 35 + Next thing, open the device file, as follows:: 36 + 37 + int file; 38 + int adapter_nr = 2; /* probably dynamically determined */ 39 + char filename[20]; 40 + 41 + snprintf(filename, 19, "/dev/i2c-%d", adapter_nr); 42 + file = open(filename, O_RDWR); 43 + if (file < 0) { 44 + /* ERROR HANDLING; you can check errno to see what went wrong */ 45 + exit(1); 46 + } 47 + 48 + When you have opened the device, you must specify with what device 49 + address you want to communicate:: 50 + 51 + int addr = 0x40; /* The I2C address */ 52 + 53 + if (ioctl(file, I2C_SLAVE, addr) < 0) { 54 + /* ERROR HANDLING; you can check errno to see what went wrong */ 55 + exit(1); 56 + } 57 + 58 + Well, you are all set up now. You can now use SMBus commands or plain 59 + I2C to communicate with your device. SMBus commands are preferred if 60 + the device supports them. Both are illustrated below:: 61 + 62 + __u8 reg = 0x10; /* Device register to access */ 63 + __s32 res; 64 + char buf[10]; 65 + 66 + /* Using SMBus commands */ 67 + res = i2c_smbus_read_word_data(file, reg); 68 + if (res < 0) { 69 + /* ERROR HANDLING: i2c transaction failed */ 70 + } else { 71 + /* res contains the read word */ 72 + } 73 + 74 + /* 75 + * Using I2C Write, equivalent of 76 + * i2c_smbus_write_word_data(file, reg, 0x6543) 77 + */ 78 + buf[0] = reg; 79 + buf[1] = 0x43; 80 + buf[2] = 0x65; 81 + if (write(file, buf, 3) != 3) { 82 + /* ERROR HANDLING: i2c transaction failed */ 83 + } 84 + 85 + /* Using I2C Read, equivalent of i2c_smbus_read_byte(file) */ 86 + if (read(file, buf, 1) != 1) { 87 + /* ERROR HANDLING: i2c transaction failed */ 88 + } else { 89 + /* buf[0] contains the read byte */ 90 + } 91 + 92 + Note that only a subset of the I2C and SMBus protocols can be achieved by 93 + the means of read() and write() calls. In particular, so-called combined 94 + transactions (mixing read and write messages in the same transaction) 95 + aren't supported. For this reason, this interface is almost never used by 96 + user-space programs. 97 + 98 + IMPORTANT: because of the use of inline functions, you *have* to use 99 + '-O' or some variation when you compile your program! 100 + 101 + 102 + Full interface description 103 + ========================== 104 + 105 + The following IOCTLs are defined: 106 + 107 + ``ioctl(file, I2C_SLAVE, long addr)`` 108 + Change slave address. The address is passed in the 7 lower bits of the 109 + argument (except for 10 bit addresses, passed in the 10 lower bits in this 110 + case). 111 + 112 + ``ioctl(file, I2C_TENBIT, long select)`` 113 + Selects ten bit addresses if select not equals 0, selects normal 7 bit 114 + addresses if select equals 0. Default 0. This request is only valid 115 + if the adapter has I2C_FUNC_10BIT_ADDR. 116 + 117 + ``ioctl(file, I2C_PEC, long select)`` 118 + Selects SMBus PEC (packet error checking) generation and verification 119 + if select not equals 0, disables if select equals 0. Default 0. 120 + Used only for SMBus transactions. This request only has an effect if the 121 + the adapter has I2C_FUNC_SMBUS_PEC; it is still safe if not, it just 122 + doesn't have any effect. 123 + 124 + ``ioctl(file, I2C_FUNCS, unsigned long *funcs)`` 125 + Gets the adapter functionality and puts it in ``*funcs``. 126 + 127 + ``ioctl(file, I2C_RDWR, struct i2c_rdwr_ioctl_data *msgset)`` 128 + Do combined read/write transaction without stop in between. 129 + Only valid if the adapter has I2C_FUNC_I2C. The argument is 130 + a pointer to a:: 131 + 132 + struct i2c_rdwr_ioctl_data { 133 + struct i2c_msg *msgs; /* ptr to array of simple messages */ 134 + int nmsgs; /* number of messages to exchange */ 135 + } 136 + 137 + The msgs[] themselves contain further pointers into data buffers. 138 + The function will write or read data to or from that buffers depending 139 + on whether the I2C_M_RD flag is set in a particular message or not. 140 + The slave address and whether to use ten bit address mode has to be 141 + set in each message, overriding the values set with the above ioctl's. 142 + 143 + ``ioctl(file, I2C_SMBUS, struct i2c_smbus_ioctl_data *args)`` 144 + If possible, use the provided ``i2c_smbus_*`` methods described below instead 145 + of issuing direct ioctls. 146 + 147 + You can do plain i2c transactions by using read(2) and write(2) calls. 148 + You do not need to pass the address byte; instead, set it through 149 + ioctl I2C_SLAVE before you try to access the device. 150 + 151 + You can do SMBus level transactions (see documentation file smbus-protocol 152 + for details) through the following functions:: 153 + 154 + __s32 i2c_smbus_write_quick(int file, __u8 value); 155 + __s32 i2c_smbus_read_byte(int file); 156 + __s32 i2c_smbus_write_byte(int file, __u8 value); 157 + __s32 i2c_smbus_read_byte_data(int file, __u8 command); 158 + __s32 i2c_smbus_write_byte_data(int file, __u8 command, __u8 value); 159 + __s32 i2c_smbus_read_word_data(int file, __u8 command); 160 + __s32 i2c_smbus_write_word_data(int file, __u8 command, __u16 value); 161 + __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value); 162 + __s32 i2c_smbus_read_block_data(int file, __u8 command, __u8 *values); 163 + __s32 i2c_smbus_write_block_data(int file, __u8 command, __u8 length, 164 + __u8 *values); 165 + 166 + All these transactions return -1 on failure; you can read errno to see 167 + what happened. The 'write' transactions return 0 on success; the 168 + 'read' transactions return the read value, except for read_block, which 169 + returns the number of values read. The block buffers need not be longer 170 + than 32 bytes. 171 + 172 + The above functions are made available by linking against the libi2c library, 173 + which is provided by the i2c-tools project. See: 174 + https://git.kernel.org/pub/scm/utils/i2c-tools/i2c-tools.git/. 175 + 176 + 177 + Implementation details 178 + ====================== 179 + 180 + For the interested, here's the code flow which happens inside the kernel 181 + when you use the /dev interface to I2C: 182 + 183 + 1) Your program opens /dev/i2c-N and calls ioctl() on it, as described in 184 + section "C example" above. 185 + 186 + 2) These open() and ioctl() calls are handled by the i2c-dev kernel 187 + driver: see i2c-dev.c:i2cdev_open() and i2c-dev.c:i2cdev_ioctl(), 188 + respectively. You can think of i2c-dev as a generic I2C chip driver 189 + that can be programmed from user-space. 190 + 191 + 3) Some ioctl() calls are for administrative tasks and are handled by 192 + i2c-dev directly. Examples include I2C_SLAVE (set the address of the 193 + device you want to access) and I2C_PEC (enable or disable SMBus error 194 + checking on future transactions.) 195 + 196 + 4) Other ioctl() calls are converted to in-kernel function calls by 197 + i2c-dev. Examples include I2C_FUNCS, which queries the I2C adapter 198 + functionality using i2c.h:i2c_get_functionality(), and I2C_SMBUS, which 199 + performs an SMBus transaction using i2c-core-smbus.c:i2c_smbus_xfer(). 200 + 201 + The i2c-dev driver is responsible for checking all the parameters that 202 + come from user-space for validity. After this point, there is no 203 + difference between these calls that came from user-space through i2c-dev 204 + and calls that would have been performed by kernel I2C chip drivers 205 + directly. This means that I2C bus drivers don't need to implement 206 + anything special to support access from user-space. 207 + 208 + 5) These i2c.h functions are wrappers to the actual implementation of 209 + your I2C bus driver. Each adapter must declare callback functions 210 + implementing these standard calls. i2c.h:i2c_get_functionality() calls 211 + i2c_adapter.algo->functionality(), while 212 + i2c-core-smbus.c:i2c_smbus_xfer() calls either 213 + adapter.algo->smbus_xfer() if it is implemented, or if not, 214 + i2c-core-smbus.c:i2c_smbus_xfer_emulated() which in turn calls 215 + i2c_adapter.algo->master_xfer(). 216 + 217 + After your I2C bus driver has processed these requests, execution runs 218 + up the call chain, with almost no processing done, except by i2c-dev to 219 + package the returned data, if any, in suitable format for the ioctl.
-128
Documentation/i2c/fault-codes
··· 1 - This is a summary of the most important conventions for use of fault 2 - codes in the I2C/SMBus stack. 3 - 4 - 5 - A "Fault" is not always an "Error" 6 - ---------------------------------- 7 - Not all fault reports imply errors; "page faults" should be a familiar 8 - example. Software often retries idempotent operations after transient 9 - faults. There may be fancier recovery schemes that are appropriate in 10 - some cases, such as re-initializing (and maybe resetting). After such 11 - recovery, triggered by a fault report, there is no error. 12 - 13 - In a similar way, sometimes a "fault" code just reports one defined 14 - result for an operation ... it doesn't indicate that anything is wrong 15 - at all, just that the outcome wasn't on the "golden path". 16 - 17 - In short, your I2C driver code may need to know these codes in order 18 - to respond correctly. Other code may need to rely on YOUR code reporting 19 - the right fault code, so that it can (in turn) behave correctly. 20 - 21 - 22 - I2C and SMBus fault codes 23 - ------------------------- 24 - These are returned as negative numbers from most calls, with zero or 25 - some positive number indicating a non-fault return. The specific 26 - numbers associated with these symbols differ between architectures, 27 - though most Linux systems use <asm-generic/errno*.h> numbering. 28 - 29 - Note that the descriptions here are not exhaustive. There are other 30 - codes that may be returned, and other cases where these codes should 31 - be returned. However, drivers should not return other codes for these 32 - cases (unless the hardware doesn't provide unique fault reports). 33 - 34 - Also, codes returned by adapter probe methods follow rules which are 35 - specific to their host bus (such as PCI, or the platform bus). 36 - 37 - 38 - EAGAIN 39 - Returned by I2C adapters when they lose arbitration in master 40 - transmit mode: some other master was transmitting different 41 - data at the same time. 42 - 43 - Also returned when trying to invoke an I2C operation in an 44 - atomic context, when some task is already using that I2C bus 45 - to execute some other operation. 46 - 47 - EBADMSG 48 - Returned by SMBus logic when an invalid Packet Error Code byte 49 - is received. This code is a CRC covering all bytes in the 50 - transaction, and is sent before the terminating STOP. This 51 - fault is only reported on read transactions; the SMBus slave 52 - may have a way to report PEC mismatches on writes from the 53 - host. Note that even if PECs are in use, you should not rely 54 - on these as the only way to detect incorrect data transfers. 55 - 56 - EBUSY 57 - Returned by SMBus adapters when the bus was busy for longer 58 - than allowed. This usually indicates some device (maybe the 59 - SMBus adapter) needs some fault recovery (such as resetting), 60 - or that the reset was attempted but failed. 61 - 62 - EINVAL 63 - This rather vague error means an invalid parameter has been 64 - detected before any I/O operation was started. Use a more 65 - specific fault code when you can. 66 - 67 - EIO 68 - This rather vague error means something went wrong when 69 - performing an I/O operation. Use a more specific fault 70 - code when you can. 71 - 72 - ENODEV 73 - Returned by driver probe() methods. This is a bit more 74 - specific than ENXIO, implying the problem isn't with the 75 - address, but with the device found there. Driver probes 76 - may verify the device returns *correct* responses, and 77 - return this as appropriate. (The driver core will warn 78 - about probe faults other than ENXIO and ENODEV.) 79 - 80 - ENOMEM 81 - Returned by any component that can't allocate memory when 82 - it needs to do so. 83 - 84 - ENXIO 85 - Returned by I2C adapters to indicate that the address phase 86 - of a transfer didn't get an ACK. While it might just mean 87 - an I2C device was temporarily not responding, usually it 88 - means there's nothing listening at that address. 89 - 90 - Returned by driver probe() methods to indicate that they 91 - found no device to bind to. (ENODEV may also be used.) 92 - 93 - EOPNOTSUPP 94 - Returned by an adapter when asked to perform an operation 95 - that it doesn't, or can't, support. 96 - 97 - For example, this would be returned when an adapter that 98 - doesn't support SMBus block transfers is asked to execute 99 - one. In that case, the driver making that request should 100 - have verified that functionality was supported before it 101 - made that block transfer request. 102 - 103 - Similarly, if an I2C adapter can't execute all legal I2C 104 - messages, it should return this when asked to perform a 105 - transaction it can't. (These limitations can't be seen in 106 - the adapter's functionality mask, since the assumption is 107 - that if an adapter supports I2C it supports all of I2C.) 108 - 109 - EPROTO 110 - Returned when slave does not conform to the relevant I2C 111 - or SMBus (or chip-specific) protocol specifications. One 112 - case is when the length of an SMBus block data response 113 - (from the SMBus slave) is outside the range 1-32 bytes. 114 - 115 - ESHUTDOWN 116 - Returned when a transfer was requested using an adapter 117 - which is already suspended. 118 - 119 - ETIMEDOUT 120 - This is returned by drivers when an operation took too much 121 - time, and was aborted before it completed. 122 - 123 - SMBus adapters may return it when an operation took more 124 - time than allowed by the SMBus specification; for example, 125 - when a slave stretches clocks too far. I2C has no such 126 - timeouts, but it's normal for I2C adapters to impose some 127 - arbitrary limits (much longer than SMBus!) too. 128 -
+131
Documentation/i2c/fault-codes.rst
··· 1 + ===================== 2 + I2C/SMBUS Fault Codes 3 + ===================== 4 + 5 + This is a summary of the most important conventions for use of fault 6 + codes in the I2C/SMBus stack. 7 + 8 + 9 + A "Fault" is not always an "Error" 10 + ---------------------------------- 11 + Not all fault reports imply errors; "page faults" should be a familiar 12 + example. Software often retries idempotent operations after transient 13 + faults. There may be fancier recovery schemes that are appropriate in 14 + some cases, such as re-initializing (and maybe resetting). After such 15 + recovery, triggered by a fault report, there is no error. 16 + 17 + In a similar way, sometimes a "fault" code just reports one defined 18 + result for an operation ... it doesn't indicate that anything is wrong 19 + at all, just that the outcome wasn't on the "golden path". 20 + 21 + In short, your I2C driver code may need to know these codes in order 22 + to respond correctly. Other code may need to rely on YOUR code reporting 23 + the right fault code, so that it can (in turn) behave correctly. 24 + 25 + 26 + I2C and SMBus fault codes 27 + ------------------------- 28 + These are returned as negative numbers from most calls, with zero or 29 + some positive number indicating a non-fault return. The specific 30 + numbers associated with these symbols differ between architectures, 31 + though most Linux systems use <asm-generic/errno*.h> numbering. 32 + 33 + Note that the descriptions here are not exhaustive. There are other 34 + codes that may be returned, and other cases where these codes should 35 + be returned. However, drivers should not return other codes for these 36 + cases (unless the hardware doesn't provide unique fault reports). 37 + 38 + Also, codes returned by adapter probe methods follow rules which are 39 + specific to their host bus (such as PCI, or the platform bus). 40 + 41 + 42 + EAGAIN 43 + Returned by I2C adapters when they lose arbitration in master 44 + transmit mode: some other master was transmitting different 45 + data at the same time. 46 + 47 + Also returned when trying to invoke an I2C operation in an 48 + atomic context, when some task is already using that I2C bus 49 + to execute some other operation. 50 + 51 + EBADMSG 52 + Returned by SMBus logic when an invalid Packet Error Code byte 53 + is received. This code is a CRC covering all bytes in the 54 + transaction, and is sent before the terminating STOP. This 55 + fault is only reported on read transactions; the SMBus slave 56 + may have a way to report PEC mismatches on writes from the 57 + host. Note that even if PECs are in use, you should not rely 58 + on these as the only way to detect incorrect data transfers. 59 + 60 + EBUSY 61 + Returned by SMBus adapters when the bus was busy for longer 62 + than allowed. This usually indicates some device (maybe the 63 + SMBus adapter) needs some fault recovery (such as resetting), 64 + or that the reset was attempted but failed. 65 + 66 + EINVAL 67 + This rather vague error means an invalid parameter has been 68 + detected before any I/O operation was started. Use a more 69 + specific fault code when you can. 70 + 71 + EIO 72 + This rather vague error means something went wrong when 73 + performing an I/O operation. Use a more specific fault 74 + code when you can. 75 + 76 + ENODEV 77 + Returned by driver probe() methods. This is a bit more 78 + specific than ENXIO, implying the problem isn't with the 79 + address, but with the device found there. Driver probes 80 + may verify the device returns *correct* responses, and 81 + return this as appropriate. (The driver core will warn 82 + about probe faults other than ENXIO and ENODEV.) 83 + 84 + ENOMEM 85 + Returned by any component that can't allocate memory when 86 + it needs to do so. 87 + 88 + ENXIO 89 + Returned by I2C adapters to indicate that the address phase 90 + of a transfer didn't get an ACK. While it might just mean 91 + an I2C device was temporarily not responding, usually it 92 + means there's nothing listening at that address. 93 + 94 + Returned by driver probe() methods to indicate that they 95 + found no device to bind to. (ENODEV may also be used.) 96 + 97 + EOPNOTSUPP 98 + Returned by an adapter when asked to perform an operation 99 + that it doesn't, or can't, support. 100 + 101 + For example, this would be returned when an adapter that 102 + doesn't support SMBus block transfers is asked to execute 103 + one. In that case, the driver making that request should 104 + have verified that functionality was supported before it 105 + made that block transfer request. 106 + 107 + Similarly, if an I2C adapter can't execute all legal I2C 108 + messages, it should return this when asked to perform a 109 + transaction it can't. (These limitations can't be seen in 110 + the adapter's functionality mask, since the assumption is 111 + that if an adapter supports I2C it supports all of I2C.) 112 + 113 + EPROTO 114 + Returned when slave does not conform to the relevant I2C 115 + or SMBus (or chip-specific) protocol specifications. One 116 + case is when the length of an SMBus block data response 117 + (from the SMBus slave) is outside the range 1-32 bytes. 118 + 119 + ESHUTDOWN 120 + Returned when a transfer was requested using an adapter 121 + which is already suspended. 122 + 123 + ETIMEDOUT 124 + This is returned by drivers when an operation took too much 125 + time, and was aborted before it completed. 126 + 127 + SMBus adapters may return it when an operation took more 128 + time than allowed by the SMBus specification; for example, 129 + when a slave stretches clocks too far. I2C has no such 130 + timeouts, but it's normal for I2C adapters to impose some 131 + arbitrary limits (much longer than SMBus!) too.
-148
Documentation/i2c/functionality
··· 1 - INTRODUCTION 2 - ------------ 3 - 4 - Because not every I2C or SMBus adapter implements everything in the 5 - I2C specifications, a client can not trust that everything it needs 6 - is implemented when it is given the option to attach to an adapter: 7 - the client needs some way to check whether an adapter has the needed 8 - functionality. 9 - 10 - 11 - FUNCTIONALITY CONSTANTS 12 - ----------------------- 13 - 14 - For the most up-to-date list of functionality constants, please check 15 - <uapi/linux/i2c.h>! 16 - 17 - I2C_FUNC_I2C Plain i2c-level commands (Pure SMBus 18 - adapters typically can not do these) 19 - I2C_FUNC_10BIT_ADDR Handles the 10-bit address extensions 20 - I2C_FUNC_PROTOCOL_MANGLING Knows about the I2C_M_IGNORE_NAK, 21 - I2C_M_REV_DIR_ADDR and I2C_M_NO_RD_ACK 22 - flags (which modify the I2C protocol!) 23 - I2C_FUNC_NOSTART Can skip repeated start sequence 24 - I2C_FUNC_SMBUS_QUICK Handles the SMBus write_quick command 25 - I2C_FUNC_SMBUS_READ_BYTE Handles the SMBus read_byte command 26 - I2C_FUNC_SMBUS_WRITE_BYTE Handles the SMBus write_byte command 27 - I2C_FUNC_SMBUS_READ_BYTE_DATA Handles the SMBus read_byte_data command 28 - I2C_FUNC_SMBUS_WRITE_BYTE_DATA Handles the SMBus write_byte_data command 29 - I2C_FUNC_SMBUS_READ_WORD_DATA Handles the SMBus read_word_data command 30 - I2C_FUNC_SMBUS_WRITE_WORD_DATA Handles the SMBus write_byte_data command 31 - I2C_FUNC_SMBUS_PROC_CALL Handles the SMBus process_call command 32 - I2C_FUNC_SMBUS_READ_BLOCK_DATA Handles the SMBus read_block_data command 33 - I2C_FUNC_SMBUS_WRITE_BLOCK_DATA Handles the SMBus write_block_data command 34 - I2C_FUNC_SMBUS_READ_I2C_BLOCK Handles the SMBus read_i2c_block_data command 35 - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK Handles the SMBus write_i2c_block_data command 36 - 37 - A few combinations of the above flags are also defined for your convenience: 38 - 39 - I2C_FUNC_SMBUS_BYTE Handles the SMBus read_byte 40 - and write_byte commands 41 - I2C_FUNC_SMBUS_BYTE_DATA Handles the SMBus read_byte_data 42 - and write_byte_data commands 43 - I2C_FUNC_SMBUS_WORD_DATA Handles the SMBus read_word_data 44 - and write_word_data commands 45 - I2C_FUNC_SMBUS_BLOCK_DATA Handles the SMBus read_block_data 46 - and write_block_data commands 47 - I2C_FUNC_SMBUS_I2C_BLOCK Handles the SMBus read_i2c_block_data 48 - and write_i2c_block_data commands 49 - I2C_FUNC_SMBUS_EMUL Handles all SMBus commands that can be 50 - emulated by a real I2C adapter (using 51 - the transparent emulation layer) 52 - 53 - In kernel versions prior to 3.5 I2C_FUNC_NOSTART was implemented as 54 - part of I2C_FUNC_PROTOCOL_MANGLING. 55 - 56 - 57 - ADAPTER IMPLEMENTATION 58 - ---------------------- 59 - 60 - When you write a new adapter driver, you will have to implement a 61 - function callback `functionality'. Typical implementations are given 62 - below. 63 - 64 - A typical SMBus-only adapter would list all the SMBus transactions it 65 - supports. This example comes from the i2c-piix4 driver: 66 - 67 - static u32 piix4_func(struct i2c_adapter *adapter) 68 - { 69 - return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | 70 - I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | 71 - I2C_FUNC_SMBUS_BLOCK_DATA; 72 - } 73 - 74 - A typical full-I2C adapter would use the following (from the i2c-pxa 75 - driver): 76 - 77 - static u32 i2c_pxa_functionality(struct i2c_adapter *adap) 78 - { 79 - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; 80 - } 81 - 82 - I2C_FUNC_SMBUS_EMUL includes all the SMBus transactions (with the 83 - addition of I2C block transactions) which i2c-core can emulate using 84 - I2C_FUNC_I2C without any help from the adapter driver. The idea is 85 - to let the client drivers check for the support of SMBus functions 86 - without having to care whether the said functions are implemented in 87 - hardware by the adapter, or emulated in software by i2c-core on top 88 - of an I2C adapter. 89 - 90 - 91 - CLIENT CHECKING 92 - --------------- 93 - 94 - Before a client tries to attach to an adapter, or even do tests to check 95 - whether one of the devices it supports is present on an adapter, it should 96 - check whether the needed functionality is present. The typical way to do 97 - this is (from the lm75 driver): 98 - 99 - static int lm75_detect(...) 100 - { 101 - (...) 102 - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | 103 - I2C_FUNC_SMBUS_WORD_DATA)) 104 - goto exit; 105 - (...) 106 - } 107 - 108 - Here, the lm75 driver checks if the adapter can do both SMBus byte data 109 - and SMBus word data transactions. If not, then the driver won't work on 110 - this adapter and there's no point in going on. If the check above is 111 - successful, then the driver knows that it can call the following 112 - functions: i2c_smbus_read_byte_data(), i2c_smbus_write_byte_data(), 113 - i2c_smbus_read_word_data() and i2c_smbus_write_word_data(). As a rule of 114 - thumb, the functionality constants you test for with 115 - i2c_check_functionality() should match exactly the i2c_smbus_* functions 116 - which you driver is calling. 117 - 118 - Note that the check above doesn't tell whether the functionalities are 119 - implemented in hardware by the underlying adapter or emulated in 120 - software by i2c-core. Client drivers don't have to care about this, as 121 - i2c-core will transparently implement SMBus transactions on top of I2C 122 - adapters. 123 - 124 - 125 - CHECKING THROUGH /DEV 126 - --------------------- 127 - 128 - If you try to access an adapter from a userspace program, you will have 129 - to use the /dev interface. You will still have to check whether the 130 - functionality you need is supported, of course. This is done using 131 - the I2C_FUNCS ioctl. An example, adapted from the i2cdetect program, is 132 - below: 133 - 134 - int file; 135 - if (file = open("/dev/i2c-0", O_RDWR) < 0) { 136 - /* Some kind of error handling */ 137 - exit(1); 138 - } 139 - if (ioctl(file, I2C_FUNCS, &funcs) < 0) { 140 - /* Some kind of error handling */ 141 - exit(1); 142 - } 143 - if (!(funcs & I2C_FUNC_SMBUS_QUICK)) { 144 - /* Oops, the needed functionality (SMBus write_quick function) is 145 - not available! */ 146 - exit(1); 147 - } 148 - /* Now it is safe to use the SMBus write_quick command */
+156
Documentation/i2c/functionality.rst
··· 1 + ======================= 2 + I2C/SMBus Functionality 3 + ======================= 4 + 5 + INTRODUCTION 6 + ------------ 7 + 8 + Because not every I2C or SMBus adapter implements everything in the 9 + I2C specifications, a client can not trust that everything it needs 10 + is implemented when it is given the option to attach to an adapter: 11 + the client needs some way to check whether an adapter has the needed 12 + functionality. 13 + 14 + 15 + FUNCTIONALITY CONSTANTS 16 + ----------------------- 17 + 18 + For the most up-to-date list of functionality constants, please check 19 + <uapi/linux/i2c.h>! 20 + 21 + =============================== ============================================== 22 + I2C_FUNC_I2C Plain i2c-level commands (Pure SMBus 23 + adapters typically can not do these) 24 + I2C_FUNC_10BIT_ADDR Handles the 10-bit address extensions 25 + I2C_FUNC_PROTOCOL_MANGLING Knows about the I2C_M_IGNORE_NAK, 26 + I2C_M_REV_DIR_ADDR and I2C_M_NO_RD_ACK 27 + flags (which modify the I2C protocol!) 28 + I2C_FUNC_NOSTART Can skip repeated start sequence 29 + I2C_FUNC_SMBUS_QUICK Handles the SMBus write_quick command 30 + I2C_FUNC_SMBUS_READ_BYTE Handles the SMBus read_byte command 31 + I2C_FUNC_SMBUS_WRITE_BYTE Handles the SMBus write_byte command 32 + I2C_FUNC_SMBUS_READ_BYTE_DATA Handles the SMBus read_byte_data command 33 + I2C_FUNC_SMBUS_WRITE_BYTE_DATA Handles the SMBus write_byte_data command 34 + I2C_FUNC_SMBUS_READ_WORD_DATA Handles the SMBus read_word_data command 35 + I2C_FUNC_SMBUS_WRITE_WORD_DATA Handles the SMBus write_byte_data command 36 + I2C_FUNC_SMBUS_PROC_CALL Handles the SMBus process_call command 37 + I2C_FUNC_SMBUS_READ_BLOCK_DATA Handles the SMBus read_block_data command 38 + I2C_FUNC_SMBUS_WRITE_BLOCK_DATA Handles the SMBus write_block_data command 39 + I2C_FUNC_SMBUS_READ_I2C_BLOCK Handles the SMBus read_i2c_block_data command 40 + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK Handles the SMBus write_i2c_block_data command 41 + =============================== ============================================== 42 + 43 + A few combinations of the above flags are also defined for your convenience: 44 + 45 + ========================= ====================================== 46 + I2C_FUNC_SMBUS_BYTE Handles the SMBus read_byte 47 + and write_byte commands 48 + I2C_FUNC_SMBUS_BYTE_DATA Handles the SMBus read_byte_data 49 + and write_byte_data commands 50 + I2C_FUNC_SMBUS_WORD_DATA Handles the SMBus read_word_data 51 + and write_word_data commands 52 + I2C_FUNC_SMBUS_BLOCK_DATA Handles the SMBus read_block_data 53 + and write_block_data commands 54 + I2C_FUNC_SMBUS_I2C_BLOCK Handles the SMBus read_i2c_block_data 55 + and write_i2c_block_data commands 56 + I2C_FUNC_SMBUS_EMUL Handles all SMBus commands that can be 57 + emulated by a real I2C adapter (using 58 + the transparent emulation layer) 59 + ========================= ====================================== 60 + 61 + In kernel versions prior to 3.5 I2C_FUNC_NOSTART was implemented as 62 + part of I2C_FUNC_PROTOCOL_MANGLING. 63 + 64 + 65 + ADAPTER IMPLEMENTATION 66 + ---------------------- 67 + 68 + When you write a new adapter driver, you will have to implement a 69 + function callback ``functionality``. Typical implementations are given 70 + below. 71 + 72 + A typical SMBus-only adapter would list all the SMBus transactions it 73 + supports. This example comes from the i2c-piix4 driver:: 74 + 75 + static u32 piix4_func(struct i2c_adapter *adapter) 76 + { 77 + return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | 78 + I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | 79 + I2C_FUNC_SMBUS_BLOCK_DATA; 80 + } 81 + 82 + A typical full-I2C adapter would use the following (from the i2c-pxa 83 + driver):: 84 + 85 + static u32 i2c_pxa_functionality(struct i2c_adapter *adap) 86 + { 87 + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; 88 + } 89 + 90 + I2C_FUNC_SMBUS_EMUL includes all the SMBus transactions (with the 91 + addition of I2C block transactions) which i2c-core can emulate using 92 + I2C_FUNC_I2C without any help from the adapter driver. The idea is 93 + to let the client drivers check for the support of SMBus functions 94 + without having to care whether the said functions are implemented in 95 + hardware by the adapter, or emulated in software by i2c-core on top 96 + of an I2C adapter. 97 + 98 + 99 + CLIENT CHECKING 100 + --------------- 101 + 102 + Before a client tries to attach to an adapter, or even do tests to check 103 + whether one of the devices it supports is present on an adapter, it should 104 + check whether the needed functionality is present. The typical way to do 105 + this is (from the lm75 driver):: 106 + 107 + static int lm75_detect(...) 108 + { 109 + (...) 110 + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | 111 + I2C_FUNC_SMBUS_WORD_DATA)) 112 + goto exit; 113 + (...) 114 + } 115 + 116 + Here, the lm75 driver checks if the adapter can do both SMBus byte data 117 + and SMBus word data transactions. If not, then the driver won't work on 118 + this adapter and there's no point in going on. If the check above is 119 + successful, then the driver knows that it can call the following 120 + functions: i2c_smbus_read_byte_data(), i2c_smbus_write_byte_data(), 121 + i2c_smbus_read_word_data() and i2c_smbus_write_word_data(). As a rule of 122 + thumb, the functionality constants you test for with 123 + i2c_check_functionality() should match exactly the i2c_smbus_* functions 124 + which you driver is calling. 125 + 126 + Note that the check above doesn't tell whether the functionalities are 127 + implemented in hardware by the underlying adapter or emulated in 128 + software by i2c-core. Client drivers don't have to care about this, as 129 + i2c-core will transparently implement SMBus transactions on top of I2C 130 + adapters. 131 + 132 + 133 + CHECKING THROUGH /DEV 134 + --------------------- 135 + 136 + If you try to access an adapter from a userspace program, you will have 137 + to use the /dev interface. You will still have to check whether the 138 + functionality you need is supported, of course. This is done using 139 + the I2C_FUNCS ioctl. An example, adapted from the i2cdetect program, is 140 + below:: 141 + 142 + int file; 143 + if (file = open("/dev/i2c-0", O_RDWR) < 0) { 144 + /* Some kind of error handling */ 145 + exit(1); 146 + } 147 + if (ioctl(file, I2C_FUNCS, &funcs) < 0) { 148 + /* Some kind of error handling */ 149 + exit(1); 150 + } 151 + if (!(funcs & I2C_FUNC_SMBUS_QUICK)) { 152 + /* Oops, the needed functionality (SMBus write_quick function) is 153 + not available! */ 154 + exit(1); 155 + } 156 + /* Now it is safe to use the SMBus write_quick command */
-136
Documentation/i2c/gpio-fault-injection
··· 1 - ========================= 2 - Linux I2C fault injection 3 - ========================= 4 - 5 - The GPIO based I2C bus master driver can be configured to provide fault 6 - injection capabilities. It is then meant to be connected to another I2C bus 7 - which is driven by the I2C bus master driver under test. The GPIO fault 8 - injection driver can create special states on the bus which the other I2C bus 9 - master driver should handle gracefully. 10 - 11 - Once the Kconfig option I2C_GPIO_FAULT_INJECTOR is enabled, there will be an 12 - 'i2c-fault-injector' subdirectory in the Kernel debugfs filesystem, usually 13 - mounted at /sys/kernel/debug. There will be a separate subdirectory per GPIO 14 - driven I2C bus. Each subdirectory will contain files to trigger the fault 15 - injection. They will be described now along with their intended use-cases. 16 - 17 - Wire states 18 - =========== 19 - 20 - "scl" 21 - ----- 22 - 23 - By reading this file, you get the current state of SCL. By writing, you can 24 - change its state to either force it low or to release it again. So, by using 25 - "echo 0 > scl" you force SCL low and thus, no communication will be possible 26 - because the bus master under test will not be able to clock. It should detect 27 - the condition of SCL being unresponsive and report an error to the upper 28 - layers. 29 - 30 - "sda" 31 - ----- 32 - 33 - By reading this file, you get the current state of SDA. By writing, you can 34 - change its state to either force it low or to release it again. So, by using 35 - "echo 0 > sda" you force SDA low and thus, data cannot be transmitted. The bus 36 - master under test should detect this condition and trigger a bus recovery (see 37 - I2C specification version 4, section 3.1.16) using the helpers of the Linux I2C 38 - core (see 'struct bus_recovery_info'). However, the bus recovery will not 39 - succeed because SDA is still pinned low until you manually release it again 40 - with "echo 1 > sda". A test with an automatic release can be done with the 41 - "incomplete transfers" class of fault injectors. 42 - 43 - Incomplete transfers 44 - ==================== 45 - 46 - The following fault injectors create situations where SDA will be held low by a 47 - device. Bus recovery should be able to fix these situations. But please note: 48 - there are I2C client devices which detect a stuck SDA on their side and release 49 - it on their own after a few milliseconds. Also, there might be an external 50 - device deglitching and monitoring the I2C bus. It could also detect a stuck SDA 51 - and will init a bus recovery on its own. If you want to implement bus recovery 52 - in a bus master driver, make sure you checked your hardware setup for such 53 - devices before. And always verify with a scope or logic analyzer! 54 - 55 - "incomplete_address_phase" 56 - -------------------------- 57 - 58 - This file is write only and you need to write the address of an existing I2C 59 - client device to it. Then, a read transfer to this device will be started, but 60 - it will stop at the ACK phase after the address of the client has been 61 - transmitted. Because the device will ACK its presence, this results in SDA 62 - being pulled low by the device while SCL is high. So, similar to the "sda" file 63 - above, the bus master under test should detect this condition and try a bus 64 - recovery. This time, however, it should succeed and the device should release 65 - SDA after toggling SCL. 66 - 67 - "incomplete_write_byte" 68 - ----------------------- 69 - 70 - Similar to above, this file is write only and you need to write the address of 71 - an existing I2C client device to it. 72 - 73 - The injector will again stop at one ACK phase, so the device will keep SDA low 74 - because it acknowledges data. However, there are two differences compared to 75 - 'incomplete_address_phase': 76 - 77 - a) the message sent out will be a write message 78 - b) after the address byte, a 0x00 byte will be transferred. Then, stop at ACK. 79 - 80 - This is a highly delicate state, the device is set up to write any data to 81 - register 0x00 (if it has registers) when further clock pulses happen on SCL. 82 - This is why bus recovery (up to 9 clock pulses) must either check SDA or send 83 - additional STOP conditions to ensure the bus has been released. Otherwise 84 - random data will be written to a device! 85 - 86 - Lost arbitration 87 - ================ 88 - 89 - Here, we want to simulate the condition where the master under test loses the 90 - bus arbitration against another master in a multi-master setup. 91 - 92 - "lose_arbitration" 93 - ------------------ 94 - 95 - This file is write only and you need to write the duration of the arbitration 96 - intereference (in µs, maximum is 100ms). The calling process will then sleep 97 - and wait for the next bus clock. The process is interruptible, though. 98 - 99 - Arbitration lost is achieved by waiting for SCL going down by the master under 100 - test and then pulling SDA low for some time. So, the I2C address sent out 101 - should be corrupted and that should be detected properly. That means that the 102 - address sent out should have a lot of '1' bits to be able to detect corruption. 103 - There doesn't need to be a device at this address because arbitration lost 104 - should be detected beforehand. Also note, that SCL going down is monitored 105 - using interrupts, so the interrupt latency might cause the first bits to be not 106 - corrupted. A good starting point for using this fault injector on an otherwise 107 - idle bus is: 108 - 109 - # echo 200 > lose_arbitration & 110 - # i2cget -y <bus_to_test> 0x3f 111 - 112 - Panic during transfer 113 - ===================== 114 - 115 - This fault injector will create a Kernel panic once the master under test 116 - started a transfer. This usually means that the state machine of the bus master 117 - driver will be ungracefully interrupted and the bus may end up in an unusual 118 - state. Use this to check if your shutdown/reboot/boot code can handle this 119 - scenario. 120 - 121 - "inject_panic" 122 - -------------- 123 - 124 - This file is write only and you need to write the delay between the detected 125 - start of a transmission and the induced Kernel panic (in µs, maximum is 100ms). 126 - The calling process will then sleep and wait for the next bus clock. The 127 - process is interruptible, though. 128 - 129 - Start of a transfer is detected by waiting for SCL going down by the master 130 - under test. A good starting point for using this fault injector is: 131 - 132 - # echo 0 > inject_panic & 133 - # i2cget -y <bus_to_test> <some_address> 134 - 135 - Note that there doesn't need to be a device listening to the address you are 136 - using. Results may vary depending on that, though.
+136
Documentation/i2c/gpio-fault-injection.rst
··· 1 + ========================= 2 + Linux I2C fault injection 3 + ========================= 4 + 5 + The GPIO based I2C bus master driver can be configured to provide fault 6 + injection capabilities. It is then meant to be connected to another I2C bus 7 + which is driven by the I2C bus master driver under test. The GPIO fault 8 + injection driver can create special states on the bus which the other I2C bus 9 + master driver should handle gracefully. 10 + 11 + Once the Kconfig option I2C_GPIO_FAULT_INJECTOR is enabled, there will be an 12 + 'i2c-fault-injector' subdirectory in the Kernel debugfs filesystem, usually 13 + mounted at /sys/kernel/debug. There will be a separate subdirectory per GPIO 14 + driven I2C bus. Each subdirectory will contain files to trigger the fault 15 + injection. They will be described now along with their intended use-cases. 16 + 17 + Wire states 18 + =========== 19 + 20 + "scl" 21 + ----- 22 + 23 + By reading this file, you get the current state of SCL. By writing, you can 24 + change its state to either force it low or to release it again. So, by using 25 + "echo 0 > scl" you force SCL low and thus, no communication will be possible 26 + because the bus master under test will not be able to clock. It should detect 27 + the condition of SCL being unresponsive and report an error to the upper 28 + layers. 29 + 30 + "sda" 31 + ----- 32 + 33 + By reading this file, you get the current state of SDA. By writing, you can 34 + change its state to either force it low or to release it again. So, by using 35 + "echo 0 > sda" you force SDA low and thus, data cannot be transmitted. The bus 36 + master under test should detect this condition and trigger a bus recovery (see 37 + I2C specification version 4, section 3.1.16) using the helpers of the Linux I2C 38 + core (see 'struct bus_recovery_info'). However, the bus recovery will not 39 + succeed because SDA is still pinned low until you manually release it again 40 + with "echo 1 > sda". A test with an automatic release can be done with the 41 + "incomplete transfers" class of fault injectors. 42 + 43 + Incomplete transfers 44 + ==================== 45 + 46 + The following fault injectors create situations where SDA will be held low by a 47 + device. Bus recovery should be able to fix these situations. But please note: 48 + there are I2C client devices which detect a stuck SDA on their side and release 49 + it on their own after a few milliseconds. Also, there might be an external 50 + device deglitching and monitoring the I2C bus. It could also detect a stuck SDA 51 + and will init a bus recovery on its own. If you want to implement bus recovery 52 + in a bus master driver, make sure you checked your hardware setup for such 53 + devices before. And always verify with a scope or logic analyzer! 54 + 55 + "incomplete_address_phase" 56 + -------------------------- 57 + 58 + This file is write only and you need to write the address of an existing I2C 59 + client device to it. Then, a read transfer to this device will be started, but 60 + it will stop at the ACK phase after the address of the client has been 61 + transmitted. Because the device will ACK its presence, this results in SDA 62 + being pulled low by the device while SCL is high. So, similar to the "sda" file 63 + above, the bus master under test should detect this condition and try a bus 64 + recovery. This time, however, it should succeed and the device should release 65 + SDA after toggling SCL. 66 + 67 + "incomplete_write_byte" 68 + ----------------------- 69 + 70 + Similar to above, this file is write only and you need to write the address of 71 + an existing I2C client device to it. 72 + 73 + The injector will again stop at one ACK phase, so the device will keep SDA low 74 + because it acknowledges data. However, there are two differences compared to 75 + 'incomplete_address_phase': 76 + 77 + a) the message sent out will be a write message 78 + b) after the address byte, a 0x00 byte will be transferred. Then, stop at ACK. 79 + 80 + This is a highly delicate state, the device is set up to write any data to 81 + register 0x00 (if it has registers) when further clock pulses happen on SCL. 82 + This is why bus recovery (up to 9 clock pulses) must either check SDA or send 83 + additional STOP conditions to ensure the bus has been released. Otherwise 84 + random data will be written to a device! 85 + 86 + Lost arbitration 87 + ================ 88 + 89 + Here, we want to simulate the condition where the master under test loses the 90 + bus arbitration against another master in a multi-master setup. 91 + 92 + "lose_arbitration" 93 + ------------------ 94 + 95 + This file is write only and you need to write the duration of the arbitration 96 + intereference (in µs, maximum is 100ms). The calling process will then sleep 97 + and wait for the next bus clock. The process is interruptible, though. 98 + 99 + Arbitration lost is achieved by waiting for SCL going down by the master under 100 + test and then pulling SDA low for some time. So, the I2C address sent out 101 + should be corrupted and that should be detected properly. That means that the 102 + address sent out should have a lot of '1' bits to be able to detect corruption. 103 + There doesn't need to be a device at this address because arbitration lost 104 + should be detected beforehand. Also note, that SCL going down is monitored 105 + using interrupts, so the interrupt latency might cause the first bits to be not 106 + corrupted. A good starting point for using this fault injector on an otherwise 107 + idle bus is:: 108 + 109 + # echo 200 > lose_arbitration & 110 + # i2cget -y <bus_to_test> 0x3f 111 + 112 + Panic during transfer 113 + ===================== 114 + 115 + This fault injector will create a Kernel panic once the master under test 116 + started a transfer. This usually means that the state machine of the bus master 117 + driver will be ungracefully interrupted and the bus may end up in an unusual 118 + state. Use this to check if your shutdown/reboot/boot code can handle this 119 + scenario. 120 + 121 + "inject_panic" 122 + -------------- 123 + 124 + This file is write only and you need to write the delay between the detected 125 + start of a transmission and the induced Kernel panic (in µs, maximum is 100ms). 126 + The calling process will then sleep and wait for the next bus clock. The 127 + process is interruptible, though. 128 + 129 + Start of a transfer is detected by waiting for SCL going down by the master 130 + under test. A good starting point for using this fault injector is:: 131 + 132 + # echo 0 > inject_panic & 133 + # i2cget -y <bus_to_test> <some_address> 134 + 135 + Note that there doesn't need to be a device listening to the address you are 136 + using. Results may vary depending on that, though.
-88
Documentation/i2c/i2c-protocol
··· 1 - This document describes the i2c protocol. Or will, when it is finished :-) 2 - 3 - Key to symbols 4 - ============== 5 - 6 - S (1 bit) : Start bit 7 - P (1 bit) : Stop bit 8 - Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. 9 - A, NA (1 bit) : Accept and reverse accept bit. 10 - Addr (7 bits): I2C 7 bit address. Note that this can be expanded as usual to 11 - get a 10 bit I2C address. 12 - Comm (8 bits): Command byte, a data byte which often selects a register on 13 - the device. 14 - Data (8 bits): A plain data byte. Sometimes, I write DataLow, DataHigh 15 - for 16 bit data. 16 - Count (8 bits): A data byte containing the length of a block operation. 17 - 18 - [..]: Data sent by I2C device, as opposed to data sent by the host adapter. 19 - 20 - 21 - Simple send transaction 22 - ====================== 23 - 24 - This corresponds to i2c_master_send. 25 - 26 - S Addr Wr [A] Data [A] Data [A] ... [A] Data [A] P 27 - 28 - 29 - Simple receive transaction 30 - =========================== 31 - 32 - This corresponds to i2c_master_recv 33 - 34 - S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P 35 - 36 - 37 - Combined transactions 38 - ==================== 39 - 40 - This corresponds to i2c_transfer 41 - 42 - They are just like the above transactions, but instead of a stop bit P 43 - a start bit S is sent and the transaction continues. An example of 44 - a byte read, followed by a byte write: 45 - 46 - S Addr Rd [A] [Data] NA S Addr Wr [A] Data [A] P 47 - 48 - 49 - Modified transactions 50 - ===================== 51 - 52 - The following modifications to the I2C protocol can also be generated by 53 - setting these flags for i2c messages. With the exception of I2C_M_NOSTART, they 54 - are usually only needed to work around device issues: 55 - 56 - I2C_M_IGNORE_NAK: 57 - Normally message is interrupted immediately if there is [NA] from the 58 - client. Setting this flag treats any [NA] as [A], and all of 59 - message is sent. 60 - These messages may still fail to SCL lo->hi timeout. 61 - 62 - I2C_M_NO_RD_ACK: 63 - In a read message, master A/NA bit is skipped. 64 - 65 - I2C_M_NOSTART: 66 - In a combined transaction, no 'S Addr Wr/Rd [A]' is generated at some 67 - point. For example, setting I2C_M_NOSTART on the second partial message 68 - generates something like: 69 - S Addr Rd [A] [Data] NA Data [A] P 70 - If you set the I2C_M_NOSTART variable for the first partial message, 71 - we do not generate Addr, but we do generate the startbit S. This will 72 - probably confuse all other clients on your bus, so don't try this. 73 - 74 - This is often used to gather transmits from multiple data buffers in 75 - system memory into something that appears as a single transfer to the 76 - I2C device but may also be used between direction changes by some 77 - rare devices. 78 - 79 - I2C_M_REV_DIR_ADDR: 80 - This toggles the Rd/Wr flag. That is, if you want to do a write, but 81 - need to emit an Rd instead of a Wr, or vice versa, you set this 82 - flag. For example: 83 - S Addr Rd [A] Data [A] Data [A] ... [A] Data [A] P 84 - 85 - I2C_M_STOP: 86 - Force a stop condition (P) after the message. Some I2C related protocols 87 - like SCCB require that. Normally, you really don't want to get interrupted 88 - between the messages of one transfer.
+98
Documentation/i2c/i2c-protocol.rst
··· 1 + ============ 2 + I2C Protocol 3 + ============ 4 + 5 + This document describes the i2c protocol. Or will, when it is finished :-) 6 + 7 + Key to symbols 8 + ============== 9 + 10 + =============== ============================================================= 11 + S (1 bit) : Start bit 12 + P (1 bit) : Stop bit 13 + Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. 14 + A, NA (1 bit) : Accept and reverse accept bit. 15 + Addr (7 bits): I2C 7 bit address. Note that this can be expanded as usual to 16 + get a 10 bit I2C address. 17 + Comm (8 bits): Command byte, a data byte which often selects a register on 18 + the device. 19 + Data (8 bits): A plain data byte. Sometimes, I write DataLow, DataHigh 20 + for 16 bit data. 21 + Count (8 bits): A data byte containing the length of a block operation. 22 + 23 + [..]: Data sent by I2C device, as opposed to data sent by the 24 + host adapter. 25 + =============== ============================================================= 26 + 27 + 28 + Simple send transaction 29 + ======================= 30 + 31 + This corresponds to i2c_master_send:: 32 + 33 + S Addr Wr [A] Data [A] Data [A] ... [A] Data [A] P 34 + 35 + 36 + Simple receive transaction 37 + ========================== 38 + 39 + This corresponds to i2c_master_recv:: 40 + 41 + S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P 42 + 43 + 44 + Combined transactions 45 + ===================== 46 + 47 + This corresponds to i2c_transfer 48 + 49 + They are just like the above transactions, but instead of a stop bit P 50 + a start bit S is sent and the transaction continues. An example of 51 + a byte read, followed by a byte write:: 52 + 53 + S Addr Rd [A] [Data] NA S Addr Wr [A] Data [A] P 54 + 55 + 56 + Modified transactions 57 + ===================== 58 + 59 + The following modifications to the I2C protocol can also be generated by 60 + setting these flags for i2c messages. With the exception of I2C_M_NOSTART, they 61 + are usually only needed to work around device issues: 62 + 63 + I2C_M_IGNORE_NAK: 64 + Normally message is interrupted immediately if there is [NA] from the 65 + client. Setting this flag treats any [NA] as [A], and all of 66 + message is sent. 67 + These messages may still fail to SCL lo->hi timeout. 68 + 69 + I2C_M_NO_RD_ACK: 70 + In a read message, master A/NA bit is skipped. 71 + 72 + I2C_M_NOSTART: 73 + In a combined transaction, no 'S Addr Wr/Rd [A]' is generated at some 74 + point. For example, setting I2C_M_NOSTART on the second partial message 75 + generates something like:: 76 + 77 + S Addr Rd [A] [Data] NA Data [A] P 78 + 79 + If you set the I2C_M_NOSTART variable for the first partial message, 80 + we do not generate Addr, but we do generate the startbit S. This will 81 + probably confuse all other clients on your bus, so don't try this. 82 + 83 + This is often used to gather transmits from multiple data buffers in 84 + system memory into something that appears as a single transfer to the 85 + I2C device but may also be used between direction changes by some 86 + rare devices. 87 + 88 + I2C_M_REV_DIR_ADDR: 89 + This toggles the Rd/Wr flag. That is, if you want to do a write, but 90 + need to emit an Rd instead of a Wr, or vice versa, you set this 91 + flag. For example:: 92 + 93 + S Addr Rd [A] Data [A] Data [A] ... [A] Data [A] P 94 + 95 + I2C_M_STOP: 96 + Force a stop condition (P) after the message. Some I2C related protocols 97 + like SCCB require that. Normally, you really don't want to get interrupted 98 + between the messages of one transfer.
-64
Documentation/i2c/i2c-stub
··· 1 - MODULE: i2c-stub 2 - 3 - DESCRIPTION: 4 - 5 - This module is a very simple fake I2C/SMBus driver. It implements six 6 - types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, (r/w) 7 - word data, (r/w) I2C block data, and (r/w) SMBus block data. 8 - 9 - You need to provide chip addresses as a module parameter when loading this 10 - driver, which will then only react to SMBus commands to these addresses. 11 - 12 - No hardware is needed nor associated with this module. It will accept write 13 - quick commands to the specified addresses; it will respond to the other 14 - commands (also to the specified addresses) by reading from or writing to 15 - arrays in memory. It will also spam the kernel logs for every command it 16 - handles. 17 - 18 - A pointer register with auto-increment is implemented for all byte 19 - operations. This allows for continuous byte reads like those supported by 20 - EEPROMs, among others. 21 - 22 - SMBus block command support is disabled by default, and must be enabled 23 - explicitly by setting the respective bits (0x03000000) in the functionality 24 - module parameter. 25 - 26 - SMBus block commands must be written to configure an SMBus command for 27 - SMBus block operations. Writes can be partial. Block read commands always 28 - return the number of bytes selected with the largest write so far. 29 - 30 - The typical use-case is like this: 31 - 1. load this module 32 - 2. use i2cset (from the i2c-tools project) to pre-load some data 33 - 3. load the target chip driver module 34 - 4. observe its behavior in the kernel log 35 - 36 - There's a script named i2c-stub-from-dump in the i2c-tools package which 37 - can load register values automatically from a chip dump. 38 - 39 - PARAMETERS: 40 - 41 - int chip_addr[10]: 42 - The SMBus addresses to emulate chips at. 43 - 44 - unsigned long functionality: 45 - Functionality override, to disable some commands. See I2C_FUNC_* 46 - constants in <linux/i2c.h> for the suitable values. For example, 47 - value 0x1f0000 would only enable the quick, byte and byte data 48 - commands. 49 - 50 - u8 bank_reg[10] 51 - u8 bank_mask[10] 52 - u8 bank_start[10] 53 - u8 bank_end[10]: 54 - Optional bank settings. They tell which bits in which register 55 - select the active bank, as well as the range of banked registers. 56 - 57 - CAVEATS: 58 - 59 - If your target driver polls some byte or word waiting for it to change, the 60 - stub could lock it up. Use i2cset to unlock it. 61 - 62 - If you spam it hard enough, printk can be lossy. This module really wants 63 - something like relayfs. 64 -
+66
Documentation/i2c/i2c-stub.rst
··· 1 + ======== 2 + i2c-stub 3 + ======== 4 + 5 + Description 6 + =========== 7 + 8 + This module is a very simple fake I2C/SMBus driver. It implements six 9 + types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, (r/w) 10 + word data, (r/w) I2C block data, and (r/w) SMBus block data. 11 + 12 + You need to provide chip addresses as a module parameter when loading this 13 + driver, which will then only react to SMBus commands to these addresses. 14 + 15 + No hardware is needed nor associated with this module. It will accept write 16 + quick commands to the specified addresses; it will respond to the other 17 + commands (also to the specified addresses) by reading from or writing to 18 + arrays in memory. It will also spam the kernel logs for every command it 19 + handles. 20 + 21 + A pointer register with auto-increment is implemented for all byte 22 + operations. This allows for continuous byte reads like those supported by 23 + EEPROMs, among others. 24 + 25 + SMBus block command support is disabled by default, and must be enabled 26 + explicitly by setting the respective bits (0x03000000) in the functionality 27 + module parameter. 28 + 29 + SMBus block commands must be written to configure an SMBus command for 30 + SMBus block operations. Writes can be partial. Block read commands always 31 + return the number of bytes selected with the largest write so far. 32 + 33 + The typical use-case is like this: 34 + 35 + 1. load this module 36 + 2. use i2cset (from the i2c-tools project) to pre-load some data 37 + 3. load the target chip driver module 38 + 4. observe its behavior in the kernel log 39 + 40 + There's a script named i2c-stub-from-dump in the i2c-tools package which 41 + can load register values automatically from a chip dump. 42 + 43 + Parameters 44 + ========== 45 + 46 + int chip_addr[10]: 47 + The SMBus addresses to emulate chips at. 48 + 49 + unsigned long functionality: 50 + Functionality override, to disable some commands. See I2C_FUNC_* 51 + constants in <linux/i2c.h> for the suitable values. For example, 52 + value 0x1f0000 would only enable the quick, byte and byte data 53 + commands. 54 + 55 + u8 bank_reg[10], u8 bank_mask[10], u8 bank_start[10], u8 bank_end[10]: 56 + Optional bank settings. They tell which bits in which register 57 + select the active bank, as well as the range of banked registers. 58 + 59 + Caveats 60 + ======= 61 + 62 + If your target driver polls some byte or word waiting for it to change, the 63 + stub could lock it up. Use i2cset to unlock it. 64 + 65 + If you spam it hard enough, printk can be lossy. This module really wants 66 + something like relayfs.
-376
Documentation/i2c/i2c-topology
··· 1 - I2C topology 2 - ============ 3 - 4 - There are a couple of reasons for building more complex i2c topologies 5 - than a straight-forward i2c bus with one adapter and one or more devices. 6 - 7 - 1. A mux may be needed on the bus to prevent address collisions. 8 - 9 - 2. The bus may be accessible from some external bus master, and arbitration 10 - may be needed to determine if it is ok to access the bus. 11 - 12 - 3. A device (particularly RF tuners) may want to avoid the digital noise 13 - from the i2c bus, at least most of the time, and sits behind a gate 14 - that has to be operated before the device can be accessed. 15 - 16 - Etc 17 - 18 - These constructs are represented as i2c adapter trees by Linux, where 19 - each adapter has a parent adapter (except the root adapter) and zero or 20 - more child adapters. The root adapter is the actual adapter that issues 21 - i2c transfers, and all adapters with a parent are part of an "i2c-mux" 22 - object (quoted, since it can also be an arbitrator or a gate). 23 - 24 - Depending of the particular mux driver, something happens when there is 25 - an i2c transfer on one of its child adapters. The mux driver can 26 - obviously operate a mux, but it can also do arbitration with an external 27 - bus master or open a gate. The mux driver has two operations for this, 28 - select and deselect. select is called before the transfer and (the 29 - optional) deselect is called after the transfer. 30 - 31 - 32 - Locking 33 - ======= 34 - 35 - There are two variants of locking available to i2c muxes, they can be 36 - mux-locked or parent-locked muxes. As is evident from below, it can be 37 - useful to know if a mux is mux-locked or if it is parent-locked. The 38 - following list was correct at the time of writing: 39 - 40 - In drivers/i2c/muxes/ 41 - i2c-arb-gpio-challenge Parent-locked 42 - i2c-mux-gpio Normally parent-locked, mux-locked iff 43 - all involved gpio pins are controlled by the 44 - same i2c root adapter that they mux. 45 - i2c-mux-gpmux Normally parent-locked, mux-locked iff 46 - specified in device-tree. 47 - i2c-mux-ltc4306 Mux-locked 48 - i2c-mux-mlxcpld Parent-locked 49 - i2c-mux-pca9541 Parent-locked 50 - i2c-mux-pca954x Parent-locked 51 - i2c-mux-pinctrl Normally parent-locked, mux-locked iff 52 - all involved pinctrl devices are controlled 53 - by the same i2c root adapter that they mux. 54 - i2c-mux-reg Parent-locked 55 - 56 - In drivers/iio/ 57 - gyro/mpu3050 Mux-locked 58 - imu/inv_mpu6050/ Mux-locked 59 - 60 - In drivers/media/ 61 - dvb-frontends/lgdt3306a Mux-locked 62 - dvb-frontends/m88ds3103 Parent-locked 63 - dvb-frontends/rtl2830 Parent-locked 64 - dvb-frontends/rtl2832 Mux-locked 65 - dvb-frontends/si2168 Mux-locked 66 - usb/cx231xx/ Parent-locked 67 - 68 - 69 - Mux-locked muxes 70 - ---------------- 71 - 72 - Mux-locked muxes does not lock the entire parent adapter during the 73 - full select-transfer-deselect transaction, only the muxes on the parent 74 - adapter are locked. Mux-locked muxes are mostly interesting if the 75 - select and/or deselect operations must use i2c transfers to complete 76 - their tasks. Since the parent adapter is not fully locked during the 77 - full transaction, unrelated i2c transfers may interleave the different 78 - stages of the transaction. This has the benefit that the mux driver 79 - may be easier and cleaner to implement, but it has some caveats. 80 - 81 - ML1. If you build a topology with a mux-locked mux being the parent 82 - of a parent-locked mux, this might break the expectation from the 83 - parent-locked mux that the root adapter is locked during the 84 - transaction. 85 - 86 - ML2. It is not safe to build arbitrary topologies with two (or more) 87 - mux-locked muxes that are not siblings, when there are address 88 - collisions between the devices on the child adapters of these 89 - non-sibling muxes. 90 - 91 - I.e. the select-transfer-deselect transaction targeting e.g. device 92 - address 0x42 behind mux-one may be interleaved with a similar 93 - operation targeting device address 0x42 behind mux-two. The 94 - intension with such a topology would in this hypothetical example 95 - be that mux-one and mux-two should not be selected simultaneously, 96 - but mux-locked muxes do not guarantee that in all topologies. 97 - 98 - ML3. A mux-locked mux cannot be used by a driver for auto-closing 99 - gates/muxes, i.e. something that closes automatically after a given 100 - number (one, in most cases) of i2c transfers. Unrelated i2c transfers 101 - may creep in and close prematurely. 102 - 103 - ML4. If any non-i2c operation in the mux driver changes the i2c mux state, 104 - the driver has to lock the root adapter during that operation. 105 - Otherwise garbage may appear on the bus as seen from devices 106 - behind the mux, when an unrelated i2c transfer is in flight during 107 - the non-i2c mux-changing operation. 108 - 109 - 110 - Mux-locked Example 111 - ------------------ 112 - 113 - .----------. .--------. 114 - .--------. | mux- |-----| dev D1 | 115 - | root |--+--| locked | '--------' 116 - '--------' | | mux M1 |--. .--------. 117 - | '----------' '--| dev D2 | 118 - | .--------. '--------' 119 - '--| dev D3 | 120 - '--------' 121 - 122 - When there is an access to D1, this happens: 123 - 124 - 1. Someone issues an i2c-transfer to D1. 125 - 2. M1 locks muxes on its parent (the root adapter in this case). 126 - 3. M1 calls ->select to ready the mux. 127 - 4. M1 (presumably) does some i2c-transfers as part of its select. 128 - These transfers are normal i2c-transfers that locks the parent 129 - adapter. 130 - 5. M1 feeds the i2c-transfer from step 1 to its parent adapter as a 131 - normal i2c-transfer that locks the parent adapter. 132 - 6. M1 calls ->deselect, if it has one. 133 - 7. Same rules as in step 4, but for ->deselect. 134 - 8. M1 unlocks muxes on its parent. 135 - 136 - This means that accesses to D2 are lockout out for the full duration 137 - of the entire operation. But accesses to D3 are possibly interleaved 138 - at any point. 139 - 140 - 141 - Parent-locked muxes 142 - ------------------- 143 - 144 - Parent-locked muxes lock the parent adapter during the full select- 145 - transfer-deselect transaction. The implication is that the mux driver 146 - has to ensure that any and all i2c transfers through that parent 147 - adapter during the transaction are unlocked i2c transfers (using e.g. 148 - __i2c_transfer), or a deadlock will follow. There are a couple of 149 - caveats. 150 - 151 - PL1. If you build a topology with a parent-locked mux being the child 152 - of another mux, this might break a possible assumption from the 153 - child mux that the root adapter is unused between its select op 154 - and the actual transfer (e.g. if the child mux is auto-closing 155 - and the parent mux issus i2c-transfers as part of its select). 156 - This is especially the case if the parent mux is mux-locked, but 157 - it may also happen if the parent mux is parent-locked. 158 - 159 - PL2. If select/deselect calls out to other subsystems such as gpio, 160 - pinctrl, regmap or iio, it is essential that any i2c transfers 161 - caused by these subsystems are unlocked. This can be convoluted to 162 - accomplish, maybe even impossible if an acceptably clean solution 163 - is sought. 164 - 165 - 166 - Parent-locked Example 167 - --------------------- 168 - 169 - .----------. .--------. 170 - .--------. | parent- |-----| dev D1 | 171 - | root |--+--| locked | '--------' 172 - '--------' | | mux M1 |--. .--------. 173 - | '----------' '--| dev D2 | 174 - | .--------. '--------' 175 - '--| dev D3 | 176 - '--------' 177 - 178 - When there is an access to D1, this happens: 179 - 180 - 1. Someone issues an i2c-transfer to D1. 181 - 2. M1 locks muxes on its parent (the root adapter in this case). 182 - 3. M1 locks its parent adapter. 183 - 4. M1 calls ->select to ready the mux. 184 - 5. If M1 does any i2c-transfers (on this root adapter) as part of 185 - its select, those transfers must be unlocked i2c-transfers so 186 - that they do not deadlock the root adapter. 187 - 6. M1 feeds the i2c-transfer from step 1 to the root adapter as an 188 - unlocked i2c-transfer, so that it does not deadlock the parent 189 - adapter. 190 - 7. M1 calls ->deselect, if it has one. 191 - 8. Same rules as in step 5, but for ->deselect. 192 - 9. M1 unlocks its parent adapter. 193 - 10. M1 unlocks muxes on its parent. 194 - 195 - 196 - This means that accesses to both D2 and D3 are locked out for the full 197 - duration of the entire operation. 198 - 199 - 200 - Complex Examples 201 - ================ 202 - 203 - Parent-locked mux as parent of parent-locked mux 204 - ------------------------------------------------ 205 - 206 - This is a useful topology, but it can be bad. 207 - 208 - .----------. .----------. .--------. 209 - .--------. | parent- |-----| parent- |-----| dev D1 | 210 - | root |--+--| locked | | locked | '--------' 211 - '--------' | | mux M1 |--. | mux M2 |--. .--------. 212 - | '----------' | '----------' '--| dev D2 | 213 - | .--------. | .--------. '--------' 214 - '--| dev D4 | '--| dev D3 | 215 - '--------' '--------' 216 - 217 - When any device is accessed, all other devices are locked out for 218 - the full duration of the operation (both muxes lock their parent, 219 - and specifically when M2 requests its parent to lock, M1 passes 220 - the buck to the root adapter). 221 - 222 - This topology is bad if M2 is an auto-closing mux and M1->select 223 - issues any unlocked i2c transfers on the root adapter that may leak 224 - through and be seen by the M2 adapter, thus closing M2 prematurely. 225 - 226 - 227 - Mux-locked mux as parent of mux-locked mux 228 - ------------------------------------------ 229 - 230 - This is a good topology. 231 - 232 - .----------. .----------. .--------. 233 - .--------. | mux- |-----| mux- |-----| dev D1 | 234 - | root |--+--| locked | | locked | '--------' 235 - '--------' | | mux M1 |--. | mux M2 |--. .--------. 236 - | '----------' | '----------' '--| dev D2 | 237 - | .--------. | .--------. '--------' 238 - '--| dev D4 | '--| dev D3 | 239 - '--------' '--------' 240 - 241 - When device D1 is accessed, accesses to D2 are locked out for the 242 - full duration of the operation (muxes on the top child adapter of M1 243 - are locked). But accesses to D3 and D4 are possibly interleaved at 244 - any point. Accesses to D3 locks out D1 and D2, but accesses to D4 245 - are still possibly interleaved. 246 - 247 - 248 - Mux-locked mux as parent of parent-locked mux 249 - --------------------------------------------- 250 - 251 - This is probably a bad topology. 252 - 253 - .----------. .----------. .--------. 254 - .--------. | mux- |-----| parent- |-----| dev D1 | 255 - | root |--+--| locked | | locked | '--------' 256 - '--------' | | mux M1 |--. | mux M2 |--. .--------. 257 - | '----------' | '----------' '--| dev D2 | 258 - | .--------. | .--------. '--------' 259 - '--| dev D4 | '--| dev D3 | 260 - '--------' '--------' 261 - 262 - When device D1 is accessed, accesses to D2 and D3 are locked out 263 - for the full duration of the operation (M1 locks child muxes on the 264 - root adapter). But accesses to D4 are possibly interleaved at any 265 - point. 266 - 267 - This kind of topology is generally not suitable and should probably 268 - be avoided. The reason is that M2 probably assumes that there will 269 - be no i2c transfers during its calls to ->select and ->deselect, and 270 - if there are, any such transfers might appear on the slave side of M2 271 - as partial i2c transfers, i.e. garbage or worse. This might cause 272 - device lockups and/or other problems. 273 - 274 - The topology is especially troublesome if M2 is an auto-closing 275 - mux. In that case, any interleaved accesses to D4 might close M2 276 - prematurely, as might any i2c-transfers part of M1->select. 277 - 278 - But if M2 is not making the above stated assumption, and if M2 is not 279 - auto-closing, the topology is fine. 280 - 281 - 282 - Parent-locked mux as parent of mux-locked mux 283 - --------------------------------------------- 284 - 285 - This is a good topology. 286 - 287 - .----------. .----------. .--------. 288 - .--------. | parent- |-----| mux- |-----| dev D1 | 289 - | root |--+--| locked | | locked | '--------' 290 - '--------' | | mux M1 |--. | mux M2 |--. .--------. 291 - | '----------' | '----------' '--| dev D2 | 292 - | .--------. | .--------. '--------' 293 - '--| dev D4 | '--| dev D3 | 294 - '--------' '--------' 295 - 296 - When D1 is accessed, accesses to D2 are locked out for the full 297 - duration of the operation (muxes on the top child adapter of M1 298 - are locked). Accesses to D3 and D4 are possibly interleaved at 299 - any point, just as is expected for mux-locked muxes. 300 - 301 - When D3 or D4 are accessed, everything else is locked out. For D3 302 - accesses, M1 locks the root adapter. For D4 accesses, the root 303 - adapter is locked directly. 304 - 305 - 306 - Two mux-locked sibling muxes 307 - ---------------------------- 308 - 309 - This is a good topology. 310 - 311 - .--------. 312 - .----------. .--| dev D1 | 313 - | mux- |--' '--------' 314 - .--| locked | .--------. 315 - | | mux M1 |-----| dev D2 | 316 - | '----------' '--------' 317 - | .----------. .--------. 318 - .--------. | | mux- |-----| dev D3 | 319 - | root |--+--| locked | '--------' 320 - '--------' | | mux M2 |--. .--------. 321 - | '----------' '--| dev D4 | 322 - | .--------. '--------' 323 - '--| dev D5 | 324 - '--------' 325 - 326 - When D1 is accessed, accesses to D2, D3 and D4 are locked out. But 327 - accesses to D5 may be interleaved at any time. 328 - 329 - 330 - Two parent-locked sibling muxes 331 - ------------------------------- 332 - 333 - This is a good topology. 334 - 335 - .--------. 336 - .----------. .--| dev D1 | 337 - | parent- |--' '--------' 338 - .--| locked | .--------. 339 - | | mux M1 |-----| dev D2 | 340 - | '----------' '--------' 341 - | .----------. .--------. 342 - .--------. | | parent- |-----| dev D3 | 343 - | root |--+--| locked | '--------' 344 - '--------' | | mux M2 |--. .--------. 345 - | '----------' '--| dev D4 | 346 - | .--------. '--------' 347 - '--| dev D5 | 348 - '--------' 349 - 350 - When any device is accessed, accesses to all other devices are locked 351 - out. 352 - 353 - 354 - Mux-locked and parent-locked sibling muxes 355 - ------------------------------------------ 356 - 357 - This is a good topology. 358 - 359 - .--------. 360 - .----------. .--| dev D1 | 361 - | mux- |--' '--------' 362 - .--| locked | .--------. 363 - | | mux M1 |-----| dev D2 | 364 - | '----------' '--------' 365 - | .----------. .--------. 366 - .--------. | | parent- |-----| dev D3 | 367 - | root |--+--| locked | '--------' 368 - '--------' | | mux M2 |--. .--------. 369 - | '----------' '--| dev D4 | 370 - | .--------. '--------' 371 - '--| dev D5 | 372 - '--------' 373 - 374 - When D1 or D2 are accessed, accesses to D3 and D4 are locked out while 375 - accesses to D5 may interleave. When D3 or D4 are accessed, accesses to 376 - all other devices are locked out.
+396
Documentation/i2c/i2c-topology.rst
··· 1 + ============ 2 + I2C topology 3 + ============ 4 + 5 + There are a couple of reasons for building more complex i2c topologies 6 + than a straight-forward i2c bus with one adapter and one or more devices. 7 + 8 + 1. A mux may be needed on the bus to prevent address collisions. 9 + 10 + 2. The bus may be accessible from some external bus master, and arbitration 11 + may be needed to determine if it is ok to access the bus. 12 + 13 + 3. A device (particularly RF tuners) may want to avoid the digital noise 14 + from the i2c bus, at least most of the time, and sits behind a gate 15 + that has to be operated before the device can be accessed. 16 + 17 + Etc 18 + === 19 + 20 + These constructs are represented as i2c adapter trees by Linux, where 21 + each adapter has a parent adapter (except the root adapter) and zero or 22 + more child adapters. The root adapter is the actual adapter that issues 23 + i2c transfers, and all adapters with a parent are part of an "i2c-mux" 24 + object (quoted, since it can also be an arbitrator or a gate). 25 + 26 + Depending of the particular mux driver, something happens when there is 27 + an i2c transfer on one of its child adapters. The mux driver can 28 + obviously operate a mux, but it can also do arbitration with an external 29 + bus master or open a gate. The mux driver has two operations for this, 30 + select and deselect. select is called before the transfer and (the 31 + optional) deselect is called after the transfer. 32 + 33 + 34 + Locking 35 + ======= 36 + 37 + There are two variants of locking available to i2c muxes, they can be 38 + mux-locked or parent-locked muxes. As is evident from below, it can be 39 + useful to know if a mux is mux-locked or if it is parent-locked. The 40 + following list was correct at the time of writing: 41 + 42 + In drivers/i2c/muxes/: 43 + 44 + ====================== ============================================= 45 + i2c-arb-gpio-challenge Parent-locked 46 + i2c-mux-gpio Normally parent-locked, mux-locked iff 47 + all involved gpio pins are controlled by the 48 + same i2c root adapter that they mux. 49 + i2c-mux-gpmux Normally parent-locked, mux-locked iff 50 + specified in device-tree. 51 + i2c-mux-ltc4306 Mux-locked 52 + i2c-mux-mlxcpld Parent-locked 53 + i2c-mux-pca9541 Parent-locked 54 + i2c-mux-pca954x Parent-locked 55 + i2c-mux-pinctrl Normally parent-locked, mux-locked iff 56 + all involved pinctrl devices are controlled 57 + by the same i2c root adapter that they mux. 58 + i2c-mux-reg Parent-locked 59 + ====================== ============================================= 60 + 61 + In drivers/iio/: 62 + 63 + ====================== ============================================= 64 + gyro/mpu3050 Mux-locked 65 + imu/inv_mpu6050/ Mux-locked 66 + ====================== ============================================= 67 + 68 + In drivers/media/: 69 + 70 + ======================= ============================================= 71 + dvb-frontends/lgdt3306a Mux-locked 72 + dvb-frontends/m88ds3103 Parent-locked 73 + dvb-frontends/rtl2830 Parent-locked 74 + dvb-frontends/rtl2832 Mux-locked 75 + dvb-frontends/si2168 Mux-locked 76 + usb/cx231xx/ Parent-locked 77 + ======================= ============================================= 78 + 79 + 80 + Mux-locked muxes 81 + ---------------- 82 + 83 + Mux-locked muxes does not lock the entire parent adapter during the 84 + full select-transfer-deselect transaction, only the muxes on the parent 85 + adapter are locked. Mux-locked muxes are mostly interesting if the 86 + select and/or deselect operations must use i2c transfers to complete 87 + their tasks. Since the parent adapter is not fully locked during the 88 + full transaction, unrelated i2c transfers may interleave the different 89 + stages of the transaction. This has the benefit that the mux driver 90 + may be easier and cleaner to implement, but it has some caveats. 91 + 92 + ==== ===================================================================== 93 + ML1. If you build a topology with a mux-locked mux being the parent 94 + of a parent-locked mux, this might break the expectation from the 95 + parent-locked mux that the root adapter is locked during the 96 + transaction. 97 + 98 + ML2. It is not safe to build arbitrary topologies with two (or more) 99 + mux-locked muxes that are not siblings, when there are address 100 + collisions between the devices on the child adapters of these 101 + non-sibling muxes. 102 + 103 + I.e. the select-transfer-deselect transaction targeting e.g. device 104 + address 0x42 behind mux-one may be interleaved with a similar 105 + operation targeting device address 0x42 behind mux-two. The 106 + intension with such a topology would in this hypothetical example 107 + be that mux-one and mux-two should not be selected simultaneously, 108 + but mux-locked muxes do not guarantee that in all topologies. 109 + 110 + ML3. A mux-locked mux cannot be used by a driver for auto-closing 111 + gates/muxes, i.e. something that closes automatically after a given 112 + number (one, in most cases) of i2c transfers. Unrelated i2c transfers 113 + may creep in and close prematurely. 114 + 115 + ML4. If any non-i2c operation in the mux driver changes the i2c mux state, 116 + the driver has to lock the root adapter during that operation. 117 + Otherwise garbage may appear on the bus as seen from devices 118 + behind the mux, when an unrelated i2c transfer is in flight during 119 + the non-i2c mux-changing operation. 120 + ==== ===================================================================== 121 + 122 + 123 + Mux-locked Example 124 + ------------------ 125 + 126 + 127 + :: 128 + 129 + .----------. .--------. 130 + .--------. | mux- |-----| dev D1 | 131 + | root |--+--| locked | '--------' 132 + '--------' | | mux M1 |--. .--------. 133 + | '----------' '--| dev D2 | 134 + | .--------. '--------' 135 + '--| dev D3 | 136 + '--------' 137 + 138 + When there is an access to D1, this happens: 139 + 140 + 1. Someone issues an i2c-transfer to D1. 141 + 2. M1 locks muxes on its parent (the root adapter in this case). 142 + 3. M1 calls ->select to ready the mux. 143 + 4. M1 (presumably) does some i2c-transfers as part of its select. 144 + These transfers are normal i2c-transfers that locks the parent 145 + adapter. 146 + 5. M1 feeds the i2c-transfer from step 1 to its parent adapter as a 147 + normal i2c-transfer that locks the parent adapter. 148 + 6. M1 calls ->deselect, if it has one. 149 + 7. Same rules as in step 4, but for ->deselect. 150 + 8. M1 unlocks muxes on its parent. 151 + 152 + This means that accesses to D2 are lockout out for the full duration 153 + of the entire operation. But accesses to D3 are possibly interleaved 154 + at any point. 155 + 156 + 157 + Parent-locked muxes 158 + ------------------- 159 + 160 + Parent-locked muxes lock the parent adapter during the full select- 161 + transfer-deselect transaction. The implication is that the mux driver 162 + has to ensure that any and all i2c transfers through that parent 163 + adapter during the transaction are unlocked i2c transfers (using e.g. 164 + __i2c_transfer), or a deadlock will follow. There are a couple of 165 + caveats. 166 + 167 + ==== ==================================================================== 168 + PL1. If you build a topology with a parent-locked mux being the child 169 + of another mux, this might break a possible assumption from the 170 + child mux that the root adapter is unused between its select op 171 + and the actual transfer (e.g. if the child mux is auto-closing 172 + and the parent mux issus i2c-transfers as part of its select). 173 + This is especially the case if the parent mux is mux-locked, but 174 + it may also happen if the parent mux is parent-locked. 175 + 176 + PL2. If select/deselect calls out to other subsystems such as gpio, 177 + pinctrl, regmap or iio, it is essential that any i2c transfers 178 + caused by these subsystems are unlocked. This can be convoluted to 179 + accomplish, maybe even impossible if an acceptably clean solution 180 + is sought. 181 + ==== ==================================================================== 182 + 183 + 184 + Parent-locked Example 185 + --------------------- 186 + 187 + :: 188 + 189 + .----------. .--------. 190 + .--------. | parent- |-----| dev D1 | 191 + | root |--+--| locked | '--------' 192 + '--------' | | mux M1 |--. .--------. 193 + | '----------' '--| dev D2 | 194 + | .--------. '--------' 195 + '--| dev D3 | 196 + '--------' 197 + 198 + When there is an access to D1, this happens: 199 + 200 + 1. Someone issues an i2c-transfer to D1. 201 + 2. M1 locks muxes on its parent (the root adapter in this case). 202 + 3. M1 locks its parent adapter. 203 + 4. M1 calls ->select to ready the mux. 204 + 5. If M1 does any i2c-transfers (on this root adapter) as part of 205 + its select, those transfers must be unlocked i2c-transfers so 206 + that they do not deadlock the root adapter. 207 + 6. M1 feeds the i2c-transfer from step 1 to the root adapter as an 208 + unlocked i2c-transfer, so that it does not deadlock the parent 209 + adapter. 210 + 7. M1 calls ->deselect, if it has one. 211 + 8. Same rules as in step 5, but for ->deselect. 212 + 9. M1 unlocks its parent adapter. 213 + 10. M1 unlocks muxes on its parent. 214 + 215 + 216 + This means that accesses to both D2 and D3 are locked out for the full 217 + duration of the entire operation. 218 + 219 + 220 + Complex Examples 221 + ================ 222 + 223 + Parent-locked mux as parent of parent-locked mux 224 + ------------------------------------------------ 225 + 226 + This is a useful topology, but it can be bad:: 227 + 228 + .----------. .----------. .--------. 229 + .--------. | parent- |-----| parent- |-----| dev D1 | 230 + | root |--+--| locked | | locked | '--------' 231 + '--------' | | mux M1 |--. | mux M2 |--. .--------. 232 + | '----------' | '----------' '--| dev D2 | 233 + | .--------. | .--------. '--------' 234 + '--| dev D4 | '--| dev D3 | 235 + '--------' '--------' 236 + 237 + When any device is accessed, all other devices are locked out for 238 + the full duration of the operation (both muxes lock their parent, 239 + and specifically when M2 requests its parent to lock, M1 passes 240 + the buck to the root adapter). 241 + 242 + This topology is bad if M2 is an auto-closing mux and M1->select 243 + issues any unlocked i2c transfers on the root adapter that may leak 244 + through and be seen by the M2 adapter, thus closing M2 prematurely. 245 + 246 + 247 + Mux-locked mux as parent of mux-locked mux 248 + ------------------------------------------ 249 + 250 + This is a good topology:: 251 + 252 + .----------. .----------. .--------. 253 + .--------. | mux- |-----| mux- |-----| dev D1 | 254 + | root |--+--| locked | | locked | '--------' 255 + '--------' | | mux M1 |--. | mux M2 |--. .--------. 256 + | '----------' | '----------' '--| dev D2 | 257 + | .--------. | .--------. '--------' 258 + '--| dev D4 | '--| dev D3 | 259 + '--------' '--------' 260 + 261 + When device D1 is accessed, accesses to D2 are locked out for the 262 + full duration of the operation (muxes on the top child adapter of M1 263 + are locked). But accesses to D3 and D4 are possibly interleaved at 264 + any point. Accesses to D3 locks out D1 and D2, but accesses to D4 265 + are still possibly interleaved. 266 + 267 + 268 + Mux-locked mux as parent of parent-locked mux 269 + --------------------------------------------- 270 + 271 + This is probably a bad topology:: 272 + 273 + .----------. .----------. .--------. 274 + .--------. | mux- |-----| parent- |-----| dev D1 | 275 + | root |--+--| locked | | locked | '--------' 276 + '--------' | | mux M1 |--. | mux M2 |--. .--------. 277 + | '----------' | '----------' '--| dev D2 | 278 + | .--------. | .--------. '--------' 279 + '--| dev D4 | '--| dev D3 | 280 + '--------' '--------' 281 + 282 + When device D1 is accessed, accesses to D2 and D3 are locked out 283 + for the full duration of the operation (M1 locks child muxes on the 284 + root adapter). But accesses to D4 are possibly interleaved at any 285 + point. 286 + 287 + This kind of topology is generally not suitable and should probably 288 + be avoided. The reason is that M2 probably assumes that there will 289 + be no i2c transfers during its calls to ->select and ->deselect, and 290 + if there are, any such transfers might appear on the slave side of M2 291 + as partial i2c transfers, i.e. garbage or worse. This might cause 292 + device lockups and/or other problems. 293 + 294 + The topology is especially troublesome if M2 is an auto-closing 295 + mux. In that case, any interleaved accesses to D4 might close M2 296 + prematurely, as might any i2c-transfers part of M1->select. 297 + 298 + But if M2 is not making the above stated assumption, and if M2 is not 299 + auto-closing, the topology is fine. 300 + 301 + 302 + Parent-locked mux as parent of mux-locked mux 303 + --------------------------------------------- 304 + 305 + This is a good topology:: 306 + 307 + .----------. .----------. .--------. 308 + .--------. | parent- |-----| mux- |-----| dev D1 | 309 + | root |--+--| locked | | locked | '--------' 310 + '--------' | | mux M1 |--. | mux M2 |--. .--------. 311 + | '----------' | '----------' '--| dev D2 | 312 + | .--------. | .--------. '--------' 313 + '--| dev D4 | '--| dev D3 | 314 + '--------' '--------' 315 + 316 + When D1 is accessed, accesses to D2 are locked out for the full 317 + duration of the operation (muxes on the top child adapter of M1 318 + are locked). Accesses to D3 and D4 are possibly interleaved at 319 + any point, just as is expected for mux-locked muxes. 320 + 321 + When D3 or D4 are accessed, everything else is locked out. For D3 322 + accesses, M1 locks the root adapter. For D4 accesses, the root 323 + adapter is locked directly. 324 + 325 + 326 + Two mux-locked sibling muxes 327 + ---------------------------- 328 + 329 + This is a good topology:: 330 + 331 + .--------. 332 + .----------. .--| dev D1 | 333 + | mux- |--' '--------' 334 + .--| locked | .--------. 335 + | | mux M1 |-----| dev D2 | 336 + | '----------' '--------' 337 + | .----------. .--------. 338 + .--------. | | mux- |-----| dev D3 | 339 + | root |--+--| locked | '--------' 340 + '--------' | | mux M2 |--. .--------. 341 + | '----------' '--| dev D4 | 342 + | .--------. '--------' 343 + '--| dev D5 | 344 + '--------' 345 + 346 + When D1 is accessed, accesses to D2, D3 and D4 are locked out. But 347 + accesses to D5 may be interleaved at any time. 348 + 349 + 350 + Two parent-locked sibling muxes 351 + ------------------------------- 352 + 353 + This is a good topology:: 354 + 355 + .--------. 356 + .----------. .--| dev D1 | 357 + | parent- |--' '--------' 358 + .--| locked | .--------. 359 + | | mux M1 |-----| dev D2 | 360 + | '----------' '--------' 361 + | .----------. .--------. 362 + .--------. | | parent- |-----| dev D3 | 363 + | root |--+--| locked | '--------' 364 + '--------' | | mux M2 |--. .--------. 365 + | '----------' '--| dev D4 | 366 + | .--------. '--------' 367 + '--| dev D5 | 368 + '--------' 369 + 370 + When any device is accessed, accesses to all other devices are locked 371 + out. 372 + 373 + 374 + Mux-locked and parent-locked sibling muxes 375 + ------------------------------------------ 376 + 377 + This is a good topology:: 378 + 379 + .--------. 380 + .----------. .--| dev D1 | 381 + | mux- |--' '--------' 382 + .--| locked | .--------. 383 + | | mux M1 |-----| dev D2 | 384 + | '----------' '--------' 385 + | .----------. .--------. 386 + .--------. | | parent- |-----| dev D3 | 387 + | root |--+--| locked | '--------' 388 + '--------' | | mux M2 |--. .--------. 389 + | '----------' '--| dev D4 | 390 + | .--------. '--------' 391 + '--| dev D5 | 392 + '--------' 393 + 394 + When D1 or D2 are accessed, accesses to D3 and D4 are locked out while 395 + accesses to D5 may interleave. When D3 or D4 are accessed, accesses to 396 + all other devices are locked out.
+37
Documentation/i2c/index.rst
··· 1 + . SPDX-License-Identifier: GPL-2.0 2 + 3 + =================== 4 + I2C/SMBus Subsystem 5 + =================== 6 + 7 + .. toctree:: 8 + :maxdepth: 1 9 + 10 + dev-interface 11 + dma-considerations 12 + fault-codes 13 + functionality 14 + gpio-fault-injection 15 + i2c-protocol 16 + i2c-stub 17 + i2c-topology 18 + instantiating-devices 19 + old-module-parameters 20 + slave-eeprom-backend 21 + slave-interface 22 + smbus-protocol 23 + summary 24 + ten-bit-addresses 25 + upgrading-clients 26 + writing-clients 27 + 28 + muxes/i2c-mux-gpio 29 + 30 + busses/index 31 + 32 + .. only:: subproject and html 33 + 34 + Indices 35 + ======= 36 + 37 + * :ref:`genindex`
-248
Documentation/i2c/instantiating-devices
··· 1 - How to instantiate I2C devices 2 - ============================== 3 - 4 - Unlike PCI or USB devices, I2C devices are not enumerated at the hardware 5 - level. Instead, the software must know which devices are connected on each 6 - I2C bus segment, and what address these devices are using. For this 7 - reason, the kernel code must instantiate I2C devices explicitly. There are 8 - several ways to achieve this, depending on the context and requirements. 9 - 10 - 11 - Method 1a: Declare the I2C devices by bus number 12 - ------------------------------------------------ 13 - 14 - This method is appropriate when the I2C bus is a system bus as is the case 15 - for many embedded systems. On such systems, each I2C bus has a number 16 - which is known in advance. It is thus possible to pre-declare the I2C 17 - devices which live on this bus. This is done with an array of struct 18 - i2c_board_info which is registered by calling i2c_register_board_info(). 19 - 20 - Example (from omap2 h4): 21 - 22 - static struct i2c_board_info h4_i2c_board_info[] __initdata = { 23 - { 24 - I2C_BOARD_INFO("isp1301_omap", 0x2d), 25 - .irq = OMAP_GPIO_IRQ(125), 26 - }, 27 - { /* EEPROM on mainboard */ 28 - I2C_BOARD_INFO("24c01", 0x52), 29 - .platform_data = &m24c01, 30 - }, 31 - { /* EEPROM on cpu card */ 32 - I2C_BOARD_INFO("24c01", 0x57), 33 - .platform_data = &m24c01, 34 - }, 35 - }; 36 - 37 - static void __init omap_h4_init(void) 38 - { 39 - (...) 40 - i2c_register_board_info(1, h4_i2c_board_info, 41 - ARRAY_SIZE(h4_i2c_board_info)); 42 - (...) 43 - } 44 - 45 - The above code declares 3 devices on I2C bus 1, including their respective 46 - addresses and custom data needed by their drivers. When the I2C bus in 47 - question is registered, the I2C devices will be instantiated automatically 48 - by i2c-core. 49 - 50 - The devices will be automatically unbound and destroyed when the I2C bus 51 - they sit on goes away (if ever.) 52 - 53 - 54 - Method 1b: Declare the I2C devices via devicetree 55 - ------------------------------------------------- 56 - 57 - This method has the same implications as method 1a. The declaration of I2C 58 - devices is here done via devicetree as subnodes of the master controller. 59 - 60 - Example: 61 - 62 - i2c1: i2c@400a0000 { 63 - /* ... master properties skipped ... */ 64 - clock-frequency = <100000>; 65 - 66 - flash@50 { 67 - compatible = "atmel,24c256"; 68 - reg = <0x50>; 69 - }; 70 - 71 - pca9532: gpio@60 { 72 - compatible = "nxp,pca9532"; 73 - gpio-controller; 74 - #gpio-cells = <2>; 75 - reg = <0x60>; 76 - }; 77 - }; 78 - 79 - Here, two devices are attached to the bus using a speed of 100kHz. For 80 - additional properties which might be needed to set up the device, please refer 81 - to its devicetree documentation in Documentation/devicetree/bindings/. 82 - 83 - 84 - Method 1c: Declare the I2C devices via ACPI 85 - ------------------------------------------- 86 - 87 - ACPI can also describe I2C devices. There is special documentation for this 88 - which is currently located at Documentation/firmware-guide/acpi/enumeration.rst. 89 - 90 - 91 - Method 2: Instantiate the devices explicitly 92 - -------------------------------------------- 93 - 94 - This method is appropriate when a larger device uses an I2C bus for 95 - internal communication. A typical case is TV adapters. These can have a 96 - tuner, a video decoder, an audio decoder, etc. usually connected to the 97 - main chip by the means of an I2C bus. You won't know the number of the I2C 98 - bus in advance, so the method 1 described above can't be used. Instead, 99 - you can instantiate your I2C devices explicitly. This is done by filling 100 - a struct i2c_board_info and calling i2c_new_device(). 101 - 102 - Example (from the sfe4001 network driver): 103 - 104 - static struct i2c_board_info sfe4001_hwmon_info = { 105 - I2C_BOARD_INFO("max6647", 0x4e), 106 - }; 107 - 108 - int sfe4001_init(struct efx_nic *efx) 109 - { 110 - (...) 111 - efx->board_info.hwmon_client = 112 - i2c_new_device(&efx->i2c_adap, &sfe4001_hwmon_info); 113 - 114 - (...) 115 - } 116 - 117 - The above code instantiates 1 I2C device on the I2C bus which is on the 118 - network adapter in question. 119 - 120 - A variant of this is when you don't know for sure if an I2C device is 121 - present or not (for example for an optional feature which is not present 122 - on cheap variants of a board but you have no way to tell them apart), or 123 - it may have different addresses from one board to the next (manufacturer 124 - changing its design without notice). In this case, you can call 125 - i2c_new_probed_device() instead of i2c_new_device(). 126 - 127 - Example (from the nxp OHCI driver): 128 - 129 - static const unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; 130 - 131 - static int usb_hcd_nxp_probe(struct platform_device *pdev) 132 - { 133 - (...) 134 - struct i2c_adapter *i2c_adap; 135 - struct i2c_board_info i2c_info; 136 - 137 - (...) 138 - i2c_adap = i2c_get_adapter(2); 139 - memset(&i2c_info, 0, sizeof(struct i2c_board_info)); 140 - strscpy(i2c_info.type, "isp1301_nxp", sizeof(i2c_info.type)); 141 - isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info, 142 - normal_i2c, NULL); 143 - i2c_put_adapter(i2c_adap); 144 - (...) 145 - } 146 - 147 - The above code instantiates up to 1 I2C device on the I2C bus which is on 148 - the OHCI adapter in question. It first tries at address 0x2c, if nothing 149 - is found there it tries address 0x2d, and if still nothing is found, it 150 - simply gives up. 151 - 152 - The driver which instantiated the I2C device is responsible for destroying 153 - it on cleanup. This is done by calling i2c_unregister_device() on the 154 - pointer that was earlier returned by i2c_new_device() or 155 - i2c_new_probed_device(). 156 - 157 - 158 - Method 3: Probe an I2C bus for certain devices 159 - ---------------------------------------------- 160 - 161 - Sometimes you do not have enough information about an I2C device, not even 162 - to call i2c_new_probed_device(). The typical case is hardware monitoring 163 - chips on PC mainboards. There are several dozen models, which can live 164 - at 25 different addresses. Given the huge number of mainboards out there, 165 - it is next to impossible to build an exhaustive list of the hardware 166 - monitoring chips being used. Fortunately, most of these chips have 167 - manufacturer and device ID registers, so they can be identified by 168 - probing. 169 - 170 - In that case, I2C devices are neither declared nor instantiated 171 - explicitly. Instead, i2c-core will probe for such devices as soon as their 172 - drivers are loaded, and if any is found, an I2C device will be 173 - instantiated automatically. In order to prevent any misbehavior of this 174 - mechanism, the following restrictions apply: 175 - * The I2C device driver must implement the detect() method, which 176 - identifies a supported device by reading from arbitrary registers. 177 - * Only buses which are likely to have a supported device and agree to be 178 - probed, will be probed. For example this avoids probing for hardware 179 - monitoring chips on a TV adapter. 180 - 181 - Example: 182 - See lm90_driver and lm90_detect() in drivers/hwmon/lm90.c 183 - 184 - I2C devices instantiated as a result of such a successful probe will be 185 - destroyed automatically when the driver which detected them is removed, 186 - or when the underlying I2C bus is itself destroyed, whichever happens 187 - first. 188 - 189 - Those of you familiar with the i2c subsystem of 2.4 kernels and early 2.6 190 - kernels will find out that this method 3 is essentially similar to what 191 - was done there. Two significant differences are: 192 - * Probing is only one way to instantiate I2C devices now, while it was the 193 - only way back then. Where possible, methods 1 and 2 should be preferred. 194 - Method 3 should only be used when there is no other way, as it can have 195 - undesirable side effects. 196 - * I2C buses must now explicitly say which I2C driver classes can probe 197 - them (by the means of the class bitfield), while all I2C buses were 198 - probed by default back then. The default is an empty class which means 199 - that no probing happens. The purpose of the class bitfield is to limit 200 - the aforementioned undesirable side effects. 201 - 202 - Once again, method 3 should be avoided wherever possible. Explicit device 203 - instantiation (methods 1 and 2) is much preferred for it is safer and 204 - faster. 205 - 206 - 207 - Method 4: Instantiate from user-space 208 - ------------------------------------- 209 - 210 - In general, the kernel should know which I2C devices are connected and 211 - what addresses they live at. However, in certain cases, it does not, so a 212 - sysfs interface was added to let the user provide the information. This 213 - interface is made of 2 attribute files which are created in every I2C bus 214 - directory: new_device and delete_device. Both files are write only and you 215 - must write the right parameters to them in order to properly instantiate, 216 - respectively delete, an I2C device. 217 - 218 - File new_device takes 2 parameters: the name of the I2C device (a string) 219 - and the address of the I2C device (a number, typically expressed in 220 - hexadecimal starting with 0x, but can also be expressed in decimal.) 221 - 222 - File delete_device takes a single parameter: the address of the I2C 223 - device. As no two devices can live at the same address on a given I2C 224 - segment, the address is sufficient to uniquely identify the device to be 225 - deleted. 226 - 227 - Example: 228 - # echo eeprom 0x50 > /sys/bus/i2c/devices/i2c-3/new_device 229 - 230 - While this interface should only be used when in-kernel device declaration 231 - can't be done, there is a variety of cases where it can be helpful: 232 - * The I2C driver usually detects devices (method 3 above) but the bus 233 - segment your device lives on doesn't have the proper class bit set and 234 - thus detection doesn't trigger. 235 - * The I2C driver usually detects devices, but your device lives at an 236 - unexpected address. 237 - * The I2C driver usually detects devices, but your device is not detected, 238 - either because the detection routine is too strict, or because your 239 - device is not officially supported yet but you know it is compatible. 240 - * You are developing a driver on a test board, where you soldered the I2C 241 - device yourself. 242 - 243 - This interface is a replacement for the force_* module parameters some I2C 244 - drivers implement. Being implemented in i2c-core rather than in each 245 - device driver individually, it is much more efficient, and also has the 246 - advantage that you do not have to reload the driver to change a setting. 247 - You can also instantiate the device before the driver is loaded or even 248 - available, and you don't need to know what driver the device needs.
+253
Documentation/i2c/instantiating-devices.rst
··· 1 + ============================== 2 + How to instantiate I2C devices 3 + ============================== 4 + 5 + Unlike PCI or USB devices, I2C devices are not enumerated at the hardware 6 + level. Instead, the software must know which devices are connected on each 7 + I2C bus segment, and what address these devices are using. For this 8 + reason, the kernel code must instantiate I2C devices explicitly. There are 9 + several ways to achieve this, depending on the context and requirements. 10 + 11 + 12 + Method 1a: Declare the I2C devices by bus number 13 + ------------------------------------------------ 14 + 15 + This method is appropriate when the I2C bus is a system bus as is the case 16 + for many embedded systems. On such systems, each I2C bus has a number 17 + which is known in advance. It is thus possible to pre-declare the I2C 18 + devices which live on this bus. This is done with an array of struct 19 + i2c_board_info which is registered by calling i2c_register_board_info(). 20 + 21 + Example (from omap2 h4):: 22 + 23 + static struct i2c_board_info h4_i2c_board_info[] __initdata = { 24 + { 25 + I2C_BOARD_INFO("isp1301_omap", 0x2d), 26 + .irq = OMAP_GPIO_IRQ(125), 27 + }, 28 + { /* EEPROM on mainboard */ 29 + I2C_BOARD_INFO("24c01", 0x52), 30 + .platform_data = &m24c01, 31 + }, 32 + { /* EEPROM on cpu card */ 33 + I2C_BOARD_INFO("24c01", 0x57), 34 + .platform_data = &m24c01, 35 + }, 36 + }; 37 + 38 + static void __init omap_h4_init(void) 39 + { 40 + (...) 41 + i2c_register_board_info(1, h4_i2c_board_info, 42 + ARRAY_SIZE(h4_i2c_board_info)); 43 + (...) 44 + } 45 + 46 + The above code declares 3 devices on I2C bus 1, including their respective 47 + addresses and custom data needed by their drivers. When the I2C bus in 48 + question is registered, the I2C devices will be instantiated automatically 49 + by i2c-core. 50 + 51 + The devices will be automatically unbound and destroyed when the I2C bus 52 + they sit on goes away (if ever.) 53 + 54 + 55 + Method 1b: Declare the I2C devices via devicetree 56 + ------------------------------------------------- 57 + 58 + This method has the same implications as method 1a. The declaration of I2C 59 + devices is here done via devicetree as subnodes of the master controller. 60 + 61 + Example:: 62 + 63 + i2c1: i2c@400a0000 { 64 + /* ... master properties skipped ... */ 65 + clock-frequency = <100000>; 66 + 67 + flash@50 { 68 + compatible = "atmel,24c256"; 69 + reg = <0x50>; 70 + }; 71 + 72 + pca9532: gpio@60 { 73 + compatible = "nxp,pca9532"; 74 + gpio-controller; 75 + #gpio-cells = <2>; 76 + reg = <0x60>; 77 + }; 78 + }; 79 + 80 + Here, two devices are attached to the bus using a speed of 100kHz. For 81 + additional properties which might be needed to set up the device, please refer 82 + to its devicetree documentation in Documentation/devicetree/bindings/. 83 + 84 + 85 + Method 1c: Declare the I2C devices via ACPI 86 + ------------------------------------------- 87 + 88 + ACPI can also describe I2C devices. There is special documentation for this 89 + which is currently located at Documentation/firmware-guide/acpi/enumeration.rst. 90 + 91 + 92 + Method 2: Instantiate the devices explicitly 93 + -------------------------------------------- 94 + 95 + This method is appropriate when a larger device uses an I2C bus for 96 + internal communication. A typical case is TV adapters. These can have a 97 + tuner, a video decoder, an audio decoder, etc. usually connected to the 98 + main chip by the means of an I2C bus. You won't know the number of the I2C 99 + bus in advance, so the method 1 described above can't be used. Instead, 100 + you can instantiate your I2C devices explicitly. This is done by filling 101 + a struct i2c_board_info and calling i2c_new_device(). 102 + 103 + Example (from the sfe4001 network driver):: 104 + 105 + static struct i2c_board_info sfe4001_hwmon_info = { 106 + I2C_BOARD_INFO("max6647", 0x4e), 107 + }; 108 + 109 + int sfe4001_init(struct efx_nic *efx) 110 + { 111 + (...) 112 + efx->board_info.hwmon_client = 113 + i2c_new_device(&efx->i2c_adap, &sfe4001_hwmon_info); 114 + 115 + (...) 116 + } 117 + 118 + The above code instantiates 1 I2C device on the I2C bus which is on the 119 + network adapter in question. 120 + 121 + A variant of this is when you don't know for sure if an I2C device is 122 + present or not (for example for an optional feature which is not present 123 + on cheap variants of a board but you have no way to tell them apart), or 124 + it may have different addresses from one board to the next (manufacturer 125 + changing its design without notice). In this case, you can call 126 + i2c_new_probed_device() instead of i2c_new_device(). 127 + 128 + Example (from the nxp OHCI driver):: 129 + 130 + static const unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; 131 + 132 + static int usb_hcd_nxp_probe(struct platform_device *pdev) 133 + { 134 + (...) 135 + struct i2c_adapter *i2c_adap; 136 + struct i2c_board_info i2c_info; 137 + 138 + (...) 139 + i2c_adap = i2c_get_adapter(2); 140 + memset(&i2c_info, 0, sizeof(struct i2c_board_info)); 141 + strscpy(i2c_info.type, "isp1301_nxp", sizeof(i2c_info.type)); 142 + isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info, 143 + normal_i2c, NULL); 144 + i2c_put_adapter(i2c_adap); 145 + (...) 146 + } 147 + 148 + The above code instantiates up to 1 I2C device on the I2C bus which is on 149 + the OHCI adapter in question. It first tries at address 0x2c, if nothing 150 + is found there it tries address 0x2d, and if still nothing is found, it 151 + simply gives up. 152 + 153 + The driver which instantiated the I2C device is responsible for destroying 154 + it on cleanup. This is done by calling i2c_unregister_device() on the 155 + pointer that was earlier returned by i2c_new_device() or 156 + i2c_new_probed_device(). 157 + 158 + 159 + Method 3: Probe an I2C bus for certain devices 160 + ---------------------------------------------- 161 + 162 + Sometimes you do not have enough information about an I2C device, not even 163 + to call i2c_new_probed_device(). The typical case is hardware monitoring 164 + chips on PC mainboards. There are several dozen models, which can live 165 + at 25 different addresses. Given the huge number of mainboards out there, 166 + it is next to impossible to build an exhaustive list of the hardware 167 + monitoring chips being used. Fortunately, most of these chips have 168 + manufacturer and device ID registers, so they can be identified by 169 + probing. 170 + 171 + In that case, I2C devices are neither declared nor instantiated 172 + explicitly. Instead, i2c-core will probe for such devices as soon as their 173 + drivers are loaded, and if any is found, an I2C device will be 174 + instantiated automatically. In order to prevent any misbehavior of this 175 + mechanism, the following restrictions apply: 176 + 177 + * The I2C device driver must implement the detect() method, which 178 + identifies a supported device by reading from arbitrary registers. 179 + * Only buses which are likely to have a supported device and agree to be 180 + probed, will be probed. For example this avoids probing for hardware 181 + monitoring chips on a TV adapter. 182 + 183 + Example: 184 + See lm90_driver and lm90_detect() in drivers/hwmon/lm90.c 185 + 186 + I2C devices instantiated as a result of such a successful probe will be 187 + destroyed automatically when the driver which detected them is removed, 188 + or when the underlying I2C bus is itself destroyed, whichever happens 189 + first. 190 + 191 + Those of you familiar with the i2c subsystem of 2.4 kernels and early 2.6 192 + kernels will find out that this method 3 is essentially similar to what 193 + was done there. Two significant differences are: 194 + 195 + * Probing is only one way to instantiate I2C devices now, while it was the 196 + only way back then. Where possible, methods 1 and 2 should be preferred. 197 + Method 3 should only be used when there is no other way, as it can have 198 + undesirable side effects. 199 + * I2C buses must now explicitly say which I2C driver classes can probe 200 + them (by the means of the class bitfield), while all I2C buses were 201 + probed by default back then. The default is an empty class which means 202 + that no probing happens. The purpose of the class bitfield is to limit 203 + the aforementioned undesirable side effects. 204 + 205 + Once again, method 3 should be avoided wherever possible. Explicit device 206 + instantiation (methods 1 and 2) is much preferred for it is safer and 207 + faster. 208 + 209 + 210 + Method 4: Instantiate from user-space 211 + ------------------------------------- 212 + 213 + In general, the kernel should know which I2C devices are connected and 214 + what addresses they live at. However, in certain cases, it does not, so a 215 + sysfs interface was added to let the user provide the information. This 216 + interface is made of 2 attribute files which are created in every I2C bus 217 + directory: new_device and delete_device. Both files are write only and you 218 + must write the right parameters to them in order to properly instantiate, 219 + respectively delete, an I2C device. 220 + 221 + File new_device takes 2 parameters: the name of the I2C device (a string) 222 + and the address of the I2C device (a number, typically expressed in 223 + hexadecimal starting with 0x, but can also be expressed in decimal.) 224 + 225 + File delete_device takes a single parameter: the address of the I2C 226 + device. As no two devices can live at the same address on a given I2C 227 + segment, the address is sufficient to uniquely identify the device to be 228 + deleted. 229 + 230 + Example:: 231 + 232 + # echo eeprom 0x50 > /sys/bus/i2c/devices/i2c-3/new_device 233 + 234 + While this interface should only be used when in-kernel device declaration 235 + can't be done, there is a variety of cases where it can be helpful: 236 + 237 + * The I2C driver usually detects devices (method 3 above) but the bus 238 + segment your device lives on doesn't have the proper class bit set and 239 + thus detection doesn't trigger. 240 + * The I2C driver usually detects devices, but your device lives at an 241 + unexpected address. 242 + * The I2C driver usually detects devices, but your device is not detected, 243 + either because the detection routine is too strict, or because your 244 + device is not officially supported yet but you know it is compatible. 245 + * You are developing a driver on a test board, where you soldered the I2C 246 + device yourself. 247 + 248 + This interface is a replacement for the force_* module parameters some I2C 249 + drivers implement. Being implemented in i2c-core rather than in each 250 + device driver individually, it is much more efficient, and also has the 251 + advantage that you do not have to reload the driver to change a setting. 252 + You can also instantiate the device before the driver is loaded or even 253 + available, and you don't need to know what driver the device needs.
-83
Documentation/i2c/muxes/i2c-mux-gpio
··· 1 - Kernel driver i2c-mux-gpio 2 - 3 - Author: Peter Korsgaard <peter.korsgaard@barco.com> 4 - 5 - Description 6 - ----------- 7 - 8 - i2c-mux-gpio is an i2c mux driver providing access to I2C bus segments 9 - from a master I2C bus and a hardware MUX controlled through GPIO pins. 10 - 11 - E.G.: 12 - 13 - ---------- ---------- Bus segment 1 - - - - - 14 - | | SCL/SDA | |-------------- | | 15 - | |------------| | 16 - | | | | Bus segment 2 | | 17 - | Linux | GPIO 1..N | MUX |--------------- Devices 18 - | |------------| | | | 19 - | | | | Bus segment M 20 - | | | |---------------| | 21 - ---------- ---------- - - - - - 22 - 23 - SCL/SDA of the master I2C bus is multiplexed to bus segment 1..M 24 - according to the settings of the GPIO pins 1..N. 25 - 26 - Usage 27 - ----- 28 - 29 - i2c-mux-gpio uses the platform bus, so you need to provide a struct 30 - platform_device with the platform_data pointing to a struct 31 - i2c_mux_gpio_platform_data with the I2C adapter number of the master 32 - bus, the number of bus segments to create and the GPIO pins used 33 - to control it. See include/linux/platform_data/i2c-mux-gpio.h for details. 34 - 35 - E.G. something like this for a MUX providing 4 bus segments 36 - controlled through 3 GPIO pins: 37 - 38 - #include <linux/platform_data/i2c-mux-gpio.h> 39 - #include <linux/platform_device.h> 40 - 41 - static const unsigned myboard_gpiomux_gpios[] = { 42 - AT91_PIN_PC26, AT91_PIN_PC25, AT91_PIN_PC24 43 - }; 44 - 45 - static const unsigned myboard_gpiomux_values[] = { 46 - 0, 1, 2, 3 47 - }; 48 - 49 - static struct i2c_mux_gpio_platform_data myboard_i2cmux_data = { 50 - .parent = 1, 51 - .base_nr = 2, /* optional */ 52 - .values = myboard_gpiomux_values, 53 - .n_values = ARRAY_SIZE(myboard_gpiomux_values), 54 - .gpios = myboard_gpiomux_gpios, 55 - .n_gpios = ARRAY_SIZE(myboard_gpiomux_gpios), 56 - .idle = 4, /* optional */ 57 - }; 58 - 59 - static struct platform_device myboard_i2cmux = { 60 - .name = "i2c-mux-gpio", 61 - .id = 0, 62 - .dev = { 63 - .platform_data = &myboard_i2cmux_data, 64 - }, 65 - }; 66 - 67 - If you don't know the absolute GPIO pin numbers at registration time, 68 - you can instead provide a chip name (.chip_name) and relative GPIO pin 69 - numbers, and the i2c-mux-gpio driver will do the work for you, 70 - including deferred probing if the GPIO chip isn't immediately 71 - available. 72 - 73 - Device Registration 74 - ------------------- 75 - 76 - When registering your i2c-mux-gpio device, you should pass the number 77 - of any GPIO pin it uses as the device ID. This guarantees that every 78 - instance has a different ID. 79 - 80 - Alternatively, if you don't need a stable device name, you can simply 81 - pass PLATFORM_DEVID_AUTO as the device ID, and the platform core will 82 - assign a dynamic ID to your device. If you do not know the absolute 83 - GPIO pin numbers at registration time, this is even the only option.
+85
Documentation/i2c/muxes/i2c-mux-gpio.rst
··· 1 + ========================== 2 + Kernel driver i2c-mux-gpio 3 + ========================== 4 + 5 + Author: Peter Korsgaard <peter.korsgaard@barco.com> 6 + 7 + Description 8 + ----------- 9 + 10 + i2c-mux-gpio is an i2c mux driver providing access to I2C bus segments 11 + from a master I2C bus and a hardware MUX controlled through GPIO pins. 12 + 13 + E.G.:: 14 + 15 + ---------- ---------- Bus segment 1 - - - - - 16 + | | SCL/SDA | |-------------- | | 17 + | |------------| | 18 + | | | | Bus segment 2 | | 19 + | Linux | GPIO 1..N | MUX |--------------- Devices 20 + | |------------| | | | 21 + | | | | Bus segment M 22 + | | | |---------------| | 23 + ---------- ---------- - - - - - 24 + 25 + SCL/SDA of the master I2C bus is multiplexed to bus segment 1..M 26 + according to the settings of the GPIO pins 1..N. 27 + 28 + Usage 29 + ----- 30 + 31 + i2c-mux-gpio uses the platform bus, so you need to provide a struct 32 + platform_device with the platform_data pointing to a struct 33 + i2c_mux_gpio_platform_data with the I2C adapter number of the master 34 + bus, the number of bus segments to create and the GPIO pins used 35 + to control it. See include/linux/platform_data/i2c-mux-gpio.h for details. 36 + 37 + E.G. something like this for a MUX providing 4 bus segments 38 + controlled through 3 GPIO pins:: 39 + 40 + #include <linux/platform_data/i2c-mux-gpio.h> 41 + #include <linux/platform_device.h> 42 + 43 + static const unsigned myboard_gpiomux_gpios[] = { 44 + AT91_PIN_PC26, AT91_PIN_PC25, AT91_PIN_PC24 45 + }; 46 + 47 + static const unsigned myboard_gpiomux_values[] = { 48 + 0, 1, 2, 3 49 + }; 50 + 51 + static struct i2c_mux_gpio_platform_data myboard_i2cmux_data = { 52 + .parent = 1, 53 + .base_nr = 2, /* optional */ 54 + .values = myboard_gpiomux_values, 55 + .n_values = ARRAY_SIZE(myboard_gpiomux_values), 56 + .gpios = myboard_gpiomux_gpios, 57 + .n_gpios = ARRAY_SIZE(myboard_gpiomux_gpios), 58 + .idle = 4, /* optional */ 59 + }; 60 + 61 + static struct platform_device myboard_i2cmux = { 62 + .name = "i2c-mux-gpio", 63 + .id = 0, 64 + .dev = { 65 + .platform_data = &myboard_i2cmux_data, 66 + }, 67 + }; 68 + 69 + If you don't know the absolute GPIO pin numbers at registration time, 70 + you can instead provide a chip name (.chip_name) and relative GPIO pin 71 + numbers, and the i2c-mux-gpio driver will do the work for you, 72 + including deferred probing if the GPIO chip isn't immediately 73 + available. 74 + 75 + Device Registration 76 + ------------------- 77 + 78 + When registering your i2c-mux-gpio device, you should pass the number 79 + of any GPIO pin it uses as the device ID. This guarantees that every 80 + instance has a different ID. 81 + 82 + Alternatively, if you don't need a stable device name, you can simply 83 + pass PLATFORM_DEVID_AUTO as the device ID, and the platform core will 84 + assign a dynamic ID to your device. If you do not know the absolute 85 + GPIO pin numbers at registration time, this is even the only option.
-44
Documentation/i2c/old-module-parameters
··· 1 - I2C device driver binding control from user-space 2 - ================================================= 3 - 4 - Up to kernel 2.6.32, many i2c drivers used helper macros provided by 5 - <linux/i2c.h> which created standard module parameters to let the user 6 - control how the driver would probe i2c buses and attach to devices. These 7 - parameters were known as "probe" (to let the driver probe for an extra 8 - address), "force" (to forcibly attach the driver to a given device) and 9 - "ignore" (to prevent a driver from probing a given address). 10 - 11 - With the conversion of the i2c subsystem to the standard device driver 12 - binding model, it became clear that these per-module parameters were no 13 - longer needed, and that a centralized implementation was possible. The new, 14 - sysfs-based interface is described in the documentation file 15 - "instantiating-devices", section "Method 4: Instantiate from user-space". 16 - 17 - Below is a mapping from the old module parameters to the new interface. 18 - 19 - Attaching a driver to an I2C device 20 - ----------------------------------- 21 - 22 - Old method (module parameters): 23 - # modprobe <driver> probe=1,0x2d 24 - # modprobe <driver> force=1,0x2d 25 - # modprobe <driver> force_<device>=1,0x2d 26 - 27 - New method (sysfs interface): 28 - # echo <device> 0x2d > /sys/bus/i2c/devices/i2c-1/new_device 29 - 30 - Preventing a driver from attaching to an I2C device 31 - --------------------------------------------------- 32 - 33 - Old method (module parameters): 34 - # modprobe <driver> ignore=1,0x2f 35 - 36 - New method (sysfs interface): 37 - # echo dummy 0x2f > /sys/bus/i2c/devices/i2c-1/new_device 38 - # modprobe <driver> 39 - 40 - Of course, it is important to instantiate the "dummy" device before loading 41 - the driver. The dummy device will be handled by i2c-core itself, preventing 42 - other drivers from binding to it later on. If there is a real device at the 43 - problematic address, and you want another driver to bind to it, then simply 44 - pass the name of the device in question instead of "dummy".
+49
Documentation/i2c/old-module-parameters.rst
··· 1 + ================================================= 2 + I2C device driver binding control from user-space 3 + ================================================= 4 + 5 + Up to kernel 2.6.32, many i2c drivers used helper macros provided by 6 + <linux/i2c.h> which created standard module parameters to let the user 7 + control how the driver would probe i2c buses and attach to devices. These 8 + parameters were known as "probe" (to let the driver probe for an extra 9 + address), "force" (to forcibly attach the driver to a given device) and 10 + "ignore" (to prevent a driver from probing a given address). 11 + 12 + With the conversion of the i2c subsystem to the standard device driver 13 + binding model, it became clear that these per-module parameters were no 14 + longer needed, and that a centralized implementation was possible. The new, 15 + sysfs-based interface is described in the documentation file 16 + "instantiating-devices", section "Method 4: Instantiate from user-space". 17 + 18 + Below is a mapping from the old module parameters to the new interface. 19 + 20 + Attaching a driver to an I2C device 21 + ----------------------------------- 22 + 23 + Old method (module parameters):: 24 + 25 + # modprobe <driver> probe=1,0x2d 26 + # modprobe <driver> force=1,0x2d 27 + # modprobe <driver> force_<device>=1,0x2d 28 + 29 + New method (sysfs interface):: 30 + 31 + # echo <device> 0x2d > /sys/bus/i2c/devices/i2c-1/new_device 32 + 33 + Preventing a driver from attaching to an I2C device 34 + --------------------------------------------------- 35 + 36 + Old method (module parameters):: 37 + 38 + # modprobe <driver> ignore=1,0x2f 39 + 40 + New method (sysfs interface):: 41 + 42 + # echo dummy 0x2f > /sys/bus/i2c/devices/i2c-1/new_device 43 + # modprobe <driver> 44 + 45 + Of course, it is important to instantiate the "dummy" device before loading 46 + the driver. The dummy device will be handled by i2c-core itself, preventing 47 + other drivers from binding to it later on. If there is a real device at the 48 + problematic address, and you want another driver to bind to it, then simply 49 + pass the name of the device in question instead of "dummy".
-14
Documentation/i2c/slave-eeprom-backend
··· 1 - Linux I2C slave eeprom backend 2 - ============================== 3 - 4 - by Wolfram Sang <wsa@sang-engineering.com> in 2014-15 5 - 6 - This is a proof-of-concept backend which acts like an EEPROM on the connected 7 - I2C bus. The memory contents can be modified from userspace via this file 8 - located in sysfs: 9 - 10 - /sys/bus/i2c/devices/<device-directory>/slave-eeprom 11 - 12 - As of 2015, Linux doesn't support poll on binary sysfs files, so there is no 13 - notification when another master changed the content. 14 -
+14
Documentation/i2c/slave-eeprom-backend.rst
··· 1 + ============================== 2 + Linux I2C slave eeprom backend 3 + ============================== 4 + 5 + by Wolfram Sang <wsa@sang-engineering.com> in 2014-15 6 + 7 + This is a proof-of-concept backend which acts like an EEPROM on the connected 8 + I2C bus. The memory contents can be modified from userspace via this file 9 + located in sysfs:: 10 + 11 + /sys/bus/i2c/devices/<device-directory>/slave-eeprom 12 + 13 + As of 2015, Linux doesn't support poll on binary sysfs files, so there is no 14 + notification when another master changed the content.
-193
Documentation/i2c/slave-interface
··· 1 - Linux I2C slave interface description 2 - ===================================== 3 - 4 - by Wolfram Sang <wsa@sang-engineering.com> in 2014-15 5 - 6 - Linux can also be an I2C slave if the I2C controller in use has slave 7 - functionality. For that to work, one needs slave support in the bus driver plus 8 - a hardware independent software backend providing the actual functionality. An 9 - example for the latter is the slave-eeprom driver, which acts as a dual memory 10 - driver. While another I2C master on the bus can access it like a regular 11 - EEPROM, the Linux I2C slave can access the content via sysfs and handle data as 12 - needed. The backend driver and the I2C bus driver communicate via events. Here 13 - is a small graph visualizing the data flow and the means by which data is 14 - transported. The dotted line marks only one example. The backend could also 15 - use a character device, be in-kernel only, or something completely different: 16 - 17 - 18 - e.g. sysfs I2C slave events I/O registers 19 - +-----------+ v +---------+ v +--------+ v +------------+ 20 - | Userspace +........+ Backend +-----------+ Driver +-----+ Controller | 21 - +-----------+ +---------+ +--------+ +------------+ 22 - | | 23 - ----------------------------------------------------------------+-- I2C 24 - --------------------------------------------------------------+---- Bus 25 - 26 - Note: Technically, there is also the I2C core between the backend and the 27 - driver. However, at this time of writing, the layer is transparent. 28 - 29 - 30 - User manual 31 - =========== 32 - 33 - I2C slave backends behave like standard I2C clients. So, you can instantiate 34 - them as described in the document 'instantiating-devices'. The only difference 35 - is that i2c slave backends have their own address space. So, you have to add 36 - 0x1000 to the address you would originally request. An example for 37 - instantiating the slave-eeprom driver from userspace at the 7 bit address 0x64 38 - on bus 1: 39 - 40 - # echo slave-24c02 0x1064 > /sys/bus/i2c/devices/i2c-1/new_device 41 - 42 - Each backend should come with separate documentation to describe its specific 43 - behaviour and setup. 44 - 45 - 46 - Developer manual 47 - ================ 48 - 49 - First, the events which are used by the bus driver and the backend will be 50 - described in detail. After that, some implementation hints for extending bus 51 - drivers and writing backends will be given. 52 - 53 - 54 - I2C slave events 55 - ---------------- 56 - 57 - The bus driver sends an event to the backend using the following function: 58 - 59 - ret = i2c_slave_event(client, event, &val) 60 - 61 - 'client' describes the i2c slave device. 'event' is one of the special event 62 - types described hereafter. 'val' holds an u8 value for the data byte to be 63 - read/written and is thus bidirectional. The pointer to val must always be 64 - provided even if val is not used for an event, i.e. don't use NULL here. 'ret' 65 - is the return value from the backend. Mandatory events must be provided by the 66 - bus drivers and must be checked for by backend drivers. 67 - 68 - Event types: 69 - 70 - * I2C_SLAVE_WRITE_REQUESTED (mandatory) 71 - 72 - 'val': unused 73 - 'ret': always 0 74 - 75 - Another I2C master wants to write data to us. This event should be sent once 76 - our own address and the write bit was detected. The data did not arrive yet, so 77 - there is nothing to process or return. Wakeup or initialization probably needs 78 - to be done, though. 79 - 80 - * I2C_SLAVE_READ_REQUESTED (mandatory) 81 - 82 - 'val': backend returns first byte to be sent 83 - 'ret': always 0 84 - 85 - Another I2C master wants to read data from us. This event should be sent once 86 - our own address and the read bit was detected. After returning, the bus driver 87 - should transmit the first byte. 88 - 89 - * I2C_SLAVE_WRITE_RECEIVED (mandatory) 90 - 91 - 'val': bus driver delivers received byte 92 - 'ret': 0 if the byte should be acked, some errno if the byte should be nacked 93 - 94 - Another I2C master has sent a byte to us which needs to be set in 'val'. If 'ret' 95 - is zero, the bus driver should ack this byte. If 'ret' is an errno, then the byte 96 - should be nacked. 97 - 98 - * I2C_SLAVE_READ_PROCESSED (mandatory) 99 - 100 - 'val': backend returns next byte to be sent 101 - 'ret': always 0 102 - 103 - The bus driver requests the next byte to be sent to another I2C master in 104 - 'val'. Important: This does not mean that the previous byte has been acked, it 105 - only means that the previous byte is shifted out to the bus! To ensure seamless 106 - transmission, most hardware requests the next byte when the previous one is 107 - still shifted out. If the master sends NACK and stops reading after the byte 108 - currently shifted out, this byte requested here is never used. It very likely 109 - needs to be sent again on the next I2C_SLAVE_READ_REQUEST, depending a bit on 110 - your backend, though. 111 - 112 - * I2C_SLAVE_STOP (mandatory) 113 - 114 - 'val': unused 115 - 'ret': always 0 116 - 117 - A stop condition was received. This can happen anytime and the backend should 118 - reset its state machine for I2C transfers to be able to receive new requests. 119 - 120 - 121 - Software backends 122 - ----------------- 123 - 124 - If you want to write a software backend: 125 - 126 - * use a standard i2c_driver and its matching mechanisms 127 - * write the slave_callback which handles the above slave events 128 - (best using a state machine) 129 - * register this callback via i2c_slave_register() 130 - 131 - Check the i2c-slave-eeprom driver as an example. 132 - 133 - 134 - Bus driver support 135 - ------------------ 136 - 137 - If you want to add slave support to the bus driver: 138 - 139 - * implement calls to register/unregister the slave and add those to the 140 - struct i2c_algorithm. When registering, you probably need to set the i2c 141 - slave address and enable slave specific interrupts. If you use runtime pm, you 142 - should use pm_runtime_get_sync() because your device usually needs to be 143 - powered on always to be able to detect its slave address. When unregistering, 144 - do the inverse of the above. 145 - 146 - * Catch the slave interrupts and send appropriate i2c_slave_events to the backend. 147 - 148 - Note that most hardware supports being master _and_ slave on the same bus. So, 149 - if you extend a bus driver, please make sure that the driver supports that as 150 - well. In almost all cases, slave support does not need to disable the master 151 - functionality. 152 - 153 - Check the i2c-rcar driver as an example. 154 - 155 - 156 - About ACK/NACK 157 - -------------- 158 - 159 - It is good behaviour to always ACK the address phase, so the master knows if a 160 - device is basically present or if it mysteriously disappeared. Using NACK to 161 - state being busy is troublesome. SMBus demands to always ACK the address phase, 162 - while the I2C specification is more loose on that. Most I2C controllers also 163 - automatically ACK when detecting their slave addresses, so there is no option 164 - to NACK them. For those reasons, this API does not support NACK in the address 165 - phase. 166 - 167 - Currently, there is no slave event to report if the master did ACK or NACK a 168 - byte when it reads from us. We could make this an optional event if the need 169 - arises. However, cases should be extremely rare because the master is expected 170 - to send STOP after that and we have an event for that. Also, keep in mind not 171 - all I2C controllers have the possibility to report that event. 172 - 173 - 174 - About buffers 175 - ------------- 176 - 177 - During development of this API, the question of using buffers instead of just 178 - bytes came up. Such an extension might be possible, usefulness is unclear at 179 - this time of writing. Some points to keep in mind when using buffers: 180 - 181 - * Buffers should be opt-in and backend drivers will always have to support 182 - byte-based transactions as the ultimate fallback anyhow because this is how 183 - the majority of HW works. 184 - 185 - * For backends simulating hardware registers, buffers are largely not helpful 186 - because after each byte written an action should be immediately triggered. 187 - For reads, the data kept in the buffer might get stale if the backend just 188 - updated a register because of internal processing. 189 - 190 - * A master can send STOP at any time. For partially transferred buffers, this 191 - means additional code to handle this exception. Such code tends to be 192 - error-prone. 193 -
+198
Documentation/i2c/slave-interface.rst
··· 1 + ===================================== 2 + Linux I2C slave interface description 3 + ===================================== 4 + 5 + by Wolfram Sang <wsa@sang-engineering.com> in 2014-15 6 + 7 + Linux can also be an I2C slave if the I2C controller in use has slave 8 + functionality. For that to work, one needs slave support in the bus driver plus 9 + a hardware independent software backend providing the actual functionality. An 10 + example for the latter is the slave-eeprom driver, which acts as a dual memory 11 + driver. While another I2C master on the bus can access it like a regular 12 + EEPROM, the Linux I2C slave can access the content via sysfs and handle data as 13 + needed. The backend driver and the I2C bus driver communicate via events. Here 14 + is a small graph visualizing the data flow and the means by which data is 15 + transported. The dotted line marks only one example. The backend could also 16 + use a character device, be in-kernel only, or something completely different:: 17 + 18 + 19 + e.g. sysfs I2C slave events I/O registers 20 + +-----------+ v +---------+ v +--------+ v +------------+ 21 + | Userspace +........+ Backend +-----------+ Driver +-----+ Controller | 22 + +-----------+ +---------+ +--------+ +------------+ 23 + | | 24 + ----------------------------------------------------------------+-- I2C 25 + --------------------------------------------------------------+---- Bus 26 + 27 + Note: Technically, there is also the I2C core between the backend and the 28 + driver. However, at this time of writing, the layer is transparent. 29 + 30 + 31 + User manual 32 + =========== 33 + 34 + I2C slave backends behave like standard I2C clients. So, you can instantiate 35 + them as described in the document 'instantiating-devices'. The only difference 36 + is that i2c slave backends have their own address space. So, you have to add 37 + 0x1000 to the address you would originally request. An example for 38 + instantiating the slave-eeprom driver from userspace at the 7 bit address 0x64 39 + on bus 1:: 40 + 41 + # echo slave-24c02 0x1064 > /sys/bus/i2c/devices/i2c-1/new_device 42 + 43 + Each backend should come with separate documentation to describe its specific 44 + behaviour and setup. 45 + 46 + 47 + Developer manual 48 + ================ 49 + 50 + First, the events which are used by the bus driver and the backend will be 51 + described in detail. After that, some implementation hints for extending bus 52 + drivers and writing backends will be given. 53 + 54 + 55 + I2C slave events 56 + ---------------- 57 + 58 + The bus driver sends an event to the backend using the following function:: 59 + 60 + ret = i2c_slave_event(client, event, &val) 61 + 62 + 'client' describes the i2c slave device. 'event' is one of the special event 63 + types described hereafter. 'val' holds an u8 value for the data byte to be 64 + read/written and is thus bidirectional. The pointer to val must always be 65 + provided even if val is not used for an event, i.e. don't use NULL here. 'ret' 66 + is the return value from the backend. Mandatory events must be provided by the 67 + bus drivers and must be checked for by backend drivers. 68 + 69 + Event types: 70 + 71 + * I2C_SLAVE_WRITE_REQUESTED (mandatory) 72 + 73 + 'val': unused 74 + 75 + 'ret': always 0 76 + 77 + Another I2C master wants to write data to us. This event should be sent once 78 + our own address and the write bit was detected. The data did not arrive yet, so 79 + there is nothing to process or return. Wakeup or initialization probably needs 80 + to be done, though. 81 + 82 + * I2C_SLAVE_READ_REQUESTED (mandatory) 83 + 84 + 'val': backend returns first byte to be sent 85 + 86 + 'ret': always 0 87 + 88 + Another I2C master wants to read data from us. This event should be sent once 89 + our own address and the read bit was detected. After returning, the bus driver 90 + should transmit the first byte. 91 + 92 + * I2C_SLAVE_WRITE_RECEIVED (mandatory) 93 + 94 + 'val': bus driver delivers received byte 95 + 96 + 'ret': 0 if the byte should be acked, some errno if the byte should be nacked 97 + 98 + Another I2C master has sent a byte to us which needs to be set in 'val'. If 'ret' 99 + is zero, the bus driver should ack this byte. If 'ret' is an errno, then the byte 100 + should be nacked. 101 + 102 + * I2C_SLAVE_READ_PROCESSED (mandatory) 103 + 104 + 'val': backend returns next byte to be sent 105 + 106 + 'ret': always 0 107 + 108 + The bus driver requests the next byte to be sent to another I2C master in 109 + 'val'. Important: This does not mean that the previous byte has been acked, it 110 + only means that the previous byte is shifted out to the bus! To ensure seamless 111 + transmission, most hardware requests the next byte when the previous one is 112 + still shifted out. If the master sends NACK and stops reading after the byte 113 + currently shifted out, this byte requested here is never used. It very likely 114 + needs to be sent again on the next I2C_SLAVE_READ_REQUEST, depending a bit on 115 + your backend, though. 116 + 117 + * I2C_SLAVE_STOP (mandatory) 118 + 119 + 'val': unused 120 + 121 + 'ret': always 0 122 + 123 + A stop condition was received. This can happen anytime and the backend should 124 + reset its state machine for I2C transfers to be able to receive new requests. 125 + 126 + 127 + Software backends 128 + ----------------- 129 + 130 + If you want to write a software backend: 131 + 132 + * use a standard i2c_driver and its matching mechanisms 133 + * write the slave_callback which handles the above slave events 134 + (best using a state machine) 135 + * register this callback via i2c_slave_register() 136 + 137 + Check the i2c-slave-eeprom driver as an example. 138 + 139 + 140 + Bus driver support 141 + ------------------ 142 + 143 + If you want to add slave support to the bus driver: 144 + 145 + * implement calls to register/unregister the slave and add those to the 146 + struct i2c_algorithm. When registering, you probably need to set the i2c 147 + slave address and enable slave specific interrupts. If you use runtime pm, you 148 + should use pm_runtime_get_sync() because your device usually needs to be 149 + powered on always to be able to detect its slave address. When unregistering, 150 + do the inverse of the above. 151 + 152 + * Catch the slave interrupts and send appropriate i2c_slave_events to the backend. 153 + 154 + Note that most hardware supports being master _and_ slave on the same bus. So, 155 + if you extend a bus driver, please make sure that the driver supports that as 156 + well. In almost all cases, slave support does not need to disable the master 157 + functionality. 158 + 159 + Check the i2c-rcar driver as an example. 160 + 161 + 162 + About ACK/NACK 163 + -------------- 164 + 165 + It is good behaviour to always ACK the address phase, so the master knows if a 166 + device is basically present or if it mysteriously disappeared. Using NACK to 167 + state being busy is troublesome. SMBus demands to always ACK the address phase, 168 + while the I2C specification is more loose on that. Most I2C controllers also 169 + automatically ACK when detecting their slave addresses, so there is no option 170 + to NACK them. For those reasons, this API does not support NACK in the address 171 + phase. 172 + 173 + Currently, there is no slave event to report if the master did ACK or NACK a 174 + byte when it reads from us. We could make this an optional event if the need 175 + arises. However, cases should be extremely rare because the master is expected 176 + to send STOP after that and we have an event for that. Also, keep in mind not 177 + all I2C controllers have the possibility to report that event. 178 + 179 + 180 + About buffers 181 + ------------- 182 + 183 + During development of this API, the question of using buffers instead of just 184 + bytes came up. Such an extension might be possible, usefulness is unclear at 185 + this time of writing. Some points to keep in mind when using buffers: 186 + 187 + * Buffers should be opt-in and backend drivers will always have to support 188 + byte-based transactions as the ultimate fallback anyhow because this is how 189 + the majority of HW works. 190 + 191 + * For backends simulating hardware registers, buffers are largely not helpful 192 + because after each byte written an action should be immediately triggered. 193 + For reads, the data kept in the buffer might get stale if the backend just 194 + updated a register because of internal processing. 195 + 196 + * A master can send STOP at any time. For partially transferred buffers, this 197 + means additional code to handle this exception. Such code tends to be 198 + error-prone.
-283
Documentation/i2c/smbus-protocol
··· 1 - SMBus Protocol Summary 2 - ====================== 3 - 4 - The following is a summary of the SMBus protocol. It applies to 5 - all revisions of the protocol (1.0, 1.1, and 2.0). 6 - Certain protocol features which are not supported by 7 - this package are briefly described at the end of this document. 8 - 9 - Some adapters understand only the SMBus (System Management Bus) protocol, 10 - which is a subset from the I2C protocol. Fortunately, many devices use 11 - only the same subset, which makes it possible to put them on an SMBus. 12 - 13 - If you write a driver for some I2C device, please try to use the SMBus 14 - commands if at all possible (if the device uses only that subset of the 15 - I2C protocol). This makes it possible to use the device driver on both 16 - SMBus adapters and I2C adapters (the SMBus command set is automatically 17 - translated to I2C on I2C adapters, but plain I2C commands can not be 18 - handled at all on most pure SMBus adapters). 19 - 20 - Below is a list of SMBus protocol operations, and the functions executing 21 - them. Note that the names used in the SMBus protocol specifications usually 22 - don't match these function names. For some of the operations which pass a 23 - single data byte, the functions using SMBus protocol operation names execute 24 - a different protocol operation entirely. 25 - 26 - Each transaction type corresponds to a functionality flag. Before calling a 27 - transaction function, a device driver should always check (just once) for 28 - the corresponding functionality flag to ensure that the underlying I2C 29 - adapter supports the transaction in question. See 30 - <file:Documentation/i2c/functionality> for the details. 31 - 32 - 33 - Key to symbols 34 - ============== 35 - 36 - S (1 bit) : Start bit 37 - P (1 bit) : Stop bit 38 - Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. 39 - A, NA (1 bit) : Accept and reverse accept bit. 40 - Addr (7 bits): I2C 7 bit address. Note that this can be expanded as usual to 41 - get a 10 bit I2C address. 42 - Comm (8 bits): Command byte, a data byte which often selects a register on 43 - the device. 44 - Data (8 bits): A plain data byte. Sometimes, I write DataLow, DataHigh 45 - for 16 bit data. 46 - Count (8 bits): A data byte containing the length of a block operation. 47 - 48 - [..]: Data sent by I2C device, as opposed to data sent by the host adapter. 49 - 50 - 51 - SMBus Quick Command 52 - =================== 53 - 54 - This sends a single bit to the device, at the place of the Rd/Wr bit. 55 - 56 - A Addr Rd/Wr [A] P 57 - 58 - Functionality flag: I2C_FUNC_SMBUS_QUICK 59 - 60 - 61 - SMBus Receive Byte: i2c_smbus_read_byte() 62 - ========================================== 63 - 64 - This reads a single byte from a device, without specifying a device 65 - register. Some devices are so simple that this interface is enough; for 66 - others, it is a shorthand if you want to read the same register as in 67 - the previous SMBus command. 68 - 69 - S Addr Rd [A] [Data] NA P 70 - 71 - Functionality flag: I2C_FUNC_SMBUS_READ_BYTE 72 - 73 - 74 - SMBus Send Byte: i2c_smbus_write_byte() 75 - ======================================== 76 - 77 - This operation is the reverse of Receive Byte: it sends a single byte 78 - to a device. See Receive Byte for more information. 79 - 80 - S Addr Wr [A] Data [A] P 81 - 82 - Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE 83 - 84 - 85 - SMBus Read Byte: i2c_smbus_read_byte_data() 86 - ============================================ 87 - 88 - This reads a single byte from a device, from a designated register. 89 - The register is specified through the Comm byte. 90 - 91 - S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P 92 - 93 - Functionality flag: I2C_FUNC_SMBUS_READ_BYTE_DATA 94 - 95 - 96 - SMBus Read Word: i2c_smbus_read_word_data() 97 - ============================================ 98 - 99 - This operation is very like Read Byte; again, data is read from a 100 - device, from a designated register that is specified through the Comm 101 - byte. But this time, the data is a complete word (16 bits). 102 - 103 - S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P 104 - 105 - Functionality flag: I2C_FUNC_SMBUS_READ_WORD_DATA 106 - 107 - Note the convenience function i2c_smbus_read_word_swapped is 108 - available for reads where the two data bytes are the other way 109 - around (not SMBus compliant, but very popular.) 110 - 111 - 112 - SMBus Write Byte: i2c_smbus_write_byte_data() 113 - ============================================== 114 - 115 - This writes a single byte to a device, to a designated register. The 116 - register is specified through the Comm byte. This is the opposite of 117 - the Read Byte operation. 118 - 119 - S Addr Wr [A] Comm [A] Data [A] P 120 - 121 - Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE_DATA 122 - 123 - 124 - SMBus Write Word: i2c_smbus_write_word_data() 125 - ============================================== 126 - 127 - This is the opposite of the Read Word operation. 16 bits 128 - of data is written to a device, to the designated register that is 129 - specified through the Comm byte. 130 - 131 - S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P 132 - 133 - Functionality flag: I2C_FUNC_SMBUS_WRITE_WORD_DATA 134 - 135 - Note the convenience function i2c_smbus_write_word_swapped is 136 - available for writes where the two data bytes are the other way 137 - around (not SMBus compliant, but very popular.) 138 - 139 - 140 - SMBus Process Call: 141 - =================== 142 - 143 - This command selects a device register (through the Comm byte), sends 144 - 16 bits of data to it, and reads 16 bits of data in return. 145 - 146 - S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] 147 - S Addr Rd [A] [DataLow] A [DataHigh] NA P 148 - 149 - Functionality flag: I2C_FUNC_SMBUS_PROC_CALL 150 - 151 - 152 - SMBus Block Read: i2c_smbus_read_block_data() 153 - ============================================== 154 - 155 - This command reads a block of up to 32 bytes from a device, from a 156 - designated register that is specified through the Comm byte. The amount 157 - of data is specified by the device in the Count byte. 158 - 159 - S Addr Wr [A] Comm [A] 160 - S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P 161 - 162 - Functionality flag: I2C_FUNC_SMBUS_READ_BLOCK_DATA 163 - 164 - 165 - SMBus Block Write: i2c_smbus_write_block_data() 166 - ================================================ 167 - 168 - The opposite of the Block Read command, this writes up to 32 bytes to 169 - a device, to a designated register that is specified through the 170 - Comm byte. The amount of data is specified in the Count byte. 171 - 172 - S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P 173 - 174 - Functionality flag: I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 175 - 176 - 177 - SMBus Block Write - Block Read Process Call 178 - =========================================== 179 - 180 - SMBus Block Write - Block Read Process Call was introduced in 181 - Revision 2.0 of the specification. 182 - 183 - This command selects a device register (through the Comm byte), sends 184 - 1 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return. 185 - 186 - S Addr Wr [A] Comm [A] Count [A] Data [A] ... 187 - S Addr Rd [A] [Count] A [Data] ... A P 188 - 189 - Functionality flag: I2C_FUNC_SMBUS_BLOCK_PROC_CALL 190 - 191 - 192 - SMBus Host Notify 193 - ================= 194 - 195 - This command is sent from a SMBus device acting as a master to the 196 - SMBus host acting as a slave. 197 - It is the same form as Write Word, with the command code replaced by the 198 - alerting device's address. 199 - 200 - [S] [HostAddr] [Wr] A [DevAddr] A [DataLow] A [DataHigh] A [P] 201 - 202 - This is implemented in the following way in the Linux kernel: 203 - * I2C bus drivers which support SMBus Host Notify should report 204 - I2C_FUNC_SMBUS_HOST_NOTIFY. 205 - * I2C bus drivers trigger SMBus Host Notify by a call to 206 - i2c_handle_smbus_host_notify(). 207 - * I2C drivers for devices which can trigger SMBus Host Notify will have 208 - client->irq assigned to a Host Notify IRQ if noone else specified an other. 209 - 210 - There is currently no way to retrieve the data parameter from the client. 211 - 212 - 213 - Packet Error Checking (PEC) 214 - =========================== 215 - 216 - Packet Error Checking was introduced in Revision 1.1 of the specification. 217 - 218 - PEC adds a CRC-8 error-checking byte to transfers using it, immediately 219 - before the terminating STOP. 220 - 221 - 222 - Address Resolution Protocol (ARP) 223 - ================================= 224 - 225 - The Address Resolution Protocol was introduced in Revision 2.0 of 226 - the specification. It is a higher-layer protocol which uses the 227 - messages above. 228 - 229 - ARP adds device enumeration and dynamic address assignment to 230 - the protocol. All ARP communications use slave address 0x61 and 231 - require PEC checksums. 232 - 233 - 234 - SMBus Alert 235 - =========== 236 - 237 - SMBus Alert was introduced in Revision 1.0 of the specification. 238 - 239 - The SMBus alert protocol allows several SMBus slave devices to share a 240 - single interrupt pin on the SMBus master, while still allowing the master 241 - to know which slave triggered the interrupt. 242 - 243 - This is implemented the following way in the Linux kernel: 244 - * I2C bus drivers which support SMBus alert should call 245 - i2c_setup_smbus_alert() to setup SMBus alert support. 246 - * I2C drivers for devices which can trigger SMBus alerts should implement 247 - the optional alert() callback. 248 - 249 - 250 - I2C Block Transactions 251 - ====================== 252 - 253 - The following I2C block transactions are supported by the 254 - SMBus layer and are described here for completeness. 255 - They are *NOT* defined by the SMBus specification. 256 - 257 - I2C block transactions do not limit the number of bytes transferred 258 - but the SMBus layer places a limit of 32 bytes. 259 - 260 - 261 - I2C Block Read: i2c_smbus_read_i2c_block_data() 262 - ================================================ 263 - 264 - This command reads a block of bytes from a device, from a 265 - designated register that is specified through the Comm byte. 266 - 267 - S Addr Wr [A] Comm [A] 268 - S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P 269 - 270 - Functionality flag: I2C_FUNC_SMBUS_READ_I2C_BLOCK 271 - 272 - 273 - I2C Block Write: i2c_smbus_write_i2c_block_data() 274 - ================================================== 275 - 276 - The opposite of the Block Read command, this writes bytes to 277 - a device, to a designated register that is specified through the 278 - Comm byte. Note that command lengths of 0, 2, or more bytes are 279 - supported as they are indistinguishable from data. 280 - 281 - S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P 282 - 283 - Functionality flag: I2C_FUNC_SMBUS_WRITE_I2C_BLOCK
+301
Documentation/i2c/smbus-protocol.rst
··· 1 + ====================== 2 + SMBus Protocol Summary 3 + ====================== 4 + 5 + The following is a summary of the SMBus protocol. It applies to 6 + all revisions of the protocol (1.0, 1.1, and 2.0). 7 + Certain protocol features which are not supported by 8 + this package are briefly described at the end of this document. 9 + 10 + Some adapters understand only the SMBus (System Management Bus) protocol, 11 + which is a subset from the I2C protocol. Fortunately, many devices use 12 + only the same subset, which makes it possible to put them on an SMBus. 13 + 14 + If you write a driver for some I2C device, please try to use the SMBus 15 + commands if at all possible (if the device uses only that subset of the 16 + I2C protocol). This makes it possible to use the device driver on both 17 + SMBus adapters and I2C adapters (the SMBus command set is automatically 18 + translated to I2C on I2C adapters, but plain I2C commands can not be 19 + handled at all on most pure SMBus adapters). 20 + 21 + Below is a list of SMBus protocol operations, and the functions executing 22 + them. Note that the names used in the SMBus protocol specifications usually 23 + don't match these function names. For some of the operations which pass a 24 + single data byte, the functions using SMBus protocol operation names execute 25 + a different protocol operation entirely. 26 + 27 + Each transaction type corresponds to a functionality flag. Before calling a 28 + transaction function, a device driver should always check (just once) for 29 + the corresponding functionality flag to ensure that the underlying I2C 30 + adapter supports the transaction in question. See 31 + <file:Documentation/i2c/functionality.rst> for the details. 32 + 33 + 34 + Key to symbols 35 + ============== 36 + 37 + =============== ============================================================= 38 + S (1 bit) : Start bit 39 + P (1 bit) : Stop bit 40 + Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. 41 + A, NA (1 bit) : Accept and reverse accept bit. 42 + Addr (7 bits): I2C 7 bit address. Note that this can be expanded as usual to 43 + get a 10 bit I2C address. 44 + Comm (8 bits): Command byte, a data byte which often selects a register on 45 + the device. 46 + Data (8 bits): A plain data byte. Sometimes, I write DataLow, DataHigh 47 + for 16 bit data. 48 + Count (8 bits): A data byte containing the length of a block operation. 49 + 50 + [..]: Data sent by I2C device, as opposed to data sent by the host 51 + adapter. 52 + =============== ============================================================= 53 + 54 + 55 + SMBus Quick Command 56 + =================== 57 + 58 + This sends a single bit to the device, at the place of the Rd/Wr bit:: 59 + 60 + A Addr Rd/Wr [A] P 61 + 62 + Functionality flag: I2C_FUNC_SMBUS_QUICK 63 + 64 + 65 + SMBus Receive Byte: i2c_smbus_read_byte() 66 + ========================================== 67 + 68 + This reads a single byte from a device, without specifying a device 69 + register. Some devices are so simple that this interface is enough; for 70 + others, it is a shorthand if you want to read the same register as in 71 + the previous SMBus command:: 72 + 73 + S Addr Rd [A] [Data] NA P 74 + 75 + Functionality flag: I2C_FUNC_SMBUS_READ_BYTE 76 + 77 + 78 + SMBus Send Byte: i2c_smbus_write_byte() 79 + ======================================== 80 + 81 + This operation is the reverse of Receive Byte: it sends a single byte 82 + to a device. See Receive Byte for more information. 83 + 84 + :: 85 + 86 + S Addr Wr [A] Data [A] P 87 + 88 + Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE 89 + 90 + 91 + SMBus Read Byte: i2c_smbus_read_byte_data() 92 + ============================================ 93 + 94 + This reads a single byte from a device, from a designated register. 95 + The register is specified through the Comm byte:: 96 + 97 + S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P 98 + 99 + Functionality flag: I2C_FUNC_SMBUS_READ_BYTE_DATA 100 + 101 + 102 + SMBus Read Word: i2c_smbus_read_word_data() 103 + ============================================ 104 + 105 + This operation is very like Read Byte; again, data is read from a 106 + device, from a designated register that is specified through the Comm 107 + byte. But this time, the data is a complete word (16 bits):: 108 + 109 + S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P 110 + 111 + Functionality flag: I2C_FUNC_SMBUS_READ_WORD_DATA 112 + 113 + Note the convenience function i2c_smbus_read_word_swapped is 114 + available for reads where the two data bytes are the other way 115 + around (not SMBus compliant, but very popular.) 116 + 117 + 118 + SMBus Write Byte: i2c_smbus_write_byte_data() 119 + ============================================== 120 + 121 + This writes a single byte to a device, to a designated register. The 122 + register is specified through the Comm byte. This is the opposite of 123 + the Read Byte operation. 124 + 125 + :: 126 + 127 + S Addr Wr [A] Comm [A] Data [A] P 128 + 129 + Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE_DATA 130 + 131 + 132 + SMBus Write Word: i2c_smbus_write_word_data() 133 + ============================================== 134 + 135 + This is the opposite of the Read Word operation. 16 bits 136 + of data is written to a device, to the designated register that is 137 + specified through the Comm byte.:: 138 + 139 + S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P 140 + 141 + Functionality flag: I2C_FUNC_SMBUS_WRITE_WORD_DATA 142 + 143 + Note the convenience function i2c_smbus_write_word_swapped is 144 + available for writes where the two data bytes are the other way 145 + around (not SMBus compliant, but very popular.) 146 + 147 + 148 + SMBus Process Call: 149 + =================== 150 + 151 + This command selects a device register (through the Comm byte), sends 152 + 16 bits of data to it, and reads 16 bits of data in return:: 153 + 154 + S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] 155 + S Addr Rd [A] [DataLow] A [DataHigh] NA P 156 + 157 + Functionality flag: I2C_FUNC_SMBUS_PROC_CALL 158 + 159 + 160 + SMBus Block Read: i2c_smbus_read_block_data() 161 + ============================================== 162 + 163 + This command reads a block of up to 32 bytes from a device, from a 164 + designated register that is specified through the Comm byte. The amount 165 + of data is specified by the device in the Count byte. 166 + 167 + :: 168 + 169 + S Addr Wr [A] Comm [A] 170 + S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P 171 + 172 + Functionality flag: I2C_FUNC_SMBUS_READ_BLOCK_DATA 173 + 174 + 175 + SMBus Block Write: i2c_smbus_write_block_data() 176 + ================================================ 177 + 178 + The opposite of the Block Read command, this writes up to 32 bytes to 179 + a device, to a designated register that is specified through the 180 + Comm byte. The amount of data is specified in the Count byte. 181 + 182 + :: 183 + 184 + S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P 185 + 186 + Functionality flag: I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 187 + 188 + 189 + SMBus Block Write - Block Read Process Call 190 + =========================================== 191 + 192 + SMBus Block Write - Block Read Process Call was introduced in 193 + Revision 2.0 of the specification. 194 + 195 + This command selects a device register (through the Comm byte), sends 196 + 1 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return:: 197 + 198 + S Addr Wr [A] Comm [A] Count [A] Data [A] ... 199 + S Addr Rd [A] [Count] A [Data] ... A P 200 + 201 + Functionality flag: I2C_FUNC_SMBUS_BLOCK_PROC_CALL 202 + 203 + 204 + SMBus Host Notify 205 + ================= 206 + 207 + This command is sent from a SMBus device acting as a master to the 208 + SMBus host acting as a slave. 209 + It is the same form as Write Word, with the command code replaced by the 210 + alerting device's address. 211 + 212 + :: 213 + 214 + [S] [HostAddr] [Wr] A [DevAddr] A [DataLow] A [DataHigh] A [P] 215 + 216 + This is implemented in the following way in the Linux kernel: 217 + 218 + * I2C bus drivers which support SMBus Host Notify should report 219 + I2C_FUNC_SMBUS_HOST_NOTIFY. 220 + * I2C bus drivers trigger SMBus Host Notify by a call to 221 + i2c_handle_smbus_host_notify(). 222 + * I2C drivers for devices which can trigger SMBus Host Notify will have 223 + client->irq assigned to a Host Notify IRQ if noone else specified an other. 224 + 225 + There is currently no way to retrieve the data parameter from the client. 226 + 227 + 228 + Packet Error Checking (PEC) 229 + =========================== 230 + 231 + Packet Error Checking was introduced in Revision 1.1 of the specification. 232 + 233 + PEC adds a CRC-8 error-checking byte to transfers using it, immediately 234 + before the terminating STOP. 235 + 236 + 237 + Address Resolution Protocol (ARP) 238 + ================================= 239 + 240 + The Address Resolution Protocol was introduced in Revision 2.0 of 241 + the specification. It is a higher-layer protocol which uses the 242 + messages above. 243 + 244 + ARP adds device enumeration and dynamic address assignment to 245 + the protocol. All ARP communications use slave address 0x61 and 246 + require PEC checksums. 247 + 248 + 249 + SMBus Alert 250 + =========== 251 + 252 + SMBus Alert was introduced in Revision 1.0 of the specification. 253 + 254 + The SMBus alert protocol allows several SMBus slave devices to share a 255 + single interrupt pin on the SMBus master, while still allowing the master 256 + to know which slave triggered the interrupt. 257 + 258 + This is implemented the following way in the Linux kernel: 259 + 260 + * I2C bus drivers which support SMBus alert should call 261 + i2c_setup_smbus_alert() to setup SMBus alert support. 262 + * I2C drivers for devices which can trigger SMBus alerts should implement 263 + the optional alert() callback. 264 + 265 + 266 + I2C Block Transactions 267 + ====================== 268 + 269 + The following I2C block transactions are supported by the 270 + SMBus layer and are described here for completeness. 271 + They are *NOT* defined by the SMBus specification. 272 + 273 + I2C block transactions do not limit the number of bytes transferred 274 + but the SMBus layer places a limit of 32 bytes. 275 + 276 + 277 + I2C Block Read: i2c_smbus_read_i2c_block_data() 278 + ================================================ 279 + 280 + This command reads a block of bytes from a device, from a 281 + designated register that is specified through the Comm byte:: 282 + 283 + S Addr Wr [A] Comm [A] 284 + S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P 285 + 286 + Functionality flag: I2C_FUNC_SMBUS_READ_I2C_BLOCK 287 + 288 + 289 + I2C Block Write: i2c_smbus_write_i2c_block_data() 290 + ================================================== 291 + 292 + The opposite of the Block Read command, this writes bytes to 293 + a device, to a designated register that is specified through the 294 + Comm byte. Note that command lengths of 0, 2, or more bytes are 295 + supported as they are indistinguishable from data. 296 + 297 + :: 298 + 299 + S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P 300 + 301 + Functionality flag: I2C_FUNC_SMBUS_WRITE_I2C_BLOCK
-43
Documentation/i2c/summary
··· 1 - I2C and SMBus 2 - ============= 3 - 4 - I2C (pronounce: I squared C) is a protocol developed by Philips. It is a 5 - slow two-wire protocol (variable speed, up to 400 kHz), with a high speed 6 - extension (3.4 MHz). It provides an inexpensive bus for connecting many 7 - types of devices with infrequent or low bandwidth communications needs. 8 - I2C is widely used with embedded systems. Some systems use variants that 9 - don't meet branding requirements, and so are not advertised as being I2C. 10 - 11 - SMBus (System Management Bus) is based on the I2C protocol, and is mostly 12 - a subset of I2C protocols and signaling. Many I2C devices will work on an 13 - SMBus, but some SMBus protocols add semantics beyond what is required to 14 - achieve I2C branding. Modern PC mainboards rely on SMBus. The most common 15 - devices connected through SMBus are RAM modules configured using I2C EEPROMs, 16 - and hardware monitoring chips. 17 - 18 - Because the SMBus is mostly a subset of the generalized I2C bus, we can 19 - use its protocols on many I2C systems. However, there are systems that don't 20 - meet both SMBus and I2C electrical constraints; and others which can't 21 - implement all the common SMBus protocol semantics or messages. 22 - 23 - 24 - Terminology 25 - =========== 26 - 27 - When we talk about I2C, we use the following terms: 28 - Bus -> Algorithm 29 - Adapter 30 - Device -> Driver 31 - Client 32 - 33 - An Algorithm driver contains general code that can be used for a whole class 34 - of I2C adapters. Each specific adapter driver either depends on one algorithm 35 - driver, or includes its own implementation. 36 - 37 - A Driver driver (yes, this sounds ridiculous, sorry) contains the general 38 - code to access some type of device. Each detected device gets its own 39 - data in the Client structure. Usually, Driver and Client are more closely 40 - integrated than Algorithm and Adapter. 41 - 42 - For a given configuration, you will need a driver for your I2C bus, and 43 - drivers for your I2C devices (usually one driver for each device).
+45
Documentation/i2c/summary.rst
··· 1 + ============= 2 + I2C and SMBus 3 + ============= 4 + 5 + I2C (pronounce: I squared C) is a protocol developed by Philips. It is a 6 + slow two-wire protocol (variable speed, up to 400 kHz), with a high speed 7 + extension (3.4 MHz). It provides an inexpensive bus for connecting many 8 + types of devices with infrequent or low bandwidth communications needs. 9 + I2C is widely used with embedded systems. Some systems use variants that 10 + don't meet branding requirements, and so are not advertised as being I2C. 11 + 12 + SMBus (System Management Bus) is based on the I2C protocol, and is mostly 13 + a subset of I2C protocols and signaling. Many I2C devices will work on an 14 + SMBus, but some SMBus protocols add semantics beyond what is required to 15 + achieve I2C branding. Modern PC mainboards rely on SMBus. The most common 16 + devices connected through SMBus are RAM modules configured using I2C EEPROMs, 17 + and hardware monitoring chips. 18 + 19 + Because the SMBus is mostly a subset of the generalized I2C bus, we can 20 + use its protocols on many I2C systems. However, there are systems that don't 21 + meet both SMBus and I2C electrical constraints; and others which can't 22 + implement all the common SMBus protocol semantics or messages. 23 + 24 + 25 + Terminology 26 + =========== 27 + 28 + When we talk about I2C, we use the following terms:: 29 + 30 + Bus -> Algorithm 31 + Adapter 32 + Device -> Driver 33 + Client 34 + 35 + An Algorithm driver contains general code that can be used for a whole class 36 + of I2C adapters. Each specific adapter driver either depends on one algorithm 37 + driver, or includes its own implementation. 38 + 39 + A Driver driver (yes, this sounds ridiculous, sorry) contains the general 40 + code to access some type of device. Each detected device gets its own 41 + data in the Client structure. Usually, Driver and Client are more closely 42 + integrated than Algorithm and Adapter. 43 + 44 + For a given configuration, you will need a driver for your I2C bus, and 45 + drivers for your I2C devices (usually one driver for each device).
-28
Documentation/i2c/ten-bit-addresses
··· 1 - The I2C protocol knows about two kinds of device addresses: normal 7 bit 2 - addresses, and an extended set of 10 bit addresses. The sets of addresses 3 - do not intersect: the 7 bit address 0x10 is not the same as the 10 bit 4 - address 0x10 (though a single device could respond to both of them). 5 - To avoid ambiguity, the user sees 10 bit addresses mapped to a different 6 - address space, namely 0xa000-0xa3ff. The leading 0xa (= 10) represents the 7 - 10 bit mode. This is used for creating device names in sysfs. It is also 8 - needed when instantiating 10 bit devices via the new_device file in sysfs. 9 - 10 - I2C messages to and from 10-bit address devices have a different format. 11 - See the I2C specification for the details. 12 - 13 - The current 10 bit address support is minimal. It should work, however 14 - you can expect some problems along the way: 15 - * Not all bus drivers support 10-bit addresses. Some don't because the 16 - hardware doesn't support them (SMBus doesn't require 10-bit address 17 - support for example), some don't because nobody bothered adding the 18 - code (or it's there but not working properly.) Software implementation 19 - (i2c-algo-bit) is known to work. 20 - * Some optional features do not support 10-bit addresses. This is the 21 - case of automatic detection and instantiation of devices by their, 22 - drivers, for example. 23 - * Many user-space packages (for example i2c-tools) lack support for 24 - 10-bit addresses. 25 - 26 - Note that 10-bit address devices are still pretty rare, so the limitations 27 - listed above could stay for a long time, maybe even forever if nobody 28 - needs them to be fixed.
+33
Documentation/i2c/ten-bit-addresses.rst
··· 1 + ===================== 2 + I2C Ten-bit Addresses 3 + ===================== 4 + 5 + The I2C protocol knows about two kinds of device addresses: normal 7 bit 6 + addresses, and an extended set of 10 bit addresses. The sets of addresses 7 + do not intersect: the 7 bit address 0x10 is not the same as the 10 bit 8 + address 0x10 (though a single device could respond to both of them). 9 + To avoid ambiguity, the user sees 10 bit addresses mapped to a different 10 + address space, namely 0xa000-0xa3ff. The leading 0xa (= 10) represents the 11 + 10 bit mode. This is used for creating device names in sysfs. It is also 12 + needed when instantiating 10 bit devices via the new_device file in sysfs. 13 + 14 + I2C messages to and from 10-bit address devices have a different format. 15 + See the I2C specification for the details. 16 + 17 + The current 10 bit address support is minimal. It should work, however 18 + you can expect some problems along the way: 19 + 20 + * Not all bus drivers support 10-bit addresses. Some don't because the 21 + hardware doesn't support them (SMBus doesn't require 10-bit address 22 + support for example), some don't because nobody bothered adding the 23 + code (or it's there but not working properly.) Software implementation 24 + (i2c-algo-bit) is known to work. 25 + * Some optional features do not support 10-bit addresses. This is the 26 + case of automatic detection and instantiation of devices by their, 27 + drivers, for example. 28 + * Many user-space packages (for example i2c-tools) lack support for 29 + 10-bit addresses. 30 + 31 + Note that 10-bit address devices are still pretty rare, so the limitations 32 + listed above could stay for a long time, maybe even forever if nobody 33 + needs them to be fixed.
-279
Documentation/i2c/upgrading-clients
··· 1 - Upgrading I2C Drivers to the new 2.6 Driver Model 2 - ================================================= 3 - 4 - Ben Dooks <ben-linux@fluff.org> 5 - 6 - Introduction 7 - ------------ 8 - 9 - This guide outlines how to alter existing Linux 2.6 client drivers from 10 - the old to the new new binding methods. 11 - 12 - 13 - Example old-style driver 14 - ------------------------ 15 - 16 - 17 - struct example_state { 18 - struct i2c_client client; 19 - .... 20 - }; 21 - 22 - static struct i2c_driver example_driver; 23 - 24 - static unsigned short ignore[] = { I2C_CLIENT_END }; 25 - static unsigned short normal_addr[] = { OUR_ADDR, I2C_CLIENT_END }; 26 - 27 - I2C_CLIENT_INSMOD; 28 - 29 - static int example_attach(struct i2c_adapter *adap, int addr, int kind) 30 - { 31 - struct example_state *state; 32 - struct device *dev = &adap->dev; /* to use for dev_ reports */ 33 - int ret; 34 - 35 - state = kzalloc(sizeof(struct example_state), GFP_KERNEL); 36 - if (state == NULL) { 37 - dev_err(dev, "failed to create our state\n"); 38 - return -ENOMEM; 39 - } 40 - 41 - example->client.addr = addr; 42 - example->client.flags = 0; 43 - example->client.adapter = adap; 44 - 45 - i2c_set_clientdata(&state->i2c_client, state); 46 - strscpy(client->i2c_client.name, "example", sizeof(client->i2c_client.name)); 47 - 48 - ret = i2c_attach_client(&state->i2c_client); 49 - if (ret < 0) { 50 - dev_err(dev, "failed to attach client\n"); 51 - kfree(state); 52 - return ret; 53 - } 54 - 55 - dev = &state->i2c_client.dev; 56 - 57 - /* rest of the initialisation goes here. */ 58 - 59 - dev_info(dev, "example client created\n"); 60 - 61 - return 0; 62 - } 63 - 64 - static int example_detach(struct i2c_client *client) 65 - { 66 - struct example_state *state = i2c_get_clientdata(client); 67 - 68 - i2c_detach_client(client); 69 - kfree(state); 70 - return 0; 71 - } 72 - 73 - static int example_attach_adapter(struct i2c_adapter *adap) 74 - { 75 - return i2c_probe(adap, &addr_data, example_attach); 76 - } 77 - 78 - static struct i2c_driver example_driver = { 79 - .driver = { 80 - .owner = THIS_MODULE, 81 - .name = "example", 82 - .pm = &example_pm_ops, 83 - }, 84 - .attach_adapter = example_attach_adapter, 85 - .detach_client = example_detach, 86 - }; 87 - 88 - 89 - Updating the client 90 - ------------------- 91 - 92 - The new style binding model will check against a list of supported 93 - devices and their associated address supplied by the code registering 94 - the busses. This means that the driver .attach_adapter and 95 - .detach_client methods can be removed, along with the addr_data, 96 - as follows: 97 - 98 - - static struct i2c_driver example_driver; 99 - 100 - - static unsigned short ignore[] = { I2C_CLIENT_END }; 101 - - static unsigned short normal_addr[] = { OUR_ADDR, I2C_CLIENT_END }; 102 - 103 - - I2C_CLIENT_INSMOD; 104 - 105 - - static int example_attach_adapter(struct i2c_adapter *adap) 106 - - { 107 - - return i2c_probe(adap, &addr_data, example_attach); 108 - - } 109 - 110 - static struct i2c_driver example_driver = { 111 - - .attach_adapter = example_attach_adapter, 112 - - .detach_client = example_detach, 113 - } 114 - 115 - Add the probe and remove methods to the i2c_driver, as so: 116 - 117 - static struct i2c_driver example_driver = { 118 - + .probe = example_probe, 119 - + .remove = example_remove, 120 - } 121 - 122 - Change the example_attach method to accept the new parameters 123 - which include the i2c_client that it will be working with: 124 - 125 - - static int example_attach(struct i2c_adapter *adap, int addr, int kind) 126 - + static int example_probe(struct i2c_client *client, 127 - + const struct i2c_device_id *id) 128 - 129 - Change the name of example_attach to example_probe to align it with the 130 - i2c_driver entry names. The rest of the probe routine will now need to be 131 - changed as the i2c_client has already been setup for use. 132 - 133 - The necessary client fields have already been setup before 134 - the probe function is called, so the following client setup 135 - can be removed: 136 - 137 - - example->client.addr = addr; 138 - - example->client.flags = 0; 139 - - example->client.adapter = adap; 140 - - 141 - - strscpy(client->i2c_client.name, "example", sizeof(client->i2c_client.name)); 142 - 143 - The i2c_set_clientdata is now: 144 - 145 - - i2c_set_clientdata(&state->client, state); 146 - + i2c_set_clientdata(client, state); 147 - 148 - The call to i2c_attach_client is no longer needed, if the probe 149 - routine exits successfully, then the driver will be automatically 150 - attached by the core. Change the probe routine as so: 151 - 152 - - ret = i2c_attach_client(&state->i2c_client); 153 - - if (ret < 0) { 154 - - dev_err(dev, "failed to attach client\n"); 155 - - kfree(state); 156 - - return ret; 157 - - } 158 - 159 - 160 - Remove the storage of 'struct i2c_client' from the 'struct example_state' 161 - as we are provided with the i2c_client in our example_probe. Instead we 162 - store a pointer to it for when it is needed. 163 - 164 - struct example_state { 165 - - struct i2c_client client; 166 - + struct i2c_client *client; 167 - 168 - the new i2c client as so: 169 - 170 - - struct device *dev = &adap->dev; /* to use for dev_ reports */ 171 - + struct device *dev = &i2c_client->dev; /* to use for dev_ reports */ 172 - 173 - And remove the change after our client is attached, as the driver no 174 - longer needs to register a new client structure with the core: 175 - 176 - - dev = &state->i2c_client.dev; 177 - 178 - In the probe routine, ensure that the new state has the client stored 179 - in it: 180 - 181 - static int example_probe(struct i2c_client *i2c_client, 182 - const struct i2c_device_id *id) 183 - { 184 - struct example_state *state; 185 - struct device *dev = &i2c_client->dev; 186 - int ret; 187 - 188 - state = kzalloc(sizeof(struct example_state), GFP_KERNEL); 189 - if (state == NULL) { 190 - dev_err(dev, "failed to create our state\n"); 191 - return -ENOMEM; 192 - } 193 - 194 - + state->client = i2c_client; 195 - 196 - Update the detach method, by changing the name to _remove and 197 - to delete the i2c_detach_client call. It is possible that you 198 - can also remove the ret variable as it is not needed for any 199 - of the core functions. 200 - 201 - - static int example_detach(struct i2c_client *client) 202 - + static int example_remove(struct i2c_client *client) 203 - { 204 - struct example_state *state = i2c_get_clientdata(client); 205 - 206 - - i2c_detach_client(client); 207 - 208 - And finally ensure that we have the correct ID table for the i2c-core 209 - and other utilities: 210 - 211 - + struct i2c_device_id example_idtable[] = { 212 - + { "example", 0 }, 213 - + { } 214 - +}; 215 - + 216 - +MODULE_DEVICE_TABLE(i2c, example_idtable); 217 - 218 - static struct i2c_driver example_driver = { 219 - .driver = { 220 - .owner = THIS_MODULE, 221 - .name = "example", 222 - }, 223 - + .id_table = example_ids, 224 - 225 - 226 - Our driver should now look like this: 227 - 228 - struct example_state { 229 - struct i2c_client *client; 230 - .... 231 - }; 232 - 233 - static int example_probe(struct i2c_client *client, 234 - const struct i2c_device_id *id) 235 - { 236 - struct example_state *state; 237 - struct device *dev = &client->dev; 238 - 239 - state = kzalloc(sizeof(struct example_state), GFP_KERNEL); 240 - if (state == NULL) { 241 - dev_err(dev, "failed to create our state\n"); 242 - return -ENOMEM; 243 - } 244 - 245 - state->client = client; 246 - i2c_set_clientdata(client, state); 247 - 248 - /* rest of the initialisation goes here. */ 249 - 250 - dev_info(dev, "example client created\n"); 251 - 252 - return 0; 253 - } 254 - 255 - static int example_remove(struct i2c_client *client) 256 - { 257 - struct example_state *state = i2c_get_clientdata(client); 258 - 259 - kfree(state); 260 - return 0; 261 - } 262 - 263 - static struct i2c_device_id example_idtable[] = { 264 - { "example", 0 }, 265 - { } 266 - }; 267 - 268 - MODULE_DEVICE_TABLE(i2c, example_idtable); 269 - 270 - static struct i2c_driver example_driver = { 271 - .driver = { 272 - .owner = THIS_MODULE, 273 - .name = "example", 274 - .pm = &example_pm_ops, 275 - }, 276 - .id_table = example_idtable, 277 - .probe = example_probe, 278 - .remove = example_remove, 279 - };
+285
Documentation/i2c/upgrading-clients.rst
··· 1 + ================================================= 2 + Upgrading I2C Drivers to the new 2.6 Driver Model 3 + ================================================= 4 + 5 + Ben Dooks <ben-linux@fluff.org> 6 + 7 + Introduction 8 + ------------ 9 + 10 + This guide outlines how to alter existing Linux 2.6 client drivers from 11 + the old to the new new binding methods. 12 + 13 + 14 + Example old-style driver 15 + ------------------------ 16 + 17 + :: 18 + 19 + struct example_state { 20 + struct i2c_client client; 21 + .... 22 + }; 23 + 24 + static struct i2c_driver example_driver; 25 + 26 + static unsigned short ignore[] = { I2C_CLIENT_END }; 27 + static unsigned short normal_addr[] = { OUR_ADDR, I2C_CLIENT_END }; 28 + 29 + I2C_CLIENT_INSMOD; 30 + 31 + static int example_attach(struct i2c_adapter *adap, int addr, int kind) 32 + { 33 + struct example_state *state; 34 + struct device *dev = &adap->dev; /* to use for dev_ reports */ 35 + int ret; 36 + 37 + state = kzalloc(sizeof(struct example_state), GFP_KERNEL); 38 + if (state == NULL) { 39 + dev_err(dev, "failed to create our state\n"); 40 + return -ENOMEM; 41 + } 42 + 43 + example->client.addr = addr; 44 + example->client.flags = 0; 45 + example->client.adapter = adap; 46 + 47 + i2c_set_clientdata(&state->i2c_client, state); 48 + strscpy(client->i2c_client.name, "example", sizeof(client->i2c_client.name)); 49 + 50 + ret = i2c_attach_client(&state->i2c_client); 51 + if (ret < 0) { 52 + dev_err(dev, "failed to attach client\n"); 53 + kfree(state); 54 + return ret; 55 + } 56 + 57 + dev = &state->i2c_client.dev; 58 + 59 + /* rest of the initialisation goes here. */ 60 + 61 + dev_info(dev, "example client created\n"); 62 + 63 + return 0; 64 + } 65 + 66 + static int example_detach(struct i2c_client *client) 67 + { 68 + struct example_state *state = i2c_get_clientdata(client); 69 + 70 + i2c_detach_client(client); 71 + kfree(state); 72 + return 0; 73 + } 74 + 75 + static int example_attach_adapter(struct i2c_adapter *adap) 76 + { 77 + return i2c_probe(adap, &addr_data, example_attach); 78 + } 79 + 80 + static struct i2c_driver example_driver = { 81 + .driver = { 82 + .owner = THIS_MODULE, 83 + .name = "example", 84 + .pm = &example_pm_ops, 85 + }, 86 + .attach_adapter = example_attach_adapter, 87 + .detach_client = example_detach, 88 + }; 89 + 90 + 91 + Updating the client 92 + ------------------- 93 + 94 + The new style binding model will check against a list of supported 95 + devices and their associated address supplied by the code registering 96 + the busses. This means that the driver .attach_adapter and 97 + .detach_client methods can be removed, along with the addr_data, 98 + as follows:: 99 + 100 + - static struct i2c_driver example_driver; 101 + 102 + - static unsigned short ignore[] = { I2C_CLIENT_END }; 103 + - static unsigned short normal_addr[] = { OUR_ADDR, I2C_CLIENT_END }; 104 + 105 + - I2C_CLIENT_INSMOD; 106 + 107 + - static int example_attach_adapter(struct i2c_adapter *adap) 108 + - { 109 + - return i2c_probe(adap, &addr_data, example_attach); 110 + - } 111 + 112 + static struct i2c_driver example_driver = { 113 + - .attach_adapter = example_attach_adapter, 114 + - .detach_client = example_detach, 115 + } 116 + 117 + Add the probe and remove methods to the i2c_driver, as so:: 118 + 119 + static struct i2c_driver example_driver = { 120 + + .probe = example_probe, 121 + + .remove = example_remove, 122 + } 123 + 124 + Change the example_attach method to accept the new parameters 125 + which include the i2c_client that it will be working with:: 126 + 127 + - static int example_attach(struct i2c_adapter *adap, int addr, int kind) 128 + + static int example_probe(struct i2c_client *client, 129 + + const struct i2c_device_id *id) 130 + 131 + Change the name of example_attach to example_probe to align it with the 132 + i2c_driver entry names. The rest of the probe routine will now need to be 133 + changed as the i2c_client has already been setup for use. 134 + 135 + The necessary client fields have already been setup before 136 + the probe function is called, so the following client setup 137 + can be removed:: 138 + 139 + - example->client.addr = addr; 140 + - example->client.flags = 0; 141 + - example->client.adapter = adap; 142 + - 143 + - strscpy(client->i2c_client.name, "example", sizeof(client->i2c_client.name)); 144 + 145 + The i2c_set_clientdata is now:: 146 + 147 + - i2c_set_clientdata(&state->client, state); 148 + + i2c_set_clientdata(client, state); 149 + 150 + The call to i2c_attach_client is no longer needed, if the probe 151 + routine exits successfully, then the driver will be automatically 152 + attached by the core. Change the probe routine as so:: 153 + 154 + - ret = i2c_attach_client(&state->i2c_client); 155 + - if (ret < 0) { 156 + - dev_err(dev, "failed to attach client\n"); 157 + - kfree(state); 158 + - return ret; 159 + - } 160 + 161 + 162 + Remove the storage of 'struct i2c_client' from the 'struct example_state' 163 + as we are provided with the i2c_client in our example_probe. Instead we 164 + store a pointer to it for when it is needed. 165 + 166 + :: 167 + 168 + struct example_state { 169 + - struct i2c_client client; 170 + + struct i2c_client *client; 171 + 172 + the new i2c client as so:: 173 + 174 + - struct device *dev = &adap->dev; /* to use for dev_ reports */ 175 + + struct device *dev = &i2c_client->dev; /* to use for dev_ reports */ 176 + 177 + And remove the change after our client is attached, as the driver no 178 + longer needs to register a new client structure with the core:: 179 + 180 + - dev = &state->i2c_client.dev; 181 + 182 + In the probe routine, ensure that the new state has the client stored 183 + in it:: 184 + 185 + static int example_probe(struct i2c_client *i2c_client, 186 + const struct i2c_device_id *id) 187 + { 188 + struct example_state *state; 189 + struct device *dev = &i2c_client->dev; 190 + int ret; 191 + 192 + state = kzalloc(sizeof(struct example_state), GFP_KERNEL); 193 + if (state == NULL) { 194 + dev_err(dev, "failed to create our state\n"); 195 + return -ENOMEM; 196 + } 197 + 198 + + state->client = i2c_client; 199 + 200 + Update the detach method, by changing the name to _remove and 201 + to delete the i2c_detach_client call. It is possible that you 202 + can also remove the ret variable as it is not needed for any 203 + of the core functions. 204 + 205 + :: 206 + 207 + - static int example_detach(struct i2c_client *client) 208 + + static int example_remove(struct i2c_client *client) 209 + { 210 + struct example_state *state = i2c_get_clientdata(client); 211 + 212 + - i2c_detach_client(client); 213 + 214 + And finally ensure that we have the correct ID table for the i2c-core 215 + and other utilities:: 216 + 217 + + struct i2c_device_id example_idtable[] = { 218 + + { "example", 0 }, 219 + + { } 220 + +}; 221 + + 222 + +MODULE_DEVICE_TABLE(i2c, example_idtable); 223 + 224 + static struct i2c_driver example_driver = { 225 + .driver = { 226 + .owner = THIS_MODULE, 227 + .name = "example", 228 + }, 229 + + .id_table = example_ids, 230 + 231 + 232 + Our driver should now look like this:: 233 + 234 + struct example_state { 235 + struct i2c_client *client; 236 + .... 237 + }; 238 + 239 + static int example_probe(struct i2c_client *client, 240 + const struct i2c_device_id *id) 241 + { 242 + struct example_state *state; 243 + struct device *dev = &client->dev; 244 + 245 + state = kzalloc(sizeof(struct example_state), GFP_KERNEL); 246 + if (state == NULL) { 247 + dev_err(dev, "failed to create our state\n"); 248 + return -ENOMEM; 249 + } 250 + 251 + state->client = client; 252 + i2c_set_clientdata(client, state); 253 + 254 + /* rest of the initialisation goes here. */ 255 + 256 + dev_info(dev, "example client created\n"); 257 + 258 + return 0; 259 + } 260 + 261 + static int example_remove(struct i2c_client *client) 262 + { 263 + struct example_state *state = i2c_get_clientdata(client); 264 + 265 + kfree(state); 266 + return 0; 267 + } 268 + 269 + static struct i2c_device_id example_idtable[] = { 270 + { "example", 0 }, 271 + { } 272 + }; 273 + 274 + MODULE_DEVICE_TABLE(i2c, example_idtable); 275 + 276 + static struct i2c_driver example_driver = { 277 + .driver = { 278 + .owner = THIS_MODULE, 279 + .name = "example", 280 + .pm = &example_pm_ops, 281 + }, 282 + .id_table = example_idtable, 283 + .probe = example_probe, 284 + .remove = example_remove, 285 + };
-403
Documentation/i2c/writing-clients
··· 1 - This is a small guide for those who want to write kernel drivers for I2C 2 - or SMBus devices, using Linux as the protocol host/master (not slave). 3 - 4 - To set up a driver, you need to do several things. Some are optional, and 5 - some things can be done slightly or completely different. Use this as a 6 - guide, not as a rule book! 7 - 8 - 9 - General remarks 10 - =============== 11 - 12 - Try to keep the kernel namespace as clean as possible. The best way to 13 - do this is to use a unique prefix for all global symbols. This is 14 - especially important for exported symbols, but it is a good idea to do 15 - it for non-exported symbols too. We will use the prefix `foo_' in this 16 - tutorial. 17 - 18 - 19 - The driver structure 20 - ==================== 21 - 22 - Usually, you will implement a single driver structure, and instantiate 23 - all clients from it. Remember, a driver structure contains general access 24 - routines, and should be zero-initialized except for fields with data you 25 - provide. A client structure holds device-specific information like the 26 - driver model device node, and its I2C address. 27 - 28 - static struct i2c_device_id foo_idtable[] = { 29 - { "foo", my_id_for_foo }, 30 - { "bar", my_id_for_bar }, 31 - { } 32 - }; 33 - 34 - MODULE_DEVICE_TABLE(i2c, foo_idtable); 35 - 36 - static struct i2c_driver foo_driver = { 37 - .driver = { 38 - .name = "foo", 39 - .pm = &foo_pm_ops, /* optional */ 40 - }, 41 - 42 - .id_table = foo_idtable, 43 - .probe = foo_probe, 44 - .remove = foo_remove, 45 - /* if device autodetection is needed: */ 46 - .class = I2C_CLASS_SOMETHING, 47 - .detect = foo_detect, 48 - .address_list = normal_i2c, 49 - 50 - .shutdown = foo_shutdown, /* optional */ 51 - .command = foo_command, /* optional, deprecated */ 52 - } 53 - 54 - The name field is the driver name, and must not contain spaces. It 55 - should match the module name (if the driver can be compiled as a module), 56 - although you can use MODULE_ALIAS (passing "foo" in this example) to add 57 - another name for the module. If the driver name doesn't match the module 58 - name, the module won't be automatically loaded (hotplug/coldplug). 59 - 60 - All other fields are for call-back functions which will be explained 61 - below. 62 - 63 - 64 - Extra client data 65 - ================= 66 - 67 - Each client structure has a special `data' field that can point to any 68 - structure at all. You should use this to keep device-specific data. 69 - 70 - /* store the value */ 71 - void i2c_set_clientdata(struct i2c_client *client, void *data); 72 - 73 - /* retrieve the value */ 74 - void *i2c_get_clientdata(const struct i2c_client *client); 75 - 76 - Note that starting with kernel 2.6.34, you don't have to set the `data' field 77 - to NULL in remove() or if probe() failed anymore. The i2c-core does this 78 - automatically on these occasions. Those are also the only times the core will 79 - touch this field. 80 - 81 - 82 - Accessing the client 83 - ==================== 84 - 85 - Let's say we have a valid client structure. At some time, we will need 86 - to gather information from the client, or write new information to the 87 - client. 88 - 89 - I have found it useful to define foo_read and foo_write functions for this. 90 - For some cases, it will be easier to call the i2c functions directly, 91 - but many chips have some kind of register-value idea that can easily 92 - be encapsulated. 93 - 94 - The below functions are simple examples, and should not be copied 95 - literally. 96 - 97 - int foo_read_value(struct i2c_client *client, u8 reg) 98 - { 99 - if (reg < 0x10) /* byte-sized register */ 100 - return i2c_smbus_read_byte_data(client, reg); 101 - else /* word-sized register */ 102 - return i2c_smbus_read_word_data(client, reg); 103 - } 104 - 105 - int foo_write_value(struct i2c_client *client, u8 reg, u16 value) 106 - { 107 - if (reg == 0x10) /* Impossible to write - driver error! */ 108 - return -EINVAL; 109 - else if (reg < 0x10) /* byte-sized register */ 110 - return i2c_smbus_write_byte_data(client, reg, value); 111 - else /* word-sized register */ 112 - return i2c_smbus_write_word_data(client, reg, value); 113 - } 114 - 115 - 116 - Probing and attaching 117 - ===================== 118 - 119 - The Linux I2C stack was originally written to support access to hardware 120 - monitoring chips on PC motherboards, and thus used to embed some assumptions 121 - that were more appropriate to SMBus (and PCs) than to I2C. One of these 122 - assumptions was that most adapters and devices drivers support the SMBUS_QUICK 123 - protocol to probe device presence. Another was that devices and their drivers 124 - can be sufficiently configured using only such probe primitives. 125 - 126 - As Linux and its I2C stack became more widely used in embedded systems 127 - and complex components such as DVB adapters, those assumptions became more 128 - problematic. Drivers for I2C devices that issue interrupts need more (and 129 - different) configuration information, as do drivers handling chip variants 130 - that can't be distinguished by protocol probing, or which need some board 131 - specific information to operate correctly. 132 - 133 - 134 - Device/Driver Binding 135 - --------------------- 136 - 137 - System infrastructure, typically board-specific initialization code or 138 - boot firmware, reports what I2C devices exist. For example, there may be 139 - a table, in the kernel or from the boot loader, identifying I2C devices 140 - and linking them to board-specific configuration information about IRQs 141 - and other wiring artifacts, chip type, and so on. That could be used to 142 - create i2c_client objects for each I2C device. 143 - 144 - I2C device drivers using this binding model work just like any other 145 - kind of driver in Linux: they provide a probe() method to bind to 146 - those devices, and a remove() method to unbind. 147 - 148 - static int foo_probe(struct i2c_client *client, 149 - const struct i2c_device_id *id); 150 - static int foo_remove(struct i2c_client *client); 151 - 152 - Remember that the i2c_driver does not create those client handles. The 153 - handle may be used during foo_probe(). If foo_probe() reports success 154 - (zero not a negative status code) it may save the handle and use it until 155 - foo_remove() returns. That binding model is used by most Linux drivers. 156 - 157 - The probe function is called when an entry in the id_table name field 158 - matches the device's name. It is passed the entry that was matched so 159 - the driver knows which one in the table matched. 160 - 161 - 162 - Device Creation 163 - --------------- 164 - 165 - If you know for a fact that an I2C device is connected to a given I2C bus, 166 - you can instantiate that device by simply filling an i2c_board_info 167 - structure with the device address and driver name, and calling 168 - i2c_new_device(). This will create the device, then the driver core will 169 - take care of finding the right driver and will call its probe() method. 170 - If a driver supports different device types, you can specify the type you 171 - want using the type field. You can also specify an IRQ and platform data 172 - if needed. 173 - 174 - Sometimes you know that a device is connected to a given I2C bus, but you 175 - don't know the exact address it uses. This happens on TV adapters for 176 - example, where the same driver supports dozens of slightly different 177 - models, and I2C device addresses change from one model to the next. In 178 - that case, you can use the i2c_new_probed_device() variant, which is 179 - similar to i2c_new_device(), except that it takes an additional list of 180 - possible I2C addresses to probe. A device is created for the first 181 - responsive address in the list. If you expect more than one device to be 182 - present in the address range, simply call i2c_new_probed_device() that 183 - many times. 184 - 185 - The call to i2c_new_device() or i2c_new_probed_device() typically happens 186 - in the I2C bus driver. You may want to save the returned i2c_client 187 - reference for later use. 188 - 189 - 190 - Device Detection 191 - ---------------- 192 - 193 - Sometimes you do not know in advance which I2C devices are connected to 194 - a given I2C bus. This is for example the case of hardware monitoring 195 - devices on a PC's SMBus. In that case, you may want to let your driver 196 - detect supported devices automatically. This is how the legacy model 197 - was working, and is now available as an extension to the standard 198 - driver model. 199 - 200 - You simply have to define a detect callback which will attempt to 201 - identify supported devices (returning 0 for supported ones and -ENODEV 202 - for unsupported ones), a list of addresses to probe, and a device type 203 - (or class) so that only I2C buses which may have that type of device 204 - connected (and not otherwise enumerated) will be probed. For example, 205 - a driver for a hardware monitoring chip for which auto-detection is 206 - needed would set its class to I2C_CLASS_HWMON, and only I2C adapters 207 - with a class including I2C_CLASS_HWMON would be probed by this driver. 208 - Note that the absence of matching classes does not prevent the use of 209 - a device of that type on the given I2C adapter. All it prevents is 210 - auto-detection; explicit instantiation of devices is still possible. 211 - 212 - Note that this mechanism is purely optional and not suitable for all 213 - devices. You need some reliable way to identify the supported devices 214 - (typically using device-specific, dedicated identification registers), 215 - otherwise misdetections are likely to occur and things can get wrong 216 - quickly. Keep in mind that the I2C protocol doesn't include any 217 - standard way to detect the presence of a chip at a given address, let 218 - alone a standard way to identify devices. Even worse is the lack of 219 - semantics associated to bus transfers, which means that the same 220 - transfer can be seen as a read operation by a chip and as a write 221 - operation by another chip. For these reasons, explicit device 222 - instantiation should always be preferred to auto-detection where 223 - possible. 224 - 225 - 226 - Device Deletion 227 - --------------- 228 - 229 - Each I2C device which has been created using i2c_new_device() or 230 - i2c_new_probed_device() can be unregistered by calling 231 - i2c_unregister_device(). If you don't call it explicitly, it will be 232 - called automatically before the underlying I2C bus itself is removed, as a 233 - device can't survive its parent in the device driver model. 234 - 235 - 236 - Initializing the driver 237 - ======================= 238 - 239 - When the kernel is booted, or when your foo driver module is inserted, 240 - you have to do some initializing. Fortunately, just registering the 241 - driver module is usually enough. 242 - 243 - static int __init foo_init(void) 244 - { 245 - return i2c_add_driver(&foo_driver); 246 - } 247 - module_init(foo_init); 248 - 249 - static void __exit foo_cleanup(void) 250 - { 251 - i2c_del_driver(&foo_driver); 252 - } 253 - module_exit(foo_cleanup); 254 - 255 - The module_i2c_driver() macro can be used to reduce above code. 256 - 257 - module_i2c_driver(foo_driver); 258 - 259 - Note that some functions are marked by `__init'. These functions can 260 - be removed after kernel booting (or module loading) is completed. 261 - Likewise, functions marked by `__exit' are dropped by the compiler when 262 - the code is built into the kernel, as they would never be called. 263 - 264 - 265 - Driver Information 266 - ================== 267 - 268 - /* Substitute your own name and email address */ 269 - MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>" 270 - MODULE_DESCRIPTION("Driver for Barf Inc. Foo I2C devices"); 271 - 272 - /* a few non-GPL license types are also allowed */ 273 - MODULE_LICENSE("GPL"); 274 - 275 - 276 - Power Management 277 - ================ 278 - 279 - If your I2C device needs special handling when entering a system low 280 - power state -- like putting a transceiver into a low power mode, or 281 - activating a system wakeup mechanism -- do that by implementing the 282 - appropriate callbacks for the dev_pm_ops of the driver (like suspend 283 - and resume). 284 - 285 - These are standard driver model calls, and they work just like they 286 - would for any other driver stack. The calls can sleep, and can use 287 - I2C messaging to the device being suspended or resumed (since their 288 - parent I2C adapter is active when these calls are issued, and IRQs 289 - are still enabled). 290 - 291 - 292 - System Shutdown 293 - =============== 294 - 295 - If your I2C device needs special handling when the system shuts down 296 - or reboots (including kexec) -- like turning something off -- use a 297 - shutdown() method. 298 - 299 - Again, this is a standard driver model call, working just like it 300 - would for any other driver stack: the calls can sleep, and can use 301 - I2C messaging. 302 - 303 - 304 - Command function 305 - ================ 306 - 307 - A generic ioctl-like function call back is supported. You will seldom 308 - need this, and its use is deprecated anyway, so newer design should not 309 - use it. 310 - 311 - 312 - Sending and receiving 313 - ===================== 314 - 315 - If you want to communicate with your device, there are several functions 316 - to do this. You can find all of them in <linux/i2c.h>. 317 - 318 - If you can choose between plain I2C communication and SMBus level 319 - communication, please use the latter. All adapters understand SMBus level 320 - commands, but only some of them understand plain I2C! 321 - 322 - 323 - Plain I2C communication 324 - ----------------------- 325 - 326 - int i2c_master_send(struct i2c_client *client, const char *buf, 327 - int count); 328 - int i2c_master_recv(struct i2c_client *client, char *buf, int count); 329 - 330 - These routines read and write some bytes from/to a client. The client 331 - contains the i2c address, so you do not have to include it. The second 332 - parameter contains the bytes to read/write, the third the number of bytes 333 - to read/write (must be less than the length of the buffer, also should be 334 - less than 64k since msg.len is u16.) Returned is the actual number of bytes 335 - read/written. 336 - 337 - int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msg, 338 - int num); 339 - 340 - This sends a series of messages. Each message can be a read or write, 341 - and they can be mixed in any way. The transactions are combined: no 342 - stop bit is sent between transaction. The i2c_msg structure contains 343 - for each message the client address, the number of bytes of the message 344 - and the message data itself. 345 - 346 - You can read the file `i2c-protocol' for more information about the 347 - actual I2C protocol. 348 - 349 - 350 - SMBus communication 351 - ------------------- 352 - 353 - s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, 354 - unsigned short flags, char read_write, u8 command, 355 - int size, union i2c_smbus_data *data); 356 - 357 - This is the generic SMBus function. All functions below are implemented 358 - in terms of it. Never use this function directly! 359 - 360 - s32 i2c_smbus_read_byte(struct i2c_client *client); 361 - s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value); 362 - s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command); 363 - s32 i2c_smbus_write_byte_data(struct i2c_client *client, 364 - u8 command, u8 value); 365 - s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command); 366 - s32 i2c_smbus_write_word_data(struct i2c_client *client, 367 - u8 command, u16 value); 368 - s32 i2c_smbus_read_block_data(struct i2c_client *client, 369 - u8 command, u8 *values); 370 - s32 i2c_smbus_write_block_data(struct i2c_client *client, 371 - u8 command, u8 length, const u8 *values); 372 - s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, 373 - u8 command, u8 length, u8 *values); 374 - s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, 375 - u8 command, u8 length, 376 - const u8 *values); 377 - 378 - These ones were removed from i2c-core because they had no users, but could 379 - be added back later if needed: 380 - 381 - s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value); 382 - s32 i2c_smbus_process_call(struct i2c_client *client, 383 - u8 command, u16 value); 384 - s32 i2c_smbus_block_process_call(struct i2c_client *client, 385 - u8 command, u8 length, u8 *values); 386 - 387 - All these transactions return a negative errno value on failure. The 'write' 388 - transactions return 0 on success; the 'read' transactions return the read 389 - value, except for block transactions, which return the number of values 390 - read. The block buffers need not be longer than 32 bytes. 391 - 392 - You can read the file `smbus-protocol' for more information about the 393 - actual SMBus protocol. 394 - 395 - 396 - General purpose routines 397 - ======================== 398 - 399 - Below all general purpose routines are listed, that were not mentioned 400 - before. 401 - 402 - /* Return the adapter number for a specific adapter */ 403 - int i2c_adapter_id(struct i2c_adapter *adap);
+425
Documentation/i2c/writing-clients.rst
··· 1 + =================== 2 + Writing I2C Clients 3 + =================== 4 + 5 + This is a small guide for those who want to write kernel drivers for I2C 6 + or SMBus devices, using Linux as the protocol host/master (not slave). 7 + 8 + To set up a driver, you need to do several things. Some are optional, and 9 + some things can be done slightly or completely different. Use this as a 10 + guide, not as a rule book! 11 + 12 + 13 + General remarks 14 + =============== 15 + 16 + Try to keep the kernel namespace as clean as possible. The best way to 17 + do this is to use a unique prefix for all global symbols. This is 18 + especially important for exported symbols, but it is a good idea to do 19 + it for non-exported symbols too. We will use the prefix ``foo_`` in this 20 + tutorial. 21 + 22 + 23 + The driver structure 24 + ==================== 25 + 26 + Usually, you will implement a single driver structure, and instantiate 27 + all clients from it. Remember, a driver structure contains general access 28 + routines, and should be zero-initialized except for fields with data you 29 + provide. A client structure holds device-specific information like the 30 + driver model device node, and its I2C address. 31 + 32 + :: 33 + 34 + static struct i2c_device_id foo_idtable[] = { 35 + { "foo", my_id_for_foo }, 36 + { "bar", my_id_for_bar }, 37 + { } 38 + }; 39 + 40 + MODULE_DEVICE_TABLE(i2c, foo_idtable); 41 + 42 + static struct i2c_driver foo_driver = { 43 + .driver = { 44 + .name = "foo", 45 + .pm = &foo_pm_ops, /* optional */ 46 + }, 47 + 48 + .id_table = foo_idtable, 49 + .probe = foo_probe, 50 + .remove = foo_remove, 51 + /* if device autodetection is needed: */ 52 + .class = I2C_CLASS_SOMETHING, 53 + .detect = foo_detect, 54 + .address_list = normal_i2c, 55 + 56 + .shutdown = foo_shutdown, /* optional */ 57 + .command = foo_command, /* optional, deprecated */ 58 + } 59 + 60 + The name field is the driver name, and must not contain spaces. It 61 + should match the module name (if the driver can be compiled as a module), 62 + although you can use MODULE_ALIAS (passing "foo" in this example) to add 63 + another name for the module. If the driver name doesn't match the module 64 + name, the module won't be automatically loaded (hotplug/coldplug). 65 + 66 + All other fields are for call-back functions which will be explained 67 + below. 68 + 69 + 70 + Extra client data 71 + ================= 72 + 73 + Each client structure has a special ``data`` field that can point to any 74 + structure at all. You should use this to keep device-specific data. 75 + 76 + :: 77 + 78 + /* store the value */ 79 + void i2c_set_clientdata(struct i2c_client *client, void *data); 80 + 81 + /* retrieve the value */ 82 + void *i2c_get_clientdata(const struct i2c_client *client); 83 + 84 + Note that starting with kernel 2.6.34, you don't have to set the ``data`` field 85 + to NULL in remove() or if probe() failed anymore. The i2c-core does this 86 + automatically on these occasions. Those are also the only times the core will 87 + touch this field. 88 + 89 + 90 + Accessing the client 91 + ==================== 92 + 93 + Let's say we have a valid client structure. At some time, we will need 94 + to gather information from the client, or write new information to the 95 + client. 96 + 97 + I have found it useful to define foo_read and foo_write functions for this. 98 + For some cases, it will be easier to call the i2c functions directly, 99 + but many chips have some kind of register-value idea that can easily 100 + be encapsulated. 101 + 102 + The below functions are simple examples, and should not be copied 103 + literally:: 104 + 105 + int foo_read_value(struct i2c_client *client, u8 reg) 106 + { 107 + if (reg < 0x10) /* byte-sized register */ 108 + return i2c_smbus_read_byte_data(client, reg); 109 + else /* word-sized register */ 110 + return i2c_smbus_read_word_data(client, reg); 111 + } 112 + 113 + int foo_write_value(struct i2c_client *client, u8 reg, u16 value) 114 + { 115 + if (reg == 0x10) /* Impossible to write - driver error! */ 116 + return -EINVAL; 117 + else if (reg < 0x10) /* byte-sized register */ 118 + return i2c_smbus_write_byte_data(client, reg, value); 119 + else /* word-sized register */ 120 + return i2c_smbus_write_word_data(client, reg, value); 121 + } 122 + 123 + 124 + Probing and attaching 125 + ===================== 126 + 127 + The Linux I2C stack was originally written to support access to hardware 128 + monitoring chips on PC motherboards, and thus used to embed some assumptions 129 + that were more appropriate to SMBus (and PCs) than to I2C. One of these 130 + assumptions was that most adapters and devices drivers support the SMBUS_QUICK 131 + protocol to probe device presence. Another was that devices and their drivers 132 + can be sufficiently configured using only such probe primitives. 133 + 134 + As Linux and its I2C stack became more widely used in embedded systems 135 + and complex components such as DVB adapters, those assumptions became more 136 + problematic. Drivers for I2C devices that issue interrupts need more (and 137 + different) configuration information, as do drivers handling chip variants 138 + that can't be distinguished by protocol probing, or which need some board 139 + specific information to operate correctly. 140 + 141 + 142 + Device/Driver Binding 143 + --------------------- 144 + 145 + System infrastructure, typically board-specific initialization code or 146 + boot firmware, reports what I2C devices exist. For example, there may be 147 + a table, in the kernel or from the boot loader, identifying I2C devices 148 + and linking them to board-specific configuration information about IRQs 149 + and other wiring artifacts, chip type, and so on. That could be used to 150 + create i2c_client objects for each I2C device. 151 + 152 + I2C device drivers using this binding model work just like any other 153 + kind of driver in Linux: they provide a probe() method to bind to 154 + those devices, and a remove() method to unbind. 155 + 156 + :: 157 + 158 + static int foo_probe(struct i2c_client *client, 159 + const struct i2c_device_id *id); 160 + static int foo_remove(struct i2c_client *client); 161 + 162 + Remember that the i2c_driver does not create those client handles. The 163 + handle may be used during foo_probe(). If foo_probe() reports success 164 + (zero not a negative status code) it may save the handle and use it until 165 + foo_remove() returns. That binding model is used by most Linux drivers. 166 + 167 + The probe function is called when an entry in the id_table name field 168 + matches the device's name. It is passed the entry that was matched so 169 + the driver knows which one in the table matched. 170 + 171 + 172 + Device Creation 173 + --------------- 174 + 175 + If you know for a fact that an I2C device is connected to a given I2C bus, 176 + you can instantiate that device by simply filling an i2c_board_info 177 + structure with the device address and driver name, and calling 178 + i2c_new_device(). This will create the device, then the driver core will 179 + take care of finding the right driver and will call its probe() method. 180 + If a driver supports different device types, you can specify the type you 181 + want using the type field. You can also specify an IRQ and platform data 182 + if needed. 183 + 184 + Sometimes you know that a device is connected to a given I2C bus, but you 185 + don't know the exact address it uses. This happens on TV adapters for 186 + example, where the same driver supports dozens of slightly different 187 + models, and I2C device addresses change from one model to the next. In 188 + that case, you can use the i2c_new_probed_device() variant, which is 189 + similar to i2c_new_device(), except that it takes an additional list of 190 + possible I2C addresses to probe. A device is created for the first 191 + responsive address in the list. If you expect more than one device to be 192 + present in the address range, simply call i2c_new_probed_device() that 193 + many times. 194 + 195 + The call to i2c_new_device() or i2c_new_probed_device() typically happens 196 + in the I2C bus driver. You may want to save the returned i2c_client 197 + reference for later use. 198 + 199 + 200 + Device Detection 201 + ---------------- 202 + 203 + Sometimes you do not know in advance which I2C devices are connected to 204 + a given I2C bus. This is for example the case of hardware monitoring 205 + devices on a PC's SMBus. In that case, you may want to let your driver 206 + detect supported devices automatically. This is how the legacy model 207 + was working, and is now available as an extension to the standard 208 + driver model. 209 + 210 + You simply have to define a detect callback which will attempt to 211 + identify supported devices (returning 0 for supported ones and -ENODEV 212 + for unsupported ones), a list of addresses to probe, and a device type 213 + (or class) so that only I2C buses which may have that type of device 214 + connected (and not otherwise enumerated) will be probed. For example, 215 + a driver for a hardware monitoring chip for which auto-detection is 216 + needed would set its class to I2C_CLASS_HWMON, and only I2C adapters 217 + with a class including I2C_CLASS_HWMON would be probed by this driver. 218 + Note that the absence of matching classes does not prevent the use of 219 + a device of that type on the given I2C adapter. All it prevents is 220 + auto-detection; explicit instantiation of devices is still possible. 221 + 222 + Note that this mechanism is purely optional and not suitable for all 223 + devices. You need some reliable way to identify the supported devices 224 + (typically using device-specific, dedicated identification registers), 225 + otherwise misdetections are likely to occur and things can get wrong 226 + quickly. Keep in mind that the I2C protocol doesn't include any 227 + standard way to detect the presence of a chip at a given address, let 228 + alone a standard way to identify devices. Even worse is the lack of 229 + semantics associated to bus transfers, which means that the same 230 + transfer can be seen as a read operation by a chip and as a write 231 + operation by another chip. For these reasons, explicit device 232 + instantiation should always be preferred to auto-detection where 233 + possible. 234 + 235 + 236 + Device Deletion 237 + --------------- 238 + 239 + Each I2C device which has been created using i2c_new_device() or 240 + i2c_new_probed_device() can be unregistered by calling 241 + i2c_unregister_device(). If you don't call it explicitly, it will be 242 + called automatically before the underlying I2C bus itself is removed, as a 243 + device can't survive its parent in the device driver model. 244 + 245 + 246 + Initializing the driver 247 + ======================= 248 + 249 + When the kernel is booted, or when your foo driver module is inserted, 250 + you have to do some initializing. Fortunately, just registering the 251 + driver module is usually enough. 252 + 253 + :: 254 + 255 + static int __init foo_init(void) 256 + { 257 + return i2c_add_driver(&foo_driver); 258 + } 259 + module_init(foo_init); 260 + 261 + static void __exit foo_cleanup(void) 262 + { 263 + i2c_del_driver(&foo_driver); 264 + } 265 + module_exit(foo_cleanup); 266 + 267 + The module_i2c_driver() macro can be used to reduce above code. 268 + 269 + module_i2c_driver(foo_driver); 270 + 271 + Note that some functions are marked by ``__init``. These functions can 272 + be removed after kernel booting (or module loading) is completed. 273 + Likewise, functions marked by ``__exit`` are dropped by the compiler when 274 + the code is built into the kernel, as they would never be called. 275 + 276 + 277 + Driver Information 278 + ================== 279 + 280 + :: 281 + 282 + /* Substitute your own name and email address */ 283 + MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>" 284 + MODULE_DESCRIPTION("Driver for Barf Inc. Foo I2C devices"); 285 + 286 + /* a few non-GPL license types are also allowed */ 287 + MODULE_LICENSE("GPL"); 288 + 289 + 290 + Power Management 291 + ================ 292 + 293 + If your I2C device needs special handling when entering a system low 294 + power state -- like putting a transceiver into a low power mode, or 295 + activating a system wakeup mechanism -- do that by implementing the 296 + appropriate callbacks for the dev_pm_ops of the driver (like suspend 297 + and resume). 298 + 299 + These are standard driver model calls, and they work just like they 300 + would for any other driver stack. The calls can sleep, and can use 301 + I2C messaging to the device being suspended or resumed (since their 302 + parent I2C adapter is active when these calls are issued, and IRQs 303 + are still enabled). 304 + 305 + 306 + System Shutdown 307 + =============== 308 + 309 + If your I2C device needs special handling when the system shuts down 310 + or reboots (including kexec) -- like turning something off -- use a 311 + shutdown() method. 312 + 313 + Again, this is a standard driver model call, working just like it 314 + would for any other driver stack: the calls can sleep, and can use 315 + I2C messaging. 316 + 317 + 318 + Command function 319 + ================ 320 + 321 + A generic ioctl-like function call back is supported. You will seldom 322 + need this, and its use is deprecated anyway, so newer design should not 323 + use it. 324 + 325 + 326 + Sending and receiving 327 + ===================== 328 + 329 + If you want to communicate with your device, there are several functions 330 + to do this. You can find all of them in <linux/i2c.h>. 331 + 332 + If you can choose between plain I2C communication and SMBus level 333 + communication, please use the latter. All adapters understand SMBus level 334 + commands, but only some of them understand plain I2C! 335 + 336 + 337 + Plain I2C communication 338 + ----------------------- 339 + 340 + :: 341 + 342 + int i2c_master_send(struct i2c_client *client, const char *buf, 343 + int count); 344 + int i2c_master_recv(struct i2c_client *client, char *buf, int count); 345 + 346 + These routines read and write some bytes from/to a client. The client 347 + contains the i2c address, so you do not have to include it. The second 348 + parameter contains the bytes to read/write, the third the number of bytes 349 + to read/write (must be less than the length of the buffer, also should be 350 + less than 64k since msg.len is u16.) Returned is the actual number of bytes 351 + read/written. 352 + 353 + :: 354 + 355 + int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msg, 356 + int num); 357 + 358 + This sends a series of messages. Each message can be a read or write, 359 + and they can be mixed in any way. The transactions are combined: no 360 + stop bit is sent between transaction. The i2c_msg structure contains 361 + for each message the client address, the number of bytes of the message 362 + and the message data itself. 363 + 364 + You can read the file ``i2c-protocol`` for more information about the 365 + actual I2C protocol. 366 + 367 + 368 + SMBus communication 369 + ------------------- 370 + 371 + :: 372 + 373 + s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, 374 + unsigned short flags, char read_write, u8 command, 375 + int size, union i2c_smbus_data *data); 376 + 377 + This is the generic SMBus function. All functions below are implemented 378 + in terms of it. Never use this function directly! 379 + 380 + :: 381 + 382 + s32 i2c_smbus_read_byte(struct i2c_client *client); 383 + s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value); 384 + s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command); 385 + s32 i2c_smbus_write_byte_data(struct i2c_client *client, 386 + u8 command, u8 value); 387 + s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command); 388 + s32 i2c_smbus_write_word_data(struct i2c_client *client, 389 + u8 command, u16 value); 390 + s32 i2c_smbus_read_block_data(struct i2c_client *client, 391 + u8 command, u8 *values); 392 + s32 i2c_smbus_write_block_data(struct i2c_client *client, 393 + u8 command, u8 length, const u8 *values); 394 + s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, 395 + u8 command, u8 length, u8 *values); 396 + s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, 397 + u8 command, u8 length, 398 + const u8 *values); 399 + 400 + These ones were removed from i2c-core because they had no users, but could 401 + be added back later if needed:: 402 + 403 + s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value); 404 + s32 i2c_smbus_process_call(struct i2c_client *client, 405 + u8 command, u16 value); 406 + s32 i2c_smbus_block_process_call(struct i2c_client *client, 407 + u8 command, u8 length, u8 *values); 408 + 409 + All these transactions return a negative errno value on failure. The 'write' 410 + transactions return 0 on success; the 'read' transactions return the read 411 + value, except for block transactions, which return the number of values 412 + read. The block buffers need not be longer than 32 bytes. 413 + 414 + You can read the file ``smbus-protocol`` for more information about the 415 + actual SMBus protocol. 416 + 417 + 418 + General purpose routines 419 + ======================== 420 + 421 + Below all general purpose routines are listed, that were not mentioned 422 + before:: 423 + 424 + /* Return the adapter number for a specific adapter */ 425 + int i2c_adapter_id(struct i2c_adapter *adap);
+1
Documentation/index.rst
··· 104 104 fb/index 105 105 fpga/index 106 106 hid/index 107 + i2c/index 107 108 iio/index 108 109 infiniband/index 109 110 leds/index
+1 -1
Documentation/spi/spi-sc18is602
··· 17 17 18 18 The driver does not probe for supported chips, since the SI18IS602/603 does not 19 19 support Chip ID registers. You will have to instantiate the devices explicitly. 20 - Please see Documentation/i2c/instantiating-devices for details. 20 + Please see Documentation/i2c/instantiating-devices.rst for details. 21 21 22 22 23 23 Usage Notes
+24 -24
MAINTAINERS
··· 666 666 M: Rudolf Marek <r.marek@assembler.cz> 667 667 L: linux-i2c@vger.kernel.org 668 668 S: Maintained 669 - F: Documentation/i2c/busses/i2c-ali1563 669 + F: Documentation/i2c/busses/i2c-ali1563.rst 670 670 F: drivers/i2c/busses/i2c-ali1563.c 671 671 672 672 ALLEGRO DVT VIDEO IP CORE DRIVER ··· 6741 6741 S: Supported 6742 6742 F: drivers/i2c/muxes/i2c-mux-gpio.c 6743 6743 F: include/linux/platform_data/i2c-mux-gpio.h 6744 - F: Documentation/i2c/muxes/i2c-mux-gpio 6744 + F: Documentation/i2c/muxes/i2c-mux-gpio.rst 6745 6745 6746 6746 GENERIC HDLC (WAN) DRIVERS 6747 6747 M: Krzysztof Halasa <khc@pm.waw.pl> ··· 7497 7497 M: Ajay Gupta <ajayg@nvidia.com> 7498 7498 L: linux-i2c@vger.kernel.org 7499 7499 S: Maintained 7500 - F: Documentation/i2c/busses/i2c-nvidia-gpu 7500 + F: Documentation/i2c/busses/i2c-nvidia-gpu.rst 7501 7501 F: drivers/i2c/busses/i2c-nvidia-gpu.c 7502 7502 7503 7503 I2C MUXES 7504 7504 M: Peter Rosin <peda@axentia.se> 7505 7505 L: linux-i2c@vger.kernel.org 7506 7506 S: Maintained 7507 - F: Documentation/i2c/i2c-topology 7507 + F: Documentation/i2c/i2c-topology.rst 7508 7508 F: Documentation/i2c/muxes/ 7509 7509 F: Documentation/devicetree/bindings/i2c/i2c-mux* 7510 7510 F: Documentation/devicetree/bindings/i2c/i2c-arb* ··· 7524 7524 M: Jean Delvare <jdelvare@suse.com> 7525 7525 L: linux-i2c@vger.kernel.org 7526 7526 S: Maintained 7527 - F: Documentation/i2c/busses/i2c-parport 7528 - F: Documentation/i2c/busses/i2c-parport-light 7527 + F: Documentation/i2c/busses/i2c-parport.rst 7528 + F: Documentation/i2c/busses/i2c-parport-light.rst 7529 7529 F: drivers/i2c/busses/i2c-parport.c 7530 7530 F: drivers/i2c/busses/i2c-parport-light.c 7531 7531 ··· 7559 7559 M: Jean Delvare <jdelvare@suse.com> 7560 7560 L: linux-i2c@vger.kernel.org 7561 7561 S: Maintained 7562 - F: Documentation/i2c/busses/i2c-taos-evm 7562 + F: Documentation/i2c/busses/i2c-taos-evm.rst 7563 7563 F: drivers/i2c/busses/i2c-taos-evm.c 7564 7564 7565 7565 I2C-TINY-USB DRIVER ··· 7573 7573 M: Jean Delvare <jdelvare@suse.com> 7574 7574 L: linux-i2c@vger.kernel.org 7575 7575 S: Maintained 7576 - F: Documentation/i2c/busses/i2c-ali1535 7577 - F: Documentation/i2c/busses/i2c-ali1563 7578 - F: Documentation/i2c/busses/i2c-ali15x3 7579 - F: Documentation/i2c/busses/i2c-amd756 7580 - F: Documentation/i2c/busses/i2c-amd8111 7581 - F: Documentation/i2c/busses/i2c-i801 7582 - F: Documentation/i2c/busses/i2c-nforce2 7583 - F: Documentation/i2c/busses/i2c-piix4 7584 - F: Documentation/i2c/busses/i2c-sis5595 7585 - F: Documentation/i2c/busses/i2c-sis630 7586 - F: Documentation/i2c/busses/i2c-sis96x 7587 - F: Documentation/i2c/busses/i2c-via 7588 - F: Documentation/i2c/busses/i2c-viapro 7576 + F: Documentation/i2c/busses/i2c-ali1535.rst 7577 + F: Documentation/i2c/busses/i2c-ali1563.rst 7578 + F: Documentation/i2c/busses/i2c-ali15x3.rst 7579 + F: Documentation/i2c/busses/i2c-amd756.rst 7580 + F: Documentation/i2c/busses/i2c-amd8111.rst 7581 + F: Documentation/i2c/busses/i2c-i801.rst 7582 + F: Documentation/i2c/busses/i2c-nforce2.rst 7583 + F: Documentation/i2c/busses/i2c-piix4.rst 7584 + F: Documentation/i2c/busses/i2c-sis5595.rst 7585 + F: Documentation/i2c/busses/i2c-sis630.rst 7586 + F: Documentation/i2c/busses/i2c-sis96x.rst 7587 + F: Documentation/i2c/busses/i2c-via.rst 7588 + F: Documentation/i2c/busses/i2c-viapro.rst 7589 7589 F: drivers/i2c/busses/i2c-ali1535.c 7590 7590 F: drivers/i2c/busses/i2c-ali1563.c 7591 7591 F: drivers/i2c/busses/i2c-ali15x3.c ··· 7614 7614 M: Neil Horman <nhorman@tuxdriver.com> 7615 7615 L: linux-i2c@vger.kernel.org 7616 7616 F: drivers/i2c/busses/i2c-ismt.c 7617 - F: Documentation/i2c/busses/i2c-ismt 7617 + F: Documentation/i2c/busses/i2c-ismt.rst 7618 7618 7619 7619 I2C/SMBUS STUB DRIVER 7620 7620 M: Jean Delvare <jdelvare@suse.com> ··· 10355 10355 S: Supported 10356 10356 F: drivers/i2c/busses/i2c-mlxcpld.c 10357 10357 F: drivers/i2c/muxes/i2c-mux-mlxcpld.c 10358 - F: Documentation/i2c/busses/i2c-mlxcpld 10358 + F: Documentation/i2c/busses/i2c-mlxcpld.rst 10359 10359 10360 10360 MELLANOX MLXCPLD LED DRIVER 10361 10361 M: Vadim Pasternak <vadimp@mellanox.com> ··· 11976 11976 L: linux-i2c@vger.kernel.org 11977 11977 S: Maintained 11978 11978 F: Documentation/devicetree/bindings/i2c/i2c-ocores.txt 11979 - F: Documentation/i2c/busses/i2c-ocores 11979 + F: Documentation/i2c/busses/i2c-ocores.rst 11980 11980 F: drivers/i2c/busses/i2c-ocores.c 11981 11981 F: include/linux/platform_data/i2c-ocores.h 11982 11982 ··· 14280 14280 SCx200 CPU SUPPORT 14281 14281 M: Jim Cromie <jim.cromie@gmail.com> 14282 14282 S: Odd Fixes 14283 - F: Documentation/i2c/busses/scx200_acb 14283 + F: Documentation/i2c/busses/scx200_acb.rst 14284 14284 F: arch/x86/platform/scx200/ 14285 14285 F: drivers/watchdog/scx200_wdt.c 14286 14286 F: drivers/i2c/busses/scx200*
+1 -1
drivers/hwmon/atxp1.c
··· 5 5 * 6 6 * The ATXP1 can reside on I2C addresses 0x37 or 0x4e. The chip is 7 7 * not auto-detected by the driver and must be instantiated explicitly. 8 - * See Documentation/i2c/instantiating-devices for more information. 8 + * See Documentation/i2c/instantiating-devices.rst for more information. 9 9 */ 10 10 11 11 #include <linux/kernel.h>
+1 -1
drivers/hwmon/smm665.c
··· 197 197 if (rv != -ENXIO) { 198 198 /* 199 199 * We expect ENXIO to reflect NACK 200 - * (per Documentation/i2c/fault-codes). 200 + * (per Documentation/i2c/fault-codes.rst). 201 201 * Everything else is an error. 202 202 */ 203 203 dev_dbg(&client->dev,
+2 -2
drivers/i2c/Kconfig
··· 54 54 Say Y here to use i2c-* device files, usually found in the /dev 55 55 directory on your system. They make it possible to have user-space 56 56 programs use the I2C bus. Information on how to do this is 57 - contained in the file <file:Documentation/i2c/dev-interface>. 57 + contained in the file <file:Documentation/i2c/dev-interface.rst>. 58 58 59 59 This support is also available as a module. If so, the module 60 60 will be called i2c-dev. ··· 107 107 especially for certain kinds of sensor chips. 108 108 109 109 If you do build this module, be sure to read the notes and warnings 110 - in <file:Documentation/i2c/i2c-stub>. 110 + in <file:Documentation/i2c/i2c-stub.rst>. 111 111 112 112 If you don't know what to do here, definitely say N. 113 113
+1 -1
drivers/i2c/busses/Kconfig
··· 1206 1206 and makes it easier to add support for new devices. 1207 1207 1208 1208 An adapter type parameter is now mandatory. Please read the file 1209 - Documentation/i2c/busses/i2c-parport for details. 1209 + Documentation/i2c/busses/i2c-parport.rst for details. 1210 1210 1211 1211 Another driver exists, named i2c-parport-light, which doesn't depend 1212 1212 on the parport driver. This is meant for embedded systems. Don't say
+1 -1
drivers/i2c/busses/i2c-i801.c
··· 77 77 * SMBus Host Notify yes 78 78 * Interrupt processing yes 79 79 * 80 - * See the file Documentation/i2c/busses/i2c-i801 for details. 80 + * See the file Documentation/i2c/busses/i2c-i801.rst for details. 81 81 */ 82 82 83 83 #include <linux/interrupt.h>
+1 -1
drivers/i2c/busses/i2c-taos-evm.c
··· 125 125 /* 126 126 * Voluntarily dropping error code of kstrtou8 since all 127 127 * error code that it could return are invalid according 128 - * to Documentation/i2c/fault-codes. 128 + * to Documentation/i2c/fault-codes.rst. 129 129 */ 130 130 if (kstrtou8(p + 1, 16, &data->byte)) 131 131 return -EPROTO;
+2 -2
drivers/i2c/i2c-core-base.c
··· 2206 2206 dev_warn(&adapter->dev, 2207 2207 "This adapter will soon drop class based instantiation of devices. " 2208 2208 "Please make sure client 0x%02x gets instantiated by other means. " 2209 - "Check 'Documentation/i2c/instantiating-devices' for details.\n", 2209 + "Check 'Documentation/i2c/instantiating-devices.rst' for details.\n", 2210 2210 info.addr); 2211 2211 2212 2212 dev_dbg(&adapter->dev, "Creating %s at 0x%02x\n", ··· 2236 2236 if (adapter->class == I2C_CLASS_DEPRECATED) { 2237 2237 dev_dbg(&adapter->dev, 2238 2238 "This adapter dropped support for I2C classes and won't auto-detect %s devices anymore. " 2239 - "If you need it, check 'Documentation/i2c/instantiating-devices' for alternatives.\n", 2239 + "If you need it, check 'Documentation/i2c/instantiating-devices.rst' for alternatives.\n", 2240 2240 driver->driver.name); 2241 2241 return 0; 2242 2242 }
+1 -1
drivers/iio/dummy/iio_simple_dummy.c
··· 693 693 * Varies depending on bus type of the device. As there is no device 694 694 * here, call probe directly. For information on device registration 695 695 * i2c: 696 - * Documentation/i2c/writing-clients 696 + * Documentation/i2c/writing-clients.rst 697 697 * spi: 698 698 * Documentation/spi/spi-summary 699 699 */
+1 -1
drivers/rtc/rtc-ds1374.c
··· 14 14 */ 15 15 /* 16 16 * It would be more efficient to use i2c msgs/i2c_transfer directly but, as 17 - * recommened in .../Documentation/i2c/writing-clients section 17 + * recommended in .../Documentation/i2c/writing-clients.rst section 18 18 * "Sending and receiving", using SMBus level communication is preferred. 19 19 */ 20 20
+1 -1
include/linux/i2c.h
··· 521 521 * 522 522 * The return codes from the @master_xfer{_atomic} fields should indicate the 523 523 * type of error code that occurred during the transfer, as documented in the 524 - * Kernel Documentation file Documentation/i2c/fault-codes. 524 + * Kernel Documentation file Documentation/i2c/fault-codes.rst. 525 525 */ 526 526 struct i2c_algorithm { 527 527 /*