#include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm_wakeirq.h>
 #include <linux/regmap.h>
 #include <linux/soc/qcom/smem.h>
 #include <linux/soc/qcom/smem_state.h>
                goto unwind_interfaces;
        }
 
+       /*
+        * Treat smp2p interrupt as wakeup source, but keep it disabled
+        * by default. User space can decide enabling it depending on its
+        * use cases. For example if remoteproc crashes and device wants
+        * to handle it immediatedly (e.g. to not miss phone calls) it can
+        * enable wakeup source from user space, while other devices which
+        * do not have proper autosleep feature may want to handle it with
+        * other wakeup events (e.g. Power button) instead waking up immediately.
+        */
+       device_set_wakeup_capable(&pdev->dev, true);
+
+       ret = dev_pm_set_wake_irq(&pdev->dev, irq);
+       if (ret)
+               goto set_wake_irq_fail;
 
        return 0;
 
+set_wake_irq_fail:
+       dev_pm_clear_wake_irq(&pdev->dev);
+
 unwind_interfaces:
        list_for_each_entry(entry, &smp2p->inbound, node)
                irq_domain_remove(entry->domain);
        struct qcom_smp2p *smp2p = platform_get_drvdata(pdev);
        struct smp2p_entry *entry;
 
+       dev_pm_clear_wake_irq(&pdev->dev);
+
        list_for_each_entry(entry, &smp2p->inbound, node)
                irq_domain_remove(entry->domain);