All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] i2c: designware: Calculate *CNT for Fast Mode Plus
@ 2020-04-07 13:34 Wan Ahmad Zainie
  2020-04-07 13:34 ` [PATCH 1/2] i2c: designware: Calculate SCL timing parameter " Wan Ahmad Zainie
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Wan Ahmad Zainie @ 2020-04-07 13:34 UTC (permalink / raw)
  To: jarkko.nikula, andriy.shevchenko, mika.westerberg
  Cc: linux-i2c, wan.ahmad.zainie.wan.mohamad

Hi.

Custom parameters for HCNT/LCNT are not available for OF based system.
We will use existing SCL timing parameter calculation functions to
get HCNT/LCNT value for Fast Mode Plus and High Speed Mode.

The patches were tested on Keem Bay EVM (OF based system), and using
Tiger Lake platform and Leaf Hill board to cover ACPI and PCI mode.

Thank you.

Best regards,
Zainie.


Wan Ahmad Zainie (2):
  i2c: designware: Calculate SCL timing parameter for Fast Mode Plus
  i2c: designware: Calculate SCL timing parameter for High Speed Mode

 drivers/i2c/busses/i2c-designware-master.c | 37 ++++++++++++++++++----
 1 file changed, 31 insertions(+), 6 deletions(-)

-- 
2.17.1


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

* [PATCH 1/2] i2c: designware: Calculate SCL timing parameter for Fast Mode Plus
  2020-04-07 13:34 [PATCH 0/2] i2c: designware: Calculate *CNT for Fast Mode Plus Wan Ahmad Zainie
@ 2020-04-07 13:34 ` Wan Ahmad Zainie
  2020-04-08  7:08   ` Jarkko Nikula
  2020-04-15 11:14   ` Wolfram Sang
  2020-04-07 13:34 ` [PATCH 2/2] i2c: designware: Calculate SCL timing parameter for High Speed Mode Wan Ahmad Zainie
  2020-04-07 14:56 ` [PATCH 0/2] i2c: designware: Calculate *CNT for Fast Mode Plus Andy Shevchenko
  2 siblings, 2 replies; 9+ messages in thread
From: Wan Ahmad Zainie @ 2020-04-07 13:34 UTC (permalink / raw)
  To: jarkko.nikula, andriy.shevchenko, mika.westerberg
  Cc: linux-i2c, wan.ahmad.zainie.wan.mohamad

Custom parameters for HCNT/LCNT are not available for OF based system.
Thus, we will use existing SCL timing parameter calculation functions
for Fast Mode Plus.

Signed-off-by: Wan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-designware-master.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index 3a58eef20936..23038d7272da 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -76,14 +76,27 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
 	 */
 	if (t->bus_freq_hz == 1000000) {
 		/*
-		 * Check are fast mode plus parameters available and use
-		 * fast mode if not.
+		 * Check are Fast Mode Plus parameters available. Calculate
+		 * SCL timing parameters for Fast Mode Plus if not set.
 		 */
 		if (dev->fp_hcnt && dev->fp_lcnt) {
 			dev->fs_hcnt = dev->fp_hcnt;
 			dev->fs_lcnt = dev->fp_lcnt;
-			fp_str = " Plus";
+		} else {
+			ic_clk = i2c_dw_clk_rate(dev);
+			dev->fs_hcnt =
+				i2c_dw_scl_hcnt(ic_clk,
+						260,	/* tHIGH = 260 ns */
+						sda_falling_time,
+						0,	/* DW default */
+						0);	/* No offset */
+			dev->fs_lcnt =
+				i2c_dw_scl_lcnt(ic_clk,
+						500,	/* tLOW = 500 ns */
+						scl_falling_time,
+						0);	/* No offset */
 		}
+		fp_str = " Plus";
 	}
 	/*
 	 * Calculate SCL timing parameters for fast mode if not set. They are
-- 
2.17.1


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

* [PATCH 2/2] i2c: designware: Calculate SCL timing parameter for High Speed Mode
  2020-04-07 13:34 [PATCH 0/2] i2c: designware: Calculate *CNT for Fast Mode Plus Wan Ahmad Zainie
  2020-04-07 13:34 ` [PATCH 1/2] i2c: designware: Calculate SCL timing parameter " Wan Ahmad Zainie
@ 2020-04-07 13:34 ` Wan Ahmad Zainie
  2020-04-08  7:09   ` Jarkko Nikula
  2020-04-15 11:14   ` Wolfram Sang
  2020-04-07 14:56 ` [PATCH 0/2] i2c: designware: Calculate *CNT for Fast Mode Plus Andy Shevchenko
  2 siblings, 2 replies; 9+ messages in thread
From: Wan Ahmad Zainie @ 2020-04-07 13:34 UTC (permalink / raw)
  To: jarkko.nikula, andriy.shevchenko, mika.westerberg
  Cc: linux-i2c, wan.ahmad.zainie.wan.mohamad

Custom parameters for HCNT/LCNT are not available for OF based system.
Thus, we will use existing SCL timing parameter calculation functions
for High Speed Mode too.

The value for the parameters tSYMBOL and tLOW is taken from DesignWare
DW_apb_i2c Databook v2.01a, section 3.15.4.6. The calculation should
assume higher bus load since it gives slower timing parameter.

Signed-off-by: Wan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-designware-master.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index 23038d7272da..b6c17b550d31 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -129,10 +129,22 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
 			dev->master_cfg |= DW_IC_CON_SPEED_FAST;
 			dev->hs_hcnt = 0;
 			dev->hs_lcnt = 0;
-		} else if (dev->hs_hcnt && dev->hs_lcnt) {
-			dev_dbg(dev->dev, "High Speed Mode HCNT:LCNT = %d:%d\n",
-				dev->hs_hcnt, dev->hs_lcnt);
+		} else if (!dev->hs_hcnt || !dev->hs_lcnt) {
+			ic_clk = i2c_dw_clk_rate(dev);
+			dev->hs_hcnt =
+				i2c_dw_scl_hcnt(ic_clk,
+						160,	/* tHIGH = 160 ns */
+						sda_falling_time,
+						0,	/* DW default */
+						0);	/* No offset */
+			dev->hs_lcnt =
+				i2c_dw_scl_lcnt(ic_clk,
+						320,	/* tLOW = 320 ns */
+						scl_falling_time,
+						0);	/* No offset */
 		}
