diff mbox

[v2] memory: ti-emif-sram: Add resume function to recopy sram code

Message ID 1527096724-22271-1-git-send-email-j-keerthy@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

J, KEERTHY May 23, 2018, 5:32 p.m. UTC
From: Dave Gerlach <d-gerlach@ti.com>

After an RTC+DDR cycle we lose sram context so emif pm functions present
in sram are lost. We can check if the first byte of the original
code in DDR contains the same first byte as the code in sram, and if
they do not match we know we have lost context and must recopy the
functions to the previous address to maintain PM functionality.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Keerthy <j-keerthy@ti.com>
---

Changes in v2:

  * Added an empty suspend function with a comment to explain why
    nothing needs to be done during suspend

 drivers/memory/ti-emif-pm.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

Comments

Santosh Shilimkar May 23, 2018, 6:36 p.m. UTC | #1
On 5/23/2018 10:32 AM, Keerthy wrote:
> From: Dave Gerlach <d-gerlach@ti.com>
> 
> After an RTC+DDR cycle we lose sram context so emif pm functions present
> in sram are lost. We can check if the first byte of the original
> code in DDR contains the same first byte as the code in sram, and if
> they do not match we know we have lost context and must recopy the
> functions to the previous address to maintain PM functionality.
> 
> Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
> Signed-off-by: Keerthy <j-keerthy@ti.com>
> ---
> 
> Changes in v2:
> 
>    * Added an empty suspend function with a comment to explain why
>      nothing needs to be done during suspend
> 
Just 1 patch or you just posted only the updated one ?
  Your earlier series has 14 patches and hence the question.

Patch itself looks fine to me.

Regards,
Santosh
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
J, KEERTHY May 23, 2018, 7:26 p.m. UTC | #2
On 5/24/2018 12:06 AM, Santosh Shilimkar wrote:
> On 5/23/2018 10:32 AM, Keerthy wrote:
>> From: Dave Gerlach <d-gerlach@ti.com>
>>
>> After an RTC+DDR cycle we lose sram context so emif pm functions present
>> in sram are lost. We can check if the first byte of the original
>> code in DDR contains the same first byte as the code in sram, and if
>> they do not match we know we have lost context and must recopy the
>> functions to the previous address to maintain PM functionality.
>>
>> Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
>> Signed-off-by: Keerthy <j-keerthy@ti.com>
>> ---
>>
>> Changes in v2:
>>
>>    * Added an empty suspend function with a comment to explain why
>>      nothing needs to be done during suspend
>>
> Just 1 patch or you just posted only the updated one ?
>  Your earlier series has 14 patches and hence the question.

Yes, the original one had 14 patches which i split into multiple smaller 
series and
am posting them separately.

>
> Patch itself looks fine to me.
>
> Regards,
> Santosh

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Santosh Shilimkar May 23, 2018, 7:32 p.m. UTC | #3
On 5/23/2018 12:26 PM, J, KEERTHY wrote:
> 
> 
> On 5/24/2018 12:06 AM, Santosh Shilimkar wrote:
>> On 5/23/2018 10:32 AM, Keerthy wrote:
>>> From: Dave Gerlach <d-gerlach@ti.com>
>>>
>>> After an RTC+DDR cycle we lose sram context so emif pm functions present
>>> in sram are lost. We can check if the first byte of the original
>>> code in DDR contains the same first byte as the code in sram, and if
>>> they do not match we know we have lost context and must recopy the
>>> functions to the previous address to maintain PM functionality.
>>>
>>> Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
>>> Signed-off-by: Keerthy <j-keerthy@ti.com>
>>> ---
>>>
>>> Changes in v2:
>>>
>>>    * Added an empty suspend function with a comment to explain why
>>>      nothing needs to be done during suspend
>>>
>> Just 1 patch or you just posted only the updated one ?
>>  Your earlier series has 14 patches and hence the question.
> 
> Yes, the original one had 14 patches which i split into multiple smaller 
> series and
> am posting them separately.
> 
OK. Will queue this up for 4.19
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/memory/ti-emif-pm.c b/drivers/memory/ti-emif-pm.c
index 632651f..2e88dc1 100644
--- a/drivers/memory/ti-emif-pm.c
+++ b/drivers/memory/ti-emif-pm.c
@@ -249,6 +249,34 @@  int ti_emif_get_mem_type(void)
 };
 MODULE_DEVICE_TABLE(of, ti_emif_of_match);
 
+#ifdef CONFIG_PM_SLEEP
+static int ti_emif_resume(struct device *dev)
+{
+	unsigned long tmp =
+			__raw_readl((void *)emif_instance->ti_emif_sram_virt);
+
+	/*
+	 * Check to see if what we are copying is already present in the
+	 * first byte at the destination, only copy if it is not which
+	 * indicates we have lost context and sram no longer contains
+	 * the PM code
+	 */
+	if (tmp != ti_emif_sram)
+		ti_emif_push_sram(dev, emif_instance);
+
+	return 0;
+}
+
+static int ti_emif_suspend(struct device *dev)
+{
+	/*
+	 * The contents will be present in DDR hence no need to
+	 * explicitly save
+	 */
+	return 0;
+}
+#endif /* CONFIG_PM_SLEEP */
+
 static int ti_emif_probe(struct platform_device *pdev)
 {
 	int ret;
@@ -308,12 +336,17 @@  static int ti_emif_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static const struct dev_pm_ops ti_emif_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(ti_emif_suspend, ti_emif_resume)
+};
+
 static struct platform_driver ti_emif_driver = {
 	.probe = ti_emif_probe,
 	.remove = ti_emif_remove,
 	.driver = {
 		.name = KBUILD_MODNAME,
 		.of_match_table = of_match_ptr(ti_emif_of_match),
+		.pm = &ti_emif_pm_ops,
 	},
 };
 module_platform_driver(ti_emif_driver);