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