Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4468552pxu; Mon, 21 Dec 2020 13:20:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3Lj0f2k8oHJLU+YqLoYFcz0PBEgCsF+F/4z85e499d/zrWjbvr1ccwbY63yvoFHpaXqYC X-Received: by 2002:a17:907:971c:: with SMTP id jg28mr17155745ejc.85.1608585610817; Mon, 21 Dec 2020 13:20:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608585610; cv=none; d=google.com; s=arc-20160816; b=S7GH8+6CSZHTODKB9HW8O4s7hs0j3C6YzQ+msr6lb7NorvSi9BbmCa1xuNzXgxOxkP 3oZ9VoZ7uIAQPiqO9au8qvy2KWC/ShA7jyjpbXquvQPpwt8Ox5nzjsUv3TBaa3qMTCPT ULDRyYUQwBPyybzs3i2pUuU6WgXO10loHiO+ZNVXP7n9fIegmAhA/dgmPnVUCVO0hgvv Fq9ZJrmvPyqWWWEAfzKkO4obGl54QHZPYTiT/NxYCboXP587TV8z3vzsGo54w81ywcYA 8oWLC3XKMzDH86ueEIqTs81/iV4ltN+37shKNkJhTdqZsVRP7MC+1/NhDqeBEgsj7HyQ Tejw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=5xQLb2sWtAGzefv1tnfhjT/+4lUyvepFNtfHqTrm+TM=; b=iRMPZJOoy3nGQbIbui5Z5l+ZYShJ4pL4gr6R/Ciwf1Ya2PJCtbPZP3BBfDNhek9K9j d0+0TDKQj3cMi99ZuBgzTO4kmVl6terSch6Nr3sIe1IE/+/hGgeHkvyfWM+EHvp9a0dS tj+8D54kTRULXgRpXmoKVX+Cqvs73YrFTLVAAtrYC9/W58zRjroJd/540ai5YmrKjPli qWkVDxvnT27x/6/kLg8Zsvt4RXTeUQqlZWAfSqKx9b2omVdivEWWehoBTKuIqEhXnIFg d2IMT/vMIOn0cIwWyiJ9Msm3UE6YSf5jS3zgeDOo6ae5wdJmlioE+78x7O/dn6FfG5Zd ipPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=PaMGgqMo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id re20si8850532ejb.112.2020.12.21.13.19.36; Mon, 21 Dec 2020 13:20:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=PaMGgqMo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726597AbgLUVSa (ORCPT + 99 others); Mon, 21 Dec 2020 16:18:30 -0500 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:4547 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726413AbgLUVSa (ORCPT ); Mon, 21 Dec 2020 16:18:30 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Mon, 21 Dec 2020 13:17:49 -0800 Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 21 Dec 2020 21:17:44 +0000 Received: from skomatineni-linux.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.10) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Mon, 21 Dec 2020 21:17:44 +0000 From: Sowjanya Komatineni To: , , , , CC: , , , , , , , Subject: [PATCH v5 6/9] spi: tegra210-quad: Add support for hardware dummy cycles transfer Date: Mon, 21 Dec 2020 13:17:36 -0800 Message-ID: <1608585459-17250-7-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1608585459-17250-1-git-send-email-skomatineni@nvidia.com> References: <1608585459-17250-1-git-send-email-skomatineni@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1608585469; bh=5xQLb2sWtAGzefv1tnfhjT/+4lUyvepFNtfHqTrm+TM=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:X-NVConfidentiality:MIME-Version:Content-Type; b=PaMGgqMo5vrg9HiXuxRB5aS6XWWZVBZjL4Gln4c/2h8mSEFmIV1QGuCQTbiYGYo/4 55OMIF5cDomyoZPpdFB0wRAWHt4D6Zeff732cLlmxmJyZ00EqTAAtvmjwcWu/k0qrP J8VY7bAvc5ofnvFvWWHOxhT9q6b4ffqjafY2JO2mJhH3mPDf601rhOhdb3Z5lDp1k4 wQzkJhMlq1PtfBrg6d5Mj7yk/dQozEIjxDiUSFcb2E/GLwrc66ygCrCZWBxEu3RpNj MsMPinN8r1tFSJ+e4oul6vpNL7ZSucyLNhlgbj/dXHBiYcf733zXG9iwMLxVYy+nm+ QJ1IDLHtCEQEg== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tegra Quad SPI controller hardware supports sending dummy bytes based on programmed dummy clock cycles after the actual transfer bytes. This patch adds this support of hardware dummy bytes transfer and skips transfer of dummy bytes from the software. For dummy cycles more than Tegra Quad SPI hardware maximum dummy cycles limit, driver transfers dummy bytes from the software. Signed-off-by: Sowjanya Komatineni --- drivers/spi/spi-tegra210-quad.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-tegra210-quad.c b/drivers/spi/spi-tegra210-quad.c index e7bee8d..2f806f4 100644 --- a/drivers/spi/spi-tegra210-quad.c +++ b/drivers/spi/spi-tegra210-quad.c @@ -117,6 +117,7 @@ #define QSPI_MISC_REG 0x194 #define QSPI_NUM_DUMMY_CYCLE(x) (((x) & 0xff) << 0) +#define QSPI_DUMMY_CYCLES_MAX 0xff #define DATA_DIR_TX BIT(0) #define DATA_DIR_RX BIT(1) @@ -170,6 +171,7 @@ struct tegra_qspi { u32 def_command2_reg; u32 spi_cs_timing1; u32 spi_cs_timing2; + u8 dummy_cycles; struct completion xfer_completion; struct spi_transfer *curr_xfer; @@ -856,6 +858,8 @@ static int tegra_qspi_start_transfer_one(struct spi_device *spi, tqspi->command1_reg = command1; + tegra_qspi_writel(tqspi, QSPI_NUM_DUMMY_CYCLE(tqspi->dummy_cycles), QSPI_MISC_REG); + ret = tegra_qspi_flush_fifos(tqspi, false); if (ret < 0) return ret; @@ -974,7 +978,7 @@ static int tegra_qspi_transfer_one_message(struct spi_master *master, struct spi { struct tegra_qspi *tqspi = spi_master_get_devdata(master); struct spi_device *spi = msg->spi; - struct spi_transfer *xfer; + struct spi_transfer *transfer; bool is_first_msg = true; int ret; @@ -983,9 +987,33 @@ static int tegra_qspi_transfer_one_message(struct spi_master *master, struct spi tqspi->tx_status = 0; tqspi->rx_status = 0; - list_for_each_entry(xfer, &msg->transfers, transfer_list) { + list_for_each_entry(transfer, &msg->transfers, transfer_list) { + struct spi_transfer *xfer = transfer; + u8 dummy_bytes = 0; u32 cmd1; + tqspi->dummy_cycles = 0; + /* + * Tegra QSPI hardware supports dummy bytes transfer after actual transfer + * bytes based on programmed dummy clock cycles in the QSPI_MISC register. + * So, check if the next transfer is dummy data transfer and program dummy + * clock cycles along with the current transfer and skip next transfer. + */ + if (!list_is_last(&xfer->transfer_list, &msg->transfers)) { + struct spi_transfer *next_xfer; + + next_xfer = list_next_entry(xfer, transfer_list); + if (next_xfer->dummy_data) { + u32 dummy_cycles = next_xfer->len * 8 / next_xfer->tx_nbits; + + if (dummy_cycles <= QSPI_DUMMY_CYCLES_MAX) { + tqspi->dummy_cycles = dummy_cycles; + dummy_bytes = next_xfer->len; + transfer = next_xfer; + } + } + } + reinit_completion(&tqspi->xfer_completion); cmd1 = tegra_qspi_setup_transfer_one(spi, xfer, is_first_msg); @@ -1016,7 +1044,7 @@ static int tegra_qspi_transfer_one_message(struct spi_master *master, struct spi goto complete_xfer; } - msg->actual_length += xfer->len; + msg->actual_length += xfer->len + dummy_bytes; complete_xfer: if (ret < 0) { -- 2.7.4