From: Jon Hunter <jonathanh@nvidia.com>
To: Thierry Reding <thierry.reding@gmail.com>,
Lee Jones <lee.jones@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
Alessandro Zummo <a.zummo@towertech.it>,
Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: <devicetree@vger.kernel.org>, <linux-rtc@vger.kernel.org>,
<linux-tegra@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/3] rtc: max77686: Make wakeup support configurable
Date: Mon, 20 Apr 2020 15:42:48 +0100 [thread overview]
Message-ID: <03086f6b-012b-67ab-6a61-fbae1bf0c3c7@nvidia.com> (raw)
In-Reply-To: <20200417170825.2551367-2-thierry.reding@gmail.com>
On 17/04/2020 18:08, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> Use the standard "wakeup-source" device tree property to determine if
> the RTC can act as a wakeup source for the system. Note that the driver
> by default always assumes that the RTC can act as a wakeup source, but
> whether it can really do so or not always depends on how it is hooked
> up.
>
> In order to preserve backwards compatibility with older device trees,
> only parse the "wakeup-source" property when a device tree node was
> associated with the RTC device. This doesn't typically happen because
> the top-level MFD driver doesn't list any compatible strings that can
> be used to map child nodes to child devices. As a fallback, check if a
> child node named "rtc" exists and use that instead.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
> Note that we could obviously add support to the MFD driver to match
> subdevices to their device tree nodes by compatible string, but there
> are side-effects, such as the driver core complaining about the lack
> of a DMA mask for these devices. That in turn could also be fixed but
> it ends up all being rather hacky, so just looking up a child node by
> name seems like a good compromise, especially since there are already
> such subnodes for some of the other subdevices of this PMIC.
> ---
> drivers/rtc/rtc-max77686.c | 18 +++++++++++++++++-
> 1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
> index d5a0e27dd0a0..35fd74b83626 100644
> --- a/drivers/rtc/rtc-max77686.c
> +++ b/drivers/rtc/rtc-max77686.c
> @@ -722,6 +722,8 @@ static int max77686_rtc_probe(struct platform_device *pdev)
> {
> struct max77686_rtc_info *info;
> const struct platform_device_id *id = platform_get_device_id(pdev);
> + struct device_node *np = of_node_get(pdev->dev.of_node);
> + bool wakeup = true;
> int ret;
>
> info = devm_kzalloc(&pdev->dev, sizeof(struct max77686_rtc_info),
> @@ -746,7 +748,21 @@ static int max77686_rtc_probe(struct platform_device *pdev)
> goto err_rtc;
> }
>
> - device_init_wakeup(&pdev->dev, 1);
> + /*
> + * Only check for the wakeup-source property if there's an actual
> + * device tree node for the RTC. If no device tree node had been
> + * attached during device instantiation, try looking up the "rtc"
> + * child node of the parent's device tree node.
> + */
> + if (!np && pdev->dev.parent->of_node)
> + np = of_get_child_by_name(pdev->dev.parent->of_node, "rtc");
> +
> + if (np) {
> + wakeup = of_property_read_bool(np, "wakeup-source");
> + of_node_put(np);
> + }
> +
> + device_init_wakeup(&pdev->dev, wakeup);
>
> info->rtc_dev = devm_rtc_device_register(&pdev->dev, id->name,
> &max77686_rtc_ops, THIS_MODULE);
>
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Cheers
Jon
--
nvpublic
next prev parent reply other threads:[~2020-04-20 14:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-17 17:08 [PATCH 1/3] dt-bindings: mfd: Document the RTC present on MAX77620 Thierry Reding
2020-04-17 17:08 ` [PATCH 2/3] rtc: max77686: Make wakeup support configurable Thierry Reding
2020-04-20 14:42 ` Jon Hunter [this message]
2020-04-17 17:08 ` [PATCH 3/3] rtc: max77686: Use single-byte writes on MAX77620 Thierry Reding
2020-04-20 14:43 ` Jon Hunter
2020-05-11 14:27 ` Alexandre Belloni
2020-04-30 14:07 ` [PATCH 1/3] dt-bindings: mfd: Document the RTC present " Rob Herring
2020-04-30 14:15 ` Alexandre Belloni
2020-05-01 13:00 ` Rob Herring
2020-05-01 13:53 ` Alexandre Belloni
2020-05-08 11:02 ` Thierry Reding
2020-05-11 14:28 ` Alexandre Belloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=03086f6b-012b-67ab-6a61-fbae1bf0c3c7@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=devicetree@vger.kernel.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).