Skip to content

Commit 8bfd4ec

Browse files
carstenhaitzlerwsakernel
authored andcommitted
i2c: cadence: Fix regression with bus recovery
Commit "i2c: cadence: Add standard bus recovery support" breaks for i2c devices that have no pinctrl defined. There is no requirement for this to exist in the DT. This has worked perfectly well without this before in at least 1 real usage case on hardware (Mali Komeda DPU, Cadence i2c to talk to a tda99xx phy). Adding the requirement to have pinctrl set up in the device tree (or otherwise be found) is a regression where the whole i2c device is lost entirely (in this case dropping entire devices which then leads to the drm display stack unable to find the phy for display output, thus having no drm display device and so on down the chain). This converts the above commit to an enhancement if pinctrl can be found for the i2c device, providing a timeout on read with recovery, but if not, do what used to be done rather than a fatal loss of a device. This restores the mentioned display devices to their working state again. Fixes: 58b9242 ("i2c: cadence: Add standard bus recovery support") Signed-off-by: Carsten Haitzler <[email protected]> Reviewed-by: Shubhrajyoti Datta <[email protected]> Reviewed-by: Michael Grzeschik <[email protected]> Acked-by: Michal Simek <[email protected]> [wsa: added braces to else-branch] Signed-off-by: Wolfram Sang <[email protected]>
1 parent 79ece9b commit 8bfd4ec

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/i2c/busses/i2c-cadence.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,8 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
852852
CDNS_I2C_POLL_US, CDNS_I2C_TIMEOUT_US);
853853
if (ret) {
854854
ret = -EAGAIN;
855-
i2c_recover_bus(adap);
855+
if (id->adap.bus_recovery_info)
856+
i2c_recover_bus(adap);
856857
goto out;
857858
}
858859

@@ -1263,8 +1264,13 @@ static int cdns_i2c_probe(struct platform_device *pdev)
12631264

12641265
id->rinfo.pinctrl = devm_pinctrl_get(&pdev->dev);
12651266
if (IS_ERR(id->rinfo.pinctrl)) {
1267+
int err = PTR_ERR(id->rinfo.pinctrl);
1268+
12661269
dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n");
1267-
return PTR_ERR(id->rinfo.pinctrl);
1270+
if (err != -ENODEV)
1271+
return err;
1272+
} else {
1273+
id->adap.bus_recovery_info = &id->rinfo;
12681274
}
12691275

12701276
id->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &r_mem);
@@ -1283,7 +1289,6 @@ static int cdns_i2c_probe(struct platform_device *pdev)
12831289
id->adap.retries = 3; /* Default retry value. */
12841290
id->adap.algo_data = id;
12851291
id->adap.dev.parent = &pdev->dev;
1286-
id->adap.bus_recovery_info = &id->rinfo;
12871292
init_completion(&id->xfer_done);
12881293
snprintf(id->adap.name, sizeof(id->adap.name),
12891294
"Cadence I2C at %08lx", (unsigned long)r_mem->start);

0 commit comments

Comments
 (0)