All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] i2c: at91: add upport for the HOLD field
@ 2015-12-02 10:39 ` Ludovic Desroches
  0 siblings, 0 replies; 26+ messages in thread
From: Ludovic Desroches @ 2015-12-02 10:39 UTC (permalink / raw)
  To: wsa, nicolas.ferre, alexandre.belloni
  Cc: linux-i2c, linux-kernel, plagnioj, linux-arm-kernel, devicetree,
	Ludovic Desroches

The hold field allows to configure the data hold time which can be set
with the help of the generic binding 'i2c-sda-hold-time-ns'. This
feature has been introduced with SAMA5D4 SoC family.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 drivers/i2c/busses/i2c-at91.c | 54 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 51 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 10835d1..09e1690 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -64,6 +64,7 @@
 #define	AT91_TWI_IADR		0x000c	/* Internal Address Register */
 
 #define	AT91_TWI_CWGR		0x0010	/* Clock Waveform Generator Reg */
+#define	AT91_TWI_CWGR_HOLD(x)	(((x) & 0x1f) << 24)
 
 #define	AT91_TWI_SR		0x0020	/* Status Register */
 #define	AT91_TWI_TXCOMP		BIT(0)	/* Transmission Complete */
@@ -110,6 +111,7 @@ struct at91_twi_pdata {
 	unsigned clk_offset;
 	bool has_unre_flag;
 	bool has_alt_cmd;
+	bool has_hold_field;
 	struct at_dma_slave dma_slave;
 };
 
@@ -187,10 +189,13 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
  */
 static void at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
 {
-	int ckdiv, cdiv, div;
+	int ckdiv, cdiv, div, hold = 0;
 	struct at91_twi_pdata *pdata = dev->pdata;
 	int offset = pdata->clk_offset;
 	int max_ckdiv = pdata->clk_max_div;
+	u32 twd_hold_time_ns = 0;
+
+#define MAX_HOLD 31
 
 	div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
 				       2 * twi_clk) - offset);
@@ -204,8 +209,33 @@ static void at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
 		cdiv = 255;
 	}
 
-	dev->twi_cwgr_reg = (ckdiv << 16) | (cdiv << 8) | cdiv;
-	dev_dbg(dev->dev, "cdiv %d ckdiv %d\n", cdiv, ckdiv);
+	if (pdata->has_hold_field) {
+		of_property_read_u32(dev->dev->of_node, "i2c-sda-hold-time-ns",
+				     &twd_hold_time_ns);
+
+		/*
+		 * hold time = HOLD + 3 x T_peripheral_clock
+		 * Use clk rate in kHz to prevent overflows when computing
+		 * hold.
+		 */
+		hold = DIV_ROUND_UP(twd_hold_time_ns
+				    * (clk_get_rate(dev->clk) / 1000), 1000000);
+		hold -= 3;
+		if (hold < 0)
+			hold = 0;
+		if (hold > MAX_HOLD) {
+			dev_warn(dev->dev,
+				 "HOLD field set to its maximum value (%d instead of %d)\n",
+				 MAX_HOLD, hold);
+			hold = MAX_HOLD;
+		}
+	}
+
+	dev->twi_cwgr_reg = (ckdiv << 16) | (cdiv << 8) | cdiv
+			    | AT91_TWI_CWGR_HOLD(hold);
+
+	dev_dbg(dev->dev, "cdiv %d ckdiv %d hold %d (%d ns)\n",
+		cdiv, ckdiv, hold, twd_hold_time_ns);
 }
 
 static void at91_twi_dma_cleanup(struct at91_twi_dev *dev)
@@ -797,6 +827,7 @@ static struct at91_twi_pdata at91rm9200_config = {
 	.clk_offset = 3,
 	.has_unre_flag = true,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
 };
 
 static struct at91_twi_pdata at91sam9261_config = {
@@ -804,6 +835,7 @@ static struct at91_twi_pdata at91sam9261_config = {
 	.clk_offset = 4,
 	.has_unre_flag = false,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
 };
 
 static struct at91_twi_pdata at91sam9260_config = {
@@ -811,6 +843,7 @@ static struct at91_twi_pdata at91sam9260_config = {
 	.clk_offset = 4,
 	.has_unre_flag = false,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
 };
 
 static struct at91_twi_pdata at91sam9g20_config = {
@@ -818,6 +851,7 @@ static struct at91_twi_pdata at91sam9g20_config = {
 	.clk_offset = 4,
 	.has_unre_flag = false,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
 };
 
 static struct at91_twi_pdata at91sam9g10_config = {
@@ -825,6 +859,7 @@ static struct at91_twi_pdata at91sam9g10_config = {
 	.clk_offset = 4,
 	.has_unre_flag = false,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
 };
 
 static const struct platform_device_id at91_twi_devtypes[] = {
@@ -854,6 +889,15 @@ static struct at91_twi_pdata at91sam9x5_config = {
 	.clk_offset = 4,
 	.has_unre_flag = false,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
+};
+
+static struct at91_twi_pdata sama5d4_config = {
+	.clk_max_div = 7,
+	.clk_offset = 4,
+	.has_unre_flag = false,
+	.has_alt_cmd = false,
+	.has_hold_field = true,
 };
 
 static struct at91_twi_pdata sama5d2_config = {
@@ -861,6 +905,7 @@ static struct at91_twi_pdata sama5d2_config = {
 	.clk_offset = 4,
 	.has_unre_flag = true,
 	.has_alt_cmd = true,
+	.has_hold_field = true,
 };
 
 static const struct of_device_id atmel_twi_dt_ids[] = {
@@ -883,6 +928,9 @@ static const struct of_device_id atmel_twi_dt_ids[] = {
 		.compatible = "atmel,at91sam9x5-i2c",
 		.data = &at91sam9x5_config,
 	}, {
+		.compatible = "atmel,sama5d4-i2c",
+		.data = &sama5d4_config,
+	}, {
 		.compatible = "atmel,sama5d2-i2c",
 		.data = &sama5d2_config,
 	}, {
-- 
2.5.0


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

* [PATCH 1/4] i2c: at91: add upport for the HOLD field
@ 2015-12-02 10:39 ` Ludovic Desroches
  0 siblings, 0 replies; 26+ messages in thread
From: Ludovic Desroches @ 2015-12-02 10:39 UTC (permalink / raw)
  To: wsa, nicolas.ferre, alexandre.belloni
  Cc: linux-i2c, linux-kernel, plagnioj, linux-arm-kernel, devicetree,
	Ludovic Desroches

The hold field allows to configure the data hold time which can be set
with the help of the generic binding 'i2c-sda-hold-time-ns'. This
feature has been introduced with SAMA5D4 SoC family.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 drivers/i2c/busses/i2c-at91.c | 54 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 51 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 10835d1..09e1690 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -64,6 +64,7 @@
 #define	AT91_TWI_IADR		0x000c	/* Internal Address Register */
 
 #define	AT91_TWI_CWGR		0x0010	/* Clock Waveform Generator Reg */
+#define	AT91_TWI_CWGR_HOLD(x)	(((x) & 0x1f) << 24)
 
 #define	AT91_TWI_SR		0x0020	/* Status Register */
 #define	AT91_TWI_TXCOMP		BIT(0)	/* Transmission Complete */
@@ -110,6 +111,7 @@ struct at91_twi_pdata {
 	unsigned clk_offset;
 	bool has_unre_flag;
 	bool has_alt_cmd;
+	bool has_hold_field;
 	struct at_dma_slave dma_slave;
 };
 
@@ -187,10 +189,13 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
  */
 static void at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
 {
-	int ckdiv, cdiv, div;
+	int ckdiv, cdiv, div, hold = 0;
 	struct at91_twi_pdata *pdata = dev->pdata;
 	int offset = pdata->clk_offset;
 	int max_ckdiv = pdata->clk_max_div;
+	u32 twd_hold_time_ns = 0;
+
+#define MAX_HOLD 31
 
 	div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
 				       2 * twi_clk) - offset);
@@ -204,8 +209,33 @@ static void at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
 		cdiv = 255;
 	}
 
-	dev->twi_cwgr_reg = (ckdiv << 16) | (cdiv << 8) | cdiv;
-	dev_dbg(dev->dev, "cdiv %d ckdiv %d\n", cdiv, ckdiv);
+	if (pdata->has_hold_field) {
+		of_property_read_u32(dev->dev->of_node, "i2c-sda-hold-time-ns",
+				     &twd_hold_time_ns);
+
+		/*
+		 * hold time = HOLD + 3 x T_peripheral_clock
+		 * Use clk rate in kHz to prevent overflows when computing
+		 * hold.
+		 */
+		hold = DIV_ROUND_UP(twd_hold_time_ns
+				    * (clk_get_rate(dev->clk) / 1000), 1000000);
+		hold -= 3;
+		if (hold < 0)
+			hold = 0;
+		if (hold > MAX_HOLD) {
+			dev_warn(dev->dev,
+				 "HOLD field set to its maximum value (%d instead of %d)\n",
+				 MAX_HOLD, hold);
+			hold = MAX_HOLD;
+		}
+	}
+
+	dev->twi_cwgr_reg = (ckdiv << 16) | (cdiv << 8) | cdiv
+			    | AT91_TWI_CWGR_HOLD(hold);
+
+	dev_dbg(dev->dev, "cdiv %d ckdiv %d hold %d (%d ns)\n",
+		cdiv, ckdiv, hold, twd_hold_time_ns);
 }
 
 static void at91_twi_dma_cleanup(struct at91_twi_dev *dev)
