aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/host/sdhci.h
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/mmc/host/sdhci.h
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'drivers/mmc/host/sdhci.h')
-rw-r--r--drivers/mmc/host/sdhci.h222
1 files changed, 87 insertions, 135 deletions
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index d316bc79b636..745c42fa41ed 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -1,6 +1,8 @@
1/* 1/*
2 * linux/drivers/mmc/host/sdhci.h - Secure Digital Host Controller Interface driver 2 * linux/drivers/mmc/host/sdhci.h - Secure Digital Host Controller Interface driver
3 * 3 *
4 * Header file for Host Controller registers and I/O accessors.
5 *
4 * Copyright (C) 2005-2008 Pierre Ossman, All Rights Reserved. 6 * Copyright (C) 2005-2008 Pierre Ossman, All Rights Reserved.
5 * 7 *
6 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
@@ -8,19 +10,22 @@
8 * the Free Software Foundation; either version 2 of the License, or (at 10 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version. 11 * your option) any later version.
10 */ 12 */
11#ifndef __SDHCI_H 13#ifndef __SDHCI_HW_H
12#define __SDHCI_H 14#define __SDHCI_HW_H
13 15
14#include <linux/scatterlist.h> 16#include <linux/scatterlist.h>
15#include <linux/compiler.h> 17#include <linux/compiler.h>
16#include <linux/types.h> 18#include <linux/types.h>
17#include <linux/io.h> 19#include <linux/io.h>
18 20
21#include <linux/mmc/sdhci.h>
22
19/* 23/*
20 * Controller registers 24 * Controller registers
21 */ 25 */
22 26
23#define SDHCI_DMA_ADDRESS 0x00 27#define SDHCI_DMA_ADDRESS 0x00
28#define SDHCI_ARGUMENT2 SDHCI_DMA_ADDRESS
24 29
25#define SDHCI_BLOCK_SIZE 0x04 30#define SDHCI_BLOCK_SIZE 0x04
26#define SDHCI_MAKE_BLKSZ(dma, blksz) (((dma & 0x7) << 12) | (blksz & 0xFFF)) 31#define SDHCI_MAKE_BLKSZ(dma, blksz) (((dma & 0x7) << 12) | (blksz & 0xFFF))
@@ -32,7 +37,8 @@
32#define SDHCI_TRANSFER_MODE 0x0C 37#define SDHCI_TRANSFER_MODE 0x0C
33#define SDHCI_TRNS_DMA 0x01 38#define SDHCI_TRNS_DMA 0x01
34#define SDHCI_TRNS_BLK_CNT_EN 0x02 39#define SDHCI_TRNS_BLK_CNT_EN 0x02
35#define SDHCI_TRNS_ACMD12 0x04 40#define SDHCI_TRNS_AUTO_CMD12 0x04
41#define SDHCI_TRNS_AUTO_CMD23 0x08
36#define SDHCI_TRNS_READ 0x10 42#define SDHCI_TRNS_READ 0x10
37#define SDHCI_TRNS_MULTI 0x20 43#define SDHCI_TRNS_MULTI 0x20
38 44
@@ -41,6 +47,7 @@
41#define SDHCI_CMD_CRC 0x08 47#define SDHCI_CMD_CRC 0x08
42#define SDHCI_CMD_INDEX 0x10 48#define SDHCI_CMD_INDEX 0x10
43#define SDHCI_CMD_DATA 0x20 49#define SDHCI_CMD_DATA 0x20
50#define SDHCI_CMD_ABORTCMD 0xC0
44 51
45#define SDHCI_CMD_RESP_NONE 0x00 52#define SDHCI_CMD_RESP_NONE 0x00
46#define SDHCI_CMD_RESP_LONG 0x01 53#define SDHCI_CMD_RESP_LONG 0x01
@@ -48,6 +55,7 @@
48#define SDHCI_CMD_RESP_SHORT_BUSY 0x03 55#define SDHCI_CMD_RESP_SHORT_BUSY 0x03
49 56
50#define SDHCI_MAKE_CMD(c, f) (((c & 0xff) << 8) | (f & 0xff)) 57#define SDHCI_MAKE_CMD(c, f) (((c & 0xff) << 8) | (f & 0xff))
58#define SDHCI_GET_CMD(c) ((c>>8) & 0x3f)
51 59
52#define SDHCI_RESPONSE 0x10 60#define SDHCI_RESPONSE 0x10
53 61
@@ -62,8 +70,10 @@
62#define SDHCI_DATA_AVAILABLE 0x00000800 70#define SDHCI_DATA_AVAILABLE 0x00000800
63#define SDHCI_CARD_PRESENT 0x00010000 71#define SDHCI_CARD_PRESENT 0x00010000
64#define SDHCI_WRITE_PROTECT 0x00080000 72#define SDHCI_WRITE_PROTECT 0x00080000
73#define SDHCI_DATA_LVL_MASK 0x00F00000
74#define SDHCI_DATA_LVL_SHIFT 20
65 75
66#define SDHCI_HOST_CONTROL 0x28 76#define SDHCI_HOST_CONTROL 0x28
67#define SDHCI_CTRL_LED 0x01 77#define SDHCI_CTRL_LED 0x01
68#define SDHCI_CTRL_4BITBUS 0x02 78#define SDHCI_CTRL_4BITBUS 0x02
69#define SDHCI_CTRL_HISPD 0x04 79#define SDHCI_CTRL_HISPD 0x04
@@ -72,7 +82,7 @@
72#define SDHCI_CTRL_ADMA1 0x08 82#define SDHCI_CTRL_ADMA1 0x08
73#define SDHCI_CTRL_ADMA32 0x10 83#define SDHCI_CTRL_ADMA32 0x10
74#define SDHCI_CTRL_ADMA64 0x18 84#define SDHCI_CTRL_ADMA64 0x18
75#define SDHCI_CTRL_8BITBUS 0x20 85#define SDHCI_CTRL_8BITBUS 0x20
76 86
77#define SDHCI_POWER_CONTROL 0x29 87#define SDHCI_POWER_CONTROL 0x29
78#define SDHCI_POWER_ON 0x01 88#define SDHCI_POWER_ON 0x01
@@ -83,9 +93,17 @@
83#define SDHCI_BLOCK_GAP_CONTROL 0x2A 93#define SDHCI_BLOCK_GAP_CONTROL 0x2A
84 94
85#define SDHCI_WAKE_UP_CONTROL 0x2B 95#define SDHCI_WAKE_UP_CONTROL 0x2B
96#define SDHCI_WAKE_ON_INT 0x01
97#define SDHCI_WAKE_ON_INSERT 0x02
98#define SDHCI_WAKE_ON_REMOVE 0x04
86 99
87#define SDHCI_CLOCK_CONTROL 0x2C 100#define SDHCI_CLOCK_CONTROL 0x2C
88#define SDHCI_DIVIDER_SHIFT 8 101#define SDHCI_DIVIDER_SHIFT 8
102#define SDHCI_DIVIDER_HI_SHIFT 6
103#define SDHCI_DIV_MASK 0xFF
104#define SDHCI_DIV_MASK_LEN 8
105#define SDHCI_DIV_HI_MASK 0x300
106#define SDHCI_PROG_CLOCK_MODE 0x0020
89#define SDHCI_CLOCK_CARD_EN 0x0004 107#define SDHCI_CLOCK_CARD_EN 0x0004
90#define SDHCI_CLOCK_INT_STABLE 0x0002 108#define SDHCI_CLOCK_INT_STABLE 0x0002
91#define SDHCI_CLOCK_INT_EN 0x0001 109#define SDHCI_CLOCK_INT_EN 0x0001
@@ -133,16 +151,33 @@
133 151
134#define SDHCI_ACMD12_ERR 0x3C 152#define SDHCI_ACMD12_ERR 0x3C
135 153
136/* 3E-3F reserved */ 154#define SDHCI_HOST_CONTROL2 0x3E
155#define SDHCI_CTRL_UHS_MASK 0x0007
156#define SDHCI_CTRL_UHS_SDR12 0x0000
157#define SDHCI_CTRL_UHS_SDR25 0x0001
158#define SDHCI_CTRL_UHS_SDR50 0x0002
159#define SDHCI_CTRL_UHS_SDR104 0x0003
160#define SDHCI_CTRL_UHS_DDR50 0x0004
161#define SDHCI_CTRL_VDD_180 0x0008
162#define SDHCI_CTRL_DRV_TYPE_MASK 0x0030
163#define SDHCI_CTRL_DRV_TYPE_B 0x0000
164#define SDHCI_CTRL_DRV_TYPE_A 0x0010
165#define SDHCI_CTRL_DRV_TYPE_C 0x0020
166#define SDHCI_CTRL_DRV_TYPE_D 0x0030
167#define SDHCI_CTRL_EXEC_TUNING 0x0040
168#define SDHCI_CTRL_TUNED_CLK 0x0080
169#define SDHCI_CTRL_PRESET_VAL_ENABLE 0x8000
137 170
138#define SDHCI_CAPABILITIES 0x40 171#define SDHCI_CAPABILITIES 0x40
139#define SDHCI_TIMEOUT_CLK_MASK 0x0000003F 172#define SDHCI_TIMEOUT_CLK_MASK 0x0000003F
140#define SDHCI_TIMEOUT_CLK_SHIFT 0 173#define SDHCI_TIMEOUT_CLK_SHIFT 0
141#define SDHCI_TIMEOUT_CLK_UNIT 0x00000080 174#define SDHCI_TIMEOUT_CLK_UNIT 0x00000080
142#define SDHCI_CLOCK_BASE_MASK 0x00003F00 175#define SDHCI_CLOCK_BASE_MASK 0x00003F00
176#define SDHCI_CLOCK_V3_BASE_MASK 0x0000FF00
143#define SDHCI_CLOCK_BASE_SHIFT 8 177#define SDHCI_CLOCK_BASE_SHIFT 8
144#define SDHCI_MAX_BLOCK_MASK 0x00030000 178#define SDHCI_MAX_BLOCK_MASK 0x00030000
145#define SDHCI_MAX_BLOCK_SHIFT 16 179#define SDHCI_MAX_BLOCK_SHIFT 16
180#define SDHCI_CAN_DO_8BIT 0x00040000
146#define SDHCI_CAN_DO_ADMA2 0x00080000 181#define SDHCI_CAN_DO_ADMA2 0x00080000
147#define SDHCI_CAN_DO_ADMA1 0x00100000 182#define SDHCI_CAN_DO_ADMA1 0x00100000
148#define SDHCI_CAN_DO_HISPD 0x00200000 183#define SDHCI_CAN_DO_HISPD 0x00200000
@@ -152,9 +187,30 @@
152#define SDHCI_CAN_VDD_180 0x04000000 187#define SDHCI_CAN_VDD_180 0x04000000
153#define SDHCI_CAN_64BIT 0x10000000 188#define SDHCI_CAN_64BIT 0x10000000
154 189
155/* 44-47 reserved for more caps */ 190#define SDHCI_SUPPORT_SDR50 0x00000001
156 191#define SDHCI_SUPPORT_SDR104 0x00000002
157#define SDHCI_MAX_CURRENT 0x48 192#define SDHCI_SUPPORT_DDR50 0x00000004
193#define SDHCI_DRIVER_TYPE_A 0x00000010
194#define SDHCI_DRIVER_TYPE_C 0x00000020
195#define SDHCI_DRIVER_TYPE_D 0x00000040
196#define SDHCI_RETUNING_TIMER_COUNT_MASK 0x00000F00
197#define SDHCI_RETUNING_TIMER_COUNT_SHIFT 8
198#define SDHCI_USE_SDR50_TUNING 0x00002000
199#define SDHCI_RETUNING_MODE_MASK 0x0000C000
200#define SDHCI_RETUNING_MODE_SHIFT 14
201#define SDHCI_CLOCK_MUL_MASK 0x00FF0000
202#define SDHCI_CLOCK_MUL_SHIFT 16
203
204#define SDHCI_CAPABILITIES_1 0x44
205
206#define SDHCI_MAX_CURRENT 0x48
207#define SDHCI_MAX_CURRENT_330_MASK 0x0000FF
208#define SDHCI_MAX_CURRENT_330_SHIFT 0
209#define SDHCI_MAX_CURRENT_300_MASK 0x00FF00
210#define SDHCI_MAX_CURRENT_300_SHIFT 8
211#define SDHCI_MAX_CURRENT_180_MASK 0xFF0000
212#define SDHCI_MAX_CURRENT_180_SHIFT 16
213#define SDHCI_MAX_CURRENT_MULTIPLIER 4
158 214
159/* 4C-4F reserved for more max current */ 215/* 4C-4F reserved for more max current */
160 216
@@ -178,134 +234,20 @@
178#define SDHCI_SPEC_VER_SHIFT 0 234#define SDHCI_SPEC_VER_SHIFT 0
179#define SDHCI_SPEC_100 0 235#define SDHCI_SPEC_100 0
180#define SDHCI_SPEC_200 1 236#define SDHCI_SPEC_200 1
237#define SDHCI_SPEC_300 2
181 238
182struct sdhci_ops; 239/*
183 240 * End of controller registers.
184struct sdhci_host { 241 */
185 /* Data set by hardware interface driver */
186 const char *hw_name; /* Hardware bus name */
187
188 unsigned int quirks; /* Deviations from spec. */
189
190/* Controller doesn't honor resets unless we touch the clock register */
191#define SDHCI_QUIRK_CLOCK_BEFORE_RESET (1<<0)
192/* Controller has bad caps bits, but really supports DMA */
193#define SDHCI_QUIRK_FORCE_DMA (1<<1)
194/* Controller doesn't like to be reset when there is no card inserted. */
195#define SDHCI_QUIRK_NO_CARD_NO_RESET (1<<2)
196/* Controller doesn't like clearing the power reg before a change */
197#define SDHCI_QUIRK_SINGLE_POWER_WRITE (1<<3)
198/* Controller has flaky internal state so reset it on each ios change */
199#define SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS (1<<4)
200/* Controller has an unusable DMA engine */
201#define SDHCI_QUIRK_BROKEN_DMA (1<<5)
202/* Controller has an unusable ADMA engine */
203#define SDHCI_QUIRK_BROKEN_ADMA (1<<6)
204/* Controller can only DMA from 32-bit aligned addresses */
205#define SDHCI_QUIRK_32BIT_DMA_ADDR (1<<7)
206/* Controller can only DMA chunk sizes that are a multiple of 32 bits */
207#define SDHCI_QUIRK_32BIT_DMA_SIZE (1<<8)
208/* Controller can only ADMA chunks that are a multiple of 32 bits */
209#define SDHCI_QUIRK_32BIT_ADMA_SIZE (1<<9)
210/* Controller needs to be reset after each request to stay stable */
211#define SDHCI_QUIRK_RESET_AFTER_REQUEST (1<<10)
212/* Controller needs voltage and power writes to happen separately */
213#define SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER (1<<11)
214/* Controller provides an incorrect timeout value for transfers */
215#define SDHCI_QUIRK_BROKEN_TIMEOUT_VAL (1<<12)
216/* Controller has an issue with buffer bits for small transfers */
217#define SDHCI_QUIRK_BROKEN_SMALL_PIO (1<<13)
218/* Controller does not provide transfer-complete interrupt when not busy */
219#define SDHCI_QUIRK_NO_BUSY_IRQ (1<<14)
220/* Controller has unreliable card detection */
221#define SDHCI_QUIRK_BROKEN_CARD_DETECTION (1<<15)
222/* Controller reports inverted write-protect state */
223#define SDHCI_QUIRK_INVERTED_WRITE_PROTECT (1<<16)
224/* Controller has nonstandard clock management */
225#define SDHCI_QUIRK_NONSTANDARD_CLOCK (1<<17)
226/* Controller does not like fast PIO transfers */
227#define SDHCI_QUIRK_PIO_NEEDS_DELAY (1<<18)
228/* Controller losing signal/interrupt enable states after reset */
229#define SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET (1<<19)
230/* Controller has to be forced to use block size of 2048 bytes */
231#define SDHCI_QUIRK_FORCE_BLK_SZ_2048 (1<<20)
232/* Controller cannot do multi-block transfers */
233#define SDHCI_QUIRK_NO_MULTIBLOCK (1<<21)
234/* Controller can only handle 1-bit data transfers */
235#define SDHCI_QUIRK_FORCE_1_BIT_DATA (1<<22)
236/* Controller needs 10ms delay between applying power and clock */
237#define SDHCI_QUIRK_DELAY_AFTER_POWER (1<<23)
238/* Controller uses SDCLK instead of TMCLK for data timeouts */
239#define SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK (1<<24)
240/* Controller reports wrong base clock capability */
241#define SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN (1<<25)
242/* Controller cannot support End Attribute in NOP ADMA descriptor */
243#define SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC (1<<26)
244/* Controller is missing device caps. Use caps provided by host */
245#define SDHCI_QUIRK_MISSING_CAPS (1<<27)
246/* Controller uses Auto CMD12 command to stop the transfer */
247#define SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12 (1<<28)
248/* Controller doesn't have HISPD bit field in HI-SPEED SD card */
249#define SDHCI_QUIRK_NO_HISPD_BIT (1<<29)
250
251 int irq; /* Device IRQ */
252 void __iomem * ioaddr; /* Mapped address */
253
254 const struct sdhci_ops *ops; /* Low level hw interface */
255
256 struct regulator *vmmc; /* Power regulator */
257
258 /* Internal data */
259 struct mmc_host *mmc; /* MMC structure */
260 u64 dma_mask; /* custom DMA mask */
261
262#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
263 struct led_classdev led; /* LED control */
264 char led_name[32];
265#endif
266
267 spinlock_t lock; /* Mutex */
268
269 int flags; /* Host attributes */
270#define SDHCI_USE_SDMA (1<<0) /* Host is SDMA capable */
271#define SDHCI_USE_ADMA (1<<1) /* Host is ADMA capable */
272#define SDHCI_REQ_USE_DMA (1<<2) /* Use DMA for this req. */
273#define SDHCI_DEVICE_DEAD (1<<3) /* Device unresponsive */
274
275 unsigned int version; /* SDHCI spec. version */
276
277 unsigned int max_clk; /* Max possible freq (MHz) */
278 unsigned int timeout_clk; /* Timeout freq (KHz) */
279
280 unsigned int clock; /* Current clock (MHz) */
281 u8 pwr; /* Current voltage */
282
283 struct mmc_request *mrq; /* Current request */
284 struct mmc_command *cmd; /* Current command */
285 struct mmc_data *data; /* Current data request */
286 unsigned int data_early:1; /* Data finished before cmd */
287
288 struct sg_mapping_iter sg_miter; /* SG state for PIO */
289 unsigned int blocks; /* remaining PIO blocks */
290
291 int sg_count; /* Mapped sg entries */
292
293 u8 *adma_desc; /* ADMA descriptor table */
294 u8 *align_buffer; /* Bounce buffer */
295
296 dma_addr_t adma_addr; /* Mapped ADMA descr. table */
297 dma_addr_t align_addr; /* Mapped bounce buffer */
298
299 struct tasklet_struct card_tasklet; /* Tasklet structures */
300 struct tasklet_struct finish_tasklet;
301
302 struct timer_list timer; /* Timer for timeouts */
303
304 unsigned int caps; /* Alternative capabilities */
305 242
306 unsigned long private[0] ____cacheline_aligned; 243#define SDHCI_MAX_DIV_SPEC_200 256
307}; 244#define SDHCI_MAX_DIV_SPEC_300 2046
308 245
246/*
247 * Host SDMA buffer boundary. Valid values from 4K to 512K in powers of 2.
248 */
249#define SDHCI_DEFAULT_BOUNDARY_SIZE (512 * 1024)
250#define SDHCI_DEFAULT_BOUNDARY_ARG (ilog2(SDHCI_DEFAULT_BOUNDARY_SIZE) - 12)
309 251
310struct sdhci_ops { 252struct sdhci_ops {
311#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS 253#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
@@ -323,6 +265,15 @@ struct sdhci_ops {
323 unsigned int (*get_max_clock)(struct sdhci_host *host); 265 unsigned int (*get_max_clock)(struct sdhci_host *host);
324 unsigned int (*get_min_clock)(struct sdhci_host *host); 266 unsigned int (*get_min_clock)(struct sdhci_host *host);
325 unsigned int (*get_timeout_clock)(struct sdhci_host *host); 267 unsigned int (*get_timeout_clock)(struct sdhci_host *host);
268 int (*platform_8bit_width)(struct sdhci_host *host,
269 int width);
270 void (*platform_send_init_74_clocks)(struct sdhci_host *host,
271 u8 power_mode);
272 unsigned int (*get_ro)(struct sdhci_host *host);
273 void (*platform_reset_enter)(struct sdhci_host *host, u8 mask);
274 void (*platform_reset_exit)(struct sdhci_host *host, u8 mask);
275 int (*set_uhs_signaling)(struct sdhci_host *host, unsigned int uhs);
276
326}; 277};
327 278
328#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS 279#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
@@ -425,6 +376,7 @@ extern void sdhci_remove_host(struct sdhci_host *host, int dead);
425#ifdef CONFIG_PM 376#ifdef CONFIG_PM
426extern int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state); 377extern int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state);
427extern int sdhci_resume_host(struct sdhci_host *host); 378extern int sdhci_resume_host(struct sdhci_host *host);
379extern void sdhci_enable_irq_wakeups(struct sdhci_host *host);
428#endif 380#endif
429 381
430#endif /* __SDHCI_H */ 382#endif /* __SDHCI_HW_H */