linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] SYSCFG Fast Mode Plus support for I2C STM32F7
@ 2018-11-19 11:03 Pierre-Yves MORDRET
  2018-11-19 11:03 ` [PATCH v2 1/2] dt-bindings: i2c-stm32: " Pierre-Yves MORDRET
  2018-11-19 11:03 ` [PATCH v2 2/2] i2c: i2c-stm32f7: " Pierre-Yves MORDRET
  0 siblings, 2 replies; 5+ messages in thread
From: Pierre-Yves MORDRET @ 2018-11-19 11:03 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Maxime Coquelin, Alexandre Torgue,
	Wolfram Sang, Pierre-Yves MORDRET, linux-i2c, devicetree,
	linux-stm32, linux-arm-kernel, linux-kernel

Append optional bindings to update SYSCFG Fast Mode Plus bits if
Fast Mode Plus speed is selected.

---
  Version history:
    v2:
       * solve some build issues
    v1:
       * Initial
---

Pierre-Yves MORDRET (2):
  dt-bindings: i2c-stm32: SYSCFG Fast Mode Plus support for I2C STM32F7
  i2c: i2c-stm32f7: SYSCFG Fast Mode Plus support for I2C STM32F7

 .../devicetree/bindings/i2c/i2c-stm32.txt          |  6 ++++
 drivers/i2c/busses/i2c-stm32f7.c                   | 38 ++++++++++++++++++++--
 2 files changed, 41 insertions(+), 3 deletions(-)

-- 
2.7.4


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

* [PATCH v2 1/2] dt-bindings: i2c-stm32: SYSCFG Fast Mode Plus support for I2C STM32F7
  2018-11-19 11:03 [PATCH v2 0/2] SYSCFG Fast Mode Plus support for I2C STM32F7 Pierre-Yves MORDRET
@ 2018-11-19 11:03 ` Pierre-Yves MORDRET
  2018-11-27 12:09   ` Wolfram Sang
  2018-11-19 11:03 ` [PATCH v2 2/2] i2c: i2c-stm32f7: " Pierre-Yves MORDRET
  1 sibling, 1 reply; 5+ messages in thread
From: Pierre-Yves MORDRET @ 2018-11-19 11:03 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Maxime Coquelin, Alexandre Torgue,
	Wolfram Sang, Pierre-Yves MORDRET, linux-i2c, devicetree,
	linux-stm32, linux-arm-kernel, linux-kernel

Append optional bindings to update SYSCFG Fast Mode Plus bits if
Fast Mode Plus speed is selected.

Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
  Version history:
    v2:
    v1:
       * Initial
---
---
 Documentation/devicetree/bindings/i2c/i2c-stm32.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/i2c/i2c-stm32.txt b/Documentation/devicetree/bindings/i2c/i2c-stm32.txt
index 3b54899..69240e1 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-stm32.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-stm32.txt
@@ -26,6 +26,11 @@ Optional properties :
 - i2c-scl-falling-time-ns : Only for STM32F7, I2C SCL Falling time for the board
   (default: 10)
   I2C Timings are derived from these 2 values
+- st,syscfg-fmp:  Only for STM32F7, use to set Fast Mode Plus bit within SYSCFG
+  whether Fast Mode Plus speed is selected by slave.
+	1st cell : phandle to syscfg
+	2nd cell : register offset within SYSCFG
+	3rd cell : register bitmask for FMP bit
 
 Example :
 
@@ -53,4 +58,5 @@ Example :
 		clocks = <&rcc 1 CLK_I2C1>;
 		pinctrl-0 = <&i2c1_sda_pin>, <&i2c1_scl_pin>;
 		pinctrl-names = "default";
+		st,syscfg-fmp = <&syscfg 0x4 0x1>;
 	};
-- 
2.7.4


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

* [PATCH v2 2/2] i2c: i2c-stm32f7: SYSCFG Fast Mode Plus support for I2C STM32F7
  2018-11-19 11:03 [PATCH v2 0/2] SYSCFG Fast Mode Plus support for I2C STM32F7 Pierre-Yves MORDRET
  2018-11-19 11:03 ` [PATCH v2 1/2] dt-bindings: i2c-stm32: " Pierre-Yves MORDRET
@ 2018-11-19 11:03 ` Pierre-Yves MORDRET
  2018-11-27 12:09   ` Wolfram Sang
  1 sibling, 1 reply; 5+ messages in thread
From: Pierre-Yves MORDRET @ 2018-11-19 11:03 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Maxime Coquelin, Alexandre Torgue,
	Wolfram Sang, Pierre-Yves MORDRET, linux-i2c, devicetree,
	linux-stm32, linux-arm-kernel, linux-kernel

Read SYSCFG bindings to set Fast Mode Plus bits if Fast Mode Plus
speed is selected.

Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.com>
---
  Version history:
    v2:
       * Missing header file inclusion
    v1:
       * Initial
---
---
 drivers/i2c/busses/i2c-stm32f7.c | 38 +++++++++++++++++++++++++++++++++++---
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
index 62d023e..e9f0c0b 100644
--- a/drivers/i2c/busses/i2c-stm32f7.c
+++ b/drivers/i2c/busses/i2c-stm32f7.c
@@ -21,12 +21,14 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
+#include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
+#include <linux/regmap.h>
 #include <linux/reset.h>
 #include <linux/slab.h>
 
