i2c: designware: Fix bus speed in !CONFIG_ACPI case
Subsystems (3)
PATCH 1/1 i2c: designware: Fix bus speed in !CONFIG_ACPI case
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 moving bus speed setting back to dw_i2c_plat_probe() and let the i2c_dw_acpi_adjust_bus_speed() adjust only speed from ACPI.
---
Hi John. Would this fix the issue you are seeing?
--- drivers/i2c/busses/i2c-designware-common.c | 17 ++--------------- drivers/i2c/busses/i2c-designware-core.h | 4 ++-- drivers/i2c/busses/i2c-designware-platdrv.c | 13 ++++++++++++- 3 files changed, 16 insertions(+), 18 deletions(-)
drivers/i2c/busses/i2c-designware-common.c +2 -15
@@ -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) +u32 i2c_dw_acpi_adjust_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;
@@ -302,18 +300,7 @@ void i2c_dw_acpi_adjust_bus_speed(struct device *device)if (acpi_speed >= supported_speeds[i])break ; } - acpi_speed = i <ARRAY_SIZE (supported_speeds) ? supported_speeds[i] :0 ; - -/* -* Find bus speed from the "clock-frequency" device property, ACPI -* or by using fast mode if neither is set. -*/ -if (acpi_speed && t->bus_freq_hz) - t->bus_freq_hz =min (t->bus_freq_hz, acpi_speed); -else if (acpi_speed || t->bus_freq_hz) - t->bus_freq_hz =max (t->bus_freq_hz, acpi_speed); -else - t->bus_freq_hz =I2C_MAX_FAST_MODE_FREQ ; +return (i <ARRAY_SIZE (supported_speeds) ? supported_speeds[i] :0 ); }EXPORT_SYMBOL_GPL (i2c_dw_acpi_adjust_bus_speed);
drivers/i2c/busses/i2c-designware-core.h +2 -2
@@ -364,8 +364,8 @@ int i2c_dw_validate_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); +u32 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) {} +static inline u32 i2c_dw_acpi_adjust_bus_speed (struct device *device) {return 0 ; }#endif
drivers/i2c/busses/i2c-designware-platdrv.c +12 -1
@@ -197,6 +197,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)struct i2c_adapter *adap;struct dw_i2c_dev *dev;struct i2c_timings *t; +u32 acpi_speed;int irq, ret; irq =platform_get_irq (pdev,0 );
@@ -228,7 +229,17 @@ 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); + acpi_speed =i2c_dw_acpi_adjust_bus_speed (&pdev->dev); +/* +* Find bus speed from the "clock-frequency" device property, ACPI +* or by using fast mode if neither is set. +*/ +if (acpi_speed && t->bus_freq_hz) + t->bus_freq_hz =min (t->bus_freq_hz, acpi_speed); +else if (acpi_speed || t->bus_freq_hz) + t->bus_freq_hz =max (t->bus_freq_hz, acpi_speed); +else + t->bus_freq_hz =I2C_MAX_FAST_MODE_FREQ ;if (pdev->dev.of_node)dw_i2c_of_configure (pdev);
Signature · 1 line
2.27.0
Andy Shevchenko
reviewerQuoted 11 lines · Jarkko Nikula
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_ACPInot set and neither speed based on "clock-frequency" device property or default fast mode is set.Fix this by moving bus speed setting back to
dw_i2c_plat_probe()and let thei2c_dw_acpi_adjust_bus_speed()adjust only speed from ACPI.
I have slightly different idea, I'll send a patch soon after testing.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Andy Shevchenko
reviewerQuoted 6 lines · Andy Shevchenko
Quoted 5 lines · Jarkko Nikula
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.
Quoted 8 lines
Quoted 6 lines
It seems the change caused the bus speed being zero when
CONFIG_ACPInot set and neither speed based on "clock-frequency" device property or default fast mode is set.Fix this by moving bus speed setting back to
dw_i2c_plat_probe()and let thei2c_dw_acpi_adjust_bus_speed()adjust only speed from ACPI.I have slightly different idea, I'll send a patch soon after testing.
Note, your patch breaks PCI case.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 11 lines · Andy Shevchenko
Quoted 10 lines · Andy Shevchenko
Quoted 9 lines · Jarkko Nikula
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_ACPInot set and neither speed based on "clock-frequency" device property or default fast mode is set.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Fix this by moving bus speed setting back to
dw_i2c_plat_probe()and let thei2c_dw_acpi_adjust_bus_speed()adjust only speed from ACPI.I have slightly different idea, I'll send a patch soon after testing.
Note, your patch breaks PCI case.
Ah, indeed. So please ignore my patch.
Signature · 1 line
Jarkko
Andy Shevchenko
reviewerQuoted 6 lines · Andy Shevchenko
Quoted 5 lines · Jarkko Nikula
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.
Quoted 8 lines
Quoted 6 lines
It seems the change caused the bus speed being zero when
CONFIG_ACPInot set and neither speed based on "clock-frequency" device property or default fast mode is set.Fix this by moving bus speed setting back to
dw_i2c_plat_probe()and let thei2c_dw_acpi_adjust_bus_speed()adjust only speed from ACPI.I have slightly different idea, I'll send a patch soon after testing.
Just sent a patch. Please, review.
Signature · 2 lines
With Best Regards, Andy Shevchenko