Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-mmc

* 'devel' of master.kernel.org:/home/rmk/linux-2.6-mmc:
[MMC] sdhci: version bump sdhci
[MMC] sdhci: support controller specific quirks
[MMC] sdhci: more DMA capabilities tests
[MMC] sdhci: reset sdhci controller early
[MMC] sdhci: check controller version
[MMC] sdhci: check only relevant inhibit bits
[MMC] sdhci: Test for invalid block size
[MMC] sdhci: Avoid sdhci DMA boundaries
[MMC] Fix sdhci PIO routines
[MMC] sdhci: fix interrupt handling
[MMC] sdhci: correct register order
[MMC] sdhci: proper timeout handling
[MMC] sdhci: fix sdhci reset timeout
[MMC] sdhci: fix timeout loops in sdhci
[MMC] sdhci: support for multiple voltages
[MMC] sdhci: print device id
[MMC] sdhci: check SDHCI base clock

+411 -172
+381 -168
drivers/mmc/sdhci.c
··· 8 * published by the Free Software Foundation. 9 */ 10 11 - /* 12 - * Note that PIO transfer is rather crappy atm. The buffer full/empty 13 - * interrupts aren't reliable so we currently transfer the entire buffer 14 - * directly. Patches to solve the problem are welcome. 15 - */ 16 - 17 #include <linux/delay.h> 18 #include <linux/highmem.h> 19 #include <linux/pci.h> ··· 21 #include "sdhci.h" 22 23 #define DRIVER_NAME "sdhci" 24 - #define DRIVER_VERSION "0.11" 25 26 #define BUGMAIL "<sdhci-devel@list.drzeus.cx>" 27 28 #define DBG(f, x...) \ 29 pr_debug(DRIVER_NAME " [%s()]: " f, __func__,## x) 30 31 static const struct pci_device_id pci_ids[] __devinitdata = { 32 /* handle any SD host controller */ ··· 92 93 static void sdhci_reset(struct sdhci_host *host, u8 mask) 94 { 95 writeb(mask, host->ioaddr + SDHCI_SOFTWARE_RESET); 96 97 - if (mask & SDHCI_RESET_ALL) { 98 host->clock = 0; 99 100 - mdelay(50); 101 } 102 } 103 ··· 122 123 sdhci_reset(host, SDHCI_RESET_ALL); 124 125 - intmask = ~(SDHCI_INT_CARD_INT | SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL); 126 127 writel(intmask, host->ioaddr + SDHCI_INT_ENABLE); 128 writel(intmask, host->ioaddr + SDHCI_SIGNAL_ENABLE); 129 - 130 - /* This is unknown magic. */ 131 - writeb(0xE, host->ioaddr + SDHCI_TIMEOUT_CONTROL); 132 } 133 134 static void sdhci_activate_led(struct sdhci_host *host) ··· 187 return host->num_sg; 188 } 189 190 - static void sdhci_transfer_pio(struct sdhci_host *host) 191 { 192 char *buffer; 193 - u32 mask; 194 - int bytes, size; 195 - unsigned long max_jiffies; 196 197 - BUG_ON(!host->data); 198 199 - if (host->num_sg == 0) 200 - return; 201 - 202 - bytes = 0; 203 - if (host->data->flags & MMC_DATA_READ) 204 - mask = SDHCI_DATA_AVAILABLE; 205 - else 206 - mask = SDHCI_SPACE_AVAILABLE; 207 208 buffer = sdhci_kmap_sg(host) + host->offset; 209 210 - /* Transfer shouldn't take more than 5 s */ 211 - max_jiffies = jiffies + HZ * 5; 212 - 213 - while (host->size > 0) { 214 - if (time_after(jiffies, max_jiffies)) { 215 - printk(KERN_ERR "%s: PIO transfer stalled. " 216 - "Please report this to " 217 - BUGMAIL ".\n", mmc_hostname(host->mmc)); 218 - sdhci_dumpregs(host); 219 - 220 - sdhci_kunmap_sg(host); 221 - 222 - host->data->error = MMC_ERR_FAILED; 223 - sdhci_finish_data(host); 224 - return; 225 } 226 - 227 - if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) & mask)) 228 - continue; 229 230 size = min(host->size, host->remain); 231 232 - if (size >= 4) { 233 - if (host->data->flags & MMC_DATA_READ) 234 - *(u32*)buffer = readl(host->ioaddr + SDHCI_BUFFER); 235 - else 236 - writel(*(u32*)buffer, host->ioaddr + SDHCI_BUFFER); 237 - size = 4; 238 - } else if (size >= 2) { 239 - if (host->data->flags & MMC_DATA_READ) 240 - *(u16*)buffer = readw(host->ioaddr + SDHCI_BUFFER); 241 - else 242 - writew(*(u16*)buffer, host->ioaddr + SDHCI_BUFFER); 243 - size = 2; 244 - } else { 245 - if (host->data->flags & MMC_DATA_READ) 246 - *(u8*)buffer = readb(host->ioaddr + SDHCI_BUFFER); 247 - else 248 - writeb(*(u8*)buffer, host->ioaddr + SDHCI_BUFFER); 249 - size = 1; 250 - } 251 - 252 - buffer += size; 253 host->offset += size; 254 host->remain -= size; 255 - 256 - bytes += size; 257 host->size -= size; 258 259 if (host->remain == 0) { 260 sdhci_kunmap_sg(host); 261 if (sdhci_next_sg(host) == 0) { 262 - DBG("PIO transfer: %d bytes\n", bytes); 263 return; 264 } 265 buffer = sdhci_kmap_sg(host); ··· 234 } 235 236 sdhci_kunmap_sg(host); 237 238 - DBG("PIO transfer: %d bytes\n", bytes); 239 } 240 241 static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data) 242 { 243 - u16 mode; 244 245 WARN_ON(host->data); 246 247 - if (data == NULL) { 248 - writew(0, host->ioaddr + SDHCI_TRANSFER_MODE); 249 return; 250 - } 251 252 DBG("blksz %04x blks %04x flags %08x\n", 253 data->blksz, data->blocks, data->flags); 254 DBG("tsac %d ms nsac %d clk\n", 255 data->timeout_ns / 1000000, data->timeout_clks); 256 257 - mode = SDHCI_TRNS_BLK_CNT_EN; 258 - if (data->blocks > 1) 259 - mode |= SDHCI_TRNS_MULTI; 260 - if (data->flags & MMC_DATA_READ) 261 - mode |= SDHCI_TRNS_READ; 262 - if (host->flags & SDHCI_USE_DMA) 263 - mode |= SDHCI_TRNS_DMA; 264 265 - writew(mode, host->ioaddr + SDHCI_TRANSFER_MODE); 266 267 - writew(data->blksz, host->ioaddr + SDHCI_BLOCK_SIZE); 268 - writew(data->blocks, host->ioaddr + SDHCI_BLOCK_COUNT); 269 270 if (host->flags & SDHCI_USE_DMA) { 271 int count; ··· 383 host->offset = 0; 384 host->remain = host->cur_sg->length; 385 } 386 } 387 388 static void sdhci_finish_data(struct sdhci_host *host) 389 { 390 struct mmc_data *data; 391 - u32 intmask; 392 u16 blocks; 393 394 BUG_ON(!host->data); ··· 424 if (host->flags & SDHCI_USE_DMA) { 425 pci_unmap_sg(host->chip->pdev, data->sg, data->sg_len, 426 (data->flags & MMC_DATA_READ)?PCI_DMA_FROMDEVICE:PCI_DMA_TODEVICE); 427 - } else { 428 - intmask = readl(host->ioaddr + SDHCI_SIGNAL_ENABLE); 429 - intmask &= ~(SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL); 430 - writel(intmask, host->ioaddr + SDHCI_SIGNAL_ENABLE); 431 - 432 - intmask = readl(host->ioaddr + SDHCI_INT_ENABLE); 433 - intmask &= ~(SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL); 434 - writel(intmask, host->ioaddr + SDHCI_INT_ENABLE); 435 } 436 437 /* ··· 469 static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) 470 { 471 int flags; 472 - u32 present; 473 - unsigned long max_jiffies; 474 475 WARN_ON(host->cmd); 476 477 DBG("Sending cmd (%x)\n", cmd->opcode); 478 479 /* Wait max 10 ms */ 480 - max_jiffies = jiffies + (HZ + 99)/100; 481 - do { 482 - if (time_after(jiffies, max_jiffies)) { 483 printk(KERN_ERR "%s: Controller never released " 484 - "inhibit bits. Please report this to " 485 BUGMAIL ".\n", mmc_hostname(host->mmc)); 486 sdhci_dumpregs(host); 487 cmd->error = MMC_ERR_FAILED; 488 tasklet_schedule(&host->finish_tasklet); 489 return; 490 } 491 - present = readl(host->ioaddr + SDHCI_PRESENT_STATE); 492 - } while (present & (SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT)); 493 494 mod_timer(&host->timer, jiffies + 10 * HZ); 495 ··· 509 sdhci_prepare_data(host, cmd->data); 510 511 writel(cmd->arg, host->ioaddr + SDHCI_ARGUMENT); 512 513 if ((cmd->flags & MMC_RSP_136) && (cmd->flags & MMC_RSP_BUSY)) { 514 printk(KERN_ERR "%s: Unsupported response type! " ··· 567 568 DBG("Ending cmd (%x)\n", host->cmd->opcode); 569 570 - if (host->cmd->data) { 571 - u32 intmask; 572 - 573 host->data = host->cmd->data; 574 - 575 - if (!(host->flags & SDHCI_USE_DMA)) { 576 - /* 577 - * Don't enable the interrupts until now to make sure we 578 - * get stable handling of the FIFO. 579 - */ 580 - intmask = readl(host->ioaddr + SDHCI_INT_ENABLE); 581 - intmask |= SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL; 582 - writel(intmask, host->ioaddr + SDHCI_INT_ENABLE); 583 - 584 - intmask = readl(host->ioaddr + SDHCI_SIGNAL_ENABLE); 585 - intmask |= SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL; 586 - writel(intmask, host->ioaddr + SDHCI_SIGNAL_ENABLE); 587 - 588 - /* 589 - * The buffer interrupts are to unreliable so we 590 - * start the transfer immediatly. 591 - */ 592 - sdhci_transfer_pio(host); 593 - } 594 - } else 595 tasklet_schedule(&host->finish_tasklet); 596 597 host->cmd = NULL; ··· 579 { 580 int div; 581 u16 clk; 582 - unsigned long max_jiffies; 583 584 if (clock == host->clock) 585 return; ··· 600 writew(clk, host->ioaddr + SDHCI_CLOCK_CONTROL); 601 602 /* Wait max 10 ms */ 603 - max_jiffies = jiffies + (HZ + 99)/100; 604 - do { 605 - if (time_after(jiffies, max_jiffies)) { 606 printk(KERN_ERR "%s: Internal clock never stabilised. " 607 "Please report this to " BUGMAIL ".\n", 608 mmc_hostname(host->mmc)); 609 sdhci_dumpregs(host); 610 return; 611 } 612 - clk = readw(host->ioaddr + SDHCI_CLOCK_CONTROL); 613 - } while (!(clk & SDHCI_CLOCK_INT_STABLE)); 614 615 clk |= SDHCI_CLOCK_CARD_EN; 616 writew(clk, host->ioaddr + SDHCI_CLOCK_CONTROL); 617 618 out: 619 host->clock = clock; 620 } 621 622 /*****************************************************************************\ ··· 707 */ 708 if (ios->power_mode == MMC_POWER_OFF) { 709 writel(0, host->ioaddr + SDHCI_SIGNAL_ENABLE); 710 - spin_unlock_irqrestore(&host->lock, flags); 711 sdhci_init(host); 712 - spin_lock_irqsave(&host->lock, flags); 713 } 714 715 sdhci_set_clock(host, ios->clock); 716 717 if (ios->power_mode == MMC_POWER_OFF) 718 - writeb(0, host->ioaddr + SDHCI_POWER_CONTROL); 719 else 720 - writeb(0xFF, host->ioaddr + SDHCI_POWER_CONTROL); 721 722 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL); 723 if (ios->bus_width == MMC_BUS_WIDTH_4) ··· 922 if (host->data->error != MMC_ERR_NONE) 923 sdhci_finish_data(host); 924 else { 925 - if (intmask & (SDHCI_INT_BUF_FULL | SDHCI_INT_BUF_EMPTY)) 926 sdhci_transfer_pio(host); 927 928 if (intmask & SDHCI_INT_DATA_END) ··· 947 948 DBG("*** %s got interrupt: 0x%08x\n", host->slot_descr, intmask); 949 950 - if (intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE)) 951 tasklet_schedule(&host->card_tasklet); 952 953 if (intmask & SDHCI_INT_CMD_MASK) { 954 - sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK); 955 - 956 writel(intmask & SDHCI_INT_CMD_MASK, 957 host->ioaddr + SDHCI_INT_STATUS); 958 } 959 960 if (intmask & SDHCI_INT_DATA_MASK) { 961 - sdhci_data_irq(host, intmask & SDHCI_INT_DATA_MASK); 962 - 963 writel(intmask & SDHCI_INT_DATA_MASK, 964 host->ioaddr + SDHCI_INT_STATUS); 965 } 966 967 intmask &= ~(SDHCI_INT_CMD_MASK | SDHCI_INT_DATA_MASK); 968 969 - if (intmask & SDHCI_INT_CARD_INT) { 970 - printk(KERN_ERR "%s: Unexpected card interrupt. Please " 971 - "report this to " BUGMAIL ".\n", 972 - mmc_hostname(host->mmc)); 973 - sdhci_dumpregs(host); 974 - } 975 - 976 if (intmask & SDHCI_INT_BUS_POWER) { 977 - printk(KERN_ERR "%s: Unexpected bus power interrupt. Please " 978 - "report this to " BUGMAIL ".\n", 979 mmc_hostname(host->mmc)); 980 - sdhci_dumpregs(host); 981 } 982 983 - if (intmask & SDHCI_INT_ACMD12ERR) { 984 - printk(KERN_ERR "%s: Unexpected auto CMD12 error. Please " 985 "report this to " BUGMAIL ".\n", 986 - mmc_hostname(host->mmc)); 987 sdhci_dumpregs(host); 988 989 - writew(~0, host->ioaddr + SDHCI_ACMD12_ERR); 990 - } 991 - 992 - if (intmask) 993 writel(intmask, host->ioaddr + SDHCI_INT_STATUS); 994 995 result = IRQ_HANDLED; 996 ··· 1077 static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot) 1078 { 1079 int ret; 1080 struct sdhci_chip *chip; 1081 struct mmc_host *mmc; 1082 struct sdhci_host *host; ··· 1109 return -ENODEV; 1110 } 1111 1112 mmc = mmc_alloc_host(sizeof(struct sdhci_host), &pdev->dev); 1113 if (!mmc) 1114 return -ENOMEM; ··· 1146 goto release; 1147 } 1148 1149 caps = readl(host->ioaddr + SDHCI_CAPABILITIES); 1150 1151 - if ((caps & SDHCI_CAN_DO_DMA) && ((pdev->class & 0x0000FF) == 0x01)) 1152 host->flags |= SDHCI_USE_DMA; 1153 1154 if (host->flags & SDHCI_USE_DMA) { ··· 1185 else /* XXX: Hack to get MMC layer to avoid highmem */ 1186 pdev->dma_mask = 0; 1187 1188 - host->max_clk = (caps & SDHCI_CLOCK_BASE_MASK) >> SDHCI_CLOCK_BASE_SHIFT; 1189 host->max_clk *= 1000000; 1190 1191 /* 1192 * Set host parameters. ··· 1221 mmc->ops = &sdhci_ops; 1222 mmc->f_min = host->max_clk / 256; 1223 mmc->f_max = host->max_clk; 1224 - mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34; 1225 mmc->caps = MMC_CAP_4_BIT_DATA; 1226 1227 spin_lock_init(&host->lock); 1228 ··· 1250 mmc->max_phys_segs = 16; 1251 1252 /* 1253 - * Maximum number of sectors in one transfer. Limited by sector 1254 - * count register. 1255 */ 1256 - mmc->max_sectors = 0x3FFF; 1257 1258 /* 1259 * Maximum segment size. Could be one segment with the maximum number ··· 1274 ret = request_irq(host->irq, sdhci_irq, IRQF_SHARED, 1275 host->slot_descr, host); 1276 if (ret) 1277 - goto unmap; 1278 1279 sdhci_init(host); 1280 ··· 1293 1294 return 0; 1295 1296 - unmap: 1297 tasklet_kill(&host->card_tasklet); 1298 tasklet_kill(&host->finish_tasklet); 1299 - 1300 iounmap(host->ioaddr); 1301 release: 1302 pci_release_region(pdev, host->bar); ··· 1340 const struct pci_device_id *ent) 1341 { 1342 int ret, i; 1343 - u8 slots; 1344 struct sdhci_chip *chip; 1345 1346 BUG_ON(pdev == NULL); 1347 BUG_ON(ent == NULL); 1348 1349 - DBG("found at %s\n", pci_name(pdev)); 1350 1351 ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &slots); 1352 if (ret) ··· 1374 } 1375 1376 chip->pdev = pdev; 1377 1378 chip->num_slots = slots; 1379 pci_set_drvdata(pdev, chip); ··· 1456 module_init(sdhci_drv_init); 1457 module_exit(sdhci_drv_exit); 1458 1459 MODULE_AUTHOR("Pierre Ossman <drzeus@drzeus.cx>"); 1460 MODULE_DESCRIPTION("Secure Digital Host Controller Interface driver"); 1461 MODULE_VERSION(DRIVER_VERSION); 1462 MODULE_LICENSE("GPL");
··· 8 * published by the Free Software Foundation. 9 */ 10 11 #include <linux/delay.h> 12 #include <linux/highmem.h> 13 #include <linux/pci.h> ··· 27 #include "sdhci.h" 28 29 #define DRIVER_NAME "sdhci" 30 + #define DRIVER_VERSION "0.12" 31 32 #define BUGMAIL "<sdhci-devel@list.drzeus.cx>" 33 34 #define DBG(f, x...) \ 35 pr_debug(DRIVER_NAME " [%s()]: " f, __func__,## x) 36 + 37 + static unsigned int debug_nodma = 0; 38 + static unsigned int debug_forcedma = 0; 39 + static unsigned int debug_quirks = 0; 40 41 static const struct pci_device_id pci_ids[] __devinitdata = { 42 /* handle any SD host controller */ ··· 94 95 static void sdhci_reset(struct sdhci_host *host, u8 mask) 96 { 97 + unsigned long timeout; 98 + 99 writeb(mask, host->ioaddr + SDHCI_SOFTWARE_RESET); 100 101 + if (mask & SDHCI_RESET_ALL) 102 host->clock = 0; 103 104 + /* Wait max 100 ms */ 105 + timeout = 100; 106 + 107 + /* hw clears the bit when it's done */ 108 + while (readb(host->ioaddr + SDHCI_SOFTWARE_RESET) & mask) { 109 + if (timeout == 0) { 110 + printk(KERN_ERR "%s: Reset 0x%x never completed. " 111 + "Please report this to " BUGMAIL ".\n", 112 + mmc_hostname(host->mmc), (int)mask); 113 + sdhci_dumpregs(host); 114 + return; 115 + } 116 + timeout--; 117 + mdelay(1); 118 } 119 } 120 ··· 109 110 sdhci_reset(host, SDHCI_RESET_ALL); 111 112 + intmask = SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT | 113 + SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_INDEX | 114 + SDHCI_INT_END_BIT | SDHCI_INT_CRC | SDHCI_INT_TIMEOUT | 115 + SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT | 116 + SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL | 117 + SDHCI_INT_DMA_END | SDHCI_INT_DATA_END | SDHCI_INT_RESPONSE; 118 119 writel(intmask, host->ioaddr + SDHCI_INT_ENABLE); 120 writel(intmask, host->ioaddr + SDHCI_SIGNAL_ENABLE); 121 } 122 123 static void sdhci_activate_led(struct sdhci_host *host) ··· 172 return host->num_sg; 173 } 174 175 + static void sdhci_read_block_pio(struct sdhci_host *host) 176 { 177 + int blksize, chunk_remain; 178 + u32 data; 179 char *buffer; 180 + int size; 181 182 + DBG("PIO reading\n"); 183 184 + blksize = host->data->blksz; 185 + chunk_remain = 0; 186 + data = 0; 187 188 buffer = sdhci_kmap_sg(host) + host->offset; 189 190 + while (blksize) { 191 + if (chunk_remain == 0) { 192 + data = readl(host->ioaddr + SDHCI_BUFFER); 193 + chunk_remain = min(blksize, 4); 194 } 195 196 size = min(host->size, host->remain); 197 + size = min(size, chunk_remain); 198 199 + chunk_remain -= size; 200 + blksize -= size; 201 host->offset += size; 202 host->remain -= size; 203 host->size -= size; 204 + while (size) { 205 + *buffer = data & 0xFF; 206 + buffer++; 207 + data >>= 8; 208 + size--; 209 + } 210 211 if (host->remain == 0) { 212 sdhci_kunmap_sg(host); 213 if (sdhci_next_sg(host) == 0) { 214 + BUG_ON(blksize != 0); 215 return; 216 } 217 buffer = sdhci_kmap_sg(host); ··· 252 } 253 254 sdhci_kunmap_sg(host); 255 + } 256 257 + static void sdhci_write_block_pio(struct sdhci_host *host) 258 + { 259 + int blksize, chunk_remain; 260 + u32 data; 261 + char *buffer; 262 + int bytes, size; 263 + 264 + DBG("PIO writing\n"); 265 + 266 + blksize = host->data->blksz; 267 + chunk_remain = 4; 268 + data = 0; 269 + 270 + bytes = 0; 271 + buffer = sdhci_kmap_sg(host) + host->offset; 272 + 273 + while (blksize) { 274 + size = min(host->size, host->remain); 275 + size = min(size, chunk_remain); 276 + 277 + chunk_remain -= size; 278 + blksize -= size; 279 + host->offset += size; 280 + host->remain -= size; 281 + host->size -= size; 282 + while (size) { 283 + data >>= 8; 284 + data |= (u32)*buffer << 24; 285 + buffer++; 286 + size--; 287 + } 288 + 289 + if (chunk_remain == 0) { 290 + writel(data, host->ioaddr + SDHCI_BUFFER); 291 + chunk_remain = min(blksize, 4); 292 + } 293 + 294 + if (host->remain == 0) { 295 + sdhci_kunmap_sg(host); 296 + if (sdhci_next_sg(host) == 0) { 297 + BUG_ON(blksize != 0); 298 + return; 299 + } 300 + buffer = sdhci_kmap_sg(host); 301 + } 302 + } 303 + 304 + sdhci_kunmap_sg(host); 305 + } 306 + 307 + static void sdhci_transfer_pio(struct sdhci_host *host) 308 + { 309 + u32 mask; 310 + 311 + BUG_ON(!host->data); 312 + 313 + if (host->size == 0) 314 + return; 315 + 316 + if (host->data->flags & MMC_DATA_READ) 317 + mask = SDHCI_DATA_AVAILABLE; 318 + else 319 + mask = SDHCI_SPACE_AVAILABLE; 320 + 321 + while (readl(host->ioaddr + SDHCI_PRESENT_STATE) & mask) { 322 + if (host->data->flags & MMC_DATA_READ) 323 + sdhci_read_block_pio(host); 324 + else 325 + sdhci_write_block_pio(host); 326 + 327 + if (host->size == 0) 328 + break; 329 + 330 + BUG_ON(host->num_sg == 0); 331 + } 332 + 333 + DBG("PIO transfer complete.\n"); 334 } 335 336 static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data) 337 { 338 + u8 count; 339 + unsigned target_timeout, current_timeout; 340 341 WARN_ON(host->data); 342 343 + if (data == NULL) 344 return; 345 346 DBG("blksz %04x blks %04x flags %08x\n", 347 data->blksz, data->blocks, data->flags); 348 DBG("tsac %d ms nsac %d clk\n", 349 data->timeout_ns / 1000000, data->timeout_clks); 350 351 + /* Sanity checks */ 352 + BUG_ON(data->blksz * data->blocks > 524288); 353 + BUG_ON(data->blksz > host->max_block); 354 + BUG_ON(data->blocks > 65535); 355 356 + /* timeout in us */ 357 + target_timeout = data->timeout_ns / 1000 + 358 + data->timeout_clks / host->clock; 359 360 + /* 361 + * Figure out needed cycles. 362 + * We do this in steps in order to fit inside a 32 bit int. 363 + * The first step is the minimum timeout, which will have a 364 + * minimum resolution of 6 bits: 365 + * (1) 2^13*1000 > 2^22, 366 + * (2) host->timeout_clk < 2^16 367 + * => 368 + * (1) / (2) > 2^6 369 + */ 370 + count = 0; 371 + current_timeout = (1 << 13) * 1000 / host->timeout_clk; 372 + while (current_timeout < target_timeout) { 373 + count++; 374 + current_timeout <<= 1; 375 + if (count >= 0xF) 376 + break; 377 + } 378 + 379 + if (count >= 0xF) { 380 + printk(KERN_WARNING "%s: Too large timeout requested!\n", 381 + mmc_hostname(host->mmc)); 382 + count = 0xE; 383 + } 384 + 385 + writeb(count, host->ioaddr + SDHCI_TIMEOUT_CONTROL); 386 387 if (host->flags & SDHCI_USE_DMA) { 388 int count; ··· 302 host->offset = 0; 303 host->remain = host->cur_sg->length; 304 } 305 + 306 + /* We do not handle DMA boundaries, so set it to max (512 KiB) */ 307 + writew(SDHCI_MAKE_BLKSZ(7, data->blksz), 308 + host->ioaddr + SDHCI_BLOCK_SIZE); 309 + writew(data->blocks, host->ioaddr + SDHCI_BLOCK_COUNT); 310 + } 311 + 312 + static void sdhci_set_transfer_mode(struct sdhci_host *host, 313 + struct mmc_data *data) 314 + { 315 + u16 mode; 316 + 317 + WARN_ON(host->data); 318 + 319 + if (data == NULL) 320 + return; 321 + 322 + mode = SDHCI_TRNS_BLK_CNT_EN; 323 + if (data->blocks > 1) 324 + mode |= SDHCI_TRNS_MULTI; 325 + if (data->flags & MMC_DATA_READ) 326 + mode |= SDHCI_TRNS_READ; 327 + if (host->flags & SDHCI_USE_DMA) 328 + mode |= SDHCI_TRNS_DMA; 329 + 330 + writew(mode, host->ioaddr + SDHCI_TRANSFER_MODE); 331 } 332 333 static void sdhci_finish_data(struct sdhci_host *host) 334 { 335 struct mmc_data *data; 336 u16 blocks; 337 338 BUG_ON(!host->data); ··· 318 if (host->flags & SDHCI_USE_DMA) { 319 pci_unmap_sg(host->chip->pdev, data->sg, data->sg_len, 320 (data->flags & MMC_DATA_READ)?PCI_DMA_FROMDEVICE:PCI_DMA_TODEVICE); 321 } 322 323 /* ··· 371 static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) 372 { 373 int flags; 374 + u32 mask; 375 + unsigned long timeout; 376 377 WARN_ON(host->cmd); 378 379 DBG("Sending cmd (%x)\n", cmd->opcode); 380 381 /* Wait max 10 ms */ 382 + timeout = 10; 383 + 384 + mask = SDHCI_CMD_INHIBIT; 385 + if ((cmd->data != NULL) || (cmd->flags & MMC_RSP_BUSY)) 386 + mask |= SDHCI_DATA_INHIBIT; 387 + 388 + /* We shouldn't wait for data inihibit for stop commands, even 389 + though they might use busy signaling */ 390 + if (host->mrq->data && (cmd == host->mrq->data->stop)) 391 + mask &= ~SDHCI_DATA_INHIBIT; 392 + 393 + while (readl(host->ioaddr + SDHCI_PRESENT_STATE) & mask) { 394 + if (timeout == 0) { 395 printk(KERN_ERR "%s: Controller never released " 396 + "inhibit bit(s). Please report this to " 397 BUGMAIL ".\n", mmc_hostname(host->mmc)); 398 sdhci_dumpregs(host); 399 cmd->error = MMC_ERR_FAILED; 400 tasklet_schedule(&host->finish_tasklet); 401 return; 402 } 403 + timeout--; 404 + mdelay(1); 405 + } 406 407 mod_timer(&host->timer, jiffies + 10 * HZ); 408 ··· 400 sdhci_prepare_data(host, cmd->data); 401 402 writel(cmd->arg, host->ioaddr + SDHCI_ARGUMENT); 403 + 404 + sdhci_set_transfer_mode(host, cmd->data); 405 406 if ((cmd->flags & MMC_RSP_136) && (cmd->flags & MMC_RSP_BUSY)) { 407 printk(KERN_ERR "%s: Unsupported response type! " ··· 456 457 DBG("Ending cmd (%x)\n", host->cmd->opcode); 458 459 + if (host->cmd->data) 460 host->data = host->cmd->data; 461 + else 462 tasklet_schedule(&host->finish_tasklet); 463 464 host->cmd = NULL; ··· 490 { 491 int div; 492 u16 clk; 493 + unsigned long timeout; 494 495 if (clock == host->clock) 496 return; ··· 511 writew(clk, host->ioaddr + SDHCI_CLOCK_CONTROL); 512 513 /* Wait max 10 ms */ 514 + timeout = 10; 515 + while (!((clk = readw(host->ioaddr + SDHCI_CLOCK_CONTROL)) 516 + & SDHCI_CLOCK_INT_STABLE)) { 517 + if (timeout == 0) { 518 printk(KERN_ERR "%s: Internal clock never stabilised. " 519 "Please report this to " BUGMAIL ".\n", 520 mmc_hostname(host->mmc)); 521 sdhci_dumpregs(host); 522 return; 523 } 524 + timeout--; 525 + mdelay(1); 526 + } 527 528 clk |= SDHCI_CLOCK_CARD_EN; 529 writew(clk, host->ioaddr + SDHCI_CLOCK_CONTROL); 530 531 out: 532 host->clock = clock; 533 + } 534 + 535 + static void sdhci_set_power(struct sdhci_host *host, unsigned short power) 536 + { 537 + u8 pwr; 538 + 539 + if (host->power == power) 540 + return; 541 + 542 + writeb(0, host->ioaddr + SDHCI_POWER_CONTROL); 543 + 544 + if (power == (unsigned short)-1) 545 + goto out; 546 + 547 + pwr = SDHCI_POWER_ON; 548 + 549 + switch (power) { 550 + case MMC_VDD_170: 551 + case MMC_VDD_180: 552 + case MMC_VDD_190: 553 + pwr |= SDHCI_POWER_180; 554 + break; 555 + case MMC_VDD_290: 556 + case MMC_VDD_300: 557 + case MMC_VDD_310: 558 + pwr |= SDHCI_POWER_300; 559 + break; 560 + case MMC_VDD_320: 561 + case MMC_VDD_330: 562 + case MMC_VDD_340: 563 + pwr |= SDHCI_POWER_330; 564 + break; 565 + default: 566 + BUG(); 567 + } 568 + 569 + writeb(pwr, host->ioaddr + SDHCI_POWER_CONTROL); 570 + 571 + out: 572 + host->power = power; 573 } 574 575 /*****************************************************************************\ ··· 576 */ 577 if (ios->power_mode == MMC_POWER_OFF) { 578 writel(0, host->ioaddr + SDHCI_SIGNAL_ENABLE); 579 sdhci_init(host); 580 } 581 582 sdhci_set_clock(host, ios->clock); 583 584 if (ios->power_mode == MMC_POWER_OFF) 585 + sdhci_set_power(host, -1); 586 else 587 + sdhci_set_power(host, ios->vdd); 588 589 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL); 590 if (ios->bus_width == MMC_BUS_WIDTH_4) ··· 793 if (host->data->error != MMC_ERR_NONE) 794 sdhci_finish_data(host); 795 else { 796 + if (intmask & (SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL)) 797 sdhci_transfer_pio(host); 798 799 if (intmask & SDHCI_INT_DATA_END) ··· 818 819 DBG("*** %s got interrupt: 0x%08x\n", host->slot_descr, intmask); 820 821 + if (intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE)) { 822 + writel(intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE), 823 + host->ioaddr + SDHCI_INT_STATUS); 824 tasklet_schedule(&host->card_tasklet); 825 + } 826 + 827 + intmask &= ~(SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE); 828 829 if (intmask & SDHCI_INT_CMD_MASK) { 830 writel(intmask & SDHCI_INT_CMD_MASK, 831 host->ioaddr + SDHCI_INT_STATUS); 832 + sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK); 833 } 834 835 if (intmask & SDHCI_INT_DATA_MASK) { 836 writel(intmask & SDHCI_INT_DATA_MASK, 837 host->ioaddr + SDHCI_INT_STATUS); 838 + sdhci_data_irq(host, intmask & SDHCI_INT_DATA_MASK); 839 } 840 841 intmask &= ~(SDHCI_INT_CMD_MASK | SDHCI_INT_DATA_MASK); 842 843 if (intmask & SDHCI_INT_BUS_POWER) { 844 + printk(KERN_ERR "%s: Card is consuming too much power!\n", 845 mmc_hostname(host->mmc)); 846 + writel(SDHCI_INT_BUS_POWER, host->ioaddr + SDHCI_INT_STATUS); 847 } 848 849 + intmask &= SDHCI_INT_BUS_POWER; 850 + 851 + if (intmask) { 852 + printk(KERN_ERR "%s: Unexpected interrupt 0x%08x. Please " 853 "report this to " BUGMAIL ".\n", 854 + mmc_hostname(host->mmc), intmask); 855 sdhci_dumpregs(host); 856 857 writel(intmask, host->ioaddr + SDHCI_INT_STATUS); 858 + } 859 860 result = IRQ_HANDLED; 861 ··· 954 static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot) 955 { 956 int ret; 957 + unsigned int version; 958 struct sdhci_chip *chip; 959 struct mmc_host *mmc; 960 struct sdhci_host *host; ··· 985 return -ENODEV; 986 } 987 988 + if ((pdev->class & 0x0000FF) == PCI_SDHCI_IFVENDOR) { 989 + printk(KERN_ERR DRIVER_NAME ": Vendor specific interface. Aborting.\n"); 990 + return -ENODEV; 991 + } 992 + 993 + if ((pdev->class & 0x0000FF) > PCI_SDHCI_IFVENDOR) { 994 + printk(KERN_ERR DRIVER_NAME ": Unknown interface. Aborting.\n"); 995 + return -ENODEV; 996 + } 997 + 998 mmc = mmc_alloc_host(sizeof(struct sdhci_host), &pdev->dev); 999 if (!mmc) 1000 return -ENOMEM; ··· 1012 goto release; 1013 } 1014 1015 + sdhci_reset(host, SDHCI_RESET_ALL); 1016 + 1017 + version = readw(host->ioaddr + SDHCI_HOST_VERSION); 1018 + version = (version & SDHCI_SPEC_VER_MASK) >> SDHCI_SPEC_VER_SHIFT; 1019 + if (version != 0) { 1020 + printk(KERN_ERR "%s: Unknown controller version (%d). " 1021 + "Cowardly refusing to continue.\n", host->slot_descr, 1022 + version); 1023 + ret = -ENODEV; 1024 + goto unmap; 1025 + } 1026 + 1027 caps = readl(host->ioaddr + SDHCI_CAPABILITIES); 1028 1029 + if (debug_nodma) 1030 + DBG("DMA forced off\n"); 1031 + else if (debug_forcedma) { 1032 + DBG("DMA forced on\n"); 1033 + host->flags |= SDHCI_USE_DMA; 1034 + } else if ((pdev->class & 0x0000FF) != PCI_SDHCI_IFDMA) 1035 + DBG("Controller doesn't have DMA interface\n"); 1036 + else if (!(caps & SDHCI_CAN_DO_DMA)) 1037 + DBG("Controller doesn't have DMA capability\n"); 1038 + else 1039 host->flags |= SDHCI_USE_DMA; 1040 1041 if (host->flags & SDHCI_USE_DMA) { ··· 1030 else /* XXX: Hack to get MMC layer to avoid highmem */ 1031 pdev->dma_mask = 0; 1032 1033 + host->max_clk = 1034 + (caps & SDHCI_CLOCK_BASE_MASK) >> SDHCI_CLOCK_BASE_SHIFT; 1035 + if (host->max_clk == 0) { 1036 + printk(KERN_ERR "%s: Hardware doesn't specify base clock " 1037 + "frequency.\n", host->slot_descr); 1038 + ret = -ENODEV; 1039 + goto unmap; 1040 + } 1041 host->max_clk *= 1000000; 1042 + 1043 + host->timeout_clk = 1044 + (caps & SDHCI_TIMEOUT_CLK_MASK) >> SDHCI_TIMEOUT_CLK_SHIFT; 1045 + if (host->timeout_clk == 0) { 1046 + printk(KERN_ERR "%s: Hardware doesn't specify timeout clock " 1047 + "frequency.\n", host->slot_descr); 1048 + ret = -ENODEV; 1049 + goto unmap; 1050 + } 1051 + if (caps & SDHCI_TIMEOUT_CLK_UNIT) 1052 + host->timeout_clk *= 1000; 1053 + 1054 + host->max_block = (caps & SDHCI_MAX_BLOCK_MASK) >> SDHCI_MAX_BLOCK_SHIFT; 1055 + if (host->max_block >= 3) { 1056 + printk(KERN_ERR "%s: Invalid maximum block size.\n", 1057 + host->slot_descr); 1058 + ret = -ENODEV; 1059 + goto unmap; 1060 + } 1061 + host->max_block = 512 << host->max_block; 1062 1063 /* 1064 * Set host parameters. ··· 1039 mmc->ops = &sdhci_ops; 1040 mmc->f_min = host->max_clk / 256; 1041 mmc->f_max = host->max_clk; 1042 mmc->caps = MMC_CAP_4_BIT_DATA; 1043 + 1044 + mmc->ocr_avail = 0; 1045 + if (caps & SDHCI_CAN_VDD_330) 1046 + mmc->ocr_avail |= MMC_VDD_32_33|MMC_VDD_33_34; 1047 + else if (caps & SDHCI_CAN_VDD_300) 1048 + mmc->ocr_avail |= MMC_VDD_29_30|MMC_VDD_30_31; 1049 + else if (caps & SDHCI_CAN_VDD_180) 1050 + mmc->ocr_avail |= MMC_VDD_17_18|MMC_VDD_18_19; 1051 + 1052 + if (mmc->ocr_avail == 0) { 1053 + printk(KERN_ERR "%s: Hardware doesn't report any " 1054 + "support voltages.\n", host->slot_descr); 1055 + ret = -ENODEV; 1056 + goto unmap; 1057 + } 1058 1059 spin_lock_init(&host->lock); 1060 ··· 1054 mmc->max_phys_segs = 16; 1055 1056 /* 1057 + * Maximum number of sectors in one transfer. Limited by DMA boundary 1058 + * size (512KiB), which means (512 KiB/512=) 1024 entries. 1059 */ 1060 + mmc->max_sectors = 1024; 1061 1062 /* 1063 * Maximum segment size. Could be one segment with the maximum number ··· 1078 ret = request_irq(host->irq, sdhci_irq, IRQF_SHARED, 1079 host->slot_descr, host); 1080 if (ret) 1081 + goto untasklet; 1082 1083 sdhci_init(host); 1084 ··· 1097 1098 return 0; 1099 1100 + untasklet: 1101 tasklet_kill(&host->card_tasklet); 1102 tasklet_kill(&host->finish_tasklet); 1103 + unmap: 1104 iounmap(host->ioaddr); 1105 release: 1106 pci_release_region(pdev, host->bar); ··· 1144 const struct pci_device_id *ent) 1145 { 1146 int ret, i; 1147 + u8 slots, rev; 1148 struct sdhci_chip *chip; 1149 1150 BUG_ON(pdev == NULL); 1151 BUG_ON(ent == NULL); 1152 1153 + pci_read_config_byte(pdev, PCI_CLASS_REVISION, &rev); 1154 + 1155 + printk(KERN_INFO DRIVER_NAME 1156 + ": SDHCI controller found at %s [%04x:%04x] (rev %x)\n", 1157 + pci_name(pdev), (int)pdev->vendor, (int)pdev->device, 1158 + (int)rev); 1159 1160 ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &slots); 1161 if (ret) ··· 1173 } 1174 1175 chip->pdev = pdev; 1176 + chip->quirks = ent->driver_data; 1177 + 1178 + if (debug_quirks) 1179 + chip->quirks = debug_quirks; 1180 1181 chip->num_slots = slots; 1182 pci_set_drvdata(pdev, chip); ··· 1251 module_init(sdhci_drv_init); 1252 module_exit(sdhci_drv_exit); 1253 1254 + module_param(debug_nodma, uint, 0444); 1255 + module_param(debug_forcedma, uint, 0444); 1256 + module_param(debug_quirks, uint, 0444); 1257 + 1258 MODULE_AUTHOR("Pierre Ossman <drzeus@drzeus.cx>"); 1259 MODULE_DESCRIPTION("Secure Digital Host Controller Interface driver"); 1260 MODULE_VERSION(DRIVER_VERSION); 1261 MODULE_LICENSE("GPL"); 1262 + 1263 + MODULE_PARM_DESC(debug_nodma, "Forcefully disable DMA transfers. (default 0)"); 1264 + MODULE_PARM_DESC(debug_forcedma, "Forcefully enable DMA transfers. (default 0)"); 1265 + MODULE_PARM_DESC(debug_quirks, "Force certain quirks.");
+30 -4
drivers/mmc/sdhci.h
··· 12 * PCI registers 13 */ 14 15 #define PCI_SLOT_INFO 0x40 /* 8 bits */ 16 #define PCI_SLOT_INFO_SLOTS(x) ((x >> 4) & 7) 17 #define PCI_SLOT_INFO_FIRST_BAR_MASK 0x07 ··· 27 #define SDHCI_DMA_ADDRESS 0x00 28 29 #define SDHCI_BLOCK_SIZE 0x04 30 31 #define SDHCI_BLOCK_COUNT 0x06 32 ··· 72 #define SDHCI_CTRL_4BITBUS 0x02 73 74 #define SDHCI_POWER_CONTROL 0x29 75 76 #define SDHCI_BLOCK_GAP_CONTROL 0x2A 77 ··· 100 #define SDHCI_INT_RESPONSE 0x00000001 101 #define SDHCI_INT_DATA_END 0x00000002 102 #define SDHCI_INT_DMA_END 0x00000008 103 - #define SDHCI_INT_BUF_EMPTY 0x00000010 104 - #define SDHCI_INT_BUF_FULL 0x00000020 105 #define SDHCI_INT_CARD_INSERT 0x00000040 106 #define SDHCI_INT_CARD_REMOVE 0x00000080 107 #define SDHCI_INT_CARD_INT 0x00000100 ··· 121 #define SDHCI_INT_CMD_MASK (SDHCI_INT_RESPONSE | SDHCI_INT_TIMEOUT | \ 122 SDHCI_INT_CRC | SDHCI_INT_END_BIT | SDHCI_INT_INDEX) 123 #define SDHCI_INT_DATA_MASK (SDHCI_INT_DATA_END | SDHCI_INT_DMA_END | \ 124 - SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL | \ 125 SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_DATA_CRC | \ 126 SDHCI_INT_DATA_END_BIT) 127 ··· 130 /* 3E-3F reserved */ 131 132 #define SDHCI_CAPABILITIES 0x40 133 - #define SDHCI_CAN_DO_DMA 0x00400000 134 #define SDHCI_CLOCK_BASE_MASK 0x00003F00 135 #define SDHCI_CLOCK_BASE_SHIFT 8 136 137 /* 44-47 reserved for more caps */ 138 ··· 153 #define SDHCI_SLOT_INT_STATUS 0xFC 154 155 #define SDHCI_HOST_VERSION 0xFE 156 157 struct sdhci_chip; 158 ··· 170 #define SDHCI_USE_DMA (1<<0) 171 172 unsigned int max_clk; /* Max possible freq (MHz) */ 173 174 unsigned int clock; /* Current clock (MHz) */ 175 176 struct mmc_request *mrq; /* Current request */ 177 struct mmc_command *cmd; /* Current command */ ··· 203 204 struct sdhci_chip { 205 struct pci_dev *pdev; 206 207 int num_slots; /* Slots on controller */ 208 struct sdhci_host *hosts[0]; /* Pointers to hosts */
··· 12 * PCI registers 13 */ 14 15 + #define PCI_SDHCI_IFPIO 0x00 16 + #define PCI_SDHCI_IFDMA 0x01 17 + #define PCI_SDHCI_IFVENDOR 0x02 18 + 19 #define PCI_SLOT_INFO 0x40 /* 8 bits */ 20 #define PCI_SLOT_INFO_SLOTS(x) ((x >> 4) & 7) 21 #define PCI_SLOT_INFO_FIRST_BAR_MASK 0x07 ··· 23 #define SDHCI_DMA_ADDRESS 0x00 24 25 #define SDHCI_BLOCK_SIZE 0x04 26 + #define SDHCI_MAKE_BLKSZ(dma, blksz) (((dma & 0x7) << 12) | (blksz & 0xFFF)) 27 28 #define SDHCI_BLOCK_COUNT 0x06 29 ··· 67 #define SDHCI_CTRL_4BITBUS 0x02 68 69 #define SDHCI_POWER_CONTROL 0x29 70 + #define SDHCI_POWER_ON 0x01 71 + #define SDHCI_POWER_180 0x0A 72 + #define SDHCI_POWER_300 0x0C 73 + #define SDHCI_POWER_330 0x0E 74 75 #define SDHCI_BLOCK_GAP_CONTROL 0x2A 76 ··· 91 #define SDHCI_INT_RESPONSE 0x00000001 92 #define SDHCI_INT_DATA_END 0x00000002 93 #define SDHCI_INT_DMA_END 0x00000008 94 + #define SDHCI_INT_SPACE_AVAIL 0x00000010 95 + #define SDHCI_INT_DATA_AVAIL 0x00000020 96 #define SDHCI_INT_CARD_INSERT 0x00000040 97 #define SDHCI_INT_CARD_REMOVE 0x00000080 98 #define SDHCI_INT_CARD_INT 0x00000100 ··· 112 #define SDHCI_INT_CMD_MASK (SDHCI_INT_RESPONSE | SDHCI_INT_TIMEOUT | \ 113 SDHCI_INT_CRC | SDHCI_INT_END_BIT | SDHCI_INT_INDEX) 114 #define SDHCI_INT_DATA_MASK (SDHCI_INT_DATA_END | SDHCI_INT_DMA_END | \ 115 + SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL | \ 116 SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_DATA_CRC | \ 117 SDHCI_INT_DATA_END_BIT) 118 ··· 121 /* 3E-3F reserved */ 122 123 #define SDHCI_CAPABILITIES 0x40 124 + #define SDHCI_TIMEOUT_CLK_MASK 0x0000003F 125 + #define SDHCI_TIMEOUT_CLK_SHIFT 0 126 + #define SDHCI_TIMEOUT_CLK_UNIT 0x00000080 127 #define SDHCI_CLOCK_BASE_MASK 0x00003F00 128 #define SDHCI_CLOCK_BASE_SHIFT 8 129 + #define SDHCI_MAX_BLOCK_MASK 0x00030000 130 + #define SDHCI_MAX_BLOCK_SHIFT 16 131 + #define SDHCI_CAN_DO_DMA 0x00400000 132 + #define SDHCI_CAN_VDD_330 0x01000000 133 + #define SDHCI_CAN_VDD_300 0x02000000 134 + #define SDHCI_CAN_VDD_180 0x04000000 135 136 /* 44-47 reserved for more caps */ 137 ··· 136 #define SDHCI_SLOT_INT_STATUS 0xFC 137 138 #define SDHCI_HOST_VERSION 0xFE 139 + #define SDHCI_VENDOR_VER_MASK 0xFF00 140 + #define SDHCI_VENDOR_VER_SHIFT 8 141 + #define SDHCI_SPEC_VER_MASK 0x00FF 142 + #define SDHCI_SPEC_VER_SHIFT 0 143 144 struct sdhci_chip; 145 ··· 149 #define SDHCI_USE_DMA (1<<0) 150 151 unsigned int max_clk; /* Max possible freq (MHz) */ 152 + unsigned int timeout_clk; /* Timeout freq (KHz) */ 153 + unsigned int max_block; /* Max block size (bytes) */ 154 155 unsigned int clock; /* Current clock (MHz) */ 156 + unsigned short power; /* Current voltage */ 157 158 struct mmc_request *mrq; /* Current request */ 159 struct mmc_command *cmd; /* Current command */ ··· 179 180 struct sdhci_chip { 181 struct pci_dev *pdev; 182 + 183 + unsigned long quirks; 184 185 int num_slots; /* Slots on controller */ 186 struct sdhci_host *hosts[0]; /* Pointers to hosts */