Skip to content

Commit 747bdf9

Browse files
JiShengTeohAndi Shyti
authored andcommitted
i2c: cadence: Add system suspend and resume PM support
Enable device system suspend and resume PM support, and mark the device state as suspended during system suspend to reject any data transfer. Signed-off-by: Ji Sheng Teoh <jisheng.teoh@starfivetech.com> Reviewed-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
1 parent d0e9441 commit 747bdf9

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

drivers/i2c/busses/i2c-cadence.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,18 @@ static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev)
11761176
return 0;
11771177
}
11781178

1179+
static int __maybe_unused cdns_i2c_suspend(struct device *dev)
1180+
{
1181+
struct cdns_i2c *xi2c = dev_get_drvdata(dev);
1182+
1183+
i2c_mark_adapter_suspended(&xi2c->adap);
1184+
1185+
if (!pm_runtime_status_suspended(dev))
1186+
return cdns_i2c_runtime_suspend(dev);
1187+
1188+
return 0;
1189+
}
1190+
11791191
/**
11801192
* cdns_i2c_init - Controller initialisation
11811193
* @id: Device private data structure
@@ -1219,7 +1231,28 @@ static int __maybe_unused cdns_i2c_runtime_resume(struct device *dev)
12191231
return 0;
12201232
}
12211233

1234+
static int __maybe_unused cdns_i2c_resume(struct device *dev)
1235+
{
1236+
struct cdns_i2c *xi2c = dev_get_drvdata(dev);
1237+
int err;
1238+
1239+
err = cdns_i2c_runtime_resume(dev);
1240+
if (err)
1241+
return err;
1242+
1243+
if (pm_runtime_status_suspended(dev)) {
1244+
err = cdns_i2c_runtime_suspend(dev);
1245+
if (err)
1246+
return err;
1247+
}
1248+
1249+
i2c_mark_adapter_resumed(&xi2c->adap);
1250+
1251+
return 0;
1252+
}
1253+
12221254
static const struct dev_pm_ops cdns_i2c_dev_pm_ops = {
1255+
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(cdns_i2c_suspend, cdns_i2c_resume)
12231256
SET_RUNTIME_PM_OPS(cdns_i2c_runtime_suspend,
12241257
cdns_i2c_runtime_resume, NULL)
12251258
};

0 commit comments

Comments
 (0)