Home | History | Annotate | Line # | Download | only in at91
      1 /* $NetBSD: at91spivar.h,v 1.2 2008/07/03 01:15:38 matt Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2007 Embedtronics Oy.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or
      8  * without modification, are permitted provided that the following
      9  * conditions are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above
     13  *    copyright notice, this list of conditions and the following
     14  *    disclaimer in the documentation and/or other materials provided
     15  *    with the distribution.
     16  * 3. All advertising materials mentioning features or use of this
     17  *    software must display the following acknowledgements:
     18  *      This product includes software developed by the Urbana-Champaign
     19  *      Independent Media Center.
     20  *	This product includes software developed by Garrett D'Amore.
     21  * 4. Urbana-Champaign Independent Media Center's name and Garrett
     22  *    D'Amore's name may not be used to endorse or promote products
     23  *    derived from this software without specific prior written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY THE URBANA-CHAMPAIGN INDEPENDENT
     26  * MEDIA CENTER AND GARRETT D'AMORE ``AS IS'' AND ANY EXPRESS OR
     27  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     28  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT
     30  * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT,
     31  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     32  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     33  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     34  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     35  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     37  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     38  */
     39 
     40 #ifndef	_AT91SPIVAR_H_
     41 #define	_AT91SPIVAR_H_
     42 
     43 #include <dev/spi/spivar.h>
     44 
     45 struct at91spi_machdep {
     46 	int		(*select_slave)(void *self, int);
     47 };
     48 
     49 typedef	const struct at91spi_machdep *at91spi_machdep_tag_t;
     50 
     51 struct at91spi_softc {
     52 	device_t		sc_dev;
     53 	bus_space_tag_t		sc_iot;
     54 	bus_space_handle_t	sc_ioh;
     55 
     56 	bus_dma_tag_t		sc_dmat;
     57 
     58 	int			sc_pid;		/* peripheral identifier */
     59 	struct spi_controller	sc_spi;		/* SPI implementation ops */
     60 	at91spi_machdep_tag_t	sc_md;		/* board-specific support */
     61 	struct at91spi_job	*sc_job;	/* current job */
     62 	struct spi_chunk	*sc_wchunk;
     63 	struct spi_chunk	*sc_rchunk;
     64 	void			*sc_ih;		/* interrupt handler (what?) */
     65 
     66 	void			*sc_dmapage;
     67 	bus_addr_t		sc_dmaaddr;
     68 	bus_dmamap_t		sc_dmamap;
     69 	int			sc_dmaoffs;	/* current dma offset	*/
     70 
     71 	struct spi_transfer	*sc_transfer;
     72 	bool			sc_running;	/* is it processing stuff? */
     73 
     74 	SIMPLEQ_HEAD(,spi_transfer)	sc_q;
     75 };
     76 
     77 void at91spi_attach_common(device_t parent, device_t self, void *aux,
     78 			    at91spi_machdep_tag_t md);
     79 
     80 #endif	/* _AT91SPIVAR_H_ */
     81