Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp240548iob; Mon, 2 May 2022 18:13:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGEfv/gFIvX+WGL5lRCVFR7jxKTrAK3g+Ia3lkZHIFhoZx/sEOonn4oxFnnk7lTeimMEDk X-Received: by 2002:aa7:9109:0:b0:50a:78c8:8603 with SMTP id 9-20020aa79109000000b0050a78c88603mr14077343pfh.77.1651540383831; Mon, 02 May 2022 18:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651540383; cv=none; d=google.com; s=arc-20160816; b=pY7XgdAWSk9NTst8Bfk3t6XUHgp2kPqPH4amlB8B9JgAU4Uj20ci8nYEqpdCZTkMUE pI1HmtHOhx2IDGqVaBXbWZE/pWd5Lr+SRrhTd3lF131GwOFx/BQOA8qWai8u9t0qzhv4 oN7bGn9ndrafiGPBKPsSOrQEf2OWkm+sFtGWl4gg0j5GcExJlMiHq0YplZhXZxpJvEpR Zl0HmilPrH9XnwHsSDvIqMRAnGCJCPDWIdw62mwrNu4Y/F+wws/hjciulQcvjCO0QAV3 N2su44Z5yYfHuzS2g1u7oeJvtJSAJYIxw630EaMYoZEMyAHJqV9Jd/vwe6CnJmWGfutM hyeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=SC8skA+OBCO4ttnMU6A69mO02uNTXym35DLsl/48diU=; b=0K5s3oTN38C7AwGy9SC7Ysf8TY3JjO9W/MaQmFQA3RDsFFg4fcWq+Rq6J0/Jwu92aS WsSq/hP/Uby/LZrpASXBCghNjv3dijJeFtEl4l2OCvjGjeMtTsan4u2EFN4/i4W3nbXy RpTVkT4/UBg/0o4dWkJ4wre3rHI5uPr6GR3Axc0E6UYhu9SEnBvMoC/HfA7ZuZp1TR7/ y1oru+9PWPBQineJMOVL/CPSnmuTp2J7b4vzq/400VL3KR9ZyDGl3MSgGNX9VAPArFvJ AKdoUJfbwZpZ7eKDP3KEF/gvpd4vzq70ssq2SGygiwvoUrX3al+mlcoOxyH6Lj8VUrDl z+IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JTQTr1Gn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u189-20020a6379c6000000b003ab7e64a1f0si15485338pgc.194.2022.05.02.18.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 18:13:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JTQTr1Gn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C40A641602; Mon, 2 May 2022 17:53:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232682AbiEBLRL (ORCPT + 99 others); Mon, 2 May 2022 07:17:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379775AbiEBLRH (ORCPT ); Mon, 2 May 2022 07:17:07 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AA04DE93; Mon, 2 May 2022 04:13:32 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id t6so19179217wra.4; Mon, 02 May 2022 04:13:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=SC8skA+OBCO4ttnMU6A69mO02uNTXym35DLsl/48diU=; b=JTQTr1GnJeZgk06pN6GhaUb2czWsZHnh/AlHrbSZz19/kw5xmFBnm05PNJiBpsipKw WiPO8kbX3nazhOCZLjBYTRoSdC5iXl/YjAIxGxjexHt5VTWk21U5T7oQ+auduHMgFcJd yXT4Yt1+ssKjfnOtJuDrE4tOA0x1zSpqQAH4DhhN5SJurEMG7vQ9JrQmHEMbJlNeG1xy 1GD/aklFtrnsasmbWmYey4hFJg446lYncvxLLK5pDP8rSMz8vZuvisuwWR98b1xsc4Qk rxOzCV2A5UVCHoL5E/UwbFSrgbOIo+7JLx+75cjBsGJ4jmQWVrsbDo3WjCUCxN++sId9 wx4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=SC8skA+OBCO4ttnMU6A69mO02uNTXym35DLsl/48diU=; b=FjheUtmZGwH3HXmLsKGSmjltdcO6sXb2wGSLeapOHwzqugIIrVzMutrF2LvdnDCoUq qZ6um+wovnaXBGaEPadGDdmC08InREzalwagq5WFqPriU8XZHb7U/FNbuUtoRufYsLJT BegYd3NZOTFolvs6ihwjKBe6rb5bWlHwSkLdw55kga1oP7ORuUBHMHX4Nd3W2SCBW8IS lTRviPLBQW6Jva/M4rsHovYeBhEzlHtuQmE72Z/FnS/zL8zkyBUMbya62u0T2oZ9O3Vr Ei7y6An3Re/PuWaq5tW9rcaBANm3imUrYrp8dyU/QnQhUd8HsCACI83GjUGh5PLxyM5o EW8A== X-Gm-Message-State: AOAM530B9JVv6OgCAcuoTp1zP3TsdcBp8BJUdFcYXfRzVm0pF9/6UVaq EgOZtTODfPe4hr1u1AaBJrKfATwQI34= X-Received: by 2002:adf:e10a:0:b0:20a:86a3:d06f with SMTP id t10-20020adfe10a000000b0020a86a3d06fmr9415372wrz.249.1651490011107; Mon, 02 May 2022 04:13:31 -0700 (PDT) Received: from localhost.localdomain ([213.215.174.110]) by smtp.gmail.com with ESMTPSA id c11-20020adfa70b000000b0020c5253d90esm9082836wrd.90.2022.05.02.04.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 04:13:30 -0700 (PDT) From: Andrea Zanotti To: Mark Brown , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrea Zanotti Subject: [PATCH] spi: omap2-mcspi: add support for interword delay Date: Mon, 2 May 2022 13:13:00 +0200 Message-Id: <20220502111300.24754-1-andreazanottifo@gmail.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The module omap2-mcspi does not support the interword delay parameter present in the spi transfer. On one side, if the module is instructed to use the dma, this parameter is correctly ignored. However, without the usage of the dma, that parameter should be used. The patch introduce the handling of such delay in the omap2-mcspi module, using standard spi_delay struct. The patch has been tested using as benchmark a DM3730. The delay function used (spi_delay_exec) is already present in the kernel and it checks on its own the validity of the input, as such, no additional checks are present. The range of usage of the udelay function is incremented to 200 us, as the change from udelay to usleep_range introduces not neglectible delays. Signed-off-by: Andrea Zanotti --- drivers/spi/spi-omap2-mcspi.c | 6 ++++++ drivers/spi/spi.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index d4c9510af393..a79934be7037 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -758,6 +758,8 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) dev_vdbg(&spi->dev, "read-%d %02x\n", word_len, *(rx - 1)); } + /* Add word delay between each word */ + spi_delay_exec(&xfer->word_delay, xfer); } while (c); } else if (word_len <= 16) { u16 *rx; @@ -805,6 +807,8 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) dev_vdbg(&spi->dev, "read-%d %04x\n", word_len, *(rx - 1)); } + /* Add word delay between each word */ + spi_delay_exec(&xfer->word_delay, xfer); } while (c >= 2); } else if (word_len <= 32) { u32 *rx; @@ -852,6 +856,8 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) dev_vdbg(&spi->dev, "read-%d %08x\n", word_len, *(rx - 1)); } + /* Add word delay between each word */ + spi_delay_exec(&xfer->word_delay, xfer); } while (c >= 4); } diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 419de3d40481..5fa36c469ba0 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1143,7 +1143,7 @@ static void _spi_transfer_delay_ns(u32 ns) } else { u32 us = DIV_ROUND_UP(ns, 1000); - if (us <= 10) + if (us <= 200) udelay(us); else usleep_range(us, us + DIV_ROUND_UP(us, 10)); -- 2.17.1