From patchwork Tue Aug 11 10:09:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 6990961 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 01E4BC05AC for ; Tue, 11 Aug 2015 10:11:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1183C20643 for ; Tue, 11 Aug 2015 10:11:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E91B7205D6 for ; Tue, 11 Aug 2015 10:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964984AbbHKKKw (ORCPT ); Tue, 11 Aug 2015 06:10:52 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:34780 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965003AbbHKKKT (ORCPT ); Tue, 11 Aug 2015 06:10:19 -0400 Received: by pawu10 with SMTP id u10so161281833paw.1; Tue, 11 Aug 2015 03:10:19 -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:in-reply-to:references; bh=dtIOV9qkL6PnWPI+xwEvCJAHpG1IxVtK4tYX68LGCJs=; b=lDAfYSqrWBgO1a+G5LtbaRUT76vwy2h6L5r6Rq9iOiF8yzv5vOpo4mEhwhVgzJwmGf UnLzjpQfLywYTeIiGUWVl9gwzbDQf7EvLJZ+595fBCxITzluQ6inuYp8XHzCsEH1mT44 WIMa9RTVhDoJwPYcxVJ2okE1KlB0ucDejlJ6+pdquMb/+QMtaHIJnnZpxOnlu6VuFA+I TITaRp39On0G1dJ8OWGSWhKYKq75cIgBfDfrAtoc7VNPGUG488X2QdwagFpcVKet2ULg 5Q+1lYIGDexbEvRbA2V0Ssg7oZK2XF2SkZYDcQPZtpTEHcK4UqEzrPc2qu2Wwv5GCNqV OvgA== X-Received: by 10.68.142.200 with SMTP id ry8mr54265343pbb.136.1439287819265; Tue, 11 Aug 2015 03:10:19 -0700 (PDT) Received: from localhost.localdomain ([125.130.175.98]) by smtp.gmail.com with ESMTPSA id rt6sm2001832pbb.62.2015.08.11.03.10.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Aug 2015 03:10:18 -0700 (PDT) From: Krzysztof Kozlowski To: Sangbeom Kim , Krzysztof Kozlowski , Samuel Ortiz , Lee Jones , linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Kukjin Kim , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Anand Moon , Javier Martinez Canillas , Krzysztof Kozlowski Subject: [PATCH v2 2/3] mfd: s2mps11: Add manual shutdown method for Odroid XU3 Date: Tue, 11 Aug 2015 19:09:05 +0900 Message-Id: <1439287746-14034-3-git-send-email-k.kozlowski.k@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1439287746-14034-1-git-send-email-k.kozlowski.k@gmail.com> References: <1439287746-14034-1-git-send-email-k.kozlowski.k@gmail.com> 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=-7.0 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 On Odroid XU3 board (with S2MPS11 PMIC) the PWRHOLD bit in CTRL1 register must be manually set to 0 before initiating power off sequence. One of usual power down methods for Exynos based devices looks like: 1. PWRHOLD pin of PMIC is connected to PSHOLD of Exynos. 2. Exynos holds up this pin during system operation. 3. ACOKB pin of PMIC is pulled up to VBATT and optionally to pin in other device. 4. When PWRHOLD/PSHOLD goes low, the PMIC will turn off the power if ACOKB goes high. On Odroid XU3 family the difference is in (3) - the ACOKB is grounded. This means that PMIC must manually set PWRHOLD field to low and then wait for signal from Application Processor (the usual change in PWRHOLD/PSHOLD pin will actually cut off the power). The patch adds respective binding allowing Odroid XU3 device to be powered off. Signed-off-by: Krzysztof Kozlowski Reported-by: Anand Moon Tested-by: Anand Moon Reviewed-by: Javier Martinez Canillas Acked-by: Lee Jones --- Changes since v1: 1. Split bindings documentation to separate patch (suggested by Lee). 2. Fix additional empty line (suggested by Lee). 3. Add Anand's tested-by, Javier's reviewed-by and Lee's acked-by. Patch is losely based on patch in Hardkernel repository [0] and previous work of Anand Moon [1]. [0] https://github.com/hardkernel/linux/commit/6897e62ba328bd1c8c095d918101863250cd73e7 [1] http://www.spinics.net/lists/linux-samsung-soc/msg45959.html --- drivers/mfd/sec-core.c | 30 ++++++++++++++++++++++++++++++ include/linux/mfd/samsung/core.h | 2 ++ include/linux/mfd/samsung/s2mps11.h | 1 + 3 files changed, 33 insertions(+) diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c index d206a3e8fe87..2d1137a7a0ee 100644 --- a/drivers/mfd/sec-core.c +++ b/drivers/mfd/sec-core.c @@ -278,6 +278,8 @@ static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata( * not parsed here. */ + pd->manual_poweroff = of_property_read_bool(dev->of_node, + "samsung,s2mps11-acokb-ground"); return pd; } #else @@ -440,6 +442,33 @@ static int sec_pmic_remove(struct i2c_client *i2c) return 0; } +static void sec_pmic_shutdown(struct i2c_client *i2c) +{ + struct sec_pmic_dev *sec_pmic = i2c_get_clientdata(i2c); + unsigned int reg, mask; + + if (!sec_pmic->pdata->manual_poweroff) + return; + + switch (sec_pmic->device_type) { + case S2MPS11X: + reg = S2MPS11_REG_CTRL1; + mask = S2MPS11_CTRL1_PWRHOLD_MASK; + break; + default: + /* + * Currently only one board with S2MPS11 needs this, so just + * ignore the rest. + */ + dev_warn(sec_pmic->dev, + "Unsupported device %lu for manual power off\n", + sec_pmic->device_type); + return; + } + + regmap_update_bits(sec_pmic->regmap_pmic, reg, mask, 0); +} + #ifdef CONFIG_PM_SLEEP static int sec_pmic_suspend(struct device *dev) { @@ -491,6 +520,7 @@ static struct i2c_driver sec_pmic_driver = { }, .probe = sec_pmic_probe, .remove = sec_pmic_remove, + .shutdown = sec_pmic_shutdown, .id_table = sec_pmic_id, }; diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h index 75115384f3fc..aa78957e092f 100644 --- a/include/linux/mfd/samsung/core.h +++ b/include/linux/mfd/samsung/core.h @@ -132,6 +132,8 @@ struct sec_platform_data { int buck2_init; int buck3_init; int buck4_init; + /* Whether or not manually set PWRHOLD to low during shutdown. */ + bool manual_poweroff; }; /** diff --git a/include/linux/mfd/samsung/s2mps11.h b/include/linux/mfd/samsung/s2mps11.h index 7981a9d77d3f..b288965e8101 100644 --- a/include/linux/mfd/samsung/s2mps11.h +++ b/include/linux/mfd/samsung/s2mps11.h @@ -179,6 +179,7 @@ enum s2mps11_regulators { #define S2MPS11_BUCK_N_VOLTAGES (S2MPS11_BUCK_VSEL_MASK + 1) #define S2MPS11_RAMP_DELAY 25000 /* uV/us */ +#define S2MPS11_CTRL1_PWRHOLD_MASK BIT(4) #define S2MPS11_BUCK2_RAMP_SHIFT 6 #define S2MPS11_BUCK34_RAMP_SHIFT 4