linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/1 resend] ARM: shmobile: r8a7790: add I2C support
@ 2013-07-26 10:33 Nguyen Viet Dung
  0 siblings, 0 replies; 7+ messages in thread
From: Nguyen Viet Dung @ 2013-07-26 10:33 UTC (permalink / raw)
  To: linux-i2c, wsa; +Cc: kuninori.morimoto.gx, linux-arm-kernel

Hi Wolfram
CC Morimoto

Please consider the following patch for the r8a7790 Soc.
This patch modify I2C driver of rcar-H1 to usable on both rcar-H1 and rcar-H2.
It was developed base on the renesas-next-20130528 branch and 
have tested on the Lager board.
Input clock of I2C is peripheral module clock that is named peripheral_clk.

V2: dropped patches 2,3,4 from the previous version.

Thanks,
Nguyen viet Dung

Nguyen Viet Dung (1):
  i2c: rcar: modify I2C driver

 drivers/i2c/busses/i2c-rcar.c |   17 +++++++++++++++--
 include/linux/i2c/i2c-rcar.h  |    4 ++++
 2 files changed, 19 insertions(+), 2 deletions(-)

-- 
1.7.9.5

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

* [PATCH v2 0/1 resend] ARM: shmobile: r8a7790: add I2C support
@ 2013-08-05  7:19 Nguyen Viet Dung
       [not found] ` <1375687174-577-1-git-send-email-nv-dung-HEF513clHfp3+QwDJ9on6Q@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Nguyen Viet Dung @ 2013-08-05  7:19 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ

Hi Wolfram
CC Morimoto

Please consider the following patch for the r8a7790 Soc.
This patch modify I2C driver of rcar-H1 to usable on both rcar-H1 and rcar-H2.
It was developed base on the renesas-next-20130528 branch and 
have tested on the Lager board.
Input clock of I2C is peripheral module clock that is named peripheral_clk.

V2: dropped patches 2,3,4 from the previous version.

Thanks,
Nguyen viet Dung

Nguyen Viet Dung (1):
  i2c: rcar: modify I2C driver

 drivers/i2c/busses/i2c-rcar.c |   17 +++++++++++++++--
 include/linux/i2c/i2c-rcar.h  |    4 ++++
 2 files changed, 19 insertions(+), 2 deletions(-)

-- 
1.7.9.5

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

* [PATCH v2 1/1 resend] i2c: rcar: modify I2C driver
       [not found] ` <1375687174-577-1-git-send-email-nv-dung-HEF513clHfp3+QwDJ9on6Q@public.gmane.org>
@ 2013-08-05  7:19   ` Nguyen Viet Dung
       [not found]     ` <1375687174-577-2-git-send-email-nv-dung-HEF513clHfp3+QwDJ9on6Q@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Nguyen Viet Dung @ 2013-08-05  7:19 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ

This patch modify I2C driver of rcar-H1 to usable on both rcar-H1 and rcar-H2.

