diff options
author | Fugang Duan <fugang.duan@nxp.com> | 2017-12-21 09:14:33 +0800 |
---|---|---|
committer | Leonard Crestez <leonard.crestez@nxp.com> | 2018-08-24 12:41:33 +0300 |
commit | 071f7e85fea877c109e746c3fd6d32adcf60cea2 (patch) | |
tree | 41fe69f69d2fcb03e86096301695357964fc9205 /drivers/i2c/busses | |
parent | 756d36ea5fdb6aa7f2b8a91354a7e33856a037c2 (diff) |
MLK-17290-02 i2c: imx-lpi2c: manage irq resource request/release in runtime pm
Manage irq resource request/release in runtime pm to save irq domain's
power.
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Tested-by: Guoniu.Zhou <guoniu.zhou@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Diffstat (limited to 'drivers/i2c/busses')
-rw-r--r-- | drivers/i2c/busses/i2c-imx-lpi2c.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index f7491ea26cde..7257e7127c71 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -112,6 +112,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; @@ -562,7 +563,7 @@ static int lpi2c_imx_probe(struct platform_device *pdev) { struct lpi2c_imx_struct *lpi2c_imx; struct resource *res; - int irq, ret; + int ret; lpi2c_imx = devm_kzalloc(&pdev->dev, sizeof(*lpi2c_imx), GFP_KERNEL); if (!lpi2c_imx) @@ -573,10 +574,10 @@ 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) { + lpi2c_imx->irq = platform_get_irq(pdev, 0); + if (lpi2c_imx->irq < 0) { dev_err(&pdev->dev, "can't get irq number\n"); - return irq; + return lpi2c_imx->irq; } lpi2c_imx->adapter.owner = THIS_MODULE; @@ -603,14 +604,6 @@ static int lpi2c_imx_probe(struct platform_device *pdev) if (ret) lpi2c_imx->bitrate = LPI2C_DEFAULT_RATE; - ret = devm_request_irq(&pdev->dev, irq, lpi2c_imx_isr, - IRQF_NO_SUSPEND, - 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); @@ -650,6 +643,7 @@ static int lpi2c_runtime_suspend(struct device *dev) { struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev); + devm_free_irq(dev, lpi2c_imx->irq, lpi2c_imx); clk_disable_unprepare(lpi2c_imx->clk_ipg); clk_disable_unprepare(lpi2c_imx->clk_per); pinctrl_pm_select_idle_state(dev); @@ -675,6 +669,14 @@ static int lpi2c_runtime_resume(struct device *dev) dev_err(dev, "can't enable I2C ipg clock, ret=%d\n", ret); } + ret = devm_request_irq(dev, lpi2c_imx->irq, lpi2c_imx_isr, + IRQF_NO_SUSPEND, + dev_name(dev), lpi2c_imx); + if (ret) { + dev_err(dev, "can't claim irq %d\n", lpi2c_imx->irq); + return ret; + } + return ret; } |