linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] i2c: stm32: filter binding support & debug info
@ 2021-02-05  8:51 Alain Volmat
  2021-02-05  8:51 ` [PATCH 1/5] i2c: stm32f7: fix configuration of the digital filter Alain Volmat
                   ` (5 more replies)
  0 siblings, 6 replies; 20+ messages in thread
From: Alain Volmat @ 2021-02-05  8:51 UTC (permalink / raw)
  To: wsa, robh+dt
  Cc: mark.rutland, pierre-yves.mordret, mcoquelin.stm32,
	alexandre.torgue, linux-i2c, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, fabrice.gasnier, alain.volmat

This serie add support for the analog and digital filter binding
for the stm32f7 i2c driver.
An additional patch add also debug informations, displayed in case
of errors.

Alain Volmat (5):
  i2c: stm32f7: fix configuration of the digital filter
  i2c: stm32f7: support DT binding i2c-analog-filter
  i2c: stm32f7: add support for DNF i2c-digital-filter binding
  ARM: dts: stm32: enable the analog filter for all I2C nodes in
    stm32mp151
  i2c: stm32f7: indicate the address being accessed on errors

 arch/arm/boot/dts/stm32mp151.dtsi |  6 +++
 drivers/i2c/busses/i2c-stm32f7.c  | 63 ++++++++++++++++++++-----------
 2 files changed, 46 insertions(+), 23 deletions(-)

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

* [PATCH 1/5] i2c: stm32f7: fix configuration of the digital filter
  2021-02-05  8:51 [PATCH 0/5] i2c: stm32: filter binding support & debug info Alain Volmat
@ 2021-02-05  8:51 ` Alain Volmat
  2021-02-05 14:58   ` Pierre Yves MORDRET
  2021-02-12 10:36   ` Wolfram Sang
  2021-02-05  8:51 ` [PATCH 2/5] i2c: stm32f7: support DT binding i2c-analog-filter Alain Volmat
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 20+ messages in thread
From: Alain Volmat @ 2021-02-05  8:51 UTC (permalink / raw)
  To: wsa, robh+dt
  Cc: mark.rutland, pierre-yves.mordret, mcoquelin.stm32,
	alexandre.torgue, linux-i2c, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, fabrice.gasnier, alain.volmat

The digital filter related computation are present in the driver
however the programming of the filter within the IP is missing.
The maximum value for the DNF is wrong and should be 15 instead of 16.

Fixes: aeb068c57214 ("i2c: i2c-stm32f7: add driver")

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
 drivers/i2c/busses/i2c-stm32f7.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
index 9aa8e65b511e..473fbe144b7e 100644
--- a/drivers/i2c/busses/i2c-stm32f7.c
+++ b/drivers/i2c/busses/i2c-stm32f7.c
@@ -57,6 +57,8 @@
 #define STM32F7_I2C_CR1_RXDMAEN			BIT(15)
 #define STM32F7_I2C_CR1_TXDMAEN			BIT(14)
 #define STM32F7_I2C_CR1_ANFOFF			BIT(12)
+#define STM32F7_I2C_CR1_DNF_MASK		GENMASK(11, 8)
+#define STM32F7_I2C_CR1_DNF(n)			(((n) & 0xf) << 8)
 #define STM32F7_I2C_CR1_ERRIE			BIT(7)
 #define STM32F7_I2C_CR1_TCIE			BIT(6)
 #define STM32F7_I2C_CR1_STOPIE			BIT(5)
@@ -160,7 +162,7 @@ enum {
 };
 
 #define STM32F7_I2C_DNF_DEFAULT			0
-#define STM32F7_I2C_DNF_MAX			16
+#define STM32F7_I2C_DNF_MAX			15
 
 #define STM32F7_I2C_ANALOG_FILTER_ENABLE	1
 #define STM32F7_I2C_ANALOG_FILTER_DELAY_MIN	50	/* ns */
@@ -725,6 +727,13 @@ static void stm32f7_i2c_hw_config(struct stm32f7_i2c_dev *i2c_dev)
 	else
 		stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
 				     STM32F7_I2C_CR1_ANFOFF);
+
+	/* Program the Digital Filter */
+	stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1,
+			     STM32F7_I2C_CR1_DNF_MASK);
+	stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
+			     STM32F7_I2C_CR1_DNF(i2c_dev->setup.dnf));
+
 	stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
 			     STM32F7_I2C_CR1_PE);
 }
-- 
2.17.1


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

