From patchwork Thu Mar 15 09:29:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 131757 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp869158ljb; Thu, 15 Mar 2018 02:31:03 -0700 (PDT) X-Google-Smtp-Source: AG47ELv0igrRRqMZMx9o/c+ev3LizZrmrc9ryNwQFCVYd1iiRuLRlKrYzDAj7zom4AL8N3i9oX8z X-Received: by 2002:a17:902:b101:: with SMTP id q1-v6mr7352238plr.287.1521106263186; Thu, 15 Mar 2018 02:31:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521106263; cv=none; d=google.com; s=arc-20160816; b=VY5PG5cQ8VhbzjmdBMb9zTTeHMxzsZ3pVDE3sGzbDmHspo4uXQ9lnzh7qtxMAVxV4i KzG0gv98orNjPwZYawKuSbc8J4u6gVgjA6WUvcz3qyV8xvEa1m/ayc6LZmN05dT56NW+ Tbo4nR+iVsCkg+d3a+1S+RiY8K16FKgP/RR7Go2VgjGgpTNTv30D1gKtfM/Qb3WE9Yno Mwp3BOrj85F1Sl7i/zmO1UzP0CZZQnphrmLw7jwyRlNe+KYHOKhg0KJyLWipt4nSuXW0 nKLafmEaau7A371gkJT5EIsI3rqbXUFzFv+BC0Lgr5oYNhMybS1EO/7v9BporPBJ3Uzy J+5w== 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=cADuAsIGnjnhS4IzDHs/0A+nuhE9wE2Xn4Odl/DgiIlGiR1BNiHeZ4e4deNb5XVods EVyebNeViASgiG130VGCd3ToNEsLP2alll94EpWk9HCY5k0xgWqkyC5rO+3hoGhIq8oP YzKYFant8Ogd1i65xPD7lZICteXuM0Ixk7TENjdhb0Ir0xP4/U9hx9l+Zc2UZxpSxpMN kvsb01NvtzxbQWaWd1YJ7scFESSIMT6wJ91Xle4CZHsIci7KUn/snejneqc+PXFOuRHM bAkNDVLLM0BxWX2cotBqy1JEyENLVDX90IynDaOn/iljZZR+FhjBPQXO4ja1qtVFOzfa 9Atg== 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-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-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 e5-v6si3801937plk.185.2018.03.15.02.31.02; Thu, 15 Mar 2018 02:31:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-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-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-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 S1751806AbeCOJbB (ORCPT + 5 others); Thu, 15 Mar 2018 05:31:01 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34205 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751738AbeCOJam (ORCPT ); Thu, 15 Mar 2018 05:30:42 -0400 Received: by mail-wm0-f68.google.com with SMTP id a20so22215151wmd.1 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=NlP1Zw5tzLv5qYbcV3v2RWOc1Wo6LjMHEQ6EnGKhMb8EhC6pBzgfmvfmaQIK9D2FTH DRxjv0suh3AHeO3nhom7nl1xyYLdna5MFGfUI41kSwf5dR95hKvzPE2gEzTF9amBxcYH re5ZlSx0gnRLjwwqBT0ZooZaxWykNciKtF0SNgY4dfJYNVqgUuB4j74rhaIXimbJvKL8 JSdOnj/vA5Vs9KxbBEur6MvND9hFCZaaA8W4RUdUomC9y3R1P2yPhwlNS97k5bqbYith vb+i/BwY/SJ5jh25CILtcp/xDK0LwaXyn6HGuk7H4N2tpUy+KKw9VcAebp1QUiJRR6wa 7veQ== X-Gm-Message-State: AElRT7FFd3P/8Cs/hsDkb9Hsogt2G5HUh5/IkvRws6lZiFeHZyR9urCq yMehUIotCxLpZP5UPDncyh6lKA== 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-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@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(-) -- 2.15.0 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[] = {