Skip to content

Commit 852f719

Browse files
andy-shevwsakernel
authored andcommitted
i2c: designware: Adjust bus speed independently of ACPI
John Stultz reported that commit f9288fc ("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: f9288fc ("i2c: designware: Move ACPI parts into common module") Reported-by: John Stultz <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Acked-by: Jarkko Nikula <[email protected]> Tested-by: John Stultz <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 4877846 commit 852f719

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

drivers/i2c/busses/i2c-designware-common.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,8 @@ int i2c_dw_acpi_configure(struct device *device)
286286
}
287287
EXPORT_SYMBOL_GPL(i2c_dw_acpi_configure);
288288

289-
void i2c_dw_acpi_adjust_bus_speed(struct device *device)
289+
static u32 i2c_dw_acpi_round_bus_speed(struct device *device)
290290
{
291-
struct dw_i2c_dev *dev = dev_get_drvdata(device);
292-
struct i2c_timings *t = &dev->timings;
293291
u32 acpi_speed;
294292
int i;
295293

@@ -300,9 +298,22 @@ void i2c_dw_acpi_adjust_bus_speed(struct device *device)
300298
*/
301299
for (i = 0; i < ARRAY_SIZE(supported_speeds); i++) {
302300
if (acpi_speed >= supported_speeds[i])
303-
break;
301+
return supported_speeds[i];
304302
}
305-
acpi_speed = i < ARRAY_SIZE(supported_speeds) ? supported_speeds[i] : 0;
303+
304+
return 0;
305+
}
306+
307+
#else /* CONFIG_ACPI */
308+
309+
static inline u32 i2c_dw_acpi_round_bus_speed(struct device *device) { return 0; }
310+
311+
#endif /* CONFIG_ACPI */
312+
313+
void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev)
314+
{
315+
u32 acpi_speed = i2c_dw_acpi_round_bus_speed(dev->dev);
316+
struct i2c_timings *t = &dev->timings;
306317

307318
/*
308319
* Find bus speed from the "clock-frequency" device property, ACPI
@@ -315,9 +326,7 @@ void i2c_dw_acpi_adjust_bus_speed(struct device *device)
315326
else
316327
t->bus_freq_hz = I2C_MAX_FAST_MODE_FREQ;
317328
}
318-
EXPORT_SYMBOL_GPL(i2c_dw_acpi_adjust_bus_speed);
319-
320-
#endif /* CONFIG_ACPI */
329+
EXPORT_SYMBOL_GPL(i2c_dw_adjust_bus_speed);
321330

322331
u32 i2c_dw_scl_hcnt(u32 ic_clk, u32 tSYMBOL, u32 tf, int cond, int offset)
323332
{

drivers/i2c/busses/i2c-designware-core.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,10 @@ static inline int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev) { return 0;
361361
#endif
362362

363363
int i2c_dw_validate_speed(struct dw_i2c_dev *dev);
364+
void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev);
364365

365366
#if IS_ENABLED(CONFIG_ACPI)
366367
int i2c_dw_acpi_configure(struct device *device);
367-
void i2c_dw_acpi_adjust_bus_speed(struct device *device);
368368
#else
369369
static inline int i2c_dw_acpi_configure(struct device *device) { return -ENODEV; }
370-
static inline void i2c_dw_acpi_adjust_bus_speed(struct device *device) {}
371370
#endif

drivers/i2c/busses/i2c-designware-pcidrv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
240240
}
241241
}
242242

243-
i2c_dw_acpi_adjust_bus_speed(&pdev->dev);
243+
i2c_dw_adjust_bus_speed(dev);
244244

245245
if (has_acpi_companion(&pdev->dev))
246246
i2c_dw_acpi_configure(&pdev->dev);

drivers/i2c/busses/i2c-designware-platdrv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
228228
else
229229
i2c_parse_fw_timings(&pdev->dev, t, false);
230230

231-
i2c_dw_acpi_adjust_bus_speed(&pdev->dev);
231+
i2c_dw_adjust_bus_speed(dev);
232232

233233
if (pdev->dev.of_node)
234234
dw_i2c_of_configure(pdev);

0 commit comments

Comments
 (0)