mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] i2c: mt7621: enable for EcoNet devices
@ 2026-11-19 16:40 Caleb James DeLisle
  2026-11-19 16:40 ` [PATCH 1/2] i2c: mt7621: support big endian processors Caleb James DeLisle
  2026-11-19 16:40 ` [PATCH 2/2] i2c: mt7621: enable for EcoNet devices Caleb James DeLisle
  0 siblings, 2 replies; 3+ messages in thread
From: Caleb James DeLisle @ 2026-11-19 16:40 UTC (permalink / raw)
  To: linux-i2c
  Cc: sr, andi.shyti, matthias.bgg, angelogioacchino.delregno,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Caleb James DeLisle

Small patchset to fix an endianness bug in i2c-mt7621 and then enable
building it when building EcoNet devices.

Caleb James DeLisle (2):
  i2c: mt7621: support big endian processors
  i2c: mt7621: enable for EcoNet devices

 drivers/i2c/busses/Kconfig      |  2 +-
 drivers/i2c/busses/i2c-mt7621.c | 21 ++++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)


base-commit: e8017d29067fd1310a65c3494ce1a1b492adbac6
-- 
2.39.5


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] i2c: mt7621: support big endian processors
  2026-11-19 16:40 [PATCH 0/2] i2c: mt7621: enable for EcoNet devices Caleb James DeLisle
@ 2026-11-19 16:40 ` Caleb James DeLisle
  2026-11-19 16:40 ` [PATCH 2/2] i2c: mt7621: enable for EcoNet devices Caleb James DeLisle
  1 sibling, 0 replies; 3+ messages in thread
From: Caleb James DeLisle @ 2026-11-19 16:40 UTC (permalink / raw)
  To: linux-i2c
  Cc: sr, andi.shyti, matthias.bgg, angelogioacchino.delregno,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Caleb James DeLisle

Data is copied to and from I2C by way of a pair of IOMEM registers.
When sending, the data is copied to an intermediare buffer and then
written to the registers. However, the data is nominally little endian
but the registers are in CPU byte order. Make the buffer explicitly
little endian and use little endian read/write to support I2C on big
endian CPUs.

Signed-off-by: Caleb James DeLisle <cjd@cjdns.fr>
---
 drivers/i2c/busses/i2c-mt7621.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mt7621.c b/drivers/i2c/busses/i2c-mt7621.c
index 826abb9252e31..c79a47b293ef4 100644
--- a/drivers/i2c/busses/i2c-mt7621.c
+++ b/drivers/i2c/busses/i2c-mt7621.c
@@ -185,7 +185,8 @@ static int mtk_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
 
 		/* transfer data */
 		for (len = pmsg->len, j = 0; len > 0; len -= 8, j += 8) {
-			u32 data[2] = { };
+			__le32 data[2] = { };
+			u32 val;
 
 			page_len = (len >= 8) ? 8 : len;
 
@@ -194,9 +195,12 @@ static int mtk_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
 					SM0CTL1_READ : SM0CTL1_READ_LAST;
 			} else {
 				memcpy(data, &pmsg->buf[j], page_len);
-				iowrite32(data[0], i2c->base + REG_SM0D0_REG);
-				if (page_len > 4)
-					iowrite32(data[1], i2c->base + REG_SM0D1_REG);
+				val = le32_to_cpu(data[0]);
+				iowrite32(val, i2c->base + REG_SM0D0_REG);
+				if (page_len > 4) {
+					val = le32_to_cpu(data[1]);
+					iowrite32(val, i2c->base + REG_SM0D1_REG);
+				}
 				cmd = SM0CTL1_WRITE;
 			}
 
@@ -205,9 +209,12 @@ static int mtk_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
 				goto err_timeout;
 
 			if (pmsg->flags & I2C_M_RD) {
-				data[0] = ioread32(i2c->base + REG_SM0D0_REG);
-				if (page_len > 4)
-					data[1] = ioread32(i2c->base + REG_SM0D1_REG);
+				val = ioread32(i2c->base + REG_SM0D0_REG);
+				data[0] = cpu_to_le32(val);
+				if (page_len > 4) {
+					val = ioread32(i2c->base + REG_SM0D1_REG);
+					data[1] = cpu_to_le32(val);
+				}
 				memcpy(&pmsg->buf[j], data, page_len);
 			} else {
 				if (!(pmsg->flags & I2C_M_IGNORE_NAK)) {
-- 
2.39.5


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] i2c: mt7621: enable for EcoNet devices
  2026-11-19 16:40 [PATCH 0/2] i2c: mt7621: enable for EcoNet devices Caleb James DeLisle
  2026-11-19 16:40 ` [PATCH 1/2] i2c: mt7621: support big endian processors Caleb James DeLisle
@ 2026-11-19 16:40 ` Caleb James DeLisle
  1 sibling, 0 replies; 3+ messages in thread
From: Caleb James DeLisle @ 2026-11-19 16:40 UTC (permalink / raw)
  To: linux-i2c
  Cc: sr, andi.shyti, matthias.bgg, angelogioacchino.delregno,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Caleb James DeLisle

EcoNet EN751221 uses the same I2C subsystem as the MT7621, allow
selection of this driver when building for EcoNet devices.

Signed-off-by: Caleb James DeLisle <cjd@cjdns.fr>
---
 drivers/i2c/busses/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 275aaa7f35833..9295a35f4a181 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -918,7 +918,7 @@ config I2C_MT65XX
 
 config I2C_MT7621
 	tristate "MT7621/MT7628 I2C Controller"
-	depends on (RALINK && (SOC_MT7620 || SOC_MT7621)) || ARCH_AIROHA || COMPILE_TEST
+	depends on (RALINK && (SOC_MT7620 || SOC_MT7621)) || ARCH_AIROHA || ECONET || COMPILE_TEST
 	help
 	  Say Y here to include support for I2C controller in the
 	  MediaTek MT7621/MT7628 SoCs.
-- 
2.39.5


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-19 16:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 16:40 [PATCH 0/2] i2c: mt7621: enable for EcoNet devices Caleb James DeLisle
2026-11-19 16:40 ` [PATCH 1/2] i2c: mt7621: support big endian processors Caleb James DeLisle
2026-11-19 16:40 ` [PATCH 2/2] i2c: mt7621: enable for EcoNet devices Caleb James DeLisle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®