Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp521552ybs; Sun, 24 May 2020 12:32:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwSpYO20F4aAe3yJyuObWrenjWpe3yzXL6VyQSz0Hc4A0ggFVhYdMtTxtrTIbjTyiiw10v X-Received: by 2002:a17:906:c7cc:: with SMTP id dc12mr16758459ejb.263.1590348726712; Sun, 24 May 2020 12:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590348726; cv=none; d=google.com; s=arc-20160816; b=vjcPgiEbdol+2lsFjwC9/dBiSVPAdMMgukMiF7EaufPZDzJWPnEo3bxll3Z3nWpve/ ReuXyizK2wtzNezSuJzG5Maad77dFojjW+L4vUBuBBGjROLHoiR7atbt/0lPA2pSXYSu VxdrouDiyKGvh6uS25epozmmMxajD9kJNxPZKId8n3yVzl4o7NUZ9PsbcweNb/T0dfjL VuFUHS6f1y73a3ePXx5OuHFxQIH0Tgf3oNkPPIhH9rKu8Kk+SBBd+TZmZU/ykRhZp2uM doee2NED3pXLCkrLSDTO3DvuOXsTzzI3YSN0mN0NIG98wAiwLjAgqsxlw4Sz0CM8fz4+ AR9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=rKQHqAYuyPGCkAJDsVVw4O2WcuzpsiIQPL4viSQa7G0=; b=eNo1ceH1n5nKW2mDRWVTsXIA142e2/iFSmQoYRJZaS7q0FJpX6WaYVOiQjEqIdx9VC AdDXuTsJ31+7SAS8rkOqPBte8PRawTqFkmlsHLXkB5Nuky55mphs+gSpylgKxhTB1cDA WVQT0hj0QskV6gtZM1EvGx4uasfLxIvJysxrSzeyQ5sudGFapG3AyG7GCdxUrFB82maJ j1M6J0piFnvkTr2RB/3LjaJ0tx7HWfu0c9cAE6C4LOeFsdz0IBmRauUTykJkdVoMK8Qy hBkx1bS+ZFuH0SRqC5U9pPPTbLtzIXjwiMNudUZzrAoVuAVzqu36FQJPk1fxGZrzy7wk nVyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tAcJd41A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gz16si8789952ejb.384.2020.05.24.12.31.43; Sun, 24 May 2020 12:32:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tAcJd41A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388456AbgEXT1v (ORCPT + 99 others); Sun, 24 May 2020 15:27:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387862AbgEXT1u (ORCPT ); Sun, 24 May 2020 15:27:50 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A320AC061A0E; Sun, 24 May 2020 12:27:49 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id a4so9349842lfh.12; Sun, 24 May 2020 12:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rKQHqAYuyPGCkAJDsVVw4O2WcuzpsiIQPL4viSQa7G0=; b=tAcJd41AAo8LrMlZLQNlAz7LYU4eMuMN3ndTg4otcrNEp1Hv+lk+cx2V2IjRq6kULk upwt3u9MKW0j0vmt1VQlQZYMRY04RH5yRro4gRui9YDO3BjHM9rf27POQfcCsyarP8V1 yfyRznBNg8g6ctXtaOzFDseKwwoog+EVNFSIzyI/w/EY//RDDzMWnXYDrJy++yT+9OQZ ScMjRN166SrMp9hWQHeccljhhVEQ174/zy5KyvFDiRxiY/xWUSjjd5Tp42vP37NQulKM VEqYz3eUtYfS15ZiSafaikgKBbONNsoxkqcFayZmoP73dqf8+GtFJERNqdwMYZ1GlazF KAYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rKQHqAYuyPGCkAJDsVVw4O2WcuzpsiIQPL4viSQa7G0=; b=CJTYchLBKbMKMmvfaq9oRDIZEm4UX9nqi/Zm5HfBAFy9gAxWTGfIh7Jjo59+JYyifD JcaF3mqw5Yst3d0YjUHmGf8XnfgIBLURikTRc1RGM1KYzFLDt6OfiqeWY5z5maMzyZJU 0VmmYrefKkT3UNcjtbjnfUqbNgJKqXMjFNjLkUGP1sblFBL/NueoE1BOCjUoQcr7PFNA teuNJ2D0BRVR590ynwtm7d5zHduRo4QhXSb5b1E+TATr++BTcoWLX8p4+EGrMJVNnNe+ zkRJfEzB7CHu5pGZV7NLzIaBzAuYJoNxltDyOe8lWpOIyenme4uwX5gOLQnUaC+8Bx45 0YXg== X-Gm-Message-State: AOAM530q5YtC0tCS+01H9MsXNqVOb+aaZFqLJ65MB522L6Nc7IJO9i9p JRrlqNFup/e2Ew0eG5dAfq4= X-Received: by 2002:ac2:5324:: with SMTP id f4mr12993687lfh.209.1590348468196; Sun, 24 May 2020 12:27:48 -0700 (PDT) Received: from localhost.localdomain (ppp91-76-17-204.pppoe.mtu-net.ru. [91.76.17.204]) by smtp.gmail.com with ESMTPSA id x8sm3879864ljh.97.2020.05.24.12.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 12:27:47 -0700 (PDT) From: Dmitry Osipenko To: Tony Lindgren , Lee Jones , Thierry Reding , Jonathan Hunter , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Zack Pearsall Cc: linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] mfd: tps65910: Correct power-off programming sequence Date: Sun, 24 May 2020 22:26:43 +0300 Message-Id: <20200524192643.18207-1-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch fixes system shutdown on a devices that use TPS65910 as a system's power controller. In accordance to the TPS65910 datasheet, the PMIC's state-machine transitions into the OFF state only when DEV_OFF bit of DEVCTRL_REG is set. The ON / SLEEP states also should be cleared, otherwise PMIC won't get into a proper state on shutdown. Devices like Nexus 7 tablet and Ouya game console are now shutting down properly. Tested-by: Zack Pearsall Signed-off-by: Dmitry Osipenko --- Changelog: v2: - Now using a single tps65910_reg_update_bits() instead of set+clear. Thanks to Michał Mirosław for the suggestion. drivers/mfd/tps65910.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c index 11959021b50a..3f4483dec871 100644 --- a/drivers/mfd/tps65910.c +++ b/drivers/mfd/tps65910.c @@ -440,8 +440,13 @@ static void tps65910_power_off(void) DEVCTRL_PWR_OFF_MASK) < 0) return; - tps65910_reg_clear_bits(tps65910, TPS65910_DEVCTRL, - DEVCTRL_DEV_ON_MASK); + if (tps65910_reg_clear_bits(tps65910, TPS65910_DEVCTRL, + DEVCTRL_DEV_SLP_MASK) < 0) + return; + + tps65910_reg_update_bits(tps65910, TPS65910_DEVCTRL, + DEVCTRL_DEV_OFF_MASK | DEVCTRL_DEV_ON_MASK, + DEVCTRL_DEV_OFF_MASK); } static int tps65910_i2c_probe(struct i2c_client *i2c, -- 2.26.0