From patchwork Tue Oct 31 19:49:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trent Piepho X-Patchwork-Id: 10035301 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 D12D5602B5 for ; Tue, 31 Oct 2017 19:50:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1E7928A7C for ; Tue, 31 Oct 2017 19:50:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6E3328AFC; Tue, 31 Oct 2017 19:50:46 +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=unavailable 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 230F128AA6 for ; Tue, 31 Oct 2017 19:50:46 +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=9o1l5gUGqoPe7eVM3hN+QNXGW5EQ2P+jQ2FACFaou0I=; b=L4i0ObGvZK8bJ2 gJPDRKxbAFADEzLpRf7qFr8sh/2afMazJ/pObrgDL/fv5hNkvGo5v7Ah2BtVq1yVaS5z8MKS2h4BX UGSBV/e0Dq2h7txzyDy2NFGQ4mdToIG72KTp7q4Pnccyc1zyZX0mvxD/ulaT7yXmHsivfa7Kn7NxD FBOQr6kNjynBhRL+aTsl6j/omTrZOxFLG4n9IEoG8m5finRLZojNQK3TFYbY8R7fyunFTxjcu43ce v5mHwYfYQPSfUUesRPCGbf6CUt+dNU2FudboIzuvJ6XFO+ZIdm6FilUXdIHzceIn94E63nXBQtzm4 C+SYvzhx2pXT6oNxiocw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e9cYe-00082t-PK; Tue, 31 Oct 2017 19:50:44 +0000 Received: from mail-by2nam03on0725.outbound.protection.outlook.com ([2a01:111:f400:fe4a::725] helo=NAM03-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e9cXx-0006OG-3I for linux-arm-kernel@lists.infradead.org; Tue, 31 Oct 2017 19:50:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=impinj.onmicrosoft.com; s=selector1-impinj-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=jipPgmYN6O5z0/gFaGbn3aw4s1Y1uRhcHmJIzHjD+pI=; b=G/rYgy1VdLWKYhL9APONlo5hPrU8ACNNYRTb0y1FpL95GpBonzbwu5Y85SLUoTixleq9toi88zD4oKZRE7dHr0QH9sxK0kRspe4pyG/4ekNkYl9yaRb1WdQfW0YAwSn9T9mlfxxaDo79qks1zdGx/+/pttAnwMb5B/yMIiZkkZQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=tpiepho@impinj.com; Received: from impinj.com (216.243.31.162) by CY4PR06MB2808.namprd06.prod.outlook.com (10.175.118.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.178.6; Tue, 31 Oct 2017 19:49:31 +0000 From: Trent Piepho To: linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 1/4] spi: imx: GPIO based chip selects should not be required Date: Tue, 31 Oct 2017 12:49:04 -0700 Message-Id: <20171031194907.29108-2-tpiepho@impinj.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171031194907.29108-1-tpiepho@impinj.com> References: <20171031194907.29108-1-tpiepho@impinj.com> MIME-Version: 1.0 X-Originating-IP: [216.243.31.162] X-ClientProxiedBy: MWHPR22CA0020.namprd22.prod.outlook.com (10.172.163.158) To CY4PR06MB2808.namprd06.prod.outlook.com (10.175.118.8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2b08c3cd-a242-4aa2-2079-08d52098819f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(2017052603238); SRVR:CY4PR06MB2808; X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2808; 3:w67C0LBGArzYQZDgRpSGwAYjg7X+0/6AXzZIs54G0F4wk45oRL8Rqa4fUiSVPfjqZh/tnLwpImzblOvoK+xHtGVg2KCAPSCL7mp1U2wROolErW+iIrco0BmVh4tDU3b2d0XaAassmL96Z01ievQAJkiFmKN9GVkOtXaG5ef124jSONT3dxzxgenV44UqloS79gM8G9cRELm8sFouT80i3iJGyEkB5qGrkjN9DE8BnaiJ6qvXvWoa376kXm0qXMIM; 25:M3UExLVuU/sjKlfvKGlo4c5g5Za8wFzMt48YY2Wc68nnfFQzkGC4nxJgbwRzEzJqsa0GMR3MpD1WehmEIyDGet7Dl7CVTxO0pFwfS/URkFVm7IYPcKViN/hKo/ksMeWlawrL26g7SbStSCXnfYdUdYSGe2lEY9wgnteCMv6xbUxO3gnTky2ivLsm3CNwREtSrm4eZV5KxdWGfBTpve9sJtgfq3FunFNDHg5BjSY1tXkCj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0+pA9mFcciNcjUPnlqLY/4uZn+TIX1Mv5VWHfni+LbMucnz4UP1CSD3+MfLKSkIMDaY9dur8THo6sPbARoL6JD1RP6dUwmetjWJQfXpGjL9BlClfqTmb25qJU5hlVkRBhx7jCnwo2w60YmWJsjwBfj3IngphVfGEQPMQYieyDPQUs00Gk X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231020)(100000703101)(100105400095)(6041248)(20161123560025)(20161123555025)(20161123562025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY4PR06MB2808; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY4PR06MB2808; X-Forefront-PRVS: 04772EA191 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(376002)(346002)(39830400002)(189002)(199003)(97736004)(53936002)(478600001)(86362001)(575784001)(76176999)(101416001)(50466002)(50986999)(48376002)(69596002)(1076002)(25786009)(66066001)(81166006)(106356001)(8676002)(33646002)(105586002)(6116002)(3846002)(4326008)(36756003)(81156014)(2906002)(189998001)(8936002)(55016002)(68736007)(50226002)(2950100002)(16526018)(21086003)(305945005)(5660300001)(16586007)(47776003)(316002)(6666003)(54906003)(5003940100001)(7736002)(8656006); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR06MB2808; H:impinj.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: impinj.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY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4KsSEb6skdmMUZABBea/B9fgq2H1WcWwE2QIC8BnxM2fNnWiw7I5bJYIzT0sX4wTtdep0N2ROfBB0a+2dKfNGB/4b2MLs1RUM1eOqboCAh7NdaV0s8rzTJPwU1sZijjKvvip/za5Zp5lXnNV/iad7qjP00TUomgH8rN7u5084CKZqQxnMpKhe2VtYuXzRuIqZsFE8RBgiiD8aOFFEieuEvzup1CwLF980o58pMUt6wC7vw6kJUkrMztW6pEVHF SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: impinj.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2017 19:49:31.8975 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2b08c3cd-a242-4aa2-2079-08d52098819f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 6de70f0f-7357-4529-a415-d8cbb7e93e5e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR06MB2808 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171031_125001_405637_AD0A535B X-CRM114-Status: GOOD ( 14.67 ) 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: Oleksij Rempel , Mark Brown , Sascha Hauer , Fabio Estevam , Shawn Guo , Trent Piepho 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 The driver will fail to load if no gpio chip selects are specified, this patch changes this so that it no longer fails. It's possible to use all native chip selects, in which case there is no reason to have a gpio chip select array. This is what happens if the *optional* device tree property "cs-gpios" is omitted. The spi core already checks for the absence of gpio chip selects in the master and assigns any slaves the gpio_cs value of -ENOENT. Also have the driver respect the standard SPI device tree property "num-cs" to allow setting the number of chip selects without using cs-gpios. CC: Mark Brown CC: Shawn Guo CC: Sascha Hauer CC: Fabio Estevam CC: Oleksij Rempel Signed-off-by: Trent Piepho --- drivers/spi/spi-imx.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index fe35aaea323b..76bf0e4fc2c7 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -1523,6 +1523,7 @@ static int spi_imx_probe(struct platform_device *pdev) spi_imx->devtype_data = devtype_data; + /* Get number of chip selects, either platform data or OF */ if (mxc_platform_info) { master->num_chipselect = mxc_platform_info->num_chipselect; master->cs_gpios = devm_kzalloc(&master->dev, @@ -1532,7 +1533,13 @@ static int spi_imx_probe(struct platform_device *pdev) for (i = 0; i < master->num_chipselect; i++) master->cs_gpios[i] = mxc_platform_info->chipselect[i]; - } + } else { + u32 num_cs; + + if (!of_property_read_u32(np, "num-cs", &num_cs)) + master->num_chipselect = num_cs; + /* If not preset, default value of 1 is used */ + } spi_imx->bitbang.chipselect = spi_imx_chipselect; spi_imx->bitbang.setup_transfer = spi_imx_setupxfer; @@ -1619,13 +1626,8 @@ static int spi_imx_probe(struct platform_device *pdev) goto out_clk_put; } - if (!spi_imx->slave_mode) { - if (!master->cs_gpios) { - dev_err(&pdev->dev, "No CS GPIOs available\n"); - ret = -EINVAL; - goto out_clk_put; - } - + /* Request GPIO CS lines, if any */ + if (!spi_imx->slave_mode && master->cs_gpios) { for (i = 0; i < master->num_chipselect; i++) { if (!gpio_is_valid(master->cs_gpios[i])) continue;