* [PATCH 2/5] i2c: stm32f7: support DT binding i2c-analog-filter
  2021-02-05  8:51 [PATCH 0/5] i2c: stm32: filter binding support & debug info Alain Volmat
  2021-02-05  8:51 ` [PATCH 1/5] i2c: stm32f7: fix configuration of the digital filter Alain Volmat
@ 2021-02-05  8:51 ` Alain Volmat
  2021-02-05 14:58   ` Pierre Yves MORDRET
  2021-03-18 10:54   ` Wolfram Sang
  2021-02-05  8:51 ` [PATCH 3/5] i2c: stm32f7: add support for DNF i2c-digital-filter binding Alain Volmat
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 20+ messages in thread
From: Alain Volmat @ 2021-02-05  8:51 UTC (permalink / raw)
  To: wsa, robh+dt
  Cc: mark.rutland, pierre-yves.mordret, mcoquelin.stm32,
	alexandre.torgue, linux-i2c, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, fabrice.gasnier, alain.volmat

Replace driver internally coded enabling/disabling of the
analog-filter with the DT binding "i2c-analog-filter".

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
 drivers/i2c/busses/i2c-stm32f7.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
index 473fbe144b7e..0c539fea2754 100644
--- a/drivers/i2c/busses/i2c-stm32f7.c
+++ b/drivers/i2c/busses/i2c-stm32f7.c
@@ -164,7 +164,6 @@ enum {
 #define STM32F7_I2C_DNF_DEFAULT			0
 #define STM32F7_I2C_DNF_MAX			15
 
-#define STM32F7_I2C_ANALOG_FILTER_ENABLE	1
 #define STM32F7_I2C_ANALOG_FILTER_DELAY_MIN	50	/* ns */
 #define STM32F7_I2C_ANALOG_FILTER_DELAY_MAX	260	/* ns */
 
@@ -224,7 +223,6 @@ struct stm32f7_i2c_spec {
  * @rise_time: Rise time (ns)
  * @fall_time: Fall time (ns)
  * @dnf: Digital filter coefficient (0-16)
- * @analog_filter: Analog filter delay (On/Off)
  * @fmp_clr_offset: Fast Mode Plus clear register offset from set register
  */
 struct stm32f7_i2c_setup {
@@ -233,7 +231,6 @@ struct stm32f7_i2c_setup {
 	u32 rise_time;
 	u32 fall_time;
 	u8 dnf;
-	bool analog_filter;
 	u32 fmp_clr_offset;
 };
 
@@ -312,6 +309,7 @@ struct stm32f7_i2c_msg {
  * @wakeup_src: boolean to know if the device is a wakeup source
  * @smbus_mode: states that the controller is configured in SMBus mode
  * @host_notify_client: SMBus host-notify client
+ * @analog_filter: boolean to indicate enabling of the analog filter
  */
 struct stm32f7_i2c_dev {
 	struct i2c_adapter adap;
@@ -340,6 +338,7 @@ struct stm32f7_i2c_dev {
 	bool wakeup_src;
 	bool smbus_mode;
 	struct i2c_client *host_notify_client;
+	bool analog_filter;
 };
 
 /*
@@ -386,14 +385,12 @@ static const struct stm32f7_i2c_setup stm32f7_setup = {
 	.rise_time = STM32F7_I2C_RISE_TIME_DEFAULT,
 	.fall_time = STM32F7_I2C_FALL_TIME_DEFAULT,
 	.dnf = STM32F7_I2C_DNF_DEFAULT,
-	.analog_filter = STM32F7_I2C_ANALOG_FILTER_ENABLE,
 };
 
 static const struct stm32f7_i2c_setup stm32mp15_setup = {
 	.rise_time = STM32F7_I2C_RISE_TIME_DEFAULT,
 	.fall_time = STM32F7_I2C_FALL_TIME_DEFAULT,
 	.dnf = STM32F7_I2C_DNF_DEFAULT,
-	.analog_filter = STM32F7_I2C_ANALOG_FILTER_ENABLE,
 	.fmp_clr_offset = 0x40,
 };
 
@@ -471,10 +468,10 @@ static int stm32f7_i2c_compute_timing(struct stm32f7_i2c_dev *i2c_dev,
 
 	/*  Analog and Digital Filters */
 	af_delay_min =
-		(setup->analog_filter ?
+		(i2c_dev->analog_filter ?
 		 STM32F7_I2C_ANALOG_FILTER_DELAY_MIN : 0);
 	af_delay_max =
-		(setup->analog_filter ?
+		(i2c_dev->analog_filter ?
 		 STM32F7_I2C_ANALOG_FILTER_DELAY_MAX : 0);
 	dnf_delay = setup->dnf * i2cclk;
 
@@ -676,12 +673,15 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev,
 		return ret;
 	}
 
+	i2c_dev->analog_filter = of_property_read_bool(i2c_dev->dev->of_node,
+						       "i2c-analog-filter");
+
 	dev_dbg(i2c_dev->dev, "I2C Speed(%i), Clk Source(%i)\n",
 		setup->speed_freq, setup->clock_src);
 	dev_dbg(i2c_dev->dev, "I2C Rise(%i) and Fall(%i) Time\n",
 		setup->rise_time, setup->fall_time);
 	dev_dbg(i2c_dev->dev, "I2C Analog Filter(%s), DNF(%i)\n",
-		(setup->analog_filter ? "On" : "Off"), setup->dnf);
+		(i2c_dev->analog_filter ? "On" : "Off"), setup->dnf);
 
 	i2c_dev->bus_rate = setup->speed_freq;
 
@@ -720,8 +720,8 @@ static void stm32f7_i2c_hw_config(struct stm32f7_i2c_dev *i2c_dev)
 	timing |= STM32F7_I2C_TIMINGR_SCLL(t->scll);
 	writel_relaxed(timing, i2c_dev->base + STM32F7_I2C_TIMINGR);
 
-	/* Enable I2C */
-	if (i2c_dev->setup.analog_filter)
+	/* Configure the Analog Filter */
+	if (i2c_dev->analog_filter)
 		stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1,
 				     STM32F7_I2C_CR1_ANFOFF);
 	else
-- 
2.17.1


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

* [PATCH 3/5] i2c: stm32f7: add support for DNF i2c-digital-filter binding
  2021-02-05  8:51 [PATCH 0/5] i2c: stm32: filter binding support & debug info Alain Volmat
  2021-02-05  8:51 ` [PATCH 1/5] i2c: stm32f7: fix configuration of the digital filter Alain Volmat
  2021-02-05  8:51 ` [PATCH 2/5] i2c: stm32f7: support DT binding i2c-analog-filter Alain Volmat
@ 2021-02-05  8:51 ` Alain Volmat
  2021-02-05 14:59   ` Pierre Yves MORDRET
  2021-03-18 10:54   ` Wolfram Sang
  2021-02-05  8:51 ` [PATCH 4/5] ARM: dts: stm32: enable the analog filter for all I2C nodes in stm32mp151 Alain Volmat
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 20+ messages in thread
From: Alain Volmat @ 2021-02-05  8:51 UTC (permalink / raw)
  To: wsa, robh+dt
  Cc: mark.rutland, pierre-yves.mordret, mcoquelin.stm32,
	alexandre.torgue, linux-i2c, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, fabrice.gasnier, alain.volmat

Add the support for the i2c-digital-filter binding, allowing to enable
the digital filter via the device-tree and indicate its value in the DT.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
 drivers/i2c/busses/i2c-stm32f7.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
index 0c539fea2754..f77cd6512a86 100644
--- a/drivers/i2c/busses/i2c-stm32f7.c
+++ b/drivers/i2c/busses/i2c-stm32f7.c
@@ -222,7 +222,6 @@ struct stm32f7_i2c_spec {
  * @clock_src: I2C clock source frequency (Hz)
  * @rise_time: Rise time (ns)
  * @fall_time: Fall time (ns)
- * @dnf: Digital filter coefficient (0-16)
  * @fmp_clr_offset: Fast Mode Plus clear register offset from set register
  */
 struct stm32f7_i2c_setup {
@@ -230,7 +229,6 @@ struct stm32f7_i2c_setup {
 	u32 clock_src;
 	u32 rise_time;
 	u32 fall_time;
-	u8 dnf;
 	u32 fmp_clr_offset;
 };
 
@@ -310,6 +308,8 @@ struct stm32f7_i2c_msg {
  * @smbus_mode: states that the controller is configured in SMBus mode
  * @host_notify_client: SMBus host-notify client
  * @analog_filter: boolean to indicate enabling of the analog filter
+ * @dnf_dt: value of digital filter requested via dt
+ * @dnf: value of digital filter to apply
  */
 struct stm32f7_i2c_dev {
 	struct i2c_adapter adap;
@@ -339,6 +339,8 @@ struct stm32f7_i2c_dev {
 	bool smbus_mode;
 	struct i2c_client *host_notify_client;
 	bool analog_filter;
+	u32 dnf_dt;
+	u32 dnf;
 };
 
 /*
@@ -384,13 +386,11 @@ static struct stm32f7_i2c_spec stm32f7_i2c_specs[] = {
 static const struct stm32f7_i2c_setup stm32f7_setup = {
 	.rise_time = STM32F7_I2C_RISE_TIME_DEFAULT,
 	.fall_time = STM32F7_I2C_FALL_TIME_DEFAULT,
-	.dnf = STM32F7_I2C_DNF_DEFAULT,
 };
 
 static const struct stm32f7_i2c_setup stm32mp15_setup = {
 	.rise_time = STM32F7_I2C_RISE_TIME_DEFAULT,
 	.fall_time = STM32F7_I2C_FALL_TIME_DEFAULT,
-	.dnf = STM32F7_I2C_DNF_DEFAULT,
 	.fmp_clr_offset = 0x40,
 };
 
@@ -459,10 +459,11 @@ static int stm32f7_i2c_compute_timing(struct stm32f7_i2c_dev *i2c_dev,
 		return -EINVAL;
 	}
 
-	if (setup->dnf > STM32F7_I2C_DNF_MAX) {
+	i2c_dev->dnf = DIV_ROUND_CLOSEST(i2c_dev->dnf_dt, i2cclk);
+	if (i2c_dev->dnf > STM32F7_I2C_DNF_MAX) {
 		dev_err(i2c_dev->dev,
 			"DNF out of bound %d/%d\n",
-			setup->dnf, STM32F7_I2C_DNF_MAX);
+			i2c_dev->dnf * i2cclk, STM32F7_I2C_DNF_MAX * i2cclk);
 		return -EINVAL;
 	}
 
@@ -473,13 +474,13 @@ static int stm32f7_i2c_compute_timing(struct stm32f7_i2c_dev *i2c_dev,
 	af_delay_max =
 		(i2c_dev->analog_filter ?
 		 STM32F7_I2C_ANALOG_FILTER_DELAY_MAX : 0);
-	dnf_delay = setup->dnf * i2cclk;
+	dnf_delay = i2c_dev->dnf * i2cclk;
 
 	sdadel_min = specs->hddat_min + setup->fall_time -
-		af_delay_min - (setup->dnf + 3) * i2cclk;
+		af_delay_min - (i2c_dev->dnf + 3) * i2cclk;
 
 	sdadel_max = specs->vddat_max - setup->rise_time -
-		af_delay_max - (setup->dnf + 4) * i2cclk;
+		af_delay_max - (i2c_dev->dnf + 4) * i2cclk;
 
 	scldel_min = setup->rise_time + specs->sudat_min;
 
@@ -645,6 +646,7 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev,
 	setup->speed_freq = t->bus_freq_hz;
 	i2c_dev->setup.rise_time = t->scl_rise_ns;
 	i2c_dev->setup.fall_time = t->scl_fall_ns;
+	i2c_dev->dnf_dt = t->digital_filter_width_ns;
 	setup->clock_src = clk_get_rate(i2c_dev->clk);
 
 	if (!setup->clock_src) {
@@ -652,6 +654,9 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev,
 		return -EINVAL;
 	}
 
+	if (!of_property_read_bool(i2c_dev->dev->of_node, "i2c-digital-filter"))
+		i2c_dev->dnf_dt = STM32F7_I2C_DNF_DEFAULT;
+
 	do {
 		ret = stm32f7_i2c_compute_timing(i2c_dev, setup,
 						 &i2c_dev->timing);
@@ -681,7 +686,7 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev,
 	dev_dbg(i2c_dev->dev, "I2C Rise(%i) and Fall(%i) Time\n",
 		setup->rise_time, setup->fall_time);
 	dev_dbg(i2c_dev->dev, "I2C Analog Filter(%s), DNF(%i)\n",
-		(i2c_dev->analog_filter ? "On" : "Off"), setup->dnf);
+		(i2c_dev->analog_filter ? "On" : "Off"), i2c_dev->dnf);
 
 	i2c_dev->bus_rate = setup->speed_freq;
 
@@ -732,7 +737,7 @@ static void stm32f7_i2c_hw_config(struct stm32f7_i2c_dev *i2c_dev)
 	stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1,
 			     STM32F7_I2C_CR1_DNF_MASK);
 	stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
-			     STM32F7_I2C_CR1_DNF(i2c_dev->setup.dnf));
+			     STM32F7_I2C_CR1_DNF(i2c_dev->dnf));
 
 	stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
 			     STM32F7_I2C_CR1_PE);
-- 
2.17.1


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

* [PATCH 4/5] ARM: dts: stm32: enable the analog filter for all I2C nodes in stm32mp151
  2021-02-05  8:51 [PATCH 0/5] i2c: stm32: filter binding support & debug info Alain Volmat
                   ` (2 preceding siblings ...)
  2021-02-05  8:51 ` [PATCH 3/5] i2c: stm32f7: add support for DNF i2c-digital-filter binding Alain Volmat
@ 2021-02-05  8:51 ` Alain Volmat
  2021-02-10  8:39   ` Pierre Yves MORDRET
  2021-03-18 10:55   ` Wolfram Sang
  2021-02-05  8:51 ` [PATCH 5/5] i2c: stm32f7: indicate the address being accessed on errors Alain Volmat
  2021-02-05 14:57 ` [PATCH 0/5] i2c: stm32: filter binding support & debug info Pierre Yves MORDRET
  5 siblings, 2 replies; 20+ messages in thread
