From patchwork Fri May 14 06:25:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 52566 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1FCA3B7E8E for ; Fri, 14 May 2010 16:38:24 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1OCoVW-0006gb-L3; Fri, 14 May 2010 06:36:26 +0000 Received: from mail-pv0-f177.google.com ([74.125.83.177]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1OCoLE-0007jn-Pd; Fri, 14 May 2010 06:25:50 +0000 Received: by pvg3 with SMTP id 3so514064pvg.36 for ; Thu, 13 May 2010 23:25:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=eYlTLn+6XU8JJTlBkEIGaYSMh7nU0EoA9naTMGvO3zA=; b=VyyikGcxms8PM3MEu4GTHaf7jhOr8qc0psj1sHLcuIsmBRuQudpxnBXWAVcK6mCCgb IdC7Uqiw+47Znh/iU0k5OVkA8As12k3zpY20bFAxDvIjFNJ2UdvAZFCBtv5vHYm6n6kn 2Y0+R/u17b7EV3iRD+LSpDpYfzo+t6xrEqnNs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=XWN1GsBZfROddi9lS9Me7QUaLmkpWm8WyptPnPYKCpmSQ0v6PsZEGC6c4O7DcfRx/m hVN55ZtosQbKgF2qXi0Ip6AFYLEDXcE0Y+48+3zKQfyMpXKGh4KQA0Kvrogs7IVAokqm V8HCKjzxIp9wb2BLegSoOL0XxFor0JcSUvWSY= MIME-Version: 1.0 Received: by 10.143.21.32 with SMTP id y32mr411622wfi.60.1273818347378; Thu, 13 May 2010 23:25:47 -0700 (PDT) Received: by 10.142.252.16 with HTTP; Thu, 13 May 2010 23:25:47 -0700 (PDT) Date: Fri, 14 May 2010 14:25:47 +0800 Message-ID: Subject: [PATCH 20/20] mtd: pxa3xx_nand: fix power management support From: Haojian Zhuang To: Marc Kleine-Budde , David Woodhouse , David Woodhouse , linux-mtd@lists.infradead.org, Eric Miao , linux-arm-kernel X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100514_022549_770928_4C549999 X-CRM114-Status: GOOD ( 16.63 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.3.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.83.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is freemail (haojian.zhuang[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From 90e374bdb162c2e77c6dfc3f38ca5a2e283c4730 Mon Sep 17 00:00:00 2001 From: Lei Wen Date: Thu, 1 Apr 2010 15:12:09 +0800 Subject: [PATCH] mtd: pxa3xx_nand: fix power management support Signed-off-by: Lei Wen Signed-off-by: Haojian Zhuang --- drivers/mtd/nand/pxa3xx_nand.c | 48 +++++++++++++++++++++++++++++++-------- 1 files changed, 38 insertions(+), 10 deletions(-) } #else diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c index 2e1c8b6..15bc539 100644 --- a/drivers/mtd/nand/pxa3xx_nand.c +++ b/drivers/mtd/nand/pxa3xx_nand.c @@ -1844,26 +1844,54 @@ static int __devinit pxa3xx_nand_probe(struct platform_device *pdev) #ifdef CONFIG_PM static int pxa3xx_nand_suspend(struct platform_device *pdev, pm_message_t state) { - struct pxa3xx_nand_info *info = platform_get_drvdata(pdev); - struct mtd_info *mtd = info->mtd; + struct pxa3xx_nand *nand= platform_get_drvdata(pdev); + struct pxa3xx_nand_info *info; + struct mtd_info *mtd; + int ret = 0; + uint8_t cs; - if (info->state & STATE_CMD_PREPARED) { - dev_err(&pdev->dev, "driver busy, state = %d\n", info->state); + if (nand->state & STATE_CMD_PREPARED) { + dev_err(&pdev->dev, "driver busy, state = %d\n", nand->state); return -EAGAIN; } - return 0; + for (cs = 0; cs < NUM_CHIP_SELECT; cs ++) { + info = nand->info[cs]; + if (!info) + continue; + mtd = get_mtd_by_info(info); + ret = mtd->suspend(mtd); + } + + return ret; } static int pxa3xx_nand_resume(struct platform_device *pdev) { - struct pxa3xx_nand_info *info = platform_get_drvdata(pdev); - struct mtd_info *mtd = info->mtd; + struct pxa3xx_nand *nand= platform_get_drvdata(pdev); + struct pxa3xx_nand_info *info; + struct mtd_info *mtd; + uint8_t cs; - nand_writel(info, NDTR0CS0, info->ndtr0cs0); - nand_writel(info, NDTR1CS0, info->ndtr1cs0); - clk_enable(info->clk); + for (cs = 0; cs < NUM_CHIP_SELECT; cs ++) { + info = nand->info[cs]; + if (!info) + continue; + nand_writel(nand, NDTR0CS0, info->ndtr0cs0); + nand_writel(nand, NDTR1CS0, info->ndtr1cs0); + nand->chip_select = cs; + /* Sometimes nand chip would raise a ready interrupt + * when resume, reset the by start and stop to prevent + * it damage driver's state machine */ + pxa3xx_nand_start(nand); + pxa3xx_nand_stop(nand); + mtd = get_mtd_by_info(info); + mtd->resume(mtd); + } + /* set the controller cs to a invalid num to let driver + * reconfigure the timing when it call the cmdfunc */ + nand->chip_select = 0xff; return 0;