All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Moon <linux.amoon@gmail.com>
To: Sangbeom Kim <sbkim73@samsung.com>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	Anand Moon <linux.amoon@gmail.com>
Subject: [PATCHv2] regulator: s2mps11: Added shutdown function to poweroff
Date: Wed, 15 Jul 2015 01:11:17 +0930	[thread overview]
Message-ID: <1436888477-3841-1-git-send-email-linux.amoon@gmail.com> (raw)

Added .shutdown function to s2mps11 to help poweroff the board successfully.

s2mps11-pmic: S2MPS11_REG_CTRL1 reg value 16:00000000000000000000000000010000

The device driver clears the register to turn off the PMIC.

Signed-off-by: Anand Moon <linux.amoon@gmail.com>

---
Console log for improper shutdown.
root@odroidxu3:~# poweroff
...
  * Unmounting temporary filesystems...                                   [ OK ]
  * Deactivating swap...                                                  [ OK ]
  * Unmounting local filesystems...                                       [ OK ]
  * Will now halt
  [  209.020280] reboot: Power down
  [  209.122039] Power down failed, please power off system manually.

Console log for proper shutdown.
root@odroidxu3:~# poweroff
...
  * Unmounting temporary filesystems...                                   [ OK ]
  * Deactivating swap...                                                  [ OK ]
  * Unmounting local filesystems...                                       [ OK ]
  * Will now halt
  [  476.283071] reboo
---
 drivers/regulator/s2mps11.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 326ffb5..823180e 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -1060,6 +1060,31 @@ out:
 	return ret;
 }
 
+static void s2mps11_pmic_shutdown(struct platform_device *pdev)
+{
+	struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
+	unsigned int reg_val, ret;
+
+	ret = regmap_read(iodev->regmap_pmic, S2MPS11_REG_CTRL1, &reg_val);
+	if (ret < 0) {
+		dev_crit(&pdev->dev, "could not read S2MPS11_REG_CTRL1 value\n");
+	} else {
+		/*
+		 * s2mps11-pmic: S2MPS11_REG_CTRL1 reg value
+		 * is 00000000000000000000000000010000
+		 * clear the S2MPS11_REG_CTRL1 0x10 value to shutdown.
+		 */
+		if (reg_val & BIT(4)) {
+			ret = regmap_update_bits(iodev->regmap_pmic,
+						 S2MPS11_REG_CTRL1,
+						 BIT(4), BIT(0));
+			if (ret)
+				dev_crit(&pdev->dev,
+					 "could not write S2MPS11_REG_CTRL1 value\n");
+		}
+	}
+}
+
 static const struct platform_device_id s2mps11_pmic_id[] = {
 	{ "s2mps11-pmic", S2MPS11X},
 	{ "s2mps13-pmic", S2MPS13X},
@@ -1074,6 +1099,7 @@ static struct platform_driver s2mps11_pmic_driver = {
 		.name = "s2mps11-pmic",
 	},
 	.probe = s2mps11_pmic_probe,
+	.shutdown = s2mps11_pmic_shutdown,
 	.id_table = s2mps11_pmic_id,
 };
 
-- 
2.4.5


             reply	other threads:[~2015-07-14 15:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-14 15:41 Anand Moon [this message]
2015-07-15  1:03 ` [PATCHv2] regulator: s2mps11: Added shutdown function to poweroff Krzysztof Kozlowski
2015-07-15  2:42   ` Anand Moon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1436888477-3841-1-git-send-email-linux.amoon@gmail.com \
    --to=linux.amoon@gmail.com \
    --cc=broonie@kernel.org \
    --cc=k.kozlowski@samsung.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=sbkim73@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.