Skip to contentSkip to conversation

i2c: axxia: support slave mode

PATCH Superseded Adamski, Krzysztof (Nokia - PL/Wroclaw) 2 participants 2 messages Aug 9, 2019 – Aug 14, 2019 I2C subsystem host drivers

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 i2c: axxia: support slave mode

This device contains both master and slave controllers which can be enabled simultaneously. Both controllers share the same SDA/SCL lines and interrupt source but has separate control and status registers. Controllers also works in loopback mode - slave device can communicate with its own master controller internally. The controller can handle up to two addresses, both of which may be 10 bit. Most of the logic (sending (N)ACK, handling repeated start or switching between write/read) is handled automatically which makes working with this controller quite easy.

For simplicity, this patch adds basic support, limiting to only one slave address. Support for the 2nd device may be added in the future.

Note that synchronize_irq() is used to ensure any running slave interrupt is finished to make sure slave i2c_client structure can be safely used by i2c_slave_event.

---
Changes in v2:
- Reduced the number of dev_dbg messages.

 drivers/i2c/busses/Kconfig     |   1 +
 drivers/i2c/busses/i2c-axxia.c | 155 +++++++++++++++++++++++++++++++--
 2 files changed, 148 insertions(+), 8 deletions(-)
drivers/i2c/busses/Kconfig +1 -0
index 69f19312a574..b8262301c86d 100644
@@ -429,6 +429,7 @@ config I2C_AXXIA
 	tristate "Axxia I2C controller"
 	depends on ARCH_AXXIA || COMPILE_TEST
 	default ARCH_AXXIA
+	select I2C_SLAVE
 	help
 	  Say yes if you want to support the I2C bus on Axxia platforms.
 
drivers/i2c/busses/i2c-axxia.c +147 -8

208 lines not on this page · raw message

Signature · 1 line
2.21.0
#1 lore raw

Hi Krzysztof,

Quoted 1 line

- Reduced the number of dev_dbg messages.

Yes, that looks good. Just some curly braces left over...

Quoted 4 lines
drivers/i2c/busses/i2c-axxia.c +4 -0
+		if (fifo_status & SLV_FIFO_STRC) {
+			i2c_slave_event(idev->slave,
+					I2C_SLAVE_WRITE_REQUESTED, &val);
+		}

...

Quoted 3 lines
drivers/i2c/busses/i2c-axxia.c +3 -0
+	if (fifo_status & SLV_FIFO_RSC) {
+		readl(idev->base + SLV_DATA); /* dummy read */
+	}

..

drivers/i2c/busses/i2c-axxia.c static int axxia_i2c_fill_tx_fifo(struct axxia_i2c_dev *idev) · line 359

Quoted 3 lines
drivers/i2c/busses/i2c-axxia.c +3 -0
+	if (status & SLV_STATUS_SRC1) {
+		i2c_slave_event(idev->slave, I2C_SLAVE_STOP, &val);
+	}

If you add '--strict' to checkpatch, it warns about two of them.

Kind regards,

Wolfram