Skip to content

Commit 97c24d1

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc: mmc: remove unused "ddr" parameter in struct mmc_ios mmc: dw_mmc: Fix DDR mode support. mmc: core: use defined R1_STATE_PRG macro for card status mmc: sdhci: use f_max instead of host->clock for timeouts mmc: sdhci: move timeout_clk calculation farther down mmc: sdhci: check host->clock before using it as a denominator mmc: Revert "mmc: sdhci: Fix SDHCI_QUIRK_TIMEOUT_USES_SDCLK" mmc: tmio: eliminate unused variable 'mmc' warning mmc: esdhc-imx: fix card interrupt loss on freescale eSDHC mmc: sdhci-s3c: Fix build for header change mmc: dw_mmc: Fix mask in IDMAC_SET_BUFFER1_SIZE macro mmc: cb710: fix possible pci_dev leak in cb710_pci_configure() mmc: core: Detect eMMC v4.5 ext_csd entries mmc: mmc_test: avoid stalled file in debugfs mmc: sdhci-s3c: add BROKEN_ADMA_ZEROLEN_DESC quirk mmc: sdhci: pxav3: controller needs 32 bit ADMA addressing mmc: sdhci: fix retuning timer wrongly deleted in sdhci_tasklet_finish
2 parents 91d85ea + 7fd781e commit 97c24d1

File tree

12 files changed

+100
-77
lines changed

12 files changed

+100
-77
lines changed