From: Alain Volmat @ 2021-02-05  8:51 UTC (permalink / raw)
  To: wsa, robh+dt
  Cc: mark.rutland, pierre-yves.mordret, mcoquelin.stm32,
	alexandre.torgue, linux-i2c, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, fabrice.gasnier, alain.volmat

Enable the analog filter for all I2C nodes of the stm32mp151.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
 arch/arm/boot/dts/stm32mp151.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/stm32mp151.dtsi b/arch/arm/boot/dts/stm32mp151.dtsi
index 3c75abacb374..558fc8fb38b6 100644
--- a/arch/arm/boot/dts/stm32mp151.dtsi
+++ b/arch/arm/boot/dts/stm32mp151.dtsi
@@ -493,6 +493,7 @@
 			#size-cells = <0>;
 			st,syscfg-fmp = <&syscfg 0x4 0x1>;
 			wakeup-source;
+			i2c-analog-filter;
 			status = "disabled";
 		};
 
@@ -508,6 +509,7 @@
 			#size-cells = <0>;
 			st,syscfg-fmp = <&syscfg 0x4 0x2>;
 			wakeup-source;
+			i2c-analog-filter;
 			status = "disabled";
 		};
 
@@ -523,6 +525,7 @@
 			#size-cells = <0>;
 			st,syscfg-fmp = <&syscfg 0x4 0x4>;
 			wakeup-source;
+			i2c-analog-filter;
 			status = "disabled";
 		};
 
@@ -538,6 +541,7 @@
 			#size-cells = <0>;
 			st,syscfg-fmp = <&syscfg 0x4 0x10>;
 			wakeup-source;
+			i2c-analog-filter;
 			status = "disabled";
 		};
 
@@ -1533,6 +1537,7 @@
 			#size-cells = <0>;
 			st,syscfg-fmp = <&syscfg 0x4 0x8>;
 			wakeup-source;
+			i2c-analog-filter;
 			status = "disabled";
 		};
 
@@ -1570,6 +1575,7 @@
 			#size-cells = <0>;
 			st,syscfg-fmp = <&syscfg 0x4 0x20>;
 			wakeup-source;
+			i2c-analog-filter;
 			status = "disabled";
 		};
 
-- 
2.17.1


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

* [PATCH 5/5] i2c: stm32f7: indicate the address being accessed on errors
  2021-02-05  8:51 [PATCH 0/5] i2c: stm32: filter binding support & debug info Alain Volmat
                   ` (3 preceding siblings ...)
  2021-02-05  8:51 ` [PATCH 4/5] ARM: dts: stm32: enable the analog filter for all I2C nodes in stm32mp151 Alain Volmat
@ 2021-02-05  8:51 ` Alain Volmat
  2021-02-05 14:59   ` Pierre Yves MORDRET
  2021-03-18 10:58   ` Wolfram Sang
  2021-02-05 14:57 ` [PATCH 0/5] i2c: stm32: filter binding support & debug info Pierre Yves MORDRET
  5 siblings, 2 replies; 20+ messages in thread
From: Alain Volmat @ 2021-02-05  8:51 UTC (permalink / raw)
  To: wsa, robh+dt
  Cc: mark.rutland, pierre-yves.mordret, mcoquelin.stm32,
	alexandre.torgue, linux-i2c, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, fabrice.gasnier, alain.volmat

To help debugging issues, add the address of the slave being
accessed when getting an error.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
 drivers/i2c/busses/i2c-stm32f7.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
