Commit 9023a409 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'mmc-fixes-for-3.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc

Pull MMC fixes from Chris Ball:
 - atmel-mci: Fixes for NULL timer and DMA burst/chunk size
 - dw_mmc: Fix DMA ordering, clkdiv calculation, NULL host->data
 - mxs_mmc: Compile fix for CONFIG_OF=y && CONFIG_PM=n
 - omap: Fix NULL deref in mmc_omap_remove_slot(), reg_shift initialization
 - sdhci-s3c: Fix boot regression by adding IRQF_ONESHOT flag
 - Small fixes to core/sd, core/sdio, sdhci

* tag 'mmc-fixes-for-3.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc:
  mmc: mxs-mmc: Move of_match_table out of CONFIG_PM
  mmc: sdhci-s3c: pass IRQF ONESHOT to request threaded irq
  mmc: core: return an error on suspend if mmc_deselect_cards fails
  mmc: omap: Fix broken reg_shift initialization
  mmc: omap: Fix NULL pointer dereference if mmc_omap_new_slot() fails
  mmc: omap: Fix a section warning regression
  mmc: dw_mmc: correct the calculation for CLKDIV
  mmc: dw_mmc: fix incorrect setting of host->data of NULL
  mmc: dw_mmc: fix the IDMAC sw reset
  mmc: dw_mmc: fix the transmission handling in IDMAC
  mmc: sdio: fix setting card data bus width as 4-bit
  mmc: atmel-mci: fix burst/chunk size modification
  mmc: atmel-mci: fix data timeout issue
  mmc: sdhci: Use DBG() instead of pr_warning() on large timeout
