Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1960732yba; Mon, 15 Apr 2019 01:54:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvSSa6N7gojuKj3GH5UdXU94taLXnPrV6Uy0Ro0Hf1bKbmU/mdAGgG2ff1DqvQ7r9LP64Q X-Received: by 2002:a63:f448:: with SMTP id p8mr64465826pgk.50.1555318493146; Mon, 15 Apr 2019 01:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555318493; cv=none; d=google.com; s=arc-20160816; b=A8/J/AC5lQ0wyx18cRWmRxMMDfqcMqwQ63GbwuCh7mpN/WdMt6iTzIMb7ahgpKv0G1 jvzeuIKC2ZlXdR5w9hFWd5u44m0f1XvqgCljvmwbMPud3W0+Y/yAoVEume4HAOASdClf CEcvlXjwdWL02xhmlDMYezVqyNlgA1u49sihbDWpry878xYbQXaTGHUaAJ2P/Ipo8iBX qS979W1vWxHV4CEGZJx90SxTkf9HSA2rMQ90PMQ6StTUOfA4t4ToumuWDEytacLKvOmm 0XR4QLwEwDdu+MHWusYYmQYSHJfmCN0HBb6B4p4e6xb7c2Siu+y3DnW83xqWLsugLxE8 6GYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:in-reply-to:subject:cc:to :from:dkim-signature; bh=wBptgvrzAMh9ELb+BdRDByUxGWzc4n6+0yA4/VFTrjQ=; b=g+MAGEOU8XIIlQWqsVmEv+Q7a3J8/GpxFbD6WSp/lwghyDuXYzI7CiubM+id3tYLwV fMbUUUTPRpl+N7vyK9OiPQqa/ASM6ZJrpAJ6z767x4kdNjqJDZMZ3qwnTlFcacHg4Is7 /+Wt1TxgKRFLPkzuXWFEVWUbNyHwG8fJiy5xFX7ZOOl/AGvOjDZ8vjsmNo2gTHTu1o7H JTjVf1ZVgSUUQXNQ8kVcjvsrzPcXKc9yTlKQHHcmGfX/DORXjnxm579zrFPaofUldZyV on7jKuAqpnogjsBlnJixJgvmE2/4BZrj4v17/vpo/6vJ23zY2/mw1TyqNT1PGdXbhRQg z1vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=QIF1lBN9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u185si43360871pgd.489.2019.04.15.01.54.36; Mon, 15 Apr 2019 01:54:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=QIF1lBN9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727146AbfDOIxz (ORCPT + 99 others); Mon, 15 Apr 2019 04:53:55 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:36220 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726287AbfDOIxx (ORCPT ); Mon, 15 Apr 2019 04:53:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=wBptgvrzAMh9ELb+BdRDByUxGWzc4n6+0yA4/VFTrjQ=; b=QIF1lBN97CDr tDFZf1Nt0U3DuiItHaHe+2kfkMHn4Qr0qWuhFNOcEcpSbn0OsBuJ01XBdpDbBUe/9blCEmlu1FWQb z9K/Jhw8bNUsaS/XhFoyGtSrgb6fhxw1HwMFlugH9I1eGWEjNsVm3mvZcwrStWtr7hX8Eota7adBh hW1iM=; Received: from cpc102320-sgyl38-2-0-cust46.18-2.cable.virginm.net ([82.37.168.47] helo=debutante.sirena.org.uk) by heliosphere.sirena.org.uk with esmtpa (Exim 4.89) (envelope-from ) id 1hFxMx-0007jO-Fe; Mon, 15 Apr 2019 08:53:39 +0000 Received: by debutante.sirena.org.uk (Postfix, from userid 1000) id BCF251127B96; Mon, 15 Apr 2019 09:53:33 +0100 (BST) From: Mark Brown To: Flavio Suligoi Cc: Daniel Mack , Haojian Zhuang , Jarkko Nikula , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, Mark Brown , Robert Jarzmik Subject: Applied "spi: pxa2xx: fix SCR (divisor) calculation" to the spi tree In-Reply-To: <1555054339-17096-1-git-send-email-f.suligoi@asem.it> X-Patchwork-Hint: ignore Message-Id: <20190415085333.BCF251127B96@debutante.sirena.org.uk> Date: Mon, 15 Apr 2019 09:53:33 +0100 (BST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch spi: pxa2xx: fix SCR (divisor) calculation has been applied to the spi tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-5.1 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 bf0c999f7f0e8934c8db8261fb67a38770fffac2 Mon Sep 17 00:00:00 2001 From: Flavio Suligoi Date: Fri, 12 Apr 2019 09:32:19 +0200 Subject: [PATCH] spi: pxa2xx: fix SCR (divisor) calculation Calculate the divisor for the SCR (Serial Clock Rate), avoiding that the SSP transmission rate can be greater than the device rate. When the division between the SSP clock and the device rate generates a reminder, we have to increment by one the divisor. In this way the resulting SSP clock will never be greater than the device SPI max frequency. For example, with: - ssp_clk = 50 MHz - dev freq = 15 MHz without this patch the SSP clock will be greater than 15 MHz: - 25 MHz for PXA25x_SSP and CE4100_SSP - 16,56 MHz for the others Instead, with this patch, we have in both case an SSP clock of 12.5MHz, so the max rate of the SPI device clock is respected. Signed-off-by: Flavio Suligoi Reviewed-by: Jarkko Nikula Reviewed-by: Jarkko Nikula Signed-off-by: Mark Brown --- drivers/spi/spi-pxa2xx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index b6ddba833d02..d2076f2f468f 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -884,10 +884,14 @@ static unsigned int ssp_get_clk_div(struct driver_data *drv_data, int rate) rate = min_t(int, ssp_clk, rate); + /* + * Calculate the divisor for the SCR (Serial Clock Rate), avoiding + * that the SSP transmission rate can be greater than the device rate + */ if (ssp->type == PXA25x_SSP || ssp->type == CE4100_SSP) - return (ssp_clk / (2 * rate) - 1) & 0xff; + return (DIV_ROUND_UP(ssp_clk, 2 * rate) - 1) & 0xff; else - return (ssp_clk / rate - 1) & 0xfff; + return (DIV_ROUND_UP(ssp_clk, rate) - 1) & 0xfff; } static unsigned int pxa2xx_ssp_get_clk_div(struct driver_data *drv_data, -- 2.20.1