Signed-off-by: Nguyen Viet Dung <nv-dung-HEF513clHfp3+QwDJ9on6Q@public.gmane.org>
---
 drivers/i2c/busses/i2c-rcar.c |   17 +++++++++++++++--
 include/linux/i2c/i2c-rcar.h  |    4 ++++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 4ba4a95..85987c1 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -221,15 +221,28 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv,
 				    struct device *dev)
 {
 	struct clk *clkp = clk_get(NULL, "peripheral_clk");
+	struct i2c_rcar_platform_data *pdata = dev->platform_data;
 	u32 scgd, cdf;
 	u32 round, ick;
 	u32 scl;
+	u32 cdf_width;
+	u32 flags = pdata ? pdata->flags : 0;
 
 	if (!clkp) {
 		dev_err(dev, "there is no peripheral_clk\n");
 		return -EIO;
 	}
 
+	switch (flags & I2C_RCAR_FLAGS_ICCCR_MASK) {
+	default:
+	case I2C_RCAR_FLAGS_ICCCR_IS_2BIT:
+		cdf_width = 2;
+		break;
+	case I2C_RCAR_FLAGS_ICCCR_IS_3BIT:
+		cdf_width = 3;
+		break;
+	}
+
 	/*
 	 * calculate SCL clock
 	 * see
@@ -245,7 +258,7 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv,
 	 * clkp : peripheral_clk
 	 * F[]  : integer up-valuation
 	 */
-	for (cdf = 0; cdf < 4; cdf++) {
+	for (cdf = 0; cdf < (1 << cdf_width); cdf++) {
 		ick = clk_get_rate(clkp) / (1 + cdf);
 		if (ick < 20000000)
 			goto ick_find;
@@ -287,7 +300,7 @@ scgd_find:
 	/*
 	 * keep icccr value
 	 */
-	priv->icccr = (scgd << 2 | cdf);
+	priv->icccr = (scgd << (cdf_width) | cdf);
 
 	return 0;
 }
diff --git a/include/linux/i2c/i2c-rcar.h b/include/linux/i2c/i2c-rcar.h
index 496f5c2..572a6e5 100644
--- a/include/linux/i2c/i2c-rcar.h
+++ b/include/linux/i2c/i2c-rcar.h
@@ -5,6 +5,10 @@
 
 struct i2c_rcar_platform_data {
 	u32 bus_speed;
+	u32 flags;
+#define I2C_RCAR_FLAGS_ICCCR_MASK	(0xF << 0)
+#define I2C_RCAR_FLAGS_ICCCR_IS_2BIT	(0 << 0) /* default */
+#define I2C_RCAR_FLAGS_ICCCR_IS_3BIT	(1 << 0)
 };
 
 #endif /* __I2C_R_CAR_H__ */
-- 
1.7.9.5

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

* Re: [PATCH v2 1/1 resend] i2c: rcar: modify I2C driver
       [not found]     ` <1375687174-577-2-git-send-email-nv-dung-HEF513clHfp3+QwDJ9on6Q@public.gmane.org>
@ 2013-08-07 15:12       ` Wolfram Sang
  2013-08-08  1:13         ` Nguyen Viet Dung
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2013-08-07 15:12 UTC (permalink / raw)
  To: Nguyen Viet Dung
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ

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

On Mon, Aug 05, 2013 at 04:19:34PM +0900, Nguyen Viet Dung wrote:
> This patch modify I2C driver of rcar-H1 to usable on both rcar-H1 and rcar-H2.
> 
> Signed-off-by: Nguyen Viet Dung <nv-dung-HEF513clHfp3+QwDJ9on6Q@public.gmane.org>

Isn't it possible to distinguish between H1 and H2 somewhere in
hardware? Then we could skip the 'flags' variable in pdata.

Thanks,

   Wolfram

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH v2 1/1 resend] i2c: rcar: modify I2C driver
  2013-08-07 15:12       ` Wolfram Sang
@ 2013-08-08  1:13         ` Nguyen Viet Dung
       [not found]           ` <5202F0AC.4070609-HEF513clHfp3+QwDJ9on6Q@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Nguyen Viet Dung @ 2013-08-08  1:13 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ

Difference between H2 and H1 in hardware is only CDF bit of ICCCR register.
So, by using the flag variable in pdata, it is possible to distinguish 
H2 and H1.

If this method is not a common method, please tell me about common method.

Thanks,
Dung
On 08/08/2013 12:12 AM, Wolfram Sang wrote:
> On Mon, Aug 05, 2013 at 04:19:34PM +0900, Nguyen Viet Dung wrote:
>> This patch modify I2C driver of rcar-H1 to usable on both rcar-H1 and rcar-H2.
>>
>> Signed-off-by: Nguyen Viet Dung <nv-dung-HEF513clHfp3+QwDJ9on6Q@public.gmane.org>
> Isn't it possible to distinguish between H1 and H2 somewhere in
> hardware? Then we could skip the 'flags' variable in pdata.
>
> Thanks,
>
>     Wolfram

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

* Re: [PATCH v2 1/1 resend] i2c: rcar: modify I2C driver
       [not found]           ` <5202F0AC.4070609-HEF513clHfp3+QwDJ9on6Q@public.gmane.org>
@ 2013-08-08  8:12             ` Wolfram Sang
       [not found]               ` <20130808080819.GA6070-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2013-08-08  8:12 UTC (permalink / raw)
  To: Nguyen Viet Dung
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ

On Thu, Aug 08, 2013 at 10:13:16AM +0900, Nguyen Viet Dung wrote:

> Difference between H2 and H1 in hardware is only CDF bit of ICCCR register.

No IP version register? Sigh...

> If this method is not a common method, please tell me about common method.

Use a new platform_device_id and populate the driver_data with the info
needed to distinguish between the revisions. Check i2c-imx.c for an
example.

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

* Re: [PATCH v2 1/1 resend] i2c: rcar: modify I2C driver
       [not found]               ` <20130808080819.GA6070-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
@ 2013-08-08 11:39                 ` Nguyen Viet Dung
  0 siblings, 0 replies; 7+ messages in thread
From: Nguyen Viet Dung @ 2013-08-08 11:39 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ

Hi Wolffam

Thank for your advice.
I have understand what you have guided.

Time of 08/10~08/18 day is summer holiday in Japan.
Affter summer holiday, I am going modify the patch, and send again.

At that time,please check it for me.
Thanks,
Dung

On 08/08/2013 05:12 PM, Wolfram Sang wrote:
> On Thu, Aug 08, 2013 at 10:13:16AM +0900, Nguyen Viet Dung wrote:
>
>> Difference between H2 and H1 in hardware is only CDF bit of ICCCR register.
> No IP version register? Sigh...
>
>> If this method is not a common method, please tell me about common method.
> Use a new platform_device_id and populate the driver_data with the info
> needed to distinguish between the revisions. Check i2c-imx.c for an
> example.
>
>
>

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

end of thread, other threads:[~2013-08-08 11:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-05  7:19 [PATCH v2 0/1 resend] ARM: shmobile: r8a7790: add I2C support Nguyen Viet Dung
     [not found] ` <1375687174-577-1-git-send-email-nv-dung-HEF513clHfp3+QwDJ9on6Q@public.gmane.org>
2013-08-05  7:19   ` [PATCH v2 1/1 resend] i2c: rcar: modify I2C driver Nguyen Viet Dung
     [not found]     ` <1375687174-577-2-git-send-email-nv-dung-HEF513clHfp3+QwDJ9on6Q@public.gmane.org>
2013-08-07 15:12       ` Wolfram Sang
2013-08-08  1:13         ` Nguyen Viet Dung
     [not found]           ` <5202F0AC.4070609-HEF513clHfp3+QwDJ9on6Q@public.gmane.org>
2013-08-08  8:12             ` Wolfram Sang
     [not found]               ` <20130808080819.GA6070-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2013-08-08 11:39                 ` Nguyen Viet Dung
  -- strict thread matches above, loose matches on Subject: below --
2013-07-26 10:33 [PATCH v2 0/1 resend] ARM: shmobile: r8a7790: add I2C support Nguyen Viet Dung

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