index f77cd6512a86..ef642fe1eb2c 100644
--- a/drivers/i2c/busses/i2c-stm32f7.c
+++ b/drivers/i2c/busses/i2c-stm32f7.c
@@ -1602,7 +1602,8 @@ static irqreturn_t stm32f7_i2c_isr_error(int irq, void *data)
 
 	/* Bus error */
 	if (status & STM32F7_I2C_ISR_BERR) {
-		dev_err(dev, "<%s>: Bus error\n", __func__);
+		dev_err(dev, "<%s>: Bus error accessing addr 0x%x\n",
+			__func__, f7_msg->addr);
 		writel_relaxed(STM32F7_I2C_ICR_BERRCF, base + STM32F7_I2C_ICR);
 		stm32f7_i2c_release_bus(&i2c_dev->adap);
 		f7_msg->result = -EIO;
@@ -1610,13 +1611,15 @@ static irqreturn_t stm32f7_i2c_isr_error(int irq, void *data)
 
 	/* Arbitration loss */
 	if (status & STM32F7_I2C_ISR_ARLO) {
-		dev_dbg(dev, "<%s>: Arbitration loss\n", __func__);
+		dev_dbg(dev, "<%s>: Arbitration loss accessing addr 0x%x\n",
+			__func__, f7_msg->addr);
 		writel_relaxed(STM32F7_I2C_ICR_ARLOCF, base + STM32F7_I2C_ICR);
 		f7_msg->result = -EAGAIN;
 	}
 
 	if (status & STM32F7_I2C_ISR_PECERR) {
-		dev_err(dev, "<%s>: PEC error in reception\n", __func__);
+		dev_err(dev, "<%s>: PEC error in reception accessing addr 0x%x\n",
+			__func__, f7_msg->addr);
 		writel_relaxed(STM32F7_I2C_ICR_PECCF, base + STM32F7_I2C_ICR);
 		f7_msg->result = -EINVAL;
 	}
-- 
2.17.1


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

* Re: [PATCH 0/5] i2c: stm32: filter binding support & debug info
  2021-02-05  8:51 [PATCH 0/5] i2c: stm32: filter binding support & debug info Alain Volmat
                   ` (4 preceding siblings ...)
  2021-02-05  8:51 ` [PATCH 5/5] i2c: stm32f7: indicate the address being accessed on errors Alain Volmat
@ 2021-02-05 14:57 ` Pierre Yves MORDRET
  5 siblings, 0 replies; 20+ messages in thread
From: Pierre Yves MORDRET @ 2021-02-05 14:57 UTC (permalink / raw)
  To: Alain Volmat, wsa, robh+dt
  Cc: mark.rutland, mcoquelin.stm32, alexandre.torgue, linux-i2c,
	devicetree, linux-stm32, linux-arm-kernel, linux-kernel,
	fabrice.gasnier

Hello all

Looks good to me

Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>

Regards
On 2/5/21 9:51 AM, Alain Volmat wrote:
> This serie add support for the analog and digital filter binding
> for the stm32f7 i2c driver.
> An additional patch add also debug informations, displayed in case
> of errors.
> 
> Alain Volmat (5):
>   i2c: stm32f7: fix configuration of the digital filter
>   i2c: stm32f7: support DT binding i2c-analog-filter
>   i2c: stm32f7: add support for DNF i2c-digital-filter binding
>   ARM: dts: stm32: enable the analog filter for all I2C nodes in
>     stm32mp151
>   i2c: stm32f7: indicate the address being accessed on errors
> 
>  arch/arm/boot/dts/stm32mp151.dtsi |  6 +++
>  drivers/i2c/busses/i2c-stm32f7.c  | 63 ++++++++++++++++++++-----------
>  2 files changed, 46 insertions(+), 23 deletions(-)
> 

-- 
--
~ Py MORDRET
--

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

* Re: [PATCH 1/5] i2c: stm32f7: fix configuration of the digital filter
  2021-02-05  8:51 ` [PATCH 1/5] i2c: stm32f7: fix configuration of the digital filter Alain Volmat
@ 2021-02-05 14:58   ` Pierre Yves MORDRET
  2021-02-12 10:36   ` Wolfram Sang
  1 sibling, 0 replies; 20+ messages in thread
From: Pierre Yves MORDRET @ 2021-02-05 14:58 UTC (permalink / raw)
  To: Alain Volmat, wsa, robh+dt
  Cc: mark.rutland, mcoquelin.stm32, alexandre.torgue, linux-i2c,
	devicetree, linux-stm32, linux-arm-kernel, linux-kernel,
	fabrice.gasnier

Hello all

Looks good to me

Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>

Regards

On 2/5/21 9:51 AM, Alain Volmat wrote:
> The digital filter related computation are present in the driver
> however the programming of the filter within the IP is missing.
> The maximum value for the DNF is wrong and should be 15 instead of 16.
> 
> Fixes: aeb068c57214 ("i2c: i2c-stm32f7: add driver")
> 
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
> ---
>  drivers/i2c/busses/i2c-stm32f7.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> index 9aa8e65b511e..473fbe144b7e 100644
> --- a/drivers/i2c/busses/i2c-stm32f7.c
> +++ b/drivers/i2c/busses/i2c-stm32f7.c
> @@ -57,6 +57,8 @@
>  #define STM32F7_I2C_CR1_RXDMAEN			BIT(15)
>  #define STM32F7_I2C_CR1_TXDMAEN			BIT(14)
>  #define STM32F7_I2C_CR1_ANFOFF			BIT(12)
> +#define STM32F7_I2C_CR1_DNF_MASK		GENMASK(11, 8)
> +#define STM32F7_I2C_CR1_DNF(n)			(((n) & 0xf) << 8)
>  #define STM32F7_I2C_CR1_ERRIE			BIT(7)
>  #define STM32F7_I2C_CR1_TCIE			BIT(6)
>  #define STM32F7_I2C_CR1_STOPIE			BIT(5)
> @@ -160,7 +162,7 @@ enum {
>  };
>  
>  #define STM32F7_I2C_DNF_DEFAULT			0
> -#define STM32F7_I2C_DNF_MAX			16
> +#define STM32F7_I2C_DNF_MAX			15
>  
>  #define STM32F7_I2C_ANALOG_FILTER_ENABLE	1
>  #define STM32F7_I2C_ANALOG_FILTER_DELAY_MIN	50	/* ns */
> @@ -725,6 +727,13 @@ static void stm32f7_i2c_hw_config(struct stm32f7_i2c_dev *i2c_dev)
>  	else
>  		stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
>  				     STM32F7_I2C_CR1_ANFOFF);
> +
> +	/* Program the Digital Filter */
> +	stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1,
> +			     STM32F7_I2C_CR1_DNF_MASK);
> +	stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
> +			     STM32F7_I2C_CR1_DNF(i2c_dev->setup.dnf));
> +
>  	stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
>  			     STM32F7_I2C_CR1_PE);
>  }
> 

-- 
--
~ Py MORDRET
--

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

* Re: [PATCH 2/5] i2c: stm32f7: support DT binding i2c-analog-filter
  2021-02-05  8:51 ` [PATCH 2/5] i2c: stm32f7: support DT binding i2c-analog-filter Alain Volmat
@ 2021-02-05 14:58   ` Pierre Yves MORDRET
  2021-03-18 10:51     ` Wolfram Sang
  2021-03-18 10:54   ` Wolfram Sang
  1 sibling, 1 reply; 20+ messages in thread
From: Pierre Yves MORDRET @ 2021-02-05 14:58 UTC (permalink / raw)
  To: Alain Volmat, wsa, robh+dt
  Cc: mark.rutland, mcoquelin.stm32, alexandre.torgue, linux-i2c,
	devicetree, linux-stm32, linux-arm-kernel, linux-kernel,
	fabrice.gasnier

Hello all

Looks good to me

Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>

Regards

