| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From b862ceba838786ac81aa6a295ad91a54aff6909d Mon Sep 17 00:00:00 2001 |
| 2 | From: Gao Pan <b54642@freescale.com> |
| 3 | Date: Tue, 25 Aug 2015 14:00:32 +0800 |
| 4 | Subject: [PATCH] MLK-11403: I2C: imx: restore pin setting for i2c |
| 5 | |
| 6 | restore pin setting for i2c in suspend/resume |
| 7 | |
| 8 | Signed-off-by: Gao Pan <gaopan@freescale.com> |
| 9 | (Vipul: Fixed merge conflicts) |
| 10 | Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com> |
| 11 | (cherry picked from commit 42b5aa1d72c09015d435459c6a59022255e3ef21) |
| 12 | --- |
| 13 | drivers/i2c/busses/i2c-imx.c | 19 +++++++++++++++++-- |
| 14 | 1 file changed, 17 insertions(+), 2 deletions(-) |
| 15 | |
| 16 | --- a/drivers/i2c/busses/i2c-imx.c |
| 17 | +++ b/drivers/i2c/busses/i2c-imx.c |
| 18 | @@ -1257,7 +1257,8 @@ static int __maybe_unused i2c_imx_runtim |
| 19 | { |
| 20 | struct imx_i2c_struct *i2c_imx = dev_get_drvdata(dev); |
| 21 | |
| 22 | - clk_disable(i2c_imx->clk); |
| 23 | + clk_disable_unprepare(i2c_imx->clk); |
| 24 | + pinctrl_pm_select_sleep_state(dev); |
| 25 | |
| 26 | return 0; |
| 27 | } |
| 28 | @@ -1267,14 +1268,28 @@ static int __maybe_unused i2c_imx_runtim |
| 29 | struct imx_i2c_struct *i2c_imx = dev_get_drvdata(dev); |
| 30 | int ret; |
| 31 | |
| 32 | - ret = clk_enable(i2c_imx->clk); |
| 33 | + pinctrl_pm_select_default_state(dev); |
| 34 | + ret = clk_prepare_enable(i2c_imx->clk); |
| 35 | if (ret) |
| 36 | dev_err(dev, "can't enable I2C clock, ret=%d\n", ret); |
| 37 | |
| 38 | return ret; |
| 39 | } |
| 40 | |
| 41 | +static int i2c_imx_suspend(struct device *dev) |
| 42 | +{ |
| 43 | + pinctrl_pm_select_sleep_state(dev); |
| 44 | + return 0; |
| 45 | +} |
| 46 | + |
| 47 | +static int i2c_imx_resume(struct device *dev) |
| 48 | +{ |
| 49 | + pinctrl_pm_select_default_state(dev); |
| 50 | + return 0; |
| 51 | +} |
| 52 | + |
| 53 | static const struct dev_pm_ops i2c_imx_pm_ops = { |
| 54 | + SET_SYSTEM_SLEEP_PM_OPS(i2c_imx_suspend, i2c_imx_resume) |
| 55 | SET_RUNTIME_PM_OPS(i2c_imx_runtime_suspend, |
| 56 | i2c_imx_runtime_resume, NULL) |
| 57 | }; |