From patchwork Thu Feb 22 07:45:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 129162 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp318267lja; Wed, 21 Feb 2018 23:47:32 -0800 (PST) X-Google-Smtp-Source: AH8x227N49KJ+s7whCKI//qQQLUSSM/zLOV+eL8jBzhfRJsncK1JtkcKxKWzCaI8twmcw6V7PTIJ X-Received: by 10.101.65.71 with SMTP id x7mr4949122pgp.203.1519285652014; Wed, 21 Feb 2018 23:47:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519285652; cv=none; d=google.com; s=arc-20160816; b=FonORSY5/ZCRZEW1QqBpYG/o5Z6VvIaBJToFVKPuMBbtqZRINJwCjxFnc+gr+Nx0va cDU03f5LQNrY4aF+5LD0pm04rGa6yCm+y+fLDc8nS3eyG8h91ya5zUb4UyRDvUkL8d5u OB2ImYvyDoBhFWbD5EV8kw71yAmERnRLqO7GV3UoBTPNjfBL8iyJC099jZiVhMPXrDfh mUtnQPFa9rR1Jum7IYvUBCN9678K69vRh9JZu5XEI6I7BryNii50Fv5endbhJbRH8XMM zhGekYHrUSb4lWovYxwXKuDqzH5ElMNTHgHc7tY1di6XG4Af/TYyo0eYztfvhT488tx2 dsCA== 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 :dkim-signature:arc-authentication-results; bh=W0/eJSSF18rYh3ne7FDDTcn1QSN6bLNl9crEO8FSkJI=; b=eLeXcK9RZlC2MeK96a5UrRjqizyWXmXO21aJkl6vLxOYHBRlgTebTuKRHqV7JlfF+D u3Np1LVoRNmu9jMSVC08ODk/cxzIymTOLcWVbhDopdR6Dt3IXQDimXm6fES75+amo0Xb mgUVvp7d6pXHuprMyBJrr0hsFCeMkdZ9zax3t/NpfNO8m7+EYfuKPIgMtrz//AOZmSlP Hf3jQOJx9PL+Er8QQnzsz6j1uCeCti6NiWk5luzFjRMnzAHKLQGGplANRO4icH6ViOHB KYzmwUVI3ytd73lxe4bdfJx15+376fqOH6nn/t3401fc6MmQry33LqMTBXrtIQogylzm FGGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G6QP5iUa; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k33-v6si2911785pld.303.2018.02.21.23.47.31; Wed, 21 Feb 2018 23:47:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G6QP5iUa; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752706AbeBVHra (ORCPT + 11 others); Thu, 22 Feb 2018 02:47:30 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:39184 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752924AbeBVHr2 (ORCPT ); Thu, 22 Feb 2018 02:47:28 -0500 Received: by mail-lf0-f65.google.com with SMTP id f75so1036041lfg.6 for ; Wed, 21 Feb 2018 23:47:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=W0/eJSSF18rYh3ne7FDDTcn1QSN6bLNl9crEO8FSkJI=; b=G6QP5iUa35E1QjpFaq+BswScl39KMUGhwXEL+iHFh0IC3GG+1jgJf2GP+hXi9yqqkv 87NCer2z+YVsX0SaDE9X/xKnf+1EbiRt1cJXwEw7W1ypI5U1JLgcTf/FUtMtUjJEIbzJ /1+ZLAN9Wq8PXzLUxZVcu9+R6yWexTtTbjLa0= 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; bh=W0/eJSSF18rYh3ne7FDDTcn1QSN6bLNl9crEO8FSkJI=; b=p2gfx0CNmjNoBSxX2Ke0Zze79+UzAsD/Gkmph/2Zin5EPmIll3xsmfCQLQTj1frkPX MRql8cucas8wlAO4GE15vFZ6SeRhKFmEf0dzbHD/D+k5KtTJy9x5LKn+0Ka+kwNBaCVA aRK7WqLu9i/vs+Qjre0Mq65Kq4mSufRMhd5mSN7jznxHrEEHoKe0AbTiE72z0ao0rwsj cO6cAvbE1bdxmXqLMChUlw3OJbahfg8N4+pa9XNqbnCXI8bGciO3OnJjSLhSpGSvge5w T9cnKwdCn0P0YBp5QilCLnw8ZJbnyPyF6vh4+rah494kgyPiZD/Wc5q+VWJc7CbczkGP ly/g== X-Gm-Message-State: APf1xPBWqh8fT7CHvefkRcHdh2XVkhnNr5dG/+iQSlJkmZxKTRjrxF0C VilcaBQDJXuQ5wgbTEkFlM6FKA== X-Received: by 10.25.151.201 with SMTP id z192mr4406649lfd.41.1519285646965; Wed, 21 Feb 2018 23:47:26 -0800 (PST) Received: from localhost.localdomain (c-cb7471d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.116.203]) by smtp.gmail.com with ESMTPSA id 9sm3724045lju.64.2018.02.21.23.47.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Feb 2018 23:47:26 -0800 (PST) From: Linus Walleij To: Sebastian Reichel Cc: linux-pm@vger.kernel.org, Hans Ulli Kroll , Florian Fainelli , Linus Walleij Subject: [PATCH v2] power: gemini-poweroff: Avoid spurious poweroff Date: Thu, 22 Feb 2018 08:45:21 +0100 Message-Id: <20180222074521.23783-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On the D-Link DIR-685 we get spurious poweroff from infrared. Since that block (CIR) doesn't even have a driver this can be safely ignored, we can revisit this code once we have a device supporting CIR. On the D-Link DNS-313 we get spurious poweroff from the power button. This appears to be an initialization issue: we need to enable the block (start the state machine) before we clear any dangling IRQ. This patch fixes both issues. Fixes: f7a388d6cd1c ("power: reset: Add a driver for the Gemini poweroff") Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Fix both issues and rename the patch. - Proper commit message with specifics. --- drivers/power/reset/gemini-poweroff.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) -- 2.14.3 diff --git a/drivers/power/reset/gemini-poweroff.c b/drivers/power/reset/gemini-poweroff.c index ff75af5abbc5..2ac291af1265 100644 --- a/drivers/power/reset/gemini-poweroff.c +++ b/drivers/power/reset/gemini-poweroff.c @@ -47,8 +47,12 @@ static irqreturn_t gemini_powerbutton_interrupt(int irq, void *data) val &= 0x70U; switch (val) { case GEMINI_STAT_CIR: - dev_info(gpw->dev, "infrared poweroff\n"); - orderly_poweroff(true); + /* + * We do not yet have a driver for the infrared + * controller so it can cause spurious poweroff + * events. Ignore those for now. + */ + dev_info(gpw->dev, "infrared poweroff - ignored\n"); break; case GEMINI_STAT_RTC: dev_info(gpw->dev, "RTC poweroff\n"); @@ -116,7 +120,17 @@ static int gemini_poweroff_probe(struct platform_device *pdev) return -ENODEV; } - /* Clear the power management IRQ */ + /* + * Enable the power controller. This is crucial on Gemini + * systems: if this is not done, pressing the power button + * will result in unconditional poweroff without any warning. + * This makes the kernel handle the poweroff. + */ + val = readl(gpw->base + GEMINI_PWC_CTRLREG); + val |= GEMINI_CTRL_ENABLE; + writel(val, gpw->base + GEMINI_PWC_CTRLREG); + + /* Now that the state machine is active, clear the IRQ */ val = readl(gpw->base + GEMINI_PWC_CTRLREG); val |= GEMINI_CTRL_IRQ_CLR; writel(val, gpw->base + GEMINI_PWC_CTRLREG); @@ -129,16 +143,6 @@ static int gemini_poweroff_probe(struct platform_device *pdev) pm_power_off = gemini_poweroff; gpw_poweroff = gpw; - /* - * Enable the power controller. This is crucial on Gemini - * systems: if this is not done, pressing the power button - * will result in unconditional poweroff without any warning. - * This makes the kernel handle the poweroff. - */ - val = readl(gpw->base + GEMINI_PWC_CTRLREG); - val |= GEMINI_CTRL_ENABLE; - writel(val, gpw->base + GEMINI_PWC_CTRLREG); - dev_info(dev, "Gemini poweroff driver registered\n"); return 0;