From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 619C2C2D0A3 for ; Mon, 9 Nov 2020 14:34:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C0EF206ED for ; Mon, 9 Nov 2020 14:34:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GO1W2N1L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729807AbgKIOeB (ORCPT ); Mon, 9 Nov 2020 09:34:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729454AbgKIOeB (ORCPT ); Mon, 9 Nov 2020 09:34:01 -0500 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDC2FC0613CF; Mon, 9 Nov 2020 06:34:00 -0800 (PST) Received: by mail-qk1-x741.google.com with SMTP id q5so3842154qkc.12; Mon, 09 Nov 2020 06:34:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=gCiC2QrGVvZy6BwdDI/CgCdt1CEU+tvmWRC0OlmD6aQ=; b=GO1W2N1Lhx6B35DzuioiX1IL1gYxYF/NV0G2br2yrCL8YfBggWUCc5bjFfmZWrqz7z HOd66TVxwyWL2wkpkErivuAIq+QYley8KI7NkWaTvT2tkpEvpFjJhoMT5TkgLjCBORza KwtNLAblWGukGY2Pp8fXxl5NQ9cqU1XA8+NO2OBDklyFkxt0J20sB7UA9ylhnO5elEAD PpZhSASeBiSqFwuSO9Tsd7hoRTM3wNJq7xOdNgYIfy0OSA/N5PuVNfH/ccqlK4HrtoCW ufmMWMl4Uqjg5XWET9hNDV5KVL9omZoYG9ak0ZNOm3lNl63JREO0wUrVcYboHGkzkAvM VkVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=gCiC2QrGVvZy6BwdDI/CgCdt1CEU+tvmWRC0OlmD6aQ=; b=Hvo67QM476u9AhF7Wh4P8jQUssyzI7TSDv0bYB33FYeyCVjzguqdLEedE/FtF2TijZ JdAP9UGqCPGeqpxR/B44npOj4kWJPM02l6bT8M+sNR8+RWbFmHLiGS7p7bOLqDVJY3fJ jFQvqu1S98vNgWPIyqv3gukb6GNX1f8387KvhBYwEhlyUI9UvSFFMH9kwFjZGIuxBddy p8ZwWzSTchr3z0wAyoKvmNGMspEXFP7ZkjDYfKWpls/b0Wnw1uhsCjqqIzj2lryUoA+r iO98EDejMe2dOxHkNehOLsOpozzsD4+amw27VSNaVNB8sTysZ3H16D80YPCTzRUnAQn/ 5dvg== X-Gm-Message-State: AOAM532oSJH6PNc77TN2wkAqCCTP3dLBiYTbl5AZnmhGytwBoNkXD3pz ZPqbHRIKMGj039zhCwP6/CQ= X-Google-Smtp-Source: ABdhPJxo/WB/L7eXPNeaCbSiryg8v9P4QGKxwW8YxKhE4WVSlxSctLpNASiDqlkv7bI6AVaruoW+7A== X-Received: by 2002:a37:b07:: with SMTP id 7mr14383632qkl.370.1604932440032; Mon, 09 Nov 2020 06:34:00 -0800 (PST) Received: from [192.168.1.201] (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.googlemail.com with ESMTPSA id b4sm2517971qti.64.2020.11.09.06.33.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Nov 2020 06:33:59 -0800 (PST) Subject: Re: [PATCH 02/32] spi: dw: Add support for 32-bits ctrlr0 layout To: Serge Semin , Damien Le Moal Cc: Palmer Dabbelt , linux-riscv@lists.infradead.org, Rob Herring , Frank Rowand , devicetree@vger.kernel.org, Mark Brown , linux-spi@vger.kernel.org, Stephen Boyd , linux-clk@vger.kernel.org, Linus Walleij , linux-gpio@vger.kernel.org, Philipp Zabel References: <20201107081420.60325-1-damien.lemoal@wdc.com> <20201107081420.60325-3-damien.lemoal@wdc.com> <20201109142529.tt5ojjyn36vd3ohe@mobilestation> From: Sean Anderson Autocrypt: addr=seanga2@gmail.com; prefer-encrypt=mutual; keydata= mQENBFe74PkBCACoLC5Zq2gwrDcCkr+EPGsT14bsxrW07GiYzQhLCgwnPdEpgU95pXltbFhw 46GfyffABWxHKO2x+3L1S6ZxC5AiKbYXo7lpnTBYjamPWYouz+VJEVjUx9aaSEByBah5kX6a lKFZWNbXLAJh+dE1HFaMi3TQXXaInaREc+aO1F7fCa2zNE75ja+6ah8L4TPRFZ2HKQzve0/Y GXtoRw97qmnm3U36vKWT/m2AiLF619F4T1mHvlfjyd9hrVwjH5h/2rFyroXVXBZHGA9Aj8eN F2si35dWSZlIwXkNu9bXp0/pIu6FD0bI+BEkD5S7aH1G1iAcMFi5Qq2RNa041DfQSDDHABEB AAG0K1NlYW4gR2FsbGFnaGVyIEFuZGVyc29uIDxzZWFuZ2EyQGdtYWlsLmNvbT6JAVcEEwEK AEECGwMFCwkIBwIGFQgJCgsCBBYCAwECHgECF4ACGQEWIQSQYR1bzo1I0gPoYCg+6I/stKEQ bgUCXT+S2AUJB2TlXwAKCRA+6I/stKEQbhNOB/9ooea0hU9Sgh7PBloU6CgaC5mlqPLB7NTp +JkB+nh3Fqhk+qLZwzEynnuDLl6ESpVHIc0Ym1lyF4gT3DsrlGT1h0Gzw7vUwd1+ZfN0CuIx Rn861U/dAUjvbtN5kMBqOI4/5ea+0r7MACcIVnKF/wMXBD8eypHsorT2sJTzwZ6DRCNP70C5 N1ahpqqNmXe0uLdP0pu55JCqhrGw2SinkRMdWyhSxT56uNwIVHGhLTqH7Q4t1N6G1EH626qa SvIJsWlNpll6Y3AYLDw2/Spw/hqieS2PQ/Ky3rPZnvJt7/aSNYsKoFGX0yjkH67Uq8Lx0k1L w8jpXnbEPQN3A2ZJCbeM Message-ID: <6dc6d52e-a39d-c351-5280-71b9e8eafe37@gmail.com> Date: Mon, 9 Nov 2020 09:33:58 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201109142529.tt5ojjyn36vd3ohe@mobilestation> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org On 11/9/20 9:25 AM, Serge Semin wrote: > Hello Damien, > Thanks for your patches. My comments are below. > > On Sat, Nov 07, 2020 at 05:13:50PM +0900, Damien Le Moal wrote: >> Synopsis DesignWare DW_apb_ssi version 4 defines a 32-bit layout of >> the ctrlr0 register for SPI masters. The layout of ctrlr0 is: >> >> | 31 .. 23 | 22 .. 21 | 20 .. 16 | >> | other stuff | spi_frf | dfs_32 | >> >> | 15 .. 10 | 9 .. 8 | 7 .. 6 | 5 .. 4 | 3 .. 0 | >> | other stuff | tmod | mode | frf | dfs | >> > >> Th main difference of this layout with the 16-bits version is the data > ^ > | > e > >> frame format field which resides in bits 16..20 instead of bits 3..0. >> > > Are you sure they have been moved from [0, 3] to [16, 20]? I don't have the > manual for the 4.0x version of the core, but according to this patch: > https://patchwork.kernel.org/project/spi-devel-general/patch/1575907443-26377-7-git-send-email-wan.ahmad.zainie.wan.mohamad@intel.com/ > it has been ok to use the lowest four bits for DFS setting. Is the commit > message misleading there? This commit message is a truncated version of [1]. Importantly, DFS is valid when SSI_MAX_XFER_SIZE=16. When it =32, then DFS_32 must be used (since DFS is constant 0xF). Since SSI_MAX_XFER_SIZE is a synthesis parameter, there exist devices where DFS must be used, and also where DFS_32 must be used. [1] https://patchwork.ozlabs.org/project/uboot/patch/20201016225755.302659-10-seanga2@gmail.com/ --Sean > >> Introduce the DW SPI capability flag DW_SPI_CAP_DFS_32 to let a >> platform signal that this layout is in use. Modify >> dw_spi_update_config() to test this capability flag to set the data >> frame format field at the correct register location. >> >> Suggested-by: Sean Anderson >> Signed-off-by: Damien Le Moal >> --- >> drivers/spi/spi-dw-core.c | 8 ++++++-- >> drivers/spi/spi-dw.h | 9 +++++++++ >> 2 files changed, 15 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c >> index 2e50cc0a9291..841c85247f01 100644 >> --- a/drivers/spi/spi-dw-core.c >> +++ b/drivers/spi/spi-dw-core.c >> @@ -311,8 +311,12 @@ void dw_spi_update_config(struct dw_spi *dws, struct spi_device *spi, >> u32 speed_hz; >> u16 clk_div; >> > >> - /* CTRLR0[ 4/3: 0] Data Frame Size */ >> - cr0 |= (cfg->dfs - 1); >> + if (!(dws->caps & DW_SPI_CAP_DFS_32)) >> + /* CTRLR0[ 4/3: 0] Data Frame Size */ >> + cr0 |= (cfg->dfs - 1); >> + else >> + /* CTRLR0[20: 16] Data Frame Size */ >> + cr0 |= (cfg->dfs - 1) << DWC_APB_CTRLR0_32_DFS_OFFSET; > > If you extend the dfs field from four to five bits, then > controller->bits_per_word_mask field should be properly updated too. > > Alas it hasn't been done for the DWC_ssi version of the core. So I suppose it > should be fixed for the both of them. > > Just for the record. There are very handy macros for setting and getting bit fields > to/from a variable. This is a good place to use them instead of manually > shifting and defining the offsets. The macros are defined in linux/bitfield.h . > Alas this driver hasn't been converted to using them. So I won't insist on using > them here. But I hope someone will fix it sometime in future... I second that request. > -Sergey > >> >> if (!(dws->caps & DW_SPI_CAP_DWC_SSI)) >> /* CTRLR0[ 9:8] Transfer Mode */ >> diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h >> index faf40cb66498..48a11a51a407 100644 >> --- a/drivers/spi/spi-dw.h >> +++ b/drivers/spi/spi-dw.h >> @@ -9,6 +9,7 @@ >> #include >> #include >> #include >> +#include >> >> /* Register offsets */ >> #define DW_SPI_CTRLR0 0x00 >> @@ -72,6 +73,13 @@ >> #define DWC_SSI_CTRLR0_FRF_OFFSET 6 >> #define DWC_SSI_CTRLR0_DFS_OFFSET 0 >> >> +/* >> + * Bit fields in CTRLR0 for DWC_apb_ssi v4 32-bits ctrlr0. >> + * Based on DW_apb_ssi Databook v4.02a. >> + */ >> +#define DWC_APB_CTRLR0_32_DFS_OFFSET 16 >> +#define DWC_APB_CTRLR0_32_DFS_MASK GENMASK(20, 16) >> + >> /* >> * For Keem Bay, CTRLR0[31] is used to select controller mode. >> * 0: SSI is slave >> @@ -121,6 +129,7 @@ enum dw_ssi_type { >> #define DW_SPI_CAP_CS_OVERRIDE BIT(0) >> #define DW_SPI_CAP_KEEMBAY_MST BIT(1) >> #define DW_SPI_CAP_DWC_SSI BIT(2) >> +#define DW_SPI_CAP_DFS_32 BIT(3) >> >> /* Slave spi_transfer/spi_mem_op related */ >> struct dw_spi_cfg { >> -- >> 2.28.0 >> From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.0 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3313C388F7 for ; Mon, 9 Nov 2020 14:34:13 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 474E1206D8 for ; Mon, 9 Nov 2020 14:34:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WDE4SFlN"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GO1W2N1L" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 474E1206D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Vryttjqtug+AjDG7Fg3srk8hvY+GNWuJG71nxB8+DWY=; b=WDE4SFlN06KgGE46XlJw5eLin z+guHWNI/M/7f81c7PNp+eTZBG4NCs4ajBUW2PIacBahKdU8HhWb+lCebagGrI4BpicFKxsRCqnqz wo6EnRzyQ71SAX3cRSo7uVTFU/JYnV4nGL8wNQBxsXtL8UhlAKhx4pCtcVpMhnnHv/05SM33cnZcn cjMyy2aoc4tLGMktMh+3T5Us2Fn3TywCYQ1drkHwLl2JrfRdtUSnSj8vPtYwY0Y89d1aBY/JZdfje qPxtm+HMNwLji5ixg/oPyrgU8D2Yl4n/OC6nt7er0nxWyu5FXAV7XmeUz7m4XpONNR4SHJ64fR5LU nq9cMMOzg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kc8FA-0005H5-L5; Mon, 09 Nov 2020 14:34:04 +0000 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kc8F8-0005GC-51 for linux-riscv@lists.infradead.org; Mon, 09 Nov 2020 14:34:03 +0000 Received: by mail-qk1-x741.google.com with SMTP id v143so3494889qkb.2 for ; Mon, 09 Nov 2020 06:34:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=gCiC2QrGVvZy6BwdDI/CgCdt1CEU+tvmWRC0OlmD6aQ=; b=GO1W2N1Lhx6B35DzuioiX1IL1gYxYF/NV0G2br2yrCL8YfBggWUCc5bjFfmZWrqz7z HOd66TVxwyWL2wkpkErivuAIq+QYley8KI7NkWaTvT2tkpEvpFjJhoMT5TkgLjCBORza KwtNLAblWGukGY2Pp8fXxl5NQ9cqU1XA8+NO2OBDklyFkxt0J20sB7UA9ylhnO5elEAD PpZhSASeBiSqFwuSO9Tsd7hoRTM3wNJq7xOdNgYIfy0OSA/N5PuVNfH/ccqlK4HrtoCW ufmMWMl4Uqjg5XWET9hNDV5KVL9omZoYG9ak0ZNOm3lNl63JREO0wUrVcYboHGkzkAvM VkVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=gCiC2QrGVvZy6BwdDI/CgCdt1CEU+tvmWRC0OlmD6aQ=; b=ZndsKXI56OwbX6D3HnCUI9Op+2n1u04IZfBlxllZp3phIDPe6WDdT1Dh7l5soOah/e 4T584U0SmycaFVR0PXE7MmbNqMBjPGIEki1456HkYh7m5j2YbrTg1ILPUtSEC2ZJU/yo fT9PYYVCUMk+kqepeGEsjw7lZ6H4fWiY5idsv9tBIyTuopnY9hnH2ZRvJ8gYN01LXgpH 9m0cOT/GDCU1G73ZajW1u6AlrQ3J6BzZ2pgiwLn3gDdPoPy5AdEtQRuHuCzxnHekli8D iDCkLKIfZW6n0TeG2vdrb7idph337RgPii1gweAHKtHlWblWX9Nd7cSKZ5xZ3wOxFy5W ofGw== X-Gm-Message-State: AOAM532xj1UJeJpPAkoj4MI/QSHXpxZpIu5+Qgegz2i+77gcMKmm1VTu mvIePYVssICxE3Bevz9LYFXc0S6lznqgdA== X-Google-Smtp-Source: ABdhPJxo/WB/L7eXPNeaCbSiryg8v9P4QGKxwW8YxKhE4WVSlxSctLpNASiDqlkv7bI6AVaruoW+7A== X-Received: by 2002:a37:b07:: with SMTP id 7mr14383632qkl.370.1604932440032; Mon, 09 Nov 2020 06:34:00 -0800 (PST) Received: from [192.168.1.201] (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.googlemail.com with ESMTPSA id b4sm2517971qti.64.2020.11.09.06.33.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Nov 2020 06:33:59 -0800 (PST) Subject: Re: [PATCH 02/32] spi: dw: Add support for 32-bits ctrlr0 layout To: Serge Semin , Damien Le Moal References: <20201107081420.60325-1-damien.lemoal@wdc.com> <20201107081420.60325-3-damien.lemoal@wdc.com> <20201109142529.tt5ojjyn36vd3ohe@mobilestation> From: Sean Anderson Autocrypt: addr=seanga2@gmail.com; prefer-encrypt=mutual; keydata= mQENBFe74PkBCACoLC5Zq2gwrDcCkr+EPGsT14bsxrW07GiYzQhLCgwnPdEpgU95pXltbFhw 46GfyffABWxHKO2x+3L1S6ZxC5AiKbYXo7lpnTBYjamPWYouz+VJEVjUx9aaSEByBah5kX6a lKFZWNbXLAJh+dE1HFaMi3TQXXaInaREc+aO1F7fCa2zNE75ja+6ah8L4TPRFZ2HKQzve0/Y GXtoRw97qmnm3U36vKWT/m2AiLF619F4T1mHvlfjyd9hrVwjH5h/2rFyroXVXBZHGA9Aj8eN F2si35dWSZlIwXkNu9bXp0/pIu6FD0bI+BEkD5S7aH1G1iAcMFi5Qq2RNa041DfQSDDHABEB AAG0K1NlYW4gR2FsbGFnaGVyIEFuZGVyc29uIDxzZWFuZ2EyQGdtYWlsLmNvbT6JAVcEEwEK AEECGwMFCwkIBwIGFQgJCgsCBBYCAwECHgECF4ACGQEWIQSQYR1bzo1I0gPoYCg+6I/stKEQ bgUCXT+S2AUJB2TlXwAKCRA+6I/stKEQbhNOB/9ooea0hU9Sgh7PBloU6CgaC5mlqPLB7NTp +JkB+nh3Fqhk+qLZwzEynnuDLl6ESpVHIc0Ym1lyF4gT3DsrlGT1h0Gzw7vUwd1+ZfN0CuIx Rn861U/dAUjvbtN5kMBqOI4/5ea+0r7MACcIVnKF/wMXBD8eypHsorT2sJTzwZ6DRCNP70C5 N1ahpqqNmXe0uLdP0pu55JCqhrGw2SinkRMdWyhSxT56uNwIVHGhLTqH7Q4t1N6G1EH626qa SvIJsWlNpll6Y3AYLDw2/Spw/hqieS2PQ/Ky3rPZnvJt7/aSNYsKoFGX0yjkH67Uq8Lx0k1L w8jpXnbEPQN3A2ZJCbeM Message-ID: <6dc6d52e-a39d-c351-5280-71b9e8eafe37@gmail.com> Date: Mon, 9 Nov 2020 09:33:58 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201109142529.tt5ojjyn36vd3ohe@mobilestation> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201109_093402_231652_23B914A3 X-CRM114-Status: GOOD ( 34.14 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Linus Walleij , Stephen Boyd , Mark Brown , linux-spi@vger.kernel.org, linux-gpio@vger.kernel.org, Rob Herring , Palmer Dabbelt , Philipp Zabel , linux-riscv@lists.infradead.org, Frank Rowand , linux-clk@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On 11/9/20 9:25 AM, Serge Semin wrote: > Hello Damien, > Thanks for your patches. My comments are below. > > On Sat, Nov 07, 2020 at 05:13:50PM +0900, Damien Le Moal wrote: >> Synopsis DesignWare DW_apb_ssi version 4 defines a 32-bit layout of >> the ctrlr0 register for SPI masters. The layout of ctrlr0 is: >> >> | 31 .. 23 | 22 .. 21 | 20 .. 16 | >> | other stuff | spi_frf | dfs_32 | >> >> | 15 .. 10 | 9 .. 8 | 7 .. 6 | 5 .. 4 | 3 .. 0 | >> | other stuff | tmod | mode | frf | dfs | >> > >> Th main difference of this layout with the 16-bits version is the data > ^ > | > e > >> frame format field which resides in bits 16..20 instead of bits 3..0. >> > > Are you sure they have been moved from [0, 3] to [16, 20]? I don't have the > manual for the 4.0x version of the core, but according to this patch: > https://patchwork.kernel.org/project/spi-devel-general/patch/1575907443-26377-7-git-send-email-wan.ahmad.zainie.wan.mohamad@intel.com/ > it has been ok to use the lowest four bits for DFS setting. Is the commit > message misleading there? This commit message is a truncated version of [1]. Importantly, DFS is valid when SSI_MAX_XFER_SIZE=16. When it =32, then DFS_32 must be used (since DFS is constant 0xF). Since SSI_MAX_XFER_SIZE is a synthesis parameter, there exist devices where DFS must be used, and also where DFS_32 must be used. [1] https://patchwork.ozlabs.org/project/uboot/patch/20201016225755.302659-10-seanga2@gmail.com/ --Sean > >> Introduce the DW SPI capability flag DW_SPI_CAP_DFS_32 to let a >> platform signal that this layout is in use. Modify >> dw_spi_update_config() to test this capability flag to set the data >> frame format field at the correct register location. >> >> Suggested-by: Sean Anderson >> Signed-off-by: Damien Le Moal >> --- >> drivers/spi/spi-dw-core.c | 8 ++++++-- >> drivers/spi/spi-dw.h | 9 +++++++++ >> 2 files changed, 15 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c >> index 2e50cc0a9291..841c85247f01 100644 >> --- a/drivers/spi/spi-dw-core.c >> +++ b/drivers/spi/spi-dw-core.c >> @@ -311,8 +311,12 @@ void dw_spi_update_config(struct dw_spi *dws, struct spi_device *spi, >> u32 speed_hz; >> u16 clk_div; >> > >> - /* CTRLR0[ 4/3: 0] Data Frame Size */ >> - cr0 |= (cfg->dfs - 1); >> + if (!(dws->caps & DW_SPI_CAP_DFS_32)) >> + /* CTRLR0[ 4/3: 0] Data Frame Size */ >> + cr0 |= (cfg->dfs - 1); >> + else >> + /* CTRLR0[20: 16] Data Frame Size */ >> + cr0 |= (cfg->dfs - 1) << DWC_APB_CTRLR0_32_DFS_OFFSET; > > If you extend the dfs field from four to five bits, then > controller->bits_per_word_mask field should be properly updated too. > > Alas it hasn't been done for the DWC_ssi version of the core. So I suppose it > should be fixed for the both of them. > > Just for the record. There are very handy macros for setting and getting bit fields > to/from a variable. This is a good place to use them instead of manually > shifting and defining the offsets. The macros are defined in linux/bitfield.h . > Alas this driver hasn't been converted to using them. So I won't insist on using > them here. But I hope someone will fix it sometime in future... I second that request. > -Sergey > >> >> if (!(dws->caps & DW_SPI_CAP_DWC_SSI)) >> /* CTRLR0[ 9:8] Transfer Mode */ >> diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h >> index faf40cb66498..48a11a51a407 100644 >> --- a/drivers/spi/spi-dw.h >> +++ b/drivers/spi/spi-dw.h >> @@ -9,6 +9,7 @@ >> #include >> #include >> #include >> +#include >> >> /* Register offsets */ >> #define DW_SPI_CTRLR0 0x00 >> @@ -72,6 +73,13 @@ >> #define DWC_SSI_CTRLR0_FRF_OFFSET 6 >> #define DWC_SSI_CTRLR0_DFS_OFFSET 0 >> >> +/* >> + * Bit fields in CTRLR0 for DWC_apb_ssi v4 32-bits ctrlr0. >> + * Based on DW_apb_ssi Databook v4.02a. >> + */ >> +#define DWC_APB_CTRLR0_32_DFS_OFFSET 16 >> +#define DWC_APB_CTRLR0_32_DFS_MASK GENMASK(20, 16) >> + >> /* >> * For Keem Bay, CTRLR0[31] is used to select controller mode. >> * 0: SSI is slave >> @@ -121,6 +129,7 @@ enum dw_ssi_type { >> #define DW_SPI_CAP_CS_OVERRIDE BIT(0) >> #define DW_SPI_CAP_KEEMBAY_MST BIT(1) >> #define DW_SPI_CAP_DWC_SSI BIT(2) >> +#define DW_SPI_CAP_DFS_32 BIT(3) >> >> /* Slave spi_transfer/spi_mem_op related */ >> struct dw_spi_cfg { >> -- >> 2.28.0 >> _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv