From patchwork Fri Feb 2 05:31:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yogesh Narayan Gaur X-Patchwork-Id: 10196257 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 3080660247 for ; Fri, 2 Feb 2018 05:33:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 209C228DCC for ; Fri, 2 Feb 2018 05:33:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1540D28DDD; Fri, 2 Feb 2018 05:33:37 +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.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7218F28DCC for ; Fri, 2 Feb 2018 05:33:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kPZ++PnRq0Mj+Fh+mrFl1IZQS9MbQUfmcidk7cxrJUI=; b=VvE+cDyY0cz6Sw atjYBSb3u8GWplulTkoFfWFJeXw6mQwIKvczERm9XoC8Me1xRHYgW1yiua4v5XkSnvesH/F3IdeDW /WV/frmjLaVpvPU3cXoEbuG5Lspu6E00bE+RqTiBcwu1Yu4Pu0NpXZ8SB4TIttQsxOp1RxwJGwzz3 MSuvX1cdFE42lCzZLEoZEbq1rK4wLIBEWHm3kJi8FxzPO0ABwTEQ7tdReKzYgKF83yYLQTyu5Ss6h SLQLWQqY8mpHu9MAc+8E1Ia7rcHXFQY3jV0ePi4Y2uC3J7/zXQwWTQZxt61DeWPtvwX4GoCqlfn06 yL9Gmcuf13JRplQpHECA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ehTyg-0001GP-GZ; Fri, 02 Feb 2018 05:33:34 +0000 Received: from mail-he1eur01on0055.outbound.protection.outlook.com ([104.47.0.55] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ehTy5-0000Zf-Da; Fri, 02 Feb 2018 05:32:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=CDL8ij3veY3TIMKE0S8qjoHbK2bJg60f8Yx2EmdoZrc=; b=aJywhzXCpxZQpkuYjAbZCO468cngneObzA+mjSiQuEwYNAAkuuGeVprneSUePO/HXioCUjbyOcEPEx7jxV6XAB/rowX2J2w9nsc0nTfT+KYqeN2ljPbBrA+zuLlSm4d6Drjic+cpVMDFv/PrUXvOzfhWEWrxA39hSuWhhg2JrFw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yogeshnarayan.gaur@nxp.com; Received: from idcbfarm.ap.freescale.net (192.88.169.1) by HE1PR0402MB2842.eurprd04.prod.outlook.com (2603:10a6:3:d6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Fri, 2 Feb 2018 05:32:40 +0000 From: Yogesh Gaur To: linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, robh@kernel.org, mark.rutland@arm.com, shawnguo@kernel.org Subject: [PATCH v2 1/2] mtd: fsl-quadspi: Update slave device hwcap based on mode provided in dtsi file Date: Fri, 2 Feb 2018 11:01:23 +0530 Message-Id: <1517549484-6024-2-git-send-email-yogeshnarayan.gaur@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1517549484-6024-1-git-send-email-yogeshnarayan.gaur@nxp.com> References: <1517549484-6024-1-git-send-email-yogeshnarayan.gaur@nxp.com> MIME-Version: 1.0 X-Originating-IP: [192.88.169.1] X-ClientProxiedBy: BM1PR0101CA0013.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::23) To HE1PR0402MB2842.eurprd04.prod.outlook.com (2603:10a6:3:d6::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f51345a0-a43b-481f-84dd-08d569fe63fb X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:HE1PR0402MB2842; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0402MB2842; 3:eNduK3eAcFf0fa5aGyhQVF54XhevxCDagdZhHV5U1QRpeY/xBcT9gSMjkanDqBUjWo3WdOwgAef9seUr+uGB81gE4qvMxxyoa/8ft4mRUfFqnZ1gwCzp6hk02KzhIbJwXU3Y2cpbulNWxgEHO+g6rgXe0oC3r+bxpdRh0LSz6Uqp4NKEVF7GR63CB+viIiC/Io9b5XqEnLaNxFqLAQMD45VOcHeT+H/z77HqsNshONDEsYhM74O/XoUlV7FUYYti; 25:GB9Tz+0BmLP4sNs4Mqk4C2a3RlyHUmvOuCLiPwzGE25lmatGPpu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vgv+9QQ1kOFUkBu3WrqOitNL43; 4:xJFLYcN3vr/rIT+LJTiOTgRCrsgAa7a5AKRft5+tavqVIlRy+WOLoASfD3YzgaApYS3JEbsnJov9HH9gjAExp8OfFjS7haVUV2PVigqBPb1t8DptgVwwa/hu2DIYmmhba6amG36kdVCtv46nZ9TqiC43WJfV7ft6PdiCc0DCYCUrqgneUY1B0bl5YpfFmlNnnM0GDRKvZ0DID5P7buH5MF21GC1CAsf8lgallCj6rr+ldbOY33jQlvSzxuDQmg4vvmL04iQ0SIQsqNzeT9uyPoau0zlAbd1zu2DBWS1eLNgSCvUBrAGSq67/GiJrPnE2 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3231101)(2400082)(944501161)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041288)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011); SRVR:HE1PR0402MB2842; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0402MB2842; X-Forefront-PRVS: 05715BE7FD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(346002)(366004)(396003)(39380400002)(199004)(189003)(68736007)(4326008)(186003)(16526019)(39060400002)(36756003)(5660300001)(2906002)(106356001)(478600001)(53936002)(305945005)(15650500001)(575784001)(86362001)(7736002)(6486002)(6512007)(16586007)(66066001)(316002)(26005)(7416002)(105586002)(3846002)(2950100002)(6116002)(50466002)(6666003)(48376002)(59450400001)(6506007)(386003)(50226002)(8676002)(25786009)(51416003)(47776003)(52116002)(8936002)(81166006)(81156014)(76176011)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0402MB2842; H:idcbfarm.ap.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0402MB2842; 23:4p6t01GY+WZUH/YD/58WnR4PX/ts0sGrfrK4DvJ?= =?us-ascii?Q?7t3FWK1MTm/D0u8bcnbSrS6aDCnCJAwrWfFmvGLHFb7TkYVHDzWYkB2fgrF1?= =?us-ascii?Q?PitEwAbBWmUCLxFpLCJYFg4QhaQNoG7cEDexh7tgrZrcFcuC5le71lxIsGym?= =?us-ascii?Q?W4CgSA8y549FKEi/17zt1T/7WP/qe/vYfWsiZwLCUnpb66+THraK01WW4Rn8?= =?us-ascii?Q?Doo3NJbpAZwf2SffezLGnMoHgPL0JK9b1OP1bKXC9iB/YHrPJEZTzyeihYyy?= =?us-ascii?Q?3xgNIZxfzwgTyE3OaEKXihWWXmJ4nBRutHGZdbHAxb8GlJ0uy7hfklBzWVPw?= =?us-ascii?Q?hSuwJTsAJxP9FYUvXKVAzYbC5QIZ+2yBl9I4g3+LfOe06MMZS3XQFwChLiuu?= =?us-ascii?Q?s8c5JxzI7+bAY5TrSnvDTzAcZcjGxCj/dXb97GjOPTAb6EGjmOzcp2I3qmIl?= =?us-ascii?Q?JbdNLfuz7UPZDC66zmK1g1eIiy9+98RVc7xpLp2DeyHVpBKV3n7jBMLOqbux?= =?us-ascii?Q?58PFSqoP6gZ7c8V4KtF8/vcYefl//jGVU+HguLLHz7+qDllESsZUCFB4h01w?= =?us-ascii?Q?ZcOfhArhddMXw3u+/RVeWMg+QvcyUs6Qg9bBbDTqP9naSZ+VnQDq066BghPL?= =?us-ascii?Q?F3dHpTrQwtiEf1eFHddPoA6sPwgakR5O78GqS/19wculI93LlXibegdSt6i1?= =?us-ascii?Q?G/Q/gccpT+5x/czL7RXqDg/VKb/X1HC3LCkIjUqXoWB4myGjUy9T0mQghzi5?= =?us-ascii?Q?gZghKN8yhjkPHIOmhMWOjsHCNupgUCzCxMx9+NAu8iBJGe7PFTWf46SrSiKh?= =?us-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V/4V0nghMq+mw1OcgkGiDBHAmcqkwRo7Sqxl6Wvo4wXhL5qM0xn0QRtm+NcyA5etj+mQ8pJW5VLcDft0G83S9Depznp4AZiM=; 7:mh/VHDAXTkE8l/kv098G9MAd51i4upUuazCrI9Etxiksim6SX49kgBrCABLi6JyJKT8HakhEH/NFP8W2P5QVqy6tWY9VE8X5uQx3op4ejlW5VhHzUa6iC1bBE4dK2s/faKbxd0KVsp7KfP0xgP3sobg+/i3wLj/egAZuKieLGpULugEMWMgKNf9hwxz8N1UP0249p2JjEm5nP+eZduCMErI0u2aoYNARbXVZpm/IU7eFcvePlXdtni3J+NNIY+/H SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2018 05:32:40.5643 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f51345a0-a43b-481f-84dd-08d569fe63fb X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0402MB2842 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: boris.brezillon@free-electrons.com, Yogesh Gaur , prabhakar.kushwaha@nxp.com, suresh.gupta@nxp.com, cyrille.pitchen@wedev4u.fr, han.xu@nxp.com, computersforpeace@gmail.com, festevam@gmail.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP FSL QuadSPI controller supports Single, dual, quad modes of operation. Mode information is available via "spi-tx-bus-width" and "spi-rx-bus-width" nodes of device tree for the connected slave device. Update read and write hwcap capability for slave device by reading "spi-rx-bus-width" and "spi-tx-bus-width" respectively. Assign hwcaps mask to minimal caps for the slave node i.e. SNOR_HWCAPS_READ | SNOR_HWCAPS_PP If value not provided in device tree file, then fallback to default mode i.e. SNOR_HWCAPS_READ_1_1_4 and SNOR_HWCAPS_PP. Signed-off-by: Prabhakar Kushwaha Signed-off-by: Yogesh Gaur --- Changes for v2: - None drivers/mtd/spi-nor/fsl-quadspi.c | 56 +++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c index b9c5918..1503e0c 100644 --- a/drivers/mtd/spi-nor/fsl-quadspi.c +++ b/drivers/mtd/spi-nor/fsl-quadspi.c @@ -994,17 +994,14 @@ static void fsl_qspi_unprep(struct spi_nor *nor, enum spi_nor_ops ops) static int fsl_qspi_probe(struct platform_device *pdev) { - const struct spi_nor_hwcaps hwcaps = { - .mask = SNOR_HWCAPS_READ_1_1_4 | - SNOR_HWCAPS_PP, - }; + struct spi_nor_hwcaps hwcaps; struct device_node *np = pdev->dev.of_node; struct device *dev = &pdev->dev; struct fsl_qspi *q; struct resource *res; struct spi_nor *nor; struct mtd_info *mtd; - int ret, i = 0; + int ret, i = 0, value; q = devm_kzalloc(dev, sizeof(*q), GFP_KERNEL); if (!q) @@ -1077,6 +1074,10 @@ static int fsl_qspi_probe(struct platform_device *pdev) /* iterate the subnodes. */ for_each_available_child_of_node(dev->of_node, np) { + /* Reset hwcaps mask to minimal caps for the slave node. */ + hwcaps.mask = SNOR_HWCAPS_READ | SNOR_HWCAPS_PP; + value = 0; + /* skip the holes */ if (!q->has_second_chip) i *= 2; @@ -1106,6 +1107,51 @@ static int fsl_qspi_probe(struct platform_device *pdev) /* set the chip address for READID */ fsl_qspi_set_base_addr(q, nor); + /* + * If spi-rx-bus-width and spi-tx-bus-width not defined assign + * default hardware capabilities SNOR_HWCAPS_READ_1_1_4 and + * SNOR_HWCAPS_PP supported by the Quad-SPI controller. + */ + if (!of_property_read_u32(np, "spi-rx-bus-width", &value)) { + switch (value) { + case 1: + hwcaps.mask |= SNOR_HWCAPS_READ | + SNOR_HWCAPS_READ_FAST; + break; + case 2: + hwcaps.mask |= SNOR_HWCAPS_READ_1_1_2 | + SNOR_HWCAPS_READ_1_2_2; + break; + case 4: + hwcaps.mask |= SNOR_HWCAPS_READ_1_1_4 | + SNOR_HWCAPS_READ_1_4_4; + break; + default: + dev_err(dev, + "spi-rx-bus-width %d not supported\n", + value); + break; + } + } else + hwcaps.mask |= SNOR_HWCAPS_READ_1_1_4; + + if (!of_property_read_u32(np, "spi-tx-bus-width", &value)) { + switch (value) { + case 1: + hwcaps.mask |= SNOR_HWCAPS_PP; + break; + case 4: + hwcaps.mask |= SNOR_HWCAPS_PP_1_1_4 | + SNOR_HWCAPS_PP_1_4_4; + break; + default: + dev_err(dev, + "spi-tx-bus-width %d not supported\n", + value); + break; + } + } + ret = spi_nor_scan(nor, NULL, &hwcaps); if (ret) goto mutex_failed;