From patchwork Tue Jul 14 15:41:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 6787971 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3EA71C05AC for ; Tue, 14 Jul 2015 15:42:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6A1EA206E3 for ; Tue, 14 Jul 2015 15:42:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5574C206F4 for ; Tue, 14 Jul 2015 15:42:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753454AbbGNPlw (ORCPT ); Tue, 14 Jul 2015 11:41:52 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:34633 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752370AbbGNPlv (ORCPT ); Tue, 14 Jul 2015 11:41:51 -0400 Received: by pactm7 with SMTP id tm7so905957pac.1; Tue, 14 Jul 2015 08:41:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=zsj5EtFKl2XIfnudKilMqwc6uZrRdqFh+5+YNgJFnVM=; b=ylOzQfbKjZWwOET6D2lYltpmojhd65Gc4sDujyOmv6OzckY+jEhQdDY6I4c0g2hftp 121YUp6wuIdRqgwX+oj7i/IZSulHI+juZMga2W1peiE56ec3/+feKOVHUhPHbP+NDC3S XVSf4OQfGkecbcQJz/1KdiAQfmK5eHczHj5/IjzmtWFI7vJUA9B9rqWzf//1uQj9UA9+ VysS6aRCX/Bl+YaN9EAeMNWiDNNAHNNu2ZVtkI4lnrydwi/xyBvCsLyAySAtWuwdu3Z2 8WCPG+/4JkwlpxFtalmjxgOEkHDRZqiUzbwFbQOcyUcq+QbqFooc+7QADsldz8QzfN8u 30CA== X-Received: by 10.68.224.10 with SMTP id qy10mr82836840pbc.23.1436888510430; Tue, 14 Jul 2015 08:41:50 -0700 (PDT) Received: from localhost.localdomain ([115.117.45.10]) by smtp.gmail.com with ESMTPSA id b3sm1736213pdg.67.2015.07.14.08.41.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Jul 2015 08:41:49 -0700 (PDT) From: Anand Moon To: Sangbeom Kim , Krzysztof Kozlowski , Marek Szyprowski , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Anand Moon Subject: [PATCHv2] regulator: s2mps11: Added shutdown function to poweroff Date: Wed, 15 Jul 2015 01:11:17 +0930 Message-Id: <1436888477-3841-1-git-send-email-linux.amoon@gmail.com> X-Mailer: git-send-email 2.4.5 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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, ®_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, };