Skip to content

Commit 7783485

Browse files
committed
Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang: "The usual driver fixes and documentation updates" * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: i2c: mlxcpld: check correct size of maximum RECV_LEN packet i2c: add Kconfig help text for slave mode i2c: slave-eeprom: update documentation i2c: eg20t: Load module automatically if ID matches i2c: designware: platdrv: Set class based on DMI i2c: algo-pca: Add 0x78 as SCL stuck low status for PCA9665
2 parents 45a5ac7 + 5979112 commit 7783485

File tree

6 files changed

+43
-9
lines changed

6 files changed

+43
-9
lines changed
Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
==============================
2-
Linux I2C slave eeprom backend
2+
Linux I2C slave EEPROM backend
33
==============================
44

5-
by Wolfram Sang <[email protected]> in 2014-15
5+
by Wolfram Sang <[email protected]> in 2014-20
66

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::
7+
This backend simulates an EEPROM on the connected I2C bus. Its memory contents
8+
can be accessed from userspace via this file located in sysfs::
109

1110
/sys/bus/i2c/devices/<device-directory>/slave-eeprom
1211

12+
The following types are available: 24c02, 24c32, 24c64, and 24c512. Read-only
13+
variants are also supported. The name needed for instantiating has the form
14+
'slave-<type>[ro]'. Examples follow:
15+
16+
24c02, read/write, address 0x64:
17+
# echo slave-24c02 0x1064 > /sys/bus/i2c/devices/i2c-1/new_device
18+
19+
24c512, read-only, address 0x42:
20+
# echo slave-24c512ro 0x1042 > /sys/bus/i2c/devices/i2c-1/new_device
21+
22+
You can also preload data during boot if a device-property named
23+
'firmware-name' contains a valid filename (DT or ACPI only).
24+
1325
As of 2015, Linux doesn't support poll on binary sysfs files, so there is no
1426
notification when another master changed the content.

drivers/i2c/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,18 @@ config I2C_STUB
113113

114114
config I2C_SLAVE
115115
bool "I2C slave support"
116+
help
117+
This enables Linux to act as an I2C slave device. Note that your I2C
118+
bus master driver also needs to support this functionality. Please
119+
read Documentation/i2c/slave-interface.rst for further details.
116120

117121
if I2C_SLAVE
118122

119123
config I2C_SLAVE_EEPROM
120124
tristate "I2C eeprom slave driver"
125+
help
126+
This backend makes Linux behave like an I2C EEPROM. Please read
127+
Documentation/i2c/slave-eeprom-backend.rst for further details.
121128

122129
endif
123130

drivers/i2c/algos/i2c-algo-pca.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
314314
DEB2("BUS ERROR - SDA Stuck low\n");
315315
pca_reset(adap);
316316
goto out;
317-
case 0x90: /* Bus error - SCL stuck low */
317+
case 0x78: /* Bus error - SCL stuck low (PCA9665) */
318+
case 0x90: /* Bus error - SCL stuck low (PCA9564) */
318319
DEB2("BUS ERROR - SCL Stuck low\n");
319320
pca_reset(adap);
320321
goto out;

drivers/i2c/busses/i2c-designware-platdrv.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/clk-provider.h>
1313
#include <linux/clk.h>
1414
#include <linux/delay.h>
15+
#include <linux/dmi.h>
1516
#include <linux/err.h>
1617
#include <linux/errno.h>
1718
#include <linux/i2c.h>
@@ -191,6 +192,17 @@ static int dw_i2c_plat_request_regs(struct dw_i2c_dev *dev)
191192
return ret;
192193
}
193194

195+
static const struct dmi_system_id dw_i2c_hwmon_class_dmi[] = {
196+
{
197+
.ident = "Qtechnology QT5222",
198+
.matches = {
199+
DMI_MATCH(DMI_SYS_VENDOR, "Qtechnology"),
200+
DMI_MATCH(DMI_PRODUCT_NAME, "QT5222"),
201+
},
202+
},
203+
{ } /* terminate list */
204+
};
205+
194206
static int dw_i2c_plat_probe(struct platform_device *pdev)
195207
{
196208
struct dw_i2c_platform_data *pdata = dev_get_platdata(&pdev->dev);
@@ -267,7 +279,8 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
267279

268280
adap = &dev->adapter;
269281
adap->owner = THIS_MODULE;
270-
adap->class = I2C_CLASS_DEPRECATED;
282+
adap->class = dmi_check_system(dw_i2c_hwmon_class_dmi) ?
283+
I2C_CLASS_HWMON : I2C_CLASS_DEPRECATED;
271284
ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev));
272285
adap->dev.of_node = pdev->dev.of_node;
273286
adap->nr = -1;

drivers/i2c/busses/i2c-eg20t.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ static const struct pci_device_id pch_pcidev_id[] = {
180180
{ PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7831_I2C), 1, },
181181
{0,}
182182
};
183+
MODULE_DEVICE_TABLE(pci, pch_pcidev_id);
183184

184185
static irqreturn_t pch_i2c_handler(int irq, void *pData);
185186

drivers/i2c/busses/i2c-mlxcpld.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,9 @@ static int mlxcpld_i2c_wait_for_tc(struct mlxcpld_i2c_priv *priv)
337337
if (priv->smbus_block && (val & MLXCPLD_I2C_SMBUS_BLK_BIT)) {
338338
mlxcpld_i2c_read_comm(priv, MLXCPLD_LPCI2C_NUM_DAT_REG,
339339
&datalen, 1);
340-
if (unlikely(datalen > (I2C_SMBUS_BLOCK_MAX + 1))) {
340+
if (unlikely(datalen > I2C_SMBUS_BLOCK_MAX)) {
341341
dev_err(priv->dev, "Incorrect smbus block read message len\n");
342-
return -E2BIG;
342+
return -EPROTO;
343343
}
344344
} else {
345345
datalen = priv->xfer.data_len;

0 commit comments

Comments
 (0)