+		dev_dbg(dev->dev, "High Speed Mode HCNT:LCNT = %d:%d\n",
+			dev->hs_hcnt, dev->hs_lcnt);
 	}
 
 	ret = i2c_dw_set_sda_hold(dev);
-- 
2.17.1


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

* Re: [PATCH 0/2] i2c: designware: Calculate *CNT for Fast Mode Plus
  2020-04-07 13:34 [PATCH 0/2] i2c: designware: Calculate *CNT for Fast Mode Plus Wan Ahmad Zainie
  2020-04-07 13:34 ` [PATCH 1/2] i2c: designware: Calculate SCL timing parameter " Wan Ahmad Zainie
  2020-04-07 13:34 ` [PATCH 2/2] i2c: designware: Calculate SCL timing parameter for High Speed Mode Wan Ahmad Zainie
@ 2020-04-07 14:56 ` Andy Shevchenko
  2020-04-15 11:15   ` Wolfram Sang
  2 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2020-04-07 14:56 UTC (permalink / raw)
  To: Wan Ahmad Zainie; +Cc: jarkko.nikula, mika.westerberg, linux-i2c

On Tue, Apr 07, 2020 at 09:34:37PM +0800, Wan Ahmad Zainie wrote:
> Hi.
> 
> Custom parameters for HCNT/LCNT are not available for OF based system.
> We will use existing SCL timing parameter calculation functions to
> get HCNT/LCNT value for Fast Mode Plus and High Speed Mode.
> 
> The patches were tested on Keem Bay EVM (OF based system), and using
> Tiger Lake platform and Leaf Hill board to cover ACPI and PCI mode.

Wolfram, for the sake of clarification, the series has been reviewed
internally, that's why it has my tags already (though usually I ask
to Cc me and give them explicitly during external review, not everybody
follow this way).

> 
> Thank you.
> 
> Best regards,
> Zainie.
> 
> 
> Wan Ahmad Zainie (2):
>   i2c: designware: Calculate SCL timing parameter for Fast Mode Plus
>   i2c: designware: Calculate SCL timing parameter for High Speed Mode
> 
>  drivers/i2c/busses/i2c-designware-master.c | 37 ++++++++++++++++++----
>  1 file changed, 31 insertions(+), 6 deletions(-)
> 
> -- 
> 2.17.1
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 1/2] i2c: designware: Calculate SCL timing parameter for Fast Mode Plus
  2020-04-07 13:34 ` [PATCH 1/2] i2c: designware: Calculate SCL timing parameter " Wan Ahmad Zainie
@ 2020-04-08  7:08   ` Jarkko Nikula
  2020-04-15 11:14   ` Wolfram Sang
  1 sibling, 0 replies; 9+ messages in thread
From: Jarkko Nikula @ 2020-04-08  7:08 UTC (permalink / raw)
  To: Wan Ahmad Zainie, andriy.shevchenko, mika.westerberg; +Cc: linux-i2c

On 4/7/20 4:34 PM, Wan Ahmad Zainie wrote:
> Custom parameters for HCNT/LCNT are not available for OF based system.
> Thus, we will use existing SCL timing parameter calculation functions
> for Fast Mode Plus.
> 
> Signed-off-by: Wan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad@intel.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/i2c/busses/i2c-designware-master.c | 19 ++++++++++++++++---
>   1 file changed, 16 insertions(+), 3 deletions(-)
> 
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>

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

* Re: [PATCH 2/2] i2c: designware: Calculate SCL timing parameter for High Speed Mode
  2020-04-07 13:34 ` [PATCH 2/2] i2c: designware: Calculate SCL timing parameter for High Speed Mode Wan Ahmad Zainie
