1
2
3
4
5
6
7
8
9
10#ifndef LINUX_MMC_HOST_H
11#define LINUX_MMC_HOST_H
12
13#include <linux/leds.h>
14#include <linux/sched.h>
15
16#include <linux/mmc/core.h>
17
18struct mmc_ios {
19 unsigned int clock;
20 unsigned short vdd;
21
22
23
24 unsigned char bus_mode;
25
26#define MMC_BUSMODE_OPENDRAIN 1
27#define MMC_BUSMODE_PUSHPULL 2
28
29 unsigned char chip_select;
30
31#define MMC_CS_DONTCARE 0
32#define MMC_CS_HIGH 1
33#define MMC_CS_LOW 2
34
35 unsigned char power_mode;
36
37#define MMC_POWER_OFF 0
38#define MMC_POWER_UP 1
39#define MMC_POWER_ON 2
40
41 unsigned char bus_width;
42
43#define MMC_BUS_WIDTH_1 0
44#define MMC_BUS_WIDTH_4 2
45#define MMC_BUS_WIDTH_8 3
46
47 unsigned char timing;
48
49#define MMC_TIMING_LEGACY 0
50#define MMC_TIMING_MMC_HS 1
51#define MMC_TIMING_SD_HS 2
52};
53
54struct mmc_host_ops {
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 int (*enable)(struct mmc_host *host);
83 int (*disable)(struct mmc_host *host, int lazy);
84 void (*request)(struct mmc_host *host, struct mmc_request *req);
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105 void (*set_ios)(struct mmc_host *host, struct mmc_ios *ios);
106 int (*get_ro)(struct mmc_host *host);
107 int (*get_cd)(struct mmc_host *host);
108
109 void (*enable_sdio_irq)(struct mmc_host *host, int enable);
110};
111
112struct mmc_card;
113struct device;
114
115struct mmc_host {
116 struct device *parent;
117 struct device class_dev;
118 int index;
119 const struct mmc_host_ops *ops;
120 unsigned int f_min;
121 unsigned int f_max;
122 u32 ocr_avail;
123
124#define MMC_VDD_165_195 0x00000080
125#define MMC_VDD_20_21 0x00000100
126#define MMC_VDD_21_22 0x00000200
127#define MMC_VDD_22_23 0x00000400
128#define MMC_VDD_23_24 0x00000800
129#define MMC_VDD_24_25 0x00001000
130#define MMC_VDD_25_26 0x00002000
131#define MMC_VDD_26_27 0x00004000
132#define MMC_VDD_27_28 0x00008000
133#define MMC_VDD_28_29 0x00010000
134#define MMC_VDD_29_30 0x00020000
135#define MMC_VDD_30_31 0x00040000
136#define MMC_VDD_31_32 0x00080000
137#define MMC_VDD_32_33 0x00100000
138#define MMC_VDD_33_34 0x00200000
139#define MMC_VDD_34_35 0x00400000
140#define MMC_VDD_35_36 0x00800000
141
142 unsigned long caps;
143
144#define MMC_CAP_4_BIT_DATA (1 << 0)
145#define MMC_CAP_MMC_HIGHSPEED (1 << 1)
146#define MMC_CAP_SD_HIGHSPEED (1 << 2)
147#define MMC_CAP_SDIO_IRQ (1 << 3)
148#define MMC_CAP_SPI (1 << 4)
149#define MMC_CAP_NEEDS_POLL (1 << 5)
150#define MMC_CAP_8_BIT_DATA (1 << 6)
151#define MMC_CAP_DISABLE (1 << 7)
152#define MMC_CAP_NONREMOVABLE (1 << 8)
153#define MMC_CAP_WAIT_WHILE_BUSY (1 << 9)
154
155
156 unsigned int max_seg_size;
157 unsigned short max_hw_segs;
158 unsigned short max_phys_segs;
159 unsigned short unused;
160 unsigned int max_req_size;
161 unsigned int max_blk_size;
162 unsigned int max_blk_count;
163
164
165 spinlock_t lock;
166
167 struct mmc_ios ios;
168 u32 ocr;
169
170
171 unsigned int use_spi_crc:1;
172 unsigned int claimed:1;
173 unsigned int bus_dead:1;
174#ifdef CONFIG_MMC_DEBUG
175 unsigned int removed:1;
176#endif
177
178
179 int enabled;
180 int nesting_cnt;
181 int en_dis_recurs;
182 unsigned int disable_delay;
183 struct delayed_work disable;
184
185 struct mmc_card *card;
186
187 wait_queue_head_t wq;
188 struct task_struct *claimer;
189 int claim_cnt;
190
191 struct delayed_work detect;
192
193 const struct mmc_bus_ops *bus_ops;
194 unsigned int bus_refs;
195
196 unsigned int sdio_irqs;
197 struct task_struct *sdio_irq_thread;
198 atomic_t sdio_irq_thread_abort;
199
200#ifdef CONFIG_LEDS_TRIGGERS
201 struct led_trigger *led;
202#endif
203
204 struct dentry *debugfs_root;
205
206 unsigned long private[0] ____cacheline_aligned;
207};
208
209extern struct mmc_host *mmc_alloc_host(int extra, struct device *);
210extern int mmc_add_host(struct mmc_host *);
211extern void mmc_remove_host(struct mmc_host *);
212extern void mmc_free_host(struct mmc_host *);
213
214static inline void *mmc_priv(struct mmc_host *host)
215{
216 return (void *)host->private;
217}
218
219#define mmc_host_is_spi(host) ((host)->caps & MMC_CAP_SPI)
220
221#define mmc_dev(x) ((x)->parent)
222#define mmc_classdev(x) (&(x)->class_dev)
223#define mmc_hostname(x) (dev_name(&(x)->class_dev))
224
225extern int mmc_suspend_host(struct mmc_host *, pm_message_t);
226extern int mmc_resume_host(struct mmc_host *);
227
228extern void mmc_power_save_host(struct mmc_host *host);
229extern void mmc_power_restore_host(struct mmc_host *host);
230
231extern void mmc_detect_change(struct mmc_host *, unsigned long delay);
232extern void mmc_request_done(struct mmc_host *, struct mmc_request *);
233
234static inline void mmc_signal_sdio_irq(struct mmc_host *host)
235{
236 host->ops->enable_sdio_irq(host, 0);
237 wake_up_process(host->sdio_irq_thread);
238}
239
240struct regulator;
241
242int mmc_regulator_get_ocrmask(struct regulator *supply);
243int mmc_regulator_set_ocr(struct regulator *supply, unsigned short vdd_bit);
244
245int mmc_card_awake(struct mmc_host *host);
246int mmc_card_sleep(struct mmc_host *host);
247int mmc_card_can_sleep(struct mmc_host *host);
248
249int mmc_host_enable(struct mmc_host *host);
250int mmc_host_disable(struct mmc_host *host);
251int mmc_host_lazy_disable(struct mmc_host *host);
252
253static inline void mmc_set_disable_delay(struct mmc_host *host,
254 unsigned int disable_delay)
255{
256 host->disable_delay = disable_delay;
257}
258
259#endif
260
261