Skip to contentSkip to conversation

mfd: rsmu: fixes and new IC support

PATCH Applied Matthew Bystrin 2 participants 4 messages Apr 29 – May 7

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover mfd: rsmu: fixes and new IC support

Hi!

First patch fixes Renesas 8A34002 SPI driver.

In my setup 8A34002 is connected to VisionFive2 (via SPI or I2C). I've discovered that upstream driver does not work:

[    4.728771] 8a3400x-phc 8a3400x-phc.0.auto: 4.8.7, Id: 0x4002  HW Rev: 5  OTP Config Select: 0
[    4.737389] 8a3400x-phc 8a3400x-phc.0.auto: requesting firmware 'idtcm.bin'
[    4.744462] 8a3400x-phc 8a3400x-phc.0.auto: Direct firmware load for idtcm.bin failed with error -2
[    4.753547] 8a3400x-phc 8a3400x-phc.0.auto: Failed at line 1273 in idtcm_load_firmware!
[    4.761576] 8a3400x-phc 8a3400x-phc.0.auto: loading firmware failed with -2
[    4.769411] 8a3400x-phc 8a3400x-phc.0.auto: No wait state: DPLL_SYS_STATE 0
[    4.776374] 8a3400x-phc 8a3400x-phc.0.auto: Continuing while SYS APLL/DPLL is not locked
[    4.785206] 8a3400x-phc 8a3400x-phc.0.auto: Unsupported MANUAL_REFERENCE: 0x00
[    4.796930] 8a3400x-phc 8a3400x-phc.0.auto: PLL2 registered as ptp0

This being caused by a piece of code in rsmu_write_page_register() function:

if (reg < RSMU_CM_SCSR_BASE)

	return 0;

All addresses in include/linux/mfd/idt8a340_reg.h are less than RSMU_CM_SCSR_BASE so functions was returning early, before any modifications to the page register. Valid read of versions - is just a coincidence, because default value of the page register is zero.

There were 2 separate patch series which had to be merged in one time: mfd and ptp. The latter have been merged, the former [1] have not. As result we've got a broken driver.

This patch can be reverted later when the second part will be ready (of course if it is planned to do so). Any comments, Min? I could support with testing.

Second patch just adds support for 8A34002, which is compatible with 8A34001. As I can see there is no need to update bindings, everything is already being done.

Link [2] to v1.

Changes in v2:
- Fix page register issue in rsmu_i2c
- Add support for 8a34002 in rsmu_i2c

Link [1]: https://lore.kernel.org/netdev/LV3P220MB1202F8E2FCCFBA2519B4966EA0192@LV3P220MB1202.NAMP220.PROD.OUTLOOK.COM/
Link [2]: https://lore.kernel.org/netdev/[email protected]/

Matthew Bystrin (2):
mfd: rsmu: fix page register setup
mfd: rsmu: add 8a34002 support

 drivers/mfd/rsmu_i2c.c | 8 +++-----
 drivers/mfd/rsmu_spi.c | 7 +++----
 2 files changed, 6 insertions(+), 9 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH v2 1/2 mfd: rsmu: fix page register setup

Fix writes to page register in 8A3400x family (Clock Matrix).

All calls to rsmu_write_page_register() (both in i2c and spi) have resulted in early return, becase all addresses in include/linux/mfd/idt8a340_reg.h are less than RSMU_CM_SCSR_BASE.

There were 2 separate patch series which have to be merged in one time:
mfd and ptp. The latter have been merged, the former[1] have not.

---
 drivers/mfd/rsmu_i2c.c | 6 +-----
 drivers/mfd/rsmu_spi.c | 5 +----
 2 files changed, 2 insertions(+), 9 deletions(-)
