@@ -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);