On 2/5/21 9:51 AM, Alain Volmat wrote:
> Replace driver internally coded enabling/disabling of the
> analog-filter with the DT binding "i2c-analog-filter".
> 
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
> ---
>  drivers/i2c/busses/i2c-stm32f7.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> index 473fbe144b7e..0c539fea2754 100644
> --- a/drivers/i2c/busses/i2c-stm32f7.c
> +++ b/drivers/i2c/busses/i2c-stm32f7.c
> @@ -164,7 +164,6 @@ enum {
>  #define STM32F7_I2C_DNF_DEFAULT			0
>  #define STM32F7_I2C_DNF_MAX			15
>  
> -#define STM32F7_I2C_ANALOG_FILTER_ENABLE	1
>  #define STM32F7_I2C_ANALOG_FILTER_DELAY_MIN	50	/* ns */
>  #define STM32F7_I2C_ANALOG_FILTER_DELAY_MAX	260	/* ns */
>  
> @@ -224,7 +223,6 @@ struct stm32f7_i2c_spec {
>   * @rise_time: Rise time (ns)
>   * @fall_time: Fall time (ns)
>   * @dnf: Digital filter coefficient (0-16)
> - * @analog_filter: Analog filter delay (On/Off)
>   * @fmp_clr_offset: Fast Mode Plus clear register offset from set register
>   */
>  struct stm32f7_i2c_setup {
> @@ -233,7 +231,6 @@ struct stm32f7_i2c_setup {
>  	u32 rise_time;
>  	u32 fall_time;
>  	u8 dnf;
> -	bool analog_filter;
>  	u32 fmp_clr_offset;
>  };
>  
> @@ -312,6 +309,7 @@ struct stm32f7_i2c_msg {
>   * @wakeup_src: boolean to know if the device is a wakeup source
>   * @smbus_mode: states that the controller is configured in SMBus mode
>   * @host_notify_client: SMBus host-notify client
> + * @analog_filter: boolean to indicate enabling of the analog filter
>   */
>  struct stm32f7_i2c_dev {
>  	struct i2c_adapter adap;
> @@ -340,6 +338,7 @@ struct stm32f7_i2c_dev {
>  	bool wakeup_src;
>  	bool smbus_mode;
>  	struct i2c_client *host_notify_client;
> +	bool analog_filter;
>  };
>  
>  /*
> @@ -386,14 +385,12 @@ static const struct stm32f7_i2c_setup stm32f7_setup = {
>  	.rise_time = STM32F7_I2C_RISE_TIME_DEFAULT,
>  	.fall_time = STM32F7_I2C_FALL_TIME_DEFAULT,
>  	.dnf = STM32F7_I2C_DNF_DEFAULT,
> -	.analog_filter = STM32F7_I2C_ANALOG_FILTER_ENABLE,
>  };
>  
>  static const struct stm32f7_i2c_setup stm32mp15_setup = {
>  	.rise_time = STM32F7_I2C_RISE_TIME_DEFAULT,
>  	.fall_time = STM32F7_I2C_FALL_TIME_DEFAULT,
>  	.dnf = STM32F7_I2C_DNF_DEFAULT,
> -	.analog_filter = STM32F7_I2C_ANALOG_FILTER_ENABLE,
>  	.fmp_clr_offset = 0x40,
>  };
>  
> @@ -471,10 +468,10 @@ static int stm32f7_i2c_compute_timing(struct stm32f7_i2c_dev *i2c_dev,
>  
>  	/*  Analog and Digital Filters */
>  	af_delay_min =
> -		(setup->analog_filter ?
> +		(i2c_dev->analog_filter ?
>  		 STM32F7_I2C_ANALOG_FILTER_DELAY_MIN : 0);
>  	af_delay_max =
> -		(setup->analog_filter ?
> +		(i2c_dev->analog_filter ?
>  		 STM32F7_I2C_ANALOG_FILTER_DELAY_MAX : 0);
>  	dnf_delay = setup->dnf * i2cclk;
>  
> @@ -676,12 +673,15 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev,
>  		return ret;
>  	}
>  
> +	i2c_dev->analog_filter = of_property_read_bool(i2c_dev->dev->of_node,
> +						       "i2c-analog-filter");
> +
>  	dev_dbg(i2c_dev->dev, "I2C Speed(%i), Clk Source(%i)\n",
>  		setup->speed_freq, setup->clock_src);
>  	dev_dbg(i2c_dev->dev, "I2C Rise(%i) and Fall(%i) Time\n",
>  		setup->rise_time, setup->fall_time);
>  	dev_dbg(i2c_dev->dev, "I2C Analog Filter(%s), DNF(%i)\n",
> -		(setup->analog_filter ? "On" : "Off"), setup->dnf);
> +		(i2c_dev->analog_filter ? "On" : "Off"), setup->dnf);
>  
>  	i2c_dev->bus_rate = setup->speed_freq;
>  
> @@ -720,8 +720,8 @@ static void stm32f7_i2c_hw_config(struct stm32f7_i2c_dev *i2c_dev)
>  	timing |= STM32F7_I2C_TIMINGR_SCLL(t->scll);
>  	writel_relaxed(timing, i2c_dev->base + STM32F7_I2C_TIMINGR);
>  
> -	/* Enable I2C */
> -	if (i2c_dev->setup.analog_filter)
> +	/* Configure the Analog Filter */
> +	if (i2c_dev->analog_filter)
>  		stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1,
>  				     STM32F7_I2C_CR1_ANFOFF);
>  	else
> 

-- 
--
~ Py MORDRET
--

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

* Re: [PATCH 3/5] i2c: stm32f7: add support for DNF i2c-digital-filter binding
  2021-02-05  8:51 ` [PATCH 3/5] i2c: stm32f7: add support for DNF i2c-digital-filter binding Alain Volmat
@ 2021-02-05 14:59   ` Pierre Yves MORDRET
  2021-03-18 10:54   ` Wolfram Sang
  1 sibling, 0 replies; 20+ messages in thread
From: Pierre Yves MORDRET @ 2021-02-05 14:59 UTC (permalink / raw)
  To: Alain Volmat, wsa, robh+dt
  Cc: mark.rutland, mcoquelin.stm32, alexandre.torgue, linux-i2c,
	devicetree, linux-stm32, linux-arm-kernel, linux-kernel,
	fabrice.gasnier

Hello all

Looks good to me

Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>

Regards

On 2/5/21 9:51 AM, Alain Volmat wrote:
> Add the support for the i2c-digital-filter binding, allowing to enable
> the digital filter via the device-tree and indicate its value in the DT.
> 
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
> ---
>  drivers/i2c/busses/i2c-stm32f7.c | 27 ++++++++++++++++-----------
>  1 file changed, 16 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> index 0c539fea2754..f77cd6512a86 100644
> --- a/drivers/i2c/busses/i2c-stm32f7.c
> +++ b/drivers/i2c/busses/i2c-stm32f7.c
> @@ -222,7 +222,6 @@ struct stm32f7_i2c_spec {
>   * @clock_src: I2C clock source frequency (Hz)
>   * @rise_time: Rise time (ns)
>   * @fall_time: Fall time (ns)
> - * @dnf: Digital filter coefficient (0-16)
>   * @fmp_clr_offset: Fast Mode Plus clear register offset from set register
>   */
>  struct stm32f7_i2c_setup {
> @@ -230,7 +229,6 @@ struct stm32f7_i2c_setup {
>  	u32 clock_src;
>  	u32 rise_time;
>  	u32 fall_time;
> -	u8 dnf;
>  	u32 fmp_clr_offset;
>  };
>  
> @@ -310,6 +308,8 @@ struct stm32f7_i2c_msg {
>   * @smbus_mode: states that the controller is configured in SMBus mode
>   * @host_notify_client: SMBus host-notify client
>   * @analog_filter: boolean to indicate enabling of the analog filter
> + * @dnf_dt: value of digital filter requested via dt
> + * @dnf: value of digital filter to apply
>   */
>  struct stm32f7_i2c_dev {
>  	struct i2c_adapter adap;
> @@ -339,6 +339,8 @@ struct stm32f7_i2c_dev {
>  	bool smbus_mode;
>  	struct i2c_client *host_notify_client;
>  	bool analog_filter;
> +	u32 dnf_dt;
> +	u32 dnf;
>  };
>  
>  /*
> @@ -384,13 +386,11 @@ static struct stm32f7_i2c_spec stm32f7_i2c_specs[] = {
>  static const struct stm32f7_i2c_setup stm32f7_setup = {
>  	.rise_time = STM32F7_I2C_RISE_TIME_DEFAULT,
>  	.fall_time = STM32F7_I2C_FALL_TIME_DEFAULT,
> -	.dnf = STM32F7_I2C_DNF_DEFAULT,
>  };
>  
>  static const struct stm32f7_i2c_setup stm32mp15_setup = {
>  	.rise_time = STM32F7_I2C_RISE_TIME_DEFAULT,
>  	.fall_time = STM32F7_I2C_FALL_TIME_DEFAULT,
> -	.dnf = STM32F7_I2C_DNF_DEFAULT,
>  	.fmp_clr_offset = 0x40,
>  };
>  
> @@ -459,10 +459,11 @@ static int stm32f7_i2c_compute_timing(struct stm32f7_i2c_dev *i2c_dev,
>  		return -EINVAL;
>  	}
>  
> -	if (setup->dnf > STM32F7_I2C_DNF_MAX) {
> +	i2c_dev->dnf = DIV_ROUND_CLOSEST(i2c_dev->dnf_dt, i2cclk);
> +	if (i2c_dev->dnf > STM32F7_I2C_DNF_MAX) {
>  		dev_err(i2c_dev->dev,
>  			"DNF out of bound %d/%d\n",
> -			setup->dnf, STM32F7_I2C_DNF_MAX);
> +			i2c_dev->dnf * i2cclk, STM32F7_I2C_DNF_MAX * i2cclk);
>  		return -EINVAL;
>  	}
>  
> @@ -473,13 +474,13 @@ static int stm32f7_i2c_compute_timing(struct stm32f7_i2c_dev *i2c_dev,
>  	af_delay_max =
>  		(i2c_dev->analog_filter ?
>  		 STM32F7_I2C_ANALOG_FILTER_DELAY_MAX : 0);
> -	dnf_delay = setup->dnf * i2cclk;
> +	dnf_delay = i2c_dev->dnf * i2cclk;
>  
>  	sdadel_min = specs->hddat_min + setup->fall_time -
> -		af_delay_min - (setup->dnf + 3) * i2cclk;
> +		af_delay_min - (i2c_dev->dnf + 3) * i2cclk;
>  
>  	sdadel_max = specs->vddat_max - setup->rise_time -
> -		af_delay_max - (setup->dnf + 4) * i2cclk;
> +		af_delay_max - (i2c_dev->dnf + 4) * i2cclk;
>  
>  	scldel_min = setup->rise_time + specs->sudat_min;
>  
> @@ -645,6 +646,7 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev,
>  	setup->speed_freq = t->bus_freq_hz;
>  	i2c_dev->setup.rise_time = t->scl_rise_ns;
>  	i2c_dev->setup.fall_time = t->scl_fall_ns;
> +	i2c_dev->dnf_dt = t->digital_filter_width_ns;
>  	setup->clock_src = clk_get_rate(i2c_dev->clk);
>  
>  	if (!setup->clock_src) {
> @@ -652,6 +654,9 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev,
>  		return -EINVAL;
>  	}
>  
> +	if (!of_property_read_bool(i2c_dev->dev->of_node, "i2c-digital-filter"))
> +		i2c_dev->dnf_dt = STM32F7_I2C_DNF_DEFAULT;
> +
>  	do {
>  		ret = stm32f7_i2c_compute_timing(i2c_dev, setup,
>  						 &i2c_dev->timing);
> @@ -681,7 +686,7 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev,
>  	dev_dbg(i2c_dev->dev, "I2C Rise(%i) and Fall(%i) Time\n",
>  		setup->rise_time, setup->fall_time);
>  	dev_dbg(i2c_dev->dev, "I2C Analog Filter(%s), DNF(%i)\n",
> -		(i2c_dev->analog_filter ? "On" : "Off"), setup->dnf);
> +		(i2c_dev->analog_filter ? "On" : "Off"), i2c_dev->dnf);
>  
>  	i2c_dev->bus_rate = setup->speed_freq;
>  
> @@ -732,7 +737,7 @@ static void stm32f7_i2c_hw_config(struct stm32f7_i2c_dev *i2c_dev)
>  	stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1,
>  			     STM32F7_I2C_CR1_DNF_MASK);
>  	stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
> -			     STM32F7_I2C_CR1_DNF(i2c_dev->setup.dnf));
> +			     STM32F7_I2C_CR1_DNF(i2c_dev->dnf));
>  
>  	stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
>  			     STM32F7_I2C_CR1_PE);
> 

-- 
--
~ Py MORDRET
--

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

* Re: [PATCH 5/5] i2c: stm32f7: indicate the address being accessed on errors
  2021-02-05  8:51 ` [PATCH 5/5] i2c: stm32f7: indicate the address being accessed on errors Alain Volmat
@ 2021-02-05 14:59   ` Pierre Yves MORDRET
  2021-03-18 10:58   ` Wolfram Sang
  1 sibling, 0 replies; 20+ messages in thread
From: Pierre Yves MORDRET @ 2021-02-05 14:59 UTC (permalink / raw)
  To: Alain Volmat, wsa, robh+dt
  Cc: mark.rutland, mcoquelin.stm32, alexandre.torgue, linux-i2c,
	devicetree, linux-stm32, linux-arm-kernel, linux-kernel,
	fabrice.gasnier

Hello all

Looks good to me

Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>

Regards

On 2/5/21 9:51 AM, Alain Volmat wrote:
> To help debugging issues, add the address of the slave being
> accessed when getting an error.
> 
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
> ---
>  drivers/i2c/busses/i2c-stm32f7.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> index f77cd6512a86..ef642fe1eb2c 100644
> --- a/drivers/i2c/busses/i2c-stm32f7.c
> +++ b/drivers/i2c/busses/i2c-stm32f7.c
> @@ -1602,7 +1602,8 @@ static irqreturn_t stm32f7_i2c_isr_error(int irq, void *data)
>  
>  	/* Bus error */
>  	if (status & STM32F7_I2C_ISR_BERR) {
> -		dev_err(dev, "<%s>: Bus error\n", __func__);
> +		dev_err(dev, "<%s>: Bus error accessing addr 0x%x\n",
> +			__func__, f7_msg->addr);
>  		writel_relaxed(STM32F7_I2C_ICR_BERRCF, base + STM32F7_I2C_ICR);
>  		stm32f7_i2c_release_bus(&i2c_dev->adap);
>  		f7_msg->result = -EIO;
> @@ -1610,13 +1611,15 @@ static irqreturn_t stm32f7_i2c_isr_error(int irq, void *data)
>  
>  	/* Arbitration loss */
>  	if (status & STM32F7_I2C_ISR_ARLO) {
> -		dev_dbg(dev, "<%s>: Arbitration loss\n", __func__);
> +		dev_dbg(dev, "<%s>: Arbitration loss accessing addr 0x%x\n",
> +			__func__, f7_msg->addr);
>  		writel_relaxed(STM32F7_I2C_ICR_ARLOCF, base + STM32F7_I2C_ICR);
>  		f7_msg->result = -EAGAIN;
>  	}
>  
>  	if (status & STM32F7_I2C_ISR_PECERR) {
> -		dev_err(dev, "<%s>: PEC error in reception\n", __func__);
> +		dev_err(dev, "<%s>: PEC error in reception accessing addr 0x%x\n",
> +			__func__, f7_msg->addr);
>  		writel_relaxed(STM32F7_I2C_ICR_PECCF, base + STM32F7_I2C_ICR);
>  		f7_msg->result = -EINVAL;
>  	}
> 

-- 
--
~ Py MORDRET
--

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

* Re: [PATCH 4/5] ARM: dts: stm32: enable the analog filter for all I2C nodes in stm32mp151
  2021-02-05  8:51 ` [PATCH 4/5] ARM: dts: stm32: enable the analog filter for all I2C nodes in stm32mp151 Alain Volmat
@ 2021-02-10  8:39   ` Pierre Yves MORDRET
  2021-03-29  9:16     ` Alexandre TORGUE
  2021-03-18 10:55   ` Wolfram Sang
  1 sibling, 1 reply; 20+ messages in thread
From: Pierre Yves MORDRET @ 2021-02-10  8:39 UTC (permalink / raw)
  To: Alain Volmat, wsa, robh+dt
  Cc: mark.rutland, mcoquelin.stm32, alexandre.torgue, linux-i2c,
	devicetree, linux-stm32, linux-arm-kernel, linux-kernel,
	fabrice.gasnier

Hello

Looks good to me

Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>

Thx
Regards


On 2/5/21 9:51 AM, Alain Volmat wrote:
> Enable the analog filter for all I2C nodes of the stm32mp151.
> 
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
> ---
>  arch/arm/boot/dts/stm32mp151.dtsi | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/stm32mp151.dtsi b/arch/arm/boot/dts/stm32mp151.dtsi
> index 3c75abacb374..558fc8fb38b6 100644
> --- a/arch/arm/boot/dts/stm32mp151.dtsi
> +++ b/arch/arm/boot/dts/stm32mp151.dtsi
> @@ -493,6 +493,7 @@
>  			#size-cells = <0>;
>  			st,syscfg-fmp = <&syscfg 0x4 0x1>;
>  			wakeup-source;
> +			i2c-analog-filter;
>  			status = "disabled";
>  		};
>  
> @@ -508,6 +509,7 @@
>  			#size-cells = <0>;
>  			st,syscfg-fmp = <&syscfg 0x4 0x2>;
>  			wakeup-source;
> +			i2c-analog-filter;
>  			status = "disabled";
>  		};
>  
> @@ -523,6 +525,7 @@
>  			#size-cells = <0>;
>  			st,syscfg-fmp = <&syscfg 0x4 0x4>;
>  			wakeup-source;
> +			i2c-analog-filter;
>  			status = "disabled";
>  		};
>  
> @@ -538,6 +541,7 @@
>  			#size-cells = <0>;
>  			st,syscfg-fmp = <&syscfg 0x4 0x10>;
>  			wakeup-source;
> +			i2c-analog-filter;
>  			status = "disabled";
>  		};
>  
> @@ -1533,6 +1537,7 @@
>  			#size-cells = <0>;
>  			st,syscfg-fmp = <&syscfg 0x4 0x8>;
>  			wakeup-source;
> +			i2c-analog-filter;
>  			status = "disabled";
>  		};
>  
> @@ -1570,6 +1575,7 @@
>  			#size-cells = <0>;
>  			st,syscfg-fmp = <&syscfg 0x4 0x20>;
>  			wakeup-source;
> +			i2c-analog-filter;
>  			status = "disabled";
>  		};
>  
> 

