xref: /freebsd/sys/dev/spibus/spi.h (revision 62aa7ab939ea0f9187336ea5f91b954da0cbd4c7)
146b39c90SWarner Losh /*-
2f86e6000SWarner Losh  * Copyright (c) 2006 M. Warner Losh <imp@FreeBSD.org>
346b39c90SWarner Losh  *
446b39c90SWarner Losh  * Redistribution and use in source and binary forms, with or without
546b39c90SWarner Losh  * modification, are permitted provided that the following conditions
646b39c90SWarner Losh  * are met:
746b39c90SWarner Losh  * 1. Redistributions of source code must retain the above copyright
846b39c90SWarner Losh  *    notice, this list of conditions and the following disclaimer.
946b39c90SWarner Losh  * 2. Redistributions in binary form must reproduce the above copyright
1046b39c90SWarner Losh  *    notice, this list of conditions and the following disclaimer in the
1146b39c90SWarner Losh  *    documentation and/or other materials provided with the distribution.
1246b39c90SWarner Losh  *
1346b39c90SWarner Losh  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1446b39c90SWarner Losh  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1546b39c90SWarner Losh  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1646b39c90SWarner Losh  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1746b39c90SWarner Losh  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1846b39c90SWarner Losh  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1946b39c90SWarner Losh  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2046b39c90SWarner Losh  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2146b39c90SWarner Losh  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2246b39c90SWarner Losh  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2346b39c90SWarner Losh  * SUCH DAMAGE.
2446b39c90SWarner Losh  */
259a795dfaSWarner Losh 
269a795dfaSWarner Losh struct spi_command {
279a795dfaSWarner Losh 	void	*tx_cmd;
289a795dfaSWarner Losh 	uint32_t tx_cmd_sz;
299a795dfaSWarner Losh 	void	*rx_cmd;
309a795dfaSWarner Losh 	uint32_t rx_cmd_sz;
319a795dfaSWarner Losh 	void	*tx_data;
329a795dfaSWarner Losh 	uint32_t tx_data_sz;
339a795dfaSWarner Losh 	void	*rx_data;
349a795dfaSWarner Losh 	uint32_t rx_data_sz;
353c086734SVal Packett 	uint32_t flags;
369a795dfaSWarner Losh };
37d67fe28bSAdrian Chadd #define	SPI_COMMAND_INITIALIZER	{ 0 }
38d67fe28bSAdrian Chadd 
393c086734SVal Packett #define	SPI_FLAG_KEEP_CS	0x1		/* Keep chip select asserted */
403c086734SVal Packett #define	SPI_FLAG_NO_SLEEP	0x2		/* Prevent driver from sleeping (use polling) */
413c086734SVal Packett 
42cc906398SWarner Losh #define	SPI_CHIP_SELECT_HIGH	0x1		/* Chip select high (else low) */
4364b507e5SEmmanuel Vadot 
44db63d251SIan Lepore #ifdef FDT
45db63d251SIan Lepore #define	SPIBUS_FDT_PNP_INFO(t)	FDTCOMPAT_PNP_INFO(t, spibus)
46db63d251SIan Lepore #else
47db63d251SIan Lepore #define	SPIBUS_FDT_PNP_INFO(t)
48db63d251SIan Lepore #endif
49*62aa7ab9SVladimir Kondratyev 
50*62aa7ab9SVladimir Kondratyev #ifdef DEV_ACPI
51*62aa7ab9SVladimir Kondratyev #define	SPIBUS_ACPI_PNP_INFO(t)	ACPICOMPAT_PNP_INFO(t, spibus)
52*62aa7ab9SVladimir Kondratyev #else
53*62aa7ab9SVladimir Kondratyev #define	SPIBUS_ACPI_PNP_INFO(t)
54*62aa7ab9SVladimir Kondratyev #endif
55