Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1011009imm; Tue, 2 Oct 2018 00:50:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV61sA+SQWsgKX0KeGGk6qLlkEtrc1eQGFCEj8L5WRz4L78SX55LTDnRxrFqNTBxuU+GHLKy/ X-Received: by 2002:a17:902:7246:: with SMTP id c6-v6mr15784614pll.304.1538466617960; Tue, 02 Oct 2018 00:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538466617; cv=none; d=google.com; s=arc-20160816; b=joYEOdBTUHXm2nXbKYDYJGyfT2W1is4+5i+XtXOpUfyoB+a5gvHQAo0jP9q3LV4FZe 0RX464wJu/1QTRdFqq08Mar2Ub7W9W5Pogt2doBL1QESxnInO8l/7ZuZw+QXPcr6IY3R wxJdp3vBgutTMRKkLF4XxCJZdyrsPWa3YC/QfmOqK/HyIUMjyNNMRzKMKio8xJElrYO4 6GLyzHLAYhCuqPymXA1wkEiOE8sKMmMKLgNC/aem1bRrH04Cq095cz7wanyF9iRSftv+ UJut1K6a3JaeZvHf1LBp4R//LiOpnVJRWMUPLwNzj8QyAK1J9IrIsxM4Iui0MvrEqRIS waLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=9W2+v4WcNziGDOCSs9wzmXN6ghhrPwWsgzacj2h5b9g=; b=RxNVvPSVUoXfLZMfdtn3HXlAxQ2QY87f/Qi0LgKRCgE+LTTKEdt+LS0nfXKh+FfPmh 59sWH4XrIIm2AKIifA3qMD3RORkAoAr0DT+tAhkbaGAStHgs2wS38D/wk0E10C6Op4Up AzyAnoGwsq5L9GOV0sB6/41y55ErnvyzODqIwFVd/UNWYrGbgRJu73rk0sZApNJi0aGg G16WIx7pUouyH/Yo842W+21tKvIHVbGqoPYXg8aQ7eIINoTl2m6e8Dro/Z5VIh1m1Gt8 flGJG9E3Lqdr7XpBAIeEh6vN/32rOuAbvpK9RnI71LCIGanIByFWKnxZi7BTCs9gLAJA /8vg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4-v6si14259839pgj.341.2018.10.02.00.50.02; Tue, 02 Oct 2018 00:50:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727271AbeJBObi (ORCPT + 99 others); Tue, 2 Oct 2018 10:31:38 -0400 Received: from olimex.com ([184.105.72.32]:56423 "EHLO olimex.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727011AbeJBObi (ORCPT ); Tue, 2 Oct 2018 10:31:38 -0400 X-Greylist: delayed 605 seconds by postgrey-1.27 at vger.kernel.org; Tue, 02 Oct 2018 10:31:37 EDT Received: from localhost.localdomain ([195.238.85.143]) by olimex.com with ESMTPSA (ECDHE-RSA-AES128-SHA256:TLSv1.2:Kx=ECDH:Au=RSA:Enc=AES(128):Mac=SHA256) (SMTP-AUTH username stefan@olimex.com, mechanism PLAIN) for ; Tue, 2 Oct 2018 00:39:35 -0700 From: Stefan Mavrodiev To: Heiko Stuebner , linux-rockchip@lists.infradead.org, Lee Jones , linux-kernel@vger.kernel.org (open list) Cc: Stefan Mavrodiev Subject: [PATCH 1/1] mfd: rk808: Prepare rk805 for poweroff Date: Tue, 2 Oct 2018 10:38:29 +0300 Message-Id: <1538465910-27233-1-git-send-email-stefan@olimex.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org RK805 has SLEEP signal, which can put the device into SLEEP or OFF mode. The default is SLEEP mode. However, when the kernel performs power-off (actually the ATF) the device will not go fully off and this will result in higher power consumption and inability to wake the device with RTC alarm. The solution is to enable pm_power_off_prepare function, which will configure SLEEP pin for OFF function. Signed-off-by: Stefan Mavrodiev --- drivers/mfd/rk808.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c index 216fbf6..50f3f78 100644 --- a/drivers/mfd/rk808.c +++ b/drivers/mfd/rk808.c @@ -387,6 +387,25 @@ static void rk805_device_shutdown(void) dev_err(&rk808_i2c_client->dev, "power off error!\n"); } +static void rk805_device_shutdown_prepare(void) +{ + int ret; + struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client); + + if (!rk808) { + dev_warn(&rk808_i2c_client->dev, + "have no rk805, so do nothing here\n"); + + return; + } + + ret = regmap_update_bits(rk808->regmap, + RK805_GPIO_IO_POL_REG, + SLP_SD_MSK, SHUTDOWN_FUN); + if (ret) + dev_err(&rk808_i2c_client->dev, "power off error!\n"); +} + static void rk808_device_shutdown(void) { int ret; @@ -549,6 +568,10 @@ static int rk808_probe(struct i2c_client *client, if (pm_off && !pm_power_off) { rk808_i2c_client = client; pm_power_off = pm_pwroff_fn; + } else if (pm_off && !pm_power_off_prepare && + rk808->variant == RK805_ID) { + rk808_i2c_client = client; + pm_power_off_prepare = rk805_device_shutdown_prepare; } return 0; @@ -564,6 +587,7 @@ static int rk808_remove(struct i2c_client *client) regmap_del_irq_chip(client->irq, rk808->irq_data); pm_power_off = NULL; + pm_power_off_prepare = NULL; return 0; } -- 2.7.4