xref: /freebsd/sys/dev/mmc/bridge.h (revision f856af0466c076beef4ea9b15d088e1119a945b8)
1 /*-
2  * Copyright (c) 2006 M. Warner Losh.  All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  * $FreeBSD$
25  */
26 
27 #ifndef DEV_MMC_BRIDGE_H
28 #define DEV_MMC_BRIDGE_H
29 
30 /*
31  * This file defines interfaces for the mmc bridge.  The names chosen
32  * are similar to or the same as the names used in Linux to allow for
33  * easy porting of what Linux calls mmc host drivers.  I use the
34  * FreeBSD terminology of bridge and bus for consistancy with other
35  * drivers in the system.  This file corresponds roughly to the Linux
36  * linux/mmc/host.h file.
37  *
38  * A mmc bridge is a chipset that can have one or more mmc and/or sd
39  * cards attached to it.  mmc cards are attached on a bus topology,
40  * while sd and sdio cards are attached using a star topology (meaning
41  * in practice each sd card has its own, independent slot).  Each
42  * mmcbr is assumed to be derived from the mmcbr.  This is done to
43  * allow for easier addition of bridges (as each bridge does not need
44  * to be added to the mmcbus file).
45  *
46  * Attached to the mmc bridge is an mmcbus.  The mmcbus is described
47  * in dev/mmc/bus.h.
48  */
49 
50 
51 /*
52  * mmc_ios is a structure that is used to store the state of the mmc/sd
53  * bus configuration.  This include the bus' clock speed, its voltage,
54  * the bus mode for command output, the SPI chip select, some power
55  * states and the bus width.
56  */
57 enum mmc_vdd {
58 	vdd_150 = 0, vdd_155, vdd_160, vdd_165, vdd_170, vdd_180,
59 	vdd_190, vdd_200, vdd_210, vdd_220, vdd_230, vdd_240, vdd_250,
60 	vdd_260, vdd_270, vdd_280, vdd_290, vdd_300, vdd_310, vdd_320,
61 	vdd_330, vdd_340, vdd_350, vdd_360
62 };
63 
64 enum mmc_power_mode {
65 	power_off = 0, power_up, power_on
66 };
67 
68 enum mmc_bus_mode {
69 	opendrain = 1, pushpull
70 };
71 
72 enum mmc_chip_select {
73 	cs_dontcare = 0, cs_high, cs_low
74 };
75 
76 enum mmc_bus_width {
77 	bus_width_1 = 0, bus_width_4 = 2, bus_width_8 = 3
78 };
79 
80 struct mmc_ios {
81 	uint32_t	clock;	/* Speed of the clock in Hz to move data */
82 	enum mmc_vdd	vdd;	/* Voltage to apply to the power pins/ */
83 	enum mmc_bus_mode bus_mode;
84 	enum mmc_chip_select chip_select;
85 	enum mmc_bus_width bus_width;
86 	enum mmc_power_mode power_mode;
87 };
88 
89 enum mmc_card_mode {
90 	mode_mmc, mode_sd
91 };
92 
93 struct mmc_host {
94 	int f_min;
95 	int f_max;
96 	uint32_t host_ocr;
97 	uint32_t ocr;
98 	uint32_t caps;
99 #define MMC_CAP_4_BIT_DATA	(1 << 0) /* Can do 4-bit data transfers */
100 #define MMC_CAP_8_BIT_DATA	(1 << 1) /* Can do 8-bit data transfers */
101 	enum mmc_card_mode mode;
102 	struct mmc_ios ios;	/* Current state of the host */
103 };
104 
105 #endif /* DEV_MMC_BRIDGE_H */
106