From patchwork Wed Apr 10 12:51:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Flavio Suligoi X-Patchwork-Id: 10893853 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B3F114DB for ; Wed, 10 Apr 2019 12:54:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E572C289BE for ; Wed, 10 Apr 2019 12:54:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9D67289C4; Wed, 10 Apr 2019 12:54:50 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 8D1E6289BA for ; Wed, 10 Apr 2019 12:54:50 +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: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:In-Reply-To:References: List-Owner; bh=ue6ON37gFLavXg0NXMTUiyXD6s//BCod/XJrwRTSjds=; b=NGHMYEzUG2C7cQ o79fYQvoiKlJPUsTd6I+up+lNUBXiHTWdGvMvSrE5WqVfpceUIO3YtYQZqtWuiMR4PugiUoaCv66c M936P9Xzj02TskaLrlGN+9DoxvYzlbm+6xghYT0Z+90sd7EJiZ8JyPiV4dmRDAAcHnoX9j60++9jE 0dxguvU/NUR4j3nG8QR0yN/+1DLl6F3Q6c8dWanHnVUYJYQBsHEaikI4IujLETWhhQK5NO+qLFS7b B/wcTxkP17bzmol/mpChcJUXHwX+eve3tQotXoT5uJITHkYvTwGwExJJf++KddOsGePbsxg0H9UcU D8LKMFsde7A5UvQYR4iQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hECkX-0006TY-6v; Wed, 10 Apr 2019 12:54:45 +0000 Received: from smtp.asem.it ([151.1.184.197]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hECkU-0006ST-1E for linux-arm-kernel@lists.infradead.org; Wed, 10 Apr 2019 12:54:43 +0000 Received: from webmail.asem.it by asem.it (smtp.asem.it) (SecurityGateway 5.5.0) with ESMTP id SG003804505.MSG for ; Wed, 10 Apr 2019 14:54:36 +0200S Received: from ASAS044.asem.intra (172.16.16.44) by ASAS044.asem.intra (172.16.16.44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Wed, 10 Apr 2019 14:54:35 +0200 Received: from flavio-x.asem.intra (172.16.17.208) by ASAS044.asem.intra (172.16.16.44) with Microsoft SMTP Server id 15.1.1261.35 via Frontend Transport; Wed, 10 Apr 2019 14:54:35 +0200 From: Flavio Suligoi To: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Mark Brown Subject: [PATCH 1/2] spi: pxa2xx: fix SCR (divisor) calculation Date: Wed, 10 Apr 2019 14:51:35 +0200 Message-ID: <1554900696-28858-1-git-send-email-f.suligoi@asem.it> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-SGHeloLookup-Result: pass smtp.helo=webmail.asem.it (ip=172.16.16.44) X-SGSPF-Result: none (smtp.asem.it) X-SGOP-RefID: str=0001.0A0B0201.5CADE78C.0048, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 (_st=1 _vt=0 _iwf=0) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190410_055442_259858_145070B6 X-CRM114-Status: GOOD ( 12.93 ) 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: Flavio Suligoi , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.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 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 --- drivers/spi/spi-pxa2xx.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index f7068cc..c9560a1 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -884,10 +884,15 @@ 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 (ssp_clk / (2 * rate) - 1 + + (ssp_clk % (2 * rate) ? 1 : 0)) & 0xff; else - return (ssp_clk / rate - 1) & 0xfff; + return (ssp_clk / rate - 1 + (ssp_clk % rate ? 1 : 0)) & 0xfff; } static unsigned int pxa2xx_ssp_get_clk_div(struct driver_data *drv_data, From patchwork Wed Apr 10 12:51:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Flavio Suligoi X-Patchwork-Id: 10893855 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 17541139A for ; Wed, 10 Apr 2019 12:54:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F238628991 for ; Wed, 10 Apr 2019 12:54:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF253289C6; Wed, 10 Apr 2019 12:54: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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 B560128981 for ; Wed, 10 Apr 2019 12:54:54 +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=+zPbT3TF5mFQ+kj/mEnkhQZSAQlakrWl26VFKrrdd8c=; b=W6+6yZtWvYQGq7 bQs6mx1K2RSFOo/81HomnVmWFIxsZZQHfekPloiV2kA7EZ+6jywjY0g09/j+8wSP9TRzo/B6bYS4K 49zh5MdbV2BVzM7rQlJ0RybLCN7k+X9jYL9ceKx6cdOlNNKQi7d+xqPMkUw0lRCzkiVHLXGgx7DM1 ovU7/CWtIcD6pKx6FDT5IsGTYo8lvPcPlX4rvcwjay4RaRJGjP81KJwrAfOfbcHPwnhokpUIATzWU X2EpGpw1F1o+cwEcsUkLs97gwDJH6j5JR3pScUiAcgaubPfRbe/OEh/B8kwvp+Bu07qaqYr366j4l zHp+2hWFbUtR2oy2930w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hECkf-0006io-4q; Wed, 10 Apr 2019 12:54:53 +0000 Received: from smtp.asem.it ([151.1.184.197]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hECka-0006Us-5I for linux-arm-kernel@lists.infradead.org; Wed, 10 Apr 2019 12:54:51 +0000 Received: from webmail.asem.it by asem.it (smtp.asem.it) (SecurityGateway 5.5.0) with ESMTP id SG003804506.MSG for ; Wed, 10 Apr 2019 14:54:43 +0200S Received: from ASAS044.asem.intra (172.16.16.44) by ASAS044.asem.intra (172.16.16.44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Wed, 10 Apr 2019 14:54:41 +0200 Received: from flavio-x.asem.intra (172.16.17.208) by ASAS044.asem.intra (172.16.16.44) with Microsoft SMTP Server id 15.1.1261.35 via Frontend Transport; Wed, 10 Apr 2019 14:54:41 +0200 From: Flavio Suligoi To: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Mark Brown Subject: [PATCH 2/2] spi: pxa2xx: use a module softdep for dw_dmac Date: Wed, 10 Apr 2019 14:51:36 +0200 Message-ID: <1554900696-28858-2-git-send-email-f.suligoi@asem.it> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554900696-28858-1-git-send-email-f.suligoi@asem.it> References: <1554900696-28858-1-git-send-email-f.suligoi@asem.it> MIME-Version: 1.0 X-SGHeloLookup-Result: pass smtp.helo=webmail.asem.it (ip=172.16.16.44) X-SGSPF-Result: none (smtp.asem.it) X-SGOP-RefID: str=0001.0A0B0214.5CADE792.005C, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 (_st=1 _vt=0 _iwf=0) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190410_055448_959703_7F0F4C0F X-CRM114-Status: GOOD ( 10.27 ) 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: Flavio Suligoi , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.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 With dw_dmac, sometimes the request of a DMA channel fails because the DMA driver is not ready, so an explicit dependency request is necessary. Signed-off-by: Flavio Suligoi --- drivers/spi/spi-pxa2xx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index c9560a1..e8ac26b 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1962,3 +1962,5 @@ static void __exit pxa2xx_spi_exit(void) platform_driver_unregister(&driver); } module_exit(pxa2xx_spi_exit); + +MODULE_SOFTDEP("pre: dw_dmac");