aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mmc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-05-25 19:55:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-25 19:55:55 -0400
commit8c1c77ff9be27137fa7cbbf51efedef1a2ae915b (patch)
treecdbd09cac5f5d1c6eb5ec4257dc478c6acca70c5 /include/linux/mmc
parentf3ae1c75203535f65448517e46c8dd70a56b6c71 (diff)
parent08ee80cc397ac1a306ca689a22ede954d92d0db1 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc: (75 commits) mmc: core: eMMC bus width may not work on all platforms mmc: sdhci: Auto-CMD23 fixes. mmc: sdhci: Auto-CMD23 support. mmc: core: Block CMD23 support for UHS104/SDXC cards. mmc: sdhci: Implement MMC_CAP_CMD23 for SDHCI. mmc: core: Use CMD23 for multiblock transfers when we can. mmc: quirks: Add/remove quirks conditional support. mmc: Add new VUB300 USB-to-SD/SDIO/MMC driver mmc: sdhci-pxa: Add quirks for DMA/ADMA to match h/w mmc: core: duplicated trial with same freq in mmc_rescan_try_freq() mmc: core: add support for eMMC Dual Data Rate mmc: core: eMMC signal voltage does not use CMD11 mmc: sdhci-pxa: add platform code for UHS signaling mmc: sdhci: add hooks for setting UHS in platform specific code mmc: core: clear MMC_PM_KEEP_POWER flag on resume mmc: dw_mmc: fixed wrong regulator_enable in suspend/resume mmc: sdhi: allow powering down controller with no card inserted mmc: tmio: runtime suspend the controller, where possible mmc: sdhi: support up to 3 interrupt sources mmc: sdhi: print physical base address and clock rate ...
Diffstat (limited to 'include/linux/mmc')
-rw-r--r--include/linux/mmc/Kbuild1
-rw-r--r--include/linux/mmc/card.h189
-rw-r--r--include/linux/mmc/core.h5
-rw-r--r--include/linux/mmc/host.h49
-rw-r--r--include/linux/mmc/ioctl.h54
-rw-r--r--include/linux/mmc/mmc.h18
-rw-r--r--include/linux/mmc/sd.h9
-rw-r--r--include/linux/mmc/sdhci.h15
-rw-r--r--include/linux/mmc/sh_mobile_sdhi.h4
9 files changed, 340 insertions, 4 deletions
diff --git a/include/linux/mmc/Kbuild b/include/linux/mmc/Kbuild
new file mode 100644
index 000000000000..1fb26448faa9
--- /dev/null
+++ b/include/linux/mmc/Kbuild
@@ -0,0 +1 @@
header-y += ioctl.h
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index adb4888248be..c6927a4d157f 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -11,6 +11,7 @@
11#define LINUX_MMC_CARD_H 11#define LINUX_MMC_CARD_H
12 12
13#include <linux/mmc/core.h> 13#include <linux/mmc/core.h>
14#include <linux/mod_devicetable.h>
14 15
15struct mmc_cid { 16struct mmc_cid {
16 unsigned int manfid; 17 unsigned int manfid;
@@ -29,6 +30,7 @@ struct mmc_csd {
29 unsigned short cmdclass; 30 unsigned short cmdclass;
30 unsigned short tacc_clks; 31 unsigned short tacc_clks;
31 unsigned int tacc_ns; 32 unsigned int tacc_ns;
33 unsigned int c_size;
32 unsigned int r2w_factor; 34 unsigned int r2w_factor;
33 unsigned int max_dtr; 35 unsigned int max_dtr;
34 unsigned int erase_size; /* In sectors */ 36 unsigned int erase_size; /* In sectors */
@@ -45,6 +47,10 @@ struct mmc_ext_csd {
45 u8 rev; 47 u8 rev;
46 u8 erase_group_def; 48 u8 erase_group_def;
47 u8 sec_feature_support; 49 u8 sec_feature_support;
50 u8 rel_sectors;
51 u8 rel_param;
52 u8 part_config;
53 unsigned int part_time; /* Units: ms */
48 unsigned int sa_timeout; /* Units: 100ns */ 54 unsigned int sa_timeout; /* Units: 100ns */
49 unsigned int hs_max_dtr; 55 unsigned int hs_max_dtr;
50 unsigned int sectors; 56 unsigned int sectors;
@@ -57,13 +63,18 @@ struct mmc_ext_csd {
57 bool enhanced_area_en; /* enable bit */ 63 bool enhanced_area_en; /* enable bit */
58 unsigned long long enhanced_area_offset; /* Units: Byte */ 64 unsigned long long enhanced_area_offset; /* Units: Byte */
59 unsigned int enhanced_area_size; /* Units: KB */ 65 unsigned int enhanced_area_size; /* Units: KB */
66 unsigned int boot_size; /* in bytes */
60}; 67};
61 68
62struct sd_scr { 69struct sd_scr {
63 unsigned char sda_vsn; 70 unsigned char sda_vsn;
71 unsigned char sda_spec3;
64 unsigned char bus_widths; 72 unsigned char bus_widths;
65#define SD_SCR_BUS_WIDTH_1 (1<<0) 73#define SD_SCR_BUS_WIDTH_1 (1<<0)
66#define SD_SCR_BUS_WIDTH_4 (1<<2) 74#define SD_SCR_BUS_WIDTH_4 (1<<2)
75 unsigned char cmds;
76#define SD_SCR_CMD20_SUPPORT (1<<0)
77#define SD_SCR_CMD23_SUPPORT (1<<1)
67}; 78};
68 79
69struct sd_ssr { 80struct sd_ssr {
@@ -74,6 +85,39 @@ struct sd_ssr {
74 85
75struct sd_switch_caps { 86struct sd_switch_caps {
76 unsigned int hs_max_dtr; 87 unsigned int hs_max_dtr;
88 unsigned int uhs_max_dtr;
89#define UHS_SDR104_MAX_DTR 208000000
90#define UHS_SDR50_MAX_DTR 100000000
91#define UHS_DDR50_MAX_DTR 50000000
92#define UHS_SDR25_MAX_DTR UHS_DDR50_MAX_DTR
93#define UHS_SDR12_MAX_DTR 25000000
94 unsigned int sd3_bus_mode;
95#define UHS_SDR12_BUS_SPEED 0
96#define UHS_SDR25_BUS_SPEED 1
97#define UHS_SDR50_BUS_SPEED 2
98#define UHS_SDR104_BUS_SPEED 3
99#define UHS_DDR50_BUS_SPEED 4
100
101#define SD_MODE_UHS_SDR12 (1 << UHS_SDR12_BUS_SPEED)
102#define SD_MODE_UHS_SDR25 (1 << UHS_SDR25_BUS_SPEED)
103#define SD_MODE_UHS_SDR50 (1 << UHS_SDR50_BUS_SPEED)
104#define SD_MODE_UHS_SDR104 (1 << UHS_SDR104_BUS_SPEED)
105#define SD_MODE_UHS_DDR50 (1 << UHS_DDR50_BUS_SPEED)
106 unsigned int sd3_drv_type;
107#define SD_DRIVER_TYPE_B 0x01
108#define SD_DRIVER_TYPE_A 0x02
109#define SD_DRIVER_TYPE_C 0x04
110#define SD_DRIVER_TYPE_D 0x08
111 unsigned int sd3_curr_limit;
112#define SD_SET_CURRENT_LIMIT_200 0
113#define SD_SET_CURRENT_LIMIT_400 1
114#define SD_SET_CURRENT_LIMIT_600 2
115#define SD_SET_CURRENT_LIMIT_800 3
116
117#define SD_MAX_CURRENT_200 (1 << SD_SET_CURRENT_LIMIT_200)
118#define SD_MAX_CURRENT_400 (1 << SD_SET_CURRENT_LIMIT_400)
119#define SD_MAX_CURRENT_600 (1 << SD_SET_CURRENT_LIMIT_600)
120#define SD_MAX_CURRENT_800 (1 << SD_SET_CURRENT_LIMIT_800)
77}; 121};
78 122
79struct sdio_cccr { 123struct sdio_cccr {
@@ -118,6 +162,8 @@ struct mmc_card {
118#define MMC_STATE_HIGHSPEED (1<<2) /* card is in high speed mode */ 162#define MMC_STATE_HIGHSPEED (1<<2) /* card is in high speed mode */
119#define MMC_STATE_BLOCKADDR (1<<3) /* card uses block-addressing */ 163#define MMC_STATE_BLOCKADDR (1<<3) /* card uses block-addressing */
120#define MMC_STATE_HIGHSPEED_DDR (1<<4) /* card is in high speed mode */ 164#define MMC_STATE_HIGHSPEED_DDR (1<<4) /* card is in high speed mode */
165#define MMC_STATE_ULTRAHIGHSPEED (1<<5) /* card is in ultra high speed mode */
166#define MMC_CARD_SDXC (1<<6) /* card is SDXC */
121 unsigned int quirks; /* card quirks */ 167 unsigned int quirks; /* card quirks */
122#define MMC_QUIRK_LENIENT_FN0 (1<<0) /* allow SDIO FN0 writes outside of the VS CCCR range */ 168#define MMC_QUIRK_LENIENT_FN0 (1<<0) /* allow SDIO FN0 writes outside of the VS CCCR range */
123#define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1) /* use func->cur_blksize */ 169#define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1) /* use func->cur_blksize */
@@ -125,6 +171,10 @@ struct mmc_card {
125#define MMC_QUIRK_NONSTD_SDIO (1<<2) /* non-standard SDIO card attached */ 171#define MMC_QUIRK_NONSTD_SDIO (1<<2) /* non-standard SDIO card attached */
126 /* (missing CIA registers) */ 172 /* (missing CIA registers) */
127#define MMC_QUIRK_BROKEN_CLK_GATING (1<<3) /* clock gating the sdio bus will make card fail */ 173#define MMC_QUIRK_BROKEN_CLK_GATING (1<<3) /* clock gating the sdio bus will make card fail */
174#define MMC_QUIRK_NONSTD_FUNC_IF (1<<4) /* SDIO card has nonstd function interfaces */
175#define MMC_QUIRK_DISABLE_CD (1<<5) /* disconnect CD/DAT[3] resistor */
176#define MMC_QUIRK_INAND_CMD38 (1<<6) /* iNAND devices have broken CMD38 */
177#define MMC_QUIRK_BLK_NO_CMD23 (1<<7) /* Avoid CMD23 for regular multiblock */
128 178
129 unsigned int erase_size; /* erase size in sectors */ 179 unsigned int erase_size; /* erase size in sectors */
130 unsigned int erase_shift; /* if erase unit is power 2 */ 180 unsigned int erase_shift; /* if erase unit is power 2 */
@@ -145,14 +195,100 @@ struct mmc_card {
145 struct sdio_cccr cccr; /* common card info */ 195 struct sdio_cccr cccr; /* common card info */
146 struct sdio_cis cis; /* common tuple info */ 196 struct sdio_cis cis; /* common tuple info */
147 struct sdio_func *sdio_func[SDIO_MAX_FUNCS]; /* SDIO functions (devices) */ 197 struct sdio_func *sdio_func[SDIO_MAX_FUNCS]; /* SDIO functions (devices) */
198 struct sdio_func *sdio_single_irq; /* SDIO function when only one IRQ active */
148 unsigned num_info; /* number of info strings */ 199 unsigned num_info; /* number of info strings */
149 const char **info; /* info strings */ 200 const char **info; /* info strings */
150 struct sdio_func_tuple *tuples; /* unknown common tuples */ 201 struct sdio_func_tuple *tuples; /* unknown common tuples */
151 202
203 unsigned int sd_bus_speed; /* Bus Speed Mode set for the card */
204
152 struct dentry *debugfs_root; 205 struct dentry *debugfs_root;
153}; 206};
154 207
155void mmc_fixup_device(struct mmc_card *dev); 208/*
209 * The world is not perfect and supplies us with broken mmc/sdio devices.
210 * For at least some of these bugs we need a work-around.
211 */
212
213struct mmc_fixup {
214 /* CID-specific fields. */
215 const char *name;
216
217 /* Valid revision range */
218 u64 rev_start, rev_end;
219
220 unsigned int manfid;
221 unsigned short oemid;
222
223 /* SDIO-specfic fields. You can use SDIO_ANY_ID here of course */
224 u16 cis_vendor, cis_device;
225
226 void (*vendor_fixup)(struct mmc_card *card, int data);
227 int data;
228};
229
230#define CID_MANFID_ANY (-1u)
231#define CID_OEMID_ANY ((unsigned short) -1)
232#define CID_NAME_ANY (NULL)
233
234#define END_FIXUP { 0 }
235
236#define _FIXUP_EXT(_name, _manfid, _oemid, _rev_start, _rev_end, \
237 _cis_vendor, _cis_device, \
238 _fixup, _data) \
239 { \
240 .name = (_name), \
241 .manfid = (_manfid), \
242 .oemid = (_oemid), \
243 .rev_start = (_rev_start), \
244 .rev_end = (_rev_end), \
245 .cis_vendor = (_cis_vendor), \
246 .cis_device = (_cis_device), \
247 .vendor_fixup = (_fixup), \
248 .data = (_data), \
249 }
250
251#define MMC_FIXUP_REV(_name, _manfid, _oemid, _rev_start, _rev_end, \
252 _fixup, _data) \
253 _FIXUP_EXT(_name, _manfid, \
254 _oemid, _rev_start, _rev_end, \
255 SDIO_ANY_ID, SDIO_ANY_ID, \
256 _fixup, _data) \
257
258#define MMC_FIXUP(_name, _manfid, _oemid, _fixup, _data) \
259 MMC_FIXUP_REV(_name, _manfid, _oemid, 0, -1ull, _fixup, _data)
260
261#define SDIO_FIXUP(_vendor, _device, _fixup, _data) \
262 _FIXUP_EXT(CID_NAME_ANY, CID_MANFID_ANY, \
263 CID_OEMID_ANY, 0, -1ull, \
264 _vendor, _device, \
265 _fixup, _data) \
266
267#define cid_rev(hwrev, fwrev, year, month) \
268 (((u64) hwrev) << 40 | \
269 ((u64) fwrev) << 32 | \
270 ((u64) year) << 16 | \
271 ((u64) month))
272
273#define cid_rev_card(card) \
274 cid_rev(card->cid.hwrev, \
275 card->cid.fwrev, \
276 card->cid.year, \
277 card->cid.month)
278
279/*
280 * Unconditionally quirk add/remove.
281 */
282
283static inline void __maybe_unused add_quirk(struct mmc_card *card, int data)
284{
285 card->quirks |= data;
286}
287
288static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data)
289{
290 card->quirks &= ~data;
291}
156 292
157#define mmc_card_mmc(c) ((c)->type == MMC_TYPE_MMC) 293#define mmc_card_mmc(c) ((c)->type == MMC_TYPE_MMC)
158#define mmc_card_sd(c) ((c)->type == MMC_TYPE_SD) 294#define mmc_card_sd(c) ((c)->type == MMC_TYPE_SD)
@@ -163,12 +299,50 @@ void mmc_fixup_device(struct mmc_card *dev);
163#define mmc_card_highspeed(c) ((c)->state & MMC_STATE_HIGHSPEED) 299#define mmc_card_highspeed(c) ((c)->state & MMC_STATE_HIGHSPEED)
164#define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR) 300#define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR)
165#define mmc_card_ddr_mode(c) ((c)->state & MMC_STATE_HIGHSPEED_DDR) 301#define mmc_card_ddr_mode(c) ((c)->state & MMC_STATE_HIGHSPEED_DDR)
302#define mmc_sd_card_uhs(c) ((c)->state & MMC_STATE_ULTRAHIGHSPEED)
303#define mmc_card_ext_capacity(c) ((c)->state & MMC_CARD_SDXC)
166 304
167#define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT) 305#define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT)
168#define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY) 306#define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY)
169#define mmc_card_set_highspeed(c) ((c)->state |= MMC_STATE_HIGHSPEED) 307#define mmc_card_set_highspeed(c) ((c)->state |= MMC_STATE_HIGHSPEED)
170#define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR) 308#define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR)
171#define mmc_card_set_ddr_mode(c) ((c)->state |= MMC_STATE_HIGHSPEED_DDR) 309#define mmc_card_set_ddr_mode(c) ((c)->state |= MMC_STATE_HIGHSPEED_DDR)
310#define mmc_sd_card_set_uhs(c) ((c)->state |= MMC_STATE_ULTRAHIGHSPEED)
311#define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC)
312
313/*
314 * Quirk add/remove for MMC products.
315 */
316
317static inline void __maybe_unused add_quirk_mmc(struct mmc_card *card, int data)
318{
319 if (mmc_card_mmc(card))
320 card->quirks |= data;
321}
322
323static inline void __maybe_unused remove_quirk_mmc(struct mmc_card *card,
324 int data)
325{
326 if (mmc_card_mmc(card))
327 card->quirks &= ~data;
328}
329
330/*
331 * Quirk add/remove for SD products.
332 */
333
334static inline void __maybe_unused add_quirk_sd(struct mmc_card *card, int data)
335{
336 if (mmc_card_sd(card))
337 card->quirks |= data;
338}
339
340static inline void __maybe_unused remove_quirk_sd(struct mmc_card *card,
341 int data)
342{
343 if (mmc_card_sd(card))
344 card->quirks &= ~data;
345}
172 346
173static inline int mmc_card_lenient_fn0(const struct mmc_card *c) 347static inline int mmc_card_lenient_fn0(const struct mmc_card *c)
174{ 348{
@@ -180,6 +354,16 @@ static inline int mmc_blksz_for_byte_mode(const struct mmc_card *c)
180 return c->quirks & MMC_QUIRK_BLKSZ_FOR_BYTE_MODE; 354 return c->quirks & MMC_QUIRK_BLKSZ_FOR_BYTE_MODE;
181} 355}
182 356
357static inline int mmc_card_disable_cd(const struct mmc_card *c)
358{
359 return c->quirks & MMC_QUIRK_DISABLE_CD;
360}
361
362static inline int mmc_card_nonstd_func_interface(const struct mmc_card *c)
363{
364 return c->quirks & MMC_QUIRK_NONSTD_FUNC_IF;
365}
366
183#define mmc_card_name(c) ((c)->cid.prod_name) 367#define mmc_card_name(c) ((c)->cid.prod_name)
184#define mmc_card_id(c) (dev_name(&(c)->dev)) 368#define mmc_card_id(c) (dev_name(&(c)->dev))
185 369
@@ -203,4 +387,7 @@ struct mmc_driver {
203extern int mmc_register_driver(struct mmc_driver *); 387extern int mmc_register_driver(struct mmc_driver *);
204extern void mmc_unregister_driver(struct mmc_driver *); 388extern void mmc_unregister_driver(struct mmc_driver *);
205 389
390extern void mmc_fixup_device(struct mmc_card *card,
391 const struct mmc_fixup *table);
392
206#endif 393#endif
diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h
index 07f27af4dba5..b6718e549a51 100644
--- a/include/linux/mmc/core.h
+++ b/include/linux/mmc/core.h
@@ -92,7 +92,7 @@ struct mmc_command {
92 * actively failing requests 92 * actively failing requests
93 */ 93 */
94 94
95 unsigned int erase_timeout; /* in milliseconds */ 95 unsigned int cmd_timeout_ms; /* in milliseconds */
96 96
97 struct mmc_data *data; /* data segment associated with cmd */ 97 struct mmc_data *data; /* data segment associated with cmd */
98 struct mmc_request *mrq; /* associated request */ 98 struct mmc_request *mrq; /* associated request */
@@ -120,6 +120,7 @@ struct mmc_data {
120}; 120};
121 121
122struct mmc_request { 122struct mmc_request {
123 struct mmc_command *sbc; /* SET_BLOCK_COUNT for multiblock */
123 struct mmc_command *cmd; 124 struct mmc_command *cmd;
124 struct mmc_data *data; 125 struct mmc_data *data;
125 struct mmc_command *stop; 126 struct mmc_command *stop;
@@ -133,8 +134,10 @@ struct mmc_card;
133 134
134extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *); 135extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
135extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int); 136extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
137extern int mmc_app_cmd(struct mmc_host *, struct mmc_card *);
136extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *, 138extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *,
137 struct mmc_command *, int); 139 struct mmc_command *, int);
140extern int mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int);
138 141
139#define MMC_ERASE_ARG 0x00000000 142#define MMC_ERASE_ARG 0x00000000
140#define MMC_SECURE_ERASE_ARG 0x80000000 143#define MMC_SECURE_ERASE_ARG 0x80000000
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index bcb793ec7374..1ee4424462eb 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -50,12 +50,30 @@ struct mmc_ios {
50#define MMC_TIMING_LEGACY 0 50#define MMC_TIMING_LEGACY 0
51#define MMC_TIMING_MMC_HS 1 51#define MMC_TIMING_MMC_HS 1
52#define MMC_TIMING_SD_HS 2 52#define MMC_TIMING_SD_HS 2
53#define MMC_TIMING_UHS_SDR12 MMC_TIMING_LEGACY
54#define MMC_TIMING_UHS_SDR25 MMC_TIMING_SD_HS
55#define MMC_TIMING_UHS_SDR50 3
56#define MMC_TIMING_UHS_SDR104 4
57#define MMC_TIMING_UHS_DDR50 5
53 58
54 unsigned char ddr; /* dual data rate used */ 59 unsigned char ddr; /* dual data rate used */
55 60
56#define MMC_SDR_MODE 0 61#define MMC_SDR_MODE 0
57#define MMC_1_2V_DDR_MODE 1 62#define MMC_1_2V_DDR_MODE 1
58#define MMC_1_8V_DDR_MODE 2 63#define MMC_1_8V_DDR_MODE 2
64
65 unsigned char signal_voltage; /* signalling voltage (1.8V or 3.3V) */
66
67#define MMC_SIGNAL_VOLTAGE_330 0
68#define MMC_SIGNAL_VOLTAGE_180 1
69#define MMC_SIGNAL_VOLTAGE_120 2
70
71 unsigned char drv_type; /* driver type (A, B, C, D) */
72
73#define MMC_SET_DRIVER_TYPE_B 0
74#define MMC_SET_DRIVER_TYPE_A 1
75#define MMC_SET_DRIVER_TYPE_C 2
76#define MMC_SET_DRIVER_TYPE_D 3
59}; 77};
60 78
61struct mmc_host_ops { 79struct mmc_host_ops {
@@ -117,6 +135,10 @@ struct mmc_host_ops {
117 135
118 /* optional callback for HC quirks */ 136 /* optional callback for HC quirks */
119 void (*init_card)(struct mmc_host *host, struct mmc_card *card); 137 void (*init_card)(struct mmc_host *host, struct mmc_card *card);
138
139 int (*start_signal_voltage_switch)(struct mmc_host *host, struct mmc_ios *ios);
140 int (*execute_tuning)(struct mmc_host *host);
141 void (*enable_preset_value)(struct mmc_host *host, bool enable);
120}; 142};
121 143
122struct mmc_card; 144struct mmc_card;
@@ -173,6 +195,22 @@ struct mmc_host {
173 /* DDR mode at 1.2V */ 195 /* DDR mode at 1.2V */
174#define MMC_CAP_POWER_OFF_CARD (1 << 13) /* Can power off after boot */ 196#define MMC_CAP_POWER_OFF_CARD (1 << 13) /* Can power off after boot */
175#define MMC_CAP_BUS_WIDTH_TEST (1 << 14) /* CMD14/CMD19 bus width ok */ 197#define MMC_CAP_BUS_WIDTH_TEST (1 << 14) /* CMD14/CMD19 bus width ok */
198#define MMC_CAP_UHS_SDR12 (1 << 15) /* Host supports UHS SDR12 mode */
199#define MMC_CAP_UHS_SDR25 (1 << 16) /* Host supports UHS SDR25 mode */
200#define MMC_CAP_UHS_SDR50 (1 << 17) /* Host supports UHS SDR50 mode */
201#define MMC_CAP_UHS_SDR104 (1 << 18) /* Host supports UHS SDR104 mode */
202#define MMC_CAP_UHS_DDR50 (1 << 19) /* Host supports UHS DDR50 mode */
203#define MMC_CAP_SET_XPC_330 (1 << 20) /* Host supports >150mA current at 3.3V */
204#define MMC_CAP_SET_XPC_300 (1 << 21) /* Host supports >150mA current at 3.0V */
205#define MMC_CAP_SET_XPC_180 (1 << 22) /* Host supports >150mA current at 1.8V */
206#define MMC_CAP_DRIVER_TYPE_A (1 << 23) /* Host supports Driver Type A */
207#define MMC_CAP_DRIVER_TYPE_C (1 << 24) /* Host supports Driver Type C */
208#define MMC_CAP_DRIVER_TYPE_D (1 << 25) /* Host supports Driver Type D */
209#define MMC_CAP_MAX_CURRENT_200 (1 << 26) /* Host max current limit is 200mA */
210#define MMC_CAP_MAX_CURRENT_400 (1 << 27) /* Host max current limit is 400mA */
211#define MMC_CAP_MAX_CURRENT_600 (1 << 28) /* Host max current limit is 600mA */
212#define MMC_CAP_MAX_CURRENT_800 (1 << 29) /* Host max current limit is 800mA */
213#define MMC_CAP_CMD23 (1 << 30) /* CMD23 supported. */
176 214
177 mmc_pm_flag_t pm_caps; /* supported pm features */ 215 mmc_pm_flag_t pm_caps; /* supported pm features */
178 216
@@ -321,10 +359,19 @@ static inline int mmc_card_is_removable(struct mmc_host *host)
321 return !(host->caps & MMC_CAP_NONREMOVABLE) && mmc_assume_removable; 359 return !(host->caps & MMC_CAP_NONREMOVABLE) && mmc_assume_removable;
322} 360}
323 361
324static inline int mmc_card_is_powered_resumed(struct mmc_host *host) 362static inline int mmc_card_keep_power(struct mmc_host *host)
325{ 363{
326 return host->pm_flags & MMC_PM_KEEP_POWER; 364 return host->pm_flags & MMC_PM_KEEP_POWER;
327} 365}
328 366
367static inline int mmc_card_wake_sdio_irq(struct mmc_host *host)
368{
369 return host->pm_flags & MMC_PM_WAKE_SDIO_IRQ;
370}
371
372static inline int mmc_host_cmd23(struct mmc_host *host)
373{
374 return host->caps & MMC_CAP_CMD23;
375}
329#endif 376#endif
330 377
diff --git a/include/linux/mmc/ioctl.h b/include/linux/mmc/ioctl.h
new file mode 100644
index 000000000000..5baf2983a12f
--- /dev/null
+++ b/include/linux/mmc/ioctl.h
@@ -0,0 +1,54 @@
1#ifndef LINUX_MMC_IOCTL_H
2#define LINUX_MMC_IOCTL_H
3struct mmc_ioc_cmd {
4 /* Implies direction of data. true = write, false = read */
5 int write_flag;
6
7 /* Application-specific command. true = precede with CMD55 */
8 int is_acmd;
9
10 __u32 opcode;
11 __u32 arg;
12 __u32 response[4]; /* CMD response */
13 unsigned int flags;
14 unsigned int blksz;
15 unsigned int blocks;
16
17 /*
18 * Sleep at least postsleep_min_us useconds, and at most
19 * postsleep_max_us useconds *after* issuing command. Needed for
20 * some read commands for which cards have no other way of indicating
21 * they're ready for the next command (i.e. there is no equivalent of
22 * a "busy" indicator for read operations).
23 */
24 unsigned int postsleep_min_us;
25 unsigned int postsleep_max_us;
26
27 /*
28 * Override driver-computed timeouts. Note the difference in units!
29 */
30 unsigned int data_timeout_ns;
31 unsigned int cmd_timeout_ms;
32
33 /*
34 * For 64-bit machines, the next member, ``__u64 data_ptr``, wants to
35 * be 8-byte aligned. Make sure this struct is the same size when
36 * built for 32-bit.
37 */
38 __u32 __pad;
39
40 /* DAT buffer */
41 __u64 data_ptr;
42};
43#define mmc_ioc_cmd_set_data(ic, ptr) ic.data_ptr = (__u64)(unsigned long) ptr
44
45#define MMC_IOC_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct mmc_ioc_cmd)
46
47/*
48 * Since this ioctl is only meant to enhance (and not replace) normal access
49 * to the mmc bus device, an upper data transfer limit of MMC_IOC_MAX_BYTES
50 * is enforced per ioctl call. For larger data transfers, use the normal
51 * block device operations.
52 */
53#define MMC_IOC_MAX_BYTES (512L * 256)
54#endif /* LINUX_MMC_IOCTL_H */
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index 264ba5451e3b..ac26a685cca8 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -50,6 +50,7 @@
50#define MMC_SET_BLOCKLEN 16 /* ac [31:0] block len R1 */ 50#define MMC_SET_BLOCKLEN 16 /* ac [31:0] block len R1 */
51#define MMC_READ_SINGLE_BLOCK 17 /* adtc [31:0] data addr R1 */ 51#define MMC_READ_SINGLE_BLOCK 17 /* adtc [31:0] data addr R1 */
52#define MMC_READ_MULTIPLE_BLOCK 18 /* adtc [31:0] data addr R1 */ 52#define MMC_READ_MULTIPLE_BLOCK 18 /* adtc [31:0] data addr R1 */
53#define MMC_SEND_TUNING_BLOCK 19 /* adtc R1 */
53 54
54 /* class 3 */ 55 /* class 3 */
55#define MMC_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */ 56#define MMC_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */
@@ -82,6 +83,12 @@
82#define MMC_APP_CMD 55 /* ac [31:16] RCA R1 */ 83#define MMC_APP_CMD 55 /* ac [31:16] RCA R1 */
83#define MMC_GEN_CMD 56 /* adtc [0] RD/WR R1 */ 84#define MMC_GEN_CMD 56 /* adtc [0] RD/WR R1 */
84 85
86static inline bool mmc_op_multi(u32 opcode)
87{
88 return opcode == MMC_WRITE_MULTIPLE_BLOCK ||
89 opcode == MMC_READ_MULTIPLE_BLOCK;
90}
91
85/* 92/*
86 * MMC_SWITCH argument format: 93 * MMC_SWITCH argument format:
87 * 94 *
@@ -255,18 +262,23 @@ struct _mmc_csd {
255 262
256#define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */ 263#define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */
257#define EXT_CSD_PARTITION_SUPPORT 160 /* RO */ 264#define EXT_CSD_PARTITION_SUPPORT 160 /* RO */
265#define EXT_CSD_WR_REL_PARAM 166 /* RO */
258#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ 266#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */
267#define EXT_CSD_PART_CONFIG 179 /* R/W */
259#define EXT_CSD_ERASED_MEM_CONT 181 /* RO */ 268#define EXT_CSD_ERASED_MEM_CONT 181 /* RO */
260#define EXT_CSD_BUS_WIDTH 183 /* R/W */ 269#define EXT_CSD_BUS_WIDTH 183 /* R/W */
261#define EXT_CSD_HS_TIMING 185 /* R/W */ 270#define EXT_CSD_HS_TIMING 185 /* R/W */
262#define EXT_CSD_REV 192 /* RO */ 271#define EXT_CSD_REV 192 /* RO */
263#define EXT_CSD_STRUCTURE 194 /* RO */ 272#define EXT_CSD_STRUCTURE 194 /* RO */
264#define EXT_CSD_CARD_TYPE 196 /* RO */ 273#define EXT_CSD_CARD_TYPE 196 /* RO */
274#define EXT_CSD_PART_SWITCH_TIME 199 /* RO */
265#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ 275#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */
266#define EXT_CSD_S_A_TIMEOUT 217 /* RO */ 276#define EXT_CSD_S_A_TIMEOUT 217 /* RO */
277#define EXT_CSD_REL_WR_SEC_C 222 /* RO */
267#define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */ 278#define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */
268#define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */ 279#define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */
269#define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */ 280#define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */
281#define EXT_CSD_BOOT_MULT 226 /* RO */
270#define EXT_CSD_SEC_TRIM_MULT 229 /* RO */ 282#define EXT_CSD_SEC_TRIM_MULT 229 /* RO */
271#define EXT_CSD_SEC_ERASE_MULT 230 /* RO */ 283#define EXT_CSD_SEC_ERASE_MULT 230 /* RO */
272#define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */ 284#define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */
@@ -276,6 +288,12 @@ struct _mmc_csd {
276 * EXT_CSD field definitions 288 * EXT_CSD field definitions
277 */ 289 */
278 290
291#define EXT_CSD_WR_REL_PARAM_EN (1<<2)
292
293#define EXT_CSD_PART_CONFIG_ACC_MASK (0x7)
294#define EXT_CSD_PART_CONFIG_ACC_BOOT0 (0x1)
295#define EXT_CSD_PART_CONFIG_ACC_BOOT1 (0x2)
296
279#define EXT_CSD_CMD_SET_NORMAL (1<<0) 297#define EXT_CSD_CMD_SET_NORMAL (1<<0)
280#define EXT_CSD_CMD_SET_SECURE (1<<1) 298#define EXT_CSD_CMD_SET_SECURE (1<<1)
281#define EXT_CSD_CMD_SET_CPSECURE (1<<2) 299#define EXT_CSD_CMD_SET_CPSECURE (1<<2)
diff --git a/include/linux/mmc/sd.h b/include/linux/mmc/sd.h
index 3fd85e088cc3..7d35d52c3df3 100644
--- a/include/linux/mmc/sd.h
+++ b/include/linux/mmc/sd.h
@@ -17,6 +17,7 @@
17/* This is basically the same command as for MMC with some quirks. */ 17/* This is basically the same command as for MMC with some quirks. */
18#define SD_SEND_RELATIVE_ADDR 3 /* bcr R6 */ 18#define SD_SEND_RELATIVE_ADDR 3 /* bcr R6 */
19#define SD_SEND_IF_COND 8 /* bcr [11:0] See below R7 */ 19#define SD_SEND_IF_COND 8 /* bcr [11:0] See below R7 */
20#define SD_SWITCH_VOLTAGE 11 /* ac R1 */
20 21
21 /* class 10 */ 22 /* class 10 */
22#define SD_SWITCH 6 /* adtc [31:0] See below R1 */ 23#define SD_SWITCH 6 /* adtc [31:0] See below R1 */
@@ -32,6 +33,12 @@
32#define SD_APP_OP_COND 41 /* bcr [31:0] OCR R3 */ 33#define SD_APP_OP_COND 41 /* bcr [31:0] OCR R3 */
33#define SD_APP_SEND_SCR 51 /* adtc R1 */ 34#define SD_APP_SEND_SCR 51 /* adtc R1 */
34 35
36/* OCR bit definitions */
37#define SD_OCR_S18R (1 << 24) /* 1.8V switching request */
38#define SD_ROCR_S18A SD_OCR_S18R /* 1.8V switching accepted by card */
39#define SD_OCR_XPC (1 << 28) /* SDXC power control */
40#define SD_OCR_CCS (1 << 30) /* Card Capacity Status */
41
35/* 42/*
36 * SD_SWITCH argument format: 43 * SD_SWITCH argument format:
37 * 44 *
@@ -59,7 +66,7 @@
59 66
60#define SCR_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.01 */ 67#define SCR_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.01 */
61#define SCR_SPEC_VER_1 1 /* Implements system specification 1.10 */ 68#define SCR_SPEC_VER_1 1 /* Implements system specification 1.10 */
62#define SCR_SPEC_VER_2 2 /* Implements system specification 2.00 */ 69#define SCR_SPEC_VER_2 2 /* Implements system specification 2.00-3.0X */
63 70
64/* 71/*
65 * SD bus widths 72 * SD bus widths
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index 83bd9f76709a..6a68c4eb4e44 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -85,6 +85,8 @@ struct sdhci_host {
85#define SDHCI_QUIRK_NO_HISPD_BIT (1<<29) 85#define SDHCI_QUIRK_NO_HISPD_BIT (1<<29)
86/* Controller treats ADMA descriptors with length 0000h incorrectly */ 86/* Controller treats ADMA descriptors with length 0000h incorrectly */
87#define SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC (1<<30) 87#define SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC (1<<30)
88/* The read-only detection via SDHCI_PRESENT_STATE register is unstable */
89#define SDHCI_QUIRK_UNSTABLE_RO_DETECT (1<<31)
88 90
89 int irq; /* Device IRQ */ 91 int irq; /* Device IRQ */
90 void __iomem *ioaddr; /* Mapped address */ 92 void __iomem *ioaddr; /* Mapped address */
@@ -109,11 +111,16 @@ struct sdhci_host {
109#define SDHCI_USE_ADMA (1<<1) /* Host is ADMA capable */ 111#define SDHCI_USE_ADMA (1<<1) /* Host is ADMA capable */
110#define SDHCI_REQ_USE_DMA (1<<2) /* Use DMA for this req. */ 112#define SDHCI_REQ_USE_DMA (1<<2) /* Use DMA for this req. */
111#define SDHCI_DEVICE_DEAD (1<<3) /* Device unresponsive */ 113#define SDHCI_DEVICE_DEAD (1<<3) /* Device unresponsive */
114#define SDHCI_SDR50_NEEDS_TUNING (1<<4) /* SDR50 needs tuning */
115#define SDHCI_NEEDS_RETUNING (1<<5) /* Host needs retuning */
116#define SDHCI_AUTO_CMD12 (1<<6) /* Auto CMD12 support */
117#define SDHCI_AUTO_CMD23 (1<<7) /* Auto CMD23 support */
112 118
113 unsigned int version; /* SDHCI spec. version */ 119 unsigned int version; /* SDHCI spec. version */
114 120
115 unsigned int max_clk; /* Max possible freq (MHz) */ 121 unsigned int max_clk; /* Max possible freq (MHz) */
116 unsigned int timeout_clk; /* Timeout freq (KHz) */ 122 unsigned int timeout_clk; /* Timeout freq (KHz) */
123 unsigned int clk_mul; /* Clock Muliplier value */
117 124
118 unsigned int clock; /* Current clock (MHz) */ 125 unsigned int clock; /* Current clock (MHz) */
119 u8 pwr; /* Current voltage */ 126 u8 pwr; /* Current voltage */
@@ -145,6 +152,14 @@ struct sdhci_host {
145 unsigned int ocr_avail_sd; 152 unsigned int ocr_avail_sd;
146 unsigned int ocr_avail_mmc; 153 unsigned int ocr_avail_mmc;
147 154
155 wait_queue_head_t buf_ready_int; /* Waitqueue for Buffer Read Ready interrupt */
156 unsigned int tuning_done; /* Condition flag set when CMD19 succeeds */
157
158 unsigned int tuning_count; /* Timer count for re-tuning */
159 unsigned int tuning_mode; /* Re-tuning mode supported by host */
160#define SDHCI_TUNING_MODE_1 0
161 struct timer_list tuning_timer; /* Timer for tuning */
162
148 unsigned long private[0] ____cacheline_aligned; 163 unsigned long private[0] ____cacheline_aligned;
149}; 164};
150#endif /* __SDHCI_H */ 165#endif /* __SDHCI_H */
diff --git a/include/linux/mmc/sh_mobile_sdhi.h b/include/linux/mmc/sh_mobile_sdhi.h
index c981b959760f..faf32b6ec185 100644
--- a/include/linux/mmc/sh_mobile_sdhi.h
+++ b/include/linux/mmc/sh_mobile_sdhi.h
@@ -3,12 +3,16 @@
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5 5
6struct platform_device;
7struct tmio_mmc_data;
8
6struct sh_mobile_sdhi_info { 9struct sh_mobile_sdhi_info {
7 int dma_slave_tx; 10 int dma_slave_tx;
8 int dma_slave_rx; 11 int dma_slave_rx;
9 unsigned long tmio_flags; 12 unsigned long tmio_flags;
10 unsigned long tmio_caps; 13 unsigned long tmio_caps;
11 u32 tmio_ocr_mask; /* available MMC voltages */ 14 u32 tmio_ocr_mask; /* available MMC voltages */
15 struct tmio_mmc_data *pdata;
12 void (*set_pwr)(struct platform_device *pdev, int state); 16 void (*set_pwr)(struct platform_device *pdev, int state);
13 int (*get_cd)(struct platform_device *pdev); 17 int (*get_cd)(struct platform_device *pdev);
14}; 18};