Skip to contentSkip to conversation

i2c: rcar: minor upporting from BSP

PATCH Applied Wolfram Sang 3 participants 8 messages Jan 21, 2019 – Feb 5, 2019

Subsystems (3)
lore
Share & tools
lore

Wolfram Sang

author maintainer
#0 lore raw

cover i2c: rcar: minor upporting from BSP

Two small patches originally from the BSP but improved.

Wolfram Sang (2):
i2c: rcar: comment maintenance
i2c: rcar: refactor TCYC handling

 drivers/i2c/busses/i2c-rcar.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)
Signature · 1 line
2.11.0
author maintainer
#1 lore raw

PATCH 1/2 i2c: rcar: comment maintenance

Update copyright years and remove a comment which grew incorrect and useless over time.

---
 drivers/i2c/busses/i2c-rcar.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-rcar.c +2 -5
index 254e6219e538..4da7a1f6178b 100644
@@ -2,8 +2,8 @@
 /*
  * Driver for the Renesas R-Car I2C unit
  *
- * Copyright (C) 2014-15 Wolfram Sang <[email protected]>
- * Copyright (C) 2011-2015 Renesas Electronics Corporation
+ * Copyright (C) 2014-19 Wolfram Sang <[email protected]>
+ * Copyright (C) 2011-2019 Renesas Electronics Corporation
  *
  * Copyright (C) 2012-14 Renesas Solutions Corp.
  * Kuninori Morimoto <[email protected]>
@@ -355,9 +355,6 @@ static void rcar_i2c_next_msg(struct rcar_i2c_priv *priv)
 	rcar_i2c_prepare_msg(priv);
 }
 
-/*
- *		interrupt functions
- */
 static void rcar_i2c_dma_unmap(struct rcar_i2c_priv *priv)
 {
 	struct dma_chan *chan = priv->dma_direction == DMA_FROM_DEVICE
Signature · 1 line
2.11.0
author maintainer
#4 lore raw

PATCH 2/2 i2c: rcar: refactor TCYC handling

In reply to Wolfram Sang

The latest documentation made it clear that we need to initialize the TCYC value independently of DMA. Simplify the code to do that.

---
 drivers/i2c/busses/i2c-rcar.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/i2c/busses/i2c-rcar.c +6 -9
index 4da7a1f6178b..48312f22094c 100644
@@ -39,8 +39,8 @@
 #define ICSAR	0x1C	/* slave address */
 #define ICMAR	0x20	/* master address */
 #define ICRXTX	0x24	/* data port */
-#define ICDMAER	0x3c	/* DMA enable */
-#define ICFBSCR	0x38	/* first bit setup cycle */
+#define ICFBSCR	0x38	/* first bit setup cycle (Gen3) */
+#define ICDMAER	0x3c	/* DMA enable (Gen3) */
 
 /* ICSCR */
 #define SDBS	(1 << 3)	/* slave data buffer select */
@@ -83,7 +83,6 @@
 #define TMDMAE	(1 << 0)	/* DMA Master Transmitted Enable */
 
 /* ICFBSCR */
-#define TCYC06	0x04		/*  6*Tcyc delay 1st bit between SDA and SCL */
 #define TCYC17	0x0f		/* 17*Tcyc delay 1st bit between SDA and SCL */
 
 
@@ -212,6 +211,10 @@ static void rcar_i2c_init(struct rcar_i2c_priv *priv)
 	rcar_i2c_write(priv, ICMSR, 0);
 	/* start clock */
 	rcar_i2c_write(priv, ICCCR, priv->icccr);
+
+	if (priv->devtype == I2C_RCAR_GEN3)
+		rcar_i2c_write(priv, ICFBSCR, TCYC17);
+
 }
 
 static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
@@ -363,9 +366,6 @@ static void rcar_i2c_dma_unmap(struct rcar_i2c_priv *priv)
 	/* Disable DMA Master Received/Transmitted */
 	rcar_i2c_write(priv, ICDMAER, 0);
 
-	/* Reset default delay */
-	rcar_i2c_write(priv, ICFBSCR, TCYC06);
-
 	dma_unmap_single(chan->device->dev, sg_dma_address(&priv->sg),
 			 sg_dma_len(&priv->sg), priv->dma_direction);
 
@@ -461,9 +461,6 @@ static void rcar_i2c_dma(struct rcar_i2c_priv *priv)
 		return;
 	}
 
