spi_calls revision 1.2
1$NetBSD: spi_calls,v 1.2 2025/09/14 16:00:04 thorpej Exp $
2
3/*-
4 * Copyright (c) 2021 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32/*
33 * Device calls used by the SPI subsystem.
34 */
35
36subsystem spi;
37
38#include <dev/spi/spivar.h>
39
40/*
41 * spi-enumerate-devices
42 *
43 * Enumerates the devices connected to the SPI bus, filling out
44 * the spi_attach_args and invoking the callback for each one.
45 * The caller provides the storage for the spi_attach_args.  Because
46 * the chip select is not exposed to SPI drivers in spi_attach_args,
47 * the chip select provided by the enumeration is captured in the
48 * arguments passed to the callback.
49 *
50 * If the callback returns true, then enumeration continues.  If
51 * the callback returns false, enumeration is stopped.
52 *
53 * Call returns 0 if successful, or an error code upon failure:
54 *
55 * ENOTSUP	The device handle implementation for the
56 *		SPI bus does not support this device call.
57 */
58spi-enumerate-devices {
59	struct spi_attach_args *sa;	/* IN */
60	bool (*callback)(device_t, struct spi_enumerate_devices_args *);
61	int chip_select;		/* OUT */
62};
63
64/*
65 * spi-get-transfer-mode
66 *
67 * Gets the transfer mode associated with the specified device handle
68 * from the device tree.
69 *
70 * Call returns 0 if successful, or an error code upon failure:
71 *
72 * ENOTSUP	The device handle implementation for the
73 *		SPI bus does not support this device call.
74 *
75 * EINVAL	The transfer mode information associated with the
76 *		device handle is invalid.
77 */
78spi-get-transfer-mode {
79	unsigned int mode;		/* OUT */
80	unsigned int max_frequency;	/* OUT */
81	unsigned int flags;		/* OUT */
82	unsigned int cs_setup_delay_ns;	/* OUT */
83	unsigned int cs_hold_delay_ns;	/* OUT */
84	unsigned int cs_inact_delay_ns;	/* OUT */
85	unsigned int rx_bus_width;	/* OUT */
86	unsigned int rx_delay_us;	/* OUT */
87	unsigned int rx_sample_delay_ns;/* OUT */
88	unsigned int tx_bus_width;	/* OUT */
89	unsigned int tx_delay_us;	/* OUT */
90};
91