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