@@ -797,6 +827,7 @@ static struct at91_twi_pdata at91rm9200_config = {
 	.clk_offset = 3,
 	.has_unre_flag = true,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
 };
 
 static struct at91_twi_pdata at91sam9261_config = {
@@ -804,6 +835,7 @@ static struct at91_twi_pdata at91sam9261_config = {
 	.clk_offset = 4,
 	.has_unre_flag = false,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
 };
 
 static struct at91_twi_pdata at91sam9260_config = {
@@ -811,6 +843,7 @@ static struct at91_twi_pdata at91sam9260_config = {
 	.clk_offset = 4,
 	.has_unre_flag = false,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
 };
 
 static struct at91_twi_pdata at91sam9g20_config = {
@@ -818,6 +851,7 @@ static struct at91_twi_pdata at91sam9g20_config = {
 	.clk_offset = 4,
 	.has_unre_flag = false,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
 };
 
 static struct at91_twi_pdata at91sam9g10_config = {
@@ -825,6 +859,7 @@ static struct at91_twi_pdata at91sam9g10_config = {
 	.clk_offset = 4,
 	.has_unre_flag = false,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
 };
 
 static const struct platform_device_id at91_twi_devtypes[] = {
@@ -854,6 +889,15 @@ static struct at91_twi_pdata at91sam9x5_config = {
 	.clk_offset = 4,
 	.has_unre_flag = false,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
+};
+
+static struct at91_twi_pdata sama5d4_config = {
+	.clk_max_div = 7,
+	.clk_offset = 4,
+	.has_unre_flag = false,
+	.has_alt_cmd = false,
+	.has_hold_field = true,
 };
 
 static struct at91_twi_pdata sama5d2_config = {
@@ -861,6 +905,7 @@ static struct at91_twi_pdata sama5d2_config = {
 	.clk_offset = 4,
 	.has_unre_flag = true,
 	.has_alt_cmd = true,
+	.has_hold_field = true,
 };
 
 static const struct of_device_id atmel_twi_dt_ids[] = {
@@ -883,6 +928,9 @@ static const struct of_device_id atmel_twi_dt_ids[] = {
 		.compatible = "atmel,at91sam9x5-i2c",
 		.data = &at91sam9x5_config,
 	}, {
+		.compatible = "atmel,sama5d4-i2c",
+		.data = &sama5d4_config,
+	}, {
 		.compatible = "atmel,sama5d2-i2c",
 		.data = &sama5d2_config,
 	}, {
-- 
2.5.0

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

* [PATCH 1/4] i2c: at91: add upport for the HOLD field
@ 2015-12-02 10:39 ` Ludovic Desroches
  0 siblings, 0 replies; 26+ messages in thread
From: Ludovic Desroches @ 2015-12-02 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

The hold field allows to configure the data hold time which can be set
with the help of the generic binding 'i2c-sda-hold-time-ns'. This
feature has been introduced with SAMA5D4 SoC family.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 drivers/i2c/busses/i2c-at91.c | 54 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 51 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 10835d1..09e1690 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -64,6 +64,7 @@
 #define	AT91_TWI_IADR		0x000c	/* Internal Address Register */
 
 #define	AT91_TWI_CWGR		0x0010	/* Clock Waveform Generator Reg */
+#define	AT91_TWI_CWGR_HOLD(x)	(((x) & 0x1f) << 24)
 
 #define	AT91_TWI_SR		0x0020	/* Status Register */
 #define	AT91_TWI_TXCOMP		BIT(0)	/* Transmission Complete */
@@ -110,6 +111,7 @@ struct at91_twi_pdata {
 	unsigned clk_offset;
 	bool has_unre_flag;
 	bool has_alt_cmd;
+	bool has_hold_field;
 	struct at_dma_slave dma_slave;
 };
 
@@ -187,10 +189,13 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
  */
 static void at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
 {
-	int ckdiv, cdiv, div;
+	int ckdiv, cdiv, div, hold = 0;
 	struct at91_twi_pdata *pdata = dev->pdata;
 	int offset = pdata->clk_offset;
 	int max_ckdiv = pdata->clk_max_div;
+	u32 twd_hold_time_ns = 0;
+
+#define MAX_HOLD 31
 
 	div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
 				       2 * twi_clk) - offset);
@@ -204,8 +209,33 @@ static void at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
 		cdiv = 255;
 	}
 
-	dev->twi_cwgr_reg = (ckdiv << 16) | (cdiv << 8) | cdiv;
-	dev_dbg(dev->dev, "cdiv %d ckdiv %d\n", cdiv, ckdiv);
+	if (pdata->has_hold_field) {
+		of_property_read_u32(dev->dev->of_node, "i2c-sda-hold-time-ns",
+				     &twd_hold_time_ns);
+
+		/*
+		 * hold time = HOLD + 3 x T_peripheral_clock
+		 * Use clk rate in kHz to prevent overflows when computing
+		 * hold.
+		 */
+		hold = DIV_ROUND_UP(twd_hold_time_ns
+				    * (clk_get_rate(dev->clk) / 1000), 1000000);
+		hold -= 3;
+		if (hold < 0)
+			hold = 0;
+		if (hold > MAX_HOLD) {
+			dev_warn(dev->dev,
+				 "HOLD field set to its maximum value (%d instead of %d)\n",
+				 MAX_HOLD, hold);
+			hold = MAX_HOLD;
+		}
+	}
+
+	dev->twi_cwgr_reg = (ckdiv << 16) | (cdiv << 8) | cdiv
+			    | AT91_TWI_CWGR_HOLD(hold);
+
+	dev_dbg(dev->dev, "cdiv %d ckdiv %d hold %d (%d ns)\n",
+		cdiv, ckdiv, hold, twd_hold_time_ns);
 }
 
 static void at91_twi_dma_cleanup(struct at91_twi_dev *dev)
@@ -797,6 +827,7 @@ static struct at91_twi_pdata at91rm9200_config = {
 	.clk_offset = 3,
 	.has_unre_flag = true,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
 };
 
 static struct at91_twi_pdata at91sam9261_config = {
@@ -804,6 +835,7 @@ static struct at91_twi_pdata at91sam9261_config = {
 	.clk_offset = 4,
 	.has_unre_flag = false,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
 };
 
 static struct at91_twi_pdata at91sam9260_config = {
@@ -811,6 +843,7 @@ static struct at91_twi_pdata at91sam9260_config = {
 	.clk_offset = 4,
 	.has_unre_flag = false,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
 };
 
 static struct at91_twi_pdata at91sam9g20_config = {
@@ -818,6 +851,7 @@ static struct at91_twi_pdata at91sam9g20_config = {
 	.clk_offset = 4,
 	.has_unre_flag = false,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
 };
 
 static struct at91_twi_pdata at91sam9g10_config = {
@@ -825,6 +859,7 @@ static struct at91_twi_pdata at91sam9g10_config = {
 	.clk_offset = 4,
 	.has_unre_flag = false,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
 };
 
 static const struct platform_device_id at91_twi_devtypes[] = {
@@ -854,6 +889,15 @@ static struct at91_twi_pdata at91sam9x5_config = {
 	.clk_offset = 4,
 	.has_unre_flag = false,
 	.has_alt_cmd = false,
+	.has_hold_field = false,
+};
+
+static struct at91_twi_pdata sama5d4_config = {
+	.clk_max_div = 7,
+	.clk_offset = 4,
+	.has_unre_flag = false,
+	.has_alt_cmd = false,
+	.has_hold_field = true,
 };
 
 static struct at91_twi_pdata sama5d2_config = {
@@ -861,6 +905,7 @@ static struct at91_twi_pdata sama5d2_config = {
 	.clk_offset = 4,
 	.has_unre_flag = true,
 	.has_alt_cmd = true,
+	.has_hold_field = true,
 };
 
 static const struct of_device_id atmel_twi_dt_ids[] = {
@@ -883,6 +928,9 @@ static const struct of_device_id atmel_twi_dt_ids[] = {
 		.compatible = "atmel,at91sam9x5-i2c",
 		.data = &at91sam9x5_config,
 	}, {
+		.compatible = "atmel,sama5d4-i2c",
+		.data = &sama5d4_config,
+	}, {
 		.compatible = "atmel,sama5d2-i2c",
 		.data = &sama5d2_config,
 	}, {
-- 
2.5.0

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

* [PATCH 2/4] i2c: at91: update bindings documention
  2015-12-02 10:39 ` Ludovic Desroches
  (?)
@ 2015-12-02 10:39   ` Ludovic Desroches
  -1 siblings, 0 replies; 26+ messages in thread
From: Ludovic Desroches @ 2015-12-02 10:39 UTC (permalink / raw)
  To: wsa, nicolas.ferre, alexandre.belloni
  Cc: linux-i2c, linux-kernel, plagnioj, linux-arm-kernel, devicetree,
	Ludovic Desroches

The i2c-sda-hold-time-ns property is supported from atmel,sama5d4-i2c.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 Documentation/devicetree/bindings/i2c/i2c-at91.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/i2c/i2c-at91.txt b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
index 6e81dc1..67c6f2e 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-at91.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
@@ -3,7 +3,7 @@ I2C for Atmel platforms
 Required properties :
 - compatible : Must be "atmel,at91rm9200-i2c", "atmel,at91sam9261-i2c",
      "atmel,at91sam9260-i2c", "atmel,at91sam9g20-i2c", "atmel,at91sam9g10-i2c",
-     "atmel,at91sam9x5-i2c" or "atmel,sama5d2-i2c"
+     "atmel,at91sam9x5-i2c", "atmel,sama5d4-i2c" or "atmel,sama5d2-i2c"
 - reg: physical base address of the controller and length of memory mapped
      region.
 - interrupts: interrupt number to the cpu.
@@ -17,6 +17,7 @@ Optional properties:
 - dma-names: should contain "tx" and "rx".
 - atmel,fifo-size: maximum number of data the RX and TX FIFOs can store for FIFO
   capable I2C controllers.
+- i2c-sda-hold-time-ns: TWD hold time, only available from "atmel,sama5d4-i2c".
 - Child nodes conforming to i2c bus binding
 
 Examples :
@@ -52,6 +53,7 @@ i2c0: i2c@f8034600 {
 	#size-cells = <0>;
 	clocks = <&flx0>;
 	atmel,fifo-size = <16>;
+	i2c-sda-hold-time-ns = <336>;
 
 	wm8731: wm8731@1a {
 		compatible = "wm8731";
-- 
2.5.0


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

* [PATCH 2/4] i2c: at91: update bindings documention
@ 2015-12-02 10:39   ` Ludovic Desroches
  0 siblings, 0 replies; 26+ messages in thread
From: Ludovic Desroches @ 2015-12-02 10:39 UTC (permalink / raw)
  To: wsa, nicolas.ferre, alexandre.belloni
  Cc: linux-i2c, linux-kernel, plagnioj, linux-arm-kernel, devicetree,
	Ludovic Desroches

The i2c-sda-hold-time-ns property is supported from atmel,sama5d4-i2c.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 Documentation/devicetree/bindings/i2c/i2c-at91.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/i2c/i2c-at91.txt b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
index 6e81dc1..67c6f2e 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-at91.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
@@ -3,7 +3,7 @@ I2C for Atmel platforms
 Required properties :
 - compatible : Must be "atmel,at91rm9200-i2c", "atmel,at91sam9261-i2c",
      "atmel,at91sam9260-i2c", "atmel,at91sam9g20-i2c", "atmel,at91sam9g10-i2c",
-     "atmel,at91sam9x5-i2c" or "atmel,sama5d2-i2c"
+     "atmel,at91sam9x5-i2c", "atmel,sama5d4-i2c" or "atmel,sama5d2-i2c"
 - reg: physical base address of the controller and length of memory mapped
      region.
 - interrupts: interrupt number to the cpu.
@@ -17,6 +17,7 @@ Optional properties:
 - dma-names: should contain "tx" and "rx".
 - atmel,fifo-size: maximum number of data the RX and TX FIFOs can store for FIFO
   capable I2C controllers.
+- i2c-sda-hold-time-ns: TWD hold time, only available from "atmel,sama5d4-i2c".
 - Child nodes conforming to i2c bus binding
 
 Examples :
@@ -52,6 +53,7 @@ i2c0: i2c@f8034600 {
 	#size-cells = <0>;
 	clocks = <&flx0>;
 	atmel,fifo-size = <16>;
+	i2c-sda-hold-time-ns = <336>;
 
 	wm8731: wm8731@1a {
 		compatible = "wm8731";
-- 
2.5.0

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

* [PATCH 2/4] i2c: at91: update bindings documention
@ 2015-12-02 10:39   ` Ludovic Desroches
  0 siblings, 0 replies; 26+ messages in thread
From: Ludovic Desroches @ 2015-12-02 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

The i2c-sda-hold-time-ns property is supported from atmel,sama5d4-i2c.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 Documentation/devicetree/bindings/i2c/i2c-at91.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/i2c/i2c-at91.txt b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
index 6e81dc1..67c6f2e 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-at91.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
@@ -3,7 +3,7 @@ I2C for Atmel platforms
 Required properties :
 - compatible : Must be "atmel,at91rm9200-i2c", "atmel,at91sam9261-i2c",
      "atmel,at91sam9260-i2c", "atmel,at91sam9g20-i2c", "atmel,at91sam9g10-i2c",
-     "atmel,at91sam9x5-i2c" or "atmel,sama5d2-i2c"
+     "atmel,at91sam9x5-i2c", "atmel,sama5d4-i2c" or "atmel,sama5d2-i2c"
 - reg: physical base address of the controller and length of memory mapped
      region.
 - interrupts: interrupt number to the cpu.
@@ -17,6 +17,7 @@ Optional properties:
 - dma-names: should contain "tx" and "rx".
 - atmel,fifo-size: maximum number of data the RX and TX FIFOs can store for FIFO
   capable I2C controllers.
+- i2c-sda-hold-time-ns: TWD hold time, only available from "atmel,sama5d4-i2c".
 - Child nodes conforming to i2c bus binding
 
 Examples :
@@ -52,6 +53,7 @@ i2c0: i2c at f8034600 {
 	#size-cells = <0>;
 	clocks = <&flx0>;
 	atmel,fifo-size = <16>;
+	i2c-sda-hold-time-ns = <336>;
 
 	wm8731: wm8731 at 1a {
 		compatible = "wm8731";
-- 
2.5.0

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

* [PATCH 3/4] ARM: at91/dt: sama5d4: update i2c compatible string
  2015-12-02 10:39 ` Ludovic Desroches
  (?)
@ 2015-12-02 10:39   ` Ludovic Desroches
  -1 siblings, 0 replies; 26+ messages in thread
From: Ludovic Desroches @ 2015-12-02 10:39 UTC (permalink / raw)
  To: wsa, nicolas.ferre, alexandre.belloni
  Cc: linux-i2c, linux-kernel, plagnioj, linux-arm-kernel, devicetree,
	Ludovic Desroches

A new compatible string has been introduced: atmel,sama5d4-i2c. It
allows to use the i2c-sda-hold-time-ns property if needed.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 arch/arm/boot/dts/sama5d4.dtsi | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/sama5d4.dtsi b/arch/arm/boot/dts/sama5d4.dtsi
index 2193637..83d7e7c 100644
--- a/arch/arm/boot/dts/sama5d4.dtsi
+++ b/arch/arm/boot/dts/sama5d4.dtsi
@@ -916,7 +916,7 @@
 			};
 
 			i2c0: i2c@f8014000 {
-				compatible = "atmel,at91sam9x5-i2c";
+				compatible = "atmel,sama5d4-i2c";
 				reg = <0xf8014000 0x4000>;
 				interrupts = <32 IRQ_TYPE_LEVEL_HIGH 6>;
 				dmas = <&dma1
@@ -935,7 +935,7 @@
 			};
 
 			i2c1: i2c@f8018000 {
-				compatible = "atmel,at91sam9x5-i2c";
+				compatible = "atmel,sama5d4-i2c";
 				reg = <0xf8018000 0x4000>;
 				interrupts = <33 IRQ_TYPE_LEVEL_HIGH 6>;
 				dmas = <&dma1
@@ -975,7 +975,7 @@
 			};
 
 			i2c2: i2c@f8024000 {
-				compatible = "atmel,at91sam9x5-i2c";
+				compatible = "atmel,sama5d4-i2c";
 				reg = <0xf8024000 0x4000>;
 				interrupts = <34 IRQ_TYPE_LEVEL_HIGH 6>;
 				dmas = <&dma1
-- 
2.5.0


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

* [PATCH 3/4] ARM: at91/dt: sama5d4: update i2c compatible string
@ 2015-12-02 10:39   ` Ludovic Desroches
  0 siblings, 0 replies; 26+ messages in thread
From: Ludovic Desroches @ 2015-12-02 10:39 UTC (permalink / raw)
  To: wsa, nicolas.ferre, alexandre.belloni
  Cc: linux-i2c, linux-kernel, plagnioj, linux-arm-kernel, devicetree,
	Ludovic Desroches

A new compatible string has been introduced: atmel,sama5d4-i2c. It
allows to use the i2c-sda-hold-time-ns property if needed.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 arch/arm/boot/dts/sama5d4.dtsi | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/sama5d4.dtsi b/arch/arm/boot/dts/sama5d4.dtsi
index 2193637..83d7e7c 100644
--- a/arch/arm/boot/dts/sama5d4.dtsi
+++ b/arch/arm/boot/dts/sama5d4.dtsi
@@ -916,7 +916,7 @@
 			};
 
 			i2c0: i2c@f8014000 {
-				compatible = "atmel,at91sam9x5-i2c";
+				compatible = "atmel,sama5d4-i2c";
 				reg = <0xf8014000 0x4000>;
 				interrupts = <32 IRQ_TYPE_LEVEL_HIGH 6>;
 				dmas = <&dma1
@@ -935,7 +935,7 @@
 			};
 
 			i2c1: i2c@f8018000 {
-				compatible = "atmel,at91sam9x5-i2c";
+				compatible = "atmel,sama5d4-i2c";
 				reg = <0xf8018000 0x4000>;
 				interrupts = <33 IRQ_TYPE_LEVEL_HIGH 6>;
 				dmas = <&dma1
@@ -975,7 +975,7 @@
 			};
 
 			i2c2: i2c@f8024000 {
-				compatible = "atmel,at91sam9x5-i2c";
+				compatible = "atmel,sama5d4-i2c";
 				reg = <0xf8024000 0x4000>;
 				interrupts = <34 IRQ_TYPE_LEVEL_HIGH 6>;
 				dmas = <&dma1
-- 
2.5.0

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

* [PATCH 3/4] ARM: at91/dt: sama5d4: update i2c compatible string
@ 2015-12-02 10:39   ` Ludovic Desroches
  0 siblings, 0 replies; 26+ messages in thread
From: Ludovic Desroches @ 2015-12-02 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

A new compatible string has been introduced: atmel,sama5d4-i2c. It
allows to use the i2c-sda-hold-time-ns property if needed.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 arch/arm/boot/dts/sama5d4.dtsi | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/sama5d4.dtsi b/arch/arm/boot/dts/sama5d4.dtsi
index 2193637..83d7e7c 100644
--- a/arch/arm/boot/dts/sama5d4.dtsi
+++ b/arch/arm/boot/dts/sama5d4.dtsi
@@ -916,7 +916,7 @@
 			};
 
 			i2c0: i2c at f8014000 {
-				compatible = "atmel,at91sam9x5-i2c";
+				compatible = "atmel,sama5d4-i2c";
 				reg = <0xf8014000 0x4000>;
 				interrupts = <32 IRQ_TYPE_LEVEL_HIGH 6>;
 				dmas = <&dma1
@@ -935,7 +935,7 @@
 			};
 
 			i2c1: i2c@f8018000 {
-				compatible = "atmel,at91sam9x5-i2c";
+				compatible = "atmel,sama5d4-i2c";
 				reg = <0xf8018000 0x4000>;
 				interrupts = <33 IRQ_TYPE_LEVEL_HIGH 6>;
 				dmas = <&dma1
@@ -975,7 +975,7 @@
 			};
 
 			i2c2: i2c@f8024000 {
-				compatible = "atmel,at91sam9x5-i2c";
+				compatible = "atmel,sama5d4-i2c";
 				reg = <0xf8024000 0x4000>;
 				interrupts = <34 IRQ_TYPE_LEVEL_HIGH 6>;
 				dmas = <&dma1
-- 
2.5.0

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

* [PATCH 4/4] ARM: at91/dt: sama5d2 Xplained: pmic needs a specific sda hold time
@ 2015-12-02 10:39   ` Ludovic Desroches
  0 siblings, 0 replies; 26+ messages in thread
From: Ludovic Desroches @ 2015-12-02 10:39 UTC (permalink / raw)
  To: wsa, nicolas.ferre, alexandre.belloni
  Cc: linux-i2c, linux-kernel, plagnioj, linux-arm-kernel, devicetree,
	Ludovic Desroches

Data have to been hold longer for the PMIC device.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 arch/arm/boot/dts/at91-sama5d2_xplained.dts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/at91-sama5d2_xplained.dts b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
index ad6de73..9bced00 100644
--- a/arch/arm/boot/dts/at91-sama5d2_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
@@ -129,6 +129,7 @@
 				dmas = <0>, <0>;
 				pinctrl-names = "default";
 				pinctrl-0 = <&pinctrl_i2c0_default>;
+				i2c-sda-hold-time-ns = <350>;
 				status = "okay";
 
 				pmic: act8865@5b {
-- 
2.5.0


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

* [PATCH 4/4] ARM: at91/dt: sama5d2 Xplained: pmic needs a specific sda hold time
@ 2015-12-02 10:39   ` Ludovic Desroches
  0 siblings, 0 replies; 26+ messages in thread
From: Ludovic Desroches @ 2015-12-02 10:39 UTC (permalink / raw)
  To: wsa-z923LK4zBo2bacvFa/9K2g, nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	plagnioj-sclMFOaUSTBWk0Htik3J/w,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Ludovic Desroches

Data have to been hold longer for the PMIC device.

Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
---
 arch/arm/boot/dts/at91-sama5d2_xplained.dts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/at91-sama5d2_xplained.dts b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
index ad6de73..9bced00 100644
--- a/arch/arm/boot/dts/at91-sama5d2_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
@@ -129,6 +129,7 @@
 				dmas = <0>, <0>;
 				pinctrl-names = "default";
 				pinctrl-0 = <&pinctrl_i2c0_default>;
+				i2c-sda-hold-time-ns = <350>;
 				status = "okay";
 
 				pmic: act8865@5b {
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 4/4] ARM: at91/dt: sama5d2 Xplained: pmic needs a specific sda hold time
@ 2015-12-02 10:39   ` Ludovic Desroches
  0 siblings, 0 replies; 26+ messages in thread
From: Ludovic Desroches @ 2015-12-02 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

Data have to been hold longer for the PMIC device.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 arch/arm/boot/dts/at91-sama5d2_xplained.dts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/at91-sama5d2_xplained.dts b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
index ad6de73..9bced00 100644
--- a/arch/arm/boot/dts/at91-sama5d2_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
@@ -129,6 +129,7 @@
 				dmas = <0>, <0>;
 				pinctrl-names = "default";
 				pinctrl-0 = <&pinctrl_i2c0_default>;
+				i2c-sda-hold-time-ns = <350>;
 				status = "okay";
 
 				pmic: act8865 at 5b {
-- 
2.5.0

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

* Re: [PATCH 1/4] i2c: at91: add upport for the HOLD field
  2015-12-02 10:39 ` Ludovic Desroches
  (?)
@ 2015-12-02 11:01   ` Nicolas Ferre
  -1 siblings, 0 replies; 26+ messages in thread
From: Nicolas Ferre @ 2015-12-02 11:01 UTC (permalink / raw)
  To: Ludovic Desroches, wsa, alexandre.belloni
  Cc: linux-i2c, linux-kernel, plagnioj, linux-arm-kernel, devicetree

Le 02/12/2015 11:39, Ludovic Desroches a écrit :
> The hold field allows to configure the data hold time which can be set
> with the help of the generic binding 'i2c-sda-hold-time-ns'. This
> feature has been introduced with SAMA5D4 SoC family.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  drivers/i2c/busses/i2c-at91.c | 54 ++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 51 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index 10835d1..09e1690 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -64,6 +64,7 @@
>  #define	AT91_TWI_IADR		0x000c	/* Internal Address Register */
>  
>  #define	AT91_TWI_CWGR		0x0010	/* Clock Waveform Generator Reg */
> +#define	AT91_TWI_CWGR_HOLD(x)	(((x) & 0x1f) << 24)

I would have defined MAX_HOLD here and used it in the mask above...


>  
>  #define	AT91_TWI_SR		0x0020	/* Status Register */
>  #define	AT91_TWI_TXCOMP		BIT(0)	/* Transmission Complete */
> @@ -110,6 +111,7 @@ struct at91_twi_pdata {
>  	unsigned clk_offset;
>  	bool has_unre_flag;
>  	bool has_alt_cmd;
> +	bool has_hold_field;
>  	struct at_dma_slave dma_slave;
>  };
>  
> @@ -187,10 +189,13 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
>   */
>  static void at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
>  {
> -	int ckdiv, cdiv, div;
> +	int ckdiv, cdiv, div, hold = 0;
>  	struct at91_twi_pdata *pdata = dev->pdata;
>  	int offset = pdata->clk_offset;
>  	int max_ckdiv = pdata->clk_max_div;
> +	u32 twd_hold_time_ns = 0;
> +
> +#define MAX_HOLD 31

Instead of here ^^

>  
>  	div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
>  				       2 * twi_clk) - offset);
> @@ -204,8 +209,33 @@ static void at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
>  		cdiv = 255;
>  	}
>  
> -	dev->twi_cwgr_reg = (ckdiv << 16) | (cdiv << 8) | cdiv;
> -	dev_dbg(dev->dev, "cdiv %d ckdiv %d\n", cdiv, ckdiv);
> +	if (pdata->has_hold_field) {
> +		of_property_read_u32(dev->dev->of_node, "i2c-sda-hold-time-ns",
> +				     &twd_hold_time_ns);
> +
> +		/*
> +		 * hold time = HOLD + 3 x T_peripheral_clock
> +		 * Use clk rate in kHz to prevent overflows when computing
> +		 * hold.
> +		 */
> +		hold = DIV_ROUND_UP(twd_hold_time_ns
> +				    * (clk_get_rate(dev->clk) / 1000), 1000000);
> +		hold -= 3;
> +		if (hold < 0)
> +			hold = 0;
> +		if (hold > MAX_HOLD) {
> +			dev_warn(dev->dev,
> +				 "HOLD field set to its maximum value (%d instead of %d)\n",
> +				 MAX_HOLD, hold);
> +			hold = MAX_HOLD;
> +		}
> +	}
> +
> +	dev->twi_cwgr_reg = (ckdiv << 16) | (cdiv << 8) | cdiv
> +			    | AT91_TWI_CWGR_HOLD(hold);
> +
> +	dev_dbg(dev->dev, "cdiv %d ckdiv %d hold %d (%d ns)\n",
> +		cdiv, ckdiv, hold, twd_hold_time_ns);
>  }
>  
>  static void at91_twi_dma_cleanup(struct at91_twi_dev *dev)
> @@ -797,6 +827,7 @@ static struct at91_twi_pdata at91rm9200_config = {
>  	.clk_offset = 3,
>  	.has_unre_flag = true,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
>  };
>  
>  static struct at91_twi_pdata at91sam9261_config = {
> @@ -804,6 +835,7 @@ static struct at91_twi_pdata at91sam9261_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = false,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
>  };
>  
>  static struct at91_twi_pdata at91sam9260_config = {
> @@ -811,6 +843,7 @@ static struct at91_twi_pdata at91sam9260_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = false,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
>  };
>  
>  static struct at91_twi_pdata at91sam9g20_config = {
> @@ -818,6 +851,7 @@ static struct at91_twi_pdata at91sam9g20_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = false,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
>  };
>  
>  static struct at91_twi_pdata at91sam9g10_config = {
> @@ -825,6 +859,7 @@ static struct at91_twi_pdata at91sam9g10_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = false,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
>  };
>  
>  static const struct platform_device_id at91_twi_devtypes[] = {
> @@ -854,6 +889,15 @@ static struct at91_twi_pdata at91sam9x5_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = false,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
> +};
> +
> +static struct at91_twi_pdata sama5d4_config = {
> +	.clk_max_div = 7,
> +	.clk_offset = 4,
> +	.has_unre_flag = false,
> +	.has_alt_cmd = false,
> +	.has_hold_field = true,
>  };
>  
>  static struct at91_twi_pdata sama5d2_config = {
> @@ -861,6 +905,7 @@ static struct at91_twi_pdata sama5d2_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = true,
>  	.has_alt_cmd = true,
> +	.has_hold_field = true,
>  };
>  
>  static const struct of_device_id atmel_twi_dt_ids[] = {
> @@ -883,6 +928,9 @@ static const struct of_device_id atmel_twi_dt_ids[] = {
>  		.compatible = "atmel,at91sam9x5-i2c",
>  		.data = &at91sam9x5_config,
>  	}, {
> +		.compatible = "atmel,sama5d4-i2c",
> +		.data = &sama5d4_config,
> +	}, {
>  		.compatible = "atmel,sama5d2-i2c",
>  		.data = &sama5d2_config,
>  	}, {

Otherwise it's okay for me.

Bye,
-- 
Nicolas Ferre

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

* Re: [PATCH 1/4] i2c: at91: add upport for the HOLD field
@ 2015-12-02 11:01   ` Nicolas Ferre
  0 siblings, 0 replies; 26+ messages in thread
From: Nicolas Ferre @ 2015-12-02 11:01 UTC (permalink / raw)
  To: Ludovic Desroches, wsa, alexandre.belloni
  Cc: linux-i2c, linux-kernel, plagnioj, linux-arm-kernel, devicetree

Le 02/12/2015 11:39, Ludovic Desroches a écrit :
> The hold field allows to configure the data hold time which can be set
> with the help of the generic binding 'i2c-sda-hold-time-ns'. This
> feature has been introduced with SAMA5D4 SoC family.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  drivers/i2c/busses/i2c-at91.c | 54 ++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 51 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index 10835d1..09e1690 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -64,6 +64,7 @@
>  #define	AT91_TWI_IADR		0x000c	/* Internal Address Register */
>  
>  #define	AT91_TWI_CWGR		0x0010	/* Clock Waveform Generator Reg */
> +#define	AT91_TWI_CWGR_HOLD(x)	(((x) & 0x1f) << 24)

I would have defined MAX_HOLD here and used it in the mask above...


>  
>  #define	AT91_TWI_SR		0x0020	/* Status Register */
>  #define	AT91_TWI_TXCOMP		BIT(0)	/* Transmission Complete */
> @@ -110,6 +111,7 @@ struct at91_twi_pdata {
>  	unsigned clk_offset;
>  	bool has_unre_flag;
>  	bool has_alt_cmd;
> +	bool has_hold_field;
>  	struct at_dma_slave dma_slave;
>  };
>  
> @@ -187,10 +189,13 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
>   */
>  static void at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
>  {
> -	int ckdiv, cdiv, div;
> +	int ckdiv, cdiv, div, hold = 0;
>  	struct at91_twi_pdata *pdata = dev->pdata;
>  	int offset = pdata->clk_offset;
>  	int max_ckdiv = pdata->clk_max_div;
> +	u32 twd_hold_time_ns = 0;
> +
> +#define MAX_HOLD 31

Instead of here ^^

>  
>  	div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
>  				       2 * twi_clk) - offset);
> @@ -204,8 +209,33 @@ static void at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
>  		cdiv = 255;
>  	}
>  
> -	dev->twi_cwgr_reg = (ckdiv << 16) | (cdiv << 8) | cdiv;
> -	dev_dbg(dev->dev, "cdiv %d ckdiv %d\n", cdiv, ckdiv);
> +	if (pdata->has_hold_field) {
> +		of_property_read_u32(dev->dev->of_node, "i2c-sda-hold-time-ns",
> +				     &twd_hold_time_ns);
> +
> +		/*
> +		 * hold time = HOLD + 3 x T_peripheral_clock
> +		 * Use clk rate in kHz to prevent overflows when computing
> +		 * hold.
> +		 */
> +		hold = DIV_ROUND_UP(twd_hold_time_ns
> +				    * (clk_get_rate(dev->clk) / 1000), 1000000);
> +		hold -= 3;
> +		if (hold < 0)
> +			hold = 0;
> +		if (hold > MAX_HOLD) {
> +			dev_warn(dev->dev,
> +				 "HOLD field set to its maximum value (%d instead of %d)\n",
> +				 MAX_HOLD, hold);
> +			hold = MAX_HOLD;
> +		}
> +	}
> +
> +	dev->twi_cwgr_reg = (ckdiv << 16) | (cdiv << 8) | cdiv
> +			    | AT91_TWI_CWGR_HOLD(hold);
> +
> +	dev_dbg(dev->dev, "cdiv %d ckdiv %d hold %d (%d ns)\n",
> +		cdiv, ckdiv, hold, twd_hold_time_ns);
>  }
>  
>  static void at91_twi_dma_cleanup(struct at91_twi_dev *dev)
> @@ -797,6 +827,7 @@ static struct at91_twi_pdata at91rm9200_config = {
>  	.clk_offset = 3,
>  	.has_unre_flag = true,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
>  };
>  
>  static struct at91_twi_pdata at91sam9261_config = {
> @@ -804,6 +835,7 @@ static struct at91_twi_pdata at91sam9261_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = false,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
>  };
>  
>  static struct at91_twi_pdata at91sam9260_config = {
> @@ -811,6 +843,7 @@ static struct at91_twi_pdata at91sam9260_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = false,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
>  };
>  
>  static struct at91_twi_pdata at91sam9g20_config = {
> @@ -818,6 +851,7 @@ static struct at91_twi_pdata at91sam9g20_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = false,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
>  };
>  
>  static struct at91_twi_pdata at91sam9g10_config = {
> @@ -825,6 +859,7 @@ static struct at91_twi_pdata at91sam9g10_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = false,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
>  };
>  
>  static const struct platform_device_id at91_twi_devtypes[] = {
> @@ -854,6 +889,15 @@ static struct at91_twi_pdata at91sam9x5_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = false,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
> +};
> +
> +static struct at91_twi_pdata sama5d4_config = {
> +	.clk_max_div = 7,
> +	.clk_offset = 4,
> +	.has_unre_flag = false,
> +	.has_alt_cmd = false,
> +	.has_hold_field = true,
>  };
>  
>  static struct at91_twi_pdata sama5d2_config = {
> @@ -861,6 +905,7 @@ static struct at91_twi_pdata sama5d2_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = true,
>  	.has_alt_cmd = true,
> +	.has_hold_field = true,
>  };
>  
>  static const struct of_device_id atmel_twi_dt_ids[] = {
> @@ -883,6 +928,9 @@ static const struct of_device_id atmel_twi_dt_ids[] = {
>  		.compatible = "atmel,at91sam9x5-i2c",
>  		.data = &at91sam9x5_config,
>  	}, {
> +		.compatible = "atmel,sama5d4-i2c",
> +		.data = &sama5d4_config,
> +	}, {
>  		.compatible = "atmel,sama5d2-i2c",
>  		.data = &sama5d2_config,
>  	}, {

Otherwise it's okay for me.

Bye,
-- 
Nicolas Ferre

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

* [PATCH 1/4] i2c: at91: add upport for the HOLD field
@ 2015-12-02 11:01   ` Nicolas Ferre
  0 siblings, 0 replies; 26+ messages in thread
From: Nicolas Ferre @ 2015-12-02 11:01 UTC (permalink / raw)
  To: linux-arm-kernel

Le 02/12/2015 11:39, Ludovic Desroches a ?crit :
> The hold field allows to configure the data hold time which can be set
> with the help of the generic binding 'i2c-sda-hold-time-ns'. This
> feature has been introduced with SAMA5D4 SoC family.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  drivers/i2c/busses/i2c-at91.c | 54 ++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 51 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index 10835d1..09e1690 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -64,6 +64,7 @@
>  #define	AT91_TWI_IADR		0x000c	/* Internal Address Register */
>  
>  #define	AT91_TWI_CWGR		0x0010	/* Clock Waveform Generator Reg */
> +#define	AT91_TWI_CWGR_HOLD(x)	(((x) & 0x1f) << 24)

I would have defined MAX_HOLD here and used it in the mask above...


>  
>  #define	AT91_TWI_SR		0x0020	/* Status Register */
>  #define	AT91_TWI_TXCOMP		BIT(0)	/* Transmission Complete */
> @@ -110,6 +111,7 @@ struct at91_twi_pdata {
>  	unsigned clk_offset;
>  	bool has_unre_flag;
>  	bool has_alt_cmd;
> +	bool has_hold_field;
>  	struct at_dma_slave dma_slave;
>  };
>  
> @@ -187,10 +189,13 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
>   */
>  static void at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
>  {
> -	int ckdiv, cdiv, div;
> +	int ckdiv, cdiv, div, hold = 0;
>  	struct at91_twi_pdata *pdata = dev->pdata;
>  	int offset = pdata->clk_offset;
>  	int max_ckdiv = pdata->clk_max_div;
> +	u32 twd_hold_time_ns = 0;
> +
> +#define MAX_HOLD 31

Instead of here ^^

>  
>  	div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
>  				       2 * twi_clk) - offset);
> @@ -204,8 +209,33 @@ static void at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
>  		cdiv = 255;
>  	}
>  
> -	dev->twi_cwgr_reg = (ckdiv << 16) | (cdiv << 8) | cdiv;
> -	dev_dbg(dev->dev, "cdiv %d ckdiv %d\n", cdiv, ckdiv);
> +	if (pdata->has_hold_field) {
> +		of_property_read_u32(dev->dev->of_node, "i2c-sda-hold-time-ns",
> +				     &twd_hold_time_ns);
> +
> +		/*
> +		 * hold time = HOLD + 3 x T_peripheral_clock
> +		 * Use clk rate in kHz to prevent overflows when computing
> +		 * hold.
> +		 */
> +		hold = DIV_ROUND_UP(twd_hold_time_ns
> +				    * (clk_get_rate(dev->clk) / 1000), 1000000);
> +		hold -= 3;
> +		if (hold < 0)
> +			hold = 0;
> +		if (hold > MAX_HOLD) {
> +			dev_warn(dev->dev,
> +				 "HOLD field set to its maximum value (%d instead of %d)\n",
> +				 MAX_HOLD, hold);
> +			hold = MAX_HOLD;
> +		}
> +	}
> +
> +	dev->twi_cwgr_reg = (ckdiv << 16) | (cdiv << 8) | cdiv
> +			    | AT91_TWI_CWGR_HOLD(hold);
> +
> +	dev_dbg(dev->dev, "cdiv %d ckdiv %d hold %d (%d ns)\n",
> +		cdiv, ckdiv, hold, twd_hold_time_ns);
>  }
>  
>  static void at91_twi_dma_cleanup(struct at91_twi_dev *dev)
> @@ -797,6 +827,7 @@ static struct at91_twi_pdata at91rm9200_config = {
>  	.clk_offset = 3,
>  	.has_unre_flag = true,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
>  };
>  
>  static struct at91_twi_pdata at91sam9261_config = {
> @@ -804,6 +835,7 @@ static struct at91_twi_pdata at91sam9261_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = false,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
>  };
>  
>  static struct at91_twi_pdata at91sam9260_config = {
> @@ -811,6 +843,7 @@ static struct at91_twi_pdata at91sam9260_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = false,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
>  };
>  
>  static struct at91_twi_pdata at91sam9g20_config = {
> @@ -818,6 +851,7 @@ static struct at91_twi_pdata at91sam9g20_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = false,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
>  };
>  
>  static struct at91_twi_pdata at91sam9g10_config = {
> @@ -825,6 +859,7 @@ static struct at91_twi_pdata at91sam9g10_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = false,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
>  };
>  
>  static const struct platform_device_id at91_twi_devtypes[] = {
> @@ -854,6 +889,15 @@ static struct at91_twi_pdata at91sam9x5_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = false,
>  	.has_alt_cmd = false,
> +	.has_hold_field = false,
> +};
> +
> +static struct at91_twi_pdata sama5d4_config = {
> +	.clk_max_div = 7,
> +	.clk_offset = 4,
> +	.has_unre_flag = false,
> +	.has_alt_cmd = false,
> +	.has_hold_field = true,
>  };
>  
>  static struct at91_twi_pdata sama5d2_config = {
> @@ -861,6 +905,7 @@ static struct at91_twi_pdata sama5d2_config = {
>  	.clk_offset = 4,
>  	.has_unre_flag = true,
>  	.has_alt_cmd = true,
> +	.has_hold_field = true,
>  };
>  
>  static const struct of_device_id atmel_twi_dt_ids[] = {
> @@ -883,6 +928,9 @@ static const struct of_device_id atmel_twi_dt_ids[] = {
>  		.compatible = "atmel,at91sam9x5-i2c",
>  		.data = &at91sam9x5_config,
>  	}, {
> +		.compatible = "atmel,sama5d4-i2c",
> +		.data = &sama5d4_config,
> +	}, {
>  		.compatible = "atmel,sama5d2-i2c",
>  		.data = &sama5d2_config,
>  	}, {

Otherwise it's okay for me.

Bye,
-- 
Nicolas Ferre

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

* Re: [PATCH 2/4] i2c: at91: update bindings documention
@ 2015-12-02 11:04     ` Nicolas Ferre
  0 siblings, 0 replies; 26+ messages in thread
From: Nicolas Ferre @ 2015-12-02 11:04 UTC (permalink / raw)
  To: Ludovic Desroches, wsa, alexandre.belloni
  Cc: linux-i2c, linux-kernel, plagnioj, linux-arm-kernel, devicetree

Le 02/12/2015 11:39, Ludovic Desroches a écrit :
> The i2c-sda-hold-time-ns property is supported from atmel,sama5d4-i2c.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  Documentation/devicetree/bindings/i2c/i2c-at91.txt | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/i2c/i2c-at91.txt b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> index 6e81dc1..67c6f2e 100644
> --- a/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> +++ b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> @@ -3,7 +3,7 @@ I2C for Atmel platforms
>  Required properties :
>  - compatible : Must be "atmel,at91rm9200-i2c", "atmel,at91sam9261-i2c",
>       "atmel,at91sam9260-i2c", "atmel,at91sam9g20-i2c", "atmel,at91sam9g10-i2c",
> -     "atmel,at91sam9x5-i2c" or "atmel,sama5d2-i2c"
> +     "atmel,at91sam9x5-i2c", "atmel,sama5d4-i2c" or "atmel,sama5d2-i2c"
>  - reg: physical base address of the controller and length of memory mapped
>       region.
>  - interrupts: interrupt number to the cpu.
> @@ -17,6 +17,7 @@ Optional properties:
>  - dma-names: should contain "tx" and "rx".
>  - atmel,fifo-size: maximum number of data the RX and TX FIFOs can store for FIFO
>    capable I2C controllers.
> +- i2c-sda-hold-time-ns: TWD hold time, only available from "atmel,sama5d4-i2c".

Yep, but you must make it clearer that sama5d2 also has this property
available: people usually don't know that sama5d2 comes after sama5d4
over time...

Bye,

>  - Child nodes conforming to i2c bus binding
>  
>  Examples :
> @@ -52,6 +53,7 @@ i2c0: i2c@f8034600 {
>  	#size-cells = <0>;
>  	clocks = <&flx0>;
>  	atmel,fifo-size = <16>;
> +	i2c-sda-hold-time-ns = <336>;
>  
>  	wm8731: wm8731@1a {
>  		compatible = "wm8731";
> 


-- 
Nicolas Ferre

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

* Re: [PATCH 2/4] i2c: at91: update bindings documention
@ 2015-12-02 11:04     ` Nicolas Ferre
  0 siblings, 0 replies; 26+ messages in thread
From: Nicolas Ferre @ 2015-12-02 11:04 UTC (permalink / raw)
  To: Ludovic Desroches, wsa-z923LK4zBo2bacvFa/9K2g,
	alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	plagnioj-sclMFOaUSTBWk0Htik3J/w,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Le 02/12/2015 11:39, Ludovic Desroches a écrit :
> The i2c-sda-hold-time-ns property is supported from atmel,sama5d4-i2c.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/i2c/i2c-at91.txt | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/i2c/i2c-at91.txt b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> index 6e81dc1..67c6f2e 100644
> --- a/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> +++ b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> @@ -3,7 +3,7 @@ I2C for Atmel platforms
>  Required properties :
>  - compatible : Must be "atmel,at91rm9200-i2c", "atmel,at91sam9261-i2c",
>       "atmel,at91sam9260-i2c", "atmel,at91sam9g20-i2c", "atmel,at91sam9g10-i2c",
> -     "atmel,at91sam9x5-i2c" or "atmel,sama5d2-i2c"
> +     "atmel,at91sam9x5-i2c", "atmel,sama5d4-i2c" or "atmel,sama5d2-i2c"
>  - reg: physical base address of the controller and length of memory mapped
>       region.
>  - interrupts: interrupt number to the cpu.
> @@ -17,6 +17,7 @@ Optional properties:
>  - dma-names: should contain "tx" and "rx".
>  - atmel,fifo-size: maximum number of data the RX and TX FIFOs can store for FIFO
>    capable I2C controllers.
> +- i2c-sda-hold-time-ns: TWD hold time, only available from "atmel,sama5d4-i2c".

Yep, but you must make it clearer that sama5d2 also has this property
available: people usually don't know that sama5d2 comes after sama5d4
over time...

Bye,

>  - Child nodes conforming to i2c bus binding
>  
>  Examples :
> @@ -52,6 +53,7 @@ i2c0: i2c@f8034600 {
>  	#size-cells = <0>;
>  	clocks = <&flx0>;
>  	atmel,fifo-size = <16>;
> +	i2c-sda-hold-time-ns = <336>;
>  
>  	wm8731: wm8731@1a {
>  		compatible = "wm8731";
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 2/4] i2c: at91: update bindings documention
@ 2015-12-02 11:04     ` Nicolas Ferre
  0 siblings, 0 replies; 26+ messages in thread
From: Nicolas Ferre @ 2015-12-02 11:04 UTC (permalink / raw)
  To: linux-arm-kernel

Le 02/12/2015 11:39, Ludovic Desroches a ?crit :
> The i2c-sda-hold-time-ns property is supported from atmel,sama5d4-i2c.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  Documentation/devicetree/bindings/i2c/i2c-at91.txt | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/i2c/i2c-at91.txt b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> index 6e81dc1..67c6f2e 100644
> --- a/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> +++ b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> @@ -3,7 +3,7 @@ I2C for Atmel platforms
>  Required properties :
>  - compatible : Must be "atmel,at91rm9200-i2c", "atmel,at91sam9261-i2c",
>       "atmel,at91sam9260-i2c", "atmel,at91sam9g20-i2c", "atmel,at91sam9g10-i2c",
> -     "atmel,at91sam9x5-i2c" or "atmel,sama5d2-i2c"
> +     "atmel,at91sam9x5-i2c", "atmel,sama5d4-i2c" or "atmel,sama5d2-i2c"
>  - reg: physical base address of the controller and length of memory mapped
>       region.
>  - interrupts: interrupt number to the cpu.
> @@ -17,6 +17,7 @@ Optional properties:
>  - dma-names: should contain "tx" and "rx".
>  - atmel,fifo-size: maximum number of data the RX and TX FIFOs can store for FIFO
>    capable I2C controllers.
> +- i2c-sda-hold-time-ns: TWD hold time, only available from "atmel,sama5d4-i2c".

Yep, but you must make it clearer that sama5d2 also has this property
available: people usually don't know that sama5d2 comes after sama5d4
over time...

Bye,

>  - Child nodes conforming to i2c bus binding
>  
>  Examples :
> @@ -52,6 +53,7 @@ i2c0: i2c at f8034600 {
>  	#size-cells = <0>;
>  	clocks = <&flx0>;
>  	atmel,fifo-size = <16>;
> +	i2c-sda-hold-time-ns = <336>;
>  
>  	wm8731: wm8731 at 1a {
>  		compatible = "wm8731";
> 


-- 
Nicolas Ferre

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

* Re: [PATCH 3/4] ARM: at91/dt: sama5d4: update i2c compatible string
  2015-12-02 10:39   ` Ludovic Desroches
  (?)
@ 2015-12-02 11:07     ` Nicolas Ferre
  -1 siblings, 0 replies; 26+ messages in thread
From: Nicolas Ferre @ 2015-12-02 11:07 UTC (permalink / raw)
  To: Ludovic Desroches, wsa, alexandre.belloni
  Cc: linux-i2c, linux-kernel, plagnioj, linux-arm-kernel, devicetree

Le 02/12/2015 11:39, Ludovic Desroches a écrit :
> A new compatible string has been introduced: atmel,sama5d4-i2c. It
> allows to use the i2c-sda-hold-time-ns property if needed.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

Ok, we'll need to synchronize with Wolfram for the 2 remaining ones of
this series.


> ---
>  arch/arm/boot/dts/sama5d4.dtsi | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/sama5d4.dtsi b/arch/arm/boot/dts/sama5d4.dtsi
> index 2193637..83d7e7c 100644
> --- a/arch/arm/boot/dts/sama5d4.dtsi
> +++ b/arch/arm/boot/dts/sama5d4.dtsi
> @@ -916,7 +916,7 @@
>  			};
>  
>  			i2c0: i2c@f8014000 {
> -				compatible = "atmel,at91sam9x5-i2c";
> +				compatible = "atmel,sama5d4-i2c";
>  				reg = <0xf8014000 0x4000>;
>  				interrupts = <32 IRQ_TYPE_LEVEL_HIGH 6>;
>  				dmas = <&dma1
> @@ -935,7 +935,7 @@
>  			};
>  
>  			i2c1: i2c@f8018000 {
> -				compatible = "atmel,at91sam9x5-i2c";
> +				compatible = "atmel,sama5d4-i2c";
>  				reg = <0xf8018000 0x4000>;
>  				interrupts = <33 IRQ_TYPE_LEVEL_HIGH 6>;
>  				dmas = <&dma1
> @@ -975,7 +975,7 @@
>  			};
>  
>  			i2c2: i2c@f8024000 {
> -				compatible = "atmel,at91sam9x5-i2c";
> +				compatible = "atmel,sama5d4-i2c";
>  				reg = <0xf8024000 0x4000>;
>  				interrupts = <34 IRQ_TYPE_LEVEL_HIGH 6>;
>  				dmas = <&dma1
> 


-- 
Nicolas Ferre

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

* Re: [PATCH 3/4] ARM: at91/dt: sama5d4: update i2c compatible string
@ 2015-12-02 11:07     ` Nicolas Ferre
  0 siblings, 0 replies; 26+ messages in thread
From: Nicolas Ferre @ 2015-12-02 11:07 UTC (permalink / raw)
  To: Ludovic Desroches, wsa, alexandre.belloni
  Cc: linux-i2c, linux-kernel, plagnioj, linux-arm-kernel, devicetree

Le 02/12/2015 11:39, Ludovic Desroches a écrit :
> A new compatible string has been introduced: atmel,sama5d4-i2c. It
> allows to use the i2c-sda-hold-time-ns property if needed.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

Ok, we'll need to synchronize with Wolfram for the 2 remaining ones of
this series.


> ---
>  arch/arm/boot/dts/sama5d4.dtsi | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/sama5d4.dtsi b/arch/arm/boot/dts/sama5d4.dtsi
> index 2193637..83d7e7c 100644
> --- a/arch/arm/boot/dts/sama5d4.dtsi
> +++ b/arch/arm/boot/dts/sama5d4.dtsi
> @@ -916,7 +916,7 @@
>  			};
>  
>  			i2c0: i2c@f8014000 {
> -				compatible = "atmel,at91sam9x5-i2c";
> +				compatible = "atmel,sama5d4-i2c";
>  				reg = <0xf8014000 0x4000>;
>  				interrupts = <32 IRQ_TYPE_LEVEL_HIGH 6>;
>  				dmas = <&dma1
> @@ -935,7 +935,7 @@
>  			};
>  
>  			i2c1: i2c@f8018000 {
> -				compatible = "atmel,at91sam9x5-i2c";
> +				compatible = "atmel,sama5d4-i2c";
>  				reg = <0xf8018000 0x4000>;
>  				interrupts = <33 IRQ_TYPE_LEVEL_HIGH 6>;
>  				dmas = <&dma1
> @@ -975,7 +975,7 @@
>  			};
>  
>  			i2c2: i2c@f8024000 {
> -				compatible = "atmel,at91sam9x5-i2c";
> +				compatible = "atmel,sama5d4-i2c";
>  				reg = <0xf8024000 0x4000>;
>  				interrupts = <34 IRQ_TYPE_LEVEL_HIGH 6>;
>  				dmas = <&dma1
> 


-- 
Nicolas Ferre

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

* [PATCH 3/4] ARM: at91/dt: sama5d4: update i2c compatible string
@ 2015-12-02 11:07     ` Nicolas Ferre
  0 siblings, 0 replies; 26+ messages in thread
From: Nicolas Ferre @ 2015-12-02 11:07 UTC (permalink / raw)
  To: linux-arm-kernel

Le 02/12/2015 11:39, Ludovic Desroches a ?crit :
> A new compatible string has been introduced: atmel,sama5d4-i2c. It
> allows to use the i2c-sda-hold-time-ns property if needed.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

Ok, we'll need to synchronize with Wolfram for the 2 remaining ones of
this series.


> ---
>  arch/arm/boot/dts/sama5d4.dtsi | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/sama5d4.dtsi b/arch/arm/boot/dts/sama5d4.dtsi
> index 2193637..83d7e7c 100644
> --- a/arch/arm/boot/dts/sama5d4.dtsi
> +++ b/arch/arm/boot/dts/sama5d4.dtsi
> @@ -916,7 +916,7 @@
>  			};
>  
>  			i2c0: i2c at f8014000 {
> -				compatible = "atmel,at91sam9x5-i2c";
> +				compatible = "atmel,sama5d4-i2c";
>  				reg = <0xf8014000 0x4000>;
>  				interrupts = <32 IRQ_TYPE_LEVEL_HIGH 6>;
>  				dmas = <&dma1
> @@ -935,7 +935,7 @@
>  			};
>  
>  			i2c1: i2c at f8018000 {
> -				compatible = "atmel,at91sam9x5-i2c";
> +				compatible = "atmel,sama5d4-i2c";
>  				reg = <0xf8018000 0x4000>;
>  				interrupts = <33 IRQ_TYPE_LEVEL_HIGH 6>;
>  				dmas = <&dma1
> @@ -975,7 +975,7 @@
>  			};
>  
>  			i2c2: i2c at f8024000 {
> -				compatible = "atmel,at91sam9x5-i2c";
> +				compatible = "atmel,sama5d4-i2c";
>  				reg = <0xf8024000 0x4000>;
>  				interrupts = <34 IRQ_TYPE_LEVEL_HIGH 6>;
>  				dmas = <&dma1
> 


-- 
Nicolas Ferre

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

* Re: [PATCH 4/4] ARM: at91/dt: sama5d2 Xplained: pmic needs a specific sda hold time
  2015-12-02 10:39   ` Ludovic Desroches
  (?)
@ 2015-12-02 11:08     ` Nicolas Ferre
  -1 siblings, 0 replies; 26+ messages in thread
From: Nicolas Ferre @ 2015-12-02 11:08 UTC (permalink / raw)
  To: Ludovic Desroches, wsa, alexandre.belloni
  Cc: linux-i2c, linux-kernel, plagnioj, linux-arm-kernel, devicetree

Le 02/12/2015 11:39, Ludovic Desroches a écrit :
> Data have to been hold longer for the PMIC device.

s/been/be/

It can also be interesting to know where the value comes from...


> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  arch/arm/boot/dts/at91-sama5d2_xplained.dts | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/boot/dts/at91-sama5d2_xplained.dts b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
> index ad6de73..9bced00 100644
> --- a/arch/arm/boot/dts/at91-sama5d2_xplained.dts
> +++ b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
> @@ -129,6 +129,7 @@
>  				dmas = <0>, <0>;
>  				pinctrl-names = "default";
>  				pinctrl-0 = <&pinctrl_i2c0_default>;
> +				i2c-sda-hold-time-ns = <350>;
>  				status = "okay";
>  
>  				pmic: act8865@5b {
> 


-- 
Nicolas Ferre

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

* Re: [PATCH 4/4] ARM: at91/dt: sama5d2 Xplained: pmic needs a specific sda hold time
@ 2015-12-02 11:08     ` Nicolas Ferre
  0 siblings, 0 replies; 26+ messages in thread
From: Nicolas Ferre @ 2015-12-02 11:08 UTC (permalink / raw)
  To: Ludovic Desroches, wsa, alexandre.belloni
  Cc: linux-i2c, linux-kernel, plagnioj, linux-arm-kernel, devicetree

Le 02/12/2015 11:39, Ludovic Desroches a écrit :
> Data have to been hold longer for the PMIC device.

s/been/be/

It can also be interesting to know where the value comes from...


> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  arch/arm/boot/dts/at91-sama5d2_xplained.dts | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/boot/dts/at91-sama5d2_xplained.dts b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
> index ad6de73..9bced00 100644
> --- a/arch/arm/boot/dts/at91-sama5d2_xplained.dts
> +++ b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
> @@ -129,6 +129,7 @@
>  				dmas = <0>, <0>;
>  				pinctrl-names = "default";
>  				pinctrl-0 = <&pinctrl_i2c0_default>;
> +				i2c-sda-hold-time-ns = <350>;
>  				status = "okay";
>  
>  				pmic: act8865@5b {
> 


-- 
Nicolas Ferre

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

* [PATCH 4/4] ARM: at91/dt: sama5d2 Xplained: pmic needs a specific sda hold time
@ 2015-12-02 11:08     ` Nicolas Ferre
  0 siblings, 0 replies; 26+ messages in thread
From: Nicolas Ferre @ 2015-12-02 11:08 UTC (permalink / raw)
  To: linux-arm-kernel

Le 02/12/2015 11:39, Ludovic Desroches a ?crit :
> Data have to been hold longer for the PMIC device.

s/been/be/

It can also be interesting to know where the value comes from...


> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  arch/arm/boot/dts/at91-sama5d2_xplained.dts | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/boot/dts/at91-sama5d2_xplained.dts b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
> index ad6de73..9bced00 100644
> --- a/arch/arm/boot/dts/at91-sama5d2_xplained.dts
> +++ b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
> @@ -129,6 +129,7 @@
>  				dmas = <0>, <0>;
>  				pinctrl-names = "default";
>  				pinctrl-0 = <&pinctrl_i2c0_default>;
> +				i2c-sda-hold-time-ns = <350>;
>  				status = "okay";
>  
>  				pmic: act8865 at 5b {
> 


-- 
Nicolas Ferre

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

* Re: [PATCH 2/4] i2c: at91: update bindings documention
  2015-12-02 10:39   ` Ludovic Desroches
@ 2015-12-02 14:28     ` Rob Herring
  -1 siblings, 0 replies; 26+ messages in thread
From: Rob Herring @ 2015-12-02 14:28 UTC (permalink / raw)
  To: Ludovic Desroches
  Cc: wsa, nicolas.ferre, alexandre.belloni, linux-i2c, linux-kernel,
	plagnioj, linux-arm-kernel, devicetree

On Wed, Dec 02, 2015 at 11:39:05AM +0100, Ludovic Desroches wrote:
> The i2c-sda-hold-time-ns property is supported from atmel,sama5d4-i2c.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Acked-by: Rob Herring <robh@kernel.org>

> ---
>  Documentation/devicetree/bindings/i2c/i2c-at91.txt | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/i2c/i2c-at91.txt b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> index 6e81dc1..67c6f2e 100644
> --- a/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> +++ b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> @@ -3,7 +3,7 @@ I2C for Atmel platforms
>  Required properties :
>  - compatible : Must be "atmel,at91rm9200-i2c", "atmel,at91sam9261-i2c",
>       "atmel,at91sam9260-i2c", "atmel,at91sam9g20-i2c", "atmel,at91sam9g10-i2c",
> -     "atmel,at91sam9x5-i2c" or "atmel,sama5d2-i2c"
> +     "atmel,at91sam9x5-i2c", "atmel,sama5d4-i2c" or "atmel,sama5d2-i2c"
>  - reg: physical base address of the controller and length of memory mapped
>       region.
>  - interrupts: interrupt number to the cpu.
> @@ -17,6 +17,7 @@ Optional properties:
>  - dma-names: should contain "tx" and "rx".
>  - atmel,fifo-size: maximum number of data the RX and TX FIFOs can store for FIFO
>    capable I2C controllers.
> +- i2c-sda-hold-time-ns: TWD hold time, only available from "atmel,sama5d4-i2c".
>  - Child nodes conforming to i2c bus binding
>  
>  Examples :
> @@ -52,6 +53,7 @@ i2c0: i2c@f8034600 {
>  	#size-cells = <0>;
>  	clocks = <&flx0>;
>  	atmel,fifo-size = <16>;
> +	i2c-sda-hold-time-ns = <336>;
>  
>  	wm8731: wm8731@1a {
>  		compatible = "wm8731";
> -- 
> 2.5.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 2/4] i2c: at91: update bindings documention
@ 2015-12-02 14:28     ` Rob Herring
  0 siblings, 0 replies; 26+ messages in thread
From: Rob Herring @ 2015-12-02 14:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Dec 02, 2015 at 11:39:05AM +0100, Ludovic Desroches wrote:
> The i2c-sda-hold-time-ns property is supported from atmel,sama5d4-i2c.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Acked-by: Rob Herring <robh@kernel.org>

> ---
>  Documentation/devicetree/bindings/i2c/i2c-at91.txt | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/i2c/i2c-at91.txt b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> index 6e81dc1..67c6f2e 100644
> --- a/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> +++ b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> @@ -3,7 +3,7 @@ I2C for Atmel platforms
>  Required properties :
>  - compatible : Must be "atmel,at91rm9200-i2c", "atmel,at91sam9261-i2c",
>       "atmel,at91sam9260-i2c", "atmel,at91sam9g20-i2c", "atmel,at91sam9g10-i2c",
> -     "atmel,at91sam9x5-i2c" or "atmel,sama5d2-i2c"
> +     "atmel,at91sam9x5-i2c", "atmel,sama5d4-i2c" or "atmel,sama5d2-i2c"
>  - reg: physical base address of the controller and length of memory mapped
>       region.
>  - interrupts: interrupt number to the cpu.
> @@ -17,6 +17,7 @@ Optional properties:
>  - dma-names: should contain "tx" and "rx".
>  - atmel,fifo-size: maximum number of data the RX and TX FIFOs can store for FIFO
>    capable I2C controllers.
> +- i2c-sda-hold-time-ns: TWD hold time, only available from "atmel,sama5d4-i2c".
>  - Child nodes conforming to i2c bus binding
>  
>  Examples :
> @@ -52,6 +53,7 @@ i2c0: i2c at f8034600 {
>  	#size-cells = <0>;
>  	clocks = <&flx0>;
>  	atmel,fifo-size = <16>;
> +	i2c-sda-hold-time-ns = <336>;
>  
>  	wm8731: wm8731 at 1a {
>  		compatible = "wm8731";
> -- 
> 2.5.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2015-12-02 14:28 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-02 10:39 [PATCH 1/4] i2c: at91: add upport for the HOLD field Ludovic Desroches
2015-12-02 10:39 ` Ludovic Desroches
2015-12-02 10:39 ` Ludovic Desroches
2015-12-02 10:39 ` [PATCH 2/4] i2c: at91: update bindings documention Ludovic Desroches
2015-12-02 10:39   ` Ludovic Desroches
2015-12-02 10:39   ` Ludovic Desroches
2015-12-02 11:04   ` Nicolas Ferre
2015-12-02 11:04     ` Nicolas Ferre
2015-12-02 11:04     ` Nicolas Ferre
2015-12-02 14:28   ` Rob Herring
2015-12-02 14:28     ` Rob Herring
2015-12-02 10:39 ` [PATCH 3/4] ARM: at91/dt: sama5d4: update i2c compatible string Ludovic Desroches
2015-12-02 10:39   ` Ludovic Desroches
2015-12-02 10:39   ` Ludovic Desroches
2015-12-02 11:07   ` Nicolas Ferre
2015-12-02 11:07     ` Nicolas Ferre
2015-12-02 11:07     ` Nicolas Ferre
2015-12-02 10:39 ` [PATCH 4/4] ARM: at91/dt: sama5d2 Xplained: pmic needs a specific sda hold time Ludovic Desroches
2015-12-02 10:39   ` Ludovic Desroches
2015-12-02 10:39   ` Ludovic Desroches
2015-12-02 11:08   ` Nicolas Ferre
2015-12-02 11:08     ` Nicolas Ferre
2015-12-02 11:08     ` Nicolas Ferre
2015-12-02 11:01 ` [PATCH 1/4] i2c: at91: add upport for the HOLD field Nicolas Ferre
2015-12-02 11:01   ` Nicolas Ferre
2015-12-02 11:01   ` Nicolas Ferre

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.