@@ -427,12 +427,18 @@ static int i2c_init_recovery(struct i2c_adapter *adap)
struct i2c_bus_recovery_info *bri = adap->bus_recovery_info;
bool is_error_level = true;
char *err_str;
+ int ret;
if (!bri)
return 0;
- if (i2c_gpio_init_recovery(adap) == -EPROBE_DEFER)
+ if (bri->init_recovery) {
+ ret = bri->init_recovery(adap);
+ if (ret)
+ return ret;
+ } else if (i2c_gpio_init_recovery(adap) == -EPROBE_DEFER) {
return -EPROBE_DEFER;
+ }
if (!bri->recover_bus) {
err_str = "no suitable method provided";
@@ -638,6 +638,9 @@ struct i2c_timings {
* for generic GPIO recovery.
* @get_bus_free: Returns the bus free state as seen from the IP core in case it
* has a more complex internal logic than just reading SDA. Optional.
+ * @init_recovery: If specified, it will be called instead of the generic GPIO
+ * recovery initialization code. Platform may use a dummy callback to skip
+ * calling the generic code, or it may use a custom implementation.
* @prepare_recovery: This will be called before starting recovery. Platform may
* configure padmux here for SDA/SCL line or something else they want.
* @unprepare_recovery: This will be called after completing recovery. Platform
@@ -662,6 +665,7 @@ struct i2c_bus_recovery_info {
void (*set_sda)(struct i2c_adapter *adap, int val);
int (*get_bus_free)(struct i2c_adapter *adap);
+ int (*init_recovery)(struct i2c_adapter *adap);
void (*prepare_recovery)(struct i2c_adapter *adap);
void (*unprepare_recovery)(struct i2c_adapter *adap);