drivers/mfd/rsmu_i2c.c +1 -5
index cba64f107a2f..9e5fc8259eec 100644
@@ -134,14 +134,10 @@ static int rsmu_i2c_write_device(struct rsmu_ddata *rsmu, u8 reg, u8 *buf, u8 by
 static int rsmu_write_page_register(struct rsmu_ddata *rsmu, u32 reg,
 				    rsmu_rw_device rsmu_write_device)
 {
-	u32 page = reg & RSMU_CM_PAGE_MASK;
+	u32 page = (reg | RSMU_CM_SCSR_BASE) & RSMU_CM_PAGE_MASK;
 	u8 buf[4];
 	int err;
 
-	/* Do not modify offset register for none-scsr registers */
-	if (reg < RSMU_CM_SCSR_BASE)
-		return 0;
-
 	/* Simply return if we are on the same page */
 	if (rsmu->page == page)
 		return 0;
drivers/mfd/rsmu_spi.c +1 -4
index 39d9be1e141f..c931d8cea0a1 100644
@@ -101,11 +101,8 @@ static int rsmu_write_page_register(struct rsmu_ddata *rsmu, u32 reg)
 
 	switch (rsmu->type) {
 	case RSMU_CM:
-		/* Do not modify page register for none-scsr registers */
-		if (reg < RSMU_CM_SCSR_BASE)
-			return 0;
 		page_reg = RSMU_CM_PAGE_ADDR;
-		page = reg & RSMU_PAGE_MASK;
+		page = (reg | RSMU_CM_SCSR_BASE) & RSMU_PAGE_MASK;
 		buf[0] = (u8)(page & 0xFF);
 		buf[1] = (u8)((page >> 8) & 0xFF);
 		buf[2] = (u8)((page >> 16) & 0xFF);
Signature · 1 line
2.53.0
#2 lore raw

PATCH v2 2/2 mfd: rsmu: add 8a34002 support

In reply to Matthew Bystrin

Add compatible string, i2c_devcie_id and spi_devcie_id to support 8a34002.

---
 drivers/mfd/rsmu_i2c.c | 2 ++
 drivers/mfd/rsmu_spi.c | 2 ++
 2 files changed, 4 insertions(+)
drivers/mfd/rsmu_i2c.c +2 -0
index 9e5fc8259eec..c57795ed20f4 100644
@@ -330,6 +330,7 @@ static void rsmu_i2c_remove(struct i2c_client *client)
 static const struct i2c_device_id rsmu_i2c_id[] = {
 	{ "8a34000",  RSMU_CM },
 	{ "8a34001",  RSMU_CM },
+	{ "8a34002",  RSMU_CM },
 	{ "82p33810", RSMU_SABRE },
 	{ "82p33811", RSMU_SABRE },
 	{ "8v19n850", RSMU_SL },
@@ -341,6 +342,7 @@ MODULE_DEVICE_TABLE(i2c, rsmu_i2c_id);
 static const struct of_device_id rsmu_i2c_of_match[] = {
 	{ .compatible = "idt,8a34000",  .data = (void *)RSMU_CM },
 	{ .compatible = "idt,8a34001",  .data = (void *)RSMU_CM },
+	{ .compatible = "idt,8a34002",  .data = (void *)RSMU_CM },
 	{ .compatible = "idt,82p33810", .data = (void *)RSMU_SABRE },
 	{ .compatible = "idt,82p33811", .data = (void *)RSMU_SABRE },
 	{ .compatible = "idt,8v19n850", .data = (void *)RSMU_SL },
drivers/mfd/rsmu_spi.c +2 -0
index c931d8cea0a1..e07f21482439 100644
@@ -241,6 +241,7 @@ static void rsmu_spi_remove(struct spi_device *client)
 static const struct spi_device_id rsmu_spi_id[] = {
 	{ "8a34000",  RSMU_CM },
 	{ "8a34001",  RSMU_CM },
+	{ "8a34002",  RSMU_CM },
 	{ "82p33810", RSMU_SABRE },
 	{ "82p33811", RSMU_SABRE },
 	{}
@@ -250,6 +251,7 @@ MODULE_DEVICE_TABLE(spi, rsmu_spi_id);
 static const struct of_device_id rsmu_spi_of_match[] = {
 	{ .compatible = "idt,8a34000",  .data = (void *)RSMU_CM },
 	{ .compatible = "idt,8a34001",  .data = (void *)RSMU_CM },
+	{ .compatible = "idt,8a34002",  .data = (void *)RSMU_CM },
 	{ .compatible = "idt,82p33810", .data = (void *)RSMU_SABRE },
 	{ .compatible = "idt,82p33811", .data = (void *)RSMU_SABRE },
 	{}
Signature · 1 line
2.53.0
maintainer Applied
#3 lore raw
In reply to Matthew Bystrin
Quoted 15 lines · Matthew Bystrin

First patch fixes Renesas 8A34002 SPI driver.

In my setup 8A34002 is connected to VisionFive2 (via SPI or I2C). I've discovered that upstream driver does not work:

[    4.728771] 8a3400x-phc 8a3400x-phc.0.auto: 4.8.7, Id: 0x4002  HW Rev: 5  OTP Config Select: 0
[    4.737389] 8a3400x-phc 8a3400x-phc.0.auto: requesting firmware 'idtcm.bin'
[    4.744462] 8a3400x-phc 8a3400x-phc.0.auto: Direct firmware load for idtcm.bin failed with error -2
[    4.753547] 8a3400x-phc 8a3400x-phc.0.auto: Failed at line 1273 in idtcm_load_firmware!
[    4.761576] 8a3400x-phc 8a3400x-phc.0.auto: loading firmware failed with -2
[    4.769411] 8a3400x-phc 8a3400x-phc.0.auto: No wait state: DPLL_SYS_STATE 0
[    4.776374] 8a3400x-phc 8a3400x-phc.0.auto: Continuing while SYS APLL/DPLL is not locked
[    4.785206] 8a3400x-phc 8a3400x-phc.0.auto: Unsupported MANUAL_REFERENCE: 0x00
[    4.796930] 8a3400x-phc 8a3400x-phc.0.auto: PLL2 registered as ptp0
Quoted 1 line

[...]

Applied, thanks!

[1/2] mfd: rsmu: fix page register setup

      commit: d65ff90be2c1a09e9e477e6f7493fae21b31e59c
[2/2] mfd: rsmu: add 8a34002 support
      commit: c8e94555a15fbe0925a9cc424118ca10e3b5531a

--
Lee Jones [李琼斯]