-	/* Set delay for DMA operations */
-	rcar_i2c_write(priv, ICFBSCR, TCYC17);
-
 	/* Enable DMA Master Received/Transmitted */
 	if (read)
 		rcar_i2c_write(priv, ICDMAER, RMDMAE);
Signature · 1 line
2.11.0
#5 lore raw

Re: [PATCH 2/2] i2c: rcar: refactor TCYC handling

Quoted 2 lines · Wolfram Sang

The latest documentation made it clear that we need to initialize the TCYC value independently of DMA. Simplify the code to do that.

Hi Wolfram,

I see TCYC bit 6 is no longer used after this patch. Does that warrant a mention in the changelog?

Quoted 62 lines
---
 drivers/i2c/busses/i2c-rcar.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/i2c/busses/i2c-rcar.c +6 -9
index 4da7a1f6178b..48312f22094c 100644
@@ -39,8 +39,8 @@
 #define ICSAR	0x1C	/* slave address */
 #define ICMAR	0x20	/* master address */
 #define ICRXTX	0x24	/* data port */
-#define ICDMAER	0x3c	/* DMA enable */
-#define ICFBSCR	0x38	/* first bit setup cycle */
+#define ICFBSCR	0x38	/* first bit setup cycle (Gen3) */
+#define ICDMAER	0x3c	/* DMA enable (Gen3) */
 
 /* ICSCR */
 #define SDBS	(1 << 3)	/* slave data buffer select */
@@ -83,7 +83,6 @@
 #define TMDMAE	(1 << 0)	/* DMA Master Transmitted Enable */
 
 /* ICFBSCR */
-#define TCYC06	0x04		/*  6*Tcyc delay 1st bit between SDA and SCL */
 #define TCYC17	0x0f		/* 17*Tcyc delay 1st bit between SDA and SCL */
 
 
@@ -212,6 +211,10 @@ static void rcar_i2c_init(struct rcar_i2c_priv *priv)
 	rcar_i2c_write(priv, ICMSR, 0);
 	/* start clock */
 	rcar_i2c_write(priv, ICCCR, priv->icccr);
+
+	if (priv->devtype == I2C_RCAR_GEN3)
+		rcar_i2c_write(priv, ICFBSCR, TCYC17);
+
 }
 
 static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
@@ -363,9 +366,6 @@ static void rcar_i2c_dma_unmap(struct rcar_i2c_priv *priv)
 	/* Disable DMA Master Received/Transmitted */
 	rcar_i2c_write(priv, ICDMAER, 0);
 
-	/* Reset default delay */
-	rcar_i2c_write(priv, ICFBSCR, TCYC06);
-
 	dma_unmap_single(chan->device->dev, sg_dma_address(&priv->sg),
 			 sg_dma_len(&priv->sg), priv->dma_direction);
 
@@ -461,9 +461,6 @@ static void rcar_i2c_dma(struct rcar_i2c_priv *priv)
 		return;
 	}
 
-	/* Set delay for DMA operations */
-	rcar_i2c_write(priv, ICFBSCR, TCYC17);
-
 	/* Enable DMA Master Received/Transmitted */
 	if (read)
 		rcar_i2c_write(priv, ICDMAER, RMDMAE);
Signature · 1 line
2.11.0
#6 lore raw

Re: [PATCH 2/2] i2c: rcar: refactor TCYC handling

Quoted 8 lines · Simon Horman
Quoted 2 lines · Wolfram Sang

The latest documentation made it clear that we need to initialize the TCYC value independently of DMA. Simplify the code to do that.

Hi Wolfram,

I see TCYC bit 6 is no longer used after this patch. Does that warrant a mention in the changelog?

Do you think so? The old code used TCYC06 (wrongly) for non-DMA transfers. The new code sets TCYC up "independently from DMA" <- commit message.

#7 lore raw

Re: [PATCH 2/2] i2c: rcar: refactor TCYC handling

Quoted 5 lines · Wolfram Sang
Quoted 4 lines · Simon Horman
Quoted 2 lines · Wolfram Sang

The latest documentation made it clear that we need to initialize the TCYC value independently of DMA. Simplify the code to do that.

Quoted 7 lines
Quoted 4 lines

Hi Wolfram,

I see TCYC bit 6 is no longer used after this patch. Does that warrant a mention in the changelog?

Do you think so? The old code used TCYC06 (wrongly) for non-DMA transfers. The new code sets TCYC up "independently from DMA" <- commit message.

FWIIW, the text above is much clearer to me than the original changelog. But perhaps that is more a reflection on me than anything else.