@@ -276,6 +278,7 @@ struct stm32f7_i2c_msg {
  * slave)
  * @dma: dma data
  * @use_dma: boolean to know if dma is used in the current transfer
+ * @regmap: holds SYSCFG phandle for Fast Mode Plus bits
  */
 struct stm32f7_i2c_dev {
 	struct i2c_adapter adap;
@@ -296,6 +299,7 @@ struct stm32f7_i2c_dev {
 	bool master_mode;
 	struct stm32_i2c_dma *dma;
 	bool use_dma;
+	struct regmap *regmap;
 };
 
 /**
@@ -1763,6 +1767,30 @@ static int stm32f7_i2c_unreg_slave(struct i2c_client *slave)
 	return 0;
 }
 
+static int stm32f7_i2c_setup_fm_plus_bits(struct platform_device *pdev,
+					  struct stm32f7_i2c_dev *i2c_dev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	int ret;
+	u32 reg, mask;
+
+	i2c_dev->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg-fmp");
+	if (IS_ERR(i2c_dev->regmap)) {
+		/* Optional */
+		return 0;
+	}
+
+	ret = of_property_read_u32_index(np, "st,syscfg-fmp", 1, &reg);
+	if (ret)
+		return ret;
+
+	ret = of_property_read_u32_index(np, "st,syscfg-fmp", 2, &mask);
+	if (ret)
+		return ret;
+
+	return regmap_update_bits(i2c_dev->regmap, reg, mask, mask);
+}
+
 static u32 stm32f7_i2c_func(struct i2c_adapter *adap)
 {
 	return I2C_FUNC_I2C | I2C_FUNC_10BIT_ADDR | I2C_FUNC_SLAVE |
@@ -1828,12 +1856,16 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
 	i2c_dev->speed = STM32_I2C_SPEED_STANDARD;
 	ret = device_property_read_u32(&pdev->dev, "clock-frequency",
 				       &clk_rate);
-	if (!ret && clk_rate >= 1000000)
+	if (!ret && clk_rate >= 1000000) {
 		i2c_dev->speed = STM32_I2C_SPEED_FAST_PLUS;
-	else if (!ret && clk_rate >= 400000)
+		ret = stm32f7_i2c_setup_fm_plus_bits(pdev, i2c_dev);
+		if (ret)
+			goto clk_free;
+	} else if (!ret && clk_rate >= 400000) {
 		i2c_dev->speed = STM32_I2C_SPEED_FAST;
-	else if (!ret && clk_rate >= 100000)
+	} else if (!ret && clk_rate >= 100000) {
 		i2c_dev->speed = STM32_I2C_SPEED_STANDARD;
+	}
 
 	rst = devm_reset_control_get(&pdev->dev, NULL);
 	if (IS_ERR(rst)) {
-- 
2.7.4


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

* Re: [PATCH v2 1/2] dt-bindings: i2c-stm32: SYSCFG Fast Mode Plus support for I2C STM32F7
  2018-11-19 11:03 ` [PATCH v2 1/2] dt-bindings: i2c-stm32: " Pierre-Yves MORDRET
@ 2018-11-27 12:09   ` Wolfram Sang
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2018-11-27 12:09 UTC (permalink / raw)
  To: Pierre-Yves MORDRET
  Cc: Rob Herring, Mark Rutland, Maxime Coquelin, Alexandre Torgue,
	linux-i2c, devicetree, linux-stm32, linux-arm-kernel,
	linux-kernel

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

On Mon, Nov 19, 2018 at 12:03:31PM +0100, Pierre-Yves MORDRET wrote:
> Append optional bindings to update SYSCFG Fast Mode Plus bits if
> Fast Mode Plus speed is selected.
> 
> Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.com>
> Reviewed-by: Rob Herring <robh@kernel.org>

Applied to for-next, thanks!


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

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

* Re: [PATCH v2 2/2] i2c: i2c-stm32f7: SYSCFG Fast Mode Plus support for I2C STM32F7
  2018-11-19 11:03 ` [PATCH v2 2/2] i2c: i2c-stm32f7: " Pierre-Yves MORDRET
@ 2018-11-27 12:09   ` Wolfram Sang
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2018-11-27 12:09 UTC (permalink / raw)
  To: Pierre-Yves MORDRET
  Cc: Rob Herring, Mark Rutland, Maxime Coquelin, Alexandre Torgue,
	linux-i2c, devicetree, linux-stm32, linux-arm-kernel,
	linux-kernel

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

On Mon, Nov 19, 2018 at 12:03:32PM +0100, Pierre-Yves MORDRET wrote:
> Read SYSCFG bindings to set Fast Mode Plus bits if Fast Mode Plus
> speed is selected.
> 
> Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.com>

Applied to for-next, thanks!


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

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

end of thread, other threads:[~2018-11-27 12:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-19 11:03 [PATCH v2 0/2] SYSCFG Fast Mode Plus support for I2C STM32F7 Pierre-Yves MORDRET
2018-11-19 11:03 ` [PATCH v2 1/2] dt-bindings: i2c-stm32: " Pierre-Yves MORDRET
2018-11-27 12:09   ` Wolfram Sang
2018-11-19 11:03 ` [PATCH v2 2/2] i2c: i2c-stm32f7: " Pierre-Yves MORDRET
2018-11-27 12:09   ` Wolfram Sang

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