Received: by 10.213.65.68 with SMTP id h4csp1538863imn; Thu, 15 Mar 2018 02:33:29 -0700 (PDT) X-Google-Smtp-Source: AG47ELurYYQ8UVIW8FffV3Bv3cTRtyeaOuJFlazrUs4m4zF+2k6A7x0G/h6C532Oh2S60pnRzvKI X-Received: by 10.101.81.204 with SMTP id i12mr6201708pgq.206.1521106409912; Thu, 15 Mar 2018 02:33:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521106409; cv=none; d=google.com; s=arc-20160816; b=pr7bCaNxiapw+CppSzJepFVwTGcHHKSJbf/3plPftiz+pul7Z3hoCLZUghWaB5d2Nn lRdEZNncOZwyd6Ae/X+lwNmLNk4NhSG81H7+GEmF/WuJGAQqONSm9BtKXfrTNly6txjH 1/XjpEXHFABM8Vsx12ncEU+llmrXlhV/791nokfYneME+8Jndpix0VZOBUnvTYGQBSbA ZsA8EDVfVzh+X3E/D08IhAXGkkUrVAmkCxFKme7hnUzHINZ7RJ5ZX0M7AasLBrKH2PJT GA6jgJfFvaMqBV5QfzxSR0JSrji9DhcS9YnuneanQ7UMqhQblYCY7leltddByt5G37aE zuCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=boaJ70rDdGnxcniUrG2PsqsXZwMQh1pYFhh3bZ4D0Cc=; b=nBxKuXRy2aCBsCetnJzGG8EbNqfWddLBiCh2Jh8hi+1ErMYOCsmpdYnyjPiQciIGLz YUkzyZjaoda4pU7HTXFWbUGY+QWa/15Hn7Z/DRmGxLPq0B+zlKay/4IINeozWUcpqm9A 1Jqc45tfaQoAqKDYqrs6qWVNg/rGRN0QNgONx4424pubt41ymWHa3md+B3oEzr7KdiJI iCrmOhAkDGiPB3audSE/2TLTpYXhboNw1rCeHosLFVJij/XVISi7Kys/WdKunPhwSdaD 3cDillcFm94sZ+8SVEQh5e+O4zveZLuPTGovNt+EeTLSM3j0Dxw+Zg1PxdrEWRVhnVZi PjKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GTfUarzd; 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; 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 g3-v6si3615703pld.366.2018.03.15.02.33.15; Thu, 15 Mar 2018 02:33:29 -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; dkim=pass header.i=@linaro.org header.s=google header.b=GTfUarzd; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751833AbeCOJbD (ORCPT + 99 others); Thu, 15 Mar 2018 05:31:03 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:32891 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751526AbeCOJam (ORCPT ); Thu, 15 Mar 2018 05:30:42 -0400 Received: by mail-wm0-f67.google.com with SMTP id s206so22228051wme.0 for ; Thu, 15 Mar 2018 02:30:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=boaJ70rDdGnxcniUrG2PsqsXZwMQh1pYFhh3bZ4D0Cc=; b=GTfUarzdQMsuLtjOw5mApIIhKkRmnAwJ+j/mbv9qkdAAsD+nML/0Awu5L+MLBQLSIH PVxjLYxK2MMDliExN5PnhihFege1tsttiW0g1pUzXzAJRHxxg4Wbe5ZpN9Ia2+rcOd0o AQuwyY2rLqBYu/dgpNeDkhgogR8z88v9YDnCw= 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:in-reply-to :references; bh=boaJ70rDdGnxcniUrG2PsqsXZwMQh1pYFhh3bZ4D0Cc=; b=hKEahj9waRknCwqr+sMn4YI4F4oHBiJs+FysQ1eWahpFJzzU1azrpyyhnycKSDhb/Y fNXZPIUwJP7Spqq/jVDUvfk5NWHgTpZiJBXm1Dy10anz5ra3i9bGZjMM8wFgAzfHcF9y 8bIpjvbs3epGmGqsOC3fgjn5FrPFy9nEOb0Z2XxbW8No0ZUwtBQTjjRpa295wI4RvAfh mgjqRKWQpp7WR7CEAMbfLmKaXnDWB/VMKpC7TFCfIM1SkvH7tGFmdH38M953LQuS+joR 0evR1wQDJAd6gpf/yo12b4OSlnblMsBiMROHy6N+PZyZFlfND0PNcw8BF6+LXXs6o2A8 FBkg== X-Gm-Message-State: AElRT7G664tIWpxph2usly6Naa+r4tHBXiT8RBtdLANlvgvsnICZeKMb A+X8r/6Uh2l46r+/qMY58FIIZA== X-Received: by 10.28.58.199 with SMTP id h190mr4070661wma.119.1521106240852; Thu, 15 Mar 2018 02:30:40 -0700 (PDT) Received: from lmecxl0911.lme.st.com ([80.214.78.222]) by smtp.gmail.com with ESMTPSA id m71sm3603844wmd.6.2018.03.15.02.30.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Mar 2018 02:30:40 -0700 (PDT) From: Benjamin Gaignard X-Google-Original-From: Benjamin Gaignard To: mchehab@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, hans.verkuil@cisco.com Cc: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Benjamin Gaignard Subject: [PATCH 2/2] cec: stm32: add suspend/resume functions Date: Thu, 15 Mar 2018 10:29:49 +0100 Message-Id: <20180315092949.9895-3-benjamin.gaignard@st.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180315092949.9895-1-benjamin.gaignard@st.com> References: <20180315092949.9895-1-benjamin.gaignard@st.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Benjamin Gaignard If wake up irq is defined in device-tree cec adapter could be used has wake up source. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/stm32/stm32-cec.c | 44 +++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/stm32/stm32-cec.c b/drivers/media/platform/stm32/stm32-cec.c index 35cc2ffd6b96..68e18ee6655b 100644 --- a/drivers/media/platform/stm32/stm32-cec.c +++ b/drivers/media/platform/stm32/stm32-cec.c @@ -11,8 +11,11 @@ #include #include #include +#include #include +#include #include +#include #include #include @@ -243,7 +246,7 @@ static int stm32_cec_probe(struct platform_device *pdev) struct resource *res; struct stm32_cec *cec; void __iomem *mmio; - int ret; + int ret, wakeirq; cec = devm_kzalloc(&pdev->dev, sizeof(*cec), GFP_KERNEL); if (!cec) @@ -274,6 +277,12 @@ static int stm32_cec_probe(struct platform_device *pdev) if (ret) return ret; + wakeirq = of_irq_get_byname(pdev->dev.of_node, "wakeup"); + if (wakeirq > 0) { + device_init_wakeup(&pdev->dev, true); + dev_pm_set_dedicated_wake_irq(&pdev->dev, wakeirq); + } + cec->clk_cec = devm_clk_get(&pdev->dev, "cec"); if (IS_ERR(cec->clk_cec)) { dev_err(&pdev->dev, "Cannot get cec clock\n"); @@ -312,12 +321,44 @@ static int stm32_cec_remove(struct platform_device *pdev) { struct stm32_cec *cec = platform_get_drvdata(pdev); + dev_pm_clear_wake_irq(&pdev->dev); + device_init_wakeup(&pdev->dev, false); + cec_unregister_adapter(cec->adap); pm_runtime_disable(&pdev->dev); return 0; } + +static int __maybe_unused stm32_cec_suspend(struct device *dev) +{ + struct stm32_cec *cec = dev_get_drvdata(dev); + + pm_runtime_force_suspend(dev); + + if (device_may_wakeup(dev)) + enable_irq_wake(cec->irq); + + pinctrl_pm_select_sleep_state(dev); + + return 0; +} + +static int __maybe_unused stm32_cec_resume(struct device *dev) +{ + struct stm32_cec *cec = dev_get_drvdata(dev); + + pinctrl_pm_select_default_state(dev); + + if (device_may_wakeup(dev)) + disable_irq_wake(cec->irq); + + pm_runtime_force_resume(dev); + + return 0; +} + static int __maybe_unused stm32_cec_runtime_suspend(struct device *dev) { struct stm32_cec *cec = dev_get_drvdata(dev); @@ -341,6 +382,7 @@ static int __maybe_unused stm32_cec_runtime_resume(struct device *dev) static const struct dev_pm_ops stm32_cec_pm_ops = { SET_RUNTIME_PM_OPS(stm32_cec_runtime_suspend, stm32_cec_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(stm32_cec_suspend, stm32_cec_resume) }; static const struct of_device_id stm32_cec_of_match[] = { -- 2.15.0