linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: designware: Allow reduce bus speed by "clock-frequency" property
@ 2016-11-10 11:37 Jarkko Nikula
  2016-11-10 14:58 ` Mika Westerberg
  2016-11-18  1:08 ` Wolfram Sang
  0 siblings, 2 replies; 3+ messages in thread
From: Jarkko Nikula @ 2016-11-10 11:37 UTC (permalink / raw)
  To: linux-i2c; +Cc: Wolfram Sang, Mika Westerberg, Andy Shevchenko, Jarkko Nikula

Allow more flexibility to bus speed selection. Now if there are I2C
slave connections defined in ACPI the speed of slowest device on the bus
will define the bus speed. However if also "clock-frequency" device
property is defined we should use the slowest of these two.

This is targeted to maker boards where developer may want to connect
slower I2C slave devices to the bus than defined in existing ACPI I2C
slave connections.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
 drivers/i2c/busses/i2c-designware-platdrv.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 0b42a12171f3..441dad6e8afa 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -176,9 +176,6 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
 	dev->irq = irq;
 	platform_set_drvdata(pdev, dev);
 
-	/* fast mode by default because of legacy reasons */
-	dev->clk_freq = 400000;
-
 	if (pdata) {
 		dev->clk_freq = pdata->i2c_scl_freq;
 	} else {
@@ -193,8 +190,16 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
 	}
 
 	acpi_speed = i2c_acpi_find_bus_speed(&pdev->dev);
-	if (acpi_speed)
-		dev->clk_freq = acpi_speed;
+	/*
+	 * Find bus speed from the "clock-frequency" device property, ACPI
+	 * or by using fast mode if neither is set.
+	 */
+	if (acpi_speed && dev->clk_freq)
+		dev->clk_freq = min(dev->clk_freq, acpi_speed);
+	else if (acpi_speed || dev->clk_freq)
+		dev->clk_freq = max(dev->clk_freq, acpi_speed);
+	else
+		dev->clk_freq = 400000;
 
 	if (has_acpi_companion(&pdev->dev))
 		dw_i2c_acpi_configure(pdev);
-- 
2.10.2

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

* Re: [PATCH] i2c: designware: Allow reduce bus speed by "clock-frequency" property
  2016-11-10 11:37 [PATCH] i2c: designware: Allow reduce bus speed by "clock-frequency" property Jarkko Nikula
@ 2016-11-10 14:58 ` Mika Westerberg
  2016-11-18  1:08 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Mika Westerberg @ 2016-11-10 14:58 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: linux-i2c, Wolfram Sang, Andy Shevchenko

On Thu, Nov 10, 2016 at 01:37:20PM +0200, Jarkko Nikula wrote:
> Allow more flexibility to bus speed selection. Now if there are I2C
> slave connections defined in ACPI the speed of slowest device on the bus
> will define the bus speed. However if also "clock-frequency" device
> property is defined we should use the slowest of these two.
> 
> This is targeted to maker boards where developer may want to connect
> slower I2C slave devices to the bus than defined in existing ACPI I2C
> slave connections.
> 
> Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

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

* Re: i2c: designware: Allow reduce bus speed by "clock-frequency" property
  2016-11-10 11:37 [PATCH] i2c: designware: Allow reduce bus speed by "clock-frequency" property Jarkko Nikula
  2016-11-10 14:58 ` Mika Westerberg
@ 2016-11-18  1:08 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2016-11-18  1:08 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: linux-i2c, Wolfram Sang, Mika Westerberg, Andy Shevchenko

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

On Thu, Nov 10, 2016 at 01:37:20PM +0200, Jarkko Nikula wrote:
> Allow more flexibility to bus speed selection. Now if there are I2C
> slave connections defined in ACPI the speed of slowest device on the bus
> will define the bus speed. However if also "clock-frequency" device
> property is defined we should use the slowest of these two.
> 
> This is targeted to maker boards where developer may want to connect
> slower I2C slave devices to the bus than defined in existing ACPI I2C
> slave connections.
> 
> Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

Applied to for-next, thanks!


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

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

end of thread, other threads:[~2016-11-18  1:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-10 11:37 [PATCH] i2c: designware: Allow reduce bus speed by "clock-frequency" property Jarkko Nikula
2016-11-10 14:58 ` Mika Westerberg
2016-11-18  1:08 ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).