From patchwork Fri Sep 9 19:13:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 668198 X-Patchwork-Delegate: cyrille.pitchen@atmel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sW6PX5bHdz9ryQ for ; Sat, 10 Sep 2016 05:16:16 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=tB8WlNQi; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1biRGG-0003Zn-Ml; Fri, 09 Sep 2016 19:14:52 +0000 Received: from mail-pa0-x244.google.com ([2607:f8b0:400e:c03::244]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1biRGC-0003E9-NV for linux-mtd@lists.infradead.org; Fri, 09 Sep 2016 19:14:49 +0000 Received: by mail-pa0-x244.google.com with SMTP id h5so4217016pao.0 for ; Fri, 09 Sep 2016 12:14:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=2S8gtnG+V/oE+b7u+MHDksX4wKE10fCWEMDSun8FEx0=; b=tB8WlNQiTZCz8m4Pz35Q8k2bu8lr6oENzz2Dz52IQCmEymZzClY6F5d8Y/uGtwHYsE +sSPALHwCPRJ4f7F1CWKTnhMDtT54wpVL3sE7eeu2EyYrB1NfFkp1ue9g3OKOrr7RO9t 92PrDbp08MVz3kXZnpjU19F3eTwEZ1dfjty6IqndfNGRDei+FSkes534dhokjBFsa6ge iYe+KyXm6KX2lnDr6YGR/EG4JDX8Id0ILyP8y4CGQKGUv6uVka/ARjH3mw+4m54z9Ex8 UHMFQQ+KXDutEV9HZfuWV8gSR6onj5r6O//OCbnawhFb+ZGzOgq63cVkdtobsfN4zCLg Rvaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2S8gtnG+V/oE+b7u+MHDksX4wKE10fCWEMDSun8FEx0=; b=HwdWNVmp4ZiK2Upb2ShxamaXhrIATX3cZl3bmPjOSNUW1AE6niFSAOHw+C2a5k2qm8 VTBsasGmVN8+fhklPaTXjBh+jNaEMUw1LgKMQ2qdEV8qHD2naveCWXmhTE+JDuDvadyd qFxyH857NWYhiKZ4N7K55c4YJ/MPEQguSwxijNpcln4I3+8utUCxZUe8CIdGBs7NW3Eq P8OhNL3H538gzLcYWdUm8Vga0rRcSLLnjWcOQRR8iCliE75QSbi6lKu4K1ILkLCMTI5e RyZeBUMrICogDQv6mhnipYtMzHeSJ6EiaT3dPtmCNGPVgy/DQOuKb232u/gZ6OUkjJGr A+5g== X-Gm-Message-State: AE9vXwNcyDg2VCrk1WVfhqjWxWbGAPncBwpqdujHzd+8ecCvknjKiSPnjbRbAH3/s6+mUg== X-Received: by 10.66.88.135 with SMTP id bg7mr9222257pab.107.1473448467451; Fri, 09 Sep 2016 12:14:27 -0700 (PDT) Received: from mail.broadcom.com ([216.31.219.19]) by smtp.gmail.com with ESMTPSA id n7sm7058153pfg.45.2016.09.09.12.14.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Sep 2016 12:14:26 -0700 (PDT) From: Kamal Dasu To: linux-spi@vger.kernel.org, f.fainelli@gmail.com, linux-mtd@lists.infradead.org, computersforpeace@gmail.com Subject: [PATCH 1/1] mtd: devices: m25p80: Add PM suspend resume support Date: Fri, 9 Sep 2016 15:13:58 -0400 Message-Id: <1473448438-13245-1-git-send-email-kdasu.kdev@gmail.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160909_121448_858904_F191B864 X-CRM114-Status: GOOD ( 13.43 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c03:0:0:0:244 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (kdasu.kdev[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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 X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bcm-kernel-feedback-list@broadcom.com, Kamal Dasu MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Adding PM support so as to be able to probe spi-nor flash on resume. There are vendor specific commands to setup the transfer mode and enable read/write as part of spi_nor_scan(), done on intial probe and needed on resume(). The spi-nor stucture is private to the m25p driver and hence is the only place this can be done without having to duplicate code in controller driver. Signed-off-by: Kamal Dasu --- drivers/mtd/devices/m25p80.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 9cf7fcd..f8294b4 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -248,7 +248,6 @@ static int m25p_probe(struct spi_device *spi) data ? data->nr_parts : 0); } - static int m25p_remove(struct spi_device *spi) { struct m25p *flash = spi_get_drvdata(spi); @@ -319,10 +318,46 @@ static const struct of_device_id m25p_of_table[] = { }; MODULE_DEVICE_TABLE(of, m25p_of_table); +#ifdef CONFIG_PM_SLEEP +static int m25p_suspend(struct device *dev) +{ + return 0; +} + +static int m25p_resume(struct device *dev) +{ + struct m25p *flash = dev_get_drvdata(dev); + struct flash_platform_data *data; + char *flash_name = NULL; + enum read_mode mode = SPI_NOR_NORMAL; + int ret; + + data = dev_get_platdata(&flash->spi->dev); + + if (data && data->type) + flash_name = data->type; + else if (!strcmp(flash->spi->modalias, "spi-nor")) + flash_name = NULL; /* auto-detect */ + else + flash_name = flash->spi->modalias; + + if (flash->spi->mode & SPI_RX_QUAD) + mode = SPI_NOR_QUAD; + else if (flash->spi->mode & SPI_RX_DUAL) + mode = SPI_NOR_DUAL; + + ret = spi_nor_scan(&flash->spi_nor, flash_name, mode); + + return ret; +} +#endif +static SIMPLE_DEV_PM_OPS(m25p_pm_ops, m25p_suspend, m25p_resume); + static struct spi_driver m25p80_driver = { .driver = { .name = "m25p80", .of_match_table = m25p_of_table, + .pm = &m25p_pm_ops, }, .id_table = m25p_ids, .probe = m25p_probe,