* [PATCH v1] i2c: designware: Adjust bus speed independently of ACPI
@ 2020-06-23 9:15 Andy Shevchenko
2020-06-23 11:21 ` Jarkko Nikula
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Andy Shevchenko @ 2020-06-23 9:15 UTC (permalink / raw)
To: Wolfram Sang, linux-i2c, Jarkko Nikula, Mika Westerberg
Cc: Andy Shevchenko, John Stultz
John Stultz reported that commit f9288fcc5c615 ("i2c: designware: Move
ACPI parts into common module") caused a regression on the HiKey board
where adv7511 HDMI bridge driver wasn't probing anymore due the I2C bus
failed to start.
It seems the change caused the bus speed being zero when CONFIG_ACPI
not set and neither speed based on "clock-frequency" device property
or default fast mode is set.
Fix this by splitting i2c_dw_acpi_adjust_bus_speed() to
i2c_dw_acpi_round_bus_speed() and i2c_dw_adjust_bus_speed(), where
the latter one has the code that runs independently of ACPI.
Fixes: f9288fcc5c615 ("i2c: designware: Move ACPI parts into common module")
Reported-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-common.c | 25 ++++++++++++++-------
drivers/i2c/busses/i2c-designware-core.h | 3 +--
drivers/i2c/busses/i2c-designware-pcidrv.c | 2 +-
drivers/i2c/busses/i2c-designware-platdrv.c | 2 +-
4 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index e3a8640db7da..3c19aada4b30 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -286,10 +286,8 @@ int i2c_dw_acpi_configure(struct device *device)
}
EXPORT_SYMBOL_GPL(i2c_dw_acpi_configure);
-void i2c_dw_acpi_adjust_bus_speed(struct device *device)
+static u32 i2c_dw_acpi_round_bus_speed(struct device *device)
{
- struct dw_i2c_dev *dev = dev_get_drvdata(device);
- struct i2c_timings *t = &dev->timings;
u32 acpi_speed;
int i;
@@ -300,9 +298,22 @@ void i2c_dw_acpi_adjust_bus_speed(struct device *device)
*/
for (i = 0; i < ARRAY_SIZE(supported_speeds); i++) {
if (acpi_speed >= supported_speeds[i])
- break;
+ return supported_speeds[i];
}
- acpi_speed = i < ARRAY_SIZE(supported_speeds) ? supported_speeds[i] : 0;
+
+ return 0;
+}
+
+#else /* CONFIG_ACPI */
+
+static inline u32 i2c_dw_acpi_round_bus_speed(struct device *device) { return 0; }
+
+#endif /* CONFIG_ACPI */
+
+void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev)
+{
+ u32 acpi_speed = i2c_dw_acpi_round_bus_speed(dev->dev);
+ struct i2c_timings *t = &dev->timings;
/*
* Find bus speed from the "clock-frequency" device property, ACPI
@@ -315,9 +326,7 @@ void i2c_dw_acpi_adjust_bus_speed(struct device *device)
else
t->bus_freq_hz = I2C_MAX_FAST_MODE_FREQ;
}
-EXPORT_SYMBOL_GPL(i2c_dw_acpi_adjust_bus_speed);
-
-#endif /* CONFIG_ACPI */
+EXPORT_SYMBOL_GPL(i2c_dw_adjust_bus_speed);
u32 i2c_dw_scl_hcnt(u32 ic_clk, u32 tSYMBOL, u32 tf, int cond, int offset)
{
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index 556673a1f61b..eb5ef4d0f463 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -361,11 +361,10 @@ static inline int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev) { return 0;
#endif
int i2c_dw_validate_speed(struct dw_i2c_dev *dev);
+void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev);
#if IS_ENABLED(CONFIG_ACPI)
int i2c_dw_acpi_configure(struct device *device);
-void i2c_dw_acpi_adjust_bus_speed(struct device *device);
#else
static inline int i2c_dw_acpi_configure(struct device *device) { return -ENODEV; }
-static inline void i2c_dw_acpi_adjust_bus_speed(struct device *device) {}
#endif
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 947c096f86e3..8522134f9ea9 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -240,7 +240,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
}
}
- i2c_dw_acpi_adjust_bus_speed(&pdev->dev);
+ i2c_dw_adjust_bus_speed(dev);
if (has_acpi_companion(&pdev->dev))
i2c_dw_acpi_configure(&pdev->dev);
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 0de4e302fc6a..c2efaaaac252 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -228,7 +228,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
else
i2c_parse_fw_timings(&pdev->dev, t, false);
- i2c_dw_acpi_adjust_bus_speed(&pdev->dev);
+ i2c_dw_adjust_bus_speed(dev);
if (pdev->dev.of_node)
dw_i2c_of_configure(pdev);
--
2.27.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v1] i2c: designware: Adjust bus speed independently of ACPI
2020-06-23 9:15 [PATCH v1] i2c: designware: Adjust bus speed independently of ACPI Andy Shevchenko
@ 2020-06-23 11:21 ` Jarkko Nikula
2020-06-23 17:35 ` John Stultz
2020-06-23 19:25 ` Wolfram Sang
2 siblings, 0 replies; 4+ messages in thread
From: Jarkko Nikula @ 2020-06-23 11:21 UTC (permalink / raw)
To: Andy Shevchenko, Wolfram Sang, linux-i2c, Mika Westerberg; +Cc: John Stultz
On 6/23/20 12:15 PM, Andy Shevchenko wrote:
> John Stultz reported that commit f9288fcc5c615 ("i2c: designware: Move
> ACPI parts into common module") caused a regression on the HiKey board
> where adv7511 HDMI bridge driver wasn't probing anymore due the I2C bus
> failed to start.
>
> It seems the change caused the bus speed being zero when CONFIG_ACPI
> not set and neither speed based on "clock-frequency" device property
> or default fast mode is set.
>
> Fix this by splitting i2c_dw_acpi_adjust_bus_speed() to
> i2c_dw_acpi_round_bus_speed() and i2c_dw_adjust_bus_speed(), where
> the latter one has the code that runs independently of ACPI.
>
> Fixes: f9288fcc5c615 ("i2c: designware: Move ACPI parts into common module")
> Reported-by: John Stultz <john.stultz@linaro.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/i2c/busses/i2c-designware-common.c | 25 ++++++++++++++-------
> drivers/i2c/busses/i2c-designware-core.h | 3 +--
> drivers/i2c/busses/i2c-designware-pcidrv.c | 2 +-
> drivers/i2c/busses/i2c-designware-platdrv.c | 2 +-
> 4 files changed, 20 insertions(+), 12 deletions(-)
>
Looks good to me. Let's wait for John's test result.
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v1] i2c: designware: Adjust bus speed independently of ACPI
2020-06-23 9:15 [PATCH v1] i2c: designware: Adjust bus speed independently of ACPI Andy Shevchenko
2020-06-23 11:21 ` Jarkko Nikula
@ 2020-06-23 17:35 ` John Stultz
2020-06-23 19:25 ` Wolfram Sang
2 siblings, 0 replies; 4+ messages in thread
From: John Stultz @ 2020-06-23 17:35 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Wolfram Sang, linux-i2c, Jarkko Nikula, Mika Westerberg
On Tue, Jun 23, 2020 at 2:15 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> John Stultz reported that commit f9288fcc5c615 ("i2c: designware: Move
> ACPI parts into common module") caused a regression on the HiKey board
> where adv7511 HDMI bridge driver wasn't probing anymore due the I2C bus
> failed to start.
>
> It seems the change caused the bus speed being zero when CONFIG_ACPI
> not set and neither speed based on "clock-frequency" device property
> or default fast mode is set.
>
> Fix this by splitting i2c_dw_acpi_adjust_bus_speed() to
> i2c_dw_acpi_round_bus_speed() and i2c_dw_adjust_bus_speed(), where
> the latter one has the code that runs independently of ACPI.
>
> Fixes: f9288fcc5c615 ("i2c: designware: Move ACPI parts into common module")
> Reported-by: John Stultz <john.stultz@linaro.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
This works fine for me as well! Thanks so much!
Tested-by: John Stultz <john.stultz@linaro.org>
thanks
-john
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v1] i2c: designware: Adjust bus speed independently of ACPI
2020-06-23 9:15 [PATCH v1] i2c: designware: Adjust bus speed independently of ACPI Andy Shevchenko
2020-06-23 11:21 ` Jarkko Nikula
2020-06-23 17:35 ` John Stultz
@ 2020-06-23 19:25 ` Wolfram Sang
2 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2020-06-23 19:25 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-i2c, Jarkko Nikula, Mika Westerberg, John Stultz
[-- Attachment #1: Type: text/plain, Size: 930 bytes --]
On Tue, Jun 23, 2020 at 12:15:01PM +0300, Andy Shevchenko wrote:
> John Stultz reported that commit f9288fcc5c615 ("i2c: designware: Move
> ACPI parts into common module") caused a regression on the HiKey board
> where adv7511 HDMI bridge driver wasn't probing anymore due the I2C bus
> failed to start.
>
> It seems the change caused the bus speed being zero when CONFIG_ACPI
> not set and neither speed based on "clock-frequency" device property
> or default fast mode is set.
>
> Fix this by splitting i2c_dw_acpi_adjust_bus_speed() to
> i2c_dw_acpi_round_bus_speed() and i2c_dw_adjust_bus_speed(), where
> the latter one has the code that runs independently of ACPI.
>
> Fixes: f9288fcc5c615 ("i2c: designware: Move ACPI parts into common module")
> Reported-by: John Stultz <john.stultz@linaro.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied to for-current, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-23 19:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-23 9:15 [PATCH v1] i2c: designware: Adjust bus speed independently of ACPI Andy Shevchenko
2020-06-23 11:21 ` Jarkko Nikula
2020-06-23 17:35 ` John Stultz
2020-06-23 19:25 ` 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).