From patchwork Mon Nov 6 19:46:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trent Piepho X-Patchwork-Id: 10044381 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 A9390602BF for ; Mon, 6 Nov 2017 20:05:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 996BE29F34 for ; Mon, 6 Nov 2017 20:05:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DCE529F5A; Mon, 6 Nov 2017 20:05:58 +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 0467D29F34 for ; Mon, 6 Nov 2017 20:05:58 +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=GECfVtUkqciRe6sIok7v+HwDA1UHtrnHDdysvBgySxU=; b=Zfev/Of1cu0GWG n9U7hJHLfVQs6IEbx7BBY85mQCMD6MPt9KLd6FuHxtlJwtXlYt/XiCo8Gb7fkF5VajzcUwdKlJrfp NWldUiDjyaJLWYARDGk3gVzvM0IotZ29mwmddvZjk0rWy/Ri1dKFKOYAPwdljis1RBN8mNG+2cA0S 3Vl9IFfq0nWCPBU+JjwWdv+NsaIwwjcK49DQxGfbz1PpMx4Go2pnslJNNtcigF0ajduE3FcWOiMA6 xKwb819WPBV1xITA6Logb8/cMlHUWmldKtXaqrTmWbyLoxGAfkMRM5B48XFg1VOQz2/FcpJAHgOgh Hqm+m6A+uFSIQZz4ZMng==; 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 1eBnef-0005gI-5L; Mon, 06 Nov 2017 20:05:57 +0000 Received: from mail-by2nam03on0106.outbound.protection.outlook.com ([104.47.42.106] helo=NAM03-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eBnMJ-0007sT-KR for linux-arm-kernel@lists.infradead.org; Mon, 06 Nov 2017 19:47:02 +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=u2ujATxtchUSxrlSULhC19XlNE+r+puROTDEjSSl6ww=; b=WxsDeltTYTqoNTumKfBygIX6mlb5x87IUWTNO5J7ko5b/A4pZIYa6YMg66X1W976yn8UILBOZrkYVc0v53PgehKhqY/UjJTrR1SxurWJYNwgi6CqgOnp/SEtpRYbXjLkFz93gFocC/WZN9QnIHOEEagNZjhrkVivs0n2yPfTupg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=tpiepho@impinj.com; Received: from impinj.com (216.243.31.162) by MWHPR06MB2814.namprd06.prod.outlook.com (10.175.137.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.197.13; Mon, 6 Nov 2017 19:46:30 +0000 From: Trent Piepho To: linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 1/3] spi: imx: GPIO chip select DT property should not be required Date: Mon, 6 Nov 2017 11:46:16 -0800 Message-Id: <20171106194618.9421-2-tpiepho@impinj.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171106194618.9421-1-tpiepho@impinj.com> References: <20171106194618.9421-1-tpiepho@impinj.com> MIME-Version: 1.0 X-Originating-IP: [216.243.31.162] X-ClientProxiedBy: MWHPR06CA0001.namprd06.prod.outlook.com (10.174.172.142) To MWHPR06MB2814.namprd06.prod.outlook.com (10.175.137.147) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 33ae08cf-2902-4469-8add-08d5254f13b3 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199); SRVR:MWHPR06MB2814; X-Microsoft-Exchange-Diagnostics: 1; MWHPR06MB2814; 3:oI6qErqbMJJFuXdu6tYcMqkvmmqnOvfz7IzIXsjzOjvAjlpsaxEce24R9lGNKhcFPK7UB4vsEHdTaguzFaj5jiQPj7R4P1GDVYLhUCo0ZWki9J784jn01MOQ9icpFtQrpCZztSI/KFP8ldnz3Ku2SC8b4OD+tebIqN7YdUmX5QqFNKNDDpO+QafA8jGOscKnkrURE3EwnWNmfj2+EshAeSIPDeB46/eu7HfMzJPOApkEXnUFyQ5TgrlSh2iDcBCI; 25:AQkGk0RBnQ05ngpXn78EQ2TAuuD4ox0KNWn0IW/rM5h7crW3ti5doQxWVHvMpfkb/SprkijKNvdAYZqjagNlU0uhduX0qNEJCQwKbJoAAd52WCOtUGgcIDchLdWSWVyma/QeRGyFd2Y9MGP27Jns6vE1GdIIoLpvZhApm6T/DVVrCMR+z8YXLc+JyhoO90FXovZeKegFNW/VAE1V3Ro0BexUNKoNu1n01hKmucyg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4naElleGS4S83X3VNV3k+Iwjata69IYwTO7RODhHqmumT7eRg1y/KsDQhcGnUXz84ifSSnHb2RH2cV9MoWQEv7STecQwY7x6CXHyxTsbnu6rhvE8yFWa5AR2PFJIwsYrcb3bg5suMnk3R03tazTniCT1F0eR2vSLZLcenzGuO9t9z4IULvo 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)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(100000703101)(100105400095)(3231021)(6041248)(20161123558100)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123562025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR06MB2814; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR06MB2814; X-Forefront-PRVS: 048396AFA0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(39830400002)(376002)(346002)(199003)(189002)(2906002)(551934003)(21086003)(50226002)(33646002)(16526018)(4326008)(101416001)(76176999)(50986999)(36756003)(478600001)(66066001)(25786009)(1076002)(16586007)(5003940100001)(105586002)(305945005)(7736002)(316002)(68736007)(3846002)(6116002)(106356001)(6666003)(55016002)(48376002)(47776003)(54906003)(69596002)(86362001)(81156014)(81166006)(189998001)(2950100002)(8936002)(97736004)(5660300001)(50466002)(8656006)(53936002)(8676002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR06MB2814; H:impinj.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; MWHP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d3wcR+b3DK4jP491y9rK3dGPQ2WpMSNEyP+bdbwrxPf9ZyDBKkdASTzKLMHY06AolGGqr9yG2jWFp6rbViq3gIX2RXhyQ63PUsg8aPrrHooPBnrfjN9XuXfjVZTHVKqgugt9gLAVXnAQKudaioqOfu+I4Im79i1Nuwmk1xbrfKY4h1j8wWemtVWZkt8LyOLnR9525jEZfkGZ1FaiiQtMwkhL6iuQFpBZLUEYgDGYg1/c89efP SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: impinj.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2017 19:46:30.5502 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 33ae08cf-2902-4469-8add-08d5254f13b3 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 6de70f0f-7357-4529-a415-d8cbb7e93e5e X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR06MB2814 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171106_114659_931216_5A55FD62 X-CRM114-Status: GOOD ( 16.11 ) 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 the device tree property for gpio chip selects is not specified. Change the driver to make the property optional. Also have the driver respect the "num-cs" property in the standard way. This way one can use the native CS lines using standard bindings instead of being forced to specify a gpio-cs of <0>. Since native CS do not work in a commonly useful manner with this hardware/driver, note in the documention that most users probably should use GPIO based CS lines rather than native. CC: Mark Brown CC: Shawn Guo CC: Sascha Hauer CC: Fabio Estevam CC: Oleksij Rempel Signed-off-by: Trent Piepho Reviewed-by: Oleksij Rempel --- Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt | 18 ++++++++++++------ drivers/spi/spi-imx.c | 18 ++++++++++-------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt b/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt index 5bf13960f7f4..e3c48b20b1a6 100644 --- a/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt +++ b/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt @@ -12,24 +12,30 @@ Required properties: - "fsl,imx53-ecspi" for SPI compatible with the one integrated on i.MX53 and later Soc - reg : Offset and length of the register set for the device - interrupts : Should contain CSPI/eCSPI interrupt -- cs-gpios : Specifies the gpio pins to be used for chipselects. - clocks : Clock specifiers for both ipg and per clocks. - clock-names : Clock names should include both "ipg" and "per" See the clock consumer binding, Documentation/devicetree/bindings/clock/clock-bindings.txt -- dmas: DMA specifiers for tx and rx dma. See the DMA client binding, - Documentation/devicetree/bindings/dma/dma.txt -- dma-names: DMA request names should include "tx" and "rx" if present. -Obsolete properties: -- fsl,spi-num-chipselects : Contains the number of the chipselect +Recommended properties: +- cs-gpios : GPIOs to use as chip selects, see spi-bus.txt. While the native chip +select lines can be used, they appear to always generate a pulse between each +word of a transfer. Most use cases will require GPIO based chip selects to +generate a valid transaction. Optional properties: +- num-cs : Number of total chip selects, see spi-bus.txt. +- dmas: DMA specifiers for tx and rx dma. See the DMA client binding, +Documentation/devicetree/bindings/dma/dma.txt. +- dma-names: DMA request names, if present, should include "tx" and "rx". - fsl,spi-rdy-drctl: Integer, representing the value of DRCTL, the register controlling the SPI_READY handling. Note that to enable the DRCTL consideration, the SPI_READY mode-flag needs to be set too. Valid values are: 0 (disabled), 1 (edge-triggered burst) and 2 (level-triggered burst). +Obsolete properties: +- fsl,spi-num-chipselects : Contains the number of the chipselect + Example: ecspi@70010000 { diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 301cdb721bad..ad54f8258513 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;