[COMMON] pinctrl: samsung: add pinctrl_force_sleep for sleep state configuration
authorYoungmin Nam <youngmin.nam@samsung.com>
Tue, 22 Aug 2017 06:47:38 +0000 (15:47 +0900)
committerJaehyoung Choi <jkkkkk.choi@samsung.com>
Thu, 3 May 2018 11:11:52 +0000 (20:11 +0900)
Change-Id: I608701d120774998ff771d084a0da13b1675ec9d
Signed-off-by: Youngmin Nam <youngmin.nam@samsung.com>
Signed-off-by: Hyunki Koo <hyunki00.koo@samsung.com>
drivers/pinctrl/samsung/pinctrl-samsung.c

index 70d7a2386911e2142ea735284f04d15399000258..3e44b261197102d12a45f20f06bc37c518bd4dcc 100644 (file)
@@ -1117,6 +1117,14 @@ static int __maybe_unused samsung_pinctrl_suspend(struct device *dev)
 {
        struct samsung_pinctrl_drv_data *drvdata = dev_get_drvdata(dev);
        int i;
+       int ret;
+
+       if (!drvdata->suspend)
+               return -EINVAL;
+
+       ret = pinctrl_force_sleep(drvdata->pctl_dev);
+       if (ret)
+               dev_err(drvdata->dev, "could not set sleep pinstate %d\n", ret);
 
        for (i = 0; i < drvdata->nr_banks; i++) {
                struct samsung_pin_bank *bank = &drvdata->pin_banks[i];
@@ -1202,6 +1210,10 @@ static int __maybe_unused samsung_pinctrl_resume(struct device *dev)
                                writel(bank->pm_save[type], reg + offs[type]);
        }
 
+       /* For changing state without writing register. */
+       if (!IS_ERR(drvdata->pctl_dev->p) && !IS_ERR(drvdata->pctl_dev->hog_default))
+               drvdata->pctl_dev->p->state = drvdata->pctl_dev->hog_default;
+
        if (drvdata->retention_ctrl && drvdata->retention_ctrl->disable)
                drvdata->retention_ctrl->disable(drvdata);