diff options
-rw-r--r-- | Documentation/devicetree/bindings/eeprom/at24.yaml | 18 | ||||
-rw-r--r-- | Documentation/i2c/slave-testunit-backend.rst | 127 | ||||
-rw-r--r-- | drivers/i2c/i2c-core-base.c | 6 | ||||
-rw-r--r-- | drivers/i2c/i2c-dev.c | 12 | ||||
-rw-r--r-- | drivers/i2c/i2c-slave-testunit.c | 2 | ||||
-rw-r--r-- | drivers/i2c/i2c-smbus.c | 2 | ||||
-rw-r--r-- | drivers/i2c/muxes/i2c-mux-pca9541.c | 2 | ||||
-rw-r--r-- | drivers/misc/eeprom/at24.c | 8 |
8 files changed, 127 insertions, 50 deletions
diff --git a/Documentation/devicetree/bindings/eeprom/at24.yaml b/Documentation/devicetree/bindings/eeprom/at24.yaml index 3c36cd0510de..e396e47b2f13 100644 --- a/Documentation/devicetree/bindings/eeprom/at24.yaml +++ b/Documentation/devicetree/bindings/eeprom/at24.yaml @@ -18,7 +18,9 @@ select: properties: compatible: contains: - pattern: "^atmel,(24(c|cs|mac)[0-9]+|spd)$" + anyOf: + - pattern: "^atmel,(24(c|cs|mac)[0-9]+|spd)$" + - enum: ["microchip,24aa025e48", "microchip,24aa025e64"] required: - compatible @@ -103,9 +105,6 @@ properties: # These are special cases that don't conform to the above pattern. # Each requires a standard at24 model as fallback. - items: - - const: belling,bl24c16a - - const: atmel,24c16 - - items: - enum: - rohm,br24g01 - rohm,br24t01 @@ -122,16 +121,25 @@ properties: - rohm,br24g04 - const: atmel,24c04 - items: - - const: renesas,r1ex24016 + - enum: + - belling,bl24c16a + - renesas,r1ex24016 - const: atmel,24c16 - items: - const: giantec,gt24c32a - const: atmel,24c32 - items: + - const: onnn,n24s64b + - const: atmel,24c64 + - items: - enum: - renesas,r1ex24128 - samsung,s524ad0xd1 - const: atmel,24c128 + - items: + - const: microchip,24aa025e48 + - items: + - const: microchip,24aa025e64 - pattern: '^atmel,24c(32|64)d-wl$' # Actual vendor is st label: diff --git a/Documentation/i2c/slave-testunit-backend.rst b/Documentation/i2c/slave-testunit-backend.rst index ecfc2abec32d..37142a48ab35 100644 --- a/Documentation/i2c/slave-testunit-backend.rst +++ b/Documentation/i2c/slave-testunit-backend.rst @@ -16,9 +16,9 @@ Note that this is a device for testing and debugging. It should not be enabled in a production build. And while there is some versioning and we try hard to keep backward compatibility, there is no stable ABI guaranteed! -Instantiating the device is regular. Example for bus 0, address 0x30: +Instantiating the device is regular. Example for bus 0, address 0x30:: -# echo "slave-testunit 0x1030" > /sys/bus/i2c/devices/i2c-0/new_device + # echo "slave-testunit 0x1030" > /sys/bus/i2c/devices/i2c-0/new_device After that, you will have a write-only device listening. Reads will just return an 8-bit version number of the testunit. When writing, the device consists of 4 @@ -26,14 +26,17 @@ an 8-bit version number of the testunit. When writing, the device consists of 4 written to start a testcase, i.e. you usually write 4 bytes to the device. The registers are: -0x00 CMD - which test to trigger -0x01 DATAL - configuration byte 1 for the test -0x02 DATAH - configuration byte 2 for the test -0x03 DELAY - delay in n * 10ms until test is started +.. csv-table:: + :header: "Offset", "Name", "Description" -Using 'i2cset' from the i2c-tools package, the generic command looks like: + 0x00, CMD, which test to trigger + 0x01, DATAL, configuration byte 1 for the test + 0x02, DATAH, configuration byte 2 for the test + 0x03, DELAY, delay in n * 10ms until test is started -# i2cset -y <bus_num> <testunit_address> <CMD> <DATAL> <DATAH> <DELAY> i +Using 'i2cset' from the i2c-tools package, the generic command looks like:: + + # i2cset -y <bus_num> <testunit_address> <CMD> <DATAL> <DATAH> <DELAY> i DELAY is a generic parameter which will delay the execution of the test in CMD. While a command is running (including the delay), new commands will not be @@ -45,44 +48,88 @@ result in the transfer not being acknowledged. Commands -------- -0x00 NOOP (reserved for future use) +0x00 NOOP +~~~~~~~~~ + +Reserved for future use. + +0x01 READ_BYTES +~~~~~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - CMD + - DATAL + - DATAH + - DELAY + + * - 0x01 + - address to read data from (lower 7 bits, highest bit currently unused) + - number of bytes to read + - n * 10ms + +Also needs master mode. This is useful to test if your bus master driver is +handling multi-master correctly. You can trigger the testunit to read bytes +from another device on the bus. If the bus master under test also wants to +access the bus at the same time, the bus will be busy. Example to read 128 +bytes from device 0x50 after 50ms of delay:: + + # i2cset -y 0 0x30 0x01 0x50 0x80 0x05 i + +0x02 SMBUS_HOST_NOTIFY +~~~~~~~~~~~~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - CMD + - DATAL + - DATAH + - DELAY + + * - 0x02 + - low byte of the status word to send + - high byte of the status word to send + - n * 10ms + +Also needs master mode. This test will send an SMBUS_HOST_NOTIFY message to the +host. Note that the status word is currently ignored in the Linux Kernel. +Example to send a notification after 10ms:: -0x01 READ_BYTES (also needs master mode) - DATAL - address to read data from (lower 7 bits, highest bit currently unused) - DATAH - number of bytes to read + # i2cset -y 0 0x30 0x02 0x42 0x64 0x01 i -This is useful to test if your bus master driver is handling multi-master -correctly. You can trigger the testunit to read bytes from another device on -the bus. If the bus master under test also wants to access the bus at the same -time, the bus will be busy. Example to read 128 bytes from device 0x50 after -50ms of delay: +If the host controller supports HostNotify, this message with debug level +should appear (Linux 6.11 and later):: -# i2cset -y 0 0x30 0x01 0x50 0x80 0x05 i + Detected HostNotify from address 0x30 -0x02 SMBUS_HOST_NOTIFY (also needs master mode) - DATAL - low byte of the status word to send - DATAH - high byte of the status word to send +0x03 SMBUS_BLOCK_PROC_CALL +~~~~~~~~~~~~~~~~~~~~~~~~~~ -This test will send an SMBUS_HOST_NOTIFY message to the host. Note that the -status word is currently ignored in the Linux Kernel. Example to send a -notification after 10ms: +.. list-table:: + :header-rows: 1 -# i2cset -y 0 0x30 0x02 0x42 0x64 0x01 i + * - CMD + - DATAL + - DATAH + - DELAY -0x03 SMBUS_BLOCK_PROC_CALL (partial command) - DATAL - must be '1', i.e. one further byte will be written - DATAH - number of bytes to be sent back - DELAY - not applicable, partial command! + * - 0x03 + - must be '1', i.e. one further byte will be written + - number of bytes to be sent back + - leave out, partial command! -This test will respond to a block process call as defined by the SMBus -specification. The one data byte written specifies how many bytes will be sent -back in the following read transfer. Note that in this read transfer, the -testunit will prefix the length of the bytes to follow. So, if your host bus -driver emulates SMBus calls like the majority does, it needs to support the -I2C_M_RECV_LEN flag of an i2c_msg. This is a good testcase for it. The returned -data consists of the length first, and then of an array of bytes from length-1 -to 0. Here is an example which emulates i2c_smbus_block_process_call() using -i2ctransfer (you need i2c-tools v4.2 or later): +Partial command. This test will respond to a block process call as defined by +the SMBus specification. The one data byte written specifies how many bytes +will be sent back in the following read transfer. Note that in this read +transfer, the testunit will prefix the length of the bytes to follow. So, if +your host bus driver emulates SMBus calls like the majority does, it needs to +support the I2C_M_RECV_LEN flag of an i2c_msg. This is a good testcase for it. +The returned data consists of the length first, and then of an array of bytes +from length-1 to 0. Here is an example which emulates +i2c_smbus_block_process_call() using i2ctransfer (you need i2c-tools v4.2 or +later):: -# i2ctransfer -y 0 w3@0x30 0x03 0x01 0x10 r? -0x10 0x0f 0x0e 0x0d 0x0c 0x0b 0x0a 0x09 0x08 0x07 0x06 0x05 0x04 0x03 0x02 0x01 0x00 + # i2ctransfer -y 0 w3@0x30 0x03 0x01 0x10 r? + 0x10 0x0f 0x0e 0x0d 0x0c 0x0b 0x0a 0x09 0x08 0x07 0x06 0x05 0x04 0x03 0x02 0x01 0x00 diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index db0d1ac82910..a5fce479ab13 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1066,8 +1066,8 @@ EXPORT_SYMBOL(i2c_find_device_by_fwnode); static const struct i2c_device_id dummy_id[] = { - { "dummy", 0 }, - { }, + { "dummy" }, + { } }; static int dummy_probe(struct i2c_client *client) @@ -1468,6 +1468,8 @@ int i2c_handle_smbus_host_notify(struct i2c_adapter *adap, unsigned short addr) if (!adap) return -EINVAL; + dev_dbg(&adap->dev, "Detected HostNotify from address 0x%02x", addr); + irq = irq_find_mapping(adap->host_notify_domain, addr); if (irq <= 0) return -ENXIO; diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 8b7e599f1674..f4fb212b7f39 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -139,6 +139,10 @@ static ssize_t i2cdev_read(struct file *file, char __user *buf, size_t count, struct i2c_client *client = file->private_data; + /* Adapter must support I2C transfers */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + return -EOPNOTSUPP; + if (count > 8192) count = 8192; @@ -163,6 +167,10 @@ static ssize_t i2cdev_write(struct file *file, const char __user *buf, char *tmp; struct i2c_client *client = file->private_data; + /* Adapter must support I2C transfers */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + return -EOPNOTSUPP; + if (count > 8192) count = 8192; @@ -238,6 +246,10 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client, u8 __user **data_ptrs; int i, res; + /* Adapter must support I2C transfers */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + return -EOPNOTSUPP; + data_ptrs = kmalloc_array(nmsgs, sizeof(u8 __user *), GFP_KERNEL); if (data_ptrs == NULL) { kfree(msgs); diff --git a/drivers/i2c/i2c-slave-testunit.c b/drivers/i2c/i2c-slave-testunit.c index ca43e98cae1b..909872c8ca62 100644 --- a/drivers/i2c/i2c-slave-testunit.c +++ b/drivers/i2c/i2c-slave-testunit.c @@ -165,7 +165,7 @@ static void i2c_slave_testunit_remove(struct i2c_client *client) } static const struct i2c_device_id i2c_slave_testunit_id[] = { - { "slave-testunit", 0 }, + { "slave-testunit" }, { } }; MODULE_DEVICE_TABLE(i2c, i2c_slave_testunit_id); diff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c index 97f338b123b1..5a16bf01402c 100644 --- a/drivers/i2c/i2c-smbus.c +++ b/drivers/i2c/i2c-smbus.c @@ -160,7 +160,7 @@ static void smbalert_remove(struct i2c_client *ara) } static const struct i2c_device_id smbalert_ids[] = { - { "smbus_alert", 0 }, + { "smbus_alert" }, { /* LIST END */ } }; MODULE_DEVICE_TABLE(i2c, smbalert_ids); diff --git a/drivers/i2c/muxes/i2c-mux-pca9541.c b/drivers/i2c/muxes/i2c-mux-pca9541.c index e28694d991fb..8663c8a7c269 100644 --- a/drivers/i2c/muxes/i2c-mux-pca9541.c +++ b/drivers/i2c/muxes/i2c-mux-pca9541.c @@ -78,7 +78,7 @@ struct pca9541 { }; static const struct i2c_device_id pca9541_id[] = { - {"pca9541", 0}, + { "pca9541" }, {} }; diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 4bd4f32bcdab..ca872e3465ed 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -174,6 +174,10 @@ AT24_CHIP_DATA(at24_data_24mac402, 48 / 8, AT24_FLAG_MAC | AT24_FLAG_READONLY); AT24_CHIP_DATA(at24_data_24mac602, 64 / 8, AT24_FLAG_MAC | AT24_FLAG_READONLY); +AT24_CHIP_DATA(at24_data_24aa025e48, 48 / 8, + AT24_FLAG_READONLY); +AT24_CHIP_DATA(at24_data_24aa025e64, 64 / 8, + AT24_FLAG_READONLY); /* spd is a 24c02 in memory DIMMs */ AT24_CHIP_DATA(at24_data_spd, 2048 / 8, AT24_FLAG_READONLY | AT24_FLAG_IRUGO); @@ -218,6 +222,8 @@ static const struct i2c_device_id at24_ids[] = { { "24cs02", (kernel_ulong_t)&at24_data_24cs02 }, { "24mac402", (kernel_ulong_t)&at24_data_24mac402 }, { "24mac602", (kernel_ulong_t)&at24_data_24mac602 }, + { "24aa025e48", (kernel_ulong_t)&at24_data_24aa025e48 }, + { "24aa025e64", (kernel_ulong_t)&at24_data_24aa025e64 }, { "spd", (kernel_ulong_t)&at24_data_spd }, { "24c02-vaio", (kernel_ulong_t)&at24_data_24c02_vaio }, { "24c04", (kernel_ulong_t)&at24_data_24c04 }, @@ -270,6 +276,8 @@ static const struct of_device_id __maybe_unused at24_of_match[] = { { .compatible = "atmel,24c1024", .data = &at24_data_24c1024 }, { .compatible = "atmel,24c1025", .data = &at24_data_24c1025 }, { .compatible = "atmel,24c2048", .data = &at24_data_24c2048 }, + { .compatible = "microchip,24aa025e48", .data = &at24_data_24aa025e48 }, + { .compatible = "microchip,24aa025e64", .data = &at24_data_24aa025e64 }, { /* END OF LIST */ }, }; MODULE_DEVICE_TABLE(of, at24_of_match); |