From patchwork Thu Apr 2 09:11:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 6145621 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A6434BF4A6 for ; Thu, 2 Apr 2015 09:21:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9943C20386 for ; Thu, 2 Apr 2015 09:21:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A54DC20382 for ; Thu, 2 Apr 2015 09:21:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752692AbbDBJVF (ORCPT ); Thu, 2 Apr 2015 05:21:05 -0400 Received: from gw01.mail.saunalahti.fi ([195.197.172.115]:33561 "EHLO gw01.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752526AbbDBJVD (ORCPT ); Thu, 2 Apr 2015 05:21:03 -0400 X-Greylist: delayed 559 seconds by postgrey-1.27 at vger.kernel.org; Thu, 02 Apr 2015 05:21:03 EDT Received: from localhost.localdomain (a91-152-110-231.elisa-laajakaista.fi [91.152.110.231]) by gw01.mail.saunalahti.fi (Postfix) with ESMTP id 3A53340074; Thu, 2 Apr 2015 12:11:37 +0300 (EEST) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.14.8/8.14.8) with ESMTP id t329Bo4m028171; Thu, 2 Apr 2015 12:11:50 +0300 Received: (from andy@localhost) by localhost.localdomain (8.14.8/8.14.8/Submit) id t329BmHh028169; Thu, 2 Apr 2015 12:11:48 +0300 X-Authentication-Warning: localhost.localdomain: andy set sender to andy.shevchenko@gmail.com using -f From: Andy Shevchenko To: Aaron Brice , linux-spi@vger.kernel.org, Mark Brown Cc: Andy Shevchenko Subject: [PATCH v1 0/2] spi: fsl-dspi: better approximation for baudrate Date: Thu, 2 Apr 2015 12:11:45 +0300 Message-Id: <1427965907-28125-1-git-send-email-andy.shevchenko@gmail.com> X-Mailer: git-send-email 1.9.3 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This series makes better approximation when baud rate divisor parameters are calculated. The algorithm is represent as Python script here [1]. First parameter is algorithm (0 - original, 1 - after patch 1/2, 2 - after patch 2/2, 3 - memory vs. performance: use precalculated scales). I played with let's say standard baud rates (which I used for Quark) and separately run algorithms 0 and 1 for range 100-5000 baud. Input frequency is 64MHz. It seems my algo shows better results in all cases. Here is a diff for 'standard' baud rates (speed_hz, DBR, i, BR, j, PBR, real baud rate, difference): Patch 2 is RFC, since I don't know if all DSPI modules has that bit (at least what I found on public for MC55xx) and how duty cycle is significant. Not compiled. Not tested. [1] http://pastebin.com/uy0CKc6b Andy Shevchenko (2): spi: fsl-dspi: increase precision of baud rate approximation spi: fsl-dspi: use double baud rate in approximation drivers/spi/spi-fsl-dspi.c | 50 +++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) --- result0 2015-04-02 00:38:48.845761004 +0300 +++ result1 2015-04-02 00:38:48.913760154 +0300 @@ -5,7 +5,7 @@ 25000000 0 0 2 0 2 16000000 9000000 20000000 0 0 2 0 2 16000000 4000000 16667000 0 0 2 0 2 16000000 667000 -13333000 0 0 2 0 2 16000000 2667000 +13333000 0 0 2 1 3 10666666 2666334 12500000 0 0 2 1 3 10666666 1833334 10000000 0 0 2 1 3 10666666 666666 8000000 0 1 4 0 2 8000000 0 @@ -17,36 +17,36 @@ 3140500 0 1 4 2 5 3200000 59500 3125000 0 1 4 2 5 3200000 75000 3109500 0 1 4 2 5 3200000 90500 -2500000 0 1 4 3 7 2285714 214286 +2500000 0 3 8 1 3 2666666 166666 2000000 0 4 16 0 2 2000000 0 1563000 0 3 8 2 5 1600000 37000 -1250000 0 3 8 3 7 1142857 107143 +1250000 0 4 16 1 3 1333333 83333 1006000 0 5 32 0 2 1000000 6000 1000000 0 5 32 0 2 1000000 0 994000 0 5 32 0 2 1000000 6000 800000 0 4 16 2 5 800000 0 -781250 0 5 32 1 3 666666 114584 -625000 0 4 16 3 7 571428 53572 +781250 0 4 16 2 5 800000 18750 +625000 0 5 32 1 3 666666 41666 500000 0 6 64 0 2 500000 0 400000 0 5 32 2 5 400000 0 -390625 0 6 64 1 3 333333 57292 +390625 0 5 32 2 5 400000 9375 250000 0 7 128 0 2 250000 0 200000 0 6 64 2 5 200000 0 205313 0 6 64 2 5 200000 5313 -195313 0 7 128 1 3 166666 28647 -185313 0 7 128 1 3 166666 18647 +195313 0 6 64 2 5 200000 4687 +185313 0 6 64 2 5 200000 14687 125000 0 8 256 0 2 125000 0 100700 0 7 128 2 5 100000 700 100000 0 7 128 2 5 100000 0 -99300 0 8 256 1 3 83333 15967 +99300 0 7 128 2 5 100000 700 50000 0 8 256 2 5 50000 0 25000 0 9 512 2 5 25000 0 -10066 0 10 1024 3 7 8928 1138 -10016 0 10 1024 3 7 8928 1088 -9966 0 10 1024 3 7 8928 1038 -5065 0 11 2048 3 7 4464 601 -5040 0 11 2048 3 7 4464 576 -5015 0 11 2048 3 7 4464 551 +10066 0 11 2048 1 3 10416 350 +10016 0 11 2048 1 3 10416 400 +9966 0 11 2048 1 3 10416 450 +5065 0 12 4096 1 3 5208 143 +5040 0 12 4096 1 3 5208 168 +5015 0 12 4096 1 3 5208 193 1007 0 15 32768 0 2 976 31 1002 0 15 32768 0 2 976 26 997 0 15 32768 0 2 976 21