i2c: designware: Adjust bus speed independently of ACPI
Subsystems (3)
Andy Shevchenko
reviewerPATCH 1/1 i2c: designware: Adjust bus speed independently of ACPI
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.
--- 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(-)
drivers/i2c/busses/i2c-designware-common.c +17 -8
@@ -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) {
drivers/i2c/busses/i2c-designware-core.h +1 -2
@@ -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
drivers/i2c/busses/i2c-designware-pcidrv.c +1 -1
@@ -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);
drivers/i2c/busses/i2c-designware-platdrv.c +1 -1
@@ -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);
Signature · 1 line
2.27.0
Quoted 16 lines · Andy Shevchenko
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 splitting
i2c_dw_acpi_adjust_bus_speed()toi2c_dw_acpi_round_bus_speed()andi2c_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 <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Quoted 7 lines
--- 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.
Quoted 10 lines · Andy Shevchenko
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 8 lines
Fix this by splitting
i2c_dw_acpi_adjust_bus_speed()toi2c_dw_acpi_round_bus_speed()andi2c_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 <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>---
This works fine for me as well! Thanks so much!
thanks
-john
Wolfram Sang
AppliedQuoted 9 lines · Andy Shevchenko
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
Fix this by splitting
i2c_dw_acpi_adjust_bus_speed()toi2c_dw_acpi_round_bus_speed()andi2c_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 <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Applied to for-current, thanks!