aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorPierre Ossman <drzeus@drzeus.cx>2006-11-21 11:54:23 -0500
committerPierre Ossman <drzeus@drzeus.cx>2007-02-04 14:54:10 -0500
commitfe4a3c7a20f14d86022a8132adbf6ddb98e7197c (patch)
tree0719b8eb2d8c04c286095365ebff3d29285a5796 /drivers/mmc
parentdba4accab17bd2e2e09088f746257a8c14af1cc2 (diff)
mmc: Allow host drivers to specify a max block size
Most controllers have an upper limit on the block size. Allow the host drivers to specify this and make sure we avoid hitting this limit. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/at91_mci.c2
-rw-r--r--drivers/mmc/au1xmmc.c2
-rw-r--r--drivers/mmc/imxmmc.c1
-rw-r--r--drivers/mmc/mmc.c4
-rw-r--r--drivers/mmc/mmci.c5
-rw-r--r--drivers/mmc/omap.c1
-rw-r--r--drivers/mmc/pxamci.c5
-rw-r--r--drivers/mmc/sdhci.c24
-rw-r--r--drivers/mmc/sdhci.h1
-rw-r--r--drivers/mmc/tifm_sd.c4
-rw-r--r--drivers/mmc/wbsd.c6
11 files changed, 43 insertions, 12 deletions
diff --git a/drivers/mmc/at91_mci.c b/drivers/mmc/at91_mci.c
index aa152f31851e..e28850dec9ed 100644
--- a/drivers/mmc/at91_mci.c
+++ b/drivers/mmc/at91_mci.c
@@ -823,6 +823,8 @@ static int __init at91_mci_probe(struct platform_device *pdev)
823 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; 823 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
824 mmc->caps = MMC_CAP_BYTEBLOCK; 824 mmc->caps = MMC_CAP_BYTEBLOCK;
825 825
826 mmc->max_blk_size = 4095;
827
826 host = mmc_priv(mmc); 828 host = mmc_priv(mmc);
827 host->mmc = mmc; 829 host->mmc = mmc;
828 host->buffer = NULL; 830 host->buffer = NULL;
diff --git a/drivers/mmc/au1xmmc.c b/drivers/mmc/au1xmmc.c
index 6d6fe6e6d415..74e6ac0c7f71 100644
--- a/drivers/mmc/au1xmmc.c
+++ b/drivers/mmc/au1xmmc.c
@@ -922,6 +922,8 @@ static int __devinit au1xmmc_probe(struct platform_device *pdev)
922 mmc->max_seg_size = AU1XMMC_DESCRIPTOR_SIZE; 922 mmc->max_seg_size = AU1XMMC_DESCRIPTOR_SIZE;
923 mmc->max_phys_segs = AU1XMMC_DESCRIPTOR_COUNT; 923 mmc->max_phys_segs = AU1XMMC_DESCRIPTOR_COUNT;
924 924
925 mmc->max_blk_size = 2048;
926
925 mmc->ocr_avail = AU1XMMC_OCR; 927 mmc->ocr_avail = AU1XMMC_OCR;
926 928
927 host = mmc_priv(mmc); 929 host = mmc_priv(mmc);
diff --git a/drivers/mmc/imxmmc.c b/drivers/mmc/imxmmc.c
index bfb9ff693208..2107f8a8605e 100644
--- a/drivers/mmc/imxmmc.c
+++ b/drivers/mmc/imxmmc.c
@@ -960,6 +960,7 @@ static int imxmci_probe(struct platform_device *pdev)
960 mmc->max_phys_segs = 64; 960 mmc->max_phys_segs = 64;
961 mmc->max_sectors = 64; /* default 1 << (PAGE_CACHE_SHIFT - 9) */ 961 mmc->max_sectors = 64; /* default 1 << (PAGE_CACHE_SHIFT - 9) */
962 mmc->max_seg_size = 64*512; /* default PAGE_CACHE_SIZE */ 962 mmc->max_seg_size = 64*512; /* default PAGE_CACHE_SIZE */
963 mmc->max_blk_size = 2048;
963 964
964 host = mmc_priv(mmc); 965 host = mmc_priv(mmc);
965 host->mmc = mmc; 966 host->mmc = mmc;
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index b48c277312de..9bda3fddad17 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -108,6 +108,8 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
108 mrq->cmd->error = 0; 108 mrq->cmd->error = 0;
109 mrq->cmd->mrq = mrq; 109 mrq->cmd->mrq = mrq;
110 if (mrq->data) { 110 if (mrq->data) {
111 BUG_ON(mrq->data->blksz > host->max_blk_size);
112
111 mrq->cmd->data = mrq->data; 113 mrq->cmd->data = mrq->data;
112 mrq->data->error = 0; 114 mrq->data->error = 0;
113 mrq->data->mrq = mrq; 115 mrq->data->mrq = mrq;
@@ -1605,6 +1607,8 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
1605 host->max_phys_segs = 1; 1607 host->max_phys_segs = 1;
1606 host->max_sectors = 1 << (PAGE_CACHE_SHIFT - 9); 1608 host->max_sectors = 1 << (PAGE_CACHE_SHIFT - 9);
1607 host->max_seg_size = PAGE_CACHE_SIZE; 1609 host->max_seg_size = PAGE_CACHE_SIZE;
1610
1611 host->max_blk_size = 512;
1608 } 1612 }
1609 1613
1610 return host; 1614 return host;
diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c
index ccfe6561be24..5d48e0081894 100644
--- a/drivers/mmc/mmci.c
+++ b/drivers/mmc/mmci.c
@@ -534,6 +534,11 @@ static int mmci_probe(struct amba_device *dev, void *id)
534 */ 534 */
535 mmc->max_seg_size = mmc->max_sectors << 9; 535 mmc->max_seg_size = mmc->max_sectors << 9;
536 536
537 /*
538 * Block size can be up to 2048 bytes, but must be a power of two.
539 */
540 mmc->max_blk_size = 2048;
541
537 spin_lock_init(&host->lock); 542 spin_lock_init(&host->lock);
538 543
539 writel(0, host->base + MMCIMASK0); 544 writel(0, host->base + MMCIMASK0);
diff --git a/drivers/mmc/omap.c b/drivers/mmc/omap.c
index d30540b27614..fa69a0dc5969 100644
--- a/drivers/mmc/omap.c
+++ b/drivers/mmc/omap.c
@@ -1099,6 +1099,7 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
1099 */ 1099 */
1100 mmc->max_phys_segs = 32; 1100 mmc->max_phys_segs = 32;
1101 mmc->max_hw_segs = 32; 1101 mmc->max_hw_segs = 32;
1102 mmc->max_blk_size = 2048; /* BLEN is 11 bits (+1) */
1102 mmc->max_sectors = 256; /* NBLK max 11-bits, OMAP also limited by DMA */ 1103 mmc->max_sectors = 256; /* NBLK max 11-bits, OMAP also limited by DMA */
1103 mmc->max_seg_size = mmc->max_sectors * 512; 1104 mmc->max_seg_size = mmc->max_sectors * 512;
1104 1105
diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c
index 6073d998b11f..9fc9aed1a5ef 100644
--- a/drivers/mmc/pxamci.c
+++ b/drivers/mmc/pxamci.c
@@ -450,6 +450,11 @@ static int pxamci_probe(struct platform_device *pdev)
450 */ 450 */
451 mmc->max_seg_size = PAGE_SIZE; 451 mmc->max_seg_size = PAGE_SIZE;
452 452
453 /*
454 * Block length register is 10 bits.
455 */
456 mmc->max_blk_size = 1023;
457
453 host = mmc_priv(mmc); 458 host = mmc_priv(mmc);
454 host->mmc = mmc; 459 host->mmc = mmc;
455 host->dma = -1; 460 host->dma = -1;
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 175a9427b9ba..155aafe69bf4 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -381,7 +381,7 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
381 381
382 /* Sanity checks */ 382 /* Sanity checks */
383 BUG_ON(data->blksz * data->blocks > 524288); 383 BUG_ON(data->blksz * data->blocks > 524288);
384 BUG_ON(data->blksz > host->max_block); 384 BUG_ON(data->blksz > host->mmc->max_blk_size);
385 BUG_ON(data->blocks > 65535); 385 BUG_ON(data->blocks > 65535);
386 386
387 /* timeout in us */ 387 /* timeout in us */
@@ -1290,15 +1290,6 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot)
1290 if (caps & SDHCI_TIMEOUT_CLK_UNIT) 1290 if (caps & SDHCI_TIMEOUT_CLK_UNIT)
1291 host->timeout_clk *= 1000; 1291 host->timeout_clk *= 1000;
1292 1292
1293 host->max_block = (caps & SDHCI_MAX_BLOCK_MASK) >> SDHCI_MAX_BLOCK_SHIFT;
1294 if (host->max_block >= 3) {
1295 printk(KERN_ERR "%s: Invalid maximum block size.\n",
1296 host->slot_descr);
1297 ret = -ENODEV;
1298 goto unmap;
1299 }
1300 host->max_block = 512 << host->max_block;
1301
1302 /* 1293 /*
1303 * Set host parameters. 1294 * Set host parameters.
1304 */ 1295 */
@@ -1353,6 +1344,19 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot)
1353 mmc->max_seg_size = mmc->max_sectors * 512; 1344 mmc->max_seg_size = mmc->max_sectors * 512;
1354 1345
1355 /* 1346 /*
1347 * Maximum block size. This varies from controller to controller and
1348 * is specified in the capabilities register.
1349 */
1350 mmc->max_blk_size = (caps & SDHCI_MAX_BLOCK_MASK) >> SDHCI_MAX_BLOCK_SHIFT;
1351 if (mmc->max_blk_size >= 3) {
1352 printk(KERN_ERR "%s: Invalid maximum block size.\n",
1353 host->slot_descr);
1354 ret = -ENODEV;
1355 goto unmap;
1356 }
1357 mmc->max_blk_size = 512 << mmc->max_blk_size;
1358
1359 /*
1356 * Init tasklets. 1360 * Init tasklets.
1357 */ 1361 */
1358 tasklet_init(&host->card_tasklet, 1362 tasklet_init(&host->card_tasklet,
diff --git a/drivers/mmc/sdhci.h b/drivers/mmc/sdhci.h
index f9d1a0a6f03a..bc6bf7e7757d 100644
--- a/drivers/mmc/sdhci.h
+++ b/drivers/mmc/sdhci.h
@@ -174,7 +174,6 @@ struct sdhci_host {
174 174
175 unsigned int max_clk; /* Max possible freq (MHz) */ 175 unsigned int max_clk; /* Max possible freq (MHz) */
176 unsigned int timeout_clk; /* Timeout freq (KHz) */ 176 unsigned int timeout_clk; /* Timeout freq (KHz) */
177 unsigned int max_block; /* Max block size (bytes) */
178 177
179 unsigned int clock; /* Current clock (MHz) */ 178 unsigned int clock; /* Current clock (MHz) */
180 unsigned short power; /* Current voltage */ 179 unsigned short power; /* Current voltage */
diff --git a/drivers/mmc/tifm_sd.c b/drivers/mmc/tifm_sd.c
index ce19b045ca6a..bdfad15371b8 100644
--- a/drivers/mmc/tifm_sd.c
+++ b/drivers/mmc/tifm_sd.c
@@ -886,7 +886,9 @@ static int tifm_sd_probe(struct tifm_dev *sock)
886 mmc->max_hw_segs = 1; 886 mmc->max_hw_segs = 1;
887 mmc->max_phys_segs = 1; 887 mmc->max_phys_segs = 1;
888 mmc->max_sectors = 127; 888 mmc->max_sectors = 127;
889 mmc->max_seg_size = mmc->max_sectors << 11; //2k maximum hw block length 889 //2k maximum hw block length
890 mmc->max_seg_size = mmc->max_sectors << 11;
891 mmc->max_blk_size = 2048;
890 sock->signal_irq = tifm_sd_signal_irq; 892 sock->signal_irq = tifm_sd_signal_irq;
891 rc = tifm_sd_initialize_host(host); 893 rc = tifm_sd_initialize_host(host);
892 894
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c
index 7a282672f8e9..5711beecb4e8 100644
--- a/drivers/mmc/wbsd.c
+++ b/drivers/mmc/wbsd.c
@@ -1354,6 +1354,12 @@ static int __devinit wbsd_alloc_mmc(struct device *dev)
1354 */ 1354 */
1355 mmc->max_seg_size = mmc->max_sectors * 512; 1355 mmc->max_seg_size = mmc->max_sectors * 512;
1356 1356
1357 /*
1358 * Maximum block size. We have 12 bits (= 4095) but have to subtract
1359 * space for CRC. So the maximum is 4095 - 4*2 = 4087.
1360 */
1361 mmc->max_blk_size = 4087;
1362
1357 dev_set_drvdata(dev, mmc); 1363 dev_set_drvdata(dev, mmc);
1358 1364
1359 return 0; 1365 return 0;