[PATCH V2 07/18] i2c: imx-lpi2c: manage irq resource request/release in runtime pm
Clark Wang
xiaoning.wang at nxp.com
Tue Apr 6 12:32:55 BST 2021
From: Fugang Duan <fugang.duan at nxp.com>
Manage irq resource request/release in runtime pm to save irq domain's
power.
Signed-off-by: Frank Li <Frank.Li at nxp.com>
Signed-off-by: Fugang Duan <fugang.duan at nxp.com>
Signed-off-by: Clark Wang <xiaoning.wang at nxp.com>
Reviewed-by: Frank Li <Frank.Li at nxp.com>
---
V2 changes:
- Change to use request_irq/free_irq.
---
drivers/i2c/busses/i2c-imx-lpi2c.c | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
index 89b7b0795f51..333209ba81c1 100644
--- a/drivers/i2c/busses/i2c-imx-lpi2c.c
+++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
@@ -94,6 +94,7 @@ enum lpi2c_imx_pincfg {
struct lpi2c_imx_struct {
struct i2c_adapter adapter;
+ int irq;
struct clk *clk_per;
struct clk *clk_ipg;
void __iomem *base;
@@ -571,7 +572,7 @@ static int lpi2c_imx_probe(struct platform_device *pdev)
{
struct lpi2c_imx_struct *lpi2c_imx;
unsigned int temp;
- int irq, ret;
+ int ret;
lpi2c_imx = devm_kzalloc(&pdev->dev, sizeof(*lpi2c_imx), GFP_KERNEL);
if (!lpi2c_imx)
@@ -581,9 +582,9 @@ static int lpi2c_imx_probe(struct platform_device *pdev)
if (IS_ERR(lpi2c_imx->base))
return PTR_ERR(lpi2c_imx->base);
- irq = platform_get_irq(pdev, 0);
- if (irq < 0)
- return irq;
+ lpi2c_imx->irq = platform_get_irq(pdev, 0);
+ if (lpi2c_imx->irq < 0)
+ return lpi2c_imx->irq;
lpi2c_imx->adapter.owner = THIS_MODULE;
lpi2c_imx->adapter.algo = &lpi2c_imx_algo;
@@ -609,13 +610,6 @@ static int lpi2c_imx_probe(struct platform_device *pdev)
if (ret)
lpi2c_imx->bitrate = I2C_MAX_STANDARD_MODE_FREQ;
- ret = devm_request_irq(&pdev->dev, irq, lpi2c_imx_isr, 0,
- pdev->name, lpi2c_imx);
- if (ret) {
- dev_err(&pdev->dev, "can't claim irq %d\n", irq);
- return ret;
- }
-
i2c_set_adapdata(&lpi2c_imx->adapter, lpi2c_imx);
platform_set_drvdata(pdev, lpi2c_imx);
@@ -668,6 +662,7 @@ static int __maybe_unused lpi2c_runtime_suspend(struct device *dev)
{
struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev);
+ free_irq(lpi2c_imx->irq, lpi2c_imx);
lpi2c_imx_clocks_unprepare(lpi2c_imx);
pinctrl_pm_select_sleep_state(dev);
@@ -677,10 +672,21 @@ static int __maybe_unused lpi2c_runtime_suspend(struct device *dev)
static int __maybe_unused lpi2c_runtime_resume(struct device *dev)
{
struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev);
+ int ret = 0;
pinctrl_pm_select_default_state(dev);
+ ret = lpi2c_imx_clocks_prepare(lpi2c_imx);
+ if (ret)
+ return ret;
- return lpi2c_imx_clocks_prepare(lpi2c_imx);
+ ret = request_irq(lpi2c_imx->irq, lpi2c_imx_isr, 0,
+ dev_name(dev), lpi2c_imx);
+ if (ret) {
+ dev_err(dev, "can't claim irq %d\n", lpi2c_imx->irq);
+ return ret;
+ }
+
+ return ret;
}
static const struct dev_pm_ops lpi2c_pm_ops = {
--
2.25.1
More information about the linux-arm-kernel
mailing list