Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752939AbbH1TmV (ORCPT ); Fri, 28 Aug 2015 15:42:21 -0400 Received: from mail-by2on0117.outbound.protection.outlook.com ([207.46.100.117]:12864 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752561AbbH1Tlq (ORCPT ); Fri, 28 Aug 2015 15:41:46 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=freescale.com; From: Han Xu To: CC: , , , , , , , , , , Subject: [PATCH v3 1/6] mtd: nand: gpmi: add gpmi dsm supend/resume support Date: Fri, 28 Aug 2015 14:32:40 -0500 Message-ID: <1440790365-28072-2-git-send-email-b45815@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440790365-28072-1-git-send-email-b45815@freescale.com> References: <1440790365-28072-1-git-send-email-b45815@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD010;1:u2Y/KJKOsjS+vT3CzckDHdbY6b62wQAsvrNpi/lhHSrWYiPOsUfAabQbKOVchnGcikwJMS90vw8z+KC4AF14GwgL2rs7u1jQDEaS8fO3JrHFHm3CTN4xi0QLBBiYSZ10k9h91IrhhxzjjnwiksgcX06f98Hioiz39x3pbMlSsCGB5G7e3WUp5tBtaJA4pp2xBqGMiru2dIwJrSxjhbsW9Z6XrxjIcEUhM3vrXjgRPJ0aXKhWvuVy63P0KjFc44Y1KRNwSCDIunCwrjlsY85cYkCSfLInrsCntJIYlLzFJaYtuAO2aj15Xpv93crb+kgBf6ltn2VQyiDXLxy4pc0OUVxXplDNselfFpj1uPUnW6G/yqqp46ZA0nd3+6yBVPijpbJ/85ZgrVoE9pALFQ19C/b1S+MTJzaJW2Ig7f2ykGI= X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(3050300001)(189002)(199003)(5003940100001)(77156002)(62966003)(5007970100001)(47776003)(64706001)(4001540100001)(5001830100001)(5001860100001)(97736004)(81156007)(50226001)(5001960100002)(110136002)(105606002)(106466001)(2950100001)(46102003)(2351001)(189998001)(229853001)(68736005)(77096005)(48376002)(50466002)(76176999)(50986999)(33646002)(92566002)(87936001)(104016003)(575784001)(85426001)(19580405001)(36756003)(19580395003)(6806004)(2004002);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR03MB560;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB560;2:s4jdB0sWDklFYy4FKI//wDK31xZbHUJNQ8xsLlFnzdE+I5Cepj+oOThPyGUpjFaF+FAY0GWjRcFDW0w7sD9MYn5W/FCRNRG1qENR69s/knrIWCnlcgHSMEApWv0a+wzKhGevxg9Hj4UowOtV00UUZAgbAXff1v+VCij7chgx7Ls=;3:QSpXRzFuGKAfg6YBsK5SXwoe1pE8LlwTOPKYnxCl6HwCGEQFimCNzAY/peWeiXTGvtI2PTvz1NkpC50fhyxbHCx9ZAkZL2ZOWZeUCMbp25chNo1ga1f6/9GxzWVAYgoeRc8QgyjF3Y99yyAZPM1rlUs4x/E4PsZYUF3N007D6t8fCuiv1GjdWLUs6IM12KV34QlpoA/5eDmGVXRFQkQErEU5Ooca2Ul6zwjJA4iKj04=;25:FwQ6xX+jj8DbwLhj9DbevcXfBiVOFWKjEtC0NqzHp0gPi21m1f8R/GB732S2vn8HwxGhYCUM9jwbm6NBQt7fCuKQve2WJg+37qldJVCaZjaad94zEbUBlKQ+bhfih6pWg18041AtYnFid/7o+j6jHpuA0hoAJlxmtPQm1cRh1l0600mEMBP78fcR7ML4SDj2lLvVkygfVBSZXALcXZ67QeIxcbK94GEaxJp42MhJ/g1Fkxrxt32bVpx3cG6s27yZ X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR03MB560; X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB560;20:q5mPfGSB//hpjxyH56hGbppZkUsvcWOj3PFLNfbCeZBmrfdUikeyxplDQ1MN/29XQmAwivCBI1kJa1IGU1bWuDBHrqTVSBQQ5qd7w7BwsupOaFtU5m6aY1l/oEmQDCPsZswyh2w3QQ1yaQOIdtyi22zZ5yLUT3VAfj3qYYpjuTZp4MoKuEM2wBXKLg8yjMRs7ykDexVUwMPdN9a4px5u4WJJ7JxfMw1+xFxl7qOZWT7eE0RnZUcOq5vcWrqn8AIbfAV8nkEWm8jMQCUBZKyS91pLoBJIvEvZSHcelaw1agxk27wK1c1wjynM86ItO75a9gZPycATqlT9Am/2KyUREFFO+lZzinbB6xtmH/SjaOU=;4:D+cBfkOtXl6kGAgys2tfpoFEsNewJYtF1JypkS1H76V7TmfYgUaa775SgSeFsu7Yg5mPBsddMqgCI8CsSsGDmuZ0Nzwmdo2NNdOgBqysP19X24fF7W6kQasauTA/DlmwxCO0fxZWVTd3Tj7ZLffu5GKj8ZuUAm5KFk/17kS4dQE+750YxCQvra3Dtt7Nv5pfj9rfKZcW4ABz+Kc5zCLHUchGZW63JQ+hJr2n/HmqW+tkJk+OLXzt1A7AYQT6W+uAHicCpTaOnFrEfOr9TG1HThL42kbN3+QV/iJq16DI3FFfocUV+LhZPO43HubtIR4d X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(8121501046)(3002001);SRVR:DM2PR03MB560;BCL:0;PCL:0;RULEID:;SRVR:DM2PR03MB560; X-Forefront-PRVS: 0682FC00E8 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM2PR03MB560;23:VWLN9jlvN3PwWiaID0seziKkqXEklO8no8U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3tBz5K9TpKlLL3yYwxnwJAY?= =?us-ascii?Q?kBjUoegvexu2QDuyQLWKCwL7m2VbMNbXdKpoUUR3DasoTATBAinu1cPSke4Z?= =?us-ascii?Q?BkLoq8GWFh/AoE/RWMDA8h04FHAV5w+GBlp+gHVJdx9kiQEoXwIPw+7jInvV?= =?us-ascii?Q?VWGGKODZgagjD2XPpThb9NyhTFpJ6+gH1IMlKb2b2u3d/39dZljrDN8/8Fqn?= =?us-ascii?Q?UIDrFIfBir9fjq/909IDdx+WhJg1hQG3JZHEPGP1TAXAo7310KdrKT4+uGG+?= =?us-ascii?Q?+RlmmniIPePcM=3D?= X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB560;5:75rLZTvt4rVwxfKmM/4sVyQGAoBw5EpIklGJeicu6AJnCRJ2hPTyLTrGxaHjOWGgJ6HKhwNQ0Hd9X318swD0gUga7EBhTsvHeaSHKOJ+Lw74f9Qkx1aku09jCdXACTR68zbLbgjhLiGczEGfUtaq9g==;24:M1XxtzBEnI+2GJFDvqVLSlh3cyc4I1cekpY6M1QbNYngfgnCL5qf6CNdQt2/iBnL08fHhUsT1oGWuQFpuwXpeQAPuWjI5mcrFbcwEMUzlEY=;20:gxQPol+iHy76cjDHGQfq61BCuuNbTBL7daSLFWqgap7WT0TTFqf4/npLjnKB/KDGRqbWFv+14L9Q6ss5JXJqrw== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2015 19:41:42.8733 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR03MB560 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2581 Lines: 91 From: Huang Shijie i.MX6SX supports deep sleep mode(DSM) that may turn off GPMI/BCH power during suspend, add gpmi nand suspend/resume function to release DMA channel in suspend function and re-init GPMI/BCH controller during resume function. Although it is not necessary to restore GPMI/BCH registers value for i.MX6QDL, the code doesn't distinguish different platforms to keep the code simple. Signed-off-by: Huang Shijie Signed-off-by: Han Xu --- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 45 +++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c index 1b8f350..dfd0ba1 100644 --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c @@ -1,7 +1,7 @@ /* * Freescale GPMI NAND Flash Driver * - * Copyright (C) 2010-2011 Freescale Semiconductor, Inc. + * Copyright (C) 2010-2015 Freescale Semiconductor, Inc. * Copyright (C) 2008 Embedded Alley Solutions, Inc. * * This program is free software; you can redistribute it and/or modify @@ -2036,9 +2036,52 @@ static int gpmi_nand_remove(struct platform_device *pdev) return 0; } +static int gpmi_pm_suspend(struct device *dev) +{ + struct gpmi_nand_data *this = dev_get_drvdata(dev); + + release_dma_channels(this); + return 0; +} + +static int gpmi_pm_resume(struct device *dev) +{ + struct gpmi_nand_data *this = dev_get_drvdata(dev); + int ret; + + ret = acquire_dma_channels(this); + if (ret < 0) + return ret; + + /* re-init the GPMI registers */ + this->flags &= ~GPMI_TIMING_INIT_OK; + ret = gpmi_init(this); + if (ret) { + dev_err(this->dev, "Error setting GPMI : %d\n", ret); + return ret; + } + + /* re-init the BCH registers */ + ret = bch_set_geometry(this); + if (ret) { + dev_err(this->dev, "Error setting BCH : %d\n", ret); + return ret; + } + + /* re-init others */ + gpmi_extra_init(this); + + return 0; +} + +static const struct dev_pm_ops gpmi_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(gpmi_pm_suspend, gpmi_pm_resume) +}; + static struct platform_driver gpmi_nand_driver = { .driver = { .name = "gpmi-nand", + .pm = &gpmi_pm_ops, .of_match_table = gpmi_nand_id_table, }, .probe = gpmi_nand_probe, -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/