xref: /netbsd-src/sys/arch/arm/imx/imxspivar.h (revision 9e55e6308e1e0e92733b91f619df3fb5c9114240)
1*9e55e630Shkenken /*	$NetBSD: imxspivar.h,v 1.3 2019/09/27 02:59:21 hkenken Exp $	*/
25f3c2fa2Shkenken 
35f3c2fa2Shkenken /*
45f3c2fa2Shkenken  * Copyright (c) 2014  Genetec Corporation.  All rights reserved.
55f3c2fa2Shkenken  * Written by Hashimoto Kenichi for Genetec Corporation.
65f3c2fa2Shkenken  *
75f3c2fa2Shkenken  * Redistribution and use in source and binary forms, with or without
85f3c2fa2Shkenken  * modification, are permitted provided that the following conditions
95f3c2fa2Shkenken  * are met:
105f3c2fa2Shkenken  * 1. Redistributions of source code must retain the above copyright
115f3c2fa2Shkenken  *    notice, this list of conditions and the following disclaimer.
125f3c2fa2Shkenken  * 2. Redistributions in binary form must reproduce the above copyright
135f3c2fa2Shkenken  *    notice, this list of conditions and the following disclaimer in the
145f3c2fa2Shkenken  *    documentation and/or other materials provided with the distribution.
155f3c2fa2Shkenken  *
165f3c2fa2Shkenken  * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
175f3c2fa2Shkenken  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
185f3c2fa2Shkenken  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
195f3c2fa2Shkenken  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
205f3c2fa2Shkenken  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
215f3c2fa2Shkenken  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
225f3c2fa2Shkenken  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
235f3c2fa2Shkenken  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
245f3c2fa2Shkenken  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
255f3c2fa2Shkenken  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
265f3c2fa2Shkenken  * POSSIBILITY OF SUCH DAMAGE.
275f3c2fa2Shkenken  */
285f3c2fa2Shkenken 
295f3c2fa2Shkenken #ifndef	_ARM_IMX_IMXSPIVAR_H_
305f3c2fa2Shkenken #define	_ARM_IMX_IMXSPIVAR_H_
315f3c2fa2Shkenken 
325f3c2fa2Shkenken #include <dev/spi/spivar.h>
335f3c2fa2Shkenken 
345f3c2fa2Shkenken typedef struct spi_chipset_tag {
355f3c2fa2Shkenken 	void *cookie;
365f3c2fa2Shkenken 
375f3c2fa2Shkenken 	int (*spi_cs_enable)(void *, int);
385f3c2fa2Shkenken 	int (*spi_cs_disable)(void *, int);
395f3c2fa2Shkenken } *spi_chipset_tag_t;
405f3c2fa2Shkenken 
41*9e55e630Shkenken enum imxspi_type {
42*9e55e630Shkenken 	IMX31_CSPI,
43*9e55e630Shkenken 	IMX35_CSPI,
44*9e55e630Shkenken 	IMX51_ECSPI,
45*9e55e630Shkenken };
46*9e55e630Shkenken 
475f3c2fa2Shkenken struct imxspi_softc {
485f3c2fa2Shkenken 	device_t sc_dev;
49b68d413bShkenken 	int sc_phandle;
50b68d413bShkenken 
515f3c2fa2Shkenken 	bus_space_tag_t  sc_iot;
525f3c2fa2Shkenken 	bus_space_handle_t sc_ioh;
535f3c2fa2Shkenken 	spi_chipset_tag_t sc_tag;
545f3c2fa2Shkenken 
555f3c2fa2Shkenken 	struct spi_controller sc_spi;
565f3c2fa2Shkenken 	unsigned long sc_freq;
575f3c2fa2Shkenken 	struct spi_chunk *sc_wchunk;
585f3c2fa2Shkenken 	struct spi_chunk *sc_rchunk;
595f3c2fa2Shkenken 	void *sc_ih;
605f3c2fa2Shkenken 	struct spi_transfer *sc_transfer;
615f3c2fa2Shkenken 	bool  sc_running;
625f3c2fa2Shkenken 	SIMPLEQ_HEAD(,spi_transfer) sc_q;
635f3c2fa2Shkenken 
64b68d413bShkenken 	int sc_nslaves;
655f3c2fa2Shkenken 	int sc_enhanced;
66*9e55e630Shkenken 	enum imxspi_type sc_type;
675f3c2fa2Shkenken };
685f3c2fa2Shkenken 
69b68d413bShkenken int imxspi_attach_common(device_t);
70b68d413bShkenken int imxspi_intr(void *);
715f3c2fa2Shkenken 
725f3c2fa2Shkenken /*
735f3c2fa2Shkenken  * defined in machine dependent code
745f3c2fa2Shkenken  */
755f3c2fa2Shkenken int imxspi_match(device_t, cfdata_t, void *);
765f3c2fa2Shkenken void imxspi_attach(device_t, device_t, void *);
775f3c2fa2Shkenken 
785f3c2fa2Shkenken #endif	/* _ARM_IMX_IMXSPIVAR_H_ */
79