aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mmc
diff options
context:
space:
mode:
authorChristopher Kenna <cjk@cs.unc.edu>2012-09-28 13:46:28 -0400
committerChristopher Kenna <cjk@cs.unc.edu>2012-09-28 14:50:15 -0400
commitdaa22703f14c007e93b464c45fa60019a36f546d (patch)
treea1a130b6e128dc9d57c35c026977e1b4953105e1 /include/linux/mmc
parent5aa287dcf1b5879aa0150b0511833c52885f5b4c (diff)
Apply k4412 kernel from HardKernel for ODROID-X.
Diffstat (limited to 'include/linux/mmc')
-rw-r--r--include/linux/mmc/card.h32
-rw-r--r--include/linux/mmc/core.h21
-rw-r--r--include/linux/mmc/dw_mmc.h60
-rw-r--r--include/linux/mmc/host.h136
-rw-r--r--include/linux/mmc/mmc.h125
-rw-r--r--include/linux/mmc/pm.h4
-rw-r--r--include/linux/mmc/sdhci.h1
-rw-r--r--include/linux/mmc/sdio.h31
-rw-r--r--include/linux/mmc/sdio_func.h10
9 files changed, 411 insertions, 9 deletions
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index 6ad43554ac0..6ca73e329bd 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -50,8 +50,16 @@ struct mmc_ext_csd {
50 u8 rel_sectors; 50 u8 rel_sectors;
51 u8 rel_param; 51 u8 rel_param;
52 u8 part_config; 52 u8 part_config;
53 u8 boot_part_prot;
54 u8 rst_n_function;
55 u8 cache_ctrl;
56 u8 max_packed_writes;
57 u8 max_packed_reads;
58 u8 packed_event_en;
53 unsigned int part_time; /* Units: ms */ 59 unsigned int part_time; /* Units: ms */
54 unsigned int sa_timeout; /* Units: 100ns */ 60 unsigned int sa_timeout; /* Units: 100ns */
61 unsigned int generic_cmd6_time; /* Units: 10ms */
62 unsigned int power_off_longtime; /* Units: ms */
55 unsigned int hs_max_dtr; 63 unsigned int hs_max_dtr;
56 unsigned int sectors; 64 unsigned int sectors;
57 unsigned int card_type; 65 unsigned int card_type;
@@ -64,10 +72,15 @@ struct mmc_ext_csd {
64 unsigned long long enhanced_area_offset; /* Units: Byte */ 72 unsigned long long enhanced_area_offset; /* Units: Byte */
65 unsigned int enhanced_area_size; /* Units: KB */ 73 unsigned int enhanced_area_size; /* Units: KB */
66 unsigned int boot_size; /* in bytes */ 74 unsigned int boot_size; /* in bytes */
75 unsigned int cache_size; /* Units: KB */
76 bool hpi_en; /* HPI enablebit */
77 bool hpi; /* HPI support bit */
78 unsigned int hpi_cmd; /* cmd used as HPI */
67 u8 raw_partition_support; /* 160 */ 79 u8 raw_partition_support; /* 160 */
68 u8 raw_erased_mem_count; /* 181 */ 80 u8 raw_erased_mem_count; /* 181 */
69 u8 raw_ext_csd_structure; /* 194 */ 81 u8 raw_ext_csd_structure; /* 194 */
70 u8 raw_card_type; /* 196 */ 82 u8 raw_card_type; /* 196 */
83 u8 out_of_int_time; /* 198 */
71 u8 raw_s_a_timeout; /* 217 */ 84 u8 raw_s_a_timeout; /* 217 */
72 u8 raw_hc_erase_gap_size; /* 221 */ 85 u8 raw_hc_erase_gap_size; /* 221 */
73 u8 raw_erase_timeout_mult; /* 223 */ 86 u8 raw_erase_timeout_mult; /* 223 */
@@ -77,6 +90,9 @@ struct mmc_ext_csd {
77 u8 raw_sec_feature_support;/* 231 */ 90 u8 raw_sec_feature_support;/* 231 */
78 u8 raw_trim_mult; /* 232 */ 91 u8 raw_trim_mult; /* 232 */
79 u8 raw_sectors[4]; /* 212 - 4 bytes */ 92 u8 raw_sectors[4]; /* 212 - 4 bytes */
93
94 unsigned int feature_support;
95#define MMC_DISCARD_FEATURE BIT(0) /* CMD38 feature */
80}; 96};
81 97
82struct sd_scr { 98struct sd_scr {
@@ -177,6 +193,8 @@ struct mmc_card {
177#define MMC_STATE_HIGHSPEED_DDR (1<<4) /* card is in high speed mode */ 193#define MMC_STATE_HIGHSPEED_DDR (1<<4) /* card is in high speed mode */
178#define MMC_STATE_ULTRAHIGHSPEED (1<<5) /* card is in ultra high speed mode */ 194#define MMC_STATE_ULTRAHIGHSPEED (1<<5) /* card is in ultra high speed mode */
179#define MMC_CARD_SDXC (1<<6) /* card is SDXC */ 195#define MMC_CARD_SDXC (1<<6) /* card is SDXC */
196#define MMC_CARD_REMOVED (1<<7) /* card has been removed */
197#define MMC_STATE_HIGHSPEED_200 (1<<8) /* card is in HS200 mode */
180 unsigned int quirks; /* card quirks */ 198 unsigned int quirks; /* card quirks */
181#define MMC_QUIRK_LENIENT_FN0 (1<<0) /* allow SDIO FN0 writes outside of the VS CCCR range */ 199#define MMC_QUIRK_LENIENT_FN0 (1<<0) /* allow SDIO FN0 writes outside of the VS CCCR range */
182#define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1) /* use func->cur_blksize */ 200#define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1) /* use func->cur_blksize */
@@ -189,6 +207,12 @@ struct mmc_card {
189#define MMC_QUIRK_INAND_CMD38 (1<<6) /* iNAND devices have broken CMD38 */ 207#define MMC_QUIRK_INAND_CMD38 (1<<6) /* iNAND devices have broken CMD38 */
190#define MMC_QUIRK_BLK_NO_CMD23 (1<<7) /* Avoid CMD23 for regular multiblock */ 208#define MMC_QUIRK_BLK_NO_CMD23 (1<<7) /* Avoid CMD23 for regular multiblock */
191 209
210 unsigned int poweroff_notify_state; /* eMMC4.5 notify feature */
211#define MMC_NO_POWER_NOTIFICATION 0
212#define MMC_POWERED_ON 1
213#define MMC_POWEROFF_SHORT 2
214#define MMC_POWEROFF_LONG 3
215
192 unsigned int erase_size; /* erase size in sectors */ 216 unsigned int erase_size; /* erase size in sectors */
193 unsigned int erase_shift; /* if erase unit is power 2 */ 217 unsigned int erase_shift; /* if erase unit is power 2 */
194 unsigned int pref_erase; /* in sectors */ 218 unsigned int pref_erase; /* in sectors */
@@ -310,18 +334,24 @@ static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data)
310#define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT) 334#define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT)
311#define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY) 335#define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY)
312#define mmc_card_highspeed(c) ((c)->state & MMC_STATE_HIGHSPEED) 336#define mmc_card_highspeed(c) ((c)->state & MMC_STATE_HIGHSPEED)
337#define mmc_card_hs200(c) ((c)->state & MMC_STATE_HIGHSPEED_200)
313#define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR) 338#define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR)
314#define mmc_card_ddr_mode(c) ((c)->state & MMC_STATE_HIGHSPEED_DDR) 339#define mmc_card_ddr_mode(c) ((c)->state & MMC_STATE_HIGHSPEED_DDR)
315#define mmc_sd_card_uhs(c) ((c)->state & MMC_STATE_ULTRAHIGHSPEED) 340#define mmc_card_uhs(c) ((c)->state & MMC_STATE_ULTRAHIGHSPEED)
341#define mmc_sd_card_uhs(c) ((c)->state & MMC_STATE_ULTRAHIGHSPEED)
316#define mmc_card_ext_capacity(c) ((c)->state & MMC_CARD_SDXC) 342#define mmc_card_ext_capacity(c) ((c)->state & MMC_CARD_SDXC)
343#define mmc_card_removed(c) ((c) && ((c)->state & MMC_CARD_REMOVED))
317 344
318#define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT) 345#define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT)
319#define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY) 346#define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY)
320#define mmc_card_set_highspeed(c) ((c)->state |= MMC_STATE_HIGHSPEED) 347#define mmc_card_set_highspeed(c) ((c)->state |= MMC_STATE_HIGHSPEED)
348#define mmc_card_set_hs200(c) ((c)->state |= MMC_STATE_HIGHSPEED_200)
321#define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR) 349#define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR)
322#define mmc_card_set_ddr_mode(c) ((c)->state |= MMC_STATE_HIGHSPEED_DDR) 350#define mmc_card_set_ddr_mode(c) ((c)->state |= MMC_STATE_HIGHSPEED_DDR)
351#define mmc_card_set_uhs(c) ((c)->state |= MMC_STATE_ULTRAHIGHSPEED)
323#define mmc_sd_card_set_uhs(c) ((c)->state |= MMC_STATE_ULTRAHIGHSPEED) 352#define mmc_sd_card_set_uhs(c) ((c)->state |= MMC_STATE_ULTRAHIGHSPEED)
324#define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC) 353#define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC)
354#define mmc_card_set_removed(c) ((c)->state |= MMC_CARD_REMOVED)
325 355
326/* 356/*
327 * Quirk add/remove for MMC products. 357 * Quirk add/remove for MMC products.
diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h
index b6718e549a5..3d055c36e6a 100644
--- a/include/linux/mmc/core.h
+++ b/include/linux/mmc/core.h
@@ -18,6 +18,8 @@ struct mmc_request;
18struct mmc_command { 18struct mmc_command {
19 u32 opcode; 19 u32 opcode;
20 u32 arg; 20 u32 arg;
21#define MMC_CMD23_ARG_REL_WR (1 << 31)
22#define MMC_CMD23_ARG_PACKED ((0 << 31) | (1 << 30))
21 u32 resp[4]; 23 u32 resp[4];
22 unsigned int flags; /* expected response type */ 24 unsigned int flags; /* expected response type */
23#define MMC_RSP_PRESENT (1 << 0) 25#define MMC_RSP_PRESENT (1 << 0)
@@ -117,6 +119,7 @@ struct mmc_data {
117 119
118 unsigned int sg_len; /* size of scatter list */ 120 unsigned int sg_len; /* size of scatter list */
119 struct scatterlist *sg; /* I/O scatter list */ 121 struct scatterlist *sg; /* I/O scatter list */
122 s32 host_cookie; /* host private data */
120}; 123};
121 124
122struct mmc_request { 125struct mmc_request {
@@ -125,23 +128,29 @@ struct mmc_request {
125 struct mmc_data *data; 128 struct mmc_data *data;
126 struct mmc_command *stop; 129 struct mmc_command *stop;
127 130
128 void *done_data; /* completion data */ 131 struct completion completion;
129 void (*done)(struct mmc_request *);/* completion function */ 132 void (*done)(struct mmc_request *);/* completion function */
130}; 133};
131 134
132struct mmc_host; 135struct mmc_host;
133struct mmc_card; 136struct mmc_card;
137struct mmc_async_req;
134 138
139extern struct mmc_async_req *mmc_start_req(struct mmc_host *,
140 struct mmc_async_req *, int *);
141extern int mmc_interrupt_hpi(struct mmc_card *);
135extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *); 142extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
136extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int); 143extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
137extern int mmc_app_cmd(struct mmc_host *, struct mmc_card *); 144extern int mmc_app_cmd(struct mmc_host *, struct mmc_card *);
138extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *, 145extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *,
139 struct mmc_command *, int); 146 struct mmc_command *, int);
140extern int mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int); 147extern int mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int);
148extern int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd);
141 149
142#define MMC_ERASE_ARG 0x00000000 150#define MMC_ERASE_ARG 0x00000000
143#define MMC_SECURE_ERASE_ARG 0x80000000 151#define MMC_SECURE_ERASE_ARG 0x80000000
144#define MMC_TRIM_ARG 0x00000001 152#define MMC_TRIM_ARG 0x00000001
153#define MMC_DISCARD_ARG 0x00000003
145#define MMC_SECURE_TRIM1_ARG 0x80000001 154#define MMC_SECURE_TRIM1_ARG 0x80000001
146#define MMC_SECURE_TRIM2_ARG 0x80008000 155#define MMC_SECURE_TRIM2_ARG 0x80008000
147 156
@@ -152,11 +161,17 @@ extern int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr,
152 unsigned int arg); 161 unsigned int arg);
153extern int mmc_can_erase(struct mmc_card *card); 162extern int mmc_can_erase(struct mmc_card *card);
154extern int mmc_can_trim(struct mmc_card *card); 163extern int mmc_can_trim(struct mmc_card *card);
164extern int mmc_can_discard(struct mmc_card *card);
165extern int mmc_can_sanitize(struct mmc_card *card);
155extern int mmc_can_secure_erase_trim(struct mmc_card *card); 166extern int mmc_can_secure_erase_trim(struct mmc_card *card);
156extern int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from, 167extern int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from,
157 unsigned int nr); 168 unsigned int nr);
169extern unsigned int mmc_calc_max_discard(struct mmc_card *card);
158 170
159extern int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen); 171extern int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen);
172extern int mmc_hw_reset(struct mmc_host *host);
173extern int mmc_hw_reset_check(struct mmc_host *host);
174extern int mmc_can_reset(struct mmc_card *card);
160 175
161extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *); 176extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *);
162extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int); 177extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int);
@@ -166,6 +181,10 @@ extern void mmc_release_host(struct mmc_host *host);
166extern void mmc_do_release_host(struct mmc_host *host); 181extern void mmc_do_release_host(struct mmc_host *host);
167extern int mmc_try_claim_host(struct mmc_host *host); 182extern int mmc_try_claim_host(struct mmc_host *host);
168 183
184extern int mmc_flush_cache(struct mmc_card *);
185
186extern int mmc_detect_card_removed(struct mmc_host *host);
187
169/** 188/**
170 * mmc_claim_host - exclusively claim a host 189 * mmc_claim_host - exclusively claim a host
171 * @host: mmc host to claim 190 * @host: mmc host to claim
diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h
index bdd7ceeb99e..99df3199ccb 100644
--- a/include/linux/mmc/dw_mmc.h
+++ b/include/linux/mmc/dw_mmc.h
@@ -14,6 +14,8 @@
14#ifndef _LINUX_MMC_DW_MMC_H_ 14#ifndef _LINUX_MMC_DW_MMC_H_
15#define _LINUX_MMC_DW_MMC_H_ 15#define _LINUX_MMC_DW_MMC_H_
16 16
17#include <linux/scatterlist.h>
18
17#define MAX_MCI_SLOTS 2 19#define MAX_MCI_SLOTS 2
18 20
19enum dw_mci_state { 21enum dw_mci_state {
@@ -35,6 +37,11 @@ enum {
35 37
36struct mmc_data; 38struct mmc_data;
37 39
40struct dw_mci_next {
41 unsigned int sg_len;
42 s32 cookie;
43};
44
38/** 45/**
39 * struct dw_mci - MMC controller state shared between all slots 46 * struct dw_mci - MMC controller state shared between all slots
40 * @lock: Spinlock protecting the queue and associated data. 47 * @lock: Spinlock protecting the queue and associated data.
@@ -74,6 +81,7 @@ struct mmc_data;
74 * @pdev: Platform device associated with the MMC controller. 81 * @pdev: Platform device associated with the MMC controller.
75 * @pdata: Platform data associated with the MMC controller. 82 * @pdata: Platform data associated with the MMC controller.
76 * @slot: Slots sharing this MMC controller. 83 * @slot: Slots sharing this MMC controller.
84 * @fifo_depth: depth of FIFO.
77 * @data_shift: log2 of FIFO item size. 85 * @data_shift: log2 of FIFO item size.
78 * @push_data: Pointer to FIFO push function. 86 * @push_data: Pointer to FIFO push function.
79 * @pull_data: Pointer to FIFO pull function. 87 * @pull_data: Pointer to FIFO pull function.
@@ -108,19 +116,24 @@ struct dw_mci {
108 void __iomem *regs; 116 void __iomem *regs;
109 117
110 struct scatterlist *sg; 118 struct scatterlist *sg;
111 unsigned int pio_offset; 119 struct sg_mapping_iter sg_miter;
112 120
113 struct dw_mci_slot *cur_slot; 121 struct dw_mci_slot *cur_slot;
114 struct mmc_request *mrq; 122 struct mmc_request *mrq;
115 struct mmc_command *cmd; 123 struct mmc_command *cmd;
116 struct mmc_data *data; 124 struct mmc_data *data;
125 struct clk *hclk;
126 struct clk *cclk;
127 bool prv_err;
117 128
118 /* DMA interface members*/ 129 /* DMA interface members*/
119 int use_dma; 130 int use_dma;
131 int using_dma;
120 132
121 dma_addr_t sg_dma; 133 dma_addr_t sg_dma;
122 void *sg_cpu; 134 void *sg_cpu;
123 struct dw_mci_dma_ops *dma_ops; 135 struct dw_mci_dma_ops *dma_ops;
136 unsigned int buf_size;
124#ifdef CONFIG_MMC_DW_IDMAC 137#ifdef CONFIG_MMC_DW_IDMAC
125 unsigned int ring_size; 138 unsigned int ring_size;
126#else 139#else
@@ -141,11 +154,14 @@ struct dw_mci {
141 u32 current_speed; 154 u32 current_speed;
142 u32 num_slots; 155 u32 num_slots;
143 u32 fifoth_val; 156 u32 fifoth_val;
157 u16 verid;
158 u16 data_offset;
144 struct platform_device *pdev; 159 struct platform_device *pdev;
145 struct dw_mci_board *pdata; 160 struct dw_mci_board *pdata;
146 struct dw_mci_slot *slot[MAX_MCI_SLOTS]; 161 struct dw_mci_slot *slot[MAX_MCI_SLOTS];
147 162
148 /* FIFO push and pull */ 163 /* FIFO push and pull */
164 int fifo_depth;
149 int data_shift; 165 int data_shift;
150 void (*push_data)(struct dw_mci *host, void *buf, int cnt); 166 void (*push_data)(struct dw_mci *host, void *buf, int cnt);
151 void (*pull_data)(struct dw_mci *host, void *buf, int cnt); 167 void (*pull_data)(struct dw_mci *host, void *buf, int cnt);
@@ -154,6 +170,7 @@ struct dw_mci {
154 u32 quirks; 170 u32 quirks;
155 171
156 struct regulator *vmmc; /* Power regulator */ 172 struct regulator *vmmc; /* Power regulator */
173 struct dw_mci_next next_data;
157}; 174};
158 175
159/* DMA ops for Internal/External DMAC interface */ 176/* DMA ops for Internal/External DMAC interface */
@@ -177,6 +194,13 @@ struct dw_mci_dma_ops {
177/* Unreliable card detection */ 194/* Unreliable card detection */
178#define DW_MCI_QUIRK_BROKEN_CARD_DETECTION BIT(3) 195#define DW_MCI_QUIRK_BROKEN_CARD_DETECTION BIT(3)
179 196
197enum dw_mci_cd_types {
198 DW_MCI_CD_INTERNAL, /* use mmc internal CD line */
199 DW_MCI_CD_EXTERNAL, /* use external callback */
200 DW_MCI_CD_GPIO, /* use external gpio pin for CD line */
201 DW_MCI_CD_NONE, /* no CD line, use polling to detect card */
202 DW_MCI_CD_PERMANENT, /* no CD line, card permanently wired to host */
203};
180 204
181struct dma_pdata; 205struct dma_pdata;
182 206
@@ -196,15 +220,49 @@ struct dw_mci_board {
196 unsigned int bus_hz; /* Bus speed */ 220 unsigned int bus_hz; /* Bus speed */
197 221
198 unsigned int caps; /* Capabilities */ 222 unsigned int caps; /* Capabilities */
223 unsigned int caps2; /* More capabilities */
224 /*
225 * Override fifo depth. If 0, autodetect it from the FIFOTH register,
226 * but note that this may not be reliable after a bootloader has used
227 * it.
228 */
229 unsigned int fifo_depth;
230
231 unsigned int buf_size; /* Buffer size */
199 232
200 /* delay in mS before detecting cards after interrupt */ 233 /* delay in mS before detecting cards after interrupt */
201 u32 detect_delay_ms; 234 u32 detect_delay_ms;
202 235
236 char *hclk_name;
237 char *cclk_name;
238
203 int (*init)(u32 slot_id, irq_handler_t , void *); 239 int (*init)(u32 slot_id, irq_handler_t , void *);
204 int (*get_ro)(u32 slot_id); 240 int (*get_ro)(u32 slot_id);
205 int (*get_cd)(u32 slot_id); 241 int (*get_cd)(u32 slot_id);
206 int (*get_ocr)(u32 slot_id); 242 int (*get_ocr)(u32 slot_id);
207 int (*get_bus_wd)(u32 slot_id); 243 int (*get_bus_wd)(u32 slot_id);
244 void (*cfg_gpio)(int width);
245 void (*set_io_timing)(void *data, unsigned char timing);
246
247 /* Phase Shift Value */
248 unsigned int sdr_timing;
249 unsigned int ddr_timing;
250
251 /* cd_type: Type of Card Detection method (see cd_types enum above) */
252
253 enum dw_mci_cd_types cd_type;
254
255 /* ext_cd_cleanup: Cleanup external card detect subsystem.
256 * ext_cd_init: Initialize external card detect subsystem.
257 * notify_func argument is a callback to the dwmci driver
258 * that triggers the card detection event. Callback arguments:
259 * dev is pointer to platform device of the host controller,
260 * state is new state of the card (0 - removed, 1 - inserted).
261 */
262
263 int (*ext_cd_init)(void (*notify_func)(struct platform_device *, int state));
264 int (*ext_cd_cleanup)(void (*notify_func)(struct platform_device *,int state));
265
208 /* 266 /*
209 * Enable power to selected slot and set voltage to desired level. 267 * Enable power to selected slot and set voltage to desired level.
210 * Voltage levels are specified using MMC_VDD_xxx defines defined 268 * Voltage levels are specified using MMC_VDD_xxx defines defined
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index f8d1e741d80..56d81029b48 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -12,6 +12,7 @@
12 12
13#include <linux/leds.h> 13#include <linux/leds.h>
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/wakelock.h>
15 16
16#include <linux/mmc/core.h> 17#include <linux/mmc/core.h>
17#include <linux/mmc/pm.h> 18#include <linux/mmc/pm.h>
@@ -55,12 +56,15 @@ struct mmc_ios {
55#define MMC_TIMING_UHS_SDR50 3 56#define MMC_TIMING_UHS_SDR50 3
56#define MMC_TIMING_UHS_SDR104 4 57#define MMC_TIMING_UHS_SDR104 4
57#define MMC_TIMING_UHS_DDR50 5 58#define MMC_TIMING_UHS_DDR50 5
59#define MMC_TIMING_MMC_HS200 6
58 60
59 unsigned char ddr; /* dual data rate used */ 61 unsigned char ddr; /* dual data rate used */
60 62
61#define MMC_SDR_MODE 0 63#define MMC_SDR_MODE 0
62#define MMC_1_2V_DDR_MODE 1 64#define MMC_1_2V_DDR_MODE 1
63#define MMC_1_8V_DDR_MODE 2 65#define MMC_1_8V_DDR_MODE 2
66#define MMC_1_2V_SDR_MODE 3
67#define MMC_1_8V_SDR_MODE 4
64 68
65 unsigned char signal_voltage; /* signalling voltage (1.8V or 3.3V) */ 69 unsigned char signal_voltage; /* signalling voltage (1.8V or 3.3V) */
66 70
@@ -106,6 +110,15 @@ struct mmc_host_ops {
106 */ 110 */
107 int (*enable)(struct mmc_host *host); 111 int (*enable)(struct mmc_host *host);
108 int (*disable)(struct mmc_host *host, int lazy); 112 int (*disable)(struct mmc_host *host, int lazy);
113 /*
114 * It is optional for the host to implement pre_req and post_req in
115 * order to support double buffering of requests (prepare one
116 * request while another request is active).
117 */
118 void (*post_req)(struct mmc_host *host, struct mmc_request *req,
119 int err);
120 void (*pre_req)(struct mmc_host *host, struct mmc_request *req,
121 bool is_first_req);
109 void (*request)(struct mmc_host *host, struct mmc_request *req); 122 void (*request)(struct mmc_host *host, struct mmc_request *req);
110 /* 123 /*
111 * Avoid calling these three functions too often or in a "fast path", 124 * Avoid calling these three functions too often or in a "fast path",
@@ -137,13 +150,27 @@ struct mmc_host_ops {
137 void (*init_card)(struct mmc_host *host, struct mmc_card *card); 150 void (*init_card)(struct mmc_host *host, struct mmc_card *card);
138 151
139 int (*start_signal_voltage_switch)(struct mmc_host *host, struct mmc_ios *ios); 152 int (*start_signal_voltage_switch)(struct mmc_host *host, struct mmc_ios *ios);
140 int (*execute_tuning)(struct mmc_host *host); 153
154 /* The tuning command opcode value is different for SD and eMMC cards */
155 int (*execute_tuning)(struct mmc_host *host, u32 opcode);
141 void (*enable_preset_value)(struct mmc_host *host, bool enable); 156 void (*enable_preset_value)(struct mmc_host *host, bool enable);
157 int (*select_drive_strength)(unsigned int max_dtr, int host_drv, int card_drv);
158 void (*hw_reset)(struct mmc_host *host);
142}; 159};
143 160
144struct mmc_card; 161struct mmc_card;
145struct device; 162struct device;
146 163
164struct mmc_async_req {
165 /* active mmc request */
166 struct mmc_request *mrq;
167 /*
168 * Check error status of completed mmc request.
169 * Returns 0 if success otherwise non zero.
170 */
171 int (*err_check) (struct mmc_card *, struct mmc_async_req *);
172};
173
147struct mmc_host { 174struct mmc_host {
148 struct device *parent; 175 struct device *parent;
149 struct device class_dev; 176 struct device class_dev;
@@ -211,17 +238,40 @@ struct mmc_host {
211#define MMC_CAP_MAX_CURRENT_600 (1 << 28) /* Host max current limit is 600mA */ 238#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 */ 239#define MMC_CAP_MAX_CURRENT_800 (1 << 29) /* Host max current limit is 800mA */
213#define MMC_CAP_CMD23 (1 << 30) /* CMD23 supported. */ 240#define MMC_CAP_CMD23 (1 << 30) /* CMD23 supported. */
241#define MMC_CAP_HW_RESET (1 << 31) /* Hardware reset */
242
243 unsigned int caps2; /* More host capabilities */
244
245#define MMC_CAP2_BOOTPART_NOACC (1 << 0) /* Boot partition no access */
246#define MMC_CAP2_CACHE_CTRL (1 << 1) /* Allow cache control */
247#define MMC_CAP2_POWEROFF_NOTIFY (1 << 2) /* Notify poweroff supported */
248#define MMC_CAP2_PACKED_RD (1 << 3) /* Allow packed read */
249#define MMC_CAP2_PACKED_WR (1 << 4) /* Allow packed write */
250#define MMC_CAP2_PACKED_CMD (MMC_CAP2_PACKED_RD | \
251 MMC_CAP2_PACKED_WR) /* Allow packed commands */
252#define MMC_CAP2_NO_MULTI_READ (1 << 5) /* Multiblock reads don't work */
253#define MMC_CAP2_NO_SLEEP_CMD (1 << 6) /* Don't allow sleep command */
254#define MMC_CAP2_HS200_1_8V_SDR (1 << 7) /* can support */
255#define MMC_CAP2_HS200_1_2V_SDR (1 << 8) /* can support */
256#define MMC_CAP2_HS200 (MMC_CAP2_HS200_1_8V_SDR | \
257 MMC_CAP2_HS200_1_2V_SDR)
214 258
215 mmc_pm_flag_t pm_caps; /* supported pm features */ 259 mmc_pm_flag_t pm_caps; /* supported pm features */
260 unsigned int power_notify_type;
261#define MMC_HOST_PW_NOTIFY_NONE 0
262#define MMC_HOST_PW_NOTIFY_SHORT 1
263#define MMC_HOST_PW_NOTIFY_LONG 2
216 264
217#ifdef CONFIG_MMC_CLKGATE 265#ifdef CONFIG_MMC_CLKGATE
218 int clk_requests; /* internal reference counter */ 266 int clk_requests; /* internal reference counter */
219 unsigned int clk_delay; /* number of MCI clk hold cycles */ 267 unsigned int clk_delay; /* number of MCI clk hold cycles */
220 bool clk_gated; /* clock gated */ 268 bool clk_gated; /* clock gated */
221 struct work_struct clk_gate_work; /* delayed clock gate */ 269 struct delayed_work clk_gate_work; /* delayed clock gate */
222 unsigned int clk_old; /* old clock value cache */ 270 unsigned int clk_old; /* old clock value cache */
223 spinlock_t clk_lock; /* lock for clk fields */ 271 spinlock_t clk_lock; /* lock for clk fields */
224 struct mutex clk_gate_mutex; /* mutex for clock gating */ 272 struct mutex clk_gate_mutex; /* mutex for clock gating */
273 struct device_attribute clkgate_delay_attr;
274 unsigned long clkgate_delay;
225#endif 275#endif
226 276
227 /* host specific block data */ 277 /* host specific block data */
@@ -231,6 +281,7 @@ struct mmc_host {
231 unsigned int max_req_size; /* maximum number of bytes in one req */ 281 unsigned int max_req_size; /* maximum number of bytes in one req */
232 unsigned int max_blk_size; /* maximum size of one mmc block */ 282 unsigned int max_blk_size; /* maximum size of one mmc block */
233 unsigned int max_blk_count; /* maximum number of blocks in one req */ 283 unsigned int max_blk_count; /* maximum number of blocks in one req */
284 unsigned int max_discard_to; /* max. discard timeout in ms */
234 285
235 /* private data */ 286 /* private data */
236 spinlock_t lock; /* lock for claim and bus ops */ 287 spinlock_t lock; /* lock for claim and bus ops */
@@ -245,6 +296,22 @@ struct mmc_host {
245#ifdef CONFIG_MMC_DEBUG 296#ifdef CONFIG_MMC_DEBUG
246 unsigned int removed:1; /* host is being removed */ 297 unsigned int removed:1; /* host is being removed */
247#endif 298#endif
299 unsigned int state; /* card slot state for SD */
300#define MMC_SD_STATE_PRESENT (1<<0) /* present state for SD */
301#define MMC_SD_INIT_STATUS (1<<1) /* present state for SD */
302#define MMC_SD_PREV_STATUS (1<<2) /* present state for SD */
303
304#define mmc_host_sd_present(h) ((h)->state & MMC_SD_STATE_PRESENT)
305#define mmc_host_sd_set_present(h) ((h)->state |= MMC_SD_STATE_PRESENT)
306#define mmc_host_sd_clear_present(h) ((h)->state &= ~MMC_SD_STATE_PRESENT)
307
308#define mmc_host_sd_init_stat(h) ((h)->state & MMC_SD_INIT_STATUS)
309#define mmc_host_sd_set_init_stat(h) ((h)->state |= MMC_SD_INIT_STATUS)
310#define mmc_host_sd_clear_init_stat(h) ((h)->state &= ~MMC_SD_INIT_STATUS)
311
312#define mmc_host_sd_prev_stat(h) ((h)->state & MMC_SD_PREV_STATUS)
313#define mmc_host_sd_set_prev_stat(h) ((h)->state |= MMC_SD_PREV_STATUS)
314#define mmc_host_sd_clear_prev_stat(h) ((h)->state &= ~MMC_SD_PREV_STATUS)
248 315
249 /* Only used with MMC_CAP_DISABLE */ 316 /* Only used with MMC_CAP_DISABLE */
250 int enabled; /* host is enabled */ 317 int enabled; /* host is enabled */
@@ -261,10 +328,16 @@ struct mmc_host {
261 int claim_cnt; /* "claim" nesting count */ 328 int claim_cnt; /* "claim" nesting count */
262 329
263 struct delayed_work detect; 330 struct delayed_work detect;
331 int detect_change; /* card detect flag */
332 struct wake_lock detect_wake_lock;
264 333
265 const struct mmc_bus_ops *bus_ops; /* current bus driver */ 334 const struct mmc_bus_ops *bus_ops; /* current bus driver */
266 unsigned int bus_refs; /* reference counter */ 335 unsigned int bus_refs; /* reference counter */
267 336
337 unsigned int bus_resume_flags;
338#define MMC_BUSRESUME_MANUAL_RESUME (1 << 0)
339#define MMC_BUSRESUME_NEEDS_RESUME (1 << 1)
340
268 unsigned int sdio_irqs; 341 unsigned int sdio_irqs;
269 struct task_struct *sdio_irq_thread; 342 struct task_struct *sdio_irq_thread;
270 bool sdio_irq_pending; 343 bool sdio_irq_pending;
@@ -282,6 +355,17 @@ struct mmc_host {
282 355
283 struct dentry *debugfs_root; 356 struct dentry *debugfs_root;
284 357
358#ifdef CONFIG_MMC_EMBEDDED_SDIO
359 struct {
360 struct sdio_cis *cis;
361 struct sdio_cccr *cccr;
362 struct sdio_embedded_func *funcs;
363 int num_funcs;
364 } embedded_sdio_data;
365#endif
366
367 struct mmc_async_req *areq; /* active async req */
368
285 unsigned long private[0] ____cacheline_aligned; 369 unsigned long private[0] ____cacheline_aligned;
286}; 370};
287 371
@@ -290,6 +374,14 @@ extern int mmc_add_host(struct mmc_host *);
290extern void mmc_remove_host(struct mmc_host *); 374extern void mmc_remove_host(struct mmc_host *);
291extern void mmc_free_host(struct mmc_host *); 375extern void mmc_free_host(struct mmc_host *);
292 376
377#ifdef CONFIG_MMC_EMBEDDED_SDIO
378extern void mmc_set_embedded_sdio_data(struct mmc_host *host,
379 struct sdio_cis *cis,
380 struct sdio_cccr *cccr,
381 struct sdio_embedded_func *funcs,
382 int num_funcs);
383#endif
384
293static inline void *mmc_priv(struct mmc_host *host) 385static inline void *mmc_priv(struct mmc_host *host)
294{ 386{
295 return (void *)host->private; 387 return (void *)host->private;
@@ -300,6 +392,18 @@ static inline void *mmc_priv(struct mmc_host *host)
300#define mmc_dev(x) ((x)->parent) 392#define mmc_dev(x) ((x)->parent)
301#define mmc_classdev(x) (&(x)->class_dev) 393#define mmc_classdev(x) (&(x)->class_dev)
302#define mmc_hostname(x) (dev_name(&(x)->class_dev)) 394#define mmc_hostname(x) (dev_name(&(x)->class_dev))
395#define mmc_bus_needs_resume(host) ((host)->bus_resume_flags & MMC_BUSRESUME_NEEDS_RESUME)
396#define mmc_bus_manual_resume(host) ((host)->bus_resume_flags & MMC_BUSRESUME_MANUAL_RESUME)
397
398static inline void mmc_set_bus_resume_policy(struct mmc_host *host, int manual)
399{
400 if (manual)
401 host->bus_resume_flags |= MMC_BUSRESUME_MANUAL_RESUME;
402 else
403 host->bus_resume_flags &= ~MMC_BUSRESUME_MANUAL_RESUME;
404}
405
406extern int mmc_resume_bus(struct mmc_host *host);
303 407
304extern int mmc_suspend_host(struct mmc_host *); 408extern int mmc_suspend_host(struct mmc_host *);
305extern int mmc_resume_host(struct mmc_host *); 409extern int mmc_resume_host(struct mmc_host *);
@@ -310,6 +414,8 @@ extern int mmc_power_restore_host(struct mmc_host *host);
310extern void mmc_detect_change(struct mmc_host *, unsigned long delay); 414extern void mmc_detect_change(struct mmc_host *, unsigned long delay);
311extern void mmc_request_done(struct mmc_host *, struct mmc_request *); 415extern void mmc_request_done(struct mmc_host *, struct mmc_request *);
312 416
417extern int mmc_cache_ctrl(struct mmc_host *, u8);
418
313static inline void mmc_signal_sdio_irq(struct mmc_host *host) 419static inline void mmc_signal_sdio_irq(struct mmc_host *host)
314{ 420{
315 host->ops->enable_sdio_irq(host, 0); 421 host->ops->enable_sdio_irq(host, 0);
@@ -375,5 +481,29 @@ static inline int mmc_host_cmd23(struct mmc_host *host)
375{ 481{
376 return host->caps & MMC_CAP_CMD23; 482 return host->caps & MMC_CAP_CMD23;
377} 483}
378#endif
379 484
485static inline int mmc_boot_partition_access(struct mmc_host *host)
486{
487 return !(host->caps2 & MMC_CAP2_BOOTPART_NOACC);
488}
489
490#ifdef CONFIG_MMC_CLKGATE
491void mmc_host_clk_hold(struct mmc_host *host);
492void mmc_host_clk_release(struct mmc_host *host);
493unsigned int mmc_host_clk_rate(struct mmc_host *host);
494
495#else
496static inline void mmc_host_clk_hold(struct mmc_host *host)
497{
498}
499
500static inline void mmc_host_clk_release(struct mmc_host *host)
501{
502}
503
504static inline unsigned int mmc_host_clk_rate(struct mmc_host *host)
505{
506 return host->ios.clock;
507}
508#endif
509#endif /* LINUX_MMC_HOST_H */
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index ac26a685cca..df020caf560 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -51,6 +51,7 @@
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#define MMC_SEND_TUNING_BLOCK 19 /* adtc R1 */
54#define MMC_SEND_TUNING_BLOCK_HS200 21 /* adtc R1 */
54 55
55 /* class 3 */ 56 /* class 3 */
56#define MMC_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */ 57#define MMC_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */
@@ -138,8 +139,19 @@ static inline bool mmc_op_multi(u32 opcode)
138#define R1_CURRENT_STATE(x) ((x & 0x00001E00) >> 9) /* sx, b (4 bits) */ 139#define R1_CURRENT_STATE(x) ((x & 0x00001E00) >> 9) /* sx, b (4 bits) */
139#define R1_READY_FOR_DATA (1 << 8) /* sx, a */ 140#define R1_READY_FOR_DATA (1 << 8) /* sx, a */
140#define R1_SWITCH_ERROR (1 << 7) /* sx, c */ 141#define R1_SWITCH_ERROR (1 << 7) /* sx, c */
142#define R1_EXP_EVENT (1 << 6) /* sr, a */
141#define R1_APP_CMD (1 << 5) /* sr, c */ 143#define R1_APP_CMD (1 << 5) /* sr, c */
142 144
145#define R1_STATE_IDLE 0
146#define R1_STATE_READY 1
147#define R1_STATE_IDENT 2
148#define R1_STATE_STBY 3
149#define R1_STATE_TRAN 4
150#define R1_STATE_DATA 5
151#define R1_STATE_RCV 6
152#define R1_STATE_PRG 7
153#define R1_STATE_DIS 8
154
143/* 155/*
144 * MMC/SD in SPI mode reports R1 status always, and R2 for SEND_STATUS 156 * MMC/SD in SPI mode reports R1 status always, and R2 for SEND_STATUS
145 * R1 is the low order byte; R2 is the next highest byte, when present. 157 * R1 is the low order byte; R2 is the next highest byte, when present.
@@ -260,18 +272,35 @@ struct _mmc_csd {
260 * EXT_CSD fields 272 * EXT_CSD fields
261 */ 273 */
262 274
275#define EXT_CSD_FLUSH_CACHE 32 /* W */
276#define EXT_CSD_CACHE_CTRL 33 /* R/W */
277#define EXT_CSD_POWER_OFF_NOTIFICATION 34 /* R/W */
278#define EXT_CSD_PACKED_FAILURE_INDEX 35 /* RO */
279#define EXT_CSD_PACKED_CMD_STATUS 36 /* RO */
280#define EXT_CSD_EXP_EVENTS_STATUS 54 /* RO, 2 bytes */
281#define EXT_CSD_EXP_EVENTS_CTRL 56 /* R/W, 2 bytes */
263#define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */ 282#define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */
264#define EXT_CSD_PARTITION_SUPPORT 160 /* RO */ 283#define EXT_CSD_PARTITION_SUPPORT 160 /* RO */
284#define EXT_CSD_HPI_MGMT 161 /* R/W */
285#define EXT_CSD_RST_N_FUNCTION 162 /* R/W */
286#define EXT_CSD_SANITIZE_START 165 /* W */
265#define EXT_CSD_WR_REL_PARAM 166 /* RO */ 287#define EXT_CSD_WR_REL_PARAM 166 /* RO */
266#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ 288#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */
289#define EXT_CSD_BOOT_CONFIG_PROT 178 /* R/W */
267#define EXT_CSD_PART_CONFIG 179 /* R/W */ 290#define EXT_CSD_PART_CONFIG 179 /* R/W */
268#define EXT_CSD_ERASED_MEM_CONT 181 /* RO */ 291#define EXT_CSD_ERASED_MEM_CONT 181 /* RO */
269#define EXT_CSD_BUS_WIDTH 183 /* R/W */ 292#define EXT_CSD_BUS_WIDTH 183 /* R/W */
270#define EXT_CSD_HS_TIMING 185 /* R/W */ 293#define EXT_CSD_HS_TIMING 185 /* R/W */
294#define EXT_CSD_POWER_CLASS 187 /* R/W */
271#define EXT_CSD_REV 192 /* RO */ 295#define EXT_CSD_REV 192 /* RO */
272#define EXT_CSD_STRUCTURE 194 /* RO */ 296#define EXT_CSD_STRUCTURE 194 /* RO */
273#define EXT_CSD_CARD_TYPE 196 /* RO */ 297#define EXT_CSD_CARD_TYPE 196 /* RO */
298#define EXT_CSD_OUT_OF_INTERRUPT_TIME 198 /* RO */
274#define EXT_CSD_PART_SWITCH_TIME 199 /* RO */ 299#define EXT_CSD_PART_SWITCH_TIME 199 /* RO */
300#define EXT_CSD_PWR_CL_52_195 200 /* RO */
301#define EXT_CSD_PWR_CL_26_195 201 /* RO */
302#define EXT_CSD_PWR_CL_52_360 202 /* RO */
303#define EXT_CSD_PWR_CL_26_360 203 /* RO */
275#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ 304#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */
276#define EXT_CSD_S_A_TIMEOUT 217 /* RO */ 305#define EXT_CSD_S_A_TIMEOUT 217 /* RO */
277#define EXT_CSD_REL_WR_SEC_C 222 /* RO */ 306#define EXT_CSD_REL_WR_SEC_C 222 /* RO */
@@ -283,6 +312,16 @@ struct _mmc_csd {
283#define EXT_CSD_SEC_ERASE_MULT 230 /* RO */ 312#define EXT_CSD_SEC_ERASE_MULT 230 /* RO */
284#define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */ 313#define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */
285#define EXT_CSD_TRIM_MULT 232 /* RO */ 314#define EXT_CSD_TRIM_MULT 232 /* RO */
315#define EXT_CSD_PWR_CL_200_195 236 /* RO */
316#define EXT_CSD_PWR_CL_200_360 237 /* RO */
317#define EXT_CSD_PWR_CL_DDR_52_195 238 /* RO */
318#define EXT_CSD_PWR_CL_DDR_52_360 239 /* RO */
319#define EXT_CSD_POWER_OFF_LONG_TIME 247 /* RO */
320#define EXT_CSD_GENERIC_CMD6_TIME 248 /* RO */
321#define EXT_CSD_CACHE_SIZE 249 /* RO, 4 bytes */
322#define EXT_CSD_MAX_PACKED_WRITES 500 /* RO */
323#define EXT_CSD_MAX_PACKED_READS 501 /* RO */
324#define EXT_CSD_HPI_FEATURES 503 /* RO */
286 325
287/* 326/*
288 * EXT_CSD field definitions 327 * EXT_CSD field definitions
@@ -300,13 +339,76 @@ struct _mmc_csd {
300 339
301#define EXT_CSD_CARD_TYPE_26 (1<<0) /* Card can run at 26MHz */ 340#define EXT_CSD_CARD_TYPE_26 (1<<0) /* Card can run at 26MHz */
302#define EXT_CSD_CARD_TYPE_52 (1<<1) /* Card can run at 52MHz */ 341#define EXT_CSD_CARD_TYPE_52 (1<<1) /* Card can run at 52MHz */
303#define EXT_CSD_CARD_TYPE_MASK 0xF /* Mask out reserved bits */ 342#define EXT_CSD_CARD_TYPE_MASK 0x3F /* Mask out reserved bits */
304#define EXT_CSD_CARD_TYPE_DDR_1_8V (1<<2) /* Card can run at 52MHz */ 343#define EXT_CSD_CARD_TYPE_DDR_1_8V (1<<2) /* Card can run at 52MHz */
305 /* DDR mode @1.8V or 3V I/O */ 344 /* DDR mode @1.8V or 3V I/O */
306#define EXT_CSD_CARD_TYPE_DDR_1_2V (1<<3) /* Card can run at 52MHz */ 345#define EXT_CSD_CARD_TYPE_DDR_1_2V (1<<3) /* Card can run at 52MHz */
307 /* DDR mode @1.2V I/O */ 346 /* DDR mode @1.2V I/O */
308#define EXT_CSD_CARD_TYPE_DDR_52 (EXT_CSD_CARD_TYPE_DDR_1_8V \ 347#define EXT_CSD_CARD_TYPE_DDR_52 (EXT_CSD_CARD_TYPE_DDR_1_8V \
309 | EXT_CSD_CARD_TYPE_DDR_1_2V) 348 | EXT_CSD_CARD_TYPE_DDR_1_2V)
349#define EXT_CSD_CARD_TYPE_SDR_1_8V (1<<4) /* Card can run at 200MHz */
350#define EXT_CSD_CARD_TYPE_SDR_1_2V (1<<5) /* Card can run at 200MHz */
351 /* SDR mode @1.2V I/O */
352
353#define EXT_CSD_CARD_TYPE_SDR_200 (EXT_CSD_CARD_TYPE_SDR_1_8V | \
354 EXT_CSD_CARD_TYPE_SDR_1_2V)
355
356#define EXT_CSD_CARD_TYPE_SDR_ALL (EXT_CSD_CARD_TYPE_SDR_200 | \
357 EXT_CSD_CARD_TYPE_52 | \
358 EXT_CSD_CARD_TYPE_26)
359
360#define EXT_CSD_CARD_TYPE_SDR_1_2V_ALL (EXT_CSD_CARD_TYPE_SDR_1_2V | \
361 EXT_CSD_CARD_TYPE_52 | \
362 EXT_CSD_CARD_TYPE_26)
363
364#define EXT_CSD_CARD_TYPE_SDR_1_8V_ALL (EXT_CSD_CARD_TYPE_SDR_1_8V | \
365 EXT_CSD_CARD_TYPE_52 | \
366 EXT_CSD_CARD_TYPE_26)
367
368#define EXT_CSD_CARD_TYPE_SDR_1_2V_DDR_1_8V (EXT_CSD_CARD_TYPE_SDR_1_2V | \
369 EXT_CSD_CARD_TYPE_DDR_1_8V | \
370 EXT_CSD_CARD_TYPE_52 | \
371 EXT_CSD_CARD_TYPE_26)
372
373#define EXT_CSD_CARD_TYPE_SDR_1_8V_DDR_1_8V (EXT_CSD_CARD_TYPE_SDR_1_8V | \
374 EXT_CSD_CARD_TYPE_DDR_1_8V | \
375 EXT_CSD_CARD_TYPE_52 | \
376 EXT_CSD_CARD_TYPE_26)
377
378#define EXT_CSD_CARD_TYPE_SDR_1_2V_DDR_1_2V (EXT_CSD_CARD_TYPE_SDR_1_2V | \
379 EXT_CSD_CARD_TYPE_DDR_1_2V | \
380 EXT_CSD_CARD_TYPE_52 | \
381 EXT_CSD_CARD_TYPE_26)
382
383#define EXT_CSD_CARD_TYPE_SDR_1_8V_DDR_1_2V (EXT_CSD_CARD_TYPE_SDR_1_8V | \
384 EXT_CSD_CARD_TYPE_DDR_1_2V | \
385 EXT_CSD_CARD_TYPE_52 | \
386 EXT_CSD_CARD_TYPE_26)
387
388#define EXT_CSD_CARD_TYPE_SDR_1_2V_DDR_52 (EXT_CSD_CARD_TYPE_SDR_1_2V | \
389 EXT_CSD_CARD_TYPE_DDR_52 | \
390 EXT_CSD_CARD_TYPE_52 | \
391 EXT_CSD_CARD_TYPE_26)
392
393#define EXT_CSD_CARD_TYPE_SDR_1_8V_DDR_52 (EXT_CSD_CARD_TYPE_SDR_1_8V | \
394 EXT_CSD_CARD_TYPE_DDR_52 | \
395 EXT_CSD_CARD_TYPE_52 | \
396 EXT_CSD_CARD_TYPE_26)
397
398#define EXT_CSD_CARD_TYPE_SDR_ALL_DDR_1_8V (EXT_CSD_CARD_TYPE_SDR_200 | \
399 EXT_CSD_CARD_TYPE_DDR_1_8V | \
400 EXT_CSD_CARD_TYPE_52 | \
401 EXT_CSD_CARD_TYPE_26)
402
403#define EXT_CSD_CARD_TYPE_SDR_ALL_DDR_1_2V (EXT_CSD_CARD_TYPE_SDR_200 | \
404 EXT_CSD_CARD_TYPE_DDR_1_2V | \
405 EXT_CSD_CARD_TYPE_52 | \
406 EXT_CSD_CARD_TYPE_26)
407
408#define EXT_CSD_CARD_TYPE_SDR_ALL_DDR_52 (EXT_CSD_CARD_TYPE_SDR_200 | \
409 EXT_CSD_CARD_TYPE_DDR_52 | \
410 EXT_CSD_CARD_TYPE_52 | \
411 EXT_CSD_CARD_TYPE_26)
310 412
311#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */ 413#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */
312#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */ 414#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */
@@ -317,6 +419,27 @@ struct _mmc_csd {
317#define EXT_CSD_SEC_ER_EN BIT(0) 419#define EXT_CSD_SEC_ER_EN BIT(0)
318#define EXT_CSD_SEC_BD_BLK_EN BIT(2) 420#define EXT_CSD_SEC_BD_BLK_EN BIT(2)
319#define EXT_CSD_SEC_GB_CL_EN BIT(4) 421#define EXT_CSD_SEC_GB_CL_EN BIT(4)
422#define EXT_CSD_SEC_SANITIZE BIT(6) /* v4.5 only */
423
424#define EXT_CSD_RST_N_EN_MASK 0x3
425#define EXT_CSD_RST_N_ENABLED 1 /* RST_n is enabled on card */
426
427#define EXT_CSD_NO_POWER_NOTIFICATION 0
428#define EXT_CSD_POWER_ON 1
429#define EXT_CSD_POWER_OFF_SHORT 2
430#define EXT_CSD_POWER_OFF_LONG 3
431
432#define EXT_CSD_PWR_CL_8BIT_MASK 0xF0 /* 8 bit PWR CLS */
433#define EXT_CSD_PWR_CL_4BIT_MASK 0x0F /* 8 bit PWR CLS */
434#define EXT_CSD_PWR_CL_8BIT_SHIFT 4
435#define EXT_CSD_PWR_CL_4BIT_SHIFT 0
436
437#define EXT_CSD_PACKED_EVENT_EN (1 << 3)
438
439#define EXT_CSD_PACKED_FAILURE (1 << 3)
440
441#define EXT_CSD_PACKED_GENERIC_ERROR (1 << 0)
442#define EXT_CSD_PACKED_INDEXED_ERROR (1 << 1)
320 443
321/* 444/*
322 * MMC_SWITCH access modes 445 * MMC_SWITCH access modes
diff --git a/include/linux/mmc/pm.h b/include/linux/mmc/pm.h
index d37aac49cf9..66ac136c638 100644
--- a/include/linux/mmc/pm.h
+++ b/include/linux/mmc/pm.h
@@ -26,5 +26,9 @@ typedef unsigned int mmc_pm_flag_t;
26 26
27#define MMC_PM_KEEP_POWER (1 << 0) /* preserve card power during suspend */ 27#define MMC_PM_KEEP_POWER (1 << 0) /* preserve card power during suspend */
28#define MMC_PM_WAKE_SDIO_IRQ (1 << 1) /* wake up host system on SDIO IRQ assertion */ 28#define MMC_PM_WAKE_SDIO_IRQ (1 << 1) /* wake up host system on SDIO IRQ assertion */
29#define MMC_PM_IGNORE_PM_NOTIFY (1 << 2) /* ignore mmc pm notify */
30
31/* ignore mmc suspend.resume for BCM WIFI */
32#define MMC_PM_IGNORE_SUSPEND_RESUME (1 << 30)
29 33
30#endif 34#endif
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index 6a68c4eb4e4..636c932166b 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -94,6 +94,7 @@ struct sdhci_host {
94 const struct sdhci_ops *ops; /* Low level hw interface */ 94 const struct sdhci_ops *ops; /* Low level hw interface */
95 95
96 struct regulator *vmmc; /* Power regulator */ 96 struct regulator *vmmc; /* Power regulator */
97 char *vmmc_name; /* Power regulator's name */
97 98
98 /* Internal data */ 99 /* Internal data */
99 struct mmc_host *mmc; /* MMC structure */ 100 struct mmc_host *mmc; /* MMC structure */
diff --git a/include/linux/mmc/sdio.h b/include/linux/mmc/sdio.h
index 245cdacee54..c83115efea9 100644
--- a/include/linux/mmc/sdio.h
+++ b/include/linux/mmc/sdio.h
@@ -38,6 +38,7 @@
38 * [8:0] Byte/block count 38 * [8:0] Byte/block count
39 */ 39 */
40 40
41#define R4_18V_PRESENT (1<<24)
41#define R4_MEMORY_PRESENT (1 << 27) 42#define R4_MEMORY_PRESENT (1 << 27)
42 43
43/* 44/*
@@ -72,17 +73,20 @@
72#define SDIO_CCCR_REV_1_00 0 /* CCCR/FBR Version 1.00 */ 73#define SDIO_CCCR_REV_1_00 0 /* CCCR/FBR Version 1.00 */
73#define SDIO_CCCR_REV_1_10 1 /* CCCR/FBR Version 1.10 */ 74#define SDIO_CCCR_REV_1_10 1 /* CCCR/FBR Version 1.10 */
74#define SDIO_CCCR_REV_1_20 2 /* CCCR/FBR Version 1.20 */ 75#define SDIO_CCCR_REV_1_20 2 /* CCCR/FBR Version 1.20 */
76#define SDIO_CCCR_REV_3_00 3 /* CCCR/FBR Version 3.00 */
75 77
76#define SDIO_SDIO_REV_1_00 0 /* SDIO Spec Version 1.00 */ 78#define SDIO_SDIO_REV_1_00 0 /* SDIO Spec Version 1.00 */
77#define SDIO_SDIO_REV_1_10 1 /* SDIO Spec Version 1.10 */ 79#define SDIO_SDIO_REV_1_10 1 /* SDIO Spec Version 1.10 */
78#define SDIO_SDIO_REV_1_20 2 /* SDIO Spec Version 1.20 */ 80#define SDIO_SDIO_REV_1_20 2 /* SDIO Spec Version 1.20 */
79#define SDIO_SDIO_REV_2_00 3 /* SDIO Spec Version 2.00 */ 81#define SDIO_SDIO_REV_2_00 3 /* SDIO Spec Version 2.00 */
82#define SDIO_SDIO_REV_3_00 4 /* SDIO Spec Version 3.00 */
80 83
81#define SDIO_CCCR_SD 0x01 84#define SDIO_CCCR_SD 0x01
82 85
83#define SDIO_SD_REV_1_01 0 /* SD Physical Spec Version 1.01 */ 86#define SDIO_SD_REV_1_01 0 /* SD Physical Spec Version 1.01 */
84#define SDIO_SD_REV_1_10 1 /* SD Physical Spec Version 1.10 */ 87#define SDIO_SD_REV_1_10 1 /* SD Physical Spec Version 1.10 */
85#define SDIO_SD_REV_2_00 2 /* SD Physical Spec Version 2.00 */ 88#define SDIO_SD_REV_2_00 2 /* SD Physical Spec Version 2.00 */
89#define SDIO_SD_REV_3_00 3 /* SD Physical Spev Version 3.00 */
86 90
87#define SDIO_CCCR_IOEx 0x02 91#define SDIO_CCCR_IOEx 0x02
88#define SDIO_CCCR_IORx 0x03 92#define SDIO_CCCR_IORx 0x03
@@ -132,8 +136,31 @@
132#define SDIO_CCCR_SPEED 0x13 136#define SDIO_CCCR_SPEED 0x13
133 137
134#define SDIO_SPEED_SHS 0x01 /* Supports High-Speed mode */ 138#define SDIO_SPEED_SHS 0x01 /* Supports High-Speed mode */
135#define SDIO_SPEED_EHS 0x02 /* Enable High-Speed mode */ 139#define SDIO_SPEED_BSS_SHIFT 1
136 140#define SDIO_SPEED_BSS_MASK (7<<SDIO_SPEED_BSS_SHIFT)
141#define SDIO_SPEED_SDR12 (0<<SDIO_SPEED_BSS_SHIFT)
142#define SDIO_SPEED_SDR25 (1<<SDIO_SPEED_BSS_SHIFT)
143#define SDIO_SPEED_SDR50 (2<<SDIO_SPEED_BSS_SHIFT)
144#define SDIO_SPEED_SDR104 (3<<SDIO_SPEED_BSS_SHIFT)
145#define SDIO_SPEED_DDR50 (4<<SDIO_SPEED_BSS_SHIFT)
146#define SDIO_SPEED_EHS SDIO_SPEED_SDR25 /* Enable High-Speed */
147
148#define SDIO_CCCR_UHS 0x14
149#define SDIO_UHS_SDR50 0x01
150#define SDIO_UHS_SDR104 0x02
151#define SDIO_UHS_DDR50 0x04
152
153#define SDIO_CCCR_DRIVE_STRENGTH 0x15
154#define SDIO_SDTx_MASK 0x07
155#define SDIO_DRIVE_SDTA (1<<0)
156#define SDIO_DRIVE_SDTC (1<<1)
157#define SDIO_DRIVE_SDTD (1<<2)
158#define SDIO_DRIVE_DTSx_MASK 0x03
159#define SDIO_DRIVE_DTSx_SHIFT 4
160#define SDIO_DTSx_SET_TYPE_B (0 << SDIO_DRIVE_DTSx_SHIFT)
161#define SDIO_DTSx_SET_TYPE_A (1 << SDIO_DRIVE_DTSx_SHIFT)
162#define SDIO_DTSx_SET_TYPE_C (2 << SDIO_DRIVE_DTSx_SHIFT)
163#define SDIO_DTSx_SET_TYPE_D (3 << SDIO_DRIVE_DTSx_SHIFT)
137/* 164/*
138 * Function Basic Registers (FBR) 165 * Function Basic Registers (FBR)
139 */ 166 */
diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h
index 31baaf82f45..557acae8cf9 100644
--- a/include/linux/mmc/sdio_func.h
+++ b/include/linux/mmc/sdio_func.h
@@ -23,6 +23,14 @@ struct sdio_func;
23typedef void (sdio_irq_handler_t)(struct sdio_func *); 23typedef void (sdio_irq_handler_t)(struct sdio_func *);
24 24
25/* 25/*
26 * Structure used to hold embedded SDIO device data from platform layer
27 */
28struct sdio_embedded_func {
29 uint8_t f_class;
30 uint32_t f_maxblksize;
31};
32
33/*
26 * SDIO function CIS tuple (unknown to the core) 34 * SDIO function CIS tuple (unknown to the core)
27 */ 35 */
28struct sdio_func_tuple { 36struct sdio_func_tuple {
@@ -130,6 +138,8 @@ extern int sdio_release_irq(struct sdio_func *func);
130extern unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz); 138extern unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz);
131 139
132extern u8 sdio_readb(struct sdio_func *func, unsigned int addr, int *err_ret); 140extern u8 sdio_readb(struct sdio_func *func, unsigned int addr, int *err_ret);
141extern u8 sdio_readb_ext(struct sdio_func *func, unsigned int addr, int *err_ret,
142 unsigned in);
133extern u16 sdio_readw(struct sdio_func *func, unsigned int addr, int *err_ret); 143extern u16 sdio_readw(struct sdio_func *func, unsigned int addr, int *err_ret);
134extern u32 sdio_readl(struct sdio_func *func, unsigned int addr, int *err_ret); 144extern u32 sdio_readl(struct sdio_func *func, unsigned int addr, int *err_ret);
135 145