* [PATCH 5/5] extending spitest with SPI_RTIOC_TRANSFER_N ioctl
@ 2020-01-14 16:23 Laurentiu-Cristian Duca
2020-01-14 17:30 ` Jan Kiszka
0 siblings, 1 reply; 2+ messages in thread
From: Laurentiu-Cristian Duca @ 2020-01-14 16:23 UTC (permalink / raw)
To: xenomai
From: Laurentiu-Cristian Duca <laurentiu.duca@gmail.com>
The ioctl_n user parameter must be set to non-zero value
in order to perform ioctl(SPI_RTIOC_TRANSFER_N, TRANSFER_SIZE);
if ioctl_n is 0 or undefined then the test performs ioctl(SPI_RTIOC_TRANSFER).
Default SPI clock speed is set to 40MHz instead of 60MHz
because bbb am335x realtime SPI driver has its maximum set to this value.
Signed-off-by: Laurentiu-Cristian Duca <laurentiu.duca@gmail.com>
---
testsuite/spitest/spitest.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/testsuite/spitest/spitest.c b/testsuite/spitest/spitest.c
index debf1b673..e3a1c6a44 100644
--- a/testsuite/spitest/spitest.c
+++ b/testsuite/spitest/spitest.c
@@ -40,17 +40,19 @@ smokey_test_plugin(spi_transfer,
SMOKEY_STRING(device),
SMOKEY_INT(speed),
SMOKEY_BOOL(latency),
+ SMOKEY_INT(ioctl_n)
),
"Run a SPI transfer.\n"
"\tdevice=<device-path>\n"
"\tspeed=<speed-hz>\n"
- "\tlatency"
+ "\tlatency\n"
+ "\tioctl_n=<set to non-zero to use SPI_RTIOC_TRANSFER_N ioctl>"
);
#define ONE_BILLION 1000000000
#define TEN_MILLIONS 10000000
-static int with_traffic = 1, with_latency;
+static int with_traffic = 1, with_latency, with_ioctl_n = 0;
#define SEQ_SHIFT 24
#define SEQ_MASK ((1 << SEQ_SHIFT) - 1)
@@ -311,8 +313,16 @@ static int do_spi_loop(int fd)
if (ret < 0)
break;
clock_gettime(CLOCK_MONOTONIC, &start);
- if (!__Terrno(ret, ioctl(fd, SPI_RTIOC_TRANSFER)))
- return ret;
+ if(with_ioctl_n == 0) {
+ if (!__Terrno(ret,
+ ioctl(fd, SPI_RTIOC_TRANSFER)))
+ return ret;
+ } else {
+ if (!__Terrno(ret,
+ ioctl(fd, SPI_RTIOC_TRANSFER_N,
+ TRANSFER_SIZE)))
+ return ret;
+ }
if (with_latency) {
clock_gettime(CLOCK_MONOTONIC, &now);
dt = (int32_t)diff_ts(&now, &start);
@@ -348,7 +358,7 @@ static int do_spi_loop(int fd)
static int run_spi_transfer(struct smokey_test *t, int argc, char
*const argv[])
{
- int fd, ret, speed_hz = 60000000;
+ int fd, ret, speed_hz = 40000000;
struct rtdm_spi_config config;
struct rtdm_spi_iobufs iobufs;
const char *device = NULL;
@@ -366,7 +376,12 @@ static int run_spi_transfer(struct smokey_test
*t, int argc, char *const argv[])
if (SMOKEY_ARG_ISSET(spi_transfer, speed))
speed_hz = SMOKEY_ARG_INT(spi_transfer, speed);
-
+
+ if (SMOKEY_ARG_ISSET(spi_transfer, ioctl_n)) {
+ with_ioctl_n = SMOKEY_ARG_INT(spi_transfer, ioctl_n);
+ smokey_note("ioctl_n enabled; using SPI_RTIOC_TRANSFER_N");
+ }
+
if (!SMOKEY_ARG_ISSET(spi_transfer, device)) {
warning("missing device= specification");
return -EINVAL;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 5/5] extending spitest with SPI_RTIOC_TRANSFER_N ioctl
2020-01-14 16:23 [PATCH 5/5] extending spitest with SPI_RTIOC_TRANSFER_N ioctl Laurentiu-Cristian Duca
@ 2020-01-14 17:30 ` Jan Kiszka
0 siblings, 0 replies; 2+ messages in thread
From: Jan Kiszka @ 2020-01-14 17:30 UTC (permalink / raw)
To: Laurentiu-Cristian Duca, xenomai
On 14.01.20 17:23, Laurentiu-Cristian Duca via Xenomai wrote:
> From: Laurentiu-Cristian Duca <laurentiu.duca@gmail.com>
>
> The ioctl_n user parameter must be set to non-zero value
> in order to perform ioctl(SPI_RTIOC_TRANSFER_N, TRANSFER_SIZE);
> if ioctl_n is 0 or undefined then the test performs ioctl(SPI_RTIOC_TRANSFER).
> Default SPI clock speed is set to 40MHz instead of 60MHz
> because bbb am335x realtime SPI driver has its maximum set to this value.
>
> Signed-off-by: Laurentiu-Cristian Duca <laurentiu.duca@gmail.com>
> ---
> testsuite/spitest/spitest.c | 27 +++++++++++++++++++++------
> 1 file changed, 21 insertions(+), 6 deletions(-)
>
> diff --git a/testsuite/spitest/spitest.c b/testsuite/spitest/spitest.c
> index debf1b673..e3a1c6a44 100644
> --- a/testsuite/spitest/spitest.c
> +++ b/testsuite/spitest/spitest.c
> @@ -40,17 +40,19 @@ smokey_test_plugin(spi_transfer,
> SMOKEY_STRING(device),
> SMOKEY_INT(speed),
> SMOKEY_BOOL(latency),
> + SMOKEY_INT(ioctl_n)
> ),
> "Run a SPI transfer.\n"
> "\tdevice=<device-path>\n"
> "\tspeed=<speed-hz>\n"
> - "\tlatency"
> + "\tlatency\n"
> + "\tioctl_n=<set to non-zero to use SPI_RTIOC_TRANSFER_N ioctl>"
> );
>
> #define ONE_BILLION 1000000000
> #define TEN_MILLIONS 10000000
>
> -static int with_traffic = 1, with_latency;
> +static int with_traffic = 1, with_latency, with_ioctl_n = 0;
>
> #define SEQ_SHIFT 24
> #define SEQ_MASK ((1 << SEQ_SHIFT) - 1)
> @@ -311,8 +313,16 @@ static int do_spi_loop(int fd)
> if (ret < 0)
> break;
> clock_gettime(CLOCK_MONOTONIC, &start);
> - if (!__Terrno(ret, ioctl(fd, SPI_RTIOC_TRANSFER)))
> - return ret;
> + if(with_ioctl_n == 0) {
> + if (!__Terrno(ret,
> + ioctl(fd, SPI_RTIOC_TRANSFER)))
> + return ret;
> + } else {
> + if (!__Terrno(ret,
> + ioctl(fd, SPI_RTIOC_TRANSFER_N,
> + TRANSFER_SIZE)))
> + return ret;
> + }
> if (with_latency) {
> clock_gettime(CLOCK_MONOTONIC, &now);
> dt = (int32_t)diff_ts(&now, &start);
> @@ -348,7 +358,7 @@ static int do_spi_loop(int fd)
>
> static int run_spi_transfer(struct smokey_test *t, int argc, char
> *const argv[])
> {
> - int fd, ret, speed_hz = 60000000;
> + int fd, ret, speed_hz = 40000000;
> struct rtdm_spi_config config;
> struct rtdm_spi_iobufs iobufs;
> const char *device = NULL;
> @@ -366,7 +376,12 @@ static int run_spi_transfer(struct smokey_test
> *t, int argc, char *const argv[])
>
> if (SMOKEY_ARG_ISSET(spi_transfer, speed))
> speed_hz = SMOKEY_ARG_INT(spi_transfer, speed);
> -
> +
> + if (SMOKEY_ARG_ISSET(spi_transfer, ioctl_n)) {
> + with_ioctl_n = SMOKEY_ARG_INT(spi_transfer, ioctl_n);
> + smokey_note("ioctl_n enabled; using SPI_RTIOC_TRANSFER_N");
> + }
> +
> if (!SMOKEY_ARG_ISSET(spi_transfer, device)) {
> warning("missing device= specification");
> return -EINVAL;
>
Thanks, applied all to next - with some individual massaging.
Line-wrapping seems to have been enabled while sending the patches. git
send-email is recommended if your mail client does not permit proper
control.
Jan
--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-01-14 17:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14 16:23 [PATCH 5/5] extending spitest with SPI_RTIOC_TRANSFER_N ioctl Laurentiu-Cristian Duca
2020-01-14 17:30 ` Jan Kiszka
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.