diff mbox series

[3/3] power: reset: qcom-pon: Add support for 'qcom,mode-in-imem'

Message ID 20210704074045.21643-4-shawn.guo@linaro.org
State New
Headers show
Series Add 'qcom,mode-in-imem' support in PON driver | expand

Commit Message

Shawn Guo July 4, 2021, 7:40 a.m. UTC
Add support for DT property 'qcom,mode-in-imem', which is used on
devices like Sony Xperia M4 Aqua phone (MSM8939) to store a different
set of mode values IMEM rather than PON register.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/power/reset/qcom-pon.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/power/reset/qcom-pon.c b/drivers/power/reset/qcom-pon.c
index 4a688741a88a..f63d49c72f55 100644
--- a/drivers/power/reset/qcom-pon.c
+++ b/drivers/power/reset/qcom-pon.c
@@ -42,6 +42,24 @@  static int pm8916_reboot_mode_write(struct reboot_mode_driver *reboot,
 	return ret;
 }
 
+static int pm8916_reboot_mode_write_imem(struct reboot_mode_driver *reboot,
+					 unsigned int magic)
+{
+	struct pm8916_pon *pon = container_of(reboot, struct pm8916_pon,
+					      reboot_mode);
+	void __iomem *imem;
+
+	imem = devm_ioremap(pon->dev, pon->baseaddr, 4);
+	if (!imem) {
+		dev_err(pon->dev, "failed to map imem\n");
+		return -ENOMEM;
+	}
+
+	writel(magic, imem);
+
+	return 0;
+}
+
 static int pm8916_pon_probe(struct platform_device *pdev)
 {
 	struct pm8916_pon *pon;
@@ -66,7 +84,12 @@  static int pm8916_pon_probe(struct platform_device *pdev)
 
 	pon->reboot_mode.dev = &pdev->dev;
 	pon->reason_shift = (long)of_device_get_match_data(&pdev->dev);
-	pon->reboot_mode.write = pm8916_reboot_mode_write;
+
+	if (device_property_present(&pdev->dev, "qcom,mode-in-imem"))
+		pon->reboot_mode.write = pm8916_reboot_mode_write_imem;
+	else
+		pon->reboot_mode.write = pm8916_reboot_mode_write;
+
 	error = devm_reboot_mode_register(&pdev->dev, &pon->reboot_mode);
 	if (error) {
 		dev_err(&pdev->dev, "can't register reboot mode\n");