drivers/misc/cb710/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(cb710_pci_update_config_reg);
3333
static int __devinit cb710_pci_configure(struct pci_dev *pdev)
3434
{
3535
unsigned int devfn = PCI_DEVFN(PCI_SLOT(pdev->devfn), 0);
36-
struct pci_dev *pdev0 = pci_get_slot(pdev->bus, devfn);
36+
struct pci_dev *pdev0;
3737
u32 val;
3838

3939
cb710_pci_update_config_reg(pdev, 0x48,
@@ -43,6 +43,7 @@ static int __devinit cb710_pci_configure(struct pci_dev *pdev)
4343
if (val & 0x80000000)
4444
return 0;
4545

46+
pdev0 = pci_get_slot(pdev->bus, devfn);
4647
if (!pdev0)
4748
return -ENODEV;
4849

drivers/mmc/card/mmc_test.c

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static void mmc_test_prepare_mrq(struct mmc_test_card *test,
224224
static int mmc_test_busy(struct mmc_command *cmd)
225225
{
226226
return !(cmd->resp[0] & R1_READY_FOR_DATA) ||
227-
(R1_CURRENT_STATE(cmd->resp[0]) == 7);
227+
(R1_CURRENT_STATE(cmd->resp[0]) == R1_STATE_PRG);
228228
}
229229

230230
/*
@@ -2900,7 +2900,7 @@ static const struct file_operations mmc_test_fops_testlist = {
29002900
.release = single_release,
29012901
};
29022902

2903-
static void mmc_test_free_file_test(struct mmc_card *card)
2903+
static void mmc_test_free_dbgfs_file(struct mmc_card *card)
29042904
{
29052905
struct mmc_test_dbgfs_file *df, *dfs;
29062906

@@ -2917,49 +2917,53 @@ static void mmc_test_free_file_test(struct mmc_card *card)
29172917
mutex_unlock(&mmc_test_lock);
29182918
}
29192919

2920-
static int mmc_test_register_file_test(struct mmc_card *card)
2920+
static int __mmc_test_register_dbgfs_file(struct mmc_card *card,
2921+
const char *name, mode_t mode, const struct file_operations *fops)
29212922
{
29222923
struct dentry *file = NULL;
29232924
struct mmc_test_dbgfs_file *df;
2924-
int ret = 0;
2925-
2926-
mutex_lock(&mmc_test_lock);
2927-
2928-
if (card->debugfs_root)
2929-
file = debugfs_create_file("test", S_IWUSR | S_IRUGO,
2930-
card->debugfs_root, card, &mmc_test_fops_test);
2931-
2932-
if (IS_ERR_OR_NULL(file)) {
2933-
dev_err(&card->dev,
2934-
"Can't create test. Perhaps debugfs is disabled.\n");
2935-
ret = -ENODEV;
2936-
goto err;
2937-
}
29382925

29392926
if (card->debugfs_root)
2940-
file = debugfs_create_file("testlist", S_IRUGO,
2941-
card->debugfs_root, card, &mmc_test_fops_testlist);
2927+
file = debugfs_create_file(name, mode, card->debugfs_root,
2928+
card, fops);
29422929

29432930
if (IS_ERR_OR_NULL(file)) {
29442931
dev_err(&card->dev,
2945-
"Can't create testlist. Perhaps debugfs is disabled.\n");
2946-
ret = -ENODEV;
2947-
goto err;
2932+
"Can't create %s. Perhaps debugfs is disabled.\n",
2933+
name);
2934+
return -ENODEV;
29482935
}
29492936

29502937
df = kmalloc(sizeof(struct mmc_test_dbgfs_file), GFP_KERNEL);
29512938
if (!df) {
29522939
debugfs_remove(file);
29532940
dev_err(&card->dev,
29542941
"Can't allocate memory for internal usage.\n");
2955-
ret = -ENOMEM;
2956-
goto err;
2942+
return -ENOMEM;
29572943
}
29582944

29592945
df->card = card;
29602946
df->file = file;
29612947

29622948
list_add(&df->link, &mmc_test_file_test);
2949+
return 0;
2950+
}
2951+
2952+
static int mmc_test_register_dbgfs_file(struct mmc_card *card)
2953+
{
2954+
int ret;
2955+
2956+
mutex_lock(&mmc_test_lock);
2957+
2958+
ret = __mmc_test_register_dbgfs_file(card, "test", S_IWUSR | S_IRUGO,
2959+
&mmc_test_fops_test);
2960+
if (ret)
2961+
goto err;
2962+
2963+
ret = __mmc_test_register_dbgfs_file(card, "testlist", S_IRUGO,
2964+
&mmc_test_fops_testlist);
2965+
if (ret)
2966+
goto err;
29632967

29642968
err:
29652969
mutex_unlock(&mmc_test_lock);
@@ -2974,7 +2978,7 @@ static int mmc_test_probe(struct mmc_card *card)
29742978
if (!mmc_card_mmc(card) && !mmc_card_sd(card))
29752979
return -ENODEV;
29762980

2977-
ret = mmc_test_register_file_test(card);
2981+
ret = mmc_test_register_dbgfs_file(card);
29782982
if (ret)
29792983
return ret;
29802984

@@ -2986,7 +2990,7 @@ static int mmc_test_probe(struct mmc_card *card)
29862990
static void mmc_test_remove(struct mmc_card *card)
29872991
{
29882992
mmc_test_free_result(card);
2989-
mmc_test_free_file_test(card);
2993+
mmc_test_free_dbgfs_file(card);
29902994
}
29912995

29922996
static struct mmc_driver mmc_driver = {
@@ -3006,7 +3010,7 @@ static void __exit mmc_test_exit(void)
30063010
{
30073011
/* Clear stalled data if card is still plugged */
30083012
mmc_test_free_result(NULL);
3009-
mmc_test_free_file_test(NULL);
3013+
mmc_test_free_dbgfs_file(NULL);
30103014

30113015
mmc_unregister_driver(&mmc_driver);
30123016
}

drivers/mmc/core/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,7 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from,
15021502
goto out;
15031503
}
15041504
} while (!(cmd.resp[0] & R1_READY_FOR_DATA) ||
1505-
R1_CURRENT_STATE(cmd.resp[0]) == 7);
1505+
R1_CURRENT_STATE(cmd.resp[0]) == R1_STATE_PRG);
15061506
out:
15071507
return err;
15081508
}

drivers/mmc/core/mmc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
259259
}
260260

261261
card->ext_csd.rev = ext_csd[EXT_CSD_REV];
262-
if (card->ext_csd.rev > 5) {
262+
if (card->ext_csd.rev > 6) {
263263
printk(KERN_ERR "%s: unrecognised EXT_CSD revision %d\n",
264264
mmc_hostname(card->host), card->ext_csd.rev);
265265
err = -EINVAL;

drivers/mmc/core/mmc_ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
407407
break;
408408
if (mmc_host_is_spi(card->host))
409409
break;
410-
} while (R1_CURRENT_STATE(status) == 7);
410+
} while (R1_CURRENT_STATE(status) == R1_STATE_PRG);
411411

