Received: by 10.192.165.156 with SMTP id m28csp1489381imm; Wed, 11 Apr 2018 21:02:44 -0700 (PDT) X-Google-Smtp-Source: AIpwx49GtPe/5z1hNddNG5MICqzl8Tdu2i++dmSASHWWBhDXa9aqOjbrSYZLsPbgnCzicf/h+X8x X-Received: by 2002:a17:902:1e5:: with SMTP id b92-v6mr7939575plb.78.1523505764920; Wed, 11 Apr 2018 21:02:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523505764; cv=none; d=google.com; s=arc-20160816; b=EcvNQj1th1+9KDbT7qfWGE8PErDRcskK1HIlqpb7TIVlq+xp1bOBmrTRN/GzX56Gid 5e9p4Ji5I1vFxW2RS6+gVxryjRSZ20yb6J9V6sawr6cxWjBrsEFCDtXqsMgr0+1g2n6+ +kXYgeqTWvyKESM/7p91HlcS/IMBeP2p7g4q80WbHcZ/IM9sG37X6OHi2NdwdQzYsu+G MGI1QO6YLYZeLfKLUHbbxeucsEqtkgvDP18IFyCtvUlh/e9vwtCIAgh+I3LHWa5yUqFn G/4pdDDFdV1gmJiXWmVm8J35hCI/2+GlhlWsWZwTTrK5QzI1kcSwCueEYZJyhNkvsz/K wjeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=W0ydGQMz5dolplO3f4QkpvAG58a9y29dBLSScuc/Nss=; b=ZGPXBBlAz9XzUjEAIqGc467Txj3QKt44QhwQk5dxc+vybkTmNGcgoj+hYGCyIxQiJ7 wd8FJHlWC3AqW7774A4Vrp1Lsd0w9H9DoPNVlSsge2b8bY85Mqn3L9VOzWP9nAv/teWY hGV1H/HdePg9k4ekNMyE041MywFPDZOGbRsAOE3JprvK9CmvDjAUp76DV/FPQGiZXHhv +f32VvrY08mm9UvFn8fd0H3mlAFXde8GZ+dJjdyWLqoW8K3Qo4fFmPivsqn84eKeo1xG uOD4/EzBtB91jxeQIQw09zInJeRzDXie2qzNCxpk63gc8Y9RPXG030zC1pTin5iPrfg1 cnRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Z3yWsf2z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u25si1679169pgo.388.2018.04.11.21.02.08; Wed, 11 Apr 2018 21:02:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Z3yWsf2z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752569AbeDLDyz (ORCPT + 99 others); Wed, 11 Apr 2018 23:54:55 -0400 Received: from lelnx193.ext.ti.com ([198.47.27.77]:16688 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752458AbeDLDyx (ORCPT ); Wed, 11 Apr 2018 23:54:53 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id w3C3sYaL005361; Wed, 11 Apr 2018 22:54:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1523505274; bh=Xt10HpfQZPW+h3fXYI3O0oP4wI866w52q1BO7/SCdZQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Z3yWsf2zONUeXZHaFnoMhECQY2OuxVqzU277geHqRhe81c1XEB702OsqAArwyEqgC 8b95FDihAOe4rXkxRxwU+Xhwfd1tUnIYJerjTXv7VOsJbFpcpscLNopmh9mbmIsyQt VOo4ElWhHVyTltcT+JXlzrB6QvoCJ54FSoFNPQ/s= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w3C3sYh2026052; Wed, 11 Apr 2018 22:54:34 -0500 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Wed, 11 Apr 2018 22:54:34 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Wed, 11 Apr 2018 22:54:34 -0500 Received: from ula0393675.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w3C3sQpi010150; Wed, 11 Apr 2018 22:54:31 -0500 From: Keerthy To: , , CC: , , , , , , , , Subject: [PATCH 01/14] memory: ti-emif-sram: Add resume function to recopy sram code Date: Thu, 12 Apr 2018 09:23:46 +0530 Message-ID: <1523505239-16229-2-git-send-email-j-keerthy@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1523505239-16229-1-git-send-email-j-keerthy@ti.com> References: <1523505239-16229-1-git-send-email-j-keerthy@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Gerlach 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 Signed-off-by: Keerthy --- drivers/memory/ti-emif-pm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/memory/ti-emif-pm.c b/drivers/memory/ti-emif-pm.c index 632651f..ec4a62c 100644 --- a/drivers/memory/ti-emif-pm.c +++ b/drivers/memory/ti-emif-pm.c @@ -249,6 +249,25 @@ 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; +} +#endif /* CONFIG_PM_SLEEP */ + static int ti_emif_probe(struct platform_device *pdev) { int ret; @@ -308,12 +327,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(NULL, 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); -- 1.9.1