-- 
--
~ Py MORDRET
--

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

* Re: [PATCH 1/5] i2c: stm32f7: fix configuration of the digital filter
  2021-02-05  8:51 ` [PATCH 1/5] i2c: stm32f7: fix configuration of the digital filter Alain Volmat
  2021-02-05 14:58   ` Pierre Yves MORDRET
@ 2021-02-12 10:36   ` Wolfram Sang
  1 sibling, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2021-02-12 10:36 UTC (permalink / raw)
  To: Alain Volmat
  Cc: robh+dt, mark.rutland, pierre-yves.mordret, mcoquelin.stm32,
	alexandre.torgue, linux-i2c, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, fabrice.gasnier

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

On Fri, Feb 05, 2021 at 09:51:40AM +0100, Alain Volmat wrote:
> The digital filter related computation are present in the driver
> however the programming of the filter within the IP is missing.
> The maximum value for the DNF is wrong and should be 15 instead of 16.
> 
> Fixes: aeb068c57214 ("i2c: i2c-stm32f7: add driver")
> 
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>

Applied to for-current, thanks!

The rest will go in within the next cycle.


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

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

* Re: [PATCH 2/5] i2c: stm32f7: support DT binding i2c-analog-filter
  2021-02-05 14:58   ` Pierre Yves MORDRET
