From patchwork Thu May 6 09:15:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 51819 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 D5C13B7D5D for ; Thu, 6 May 2010 19:16:44 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1O9xB3-0003lh-0A; Thu, 06 May 2010 09:15:29 +0000 Received: from mail-px0-f177.google.com ([209.85.212.177]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1O9xAu-0003d2-7O; Thu, 06 May 2010 09:15:21 +0000 Received: by pxi1 with SMTP id 1so2822960pxi.36 for ; Thu, 06 May 2010 02:15:19 -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=MmAmtPlIduff/Sfw0sKAKkn7ZE1HeI0XcD2YWhgfPFM=; b=Ps23dIYwDirEH6e/3eXTd0PxA+KHBlk+64aL6hyBNiLzVhgnX+EBXAhczaneUXm7yl LzIhP3rYKbpeaexhqxydA0MJb9ick+VJofs6lracRgDjpDofI19AItAxOpGPyKEzc+Bi 46xrhh+c5Nk1JobvGxPpbS0Ie3DnvAzQt9c6Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=C9GJdtglrPfsUE2l0jODB8Ssgw7Y99UtpgZORkrDbjFIbLUmH4AHBoZ8UQT3cw+RSZ MWez0XLXOnMPOg5lbtULPoT0KZ+VznohZdvgBlxntfJa5P2b5+VnKZX3nrV32d2+5vrP 3MZ1JF8KPAoAmJcb/AvxeatZVoJucwMRzoeaw= MIME-Version: 1.0 Received: by 10.143.194.4 with SMTP id w4mr7874333wfp.155.1273137319032; Thu, 06 May 2010 02:15:19 -0700 (PDT) Received: by 10.142.252.16 with HTTP; Thu, 6 May 2010 02:15:18 -0700 (PDT) Date: Thu, 6 May 2010 05:15:18 -0400 Message-ID: Subject: [PATCH 20/20] pxa3xx_nand: fix power management support From: Haojian Zhuang To: Eric Miao , linux-arm-kernel , David Woodhouse , linux-mtd@lists.infradead.org X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100506_051520_377962_6E5C6262 X-CRM114-Status: GOOD ( 14.94 ) 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 [209.85.212.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 19580f958929fe5901df8b41f04b23b855326330 Mon Sep 17 00:00:00 2001 From: Lei Wen Date: Thu, 1 Apr 2010 15:12:09 +0800 Subject: [PATCH] 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;