From patchwork Fri Nov 18 12:02:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 9436325 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 931FD60469 for ; Fri, 18 Nov 2016 12:02:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E089287DE for ; Fri, 18 Nov 2016 12:02:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72D5729899; Fri, 18 Nov 2016 12:02:54 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 14DA2287DE for ; Fri, 18 Nov 2016 12:02:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753128AbcKRMCw (ORCPT ); Fri, 18 Nov 2016 07:02:52 -0500 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:54968 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753677AbcKRMCV (ORCPT ); Fri, 18 Nov 2016 07:02:21 -0500 Received: from [2001:470:1f1d:6b5::3] (helo=debutante) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1c7hs0-0003hY-QJ; Fri, 18 Nov 2016 12:02:19 +0000 Received: from broonie by debutante with local (Exim 4.87) (envelope-from ) id 1c7hry-0005Qd-4P; Fri, 18 Nov 2016 12:02:14 +0000 From: Mark Brown To: Heiner Kallweit Cc: Mark Brown , Mark Brown , "linux-spi@vger.kernel.org" In-Reply-To: Message-Id: Date: Fri, 18 Nov 2016 12:02:14 +0000 X-SA-Exim-Connect-IP: 2001:470:1f1d:6b5::3 X-SA-Exim-Mail-From: broonie@sirena.org.uk Subject: Applied "spi: fsl-espi: set spi_master members min_speed_hz and max_speed_hz" to the spi tree X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: No (on mezzanine.sirena.org.uk); Unknown failure 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 The patch spi: fsl-espi: set spi_master members min_speed_hz and max_speed_hz has been applied to the spi tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From f254e65ce20fda3c442ebc50ae1502281963a79b Mon Sep 17 00:00:00 2001 From: Heiner Kallweit Date: Tue, 15 Nov 2016 21:56:33 +0100 Subject: [PATCH] spi: fsl-espi: set spi_master members min_speed_hz and max_speed_hz ESPI has a max and min supported SPI frequency, determined by the clock divider range. Set master->min_speed_hz/max_speed_hz to inform the SPI core about these limits. Then the SPI core handles cases where a transfer requests a frequency outside the supported range. So far the driver simply set the lowest supported frequency if the requested frequency was below the supported range. This is not necessarily an appropriate action as the device might not support frequencies greater than the requested one. With this patch the SPI core will reject transfers requesting a too low frequency. The check in fsl_espi_setup can be removed because the SPI core sets spi->max_speed_hz to master->max_speed_hz if it's not set already. Signed-off-by: Heiner Kallweit Signed-off-by: Mark Brown --- drivers/spi/spi-fsl-espi.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 2635a33b8e98..4fbcc36fa891 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -314,13 +314,6 @@ static void fsl_espi_setup_transfer(struct spi_device *spi, if (pm > 15) { cs->hw_mode |= CSMODE_DIV16; pm = DIV_ROUND_UP(espi->spibrg, hz * 16 * 4) - 1; - - WARN_ONCE(pm > 15, - "%s: Requested speed is too low: %u Hz. Will use %u Hz instead.\n", - dev_name(&spi->dev), hz, - espi->spibrg / (4 * 16 * (15 + 1))); - if (pm > 15) - pm = 15; } cs->hw_mode |= CSMODE_PM(pm); @@ -460,9 +453,6 @@ static int fsl_espi_setup(struct spi_device *spi) u32 loop_mode; struct fsl_espi_cs *cs = spi_get_ctldata(spi); - if (!spi->max_speed_hz) - return -EINVAL; - if (!cs) { cs = kzalloc(sizeof(*cs), GFP_KERNEL); if (!cs) @@ -673,6 +663,9 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem, ret = -EINVAL; goto err_probe; } + /* determined by clock divider fields DIV16/PM in register SPMODEx */ + master->min_speed_hz = DIV_ROUND_UP(espi->spibrg, 4 * 16 * 16); + master->max_speed_hz = DIV_ROUND_UP(espi->spibrg, 4); init_completion(&espi->done);