Skip to contentSkip to conversation

platform/chrome: cros_ec_rpmsg: Add host command AP sleep state support

PATCH In review Yilun Lin 3 participants 4 messages Aug 14, 2019 – Aug 28, 2019

Subsystems (2)
lore
Share & tools
lore

Yilun Lin

author
#0 lore raw

PATCH 1/1 platform/chrome: cros_ec_rpmsg: Add host command AP sleep state support

Add EC host command to inform EC of AP suspend/resume status.

---

 drivers/platform/chrome/cros_ec_rpmsg.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/platform/chrome/cros_ec_rpmsg.c +20 -0
index 5d3fb2abad1d..6f34fe629e2c 100644
@@ -236,6 +236,25 @@ static void cros_ec_rpmsg_remove(struct rpmsg_device *rpdev)
 	cancel_work_sync(&ec_rpmsg->host_event_work);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int cros_ec_rpmsg_suspend(struct device *dev)
+{
+	struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
+
+	return cros_ec_suspend(ec_dev);
+}
+
+static int cros_ec_rpmsg_resume(struct device *dev)
+{
+	struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
+
+	return cros_ec_resume(ec_dev);
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(cros_ec_rpmsg_pm_ops, cros_ec_rpmsg_suspend,
+			 cros_ec_rpmsg_resume);
+
 static const struct of_device_id cros_ec_rpmsg_of_match[] = {
 	{ .compatible = "google,cros-ec-rpmsg", },
 	{ }
@@ -246,6 +265,7 @@ static struct rpmsg_driver cros_ec_driver_rpmsg = {
 	.drv = {
 		.name   = "cros-ec-rpmsg",
 		.of_match_table = cros_ec_rpmsg_of_match,
+		.pm	= &cros_ec_rpmsg_pm_ops,
 	},
 	.probe		= cros_ec_rpmsg_probe,
 	.remove		= cros_ec_rpmsg_remove,
Signature · 1 line
2.23.0.rc1.153.gdeed80330f-goog
#1 lore raw

Hi,

Quoted 3 lines · Yilun Lin

Add EC host command to inform EC of AP suspend/resume status.

The patch looks good to me but as I don't have the hardware to test this, could I get a Tested-by Pi-Hsun if possible before queuing in chrome-platform-5.4

Thanks,
Enric

Quoted 44 lines

---

 drivers/platform/chrome/cros_ec_rpmsg.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/platform/chrome/cros_ec_rpmsg.c +20 -0
index 5d3fb2abad1d..6f34fe629e2c 100644
@@ -236,6 +236,25 @@ static void cros_ec_rpmsg_remove(struct rpmsg_device *rpdev)
 	cancel_work_sync(&ec_rpmsg->host_event_work);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int cros_ec_rpmsg_suspend(struct device *dev)
+{
+	struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
+
+	return cros_ec_suspend(ec_dev);
+}
+
+static int cros_ec_rpmsg_resume(struct device *dev)
+{
+	struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
+
+	return cros_ec_resume(ec_dev);
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(cros_ec_rpmsg_pm_ops, cros_ec_rpmsg_suspend,
+			 cros_ec_rpmsg_resume);
+
 static const struct of_device_id cros_ec_rpmsg_of_match[] = {
 	{ .compatible = "google,cros-ec-rpmsg", },
 	{ }
@@ -246,6 +265,7 @@ static struct rpmsg_driver cros_ec_driver_rpmsg = {
 	.drv = {
 		.name   = "cros-ec-rpmsg",
 		.of_match_table = cros_ec_rpmsg_of_match,
+		.pm	= &cros_ec_rpmsg_pm_ops,
 	},
 	.probe		= cros_ec_rpmsg_probe,
 	.remove		= cros_ec_rpmsg_remove,
Tested-by
#2 lore raw

Tested that with this patch, SCP does receive host command from AP while AP goes to suspend and back.

Quoted 58 lines · Enric Balletbo i Serra

Hi,

Quoted 3 lines · Yilun Lin

Add EC host command to inform EC of AP suspend/resume status.

The patch looks good to me but as I don't have the hardware to test this, could I get a Tested-by Pi-Hsun if possible before queuing in chrome-platform-5.4

Thanks,
Enric

Quoted 44 lines

---

 drivers/platform/chrome/cros_ec_rpmsg.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/platform/chrome/cros_ec_rpmsg.c +20 -0
index 5d3fb2abad1d..6f34fe629e2c 100644
@@ -236,6 +236,25 @@ static void cros_ec_rpmsg_remove(struct rpmsg_device *rpdev)
      cancel_work_sync(&ec_rpmsg->host_event_work);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int cros_ec_rpmsg_suspend(struct device *dev)
+{
+     struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
+
+     return cros_ec_suspend(ec_dev);
+}
+
+static int cros_ec_rpmsg_resume(struct device *dev)
+{
+     struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
+
+     return cros_ec_resume(ec_dev);
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(cros_ec_rpmsg_pm_ops, cros_ec_rpmsg_suspend,
+                      cros_ec_rpmsg_resume);
+
 static const struct of_device_id cros_ec_rpmsg_of_match[] = {
      { .compatible = "google,cros-ec-rpmsg", },
      { }
@@ -246,6 +265,7 @@ static struct rpmsg_driver cros_ec_driver_rpmsg = {
      .drv = {
              .name   = "cros-ec-rpmsg",
              .of_match_table = cros_ec_rpmsg_of_match,
+             .pm     = &cros_ec_rpmsg_pm_ops,
      },
      .probe          = cros_ec_rpmsg_probe,
      .remove         = cros_ec_rpmsg_remove,
#3 lore raw
In reply to Yilun Lin

Hi,

Quoted 3 lines · Yilun Lin

Add EC host command to inform EC of AP suspend/resume status.

Applied for 5.4. Thanks,

Enric

Quoted 44 lines

---

 drivers/platform/chrome/cros_ec_rpmsg.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/platform/chrome/cros_ec_rpmsg.c +20 -0
index 5d3fb2abad1d..6f34fe629e2c 100644
@@ -236,6 +236,25 @@ static void cros_ec_rpmsg_remove(struct rpmsg_device *rpdev)
 	cancel_work_sync(&ec_rpmsg->host_event_work);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int cros_ec_rpmsg_suspend(struct device *dev)
+{
+	struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
+
+	return cros_ec_suspend(ec_dev);
+}
+
+static int cros_ec_rpmsg_resume(struct device *dev)
+{
+	struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
+
+	return cros_ec_resume(ec_dev);
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(cros_ec_rpmsg_pm_ops, cros_ec_rpmsg_suspend,
+			 cros_ec_rpmsg_resume);
+
 static const struct of_device_id cros_ec_rpmsg_of_match[] = {
 	{ .compatible = "google,cros-ec-rpmsg", },
 	{ }
@@ -246,6 +265,7 @@ static struct rpmsg_driver cros_ec_driver_rpmsg = {
 	.drv = {
 		.name   = "cros-ec-rpmsg",
 		.of_match_table = cros_ec_rpmsg_of_match,
+		.pm	= &cros_ec_rpmsg_pm_ops,
 	},
 	.probe		= cros_ec_rpmsg_probe,
 	.remove		= cros_ec_rpmsg_remove,