Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4321421ybl; Mon, 26 Aug 2019 08:43:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqy5xXSKavAE1M09kLzKGOd3I2Hen4Ji1PyLFLQHXqpiP3XOmm31WCP/vHEXFGxjqXGDAwNK X-Received: by 2002:aa7:991a:: with SMTP id z26mr20655612pff.43.1566834226664; Mon, 26 Aug 2019 08:43:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566834226; cv=none; d=google.com; s=arc-20160816; b=DkXvB9KsJLrp9EjhAtEl+QiD0RyBUfyQpu+6MWf7e72lASA1v7HPvNzbNfCs6IVqGS D0vHhDOhPUw5OofMt/FQXUoQdRMY9+dsgOBfPuHJSH6SmFkIK9578JxWC9vAe7xuj69M WvMU2+v0E4hZWegc468osVO6yff+sbwfnBR5Qno3Hz09g2s//c12aofuCKHo4OuW4tvz 8u1Nskj8Ft9IOfUgLQazTVX0figHqmPvU8fNfAiYGsE9NLSdy+OzwXH2sLym10GKJ7ex tOAkocBUo+7+qTDLx4lsrdUnOfpJUQ1AEh9j5fYq7IoALLSgoYDyd7iWyVDkx8LdK+7W gP5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=jU9f5j6ZxSufRp0l6yClPcW1jUXM3GEpOLQlLRS9pBU=; b=mA0mRgRJjk+LzGVI0utPilIf14laf5G0vghcwrP0NcDb3iJGNz5dBS4Po/MyqUmjbn 4yDcy04zQfmkjl/pgV2c3GtUUqNRr/zFBwQlwQBxhBDOcSenaff53+Mofru5u7l/kPYy /dO8i4weTwGnnpSl4UoNBItF8/nYbr2LH1KRV+W7T/8hOXh2Hd/KlpYUky7P68sJmMbG SBtlv+atPY9r2YL3ItMvZrNYKuHtwpzHjT67ADL4rwDh5AgcpZg1sQ1Y7W7AvNQkoec1 N8e00VWc1/qB3yr4sKGTLzCcUeaMsF5WDiL2BqwBsBBckPgnsjoMDJbwEiTx67rbqE2b JStg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=To1PgnC5; 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 d22si8778376pjv.17.2019.08.26.08.43.31; Mon, 26 Aug 2019 08:43:46 -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=@st.com header.s=STMicroelectronics header.b=To1PgnC5; 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 S1733255AbfHZPjq (ORCPT + 99 others); Mon, 26 Aug 2019 11:39:46 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:1659 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733200AbfHZPjf (ORCPT ); Mon, 26 Aug 2019 11:39:35 -0400 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7QFPxf4018386; Mon, 26 Aug 2019 17:39:23 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=jU9f5j6ZxSufRp0l6yClPcW1jUXM3GEpOLQlLRS9pBU=; b=To1PgnC5V2IkRIl04X2kCQ4oVzbXRNf5P5lzE3ePlDgyC556SLdSpOi1X84Fd05OhJ1w 6WFgqhhx5nX1gKmrSRgQmw8akYzlR4e6i+XSLcllZN/jD16WXKTLv3vAiS2ZJwmIhTCf nNjp4LSdVgz2RhkXzSkXRBQW2HSGRdG7rcyv4u5yEzBQBZ53PWw+6cFP49237RInq0KJ nHf/mgBEOfUFoy89GfXdGrpiuifa6b/AqQmdVru9pKYWYfcSGYtNXNvC93+aSawavht1 Ws2+y6m06TOminI/hfJwLkBwpSZjkkvFMZU/eqy7s7OEZfxBYzhH27PO/wiuIAV9cze7 VA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2uju0vmgkf-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 26 Aug 2019 17:39:23 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 166B7238; Mon, 26 Aug 2019 15:39:07 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas24.st.com [10.75.90.94]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id C05532BC1DD; Mon, 26 Aug 2019 17:38:53 +0200 (CEST) Received: from SAFEX1HUBCAS21.st.com (10.75.90.45) by Safex1hubcas24.st.com (10.75.90.94) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 26 Aug 2019 17:38:53 +0200 Received: from localhost (10.201.23.25) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 26 Aug 2019 17:38:53 +0200 From: Fabien Dessenne To: Rob Herring , Mark Rutland , Maxime Coquelin , Alexandre Torgue , Ohad Ben-Cohen , Bjorn Andersson , , , , , CC: Fabien Dessenne , Loic Pallardy , Arnaud Pouliquen Subject: [PATCH 2/2] remoteproc: stm32: wakeup the system by wdg irq Date: Mon, 26 Aug 2019 17:38:43 +0200 Message-ID: <1566833923-16718-3-git-send-email-fabien.dessenne@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1566833923-16718-1-git-send-email-fabien.dessenne@st.com> References: <1566833923-16718-1-git-send-email-fabien.dessenne@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.201.23.25] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-26_08:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the device node defines the 'wakeup-source' property, use the WDG exti IRQ as a wakeup source of the system. Signed-off-by: Fabien Dessenne --- drivers/remoteproc/stm32_rproc.c | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 2cf4b29..7ed8895 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -65,6 +66,7 @@ struct stm32_rproc { struct reset_control *rst; struct stm32_syscon hold_boot; struct stm32_syscon pdds; + int wdg_irq; u32 nb_rmems; struct stm32_rproc_mem *rmems; struct stm32_mbox mb[MBOX_NB_MBX]; @@ -528,6 +530,13 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev) return err; } + ddata->wdg_irq = irq; + + if (of_property_read_bool(np, "wakeup-source")) { + device_init_wakeup(dev, true); + dev_pm_set_wake_irq(dev, irq); + } + dev_info(dev, "wdg irq registered\n"); } @@ -607,6 +616,10 @@ static int stm32_rproc_probe(struct platform_device *pdev) free_mb: stm32_rproc_free_mbox(rproc); free_rproc: + if (device_may_wakeup(dev)) { + dev_pm_clear_wake_irq(dev); + device_init_wakeup(dev, false); + } rproc_free(rproc); return ret; } @@ -614,22 +627,56 @@ static int stm32_rproc_probe(struct platform_device *pdev) static int stm32_rproc_remove(struct platform_device *pdev) { struct rproc *rproc = platform_get_drvdata(pdev); + struct device *dev = &pdev->dev; if (atomic_read(&rproc->power) > 0) rproc_shutdown(rproc); rproc_del(rproc); stm32_rproc_free_mbox(rproc); + + if (device_may_wakeup(dev)) { + dev_pm_clear_wake_irq(dev); + device_init_wakeup(dev, false); + } rproc_free(rproc); return 0; } +#ifdef CONFIG_PM_SLEEP +static int stm32_rproc_suspend(struct device *dev) +{ + struct rproc *rproc = dev_get_drvdata(dev); + struct stm32_rproc *ddata = rproc->priv; + + if (device_may_wakeup(dev)) + return enable_irq_wake(ddata->wdg_irq); + + return 0; +} + +static int stm32_rproc_resume(struct device *dev) +{ + struct rproc *rproc = dev_get_drvdata(dev); + struct stm32_rproc *ddata = rproc->priv; + + if (device_may_wakeup(dev)) + return disable_irq_wake(ddata->wdg_irq); + + return 0; +} +#endif + +static SIMPLE_DEV_PM_OPS(stm32_rproc_pm_ops, + stm32_rproc_suspend, stm32_rproc_resume); + static struct platform_driver stm32_rproc_driver = { .probe = stm32_rproc_probe, .remove = stm32_rproc_remove, .driver = { .name = "stm32-rproc", + .pm = &stm32_rproc_pm_ops, .of_match_table = of_match_ptr(stm32_rproc_match), }, }; -- 2.7.4