parents 1bea57f5 a3e545e9
...@@ -1326,7 +1326,7 @@ static int mmc_suspend(struct mmc_host *host) ...@@ -1326,7 +1326,7 @@ static int mmc_suspend(struct mmc_host *host)
if (!err) if (!err)
mmc_card_set_sleep(host->card); mmc_card_set_sleep(host->card);
} else if (!mmc_host_is_spi(host)) } else if (!mmc_host_is_spi(host))
mmc_deselect_cards(host); err = mmc_deselect_cards(host);
host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200); host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200);
mmc_release_host(host); mmc_release_host(host);
......
...@@ -1075,16 +1075,18 @@ static void mmc_sd_detect(struct mmc_host *host) ...@@ -1075,16 +1075,18 @@ static void mmc_sd_detect(struct mmc_host *host)
*/ */
static int mmc_sd_suspend(struct mmc_host *host) static int mmc_sd_suspend(struct mmc_host *host)
{ {
int err = 0;
BUG_ON(!host); BUG_ON(!host);
BUG_ON(!host->card); BUG_ON(!host->card);
mmc_claim_host(host); mmc_claim_host(host);
if (!mmc_host_is_spi(host)) if (!mmc_host_is_spi(host))
mmc_deselect_cards(host); err = mmc_deselect_cards(host);
host->card->state &= ~MMC_STATE_HIGHSPEED; host->card->state &= ~MMC_STATE_HIGHSPEED;
mmc_release_host(host); mmc_release_host(host);
return 0; return err;
} }
/* /*
......
...@@ -218,6 +218,12 @@ static int sdio_enable_wide(struct mmc_card *card) ...@@ -218,6 +218,12 @@ static int sdio_enable_wide(struct mmc_card *card)
if (ret) if (ret)
return ret; return ret;
if ((ctrl & SDIO_BUS_WIDTH_MASK) == SDIO_BUS_WIDTH_RESERVED)
pr_warning("%s: SDIO_CCCR_IF is invalid: 0x%02x\n",
mmc_hostname(card->host), ctrl);
/* set as 4-bit bus width */
ctrl &= ~SDIO_BUS_WIDTH_MASK;
ctrl |= SDIO_BUS_WIDTH_4BIT; ctrl |= SDIO_BUS_WIDTH_4BIT;
ret = mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_IF, ctrl, NULL); ret = mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_IF, ctrl, NULL);
......
...@@ -140,4 +140,18 @@ ...@@ -140,4 +140,18 @@
#define atmci_writel(port,reg,value) \ #define atmci_writel(port,reg,value) \
__raw_writel((value), (port)->regs + reg) __raw_writel((value), (port)->regs + reg)
/*
* Fix sconfig's burst size according to atmel MCI. We need to convert them as:
* 1 -> 0, 4 -> 1, 8 -> 2, 16 -> 3.
*
* This can be done by finding most significant bit set.
*/
static inline unsigned int atmci_convert_chksize(unsigned int maxburst)
{
if (maxburst > 1)
return fls(maxburst) - 2;
else
return 0;
}
#endif /* __DRIVERS_MMC_ATMEL_MCI_H__ */ #endif /* __DRIVERS_MMC_ATMEL_MCI_H__ */
...@@ -910,6 +910,7 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) ...@@ -910,6 +910,7 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)
enum dma_data_direction direction; enum dma_data_direction direction;
enum dma_transfer_direction slave_dirn; enum dma_transfer_direction slave_dirn;
unsigned int sglen; unsigned int sglen;
u32 maxburst;
u32 iflags; u32 iflags;
data->error = -EINPROGRESS; data->error = -EINPROGRESS;
...@@ -943,17 +944,18 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) ...@@ -943,17 +944,18 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)
if (!chan) if (!chan)
return -ENODEV; return -ENODEV;
if (host->caps.has_dma)
atmci_writel(host, ATMCI_DMA, ATMCI_DMA_CHKSIZE(3) | ATMCI_DMAEN);
if (data->flags & MMC_DATA_READ) { if (data->flags & MMC_DATA_READ) {
direction = DMA_FROM_DEVICE; direction = DMA_FROM_DEVICE;
host->dma_conf.direction = slave_dirn = DMA_DEV_TO_MEM; host->dma_conf.direction = slave_dirn = DMA_DEV_TO_MEM;
maxburst = atmci_convert_chksize(host->dma_conf.src_maxburst);
} else { } else {
direction = DMA_TO_DEVICE; direction = DMA_TO_DEVICE;
host->dma_conf.direction = slave_dirn = DMA_MEM_TO_DEV; host->dma_conf.direction = slave_dirn = DMA_MEM_TO_DEV;
maxburst = atmci_convert_chksize(host->dma_conf.dst_maxburst);
} }
atmci_writel(host, ATMCI_DMA, ATMCI_DMA_CHKSIZE(maxburst) | ATMCI_DMAEN);
sglen = dma_map_sg(chan->device->dev, data->sg, sglen = dma_map_sg(chan->device->dev, data->sg,
data->sg_len, direction); data->sg_len, direction);
...@@ -2314,6 +2316,8 @@ static int __init atmci_probe(struct platform_device *pdev) ...@@ -2314,6 +2316,8 @@ static int __init atmci_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, host); platform_set_drvdata(pdev, host);
setup_timer(&host->timer, atmci_timeout_timer, (unsigned long)host);
/* We need at least one slot to succeed */ /* We need at least one slot to succeed */
nr_slots = 0; nr_slots = 0;
ret = -ENODEV; ret = -ENODEV;
...@@ -2352,8 +2356,6 @@ static int __init atmci_probe(struct platform_device *pdev) ...@@ -2352,8 +2356,6 @@ static int __init atmci_probe(struct platform_device *pdev)
} }
} }
setup_timer(&host->timer, atmci_timeout_timer, (unsigned long)host);
dev_info(&pdev->dev, dev_info(&pdev->dev,
"Atmel MCI controller at 0x%08lx irq %d, %u slots\n", "Atmel MCI controller at 0x%08lx irq %d, %u slots\n",
host->mapbase, irq, nr_slots); host->mapbase, irq, nr_slots);
......
...@@ -418,6 +418,8 @@ static int dw_mci_idmac_init(struct dw_mci *host) ...@@ -418,6 +418,8 @@ static int dw_mci_idmac_init(struct dw_mci *host)
p->des3 = host->sg_dma; p->des3 = host->sg_dma;
p->des0 = IDMAC_DES0_ER; p->des0 = IDMAC_DES0_ER;
mci_writel(host, BMOD, SDMMC_IDMAC_SWRESET);
/* Mask out interrupts - get Tx & Rx complete only */ /* Mask out interrupts - get Tx & Rx complete only */
mci_writel(host, IDINTEN, SDMMC_IDMAC_INT_NI | SDMMC_IDMAC_INT_RI | mci_writel(host, IDINTEN, SDMMC_IDMAC_INT_NI | SDMMC_IDMAC_INT_RI |
SDMMC_IDMAC_INT_TI); SDMMC_IDMAC_INT_TI);
...@@ -615,14 +617,15 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot) ...@@ -615,14 +617,15 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot)
u32 div; u32 div;
if (slot->clock != host->current_speed) { if (slot->clock != host->current_speed) {
if (host->bus_hz % slot->clock) div = host->bus_hz / slot->clock;
if (host->bus_hz % slot->clock && host->bus_hz > slot->clock)
/* /*
* move the + 1 after the divide to prevent * move the + 1 after the divide to prevent
* over-clocking the card. * over-clocking the card.
*/ */
div = ((host->bus_hz / slot->clock) >> 1) + 1; div += 1;
else
div = (host->bus_hz / slot->clock) >> 1; div = (host->bus_hz != slot->clock) ? DIV_ROUND_UP(div, 2) : 0;
dev_info(&slot->mmc->class_dev, dev_info(&slot->mmc->class_dev,
"Bus speed (slot %d) = %dHz (slot req %dHz, actual %dHZ" "Bus speed (slot %d) = %dHz (slot req %dHz, actual %dHZ"
...@@ -939,8 +942,8 @@ static void dw_mci_command_complete(struct dw_mci *host, struct mmc_command *cmd ...@@ -939,8 +942,8 @@ static void dw_mci_command_complete(struct dw_mci *host, struct mmc_command *cmd
mdelay(20); mdelay(20);
if (cmd->data) { if (cmd->data) {
host->data = NULL;
dw_mci_stop_dma(host); dw_mci_stop_dma(host);
host->data = NULL;
} }
} }
} }
...@@ -1623,7 +1626,6 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id) ...@@ -1623,7 +1626,6 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id)
if (pending & (SDMMC_IDMAC_INT_TI | SDMMC_IDMAC_INT_RI)) { if (pending & (SDMMC_IDMAC_INT_TI | SDMMC_IDMAC_INT_RI)) {
mci_writel(host, IDSTS, SDMMC_IDMAC_INT_TI | SDMMC_IDMAC_INT_RI); mci_writel(host, IDSTS, SDMMC_IDMAC_INT_TI | SDMMC_IDMAC_INT_RI);
mci_writel(host, IDSTS, SDMMC_IDMAC_INT_NI); mci_writel(host, IDSTS, SDMMC_IDMAC_INT_NI);
set_bit(EVENT_DATA_COMPLETE, &host->pending_events);
host->dma_ops->complete(host); host->dma_ops->complete(host);
} }
#endif #endif
...@@ -1725,7 +1727,8 @@ static void dw_mci_work_routine_card(struct work_struct *work) ...@@ -1725,7 +1727,8 @@ static void dw_mci_work_routine_card(struct work_struct *work)
#ifdef CONFIG_MMC_DW_IDMAC #ifdef CONFIG_MMC_DW_IDMAC
ctrl = mci_readl(host, BMOD); ctrl = mci_readl(host, BMOD);
ctrl |= 0x01; /* Software reset of DMA */ /* Software reset of DMA */
ctrl |= SDMMC_IDMAC_SWRESET;
mci_writel(host, BMOD, ctrl); mci_writel(host, BMOD, ctrl);
#endif #endif
...@@ -1950,10 +1953,6 @@ int dw_mci_probe(struct dw_mci *host) ...@@ -1950,10 +1953,6 @@ int dw_mci_probe(struct dw_mci *host)
spin_lock_init(&host->lock); spin_lock_init(&host->lock);
INIT_LIST_HEAD(&host->queue); INIT_LIST_HEAD(&host->queue);
host->dma_ops = host->pdata->dma_ops;
dw_mci_init_dma(host);
/* /*
* Get the host data width - this assumes that HCON has been set with * Get the host data width - this assumes that HCON has been set with
* the correct values. * the correct values.
...@@ -1981,10 +1980,11 @@ int dw_mci_probe(struct dw_mci *host) ...@@ -1981,10 +1980,11 @@ int dw_mci_probe(struct dw_mci *host)
} }
/* Reset all blocks */ /* Reset all blocks */
if (!mci_wait_reset(&host->dev, host)) { if (!mci_wait_reset(&host->dev, host))
ret = -ENODEV; return -ENODEV;
goto err_dmaunmap;
} host->dma_ops = host->pdata->dma_ops;
dw_mci_init_dma(host);
/* Clear the interrupts for the host controller */ /* Clear the interrupts for the host controller */
mci_writel(host, RINTSTS, 0xFFFFFFFF); mci_writel(host, RINTSTS, 0xFFFFFFFF);
...@@ -2170,14 +2170,14 @@ int dw_mci_resume(struct dw_mci *host) ...@@ -2170,14 +2170,14 @@ int dw_mci_resume(struct dw_mci *host)
if (host->vmmc) if (host->vmmc)
regulator_enable(host->vmmc); regulator_enable(host->vmmc);
if (host->dma_ops->init)
host->dma_ops->init(host);
if (!mci_wait_reset(&host->dev, host)) { if (!mci_wait_reset(&host->dev, host)) {
ret = -ENODEV; ret = -ENODEV;
return ret; return ret;
} }
if (host->dma_ops->init)
host->dma_ops->init(host);
/* Restore the old value at FIFOTH register */ /* Restore the old value at FIFOTH register */
mci_writel(host, FIFOTH, host->fifoth_val); mci_writel(host, FIFOTH, host->fifoth_val);
......
...@@ -894,8 +894,8 @@ static struct platform_driver mxs_mmc_driver = { ...@@ -894,8 +894,8 @@ static struct platform_driver mxs_mmc_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
#ifdef CONFIG_PM #ifdef CONFIG_PM
.pm = &mxs_mmc_pm_ops, .pm = &mxs_mmc_pm_ops,
.of_match_table = mxs_mmc_dt_ids,
#endif #endif
.of_match_table = mxs_mmc_dt_ids,
}, },
}; };
......
...@@ -1300,7 +1300,7 @@ static const struct mmc_host_ops mmc_omap_ops = { ...@@ -1300,7 +1300,7 @@ static const struct mmc_host_ops mmc_omap_ops = {
.set_ios = mmc_omap_set_ios, .set_ios = mmc_omap_set_ios,
}; };
static int __init mmc_omap_new_slot(struct mmc_omap_host *host, int id) static int __devinit mmc_omap_new_slot(struct mmc_omap_host *host, int id)
{ {
struct mmc_omap_slot *slot = NULL; struct mmc_omap_slot *slot = NULL;
struct mmc_host *mmc; struct mmc_host *mmc;
...@@ -1485,24 +1485,26 @@ static int __devinit mmc_omap_probe(struct platform_device *pdev) ...@@ -1485,24 +1485,26 @@ static int __devinit mmc_omap_probe(struct platform_device *pdev)
} }
host->nr_slots = pdata->nr_slots; host->nr_slots = pdata->nr_slots;
host->reg_shift = (cpu_is_omap7xx() ? 1 : 2);
host->mmc_omap_wq = alloc_workqueue("mmc_omap", 0, 0);
if (!host->mmc_omap_wq)
goto err_plat_cleanup;
for (i = 0; i < pdata->nr_slots; i++) { for (i = 0; i < pdata->nr_slots; i++) {
ret = mmc_omap_new_slot(host, i); ret = mmc_omap_new_slot(host, i);
if (ret < 0) { if (ret < 0) {
while (--i >= 0) while (--i >= 0)
mmc_omap_remove_slot(host->slots[i]); mmc_omap_remove_slot(host->slots[i]);
goto err_plat_cleanup; goto err_destroy_wq;
} }
} }
host->reg_shift = (cpu_is_omap7xx() ? 1 : 2);
host->mmc_omap_wq = alloc_workqueue("mmc_omap", 0, 0);
if (!host->mmc_omap_wq)
goto err_plat_cleanup;
return 0; return 0;
err_destroy_wq:
destroy_workqueue(host->mmc_omap_wq);
err_plat_cleanup: err_plat_cleanup:
if (pdata->cleanup) if (pdata->cleanup)
pdata->cleanup(&pdev->dev); pdata->cleanup(&pdev->dev);
......
...@@ -404,7 +404,7 @@ static void sdhci_s3c_setup_card_detect_gpio(struct sdhci_s3c *sc) ...@@ -404,7 +404,7 @@ static void sdhci_s3c_setup_card_detect_gpio(struct sdhci_s3c *sc)
if (sc->ext_cd_irq && if (sc->ext_cd_irq &&
request_threaded_irq(sc->ext_cd_irq, NULL, request_threaded_irq(sc->ext_cd_irq, NULL,
sdhci_s3c_gpio_card_detect_thread, sdhci_s3c_gpio_card_detect_thread,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
dev_name(dev), sc) == 0) { dev_name(dev), sc) == 0) {
int status = gpio_get_value(sc->ext_cd_gpio); int status = gpio_get_value(sc->ext_cd_gpio);
if (pdata->ext_cd_gpio_invert) if (pdata->ext_cd_gpio_invert)
......
...@@ -680,8 +680,8 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd) ...@@ -680,8 +680,8 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd)
} }
if (count >= 0xF) { if (count >= 0xF) {
pr_warning("%s: Too large timeout 0x%x requested for CMD%d!\n", DBG("%s: Too large timeout 0x%x requested for CMD%d!\n",
mmc_hostname(host->mmc), count, cmd->opcode); mmc_hostname(host->mmc), count, cmd->opcode);
count = 0xE; count = 0xE;
} }
......
...@@ -98,7 +98,9 @@ ...@@ -98,7 +98,9 @@
#define SDIO_CCCR_IF 0x07 /* bus interface controls */ #define SDIO_CCCR_IF 0x07 /* bus interface controls */
#define SDIO_BUS_WIDTH_MASK 0x03 /* data bus width setting */
#define SDIO_BUS_WIDTH_1BIT 0x00 #define SDIO_BUS_WIDTH_1BIT 0x00
#define SDIO_BUS_WIDTH_RESERVED 0x01
#define SDIO_BUS_WIDTH_4BIT 0x02 #define SDIO_BUS_WIDTH_4BIT 0x02
#define SDIO_BUS_ECSI 0x20 /* Enable continuous SPI interrupt */ #define SDIO_BUS_ECSI 0x20 /* Enable continuous SPI interrupt */
#define SDIO_BUS_SCSI 0x40 /* Support continuous SPI interrupt */ #define SDIO_BUS_SCSI 0x40 /* Support continuous SPI interrupt */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment