devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S
@ 2024-08-19 10:23 Claudiu
  2024-08-19 10:23 ` [PATCH v4 01/11] i2c: riic: Use temporary variable for struct device Claudiu
                   ` (11 more replies)
  0 siblings, 12 replies; 26+ messages in thread
From: Claudiu @ 2024-08-19 10:23 UTC (permalink / raw)
  To: chris.brandt, andi.shyti, robh, krzk+dt, conor+dt, geert+renesas,
	magnus.damm, p.zabel, wsa+renesas
  Cc: linux-renesas-soc, linux-i2c, devicetree, linux-kernel,
	claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Hi,

Series adds I2C support for the Renesas RZ/G3S SoC.

Series is split as follows:
- patch 01-03/12   - add some cleanups on RIIC driver
- patch 04/12      - enable runtime autosuspend support on the RIIC driver
- patch 05/12      - add suspend to RAM support on the RIIC driver
- patch 06/12      - prepares for the addition of fast mode plus
- patch 07/12      - updates the I2C documentation for the RZ/G3S SoC
- patch 08/12      - add fast mode plus support on the RIIC driver
- patches 09-11/11 - device tree support

Thank you,
Claudiu Beznea

Changes in v4:
- collected tags
- addressed review comments

Changes in v3:
- dropped patch "clk: renesas: r9a08g045: Add clock, reset and power
  domain support for I2C" as it was already integrated
- addressed review comments

Changes in v2:
- change the i2c clock names to match the documentation
- update commit description for patch "i2c: riic: Use temporary
  variable for struct device"
- addressed review comments
- dropped renesas,riic-no-fast-mode-plus DT property and associated code

Claudiu Beznea (11):
  i2c: riic: Use temporary variable for struct device
  i2c: riic: Call pm_runtime_get_sync() when need to access registers
  i2c: riic: Use pm_runtime_resume_and_get()
  i2c: riic: Enable runtime PM autosuspend support
  i2c: riic: Add suspend/resume support
  i2c: riic: Define individual arrays to describe the register offsets
  dt-bindings: i2c: renesas,riic: Document the R9A08G045 support
  i2c: riic: Add support for fast mode plus
  arm64: dts: renesas: r9a08g045: Add I2C nodes
  arm64: dts: renesas: rzg3s-smarc: Enable i2c0 node
  arm64: dts: renesas: rzg3s-smarc-som: Enable i2c1 node

 .../devicetree/bindings/i2c/renesas,riic.yaml |   4 +
 arch/arm64/boot/dts/renesas/r9a08g045.dtsi    |  88 +++++++
 .../boot/dts/renesas/rzg3s-smarc-som.dtsi     |   5 +
 arch/arm64/boot/dts/renesas/rzg3s-smarc.dtsi  |   7 +
 drivers/i2c/busses/i2c-riic.c                 | 221 ++++++++++++------
 5 files changed, 256 insertions(+), 69 deletions(-)

-- 
2.39.2


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

* [PATCH v4 01/11] i2c: riic: Use temporary variable for struct device
  2024-08-19 10:23 [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Claudiu
@ 2024-08-19 10:23 ` Claudiu
  2024-08-19 10:23 ` [PATCH v4 02/11] i2c: riic: Call pm_runtime_get_sync() when need to access registers Claudiu
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 26+ messages in thread
From: Claudiu @ 2024-08-19 10:23 UTC (permalink / raw)
  To: chris.brandt, andi.shyti, robh, krzk+dt, conor+dt, geert+renesas,
	magnus.damm, p.zabel, wsa+renesas
  Cc: linux-renesas-soc, linux-i2c, devicetree, linux-kernel,
	claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Use a temporary variable for the struct device pointers to avoid
dereferencing.

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---

Changes in v4:
- collected tags

Changes in v3:
- dropped updates around &riic->adapter.dev introduced in v2; with
  this restored commit description from v1

Changes in v2:
- updated commit description to reflect all the changes done

 drivers/i2c/busses/i2c-riic.c | 49 +++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 23 deletions(-)

diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
index d6f585cdb7e5..bc33762a5d07 100644
--- a/drivers/i2c/busses/i2c-riic.c
+++ b/drivers/i2c/busses/i2c-riic.c
@@ -131,11 +131,12 @@ static inline void riic_clear_set_bit(struct riic_dev *riic, u8 clear, u8 set, u
 static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
 {
 	struct riic_dev *riic = i2c_get_adapdata(adap);
+	struct device *dev = adap->dev.parent;
 	unsigned long time_left;
 	int i;
 	u8 start_bit;
 
-	pm_runtime_get_sync(adap->dev.parent);
+	pm_runtime_get_sync(dev);
 
 	if (riic_readb(riic, RIIC_ICCR2) & ICCR2_BBSY) {
 		riic->err = -EBUSY;
@@ -168,7 +169,7 @@ static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
 	}
 
  out:
-	pm_runtime_put(adap->dev.parent);
+	pm_runtime_put(dev);
 
 	return riic->err ?: num;
 }
@@ -303,8 +304,9 @@ static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t)
 	int ret = 0;
 	unsigned long rate;
 	int total_ticks, cks, brl, brh;
+	struct device *dev = riic->adapter.dev.parent;
 
-	pm_runtime_get_sync(riic->adapter.dev.parent);
+	pm_runtime_get_sync(dev);
 
 	if (t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ) {
 		dev_err(&riic->adapter.dev,
@@ -396,7 +398,7 @@ static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t)
 	riic_clear_set_bit(riic, ICCR1_IICRST, 0, RIIC_ICCR1);
 
 out:
-	pm_runtime_put(riic->adapter.dev.parent);
+	pm_runtime_put(dev);
 	return ret;
 }
 
@@ -415,13 +417,14 @@ static void riic_reset_control_assert(void *data)
 
 static int riic_i2c_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	struct riic_dev *riic;
 	struct i2c_adapter *adap;
 	struct i2c_timings i2c_t;
 	struct reset_control *rstc;
 	int i, ret;
 
-	riic = devm_kzalloc(&pdev->dev, sizeof(*riic), GFP_KERNEL);
+	riic = devm_kzalloc(dev, sizeof(*riic), GFP_KERNEL);
 	if (!riic)
 		return -ENOMEM;
 
@@ -429,22 +432,22 @@ static int riic_i2c_probe(struct platform_device *pdev)
 	if (IS_ERR(riic->base))
 		return PTR_ERR(riic->base);
 
-	riic->clk = devm_clk_get(&pdev->dev, NULL);
+	riic->clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(riic->clk)) {
-		dev_err(&pdev->dev, "missing controller clock");
+		dev_err(dev, "missing controller clock");
 		return PTR_ERR(riic->clk);
 	}
 
-	rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
+	rstc = devm_reset_control_get_optional_exclusive(dev, NULL);
 	if (IS_ERR(rstc))
-		return dev_err_probe(&pdev->dev, PTR_ERR(rstc),
+		return dev_err_probe(dev, PTR_ERR(rstc),
 				     "Error: missing reset ctrl\n");
 
 	ret = reset_control_deassert(rstc);
 	if (ret)
 		return ret;
 
-	ret = devm_add_action_or_reset(&pdev->dev, riic_reset_control_assert, rstc);
+	ret = devm_add_action_or_reset(dev, riic_reset_control_assert, rstc);
 	if (ret)
 		return ret;
 
@@ -453,29 +456,29 @@ static int riic_i2c_probe(struct platform_device *pdev)
 		if (ret < 0)
 			return ret;
 
-		ret = devm_request_irq(&pdev->dev, ret, riic_irqs[i].isr,
+		ret = devm_request_irq(dev, ret, riic_irqs[i].isr,
 				       0, riic_irqs[i].name, riic);
 		if (ret) {
-			dev_err(&pdev->dev, "failed to request irq %s\n", riic_irqs[i].name);
+			dev_err(dev, "failed to request irq %s\n", riic_irqs[i].name);
 			return ret;
 		}
 	}
 
-	riic->info = of_device_get_match_data(&pdev->dev);
+	riic->info = of_device_get_match_data(dev);
 
 	adap = &riic->adapter;
 	i2c_set_adapdata(adap, riic);
 	strscpy(adap->name, "Renesas RIIC adapter", sizeof(adap->name));
 	adap->owner = THIS_MODULE;
 	adap->algo = &riic_algo;
-	adap->dev.parent = &pdev->dev;
-	adap->dev.of_node = pdev->dev.of_node;
+	adap->dev.parent = dev;
+	adap->dev.of_node = dev->of_node;
 
 	init_completion(&riic->msg_done);
 
-	i2c_parse_fw_timings(&pdev->dev, &i2c_t, true);
+	i2c_parse_fw_timings(dev, &i2c_t, true);
 
-	pm_runtime_enable(&pdev->dev);
+	pm_runtime_enable(dev);
 
 	ret = riic_init_hw(riic, &i2c_t);
 	if (ret)
@@ -487,24 +490,24 @@ static int riic_i2c_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, riic);
 
-	dev_info(&pdev->dev, "registered with %dHz bus speed\n",
-		 i2c_t.bus_freq_hz);
+	dev_info(dev, "registered with %dHz bus speed\n", i2c_t.bus_freq_hz);
 	return 0;
 
 out:
