Home | History | Annotate | Line # | Download | only in ic
rtsxvar.h revision 1.1.8.1
      1  1.1.8.1  martin /*	$NetBSD: rtsxvar.h,v 1.1.8.1 2015/01/17 13:44:47 martin Exp $	*/
      2  1.1.8.1  martin /*	$OpenBSD: rtsxvar.h,v 1.3 2014/08/19 17:55:03 phessler Exp $	*/
      3      1.1  nonaka 
      4      1.1  nonaka /*
      5      1.1  nonaka  * Copyright (c) 2006 Uwe Stuehler <uwe (at) openbsd.org>
      6      1.1  nonaka  * Copyright (c) 2012 Stefan Sperling <stsp (at) openbsd.org>
      7      1.1  nonaka  *
      8      1.1  nonaka  * Permission to use, copy, modify, and distribute this software for any
      9      1.1  nonaka  * purpose with or without fee is hereby granted, provided that the above
     10      1.1  nonaka  * copyright notice and this permission notice appear in all copies.
     11      1.1  nonaka  *
     12      1.1  nonaka  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     13      1.1  nonaka  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     14      1.1  nonaka  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     15      1.1  nonaka  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     16      1.1  nonaka  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     17      1.1  nonaka  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     18      1.1  nonaka  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     19      1.1  nonaka  */
     20      1.1  nonaka 
     21      1.1  nonaka #ifndef _RTSXVAR_H_
     22      1.1  nonaka #define _RTSXVAR_H_
     23      1.1  nonaka 
     24      1.1  nonaka #include <sys/bus.h>
     25      1.1  nonaka #include <sys/device.h>
     26      1.1  nonaka #include <sys/pmf.h>
     27      1.1  nonaka #include <sys/mutex.h>
     28      1.1  nonaka #include <sys/condvar.h>
     29      1.1  nonaka 
     30      1.1  nonaka /* Number of registers to save for suspend/resume in terms of their ranges. */
     31      1.1  nonaka #define RTSX_NREG ((0XFDAE - 0XFDA0) + (0xFD69 - 0xFD32) + (0xFE34 - 0xFE20))
     32      1.1  nonaka 
     33      1.1  nonaka struct rtsx_softc {
     34      1.1  nonaka 	device_t	sc_dev;
     35      1.1  nonaka 
     36      1.1  nonaka 	device_t	sc_sdmmc;	/* generic SD/MMC device */
     37      1.1  nonaka 
     38      1.1  nonaka 	bus_space_tag_t	sc_iot;		/* host register set tag */
     39      1.1  nonaka 	bus_space_handle_t sc_ioh;	/* host register set handle */
     40      1.1  nonaka 	bus_size_t      sc_iosize;
     41      1.1  nonaka 	bus_dma_tag_t	sc_dmat;	/* DMA tag from attachment driver */
     42      1.1  nonaka 	bus_dmamap_t	sc_dmap_cmd;	/* DMA map for command transfer */
     43      1.1  nonaka 
     44      1.1  nonaka 	struct kmutex	sc_host_mtx;
     45      1.1  nonaka 	struct kmutex	sc_intr_mtx;
     46      1.1  nonaka 	struct kcondvar sc_intr_cv;
     47      1.1  nonaka 
     48      1.1  nonaka 	uint32_t 	sc_intr_status;	/* soft interrupt status */
     49      1.1  nonaka 
     50      1.1  nonaka 	uint8_t		sc_regs[RTSX_NREG]; /* host controller state */
     51      1.1  nonaka 	uint32_t	sc_regs4[6];	/* host controller state */
     52      1.1  nonaka 
     53      1.1  nonaka 	uint32_t	sc_flags;
     54      1.1  nonaka #define	RTSX_F_CARD_PRESENT	__BIT(0)
     55      1.1  nonaka #define	RTSX_F_SDIO_SUPPORT	__BIT(1)
     56      1.1  nonaka #define	RTSX_F_5209		__BIT(2)
     57  1.1.8.1  martin #define	RTSX_F_5227		__BIT(3)
     58  1.1.8.1  martin #define	RTSX_F_5229		__BIT(4)
     59  1.1.8.1  martin #define	RTSX_F_5229_TYPE_C	__BIT(5)
     60  1.1.8.1  martin #define	RTSX_F_8402		__BIT(6)
     61  1.1.8.1  martin #define	RTSX_F_8411		__BIT(7)
     62  1.1.8.1  martin #define	RTSX_F_8411B		__BIT(8)
     63  1.1.8.1  martin #define	RTSX_F_8411B_QFN48	__BIT(9)
     64      1.1  nonaka };
     65      1.1  nonaka 
     66  1.1.8.1  martin #define	RTSX_IS_RTS5209(sc)	(((sc)->sc_flags & RTSX_F_5209) == RTSX_F_5209)
     67  1.1.8.1  martin #define	RTSX_IS_RTS5227(sc)	(((sc)->sc_flags & RTSX_F_5227) == RTSX_F_5227)
     68  1.1.8.1  martin #define	RTSX_IS_RTS5229(sc)	(((sc)->sc_flags & RTSX_F_5229) == RTSX_F_5229)
     69  1.1.8.1  martin #define	RTSX_IS_RTS5229_TYPE_C(sc)					\
     70  1.1.8.1  martin 	(((sc)->sc_flags & (RTSX_F_5229|RTSX_F_5229_TYPE_C)) ==		\
     71  1.1.8.1  martin 	                   (RTSX_F_5229|RTSX_F_5229_TYPE_C))
     72  1.1.8.1  martin #define	RTSX_IS_RTL8402(sc)	(((sc)->sc_flags & RTSX_F_8402) == RTSX_F_8402)
     73  1.1.8.1  martin #define	RTSX_IS_RTL8411(sc)	(((sc)->sc_flags & RTSX_F_8411) == RTSX_F_8411)
     74  1.1.8.1  martin #define	RTSX_IS_RTL8411B(sc)						\
     75  1.1.8.1  martin 	(((sc)->sc_flags & RTSX_F_8411B) == RTSX_F_8411B)
     76  1.1.8.1  martin #define	RTSX_IS_RTL8411B_QFN48(sc)					\
     77  1.1.8.1  martin 	(((sc)->sc_flags & (RTSX_F_8411B|RTSX_F_8411B_QFN48)) ==	\
     78  1.1.8.1  martin 	                   (RTSX_F_8411B|RTSX_F_8411B_QFN48))
     79  1.1.8.1  martin 
     80      1.1  nonaka /* Host controller functions called by the attachment driver. */
     81      1.1  nonaka int	rtsx_attach(struct rtsx_softc *, bus_space_tag_t,
     82      1.1  nonaka 	    bus_space_handle_t, bus_size_t, bus_dma_tag_t, int);
     83      1.1  nonaka int	rtsx_detach(struct rtsx_softc *, int);
     84      1.1  nonaka bool	rtsx_suspend(device_t, const pmf_qual_t *);
     85      1.1  nonaka bool	rtsx_resume(device_t, const pmf_qual_t *);
     86      1.1  nonaka bool	rtsx_shutdown(device_t, int);
     87      1.1  nonaka int	rtsx_intr(void *);
     88      1.1  nonaka 
     89      1.1  nonaka #endif	/* _RTSXVAR_H_ */
     90