412412
if (mmc_host_is_spi(card->host)) {
413413
if (status & R1_SPI_ILLEGAL_COMMAND)

drivers/mmc/host/dw_mmc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct idmac_desc {
6262

6363
u32 des1; /* Buffer sizes */
6464
#define IDMAC_SET_BUFFER1_SIZE(d, s) \
65-
((d)->des1 = ((d)->des1 & 0x03ffc000) | ((s) & 0x3fff))
65+
((d)->des1 = ((d)->des1 & 0x03ffe000) | ((s) & 0x1fff))
6666

6767
u32 des2; /* buffer 1 physical address */
6868

@@ -699,7 +699,7 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
699699
}
700700

701701
/* DDR mode set */
702-
if (ios->ddr) {
702+
if (ios->timing == MMC_TIMING_UHS_DDR50) {
703703
regs = mci_readl(slot->host, UHS_REG);
704704
regs |= (0x1 << slot->id) << 16;
705705
mci_writel(slot->host, UHS_REG, regs);
@@ -1646,7 +1646,7 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id)
16461646
mmc->caps |= MMC_CAP_4_BIT_DATA;
16471647

16481648
if (host->pdata->quirks & DW_MCI_QUIRK_HIGHSPEED)
1649-
mmc->caps |= MMC_CAP_SD_HIGHSPEED;
1649+
mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;
16501650

16511651
#ifdef CONFIG_MMC_DW_IDMAC
16521652
mmc->max_segs = host->ring_size;

drivers/mmc/host/sdhci-esdhc-imx.c

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "sdhci-pltfm.h"
2828
#include "sdhci-esdhc.h"
2929

30+
#define SDHCI_CTRL_D3CD 0x08
3031
/* VENDOR SPEC register */
3132
#define SDHCI_VENDOR_SPEC 0xC0
3233
#define SDHCI_VENDOR_SPEC_SDIO_QUIRK 0x00000002
@@ -141,13 +142,32 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg)
141142
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
142143
struct pltfm_imx_data *imx_data = pltfm_host->priv;
143144
struct esdhc_platform_data *boarddata = &imx_data->boarddata;
144-
145-
if (unlikely((reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE)
146-
&& (boarddata->cd_type == ESDHC_CD_GPIO)))
147-
/*
148-
* these interrupts won't work with a custom card_detect gpio
149-
*/
150-
val &= ~(SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT);
145+
u32 data;
146+
147+
if (unlikely(reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE)) {
148+
if (boarddata->cd_type == ESDHC_CD_GPIO)
149+
/*
150+
* These interrupts won't work with a custom
151+
* card_detect gpio (only applied to mx25/35)
152+
*/
153+
val &= ~(SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT);
154+
155+
if (val & SDHCI_INT_CARD_INT) {
156+
/*
157+
* Clear and then set D3CD bit to avoid missing the
158+
* card interrupt. This is a eSDHC controller problem
159+
* so we need to apply the following workaround: clear
160+
* and set D3CD bit will make eSDHC re-sample the card
161+
* interrupt. In case a card interrupt was lost,
162+
* re-sample it by the following steps.
163+
*/
164+
data = readl(host->ioaddr + SDHCI_HOST_CONTROL);
165+
data &= ~SDHCI_CTRL_D3CD;
166+
writel(data, host->ioaddr + SDHCI_HOST_CONTROL);
167+
data |= SDHCI_CTRL_D3CD;
168+
writel(data, host->ioaddr + SDHCI_HOST_CONTROL);
169+
}
170+
}
151171

152172
if (unlikely((imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
153173
&& (reg == SDHCI_INT_STATUS)
@@ -217,8 +237,10 @@ static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
217237
*/
218238
return;
219239
case SDHCI_HOST_CONTROL:
220-
/* FSL messed up here, so we can just keep those two */
221-
new_val = val & (SDHCI_CTRL_LED | SDHCI_CTRL_4BITBUS);
240+
/* FSL messed up here, so we can just keep those three */
241+
new_val = val & (SDHCI_CTRL_LED | \
242+
SDHCI_CTRL_4BITBUS | \
243+
SDHCI_CTRL_D3CD);
222244
/* ensure the endianess */
223245
new_val |= ESDHC_HOST_CONTROL_LE;
224246
/* DMA mode bits are shifted */

drivers/mmc/host/sdhci-pxav3.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ static int __devinit sdhci_pxav3_probe(struct platform_device *pdev)
195195
clk_enable(clk);
196196

197197
host->quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL
198-
| SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC;
198+
| SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC
199+
| SDHCI_QUIRK_32BIT_ADMA_SIZE;
199200

200201
/* enable 1/8V DDR capable */
201202
host->mmc->caps |= MMC_CAP_1_8V_DDR;

drivers/mmc/host/sdhci-s3c.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/clk.h>
2020
#include <linux/io.h>
2121
#include <linux/gpio.h>
22+
#include <linux/module.h>
2223

2324
#include <linux/mmc/host.h>
2425

@@ -502,6 +503,9 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
502503
/* This host supports the Auto CMD12 */
503504
host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12;
504505

506+
/* Samsung SoCs need BROKEN_ADMA_ZEROLEN_DESC */
507+
host->quirks |= SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC;
508+
505509
if (pdata->cd_type == S3C_SDHCI_CD_NONE ||
506510
pdata->cd_type == S3C_SDHCI_CD_PERMANENT)
507511
host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;

drivers/mmc/host/sdhci.c

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -628,12 +628,11 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd)
628628
/* timeout in us */
629629
if (!data)
630630
target_timeout = cmd->cmd_timeout_ms * 1000;
631-
else
632-
target_timeout = data->timeout_ns / 1000 +
633-
data->timeout_clks / host->clock;
634-
635-
if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)
636-
host->timeout_clk = host->clock / 1000;
631+
else {
632+
target_timeout = data->timeout_ns / 1000;
633+
if (host->clock)
634+
target_timeout += data->timeout_clks / host->clock;
635+
}
637636

638637
/*
639638
* Figure out needed cycles.
@@ -645,7 +644,6 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd)
645644
* =>
646645
* (1) / (2) > 2^6
647646
*/
648-
BUG_ON(!host->timeout_clk);
649647
count = 0;
650648
current_timeout = (1 << 13) * 1000 / host->timeout_clk;
651649
while (current_timeout < target_timeout) {
@@ -1867,9 +1865,6 @@ static void sdhci_tasklet_finish(unsigned long param)
18671865

18681866
del_timer(&host->timer);
18691867

1870-
if (host->version >= SDHCI_SPEC_300)
1871-
del_timer(&host->tuning_timer);
1872-
18731868
mrq = host->mrq;
18741869

18751870
/*
@@ -2461,22 +2456,6 @@ int sdhci_add_host(struct sdhci_host *host)
24612456
host->max_clk = host->ops->get_max_clock(host);
24622457
}
24632458

2464-
host->timeout_clk =
2465-
(caps[0] & SDHCI_TIMEOUT_CLK_MASK) >> SDHCI_TIMEOUT_CLK_SHIFT;
2466-
if (host->timeout_clk == 0) {
2467-
if (host->ops->get_timeout_clock) {
2468-
host->timeout_clk = host->ops->get_timeout_clock(host);
2469-
} else if (!(host->quirks &
2470-
SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)) {
2471-
printk(KERN_ERR
2472-
"%s: Hardware doesn't specify timeout clock "
2473-
"frequency.\n", mmc_hostname(mmc));
2474-
return -ENODEV;
2475-
}
2476-
}
2477-
if (caps[0] & SDHCI_TIMEOUT_CLK_UNIT)
2478-
host->timeout_clk *= 1000;
2479-
24802459
/*
24812460
* In case of Host Controller v3.00, find out whether clock
24822461
* multiplier is supported.
@@ -2509,10 +2488,26 @@ int sdhci_add_host(struct sdhci_host *host)
25092488
} else
25102489
mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200;
25112490

2491+
host->timeout_clk =
2492+
(caps[0] & SDHCI_TIMEOUT_CLK_MASK) >> SDHCI_TIMEOUT_CLK_SHIFT;
2493+
if (host->timeout_clk == 0) {
2494+
if (host->ops->get_timeout_clock) {
2495+
host->timeout_clk = host->ops->get_timeout_clock(host);
2496+
} else if (!(host->quirks &
2497+
SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)) {
2498+
printk(KERN_ERR
2499+
"%s: Hardware doesn't specify timeout clock "
2500+
"frequency.\n", mmc_hostname(mmc));
2501+
return -ENODEV;
2502+
}
2503+
}
2504+
if (caps[0] & SDHCI_TIMEOUT_CLK_UNIT)
2505+
host->timeout_clk *= 1000;
2506+
25122507
if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)
2513-
mmc->max_discard_to = (1 << 27) / (mmc->f_max / 1000);
2514-
else
2515-
mmc->max_discard_to = (1 << 27) / host->timeout_clk;
2508+
host->timeout_clk = mmc->f_max / 1000;
2509+
2510+
mmc->max_discard_to = (1 << 27) / host->timeout_clk;
25162511

25172512
mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23;
25182513

0 commit comments

Comments
 (0)