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