From nobody Sun Nov 24 02:59:44 2024 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D477212D21 for ; Thu, 7 Nov 2024 15:07:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730992068; cv=none; b=AFW8tn0x/IUsM/IukYVUU2ciaZfzhXkFY5ll9Rgs/jLj1qdBOOAspQ+B5GSxLrGS4L5h6rWCcGXn+aPMKyPa1JQ89IhFDqVf0PYkzdBjJVmqQBH9E4MNn11u2obIgW2eEsvADWs8ORhLBoG3mv58nDnUbpRhQV+yAXNRXx9Dpf8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730992068; c=relaxed/simple; bh=zmmURaCZvXE4+kB7JLY8MS1IeA8+E+rhjn3iho+XAj0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=UWI/vCrSQwg2+BOXOoXaz8hzQ4k/VJjVqdKHb3F9E2zRjdEyFHWQq1qW5YdISLHCfGK6ZgOsEwAs1doTuUWNN3mmrYp8BAr0lBYx9quhAclJlaeGHB84Nev8cnaC++oiq7Ipl4CbiveJoBp9Emt6GzjpvFLSzscS1oliyh/N6go= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1t946e-0003NQ-3U; Thu, 07 Nov 2024 16:07:32 +0100 From: Jonas Rebmann Date: Thu, 07 Nov 2024 16:07:31 +0100 Subject: [PATCH] spi: spidev_test: add support for word delay Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241107-spidev-test-word-delay-v1-1-d4bba5569e39@pengutronix.de> X-B4-Tracking: v=1; b=H4sIALLXLGcC/x3MSwqAMAwA0atI1gbaKgheRVykNmpAVBrxQ/HuF pdvMZNAOQortEWCyKeobGuGLQsYZlonRgnZ4IyrrTUN6i6BTzxYD7y2GDDwQg9a8uRd1dQVecj xHnmU+x93/ft+yB2VKGgAAAA= X-Change-ID: 20241107-spidev-test-word-delay-1abab23743ab To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, Jonas Rebmann X-Mailer: b4 0.14.2 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::ac X-SA-Exim-Mail-From: jre@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Support setting the word delay using the -w/--word-delay command line parameter. Note that spidev exposes word delay only as an u8, allowing for a maximum of 255us of delay to be inserted. Signed-off-by: Jonas Rebmann --- tools/spi/spidev_test.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/spi/spidev_test.c b/tools/spi/spidev_test.c index 9179942d7f15ceb5cab17477d950800f545b6ab4..f2135d619a0bb4aa3eff830af0f= 2114ad9991cc5 100644 --- a/tools/spi/spidev_test.c +++ b/tools/spi/spidev_test.c @@ -42,6 +42,7 @@ static char *input_file; static char *output_file; static uint32_t speed =3D 500000; static uint16_t delay; +static uint16_t word_delay; static int verbose; static int transfer_size; static int iterations; @@ -124,6 +125,7 @@ static void transfer(int fd, uint8_t const *tx, uint8_t= const *rx, size_t len) .rx_buf =3D (unsigned long)rx, .len =3D len, .delay_usecs =3D delay, + .word_delay_usecs =3D word_delay, .speed_hz =3D speed, .bits_per_word =3D bits, }; @@ -172,11 +174,12 @@ static void transfer(int fd, uint8_t const *tx, uint8= _t const *rx, size_t len) =20 static void print_usage(const char *prog) { - printf("Usage: %s [-2348CDFHILMNORSZbdilopsv]\n", prog); + printf("Usage: %s [-2348CDFHILMNORSZbdilopsvw]\n", prog); puts("general device settings:\n" " -D --device device to use (default /dev/spidev1.1)\n" " -s --speed max speed (Hz)\n" " -d --delay delay (usec)\n" + " -w --word-delay word delay (usec)\n" " -l --loop loopback\n" "spi mode:\n" " -H --cpha clock phase\n" @@ -213,6 +216,7 @@ static void parse_opts(int argc, char *argv[]) { "device", 1, 0, 'D' }, { "speed", 1, 0, 's' }, { "delay", 1, 0, 'd' }, + { "word-delay", 1, 0, 'w' }, { "loop", 0, 0, 'l' }, { "cpha", 0, 0, 'H' }, { "cpol", 0, 0, 'O' }, @@ -237,7 +241,7 @@ static void parse_opts(int argc, char *argv[]) }; int c; =20 - c =3D getopt_long(argc, argv, "D:s:d:b:i:o:lHOLC3ZFMNR248p:vS:I:", + c =3D getopt_long(argc, argv, "D:s:d:w:b:i:o:lHOLC3ZFMNR248p:vS:I:", lopts, NULL); =20 if (c =3D=3D -1) @@ -253,6 +257,9 @@ static void parse_opts(int argc, char *argv[]) case 'd': delay =3D atoi(optarg); break; + case 'w': + word_delay =3D atoi(optarg); + break; case 'b': bits =3D atoi(optarg); break; --- base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc change-id: 20241107-spidev-test-word-delay-1abab23743ab Best regards, --=20 Jonas Rebmann