@ 2021-03-18 10:51     ` Wolfram Sang
  0 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2021-03-18 10:51 UTC (permalink / raw)
  To: Pierre Yves MORDRET
  Cc: Alain Volmat, robh+dt, mark.rutland, mcoquelin.stm32,
	alexandre.torgue, linux-i2c, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, fabrice.gasnier

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


> Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>

Please use "Reviewed-by" or "Acked-by" next time, then I will see it
in patchwork as taken care of. Thanks!


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

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

* Re: [PATCH 2/5] i2c: stm32f7: support DT binding i2c-analog-filter
  2021-02-05  8:51 ` [PATCH 2/5] i2c: stm32f7: support DT binding i2c-analog-filter Alain Volmat
  2021-02-05 14:58   ` Pierre Yves MORDRET
@ 2021-03-18 10:54   ` Wolfram Sang
  1 sibling, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2021-03-18 10:54 UTC (permalink / raw)
  To: Alain Volmat
  Cc: robh+dt, mark.rutland, pierre-yves.mordret, mcoquelin.stm32,
	alexandre.torgue, linux-i2c, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, fabrice.gasnier

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

On Fri, Feb 05, 2021 at 09:51:41AM +0100, Alain Volmat wrote:
> Replace driver internally coded enabling/disabling of the
> analog-filter with the DT binding "i2c-analog-filter".
> 
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>

Applied to for-next, thanks!


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

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

* Re: [PATCH 3/5] i2c: stm32f7: add support for DNF i2c-digital-filter binding
  2021-02-05  8:51 ` [PATCH 3/5] i2c: stm32f7: add support for DNF i2c-digital-filter binding Alain Volmat
  2021-02-05 14:59   ` Pierre Yves MORDRET