-	pm_runtime_disable(&pdev->dev);
+	pm_runtime_disable(dev);
 	return ret;
 }
 
 static void riic_i2c_remove(struct platform_device *pdev)
 {
 	struct riic_dev *riic = platform_get_drvdata(pdev);
+	struct device *dev = &pdev->dev;
 
-	pm_runtime_get_sync(&pdev->dev);
+	pm_runtime_get_sync(dev);
 	riic_writeb(riic, 0, RIIC_ICIER);
-	pm_runtime_put(&pdev->dev);
+	pm_runtime_put(dev);
 	i2c_del_adapter(&riic->adapter);
-	pm_runtime_disable(&pdev->dev);
+	pm_runtime_disable(dev);
 }
 
 static const struct riic_of_data riic_rz_a_info = {
-- 
2.39.2


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

* [PATCH v4 02/11] i2c: riic: Call pm_runtime_get_sync() when need to access registers
  2024-08-19 10:23 [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Claudiu
  2024-08-19 10:23 ` [PATCH v4 01/11] i2c: riic: Use temporary variable for struct device Claudiu
@ 2024-08-19 10:23 ` Claudiu
  2024-08-19 10:23 ` [PATCH v4 03/11] i2c: riic: Use pm_runtime_resume_and_get() Claudiu
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 26+ messages in thread
From: Claudiu @ 2024-08-19 10:23 UTC (permalink / raw)
  To: chris.brandt, andi.shyti, robh, krzk+dt, conor+dt, geert+renesas,
	magnus.damm, p.zabel, wsa+renesas
  Cc: linux-renesas-soc, linux-i2c, devicetree, linux-kernel,
	claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

There is no need to runtime resume the device as long as the IP registers
are not accessed. Calling pm_runtime_get_sync() at the register access
time leads to a simpler error path.

Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---

Changes in v4:
- collected tags

Changes in v3:
- collected tags

Changes in v2:
- none

 drivers/i2c/busses/i2c-riic.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
index bc33762a5d07..2e119024c2d7 100644
--- a/drivers/i2c/busses/i2c-riic.c
+++ b/drivers/i2c/busses/i2c-riic.c
@@ -301,19 +301,15 @@ static const struct i2c_algorithm riic_algo = {
 
 static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t)
 {
-	int ret = 0;
 	unsigned long rate;
 	int total_ticks, cks, brl, brh;
 	struct device *dev = riic->adapter.dev.parent;
 
-	pm_runtime_get_sync(dev);
-
 	if (t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ) {
 		dev_err(&riic->adapter.dev,
 			"unsupported bus speed (%dHz). %d max\n",
 			t->bus_freq_hz, I2C_MAX_FAST_MODE_FREQ);
-		ret = -EINVAL;
-		goto out;
+		return -EINVAL;
 	}
 
 	rate = clk_get_rate(riic->clk);
@@ -351,8 +347,7 @@ static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t)
 	if (brl > (0x1F + 3)) {
 		dev_err(&riic->adapter.dev, "invalid speed (%lu). Too slow.\n",
 			(unsigned long)t->bus_freq_hz);
-		ret = -EINVAL;
-		goto out;
+		return -EINVAL;
 	}
 
 	brh = total_ticks - brl;
@@ -384,6 +379,8 @@ static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t)
 		 t->scl_fall_ns / (1000000000 / rate),
 		 t->scl_rise_ns / (1000000000 / rate), cks, brl, brh);
 
+	pm_runtime_get_sync(dev);
+
 	/* Changing the order of accessing IICRST and ICE may break things! */
 	riic_writeb(riic, ICCR1_IICRST | ICCR1_SOWP, RIIC_ICCR1);
 	riic_clear_set_bit(riic, 0, ICCR1_ICE, RIIC_ICCR1);
@@ -397,9 +394,8 @@ static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t)
 
 	riic_clear_set_bit(riic, ICCR1_IICRST, 0, RIIC_ICCR1);
 
-out:
 	pm_runtime_put(dev);
-	return ret;
+	return 0;
 }
 
 static struct riic_irq_desc riic_irqs[] = {
-- 
2.39.2


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

* [PATCH v4 03/11] i2c: riic: Use pm_runtime_resume_and_get()
  2024-08-19 10:23 [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Claudiu
  2024-08-19 10:23 ` [PATCH v4 01/11] i2c: riic: Use temporary variable for struct device Claudiu
  2024-08-19 10:23 ` [PATCH v4 02/11] i2c: riic: Call pm_runtime_get_sync() when need to access registers Claudiu
@ 2024-08-19 10:23 ` Claudiu
  2024-08-19 10:23 ` [PATCH v4 04/11] i2c: riic: Enable runtime PM autosuspend support Claudiu
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 26+ messages in thread
From: Claudiu @ 2024-08-19 10:23 UTC (permalink / raw)
  To: chris.brandt, andi.shyti, robh, krzk+dt, conor+dt, geert+renesas,
	magnus.damm, p.zabel, wsa+renesas
  Cc: linux-renesas-soc, linux-i2c, devicetree, linux-kernel,
	claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

pm_runtime_get_sync() may return with error. In case it returns with error
dev->power.usage_count needs to be decremented. pm_runtime_resume_and_get()
takes care of this. Thus use it.

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---

Changes in v4:
- collected tags

Changes in v3:
- dropped error message on pm_runtime_resume_and_get() failures
- restored initial place of i2c_del_adapter() in riic_i2c_remove()

Changes in v2:
- delete i2c adapter all the time in remove

 drivers/i2c/busses/i2c-riic.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
index 2e119024c2d7..6fc41bde2ec2 100644
--- a/drivers/i2c/busses/i2c-riic.c
+++ b/drivers/i2c/busses/i2c-riic.c
@@ -133,10 +133,12 @@ static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
 	struct riic_dev *riic = i2c_get_adapdata(adap);
 	struct device *dev = adap->dev.parent;
 	unsigned long time_left;
-	int i;
+	int i, ret;
 	u8 start_bit;
 
-	pm_runtime_get_sync(dev);
+	ret = pm_runtime_resume_and_get(dev);
+	if (ret)
+		return ret;
 
 	if (riic_readb(riic, RIIC_ICCR2) & ICCR2_BBSY) {
 		riic->err = -EBUSY;
@@ -301,6 +303,7 @@ static const struct i2c_algorithm riic_algo = {
 
 static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t)
 {
+	int ret;
 	unsigned long rate;
 	int total_ticks, cks, brl, brh;
 	struct device *dev = riic->adapter.dev.parent;
@@ -379,7 +382,9 @@ static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t)
 		 t->scl_fall_ns / (1000000000 / rate),
 		 t->scl_rise_ns / (1000000000 / rate), cks, brl, brh);
 
-	pm_runtime_get_sync(dev);
+	ret = pm_runtime_resume_and_get(dev);
+	if (ret)
+		return ret;
 
 	/* Changing the order of accessing IICRST and ICE may break things! */
 	riic_writeb(riic, ICCR1_IICRST | ICCR1_SOWP, RIIC_ICCR1);
@@ -498,10 +503,13 @@ static void riic_i2c_remove(struct platform_device *pdev)
 {
 	struct riic_dev *riic = platform_get_drvdata(pdev);
 	struct device *dev = &pdev->dev;
+	int ret;
 
-	pm_runtime_get_sync(dev);
-	riic_writeb(riic, 0, RIIC_ICIER);
-	pm_runtime_put(dev);
+	ret = pm_runtime_resume_and_get(dev);
+	if (!ret) {
+		riic_writeb(riic, 0, RIIC_ICIER);
+		pm_runtime_put(dev);
+	}
 	i2c_del_adapter(&riic->adapter);
 	pm_runtime_disable(dev);
 }
-- 
2.39.2


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

* [PATCH v4 04/11] i2c: riic: Enable runtime PM autosuspend support
  2024-08-19 10:23 [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Claudiu
                   ` (2 preceding siblings ...)
  2024-08-19 10:23 ` [PATCH v4 03/11] i2c: riic: Use pm_runtime_resume_and_get() Claudiu
@ 2024-08-19 10:23 ` Claudiu
  2024-08-19 10:23 ` [PATCH v4 05/11] i2c: riic: Add suspend/resume support Claudiu
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 26+ messages in thread
From: Claudiu @ 2024-08-19 10:23 UTC (permalink / raw)
  To: chris.brandt, andi.shyti, robh, krzk+dt, conor+dt, geert+renesas,
	magnus.damm, p.zabel, wsa+renesas
  Cc: linux-renesas-soc, linux-i2c, devicetree, linux-kernel,
	claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Enable runtime PM autosuspend support for the RIIC driver. With this, in
case there are consecutive xfer requests the device wouldn't be runtime
enabled/disabled after each consecutive xfer but after the
the delay configured by user. With this, we can avoid touching hardware
registers involved in runtime PM suspend/resume saving in this way some
cycles. The default chosen autosuspend delay is zero to keep the
previous driver behavior.

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---

Changes in v4:
- collected tags
- added a comment on top of pm_runtime_set_autosuspend_delay()

Changes in v3:
- none

Changes in v2:
- none

 drivers/i2c/busses/i2c-riic.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
index 6fc41bde2ec2..ec854a525a0b 100644
--- a/drivers/i2c/busses/i2c-riic.c
+++ b/drivers/i2c/busses/i2c-riic.c
@@ -171,7 +171,8 @@ static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
 	}
 
  out:
-	pm_runtime_put(dev);
+	pm_runtime_mark_last_busy(dev);
+	pm_runtime_put_autosuspend(dev);
 
 	return riic->err ?: num;
 }
@@ -399,7 +400,8 @@ static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t)
 
 	riic_clear_set_bit(riic, ICCR1_IICRST, 0, RIIC_ICCR1);
 
-	pm_runtime_put(dev);
+	pm_runtime_mark_last_busy(dev);
+	pm_runtime_put_autosuspend(dev);
 	return 0;
 }
 
@@ -479,6 +481,9 @@ static int riic_i2c_probe(struct platform_device *pdev)
 
 	i2c_parse_fw_timings(dev, &i2c_t, true);
 
+	/* Default 0 to save power. Can be overridden via sysfs for lower latency. */
+	pm_runtime_set_autosuspend_delay(dev, 0);
+	pm_runtime_use_autosuspend(dev);
 	pm_runtime_enable(dev);
 
 	ret = riic_init_hw(riic, &i2c_t);
@@ -496,6 +501,7 @@ static int riic_i2c_probe(struct platform_device *pdev)
 
 out:
 	pm_runtime_disable(dev);
+	pm_runtime_dont_use_autosuspend(dev);
 	return ret;
 }
 
@@ -512,6 +518,7 @@ static void riic_i2c_remove(struct platform_device *pdev)
 	}
 	i2c_del_adapter(&riic->adapter);
 	pm_runtime_disable(dev);
+	pm_runtime_dont_use_autosuspend(dev);
 }
 
 static const struct riic_of_data riic_rz_a_info = {
-- 
2.39.2


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

* [PATCH v4 05/11] i2c: riic: Add suspend/resume support
  2024-08-19 10:23 [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Claudiu
                   ` (3 preceding siblings ...)
  2024-08-19 10:23 ` [PATCH v4 04/11] i2c: riic: Enable runtime PM autosuspend support Claudiu
@ 2024-08-19 10:23 ` Claudiu
  2024-08-19 19:37   ` Andi Shyti
  2024-08-19 10:23 ` [PATCH v4 06/11] i2c: riic: Define individual arrays to describe the register offsets Claudiu
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 26+ messages in thread
From: Claudiu @ 2024-08-19 10:23 UTC (permalink / raw)
  To: chris.brandt, andi.shyti, robh, krzk+dt, conor+dt, geert+renesas,
	magnus.damm, p.zabel, wsa+renesas
  Cc: linux-renesas-soc, linux-i2c, devicetree, linux-kernel,
	claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Add suspend/resume support for the RIIC driver. This is necessary for the
Renesas RZ/G3S SoC which support suspend to deep sleep state where power
to most of the SoC components is turned off. As a result the I2C controller
needs to be reconfigured after suspend/resume. For this, the reset line
was stored in the driver private data structure as well as i2c timings.
The reset line and I2C timings are necessary to re-initialize the
controller after resume.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---

Changes in v4:
- rebased on top of latest next

Changes in v3:
- none

Changes in v2:
- deassert the reset line in resume if riic_init_hw() fails as
  if that happens there is no way to recover the controller

 drivers/i2c/busses/i2c-riic.c | 68 +++++++++++++++++++++++++++++------
 1 file changed, 57 insertions(+), 11 deletions(-)

diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
index ec854a525a0b..f863b367fb85 100644
--- a/drivers/i2c/busses/i2c-riic.c
+++ b/drivers/i2c/busses/i2c-riic.c
@@ -105,6 +105,8 @@ struct riic_dev {
 	struct completion msg_done;
 	struct i2c_adapter adapter;
 	struct clk *clk;
+	struct reset_control *rstc;
+	struct i2c_timings i2c_t;
 };
 
 struct riic_irq_desc {
@@ -302,11 +304,12 @@ static const struct i2c_algorithm riic_algo = {
 	.functionality = riic_func,
 };
 
-static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t)
+static int riic_init_hw(struct riic_dev *riic)
 {
 	int ret;
 	unsigned long rate;
 	int total_ticks, cks, brl, brh;
+	struct i2c_timings *t = &riic->i2c_t;
 	struct device *dev = riic->adapter.dev.parent;
 
 	if (t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ) {
@@ -423,8 +426,6 @@ static int riic_i2c_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct riic_dev *riic;
 	struct i2c_adapter *adap;
-	struct i2c_timings i2c_t;
-	struct reset_control *rstc;
 	int i, ret;
 
 	riic = devm_kzalloc(dev, sizeof(*riic), GFP_KERNEL);
@@ -441,16 +442,16 @@ static int riic_i2c_probe(struct platform_device *pdev)
 		return PTR_ERR(riic->clk);
 	}
 
-	rstc = devm_reset_control_get_optional_exclusive(dev, NULL);
-	if (IS_ERR(rstc))
-		return dev_err_probe(dev, PTR_ERR(rstc),
+	riic->rstc = devm_reset_control_get_optional_exclusive(dev, NULL);
+	if (IS_ERR(riic->rstc))
+		return dev_err_probe(dev, PTR_ERR(riic->rstc),
 				     "Error: missing reset ctrl\n");
 
-	ret = reset_control_deassert(rstc);
+	ret = reset_control_deassert(riic->rstc);
 	if (ret)
 		return ret;
 
-	ret = devm_add_action_or_reset(dev, riic_reset_control_assert, rstc);
+	ret = devm_add_action_or_reset(dev, riic_reset_control_assert, riic->rstc);
 	if (ret)
 		return ret;
 
@@ -479,14 +480,14 @@ static int riic_i2c_probe(struct platform_device *pdev)
 
 	init_completion(&riic->msg_done);
 
-	i2c_parse_fw_timings(dev, &i2c_t, true);
+	i2c_parse_fw_timings(dev, &riic->i2c_t, true);
 
 	/* Default 0 to save power. Can be overridden via sysfs for lower latency. */
 	pm_runtime_set_autosuspend_delay(dev, 0);
 	pm_runtime_use_autosuspend(dev);
 	pm_runtime_enable(dev);
 
-	ret = riic_init_hw(riic, &i2c_t);
+	ret = riic_init_hw(riic);
 	if (ret)
 		goto out;
 
@@ -496,7 +497,7 @@ static int riic_i2c_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, riic);
 
-	dev_info(dev, "registered with %dHz bus speed\n", i2c_t.bus_freq_hz);
+	dev_info(dev, "registered with %dHz bus speed\n", riic->i2c_t.bus_freq_hz);
 	return 0;
 
 out:
@@ -553,6 +554,50 @@ static const struct riic_of_data riic_rz_v2h_info = {
 	},
 };
 
+static int riic_i2c_suspend(struct device *dev)
+{
+	struct riic_dev *riic = dev_get_drvdata(dev);
+	int ret;
+
+	ret = pm_runtime_resume_and_get(dev);
+	if (ret)
+		return ret;
+
+	i2c_mark_adapter_suspended(&riic->adapter);
+
+	/* Disable output on SDA, SCL pins. */
+	riic_clear_set_bit(riic, ICCR1_ICE, 0, RIIC_ICCR1);
+
+	pm_runtime_mark_last_busy(dev);
+	pm_runtime_put_sync(dev);
+
+	return reset_control_assert(riic->rstc);
+}
+
+static int riic_i2c_resume(struct device *dev)
+{
+	struct riic_dev *riic = dev_get_drvdata(dev);
+	int ret;
+
+	ret = reset_control_deassert(riic->rstc);
+	if (ret)
+		return ret;
+
+	ret = riic_init_hw(riic);
+	if (ret) {
+		reset_control_assert(riic->rstc);
+		return ret;
+	}
+
+	i2c_mark_adapter_resumed(&riic->adapter);
+
+	return 0;
+}
+
+static const struct dev_pm_ops riic_i2c_pm_ops = {
+	SYSTEM_SLEEP_PM_OPS(riic_i2c_suspend, riic_i2c_resume)
+};
+
 static const struct of_device_id riic_i2c_dt_ids[] = {
 	{ .compatible = "renesas,riic-rz", .data = &riic_rz_a_info },
 	{ .compatible = "renesas,riic-r9a09g057", .data = &riic_rz_v2h_info },
@@ -565,6 +610,7 @@ static struct platform_driver riic_i2c_driver = {
 	.driver		= {
 		.name	= "i2c-riic",
 		.of_match_table = riic_i2c_dt_ids,
+		.pm	= pm_ptr(&riic_i2c_pm_ops),
 	},
 };
 
-- 
2.39.2


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

* [PATCH v4 06/11] i2c: riic: Define individual arrays to describe the register offsets
  2024-08-19 10:23 [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Claudiu
                   ` (4 preceding siblings ...)
  2024-08-19 10:23 ` [PATCH v4 05/11] i2c: riic: Add suspend/resume support Claudiu
@ 2024-08-19 10:23 ` Claudiu
  2024-08-19 20:20   ` Andi Shyti
  2024-08-19 10:23 ` [PATCH v4 07/11] dt-bindings: i2c: renesas,riic: Document the R9A08G045 support Claudiu
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 26+ messages in thread
From: Claudiu @ 2024-08-19 10:23 UTC (permalink / raw)
  To: chris.brandt, andi.shyti, robh, krzk+dt, conor+dt, geert+renesas,
	magnus.damm, p.zabel, wsa+renesas
  Cc: linux-renesas-soc, linux-i2c, devicetree, linux-kernel,
	claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Define individual arrays to describe the register offsets. In this way
we can describe different IP variants that share the same register offsets
but have differences in other characteristics. Commit prepares for the
addition of fast mode plus.

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---

Changes in v4:
- collected tags

Changes in v3:
- none

Changes in v2:
- none

 drivers/i2c/busses/i2c-riic.c | 58 +++++++++++++++++++----------------
 1 file changed, 31 insertions(+), 27 deletions(-)

diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
index f863b367fb85..cc2452853d19 100644
--- a/drivers/i2c/busses/i2c-riic.c
+++ b/drivers/i2c/busses/i2c-riic.c
@@ -91,7 +91,7 @@ enum riic_reg_list {
 };
 
 struct riic_of_data {
-	u8 regs[RIIC_REG_END];
+	const u8 *regs;
 };
 
 struct riic_dev {
@@ -522,36 +522,40 @@ static void riic_i2c_remove(struct platform_device *pdev)
 	pm_runtime_dont_use_autosuspend(dev);
 }
 
+static const u8 riic_rz_a_regs[RIIC_REG_END] = {
+	[RIIC_ICCR1] = 0x00,
+	[RIIC_ICCR2] = 0x04,
+	[RIIC_ICMR1] = 0x08,
+	[RIIC_ICMR3] = 0x10,
+	[RIIC_ICSER] = 0x18,
+	[RIIC_ICIER] = 0x1c,
+	[RIIC_ICSR2] = 0x24,
+	[RIIC_ICBRL] = 0x34,
+	[RIIC_ICBRH] = 0x38,
+	[RIIC_ICDRT] = 0x3c,
+	[RIIC_ICDRR] = 0x40,
+};
+
 static const struct riic_of_data riic_rz_a_info = {
-	.regs = {
-		[RIIC_ICCR1] = 0x00,
-		[RIIC_ICCR2] = 0x04,
-		[RIIC_ICMR1] = 0x08,
-		[RIIC_ICMR3] = 0x10,
-		[RIIC_ICSER] = 0x18,
-		[RIIC_ICIER] = 0x1c,
-		[RIIC_ICSR2] = 0x24,
-		[RIIC_ICBRL] = 0x34,
-		[RIIC_ICBRH] = 0x38,
-		[RIIC_ICDRT] = 0x3c,
-		[RIIC_ICDRR] = 0x40,
-	},
+	.regs = riic_rz_a_regs,
+};
+
+static const u8 riic_rz_v2h_regs[RIIC_REG_END] = {
+	[RIIC_ICCR1] = 0x00,
+	[RIIC_ICCR2] = 0x01,
+	[RIIC_ICMR1] = 0x02,
+	[RIIC_ICMR3] = 0x04,
+	[RIIC_ICSER] = 0x06,
+	[RIIC_ICIER] = 0x07,
+	[RIIC_ICSR2] = 0x09,
+	[RIIC_ICBRL] = 0x10,
+	[RIIC_ICBRH] = 0x11,
+	[RIIC_ICDRT] = 0x12,
+	[RIIC_ICDRR] = 0x13,
 };
 
 static const struct riic_of_data riic_rz_v2h_info = {
-	.regs = {
-		[RIIC_ICCR1] = 0x00,
-		[RIIC_ICCR2] = 0x01,
-		[RIIC_ICMR1] = 0x02,
-		[RIIC_ICMR3] = 0x04,
-		[RIIC_ICSER] = 0x06,
-		[RIIC_ICIER] = 0x07,
-		[RIIC_ICSR2] = 0x09,
-		[RIIC_ICBRL] = 0x10,
-		[RIIC_ICBRH] = 0x11,
-		[RIIC_ICDRT] = 0x12,
-		[RIIC_ICDRR] = 0x13,
-	},
+	.regs = riic_rz_v2h_regs,
 };
 
 static int riic_i2c_suspend(struct device *dev)
-- 
2.39.2


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

* [PATCH v4 07/11] dt-bindings: i2c: renesas,riic: Document the R9A08G045 support
  2024-08-19 10:23 [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Claudiu
                   ` (5 preceding siblings ...)
  2024-08-19 10:23 ` [PATCH v4 06/11] i2c: riic: Define individual arrays to describe the register offsets Claudiu
@ 2024-08-19 10:23 ` Claudiu
  2024-08-19 11:05   ` Krzysztof Kozlowski
  2024-08-19 10:23 ` [PATCH v4 08/11] i2c: riic: Add support for fast mode plus Claudiu
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 26+ messages in thread
From: Claudiu @ 2024-08-19 10:23 UTC (permalink / raw)
  To: chris.brandt, andi.shyti, robh, krzk+dt, conor+dt, geert+renesas,
	magnus.damm, p.zabel, wsa+renesas
  Cc: linux-renesas-soc, linux-i2c, devicetree, linux-kernel,
	claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Document the Renesas RZ/G3S (R9A08G045) RIIC IP. This is compatible with
the version available on Renesas RZ/V2H (R9A09G075).

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---

Changes in v4:
- added comment near the fallback for RZ/G3S; because of this
  dropped Conor's tag

Changes in v3:
- collected tags

Changes in v2:
- dropped the renesas,riic-no-fast-mode-plus
- updated commit description

 Documentation/devicetree/bindings/i2c/renesas,riic.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/i2c/renesas,riic.yaml b/Documentation/devicetree/bindings/i2c/renesas,riic.yaml
index 7993fe463c4c..505a8ec92266 100644
--- a/Documentation/devicetree/bindings/i2c/renesas,riic.yaml
+++ b/Documentation/devicetree/bindings/i2c/renesas,riic.yaml
@@ -25,6 +25,10 @@ properties:
               - renesas,riic-r9a07g054  # RZ/V2L
           - const: renesas,riic-rz      # RZ/A or RZ/G2L
 
+      - items:
+          - const: renesas,riic-r9a08g045   # RZ/G3S
+          - const: renesas,riic-r9a09g057   # RZ/V2H(P)
+
       - const: renesas,riic-r9a09g057   # RZ/V2H(P)
 
   reg:
-- 
2.39.2


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

* [PATCH v4 08/11] i2c: riic: Add support for fast mode plus
  2024-08-19 10:23 [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Claudiu
                   ` (6 preceding siblings ...)
  2024-08-19 10:23 ` [PATCH v4 07/11] dt-bindings: i2c: renesas,riic: Document the R9A08G045 support Claudiu
@ 2024-08-19 10:23 ` Claudiu
  2024-08-19 20:12   ` Andi Shyti
  2024-08-19 10:23 ` [PATCH v4 09/11] arm64: dts: renesas: r9a08g045: Add I2C nodes Claudiu
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 26+ messages in thread
From: Claudiu @ 2024-08-19 10:23 UTC (permalink / raw)
  To: chris.brandt, andi.shyti, robh, krzk+dt, conor+dt, geert+renesas,
	magnus.damm, p.zabel, wsa+renesas
  Cc: linux-renesas-soc, linux-i2c, devicetree, linux-kernel,
	claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Fast mode plus is available on most of the IP variants that RIIC driver
is working with. The exception is (according to HW manuals of the SoCs
where this IP is available) the Renesas RZ/A1H. For this, patch
introduces the struct riic_of_data::fast_mode_plus.

Fast mode plus was tested on RZ/G3S, RZ/G2{L,UL,LC}, RZ/Five by
instantiating the RIIC frequency to 1MHz and issuing i2c reads on the
fast mode plus capable devices (and the i2c clock frequency was checked on
RZ/G3S).

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---

Changes in v4:
- in riic_init_hw() checked t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ
  before applying hardware settings

Changes in v3:
- enabled FM+ for all riic_rz_a_info based platforms except RZ/A1H
  as requested in review comments; with this, dropped the riic_rz_g2_info
  and RZ/G2 specific compatibles in riic_i2c_dt_ids[];

  Note that it has been tested only on platforms mentioned in commit
  description (as I don't have all the other RZ/A platforms).

Changes in v2:
- dropped code that handles the renesas,riic-no-fast-mode-plus
- updated commit description

 drivers/i2c/busses/i2c-riic.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
index cc2452853d19..32b8bd4888dd 100644
--- a/drivers/i2c/busses/i2c-riic.c
+++ b/drivers/i2c/busses/i2c-riic.c
@@ -63,6 +63,8 @@
 #define ICMR3_ACKWP	0x10
 #define ICMR3_ACKBT	0x08
 
+#define ICFER_FMPE	0x80
+
 #define ICIER_TIE	0x80
 #define ICIER_TEIE	0x40
 #define ICIER_RIE	0x20
@@ -80,6 +82,7 @@ enum riic_reg_list {
 	RIIC_ICCR2,
 	RIIC_ICMR1,
 	RIIC_ICMR3,
+	RIIC_ICFER,
 	RIIC_ICSER,
 	RIIC_ICIER,
 	RIIC_ICSR2,
@@ -92,6 +95,7 @@ enum riic_reg_list {
 
 struct riic_of_data {
 	const u8 *regs;
+	bool fast_mode_plus;
 };
 
 struct riic_dev {
@@ -311,11 +315,14 @@ static int riic_init_hw(struct riic_dev *riic)
 	int total_ticks, cks, brl, brh;
 	struct i2c_timings *t = &riic->i2c_t;
 	struct device *dev = riic->adapter.dev.parent;
+	const struct riic_of_data *info = riic->info;
 
-	if (t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ) {
+	if ((!info->fast_mode_plus && t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ) ||
+	    (info->fast_mode_plus && t->bus_freq_hz > I2C_MAX_FAST_MODE_PLUS_FREQ)) {
 		dev_err(&riic->adapter.dev,
-			"unsupported bus speed (%dHz). %d max\n",
-			t->bus_freq_hz, I2C_MAX_FAST_MODE_FREQ);
+			"unsupported bus speed (%dHz). %d max\n", t->bus_freq_hz,
+			info->fast_mode_plus ? I2C_MAX_FAST_MODE_PLUS_FREQ :
+			I2C_MAX_FAST_MODE_FREQ);
 		return -EINVAL;
 	}
 
@@ -401,6 +408,9 @@ static int riic_init_hw(struct riic_dev *riic)
 	riic_writeb(riic, 0, RIIC_ICSER);
 	riic_writeb(riic, ICMR3_ACKWP | ICMR3_RDRFS, RIIC_ICMR3);
 
+	if (info->fast_mode_plus && t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ)
+		riic_clear_set_bit(riic, 0, ICFER_FMPE, RIIC_ICFER);
+
 	riic_clear_set_bit(riic, ICCR1_IICRST, 0, RIIC_ICCR1);
 
 	pm_runtime_mark_last_busy(dev);
@@ -527,6 +537,7 @@ static const u8 riic_rz_a_regs[RIIC_REG_END] = {
 	[RIIC_ICCR2] = 0x04,
 	[RIIC_ICMR1] = 0x08,
 	[RIIC_ICMR3] = 0x10,
+	[RIIC_ICFER] = 0x14,
 	[RIIC_ICSER] = 0x18,
 	[RIIC_ICIER] = 0x1c,
 	[RIIC_ICSR2] = 0x24,
@@ -538,6 +549,11 @@ static const u8 riic_rz_a_regs[RIIC_REG_END] = {
 
 static const struct riic_of_data riic_rz_a_info = {
 	.regs = riic_rz_a_regs,
+	.fast_mode_plus = true,
+};
+
+static const struct riic_of_data riic_rz_a1h_info = {
+	.regs = riic_rz_a_regs,
 };
 
 static const u8 riic_rz_v2h_regs[RIIC_REG_END] = {
@@ -545,6 +561,7 @@ static const u8 riic_rz_v2h_regs[RIIC_REG_END] = {
 	[RIIC_ICCR2] = 0x01,
 	[RIIC_ICMR1] = 0x02,
 	[RIIC_ICMR3] = 0x04,
+	[RIIC_ICFER] = 0x05,
 	[RIIC_ICSER] = 0x06,
 	[RIIC_ICIER] = 0x07,
 	[RIIC_ICSR2] = 0x09,
@@ -556,6 +573,7 @@ static const u8 riic_rz_v2h_regs[RIIC_REG_END] = {
 
 static const struct riic_of_data riic_rz_v2h_info = {
 	.regs = riic_rz_v2h_regs,
+	.fast_mode_plus = true,
 };
 
 static int riic_i2c_suspend(struct device *dev)
@@ -604,6 +622,7 @@ static const struct dev_pm_ops riic_i2c_pm_ops = {
 
 static const struct of_device_id riic_i2c_dt_ids[] = {
 	{ .compatible = "renesas,riic-rz", .data = &riic_rz_a_info },
+	{ .compatible = "renesas,riic-r7s72100", .data =  &riic_rz_a1h_info, },
 	{ .compatible = "renesas,riic-r9a09g057", .data = &riic_rz_v2h_info },
 	{ /* Sentinel */ },
 };
-- 
2.39.2


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

* [PATCH v4 09/11] arm64: dts: renesas: r9a08g045: Add I2C nodes
  2024-08-19 10:23 [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Claudiu
                   ` (7 preceding siblings ...)
  2024-08-19 10:23 ` [PATCH v4 08/11] i2c: riic: Add support for fast mode plus Claudiu
@ 2024-08-19 10:23 ` Claudiu
  2024-08-19 10:23 ` [PATCH v4 10/11] arm64: dts: renesas: rzg3s-smarc: Enable i2c0 node Claudiu
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 26+ messages in thread
From: Claudiu @ 2024-08-19 10:23 UTC (permalink / raw)
  To: chris.brandt, andi.shyti, robh, krzk+dt, conor+dt, geert+renesas,
	magnus.damm, p.zabel, wsa+renesas
  Cc: linux-renesas-soc, linux-i2c, devicetree, linux-kernel,
	claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

The Renesas RZ/G3S has 4 I2C channels. Add DT nodes for it.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---

Changes in v4:
- none

Changes in v3:
- none

Changes in v2:
- dropped renesas,riic-no-fast-mode-plus

 arch/arm64/boot/dts/renesas/r9a08g045.dtsi | 88 ++++++++++++++++++++++
 1 file changed, 88 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r9a08g045.dtsi b/arch/arm64/boot/dts/renesas/r9a08g045.dtsi
index 37885cd24f16..e44e8949e22a 100644
--- a/arch/arm64/boot/dts/renesas/r9a08g045.dtsi
+++ b/arch/arm64/boot/dts/renesas/r9a08g045.dtsi
@@ -72,6 +72,94 @@ scif0: serial@1004b800 {
 			status = "disabled";
 		};
 
+		i2c0: i2c@10090000 {
+			compatible = "renesas,riic-r9a08g045", "renesas,riic-r9a09g057";
+			reg = <0 0x10090000 0 0x400>;
+			interrupts = <GIC_SPI 257 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 263 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 264 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 259 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 260 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 258 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 261 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 262 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "tei", "ri", "ti", "spi", "sti",
+					  "naki", "ali", "tmoi";
+			clocks = <&cpg CPG_MOD R9A08G045_I2C0_PCLK>;
+			clock-frequency = <100000>;
+			resets = <&cpg R9A08G045_I2C0_MRST>;
+			power-domains = <&cpg>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
+
+		i2c1: i2c@10090400 {
+			compatible = "renesas,riic-r9a08g045", "renesas,riic-r9a09g057";
+			reg = <0 0x10090400 0 0x400>;
+			interrupts = <GIC_SPI 265 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 271 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 272 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 267 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 268 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 266 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 269 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 270 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "tei", "ri", "ti", "spi", "sti",
+					  "naki", "ali", "tmoi";
+			clocks = <&cpg CPG_MOD R9A08G045_I2C1_PCLK>;
+			clock-frequency = <100000>;
+			resets = <&cpg R9A08G045_I2C1_MRST>;
+			power-domains = <&cpg>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
+
+		i2c2: i2c@10090800 {
+			compatible = "renesas,riic-r9a08g045", "renesas,riic-r9a09g057";
+			reg = <0 0x10090800 0 0x400>;
+			interrupts = <GIC_SPI 273 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 279 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 280 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 275 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 276 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 274 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 277 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 278 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "tei", "ri", "ti", "spi", "sti",
+					  "naki", "ali", "tmoi";
+			clocks = <&cpg CPG_MOD R9A08G045_I2C2_PCLK>;
+			clock-frequency = <100000>;
+			resets = <&cpg R9A08G045_I2C2_MRST>;
+			power-domains = <&cpg>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
+
+		i2c3: i2c@10090c00 {
+			compatible = "renesas,riic-r9a08g045", "renesas,riic-r9a09g057";
+			reg = <0 0x10090c00 0 0x400>;
+			interrupts = <GIC_SPI 281 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 287 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 288 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 283 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 284 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 282 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 285 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 286 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "tei", "ri", "ti", "spi", "sti",
+					  "naki", "ali", "tmoi";
+			clocks = <&cpg CPG_MOD R9A08G045_I2C3_PCLK>;
+			clock-frequency = <100000>;
+			resets = <&cpg R9A08G045_I2C3_MRST>;
+			power-domains = <&cpg>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
+
 		cpg: clock-controller@11010000 {
 			compatible = "renesas,r9a08g045-cpg";
 			reg = <0 0x11010000 0 0x10000>;
-- 
2.39.2


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

* [PATCH v4 10/11] arm64: dts: renesas: rzg3s-smarc: Enable i2c0 node
  2024-08-19 10:23 [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Claudiu
                   ` (8 preceding siblings ...)
  2024-08-19 10:23 ` [PATCH v4 09/11] arm64: dts: renesas: r9a08g045: Add I2C nodes Claudiu
@ 2024-08-19 10:23 ` Claudiu
  2024-08-19 10:23 ` [PATCH v4 11/11] arm64: dts: renesas: rzg3s-smarc-som: Enable i2c1 node Claudiu
  2024-08-19 20:23 ` [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Andi Shyti
  11 siblings, 0 replies; 26+ messages in thread
From: Claudiu @ 2024-08-19 10:23 UTC (permalink / raw)
  To: chris.brandt, andi.shyti, robh, krzk+dt, conor+dt, geert+renesas,
	magnus.damm, p.zabel, wsa+renesas
  Cc: linux-renesas-soc, linux-i2c, devicetree, linux-kernel,
	claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Enable i2c0 node.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---

Changes in v4:
- none

Changes in v3:
- none

Changes in v2:
- none

 arch/arm64/boot/dts/renesas/rzg3s-smarc.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/rzg3s-smarc.dtsi b/arch/arm64/boot/dts/renesas/rzg3s-smarc.dtsi
index deb2ad37bb2e..7945d44e6ee1 100644
--- a/arch/arm64/boot/dts/renesas/rzg3s-smarc.dtsi
+++ b/arch/arm64/boot/dts/renesas/rzg3s-smarc.dtsi
@@ -11,6 +11,7 @@
 
 / {
 	aliases {
+		i2c0 = &i2c0;
 		serial0 = &scif0;
 		mmc1 = &sdhi1;
 	};
@@ -66,6 +67,12 @@ vccq_sdhi1: regulator-vccq-sdhi1 {
 	};
 };
 
+&i2c0 {
+	status = "okay";
+
+	clock-frequency = <1000000>;
+};
+
 &pinctrl {
 	key-1-gpio-hog {
 		gpio-hog;
-- 
2.39.2


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

* [PATCH v4 11/11] arm64: dts: renesas: rzg3s-smarc-som: Enable i2c1 node
  2024-08-19 10:23 [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Claudiu
                   ` (9 preceding siblings ...)
  2024-08-19 10:23 ` [PATCH v4 10/11] arm64: dts: renesas: rzg3s-smarc: Enable i2c0 node Claudiu
@ 2024-08-19 10:23 ` Claudiu
  2024-08-19 20:23 ` [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Andi Shyti
  11 siblings, 0 replies; 26+ messages in thread
From: Claudiu @ 2024-08-19 10:23 UTC (permalink / raw)
  To: chris.brandt, andi.shyti, robh, krzk+dt, conor+dt, geert+renesas,
	magnus.damm, p.zabel, wsa+renesas
  Cc: linux-renesas-soc, linux-i2c, devicetree, linux-kernel,
	claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Enable i2c1 node.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---

Changes in v4:
- none

Changes in v3:
- none

Changes in v2:
- none

 arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi b/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi
index 8a3d302f1535..21bfa4e03972 100644
--- a/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi
+++ b/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi
@@ -32,6 +32,7 @@ / {
 	compatible = "renesas,rzg3s-smarcm", "renesas,r9a08g045s33", "renesas,r9a08g045";
 
 	aliases {
+		i2c1 = &i2c1;
 		mmc0 = &sdhi0;
 #if SW_CONFIG3 == SW_OFF
 		mmc2 = &sdhi2;
@@ -150,6 +151,10 @@ &extal_clk {
 	clock-frequency = <24000000>;
 };
 
+&i2c1 {
+	status = "okay";
+};
+
 #if SW_CONFIG2 == SW_ON
 /* SD0 slot */
 &sdhi0 {
-- 
2.39.2


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

* Re: [PATCH v4 07/11] dt-bindings: i2c: renesas,riic: Document the R9A08G045 support
  2024-08-19 10:23 ` [PATCH v4 07/11] dt-bindings: i2c: renesas,riic: Document the R9A08G045 support Claudiu
@ 2024-08-19 11:05   ` Krzysztof Kozlowski
  2024-08-19 11:10     ` claudiu beznea
  0 siblings, 1 reply; 26+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-19 11:05 UTC (permalink / raw)
  To: Claudiu
  Cc: chris.brandt, andi.shyti, robh, krzk+dt, conor+dt, geert+renesas,
	magnus.damm, p.zabel, wsa+renesas, linux-renesas-soc, linux-i2c,
	devicetree, linux-kernel, Claudiu Beznea

On Mon, Aug 19, 2024 at 01:23:44PM +0300, Claudiu wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> Document the Renesas RZ/G3S (R9A08G045) RIIC IP. This is compatible with
> the version available on Renesas RZ/V2H (R9A09G075).
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> ---
> 
> Changes in v4:
> - added comment near the fallback for RZ/G3S; because of this
>   dropped Conor's tag

That's not a reason to request a re-review.

Best regards,
Krzysztof


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

* Re: [PATCH v4 07/11] dt-bindings: i2c: renesas,riic: Document the R9A08G045 support
  2024-08-19 11:05   ` Krzysztof Kozlowski
@ 2024-08-19 11:10     ` claudiu beznea
  2024-08-19 11:22       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 26+ messages in thread
From: claudiu beznea @ 2024-08-19 11:10 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: chris.brandt, andi.shyti, robh, krzk+dt, conor+dt, geert+renesas,
	magnus.damm, p.zabel, wsa+renesas, linux-renesas-soc, linux-i2c,
	devicetree, linux-kernel, Claudiu Beznea



On 19.08.2024 14:05, Krzysztof Kozlowski wrote:
> On Mon, Aug 19, 2024 at 01:23:44PM +0300, Claudiu wrote:
>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>
>> Document the Renesas RZ/G3S (R9A08G045) RIIC IP. This is compatible with
>> the version available on Renesas RZ/V2H (R9A09G075).
>>
>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>> ---
>>
>> Changes in v4:
>> - added comment near the fallback for RZ/G3S; because of this
>>   dropped Conor's tag
> 
> That's not a reason to request a re-review.

Sorry for that, I wasn't aware of the procedure for this on bindings.

Thank you,
Claudiu Beznea

> 
> Best regards,
> Krzysztof
> 

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

* Re: [PATCH v4 07/11] dt-bindings: i2c: renesas,riic: Document the R9A08G045 support
  2024-08-19 11:10     ` claudiu beznea
@ 2024-08-19 11:22       ` Krzysztof Kozlowski
  2024-08-19 16:39         ` Conor Dooley
  0 siblings, 1 reply; 26+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-19 11:22 UTC (permalink / raw)
  To: claudiu beznea
  Cc: chris.brandt, andi.shyti, robh, krzk+dt, conor+dt, geert+renesas,
	magnus.damm, p.zabel, wsa+renesas, linux-renesas-soc, linux-i2c,
	devicetree, linux-kernel, Claudiu Beznea

On 19/08/2024 13:10, claudiu beznea wrote:
> 
> 
> On 19.08.2024 14:05, Krzysztof Kozlowski wrote:
>> On Mon, Aug 19, 2024 at 01:23:44PM +0300, Claudiu wrote:
>>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>>
>>> Document the Renesas RZ/G3S (R9A08G045) RIIC IP. This is compatible with
>>> the version available on Renesas RZ/V2H (R9A09G075).
>>>
>>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>> ---
>>>
>>> Changes in v4:
>>> - added comment near the fallback for RZ/G3S; because of this
>>>   dropped Conor's tag
>>
>> That's not a reason to request a re-review.
> 
> Sorry for that, I wasn't aware of the procedure for this on bindings.

There is no difference. Please read carefully submitting patches,
including the chapter about tags.

Best regards,
Krzysztof


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

* Re: [PATCH v4 07/11] dt-bindings: i2c: renesas,riic: Document the R9A08G045 support
  2024-08-19 11:22       ` Krzysztof Kozlowski
@ 2024-08-19 16:39         ` Conor Dooley
  2024-08-19 20:01           ` Andi Shyti
  2024-08-20  7:45           ` claudiu beznea
  0 siblings, 2 replies; 26+ messages in thread
From: Conor Dooley @ 2024-08-19 16:39 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: claudiu beznea, chris.brandt, andi.shyti, robh, krzk+dt, conor+dt,
	geert+renesas, magnus.damm, p.zabel, wsa+renesas,
	linux-renesas-soc, linux-i2c, devicetree, linux-kernel,
	Claudiu Beznea

[-- Attachment #1: Type: text/plain, Size: 1350 bytes --]

On Mon, Aug 19, 2024 at 01:22:39PM +0200, Krzysztof Kozlowski wrote:
> On 19/08/2024 13:10, claudiu beznea wrote:
> > 
> > 
> > On 19.08.2024 14:05, Krzysztof Kozlowski wrote:
> >> On Mon, Aug 19, 2024 at 01:23:44PM +0300, Claudiu wrote:
> >>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> >>>
> >>> Document the Renesas RZ/G3S (R9A08G045) RIIC IP. This is compatible with
> >>> the version available on Renesas RZ/V2H (R9A09G075).
> >>>
> >>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> >>> ---
> >>>
> >>> Changes in v4:
> >>> - added comment near the fallback for RZ/G3S; because of this
> >>>   dropped Conor's tag
> >>
> >> That's not a reason to request a re-review.

FWIW, I don't care about how many binding patches I do or do not get
credit for reviewing. Feel free to give a tag yourself Krzysztof in the
future if you come across these situations and I'll happily hit ctrl+d
and remove the thread from my mailbox rather than reply :)

> > 
> > Sorry for that, I wasn't aware of the procedure for this on bindings.
> 
> There is no difference. Please read carefully submitting patches,
> including the chapter about tags.

Yeah, I don't think this patch is materially different on those
grounds...

Acked-by: Conor Dooley <conor.dooley@microchip.com>

Cheers,
Conor.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH v4 05/11] i2c: riic: Add suspend/resume support
  2024-08-19 10:23 ` [PATCH v4 05/11] i2c: riic: Add suspend/resume support Claudiu
@ 2024-08-19 19:37   ` Andi Shyti
  2024-08-20  7:25     ` claudiu beznea
  0 siblings, 1 reply; 26+ messages in thread
From: Andi Shyti @ 2024-08-19 19:37 UTC (permalink / raw)
  To: Claudiu
  Cc: chris.brandt, robh, krzk+dt, conor+dt, geert+renesas, magnus.damm,
	p.zabel, wsa+renesas, linux-renesas-soc, linux-i2c, devicetree,
	linux-kernel, Claudiu Beznea

Hi Claudiu,

On Mon, Aug 19, 2024 at 01:23:42PM GMT, Claudiu wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> Add suspend/resume support for the RIIC driver. This is necessary for the
> Renesas RZ/G3S SoC which support suspend to deep sleep state where power
> to most of the SoC components is turned off. As a result the I2C controller
> needs to be reconfigured after suspend/resume. For this, the reset line
> was stored in the driver private data structure as well as i2c timings.
> The reset line and I2C timings are necessary to re-initialize the
> controller after resume.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

This patch doesn't have tags, so I'll add mine :-)

Reviewed-by: Andi Shyti <andi.shyti@kernel.org> 

Just one thing, though...

...

> +static int riic_i2c_resume(struct device *dev)
> +{
> +	struct riic_dev *riic = dev_get_drvdata(dev);
> +	int ret;
> +
> +	ret = reset_control_deassert(riic->rstc);
> +	if (ret)
> +		return ret;
> +
> +	ret = riic_init_hw(riic);
> +	if (ret) {
> +		reset_control_assert(riic->rstc);
> +		return ret;

Can I add a comment here saying:

	/*
	 * Since the driver remains loaded after resume,
	 * we want the reset line to be asserted.
	 */
	reset_control_assert(riic->rstc);

Unless I missed the point :-)

Thanks,
Andi

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

* Re: [PATCH v4 07/11] dt-bindings: i2c: renesas,riic: Document the R9A08G045 support
  2024-08-19 16:39         ` Conor Dooley
@ 2024-08-19 20:01           ` Andi Shyti
  2024-08-20  7:45           ` claudiu beznea
  1 sibling, 0 replies; 26+ messages in thread
From: Andi Shyti @ 2024-08-19 20:01 UTC (permalink / raw)
  To: Conor Dooley
  Cc: Krzysztof Kozlowski, claudiu beznea, chris.brandt, robh, krzk+dt,
	conor+dt, geert+renesas, magnus.damm, p.zabel, wsa+renesas,
	linux-renesas-soc, linux-i2c, devicetree, linux-kernel,
	Claudiu Beznea

Hi,

On Mon, Aug 19, 2024 at 05:39:35PM GMT, Conor Dooley wrote:
> On Mon, Aug 19, 2024 at 01:22:39PM +0200, Krzysztof Kozlowski wrote:
> > On 19/08/2024 13:10, claudiu beznea wrote:
> > > On 19.08.2024 14:05, Krzysztof Kozlowski wrote:
> > >> On Mon, Aug 19, 2024 at 01:23:44PM +0300, Claudiu wrote:
> > >>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> > >>>
> > >>> Document the Renesas RZ/G3S (R9A08G045) RIIC IP. This is compatible with
> > >>> the version available on Renesas RZ/V2H (R9A09G075).
> > >>>
> > >>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> > >>> ---
> > >>>
> > >>> Changes in v4:
> > >>> - added comment near the fallback for RZ/G3S; because of this
> > >>>   dropped Conor's tag
> > >>
> > >> That's not a reason to request a re-review.
> 
> FWIW, I don't care about how many binding patches I do or do not get
> credit for reviewing. Feel free to give a tag yourself Krzysztof in the
> future if you come across these situations and I'll happily hit ctrl+d
> and remove the thread from my mailbox rather than reply :)

I'm OK with third parties tags as long as the person is Cc'ed and
it happens in the mailing list.

It's not unusual and I check they really happened, anyway.

Thanks,
Andi

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

* Re: [PATCH v4 08/11] i2c: riic: Add support for fast mode plus
  2024-08-19 10:23 ` [PATCH v4 08/11] i2c: riic: Add support for fast mode plus Claudiu
@ 2024-08-19 20:12   ` Andi Shyti
  2024-08-20  7:32     ` claudiu beznea
  0 siblings, 1 reply; 26+ messages in thread
From: Andi Shyti @ 2024-08-19 20:12 UTC (permalink / raw)
  To: Claudiu
  Cc: chris.brandt, robh, krzk+dt, conor+dt, geert+renesas, magnus.damm,
	p.zabel, wsa+renesas, linux-renesas-soc, linux-i2c, devicetree,
	linux-kernel, Claudiu Beznea

Hi Claudiu,

...

>  struct riic_dev {
> @@ -311,11 +315,14 @@ static int riic_init_hw(struct riic_dev *riic)
>  	int total_ticks, cks, brl, brh;
>  	struct i2c_timings *t = &riic->i2c_t;
>  	struct device *dev = riic->adapter.dev.parent;
> +	const struct riic_of_data *info = riic->info;

Because you are only using info->fast_mode_plus, perhaps you can
directly take:

	fast_mode_plus = riic->info->fast_mode_plus;

and you make it even more compact.

>  
> -	if (t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ) {
> +	if ((!info->fast_mode_plus && t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ) ||
> +	    (info->fast_mode_plus && t->bus_freq_hz > I2C_MAX_FAST_MODE_PLUS_FREQ)) {
>  		dev_err(&riic->adapter.dev,
> -			"unsupported bus speed (%dHz). %d max\n",
> -			t->bus_freq_hz, I2C_MAX_FAST_MODE_FREQ);
> +			"unsupported bus speed (%dHz). %d max\n", t->bus_freq_hz,

super nitpick: can you please put t->bus_freq_hz on a new line,
it looks better to either have everything put in columns or not.

> +			info->fast_mode_plus ? I2C_MAX_FAST_MODE_PLUS_FREQ :
> +			I2C_MAX_FAST_MODE_FREQ);

another super-nitpick: can you please align
I2C_MAX_FAST_MODE_PLUS_FREQ with I2C_MAX_FAST_MODE_FREQ? It makes
more clear that there is a "? ... :" statement.

Thanks,
Andi

>  		return -EINVAL;
>  	}

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

* Re: [PATCH v4 06/11] i2c: riic: Define individual arrays to describe the register offsets
  2024-08-19 10:23 ` [PATCH v4 06/11] i2c: riic: Define individual arrays to describe the register offsets Claudiu
@ 2024-08-19 20:20   ` Andi Shyti
  0 siblings, 0 replies; 26+ messages in thread
From: Andi Shyti @ 2024-08-19 20:20 UTC (permalink / raw)
  To: Claudiu
  Cc: chris.brandt, robh, krzk+dt, conor+dt, geert+renesas, magnus.damm,
	p.zabel, wsa+renesas, linux-renesas-soc, linux-i2c, devicetree,
	linux-kernel, Claudiu Beznea

Geert,

do you have any comment here?

Thanks,
Andi

On Mon, Aug 19, 2024 at 01:23:43PM GMT, Claudiu wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> Define individual arrays to describe the register offsets. In this way
> we can describe different IP variants that share the same register offsets
> but have differences in other characteristics. Commit prepares for the
> addition of fast mode plus.
> 
> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> ---
> 
> Changes in v4:
> - collected tags
> 
> Changes in v3:
> - none
> 
> Changes in v2:
> - none
> 
>  drivers/i2c/busses/i2c-riic.c | 58 +++++++++++++++++++----------------
>  1 file changed, 31 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
> index f863b367fb85..cc2452853d19 100644
> --- a/drivers/i2c/busses/i2c-riic.c
> +++ b/drivers/i2c/busses/i2c-riic.c
> @@ -91,7 +91,7 @@ enum riic_reg_list {
>  };
>  
>  struct riic_of_data {
> -	u8 regs[RIIC_REG_END];
> +	const u8 *regs;
>  };
>  
>  struct riic_dev {
> @@ -522,36 +522,40 @@ static void riic_i2c_remove(struct platform_device *pdev)
>  	pm_runtime_dont_use_autosuspend(dev);
>  }
>  
> +static const u8 riic_rz_a_regs[RIIC_REG_END] = {
> +	[RIIC_ICCR1] = 0x00,
> +	[RIIC_ICCR2] = 0x04,
> +	[RIIC_ICMR1] = 0x08,
> +	[RIIC_ICMR3] = 0x10,
> +	[RIIC_ICSER] = 0x18,
> +	[RIIC_ICIER] = 0x1c,
> +	[RIIC_ICSR2] = 0x24,
> +	[RIIC_ICBRL] = 0x34,
> +	[RIIC_ICBRH] = 0x38,
> +	[RIIC_ICDRT] = 0x3c,
> +	[RIIC_ICDRR] = 0x40,
> +};
> +
>  static const struct riic_of_data riic_rz_a_info = {
> -	.regs = {
> -		[RIIC_ICCR1] = 0x00,
> -		[RIIC_ICCR2] = 0x04,
> -		[RIIC_ICMR1] = 0x08,
> -		[RIIC_ICMR3] = 0x10,
> -		[RIIC_ICSER] = 0x18,
> -		[RIIC_ICIER] = 0x1c,
> -		[RIIC_ICSR2] = 0x24,
> -		[RIIC_ICBRL] = 0x34,
> -		[RIIC_ICBRH] = 0x38,
> -		[RIIC_ICDRT] = 0x3c,
> -		[RIIC_ICDRR] = 0x40,
> -	},
> +	.regs = riic_rz_a_regs,
> +};
> +
> +static const u8 riic_rz_v2h_regs[RIIC_REG_END] = {
> +	[RIIC_ICCR1] = 0x00,
> +	[RIIC_ICCR2] = 0x01,
> +	[RIIC_ICMR1] = 0x02,
> +	[RIIC_ICMR3] = 0x04,
> +	[RIIC_ICSER] = 0x06,
> +	[RIIC_ICIER] = 0x07,
> +	[RIIC_ICSR2] = 0x09,
> +	[RIIC_ICBRL] = 0x10,
> +	[RIIC_ICBRH] = 0x11,
> +	[RIIC_ICDRT] = 0x12,
> +	[RIIC_ICDRR] = 0x13,
>  };
>  
>  static const struct riic_of_data riic_rz_v2h_info = {
> -	.regs = {
> -		[RIIC_ICCR1] = 0x00,
> -		[RIIC_ICCR2] = 0x01,
> -		[RIIC_ICMR1] = 0x02,
> -		[RIIC_ICMR3] = 0x04,
> -		[RIIC_ICSER] = 0x06,
> -		[RIIC_ICIER] = 0x07,
> -		[RIIC_ICSR2] = 0x09,
> -		[RIIC_ICBRL] = 0x10,
> -		[RIIC_ICBRH] = 0x11,
> -		[RIIC_ICDRT] = 0x12,
> -		[RIIC_ICDRR] = 0x13,
> -	},
> +	.regs = riic_rz_v2h_regs,
>  };
>  
>  static int riic_i2c_suspend(struct device *dev)
> -- 
> 2.39.2
> 

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

* Re: [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S
  2024-08-19 10:23 [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Claudiu
                   ` (10 preceding siblings ...)
  2024-08-19 10:23 ` [PATCH v4 11/11] arm64: dts: renesas: rzg3s-smarc-som: Enable i2c1 node Claudiu
@ 2024-08-19 20:23 ` Andi Shyti
  2024-08-20 10:16   ` claudiu beznea
  11 siblings, 1 reply; 26+ messages in thread
From: Andi Shyti @ 2024-08-19 20:23 UTC (permalink / raw)
  To: Claudiu
  Cc: chris.brandt, robh, krzk+dt, conor+dt, geert+renesas, magnus.damm,
	p.zabel, wsa+renesas, linux-renesas-soc, linux-i2c, devicetree,
	linux-kernel, Claudiu Beznea

Hi Claudiu,

> Claudiu Beznea (11):
>   i2c: riic: Use temporary variable for struct device
>   i2c: riic: Call pm_runtime_get_sync() when need to access registers
>   i2c: riic: Use pm_runtime_resume_and_get()
>   i2c: riic: Enable runtime PM autosuspend support
>   i2c: riic: Add suspend/resume support
>   i2c: riic: Define individual arrays to describe the register offsets
>   dt-bindings: i2c: renesas,riic: Document the R9A08G045 support

Looks good until here, do you want me to apply these first 7
patches to unburden you a bit?

Unless Geert has some notes on patch 6.

>   i2c: riic: Add support for fast mode plus

Small things here

>   arm64: dts: renesas: r9a08g045: Add I2C nodes
>   arm64: dts: renesas: rzg3s-smarc: Enable i2c0 node
>   arm64: dts: renesas: rzg3s-smarc-som: Enable i2c1 node

I'd like someone to ack here.

Thanks,
Andi

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

* Re: [PATCH v4 05/11] i2c: riic: Add suspend/resume support
  2024-08-19 19:37   ` Andi Shyti
@ 2024-08-20  7:25     ` claudiu beznea
  0 siblings, 0 replies; 26+ messages in thread
From: claudiu beznea @ 2024-08-20  7:25 UTC (permalink / raw)
  To: Andi Shyti
  Cc: chris.brandt, robh, krzk+dt, conor+dt, geert+renesas, magnus.damm,
	p.zabel, wsa+renesas, linux-renesas-soc, linux-i2c, devicetree,
	linux-kernel, Claudiu Beznea

Hi, Andi,

On 19.08.2024 22:37, Andi Shyti wrote:
> Hi Claudiu,
> 
> On Mon, Aug 19, 2024 at 01:23:42PM GMT, Claudiu wrote:
>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>
>> Add suspend/resume support for the RIIC driver. This is necessary for the
>> Renesas RZ/G3S SoC which support suspend to deep sleep state where power
>> to most of the SoC components is turned off. As a result the I2C controller
>> needs to be reconfigured after suspend/resume. For this, the reset line
>> was stored in the driver private data structure as well as i2c timings.
>> The reset line and I2C timings are necessary to re-initialize the
>> controller after resume.
>>
>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> This patch doesn't have tags, so I'll add mine :-)
> 
> Reviewed-by: Andi Shyti <andi.shyti@kernel.org> 
> 
> Just one thing, though...
> 
> ...
> 
>> +static int riic_i2c_resume(struct device *dev)
>> +{
>> +	struct riic_dev *riic = dev_get_drvdata(dev);
>> +	int ret;
>> +
>> +	ret = reset_control_deassert(riic->rstc);
>> +	if (ret)
>> +		return ret;
>> +
>> +	ret = riic_init_hw(riic);
>> +	if (ret) {
>> +		reset_control_assert(riic->rstc);
>> +		return ret;
> 
> Can I add a comment here saying:
> 
> 	/*
> 	 * Since the driver remains loaded after resume,
> 	 * we want the reset line to be asserted.
> 	 */

Sure, thank you!

> 	reset_control_assert(riic->rstc);
> 
> Unless I missed the point :-)
> 
> Thanks,
> Andi

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

* Re: [PATCH v4 08/11] i2c: riic: Add support for fast mode plus
  2024-08-19 20:12   ` Andi Shyti
@ 2024-08-20  7:32     ` claudiu beznea
  0 siblings, 0 replies; 26+ messages in thread
From: claudiu beznea @ 2024-08-20  7:32 UTC (permalink / raw)
  To: Andi Shyti
  Cc: chris.brandt, robh, krzk+dt, conor+dt, geert+renesas, magnus.damm,
	p.zabel, wsa+renesas, linux-renesas-soc, linux-i2c, devicetree,
	linux-kernel, Claudiu Beznea

Hi, Andi,

On 19.08.2024 23:12, Andi Shyti wrote:
> Hi Claudiu,
> 
> ...
> 
>>  struct riic_dev {
>> @@ -311,11 +315,14 @@ static int riic_init_hw(struct riic_dev *riic)
>>  	int total_ticks, cks, brl, brh;
>>  	struct i2c_timings *t = &riic->i2c_t;
>>  	struct device *dev = riic->adapter.dev.parent;
>> +	const struct riic_of_data *info = riic->info;
> 
> Because you are only using info->fast_mode_plus, perhaps you can
> directly take:
> 
> 	fast_mode_plus = riic->info->fast_mode_plus;
> 
> and you make it even more compact.
> 
>>  
>> -	if (t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ) {
>> +	if ((!info->fast_mode_plus && t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ) ||
>> +	    (info->fast_mode_plus && t->bus_freq_hz > I2C_MAX_FAST_MODE_PLUS_FREQ)) {
>>  		dev_err(&riic->adapter.dev,
>> -			"unsupported bus speed (%dHz). %d max\n",
>> -			t->bus_freq_hz, I2C_MAX_FAST_MODE_FREQ);
>> +			"unsupported bus speed (%dHz). %d max\n", t->bus_freq_hz,
> 
> super nitpick: can you please put t->bus_freq_hz on a new line,
> it looks better to either have everything put in columns or not.
> 
>> +			info->fast_mode_plus ? I2C_MAX_FAST_MODE_PLUS_FREQ :
>> +			I2C_MAX_FAST_MODE_FREQ);
> 
> another super-nitpick: can you please align
> I2C_MAX_FAST_MODE_PLUS_FREQ with I2C_MAX_FAST_MODE_FREQ? It makes
> more clear that there is a "? ... :" statement.

I'll adjust everything as suggested.

Thank you,
Claudiu Beznea

> 
> Thanks,
> Andi
> 
>>  		return -EINVAL;
>>  	}

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

* Re: [PATCH v4 07/11] dt-bindings: i2c: renesas,riic: Document the R9A08G045 support
  2024-08-19 16:39         ` Conor Dooley
  2024-08-19 20:01           ` Andi Shyti
@ 2024-08-20  7:45           ` claudiu beznea
  2024-08-20 16:44             ` Conor Dooley
  1 sibling, 1 reply; 26+ messages in thread
From: claudiu beznea @ 2024-08-20  7:45 UTC (permalink / raw)
  To: Conor Dooley, Krzysztof Kozlowski
  Cc: chris.brandt, andi.shyti, robh, krzk+dt, conor+dt, geert+renesas,
	magnus.damm, p.zabel, wsa+renesas, linux-renesas-soc, linux-i2c,
	devicetree, linux-kernel, Claudiu Beznea



On 19.08.2024 19:39, Conor Dooley wrote:
> On Mon, Aug 19, 2024 at 01:22:39PM +0200, Krzysztof Kozlowski wrote:
>> On 19/08/2024 13:10, claudiu beznea wrote:
>>>
>>>
>>> On 19.08.2024 14:05, Krzysztof Kozlowski wrote:
>>>> On Mon, Aug 19, 2024 at 01:23:44PM +0300, Claudiu wrote:
>>>>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>>>>
>>>>> Document the Renesas RZ/G3S (R9A08G045) RIIC IP. This is compatible with
>>>>> the version available on Renesas RZ/V2H (R9A09G075).
>>>>>
>>>>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>>>> ---
>>>>>
>>>>> Changes in v4:
>>>>> - added comment near the fallback for RZ/G3S; because of this
>>>>>   dropped Conor's tag
>>>>
>>>> That's not a reason to request a re-review.
> 
> FWIW, I don't care about how many binding patches I do or do not get
> credit for reviewing. 

I had no intention to drop your credit for reviewing this. In the past I
went though situations where reviewer complained due to keeping the tag and
doing very simple adjustment on the next version. I dropped your tag to
avoid that situation here too and mentioned it in the change log.

Thank you,
Claudiu Beznea



> Feel free to give a tag yourself Krzysztof in the
> future if you come across these situations and I'll happily hit ctrl+d
> and remove the thread from my mailbox rather than reply :)
> 
>>>
>>> Sorry for that, I wasn't aware of the procedure for this on bindings.
>>
>> There is no difference. Please read carefully submitting patches,
>> including the chapter about tags.
> 
> Yeah, I don't think this patch is materially different on those
> grounds...
> 
> Acked-by: Conor Dooley <conor.dooley@microchip.com>
> 
> Cheers,
> Conor.

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

* Re: [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S
  2024-08-19 20:23 ` [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Andi Shyti
@ 2024-08-20 10:16   ` claudiu beznea
  0 siblings, 0 replies; 26+ messages in thread
From: claudiu beznea @ 2024-08-20 10:16 UTC (permalink / raw)
  To: Andi Shyti
  Cc: chris.brandt, robh, krzk+dt, conor+dt, geert+renesas, magnus.damm,
	p.zabel, wsa+renesas, linux-renesas-soc, linux-i2c, devicetree,
	linux-kernel, Claudiu Beznea

Hi, Andi,

On 19.08.2024 23:23, Andi Shyti wrote:
> Hi Claudiu,
> 
>> Claudiu Beznea (11):
>>   i2c: riic: Use temporary variable for struct device
>>   i2c: riic: Call pm_runtime_get_sync() when need to access registers
>>   i2c: riic: Use pm_runtime_resume_and_get()
>>   i2c: riic: Enable runtime PM autosuspend support
>>   i2c: riic: Add suspend/resume support
>>   i2c: riic: Define individual arrays to describe the register offsets
>>   dt-bindings: i2c: renesas,riic: Document the R9A08G045 support
> 
> Looks good until here, do you want me to apply these first 7
> patches to unburden you a bit?

I already prepared the new set. I will send a new version containing
everything.

> 
> Unless Geert has some notes on patch 6.
> 
>>   i2c: riic: Add support for fast mode plus
> 
> Small things here
> 
>>   arm64: dts: renesas: r9a08g045: Add I2C nodes
>>   arm64: dts: renesas: rzg3s-smarc: Enable i2c0 node
>>   arm64: dts: renesas: rzg3s-smarc-som: Enable i2c1 node
> 
> I'd like someone to ack here.

Usually, these are picked by Geert.

Thank you,
Claudiu Beznea

> 
> Thanks,
> Andi

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

* Re: [PATCH v4 07/11] dt-bindings: i2c: renesas,riic: Document the R9A08G045 support
  2024-08-20  7:45           ` claudiu beznea
@ 2024-08-20 16:44             ` Conor Dooley
  0 siblings, 0 replies; 26+ messages in thread
From: Conor Dooley @ 2024-08-20 16:44 UTC (permalink / raw)
  To: claudiu beznea
  Cc: Krzysztof Kozlowski, chris.brandt, andi.shyti, robh, krzk+dt,
	conor+dt, geert+renesas, magnus.damm, p.zabel, wsa+renesas,
	linux-renesas-soc, linux-i2c, devicetree, linux-kernel,
	Claudiu Beznea

[-- Attachment #1: Type: text/plain, Size: 1511 bytes --]

On Tue, Aug 20, 2024 at 10:45:43AM +0300, claudiu beznea wrote:
> 
> 
> On 19.08.2024 19:39, Conor Dooley wrote:
> > On Mon, Aug 19, 2024 at 01:22:39PM +0200, Krzysztof Kozlowski wrote:
> >> On 19/08/2024 13:10, claudiu beznea wrote:
> >>>
> >>>
> >>> On 19.08.2024 14:05, Krzysztof Kozlowski wrote:
> >>>> On Mon, Aug 19, 2024 at 01:23:44PM +0300, Claudiu wrote:
> >>>>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> >>>>>
> >>>>> Document the Renesas RZ/G3S (R9A08G045) RIIC IP. This is compatible with
> >>>>> the version available on Renesas RZ/V2H (R9A09G075).
> >>>>>
> >>>>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> >>>>> ---
> >>>>>
> >>>>> Changes in v4:
> >>>>> - added comment near the fallback for RZ/G3S; because of this
> >>>>>   dropped Conor's tag
> >>>>
> >>>> That's not a reason to request a re-review.
> > 
> > FWIW, I don't care about how many binding patches I do or do not get
> > credit for reviewing. 
> 
> I had no intention to drop your credit for reviewing this. In the past I

That comment was meant for Krzysztof, so that he wouldn't feel like he
should avoid acking so that I could re-ack in similar situations in the
future.

> went though situations where reviewer complained due to keeping the tag and
> doing very simple adjustment on the next version. I dropped your tag to
> avoid that situation here too and mentioned it in the change log.

Ye, I did note that you'd not dropped it confusingly :)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

end of thread, other threads:[~2024-08-20 16:45 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-19 10:23 [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Claudiu
2024-08-19 10:23 ` [PATCH v4 01/11] i2c: riic: Use temporary variable for struct device Claudiu
2024-08-19 10:23 ` [PATCH v4 02/11] i2c: riic: Call pm_runtime_get_sync() when need to access registers Claudiu
2024-08-19 10:23 ` [PATCH v4 03/11] i2c: riic: Use pm_runtime_resume_and_get() Claudiu
2024-08-19 10:23 ` [PATCH v4 04/11] i2c: riic: Enable runtime PM autosuspend support Claudiu
2024-08-19 10:23 ` [PATCH v4 05/11] i2c: riic: Add suspend/resume support Claudiu
2024-08-19 19:37   ` Andi Shyti
2024-08-20  7:25     ` claudiu beznea
2024-08-19 10:23 ` [PATCH v4 06/11] i2c: riic: Define individual arrays to describe the register offsets Claudiu
2024-08-19 20:20   ` Andi Shyti
2024-08-19 10:23 ` [PATCH v4 07/11] dt-bindings: i2c: renesas,riic: Document the R9A08G045 support Claudiu
2024-08-19 11:05   ` Krzysztof Kozlowski
2024-08-19 11:10     ` claudiu beznea
2024-08-19 11:22       ` Krzysztof Kozlowski
2024-08-19 16:39         ` Conor Dooley
2024-08-19 20:01           ` Andi Shyti
2024-08-20  7:45           ` claudiu beznea
2024-08-20 16:44             ` Conor Dooley
2024-08-19 10:23 ` [PATCH v4 08/11] i2c: riic: Add support for fast mode plus Claudiu
2024-08-19 20:12   ` Andi Shyti
2024-08-20  7:32     ` claudiu beznea
2024-08-19 10:23 ` [PATCH v4 09/11] arm64: dts: renesas: r9a08g045: Add I2C nodes Claudiu
2024-08-19 10:23 ` [PATCH v4 10/11] arm64: dts: renesas: rzg3s-smarc: Enable i2c0 node Claudiu
2024-08-19 10:23 ` [PATCH v4 11/11] arm64: dts: renesas: rzg3s-smarc-som: Enable i2c1 node Claudiu
2024-08-19 20:23 ` [PATCH v4 00/11] i2c: riic: Add support for Renesas RZ/G3S Andi Shyti
2024-08-20 10:16   ` claudiu beznea

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).