@ 2020-04-08  7:09   ` Jarkko Nikula
  2020-04-15 11:14   ` Wolfram Sang
  1 sibling, 0 replies; 9+ messages in thread
From: Jarkko Nikula @ 2020-04-08  7:09 UTC (permalink / raw)
  To: Wan Ahmad Zainie, andriy.shevchenko, mika.westerberg; +Cc: linux-i2c

On 4/7/20 4:34 PM, Wan Ahmad Zainie wrote:
> Custom parameters for HCNT/LCNT are not available for OF based system.
> Thus, we will use existing SCL timing parameter calculation functions
> for High Speed Mode too.
> 
> The value for the parameters tSYMBOL and tLOW is taken from DesignWare
> DW_apb_i2c Databook v2.01a, section 3.15.4.6. The calculation should
> assume higher bus load since it gives slower timing parameter.
> 
> Signed-off-by: Wan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad@intel.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/i2c/busses/i2c-designware-master.c | 18 +++++++++++++++---
>   1 file changed, 15 insertions(+), 3 deletions(-)
> 
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>

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

* Re: [PATCH 1/2] i2c: designware: Calculate SCL timing parameter for Fast Mode Plus
  2020-04-07 13:34 ` [PATCH 1/2] i2c: designware: Calculate SCL timing parameter " Wan Ahmad Zainie
  2020-04-08  7:08   ` Jarkko Nikula
@ 2020-04-15 11:14   ` Wolfram Sang
  1 sibling, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2020-04-15 11:14 UTC (permalink / raw)
  To: Wan Ahmad Zainie
  Cc: jarkko.nikula, andriy.shevchenko, mika.westerberg, linux-i2c

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

On Tue, Apr 07, 2020 at 09:34:38PM +0800, Wan Ahmad Zainie wrote:
> Custom parameters for HCNT/LCNT are not available for OF based system.
> Thus, we will use existing SCL timing parameter calculation functions
> for Fast Mode Plus.
> 
> Signed-off-by: Wan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad@intel.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Applied to for-next, thanks!


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

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

* Re: [PATCH 2/2] i2c: designware: Calculate SCL timing parameter for High Speed Mode
  2020-04-07 13:34 ` [PATCH 2/2] i2c: designware: Calculate SCL timing parameter for High Speed Mode Wan Ahmad Zainie
  2020-04-08  7:09   ` Jarkko Nikula
@ 2020-04-15 11:14   ` Wolfram Sang
  1 sibling, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2020-04-15 11:14 UTC (permalink / raw)
  To: Wan Ahmad Zainie
  Cc: jarkko.nikula, andriy.shevchenko, mika.westerberg, linux-i2c

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

On Tue, Apr 07, 2020 at 09:34:39PM +0800, Wan Ahmad Zainie wrote:
> Custom parameters for HCNT/LCNT are not available for OF based system.
> Thus, we will use existing SCL timing parameter calculation functions
> for High Speed Mode too.
> 
> The value for the parameters tSYMBOL and tLOW is taken from DesignWare
> DW_apb_i2c Databook v2.01a, section 3.15.4.6. The calculation should
> assume higher bus load since it gives slower timing parameter.
> 
> Signed-off-by: Wan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad@intel.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Applied to for-next, thanks!


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

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

* Re: [PATCH 0/2] i2c: designware: Calculate *CNT for Fast Mode Plus
  2020-04-07 14:56 ` [PATCH 0/2] i2c: designware: Calculate *CNT for Fast Mode Plus Andy Shevchenko
@ 2020-04-15 11:15   ` Wolfram Sang
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2020-04-15 11:15 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Wan Ahmad Zainie, jarkko.nikula, mika.westerberg, linux-i2c

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


> Wolfram, for the sake of clarification, the series has been reviewed
> internally, that's why it has my tags already (though usually I ask
> to Cc me and give them explicitly during external review, not everybody
> follow this way).

Thanks for the heads up! I prefer the latter way, too, but here all is
fine.


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

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

end of thread, other threads:[~2020-04-15 11:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07 13:34 [PATCH 0/2] i2c: designware: Calculate *CNT for Fast Mode Plus Wan Ahmad Zainie
2020-04-07 13:34 ` [PATCH 1/2] i2c: designware: Calculate SCL timing parameter " Wan Ahmad Zainie
2020-04-08  7:08   ` Jarkko Nikula
2020-04-15 11:14   ` Wolfram Sang
2020-04-07 13:34 ` [PATCH 2/2] i2c: designware: Calculate SCL timing parameter for High Speed Mode Wan Ahmad Zainie
2020-04-08  7:09   ` Jarkko Nikula
2020-04-15 11:14   ` Wolfram Sang
2020-04-07 14:56 ` [PATCH 0/2] i2c: designware: Calculate *CNT for Fast Mode Plus Andy Shevchenko
2020-04-15 11:15   ` Wolfram Sang

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.