@ 2021-03-18 10:54   ` Wolfram Sang
  1 sibling, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2021-03-18 10:54 UTC (permalink / raw)
  To: Alain Volmat
  Cc: robh+dt, mark.rutland, pierre-yves.mordret, mcoquelin.stm32,
	alexandre.torgue, linux-i2c, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, fabrice.gasnier

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

On Fri, Feb 05, 2021 at 09:51:42AM +0100, Alain Volmat wrote:
> Add the support for the i2c-digital-filter binding, allowing to enable
> the digital filter via the device-tree and indicate its value in the DT.
> 
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>

Applied to for-next, thanks!


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

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

* Re: [PATCH 4/5] ARM: dts: stm32: enable the analog filter for all I2C nodes in stm32mp151
  2021-02-05  8:51 ` [PATCH 4/5] ARM: dts: stm32: enable the analog filter for all I2C nodes in stm32mp151 Alain Volmat
  2021-02-10  8:39   ` Pierre Yves MORDRET
@ 2021-03-18 10:55   ` Wolfram Sang
  2021-03-18 13:16     ` Alexandre TORGUE
  1 sibling, 1 reply; 20+ messages in thread
From: Wolfram Sang @ 2021-03-18 10:55 UTC (permalink / raw)
  To: Alain Volmat
  Cc: robh+dt, mark.rutland, pierre-yves.mordret, mcoquelin.stm32,
	alexandre.torgue, linux-i2c, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, fabrice.gasnier

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

On Fri, Feb 05, 2021 at 09:51:43AM +0100, Alain Volmat wrote:
> Enable the analog filter for all I2C nodes of the stm32mp151.
> 
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>

I usually don't take DTS patches, but they can go in now via arm-soc as
I applied the patches to the driver.


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

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

* Re: [PATCH 5/5] i2c: stm32f7: indicate the address being accessed on errors
  2021-02-05  8:51 ` [PATCH 5/5] i2c: stm32f7: indicate the address being accessed on errors Alain Volmat
  2021-02-05 14:59   ` Pierre Yves MORDRET
@ 2021-03-18 10:58   ` Wolfram Sang
  1 sibling, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2021-03-18 10:58 UTC (permalink / raw)
  To: Alain Volmat
  Cc: robh+dt, mark.rutland, pierre-yves.mordret, mcoquelin.stm32,
	alexandre.torgue, linux-i2c, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, fabrice.gasnier

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

On Fri, Feb 05, 2021 at 09:51:44AM +0100, Alain Volmat wrote:
> To help debugging issues, add the address of the slave being
> accessed when getting an error.
> 
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>

Applied to for-next, thanks!


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

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

* Re: [PATCH 4/5] ARM: dts: stm32: enable the analog filter for all I2C nodes in stm32mp151
  2021-03-18 10:55   ` Wolfram Sang
@ 2021-03-18 13:16     ` Alexandre TORGUE
  0 siblings, 0 replies; 20+ messages in thread
From: Alexandre TORGUE @ 2021-03-18 13:16 UTC (permalink / raw)
  To: Wolfram Sang, Alain Volmat
  Cc: robh+dt, mark.rutland, pierre-yves.mordret, mcoquelin.stm32,
	linux-i2c, devicetree, linux-stm32, linux-arm-kernel,
	linux-kernel, fabrice.gasnier

Hi Wolfram

On 3/18/21 11:55 AM, Wolfram Sang wrote:
> On Fri, Feb 05, 2021 at 09:51:43AM +0100, Alain Volmat wrote:
>> Enable the analog filter for all I2C nodes of the stm32mp151.
>>
>> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
> 
> I usually don't take DTS patches, but they can go in now via arm-soc as
> I applied the patches to the driver.
> 

I'll take it in my stm32 tree.

Thanks
Alex


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

* Re: [PATCH 4/5] ARM: dts: stm32: enable the analog filter for all I2C nodes in stm32mp151
  2021-02-10  8:39   ` Pierre Yves MORDRET
@ 2021-03-29  9:16     ` Alexandre TORGUE
  0 siblings, 0 replies; 20+ messages in thread
From: Alexandre TORGUE @ 2021-03-29  9:16 UTC (permalink / raw)
  To: Pierre Yves MORDRET, Alain Volmat, wsa, robh+dt
  Cc: mark.rutland, mcoquelin.stm32, linux-i2c, devicetree,
	linux-stm32, linux-arm-kernel, linux-kernel, fabrice.gasnier

Hi Alain

On 2/10/21 9:39 AM, Pierre Yves MORDRET wrote:
> Hello
> 
> Looks good to me
> 
> Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>
> 
> Thx
> Regards
> 
> 

Applied on stm32-next.

Thanks.
Alex

> On 2/5/21 9:51 AM, Alain Volmat wrote:
>> Enable the analog filter for all I2C nodes of the stm32mp151.
>>
>> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
>> ---
>>   arch/arm/boot/dts/stm32mp151.dtsi | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/arch/arm/boot/dts/stm32mp151.dtsi b/arch/arm/boot/dts/stm32mp151.dtsi
>> index 3c75abacb374..558fc8fb38b6 100644
>> --- a/arch/arm/boot/dts/stm32mp151.dtsi
>> +++ b/arch/arm/boot/dts/stm32mp151.dtsi
>> @@ -493,6 +493,7 @@
>>   			#size-cells = <0>;
>>   			st,syscfg-fmp = <&syscfg 0x4 0x1>;
>>   			wakeup-source;
>> +			i2c-analog-filter;
>>   			status = "disabled";
>>   		};
>>   
>> @@ -508,6 +509,7 @@
>>   			#size-cells = <0>;
>>   			st,syscfg-fmp = <&syscfg 0x4 0x2>;
>>   			wakeup-source;
>> +			i2c-analog-filter;
>>   			status = "disabled";
>>   		};
>>   
>> @@ -523,6 +525,7 @@
>>   			#size-cells = <0>;
>>   			st,syscfg-fmp = <&syscfg 0x4 0x4>;
>>   			wakeup-source;
>> +			i2c-analog-filter;
>>   			status = "disabled";
>>   		};
>>   
>> @@ -538,6 +541,7 @@
>>   			#size-cells = <0>;
>>   			st,syscfg-fmp = <&syscfg 0x4 0x10>;
>>   			wakeup-source;
>> +			i2c-analog-filter;
>>   			status = "disabled";
>>   		};
>>   
>> @@ -1533,6 +1537,7 @@
>>   			#size-cells = <0>;
>>   			st,syscfg-fmp = <&syscfg 0x4 0x8>;
>>   			wakeup-source;
>> +			i2c-analog-filter;
>>   			status = "disabled";
>>   		};
>>   
>> @@ -1570,6 +1575,7 @@
>>   			#size-cells = <0>;
>>   			st,syscfg-fmp = <&syscfg 0x4 0x20>;
>>   			wakeup-source;
>> +			i2c-analog-filter;
>>   			status = "disabled";
>>   		};
>>   
>>
> 

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

end of thread, other threads:[~2021-03-29  9:17 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-05  8:51 [PATCH 0/5] i2c: stm32: filter binding support & debug info Alain Volmat
2021-02-05  8:51 ` [PATCH 1/5] i2c: stm32f7: fix configuration of the digital filter Alain Volmat
2021-02-05 14:58   ` Pierre Yves MORDRET
2021-02-12 10:36   ` Wolfram Sang
2021-02-05  8:51 ` [PATCH 2/5] i2c: stm32f7: support DT binding i2c-analog-filter Alain Volmat
2021-02-05 14:58   ` Pierre Yves MORDRET
2021-03-18 10:51     ` Wolfram Sang
2021-03-18 10:54   ` Wolfram Sang
2021-02-05  8:51 ` [PATCH 3/5] i2c: stm32f7: add support for DNF i2c-digital-filter binding Alain Volmat
2021-02-05 14:59   ` Pierre Yves MORDRET
2021-03-18 10:54   ` Wolfram Sang
2021-02-05  8:51 ` [PATCH 4/5] ARM: dts: stm32: enable the analog filter for all I2C nodes in stm32mp151 Alain Volmat
2021-02-10  8:39   ` Pierre Yves MORDRET
2021-03-29  9:16     ` Alexandre TORGUE
2021-03-18 10:55   ` Wolfram Sang
2021-03-18 13:16     ` Alexandre TORGUE
2021-02-05  8:51 ` [PATCH 5/5] i2c: stm32f7: indicate the address being accessed on errors Alain Volmat
2021-02-05 14:59   ` Pierre Yves MORDRET
2021-03-18 10:58   ` Wolfram Sang
2021-02-05 14:57 ` [PATCH 0/5] i2c: stm32: filter binding support & debug info Pierre Yves MORDRET

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).