linux/drivers/spi/spi-test.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 *  linux/drivers/spi/spi-test.h
 *
 *  (c) Martin Sperl <[email protected]>
 *
 *  spi_test definitions
 */

#include <linux/spi/spi.h>

#define SPI_TEST_MAX_TRANSFERS
#define SPI_TEST_MAX_SIZE
#define SPI_TEST_MAX_ITERATE

/* the "dummy" start addresses used in spi_test
 * these addresses get translated at a later stage
 */
#define RX_START
#define TX_START
#define RX(off)
#define TX(off)

/* some special defines for offsets */
#define SPI_TEST_MAX_SIZE_HALF

/* detection pattern for unfinished reads...
 * - 0x00 or 0xff could be valid levels for tx_buf = NULL,
 * so we do not use either of them
 */
#define SPI_TEST_PATTERN_UNWRITTEN
#define SPI_TEST_PATTERN_DO_NOT_WRITE
#define SPI_TEST_CHECK_DO_NOT_WRITE

/**
 * struct spi_test - describes a specific (set of) tests to execute
 *
 * @description:      description of the test
 *
 * @msg:              a template @spi_message usedfor the default settings
 * @transfers:        array of @spi_transfers that are part of the
 *                    resulting spi_message.
 * @transfer_count:   number of transfers
 *
 * @run_test:         run a specific spi_test - this allows to override
 *                    the default implementation of @spi_test_run_transfer
 *                    either to add some custom filters for a specific test
 *                    or to effectively run some very custom tests...
 * @execute_msg:      run the spi_message for real - this allows to override
 *                    @spi_test_execute_msg to apply final modifications
 *                    on the spi_message
 * @expected_return:  the expected return code - in some cases we want to
 *                    test also for error conditions
 *
 * @iterate_len:      list of length to iterate on
 * @iterate_tx_align: change the alignment of @spi_transfer.tx_buf
 *                    for all values in the below range if set.
 *                    the ranges are:
 *                    [0 : @spi_master.dma_alignment[ if set
 *                    [0 : iterate_tx_align[ if unset
 * @iterate_rx_align: change the alignment of @spi_transfer.rx_buf
 *                    see @iterate_tx_align for details
 * @iterate_transfer_mask: the bitmask of transfers to which the iterations
 *                         apply - if 0, then it applies to all transfer
 *
 * @fill_option:      define the way how tx_buf is filled
 * @fill_pattern:     fill pattern to apply to the tx_buf
 *                    (used in some of the @fill_options)
 * @elapsed_time:     elapsed time in nanoseconds
 */

struct spi_test {};

/* default implementation for @spi_test.run_test */
int spi_test_run_test(struct spi_device *spi,
		      const struct spi_test *test,
		      void *tx, void *rx);

/* default implementation for @spi_test.execute_msg */
int spi_test_execute_msg(struct spi_device *spi,
			 struct spi_test *test,
			 void *tx, void *rx);

/* function to execute a set of tests */
int spi_test_run_tests(struct spi_device *spi,
		       struct spi_test *tests);

#define ITERATE_LEN_LIST
/* some of the default @spi_transfer.len to test, terminated by a -1 */
#define ITERATE_LEN
#define ITERATE_MAX_LEN

/* the default alignment to test */
#define ITERATE_ALIGN