sdmmcchip.h revision 1.1.4.3 1 1.1.4.3 yamt /* $NetBSD: sdmmcchip.h,v 1.1.4.3 2010/08/11 22:54:11 yamt Exp $ */
2 1.1.4.2 yamt /* $OpenBSD: sdmmcchip.h,v 1.3 2007/05/31 10:09:01 uwe Exp $ */
3 1.1.4.2 yamt
4 1.1.4.2 yamt /*
5 1.1.4.2 yamt * Copyright (c) 2006 Uwe Stuehler <uwe (at) openbsd.org>
6 1.1.4.2 yamt *
7 1.1.4.2 yamt * Permission to use, copy, modify, and distribute this software for any
8 1.1.4.2 yamt * purpose with or without fee is hereby granted, provided that the above
9 1.1.4.2 yamt * copyright notice and this permission notice appear in all copies.
10 1.1.4.2 yamt *
11 1.1.4.2 yamt * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 1.1.4.2 yamt * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 1.1.4.2 yamt * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 1.1.4.2 yamt * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 1.1.4.2 yamt * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 1.1.4.2 yamt * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 1.1.4.2 yamt * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 1.1.4.2 yamt */
19 1.1.4.2 yamt
20 1.1.4.2 yamt #ifndef _SDMMC_CHIP_H_
21 1.1.4.2 yamt #define _SDMMC_CHIP_H_
22 1.1.4.2 yamt
23 1.1.4.2 yamt #include <sys/device.h>
24 1.1.4.2 yamt
25 1.1.4.2 yamt #include <machine/bus.h>
26 1.1.4.2 yamt
27 1.1.4.2 yamt struct sdmmc_command;
28 1.1.4.2 yamt
29 1.1.4.2 yamt typedef struct sdmmc_chip_functions *sdmmc_chipset_tag_t;
30 1.1.4.3 yamt typedef struct sdmmc_spi_chip_functions *sdmmc_spi_chipset_tag_t;
31 1.1.4.2 yamt typedef void *sdmmc_chipset_handle_t;
32 1.1.4.2 yamt
33 1.1.4.2 yamt struct sdmmc_chip_functions {
34 1.1.4.2 yamt /* host controller reset */
35 1.1.4.2 yamt int (*host_reset)(sdmmc_chipset_handle_t);
36 1.1.4.2 yamt
37 1.1.4.2 yamt /* host capabilities */
38 1.1.4.2 yamt uint32_t (*host_ocr)(sdmmc_chipset_handle_t);
39 1.1.4.2 yamt int (*host_maxblklen)(sdmmc_chipset_handle_t);
40 1.1.4.2 yamt
41 1.1.4.2 yamt /* card detection */
42 1.1.4.2 yamt int (*card_detect)(sdmmc_chipset_handle_t);
43 1.1.4.2 yamt
44 1.1.4.2 yamt /* write protect */
45 1.1.4.2 yamt int (*write_protect)(sdmmc_chipset_handle_t);
46 1.1.4.2 yamt
47 1.1.4.2 yamt /* bus power, clock frequency and width */
48 1.1.4.2 yamt int (*bus_power)(sdmmc_chipset_handle_t, uint32_t);
49 1.1.4.2 yamt int (*bus_clock)(sdmmc_chipset_handle_t, int);
50 1.1.4.2 yamt int (*bus_width)(sdmmc_chipset_handle_t, int);
51 1.1.4.2 yamt
52 1.1.4.2 yamt /* command execution */
53 1.1.4.2 yamt void (*exec_command)(sdmmc_chipset_handle_t,
54 1.1.4.2 yamt struct sdmmc_command *);
55 1.1.4.2 yamt
56 1.1.4.2 yamt /* card interrupt */
57 1.1.4.2 yamt void (*card_enable_intr)(sdmmc_chipset_handle_t, int);
58 1.1.4.2 yamt void (*card_intr_ack)(sdmmc_chipset_handle_t);
59 1.1.4.2 yamt };
60 1.1.4.2 yamt
61 1.1.4.2 yamt /* host controller reset */
62 1.1.4.2 yamt #define sdmmc_chip_host_reset(tag, handle) \
63 1.1.4.2 yamt ((tag)->host_reset((handle)))
64 1.1.4.2 yamt /* host capabilities */
65 1.1.4.2 yamt #define sdmmc_chip_host_ocr(tag, handle) \
66 1.1.4.2 yamt ((tag)->host_ocr((handle)))
67 1.1.4.2 yamt #define sdmmc_chip_host_maxblklen(tag, handle) \
68 1.1.4.2 yamt ((tag)->host_maxblklen((handle)))
69 1.1.4.2 yamt /* card detection */
70 1.1.4.2 yamt #define sdmmc_chip_card_detect(tag, handle) \
71 1.1.4.2 yamt ((tag)->card_detect((handle)))
72 1.1.4.2 yamt /* write protect */
73 1.1.4.2 yamt #define sdmmc_chip_write_protect(tag, handle) \
74 1.1.4.2 yamt ((tag)->write_protect((handle)))
75 1.1.4.2 yamt /* bus power, clock frequency and width */
76 1.1.4.2 yamt #define sdmmc_chip_bus_power(tag, handle, ocr) \
77 1.1.4.2 yamt ((tag)->bus_power((handle), (ocr)))
78 1.1.4.2 yamt #define sdmmc_chip_bus_clock(tag, handle, freq) \
79 1.1.4.2 yamt ((tag)->bus_clock((handle), (freq)))
80 1.1.4.2 yamt #define sdmmc_chip_bus_width(tag, handle, width) \
81 1.1.4.2 yamt ((tag)->bus_width((handle), (width)))
82 1.1.4.2 yamt /* command execution */
83 1.1.4.2 yamt #define sdmmc_chip_exec_command(tag, handle, cmdp) \
84 1.1.4.2 yamt ((tag)->exec_command((handle), (cmdp)))
85 1.1.4.2 yamt /* card interrupt */
86 1.1.4.2 yamt #define sdmmc_chip_card_enable_intr(tag, handle, enable) \
87 1.1.4.2 yamt ((tag)->card_enable_intr((handle), (enable)))
88 1.1.4.2 yamt #define sdmmc_chip_card_intr_ack(tag, handle) \
89 1.1.4.2 yamt ((tag)->card_intr_ack((handle)))
90 1.1.4.2 yamt
91 1.1.4.2 yamt /* clock frequencies for sdmmc_chip_bus_clock() */
92 1.1.4.2 yamt #define SDMMC_SDCLK_OFF 0
93 1.1.4.2 yamt #define SDMMC_SDCLK_400K 400
94 1.1.4.2 yamt
95 1.1.4.3 yamt /* SPI mode */
96 1.1.4.3 yamt struct sdmmc_spi_chip_functions {
97 1.1.4.3 yamt /* card initialize */
98 1.1.4.3 yamt void (*initialize)(sdmmc_chipset_handle_t);
99 1.1.4.3 yamt };
100 1.1.4.3 yamt #define sdmmc_spi_chip_initialize(tag, handle) \
101 1.1.4.3 yamt ((tag)->initialize((handle)))
102 1.1.4.3 yamt
103 1.1.4.2 yamt struct sdmmcbus_attach_args {
104 1.1.4.2 yamt const char *saa_busname;
105 1.1.4.2 yamt sdmmc_chipset_tag_t saa_sct;
106 1.1.4.3 yamt sdmmc_spi_chipset_tag_t saa_spi_sct;
107 1.1.4.2 yamt sdmmc_chipset_handle_t saa_sch;
108 1.1.4.2 yamt bus_dma_tag_t saa_dmat;
109 1.1.4.2 yamt u_int saa_clkmin;
110 1.1.4.2 yamt u_int saa_clkmax;
111 1.1.4.2 yamt uint32_t saa_caps; /* see sdmmc_softc.sc_caps */
112 1.1.4.2 yamt };
113 1.1.4.2 yamt
114 1.1.4.2 yamt void sdmmc_needs_discover(device_t);
115 1.1.4.2 yamt void sdmmc_card_intr(device_t);
116 1.1.4.2 yamt void sdmmc_delay(u_int);
117 1.1.4.2 yamt
118 1.1.4.2 yamt #endif /* _SDMMC_CHIP_H_ */
119