Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp653212pxu; Fri, 11 Dec 2020 10:54:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4PdC9hZIzwSPlsbbMorMHd1EsBdycFTwGNa6f5No6LQRe9DHnyfZpULm/dWQkisQhHrtO X-Received: by 2002:a05:6402:1383:: with SMTP id b3mr13027841edv.100.1607712874048; Fri, 11 Dec 2020 10:54:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607712874; cv=none; d=google.com; s=arc-20160816; b=09Fd14jJvZai2a3TBwxcg46WL3lMeO3tN8lWSi8MLD/tdIyF2mfYKNFONzQJIzNKGr KRwYaWx4jtSG6XyE6aoqrcAEUqltEN+F6c2E+jYTaGx27Hm0L8dCE2VYw0Kx55yomjq0 uMY6CJFlUgulnk2M6qrHd63GHg0zrEFsLUnkqaqNTpvpkGlthVRsaIhueO6rt9bf80H1 Kv/dKt0taH3G6GjJIYqpYib9IhNiccrR5M+qqsKLrBPzSsiLomSvQZienCFjnvjd/OQo 5vrHqJrW49pYdv9zxu7S6lWDlqd7366crX0cjIu+94OLoZpA2PcHa/z27INKhCbhyYdk LskQ== 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=w3ehnwe0omM34FaObddURkJNKGQctD+ZomRiDYg+fkY=; b=utD4WCWrKniN1lGSDs1s6PgXfROiRQTo5aTqckWgw1Hv9yxh5FTF7BnaHr6oJzfAtF tj6oCnOOaqLs2lL3ooGLwm3tp6xQvKI5mz0D9WkO1//0tfz2R7KyV0RR5QNBBzQq17TT yUA+zjNBrMcGw/Xn11jYtk9yZeiIFyoPBeE0ELpY92bm0jhowu7z8yBVrS/V4dzAjav3 YfOXBPROFIbK6dWQznuXuaLI0aLYb7b4K78uD08vdobkHMcRkTTDuzhEF10looyQHX0h Hh7keBlk6ftYTzhKYJgUFFgRXwvYBO3AcBXo+UGQzLg8w+ivK2MOCRzZAToIUV2pMeJv o/Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=M3QtDGJ0; 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 q19si6222786edv.85.2020.12.11.10.54.07; Fri, 11 Dec 2020 10:54:34 -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=M3QtDGJ0; 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 S2393778AbgLKREN (ORCPT + 99 others); Fri, 11 Dec 2020 12:04:13 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:5171 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393257AbgLKRDG (ORCPT ); Fri, 11 Dec 2020 12:03:06 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Fri, 11 Dec 2020 09:01:36 -0800 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 11 Dec 2020 17:01:35 +0000 Received: from skomatineni-linux.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.13) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Fri, 11 Dec 2020 17:01:35 +0000 From: Sowjanya Komatineni To: , , , , CC: , , , , Subject: [PATCH v2 5/9] spi: spi-mem: Allow masters to transfer dummy cycles directly by hardware Date: Fri, 11 Dec 2020 09:01:24 -0800 Message-ID: <1607706088-1437-8-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1607706088-1437-1-git-send-email-skomatineni@nvidia.com> References: <1607706088-1437-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=1607706096; bh=w3ehnwe0omM34FaObddURkJNKGQctD+ZomRiDYg+fkY=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:X-NVConfidentiality:MIME-Version:Content-Type; b=M3QtDGJ0G+ShIS2KqrK5wZz8VU8My4IP/kP7qgLkbEN9RveXHb+BLDuafNnSEfepb Jl/1QcV4ALz/6ulU1WiQXFUJz49nEI4AcFnx+CMZcYhShgSI80dlbGjxnri0AB1bSs Xib4karOu1aK6Y/NxIZHAvryLIkpyXPHvBWqXN0rdFPPboa6u7MxFrILOhcnzXz+Vt DHRgp4UV18Pms2tOZlUAtF303lwzpdfISmpiUTh8+NhrBGtTH8Mrvg4o2WbZwbeJxG 1fjnN9/qTEq7LULCLS4CYb7ge6SVuNbuCJ+O2vKBJr5CHYH2f1OUaL4C6ODj+3n6FK Jhz2B4tLt2nbQ== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds a flag SPI_MASTER_USES_HW_DUMMY_CYCLES for the controllers that support transfer of dummy cycles by the hardware directly. For controller with this flag set, spi-mem driver will skip dummy bytes transfer in the spi message. Controller drivers can get the number of dummy cycles from spi_message. Signed-off-by: Sowjanya Komatineni --- drivers/spi/spi-mem.c | 18 +++++++++++------- include/linux/spi/spi.h | 8 ++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index f3a3f19..38a523b 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -350,13 +350,17 @@ int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) } if (op->dummy.nbytes) { - memset(tmpbuf + op->addr.nbytes + 1, 0xff, op->dummy.nbytes); - xfers[xferpos].tx_buf = tmpbuf + op->addr.nbytes + 1; - xfers[xferpos].len = op->dummy.nbytes; - xfers[xferpos].tx_nbits = op->dummy.buswidth; - spi_message_add_tail(&xfers[xferpos], &msg); - xferpos++; - totalxferlen += op->dummy.nbytes; + if (ctlr->flags & SPI_MASTER_USES_HW_DUMMY_CYCLES) { + msg.dummy_cycles = (op->dummy.nbytes * 8) / op->dummy.buswidth; + } else { + memset(tmpbuf + op->addr.nbytes + 1, 0xff, op->dummy.nbytes); + xfers[xferpos].tx_buf = tmpbuf + op->addr.nbytes + 1; + xfers[xferpos].len = op->dummy.nbytes; + xfers[xferpos].tx_nbits = op->dummy.buswidth; + spi_message_add_tail(&xfers[xferpos], &msg); + xferpos++; + totalxferlen += op->dummy.nbytes; + } } if (op->data.nbytes) { diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index aa09fdc..2024149 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -512,6 +512,8 @@ struct spi_controller { #define SPI_MASTER_GPIO_SS BIT(5) /* GPIO CS must select slave */ +#define SPI_MASTER_USES_HW_DUMMY_CYCLES BIT(6) /* HW dummy bytes transfer */ + /* flag indicating this is an SPI slave controller */ bool slave; @@ -1022,6 +1024,12 @@ struct spi_message { unsigned actual_length; int status; + /* + * dummy cycles in the message transfer. This is used by the controller + * drivers supports transfer of dummy cycles directly by the hardware. + */ + u8 dummy_cycles; + /* for optional use by whatever driver currently owns the * spi_message ... between calls to spi_async and then later * complete(), that's the spi_controller controller driver. -- 2.7.4