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: 9324179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 02B0560231 for ; Fri, 9 Sep 2016 19:14:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6FDD29FC0 for ; Fri, 9 Sep 2016 19:14:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBB4129FC2; Fri, 9 Sep 2016 19:14:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.4 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8131229FC0 for ; Fri, 9 Sep 2016 19:14:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752196AbcIITO2 (ORCPT ); Fri, 9 Sep 2016 15:14:28 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:36079 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752015AbcIITO2 (ORCPT ); Fri, 9 Sep 2016 15:14:28 -0400 Received: by mail-pa0-f68.google.com with SMTP id ez1so4192547pab.3 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=eLsSRhqbv3uPbQOP7NxL/MQhvx+S5mGTC0bav+HaHXHYs2gQxIKOWSn8aX/nhn/0Sr v2JT1hO7TgFJBaOMH4/v/O1Ic1J491K8INwGwSpFa8dTK4/NG67dCbVdHvV+WTxQy+Wj UkO5rL57PBHmquHpd3dEbrZrS1ERkEeFdp2Qu1VA85+vZtukd05q1ilbNRSLq2vM0F1g jV2doBnpEXZjwsPJZgJbTri9Hnmrx8Q2rCno5JB9rvBVt8bpEVoA2R71UxIjemixGgr6 LdqLrHHf5SVJyqxpEMiqFeTtGkfnxMmPkR7ayymUpl7Wo27hYoXnh15EW5nnaz2t5XtS GYKA== X-Gm-Message-State: AE9vXwOH3figZSlaR5tl668TopIAx5eqwTCWYEpnMnWEwSBjo6UA+GxN/3E5CIuTm8CrFA== 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 Cc: bcm-kernel-feedback-list@broadcom.com, Kamal Dasu 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 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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,