i2c: mediatek: Enable i2c module clock before i2c registers access.
authorJun Gao <jun.gao@mediatek.com>
Tue, 19 Dec 2017 06:51:03 +0000 (14:51 +0800)
committerWolfram Sang <wsa@the-dreams.de>
Wed, 3 Jan 2018 23:54:02 +0000 (00:54 +0100)
Make sure i2c module clock has been enabled before i2c registers
access.

Signed-off-by: Jun Gao <jun.gao@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-mt65xx.c

index 58d6401871a94402dad6aa40bc6b9470dbb1c0b7..cf23a746cc17efeb2eaa98792b0587887c4152dc 100644 (file)
@@ -861,10 +861,19 @@ static int mtk_i2c_remove(struct platform_device *pdev)
 #ifdef CONFIG_PM_SLEEP
 static int mtk_i2c_resume(struct device *dev)
 {
+       int ret;
        struct mtk_i2c *i2c = dev_get_drvdata(dev);
 
+       ret = mtk_i2c_clock_enable(i2c);
+       if (ret) {
+               dev_err(dev, "clock enable failed!\n");
+               return ret;
+       }
+
        mtk_i2c_init_hw(i2c);
 
+       mtk_i2c_clock_disable(i2c);
+
        return 0;
 }
 #endif