Commit a4275153 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull MMC fixes from Chris Ball:
 - sdhci: fix a NULL dereference at resume-time, seen on OLPC XO-4
 - sdhci: fix against 3.7-rc1 for UHS modes without a vqmmc regulator
 - sdhci-of-esdhc: disable CMD23 on boards where it's broken
 - sdhci-s3c: fix against 3.7-rc1 for card detection with runtime PM
 - dw_mmc, omap_hsmmc: fix potential NULL derefs, compiler warnings

* tag 'mmc-fixes-for-3.7-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc:
  mmc: sdhci-s3c: fix the card detection in runtime-pm
  mmc: sdhci-s3c: use clk_prepare_enable and clk_disable_unprepare
  mmc: dw_mmc: constify dw_mci_idmac_ops in exynos back-end
  mmc: dw_mmc: fix modular build for exynos back-end
  mmc: sdhci: fix NULL dereference in sdhci_request() tuning
  mmc: sdhci: fix IS_ERR() checking of regulator_get()
  mmc: fix sdhci-dove probe/removal
  mmc: sh_mmcif: fix use after free
  mmc: sdhci-pci: fix 'Invalid iomem size' error message condition
  mmc: mxcmmc: Fix MODULE_ALIAS
  mmc: omap_hsmmc: fix NULL pointer dereference for dt boot
  mmc: omap_hsmmc: fix host reference after mmc_free_host
  mmc: dw_mmc: fix multiple drv_data NULL dereferences
  mmc: dw_mmc: enable controller interrupt before calling mmc_start_host
  mmc: sdhci-of-esdhc: disable CMD23 for some Freescale SoCs
  mmc: dw_mmc: remove _dev_info compile warning
  mmc: dw_mmc: convert the variable type of irq
parents 9ca72adc 0aa55c23
...@@ -208,7 +208,7 @@ static unsigned long exynos5250_dwmmc_caps[4] = { ...@@ -208,7 +208,7 @@ static unsigned long exynos5250_dwmmc_caps[4] = {
MMC_CAP_CMD23, MMC_CAP_CMD23,
}; };
static struct dw_mci_drv_data exynos5250_drv_data = { static const struct dw_mci_drv_data exynos5250_drv_data = {
.caps = exynos5250_dwmmc_caps, .caps = exynos5250_dwmmc_caps,
.init = dw_mci_exynos_priv_init, .init = dw_mci_exynos_priv_init,
.setup_clock = dw_mci_exynos_setup_clock, .setup_clock = dw_mci_exynos_setup_clock,
...@@ -220,14 +220,14 @@ static struct dw_mci_drv_data exynos5250_drv_data = { ...@@ -220,14 +220,14 @@ static struct dw_mci_drv_data exynos5250_drv_data = {
static const struct of_device_id dw_mci_exynos_match[] = { static const struct of_device_id dw_mci_exynos_match[] = {
{ .compatible = "samsung,exynos5250-dw-mshc", { .compatible = "samsung,exynos5250-dw-mshc",
.data = (void *)&exynos5250_drv_data, }, .data = &exynos5250_drv_data, },
{}, {},
}; };
MODULE_DEVICE_TABLE(of, dw_mci_pltfm_match); MODULE_DEVICE_TABLE(of, dw_mci_exynos_match);
int dw_mci_exynos_probe(struct platform_device *pdev) int dw_mci_exynos_probe(struct platform_device *pdev)
{ {
struct dw_mci_drv_data *drv_data; const struct dw_mci_drv_data *drv_data;
const struct of_device_id *match; const struct of_device_id *match;
match = of_match_node(dw_mci_exynos_match, pdev->dev.of_node); match = of_match_node(dw_mci_exynos_match, pdev->dev.of_node);
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "dw_mmc.h" #include "dw_mmc.h"
int dw_mci_pltfm_register(struct platform_device *pdev, int dw_mci_pltfm_register(struct platform_device *pdev,
struct dw_mci_drv_data *drv_data) const struct dw_mci_drv_data *drv_data)
{ {
struct dw_mci *host; struct dw_mci *host;
struct resource *regs; struct resource *regs;
...@@ -50,8 +50,8 @@ int dw_mci_pltfm_register(struct platform_device *pdev, ...@@ -50,8 +50,8 @@ int dw_mci_pltfm_register(struct platform_device *pdev,
if (!host->regs) if (!host->regs)
return -ENOMEM; return -ENOMEM;
if (host->drv_data->init) { if (drv_data && drv_data->init) {
ret = host->drv_data->init(host); ret = drv_data->init(host);
if (ret) if (ret)
return ret; return ret;
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#define _DW_MMC_PLTFM_H_ #define _DW_MMC_PLTFM_H_
extern int dw_mci_pltfm_register(struct platform_device *pdev, extern int dw_mci_pltfm_register(struct platform_device *pdev,
struct dw_mci_drv_data *drv_data); const struct dw_mci_drv_data *drv_data);
extern int __devexit dw_mci_pltfm_remove(struct platform_device *pdev); extern int __devexit dw_mci_pltfm_remove(struct platform_device *pdev);
extern const struct dev_pm_ops dw_mci_pltfm_pmops; extern const struct dev_pm_ops dw_mci_pltfm_pmops;
......
...@@ -232,6 +232,7 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, struct mmc_command *cmd) ...@@ -232,6 +232,7 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, struct mmc_command *cmd)
{ {
struct mmc_data *data; struct mmc_data *data;
struct dw_mci_slot *slot = mmc_priv(mmc); struct dw_mci_slot *slot = mmc_priv(mmc);
struct dw_mci_drv_data *drv_data = slot->host->drv_data;
u32 cmdr; u32 cmdr;
cmd->error = -EINPROGRESS; cmd->error = -EINPROGRESS;
...@@ -261,8 +262,8 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, struct mmc_command *cmd) ...@@ -261,8 +262,8 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, struct mmc_command *cmd)
cmdr |= SDMMC_CMD_DAT_WR; cmdr |= SDMMC_CMD_DAT_WR;
} }
if (slot->host->drv_data->prepare_command) if (drv_data && drv_data->prepare_command)
slot->host->drv_data->prepare_command(slot->host, &cmdr); drv_data->prepare_command(slot->host, &cmdr);
return cmdr; return cmdr;
} }
...@@ -434,7 +435,7 @@ static int dw_mci_idmac_init(struct dw_mci *host) ...@@ -434,7 +435,7 @@ static int dw_mci_idmac_init(struct dw_mci *host)
return 0; return 0;
} }
static struct dw_mci_dma_ops dw_mci_idmac_ops = { static const struct dw_mci_dma_ops dw_mci_idmac_ops = {
.init = dw_mci_idmac_init, .init = dw_mci_idmac_init,
.start = dw_mci_idmac_start_dma, .start = dw_mci_idmac_start_dma,
.stop = dw_mci_idmac_stop_dma, .stop = dw_mci_idmac_stop_dma,
...@@ -772,6 +773,7 @@ static void dw_mci_request(struct mmc_host *mmc, struct mmc_request *mrq) ...@@ -772,6 +773,7 @@ static void dw_mci_request(struct mmc_host *mmc, struct mmc_request *mrq)
static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
{ {
struct dw_mci_slot *slot = mmc_priv(mmc); struct dw_mci_slot *slot = mmc_priv(mmc);
struct dw_mci_drv_data *drv_data = slot->host->drv_data;
u32 regs; u32 regs;
/* set default 1 bit mode */ /* set default 1 bit mode */
...@@ -807,8 +809,8 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) ...@@ -807,8 +809,8 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
slot->clock = ios->clock; slot->clock = ios->clock;
} }
if (slot->host->drv_data->set_ios) if (drv_data && drv_data->set_ios)
slot->host->drv_data->set_ios(slot->host, ios); drv_data->set_ios(slot->host, ios);
switch (ios->power_mode) { switch (ios->power_mode) {
case MMC_POWER_UP: case MMC_POWER_UP:
...@@ -1815,6 +1817,7 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) ...@@ -1815,6 +1817,7 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
{ {
struct mmc_host *mmc; struct mmc_host *mmc;
struct dw_mci_slot *slot; struct dw_mci_slot *slot;
struct dw_mci_drv_data *drv_data = host->drv_data;
int ctrl_id, ret; int ctrl_id, ret;
u8 bus_width; u8 bus_width;
...@@ -1854,8 +1857,8 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) ...@@ -1854,8 +1857,8 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
} else { } else {
ctrl_id = to_platform_device(host->dev)->id; ctrl_id = to_platform_device(host->dev)->id;
} }
if (host->drv_data && host->drv_data->caps) if (drv_data && drv_data->caps)
mmc->caps |= host->drv_data->caps[ctrl_id]; mmc->caps |= drv_data->caps[ctrl_id];
if (host->pdata->caps2) if (host->pdata->caps2)
mmc->caps2 = host->pdata->caps2; mmc->caps2 = host->pdata->caps2;
...@@ -1867,10 +1870,10 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) ...@@ -1867,10 +1870,10 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
else else
bus_width = 1; bus_width = 1;
if (host->drv_data->setup_bus) { if (drv_data && drv_data->setup_bus) {
struct device_node *slot_np; struct device_node *slot_np;
slot_np = dw_mci_of_find_slot_node(host->dev, slot->id); slot_np = dw_mci_of_find_slot_node(host->dev, slot->id);
ret = host->drv_data->setup_bus(host, slot_np, bus_width); ret = drv_data->setup_bus(host, slot_np, bus_width);
if (ret) if (ret)
goto err_setup_bus; goto err_setup_bus;
} }
...@@ -1968,7 +1971,7 @@ static void dw_mci_init_dma(struct dw_mci *host) ...@@ -1968,7 +1971,7 @@ static void dw_mci_init_dma(struct dw_mci *host)
/* Determine which DMA interface to use */ /* Determine which DMA interface to use */
#ifdef CONFIG_MMC_DW_IDMAC #ifdef CONFIG_MMC_DW_IDMAC
host->dma_ops = &dw_mci_idmac_ops; host->dma_ops = &dw_mci_idmac_ops;
dev_info(&host->dev, "Using internal DMA controller.\n"); dev_info(host->dev, "Using internal DMA controller.\n");
#endif #endif
if (!host->dma_ops) if (!host->dma_ops)
...@@ -2035,6 +2038,7 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) ...@@ -2035,6 +2038,7 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)
struct dw_mci_board *pdata; struct dw_mci_board *pdata;
struct device *dev = host->dev; struct device *dev = host->dev;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
struct dw_mci_drv_data *drv_data = host->drv_data;
int idx, ret; int idx, ret;
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
...@@ -2062,8 +2066,8 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) ...@@ -2062,8 +2066,8 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)
of_property_read_u32(np, "card-detect-delay", &pdata->detect_delay_ms); of_property_read_u32(np, "card-detect-delay", &pdata->detect_delay_ms);
if (host->drv_data->parse_dt) { if (drv_data && drv_data->parse_dt) {
ret = host->drv_data->parse_dt(host); ret = drv_data->parse_dt(host);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
} }
...@@ -2080,6 +2084,7 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) ...@@ -2080,6 +2084,7 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)
int dw_mci_probe(struct dw_mci *host) int dw_mci_probe(struct dw_mci *host)
{ {
struct dw_mci_drv_data *drv_data = host->drv_data;
int width, i, ret = 0; int width, i, ret = 0;
u32 fifo_size; u32 fifo_size;
int init_slots = 0; int init_slots = 0;
...@@ -2127,8 +2132,8 @@ int dw_mci_probe(struct dw_mci *host) ...@@ -2127,8 +2132,8 @@ int dw_mci_probe(struct dw_mci *host)
else else
host->bus_hz = clk_get_rate(host->ciu_clk); host->bus_hz = clk_get_rate(host->ciu_clk);
if (host->drv_data->setup_clock) { if (drv_data && drv_data->setup_clock) {
ret = host->drv_data->setup_clock(host); ret = drv_data->setup_clock(host);
if (ret) { if (ret) {
dev_err(host->dev, dev_err(host->dev,
"implementation specific clock setup failed\n"); "implementation specific clock setup failed\n");
...@@ -2228,6 +2233,21 @@ int dw_mci_probe(struct dw_mci *host) ...@@ -2228,6 +2233,21 @@ int dw_mci_probe(struct dw_mci *host)
else else
host->num_slots = ((mci_readl(host, HCON) >> 1) & 0x1F) + 1; host->num_slots = ((mci_readl(host, HCON) >> 1) & 0x1F) + 1;
/*
* Enable interrupts for command done, data over, data empty, card det,
* receive ready and error such as transmit, receive timeout, crc error
*/
mci_writel(host, RINTSTS, 0xFFFFFFFF);
mci_writel(host, INTMASK, SDMMC_INT_CMD_DONE | SDMMC_INT_DATA_OVER |
SDMMC_INT_TXDR | SDMMC_INT_RXDR |
DW_MCI_ERROR_FLAGS | SDMMC_INT_CD);
mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); /* Enable mci interrupt */
dev_info(host->dev, "DW MMC controller at irq %d, "
"%d bit host data width, "
"%u deep fifo\n",
host->irq, width, fifo_size);
/* We need at least one slot to succeed */ /* We need at least one slot to succeed */
for (i = 0; i < host->num_slots; i++) { for (i = 0; i < host->num_slots; i++) {
ret = dw_mci_init_slot(host, i); ret = dw_mci_init_slot(host, i);
...@@ -2257,20 +2277,6 @@ int dw_mci_probe(struct dw_mci *host) ...@@ -2257,20 +2277,6 @@ int dw_mci_probe(struct dw_mci *host)
else else
host->data_offset = DATA_240A_OFFSET; host->data_offset = DATA_240A_OFFSET;
/*
* Enable interrupts for command done, data over, data empty, card det,
* receive ready and error such as transmit, receive timeout, crc error
*/
mci_writel(host, RINTSTS, 0xFFFFFFFF);
mci_writel(host, INTMASK, SDMMC_INT_CMD_DONE | SDMMC_INT_DATA_OVER |
SDMMC_INT_TXDR | SDMMC_INT_RXDR |
DW_MCI_ERROR_FLAGS | SDMMC_INT_CD);
mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); /* Enable mci interrupt */
dev_info(host->dev, "DW MMC controller at irq %d, "
"%d bit host data width, "
"%u deep fifo\n",
host->irq, width, fifo_size);
if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO) if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO)
dev_info(host->dev, "Internal DMAC interrupt fix enabled.\n"); dev_info(host->dev, "Internal DMAC interrupt fix enabled.\n");
......
...@@ -1134,4 +1134,4 @@ module_platform_driver(mxcmci_driver); ...@@ -1134,4 +1134,4 @@ module_platform_driver(mxcmci_driver);
MODULE_DESCRIPTION("i.MX Multimedia Card Interface Driver"); MODULE_DESCRIPTION("i.MX Multimedia Card Interface Driver");
MODULE_AUTHOR("Sascha Hauer, Pengutronix"); MODULE_AUTHOR("Sascha Hauer, Pengutronix");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:imx-mmc"); MODULE_ALIAS("platform:mxc-mmc");
...@@ -178,7 +178,8 @@ struct omap_hsmmc_host { ...@@ -178,7 +178,8 @@ struct omap_hsmmc_host {
static int omap_hsmmc_card_detect(struct device *dev, int slot) static int omap_hsmmc_card_detect(struct device *dev, int slot)
{ {
struct omap_mmc_platform_data *mmc = dev->platform_data; struct omap_hsmmc_host *host = dev_get_drvdata(dev);
struct omap_mmc_platform_data *mmc = host->pdata;
/* NOTE: assumes card detect signal is active-low */ /* NOTE: assumes card detect signal is active-low */
return !gpio_get_value_cansleep(mmc->slots[0].switch_pin); return !gpio_get_value_cansleep(mmc->slots[0].switch_pin);
...@@ -186,7 +187,8 @@ static int omap_hsmmc_card_detect(struct device *dev, int slot) ...@@ -186,7 +187,8 @@ static int omap_hsmmc_card_detect(struct device *dev, int slot)
static int omap_hsmmc_get_wp(struct device *dev, int slot) static int omap_hsmmc_get_wp(struct device *dev, int slot)
{ {
struct omap_mmc_platform_data *mmc = dev->platform_data; struct omap_hsmmc_host *host = dev_get_drvdata(dev);
struct omap_mmc_platform_data *mmc = host->pdata;
/* NOTE: assumes write protect signal is active-high */ /* NOTE: assumes write protect signal is active-high */
return gpio_get_value_cansleep(mmc->slots[0].gpio_wp); return gpio_get_value_cansleep(mmc->slots[0].gpio_wp);
...@@ -194,7 +196,8 @@ static int omap_hsmmc_get_wp(struct device *dev, int slot) ...@@ -194,7 +196,8 @@ static int omap_hsmmc_get_wp(struct device *dev, int slot)
static int omap_hsmmc_get_cover_state(struct device *dev, int slot) static int omap_hsmmc_get_cover_state(struct device *dev, int slot)
{ {
struct omap_mmc_platform_data *mmc = dev->platform_data; struct omap_hsmmc_host *host = dev_get_drvdata(dev);
struct omap_mmc_platform_data *mmc = host->pdata;
/* NOTE: assumes card detect signal is active-low */ /* NOTE: assumes card detect signal is active-low */
return !gpio_get_value_cansleep(mmc->slots[0].switch_pin); return !gpio_get_value_cansleep(mmc->slots[0].switch_pin);
...@@ -204,7 +207,8 @@ static int omap_hsmmc_get_cover_state(struct device *dev, int slot) ...@@ -204,7 +207,8 @@ static int omap_hsmmc_get_cover_state(struct device *dev, int slot)
static int omap_hsmmc_suspend_cdirq(struct device *dev, int slot) static int omap_hsmmc_suspend_cdirq(struct device *dev, int slot)
{ {
struct omap_mmc_platform_data *mmc = dev->platform_data; struct omap_hsmmc_host *host = dev_get_drvdata(dev);
struct omap_mmc_platform_data *mmc = host->pdata;
disable_irq(mmc->slots[0].card_detect_irq); disable_irq(mmc->slots[0].card_detect_irq);
return 0; return 0;
...@@ -212,7 +216,8 @@ static int omap_hsmmc_suspend_cdirq(struct device *dev, int slot) ...@@ -212,7 +216,8 @@ static int omap_hsmmc_suspend_cdirq(struct device *dev, int slot)
static int omap_hsmmc_resume_cdirq(struct device *dev, int slot) static int omap_hsmmc_resume_cdirq(struct device *dev, int slot)
{ {
struct omap_mmc_platform_data *mmc = dev->platform_data; struct omap_hsmmc_host *host = dev_get_drvdata(dev);
struct omap_mmc_platform_data *mmc = host->pdata;
enable_irq(mmc->slots[0].card_detect_irq); enable_irq(mmc->slots[0].card_detect_irq);
return 0; return 0;
...@@ -2009,9 +2014,9 @@ static int __devexit omap_hsmmc_remove(struct platform_device *pdev) ...@@ -2009,9 +2014,9 @@ static int __devexit omap_hsmmc_remove(struct platform_device *pdev)
clk_put(host->dbclk); clk_put(host->dbclk);
} }
mmc_free_host(host->mmc); omap_hsmmc_gpio_free(host->pdata);
iounmap(host->base); iounmap(host->base);
omap_hsmmc_gpio_free(pdev->dev.platform_data); mmc_free_host(host->mmc);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res) if (res)
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <linux/err.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h> #include <linux/err.h>
...@@ -84,30 +85,32 @@ static int __devinit sdhci_dove_probe(struct platform_device *pdev) ...@@ -84,30 +85,32 @@ static int __devinit sdhci_dove_probe(struct platform_device *pdev)
struct sdhci_dove_priv *priv; struct sdhci_dove_priv *priv;
int ret; int ret;
ret = sdhci_pltfm_register(pdev, &sdhci_dove_pdata);
if (ret)
goto sdhci_dove_register_fail;
priv = devm_kzalloc(&pdev->dev, sizeof(struct sdhci_dove_priv), priv = devm_kzalloc(&pdev->dev, sizeof(struct sdhci_dove_priv),
GFP_KERNEL); GFP_KERNEL);
if (!priv) { if (!priv) {
dev_err(&pdev->dev, "unable to allocate private data"); dev_err(&pdev->dev, "unable to allocate private data");
ret = -ENOMEM; return -ENOMEM;
goto sdhci_dove_allocate_fail;
} }
priv->clk = clk_get(&pdev->dev, NULL);
if (!IS_ERR(priv->clk))
clk_prepare_enable(priv->clk);
ret = sdhci_pltfm_register(pdev, &sdhci_dove_pdata);
if (ret)
goto sdhci_dove_register_fail;
host = platform_get_drvdata(pdev); host = platform_get_drvdata(pdev);
pltfm_host = sdhci_priv(host); pltfm_host = sdhci_priv(host);
pltfm_host->priv = priv; pltfm_host->priv = priv;
priv->clk = clk_get(&pdev->dev, NULL);
if (!IS_ERR(priv->clk))
clk_prepare_enable(priv->clk);
return 0; return 0;
sdhci_dove_allocate_fail:
sdhci_pltfm_unregister(pdev);
sdhci_dove_register_fail: sdhci_dove_register_fail:
if (!IS_ERR(priv->clk)) {
clk_disable_unprepare(priv->clk);
clk_put(priv->clk);
}
return ret; return ret;
} }
...@@ -117,14 +120,13 @@ static int __devexit sdhci_dove_remove(struct platform_device *pdev) ...@@ -117,14 +120,13 @@ static int __devexit sdhci_dove_remove(struct platform_device *pdev)
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
struct sdhci_dove_priv *priv = pltfm_host->priv; struct sdhci_dove_priv *priv = pltfm_host->priv;
if (priv->clk) { sdhci_pltfm_unregister(pdev);
if (!IS_ERR(priv->clk)) {
clk_disable_unprepare(priv->clk); if (!IS_ERR(priv->clk)) {
clk_put(priv->clk); clk_disable_unprepare(priv->clk);
} clk_put(priv->clk);
devm_kfree(&pdev->dev, priv->clk);
} }
return sdhci_pltfm_unregister(pdev); return 0;
} }
static const struct of_device_id sdhci_dove_of_match_table[] __devinitdata = { static const struct of_device_id sdhci_dove_of_match_table[] __devinitdata = {
......
...@@ -169,6 +169,16 @@ static void esdhc_of_resume(struct sdhci_host *host) ...@@ -169,6 +169,16 @@ static void esdhc_of_resume(struct sdhci_host *host)
} }
#endif #endif
static void esdhc_of_platform_init(struct sdhci_host *host)
{
u32 vvn;
vvn = in_be32(host->ioaddr + SDHCI_SLOT_INT_STATUS);
vvn = (vvn & SDHCI_VENDOR_VER_MASK) >> SDHCI_VENDOR_VER_SHIFT;
if (vvn == VENDOR_V_22)
host->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
}
static struct sdhci_ops sdhci_esdhc_ops = { static struct sdhci_ops sdhci_esdhc_ops = {
.read_l = esdhc_readl, .read_l = esdhc_readl,
.read_w = esdhc_readw, .read_w = esdhc_readw,
...@@ -180,6 +190,7 @@ static struct sdhci_ops sdhci_esdhc_ops = { ...@@ -180,6 +190,7 @@ static struct sdhci_ops sdhci_esdhc_ops = {
.enable_dma = esdhc_of_enable_dma, .enable_dma = esdhc_of_enable_dma,
.get_max_clock = esdhc_of_get_max_clock, .get_max_clock = esdhc_of_get_max_clock,
.get_min_clock = esdhc_of_get_min_clock, .get_min_clock = esdhc_of_get_min_clock,
.platform_init = esdhc_of_platform_init,
#ifdef CONFIG_PM #ifdef CONFIG_PM
.platform_suspend = esdhc_of_suspend, .platform_suspend = esdhc_of_suspend,
.platform_resume = esdhc_of_resume, .platform_resume = esdhc_of_resume,
......
...@@ -1196,7 +1196,7 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot( ...@@ -1196,7 +1196,7 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot(
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
} }
if (pci_resource_len(pdev, bar) != 0x100) { if (pci_resource_len(pdev, bar) < 0x100) {
dev_err(&pdev->dev, "Invalid iomem size. You may " dev_err(&pdev->dev, "Invalid iomem size. You may "
"experience problems.\n"); "experience problems.\n");
} }
......
...@@ -150,6 +150,13 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, ...@@ -150,6 +150,13 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
goto err_remap; goto err_remap;
} }
/*
* Some platforms need to probe the controller to be able to
* determine which caps should be used.
*/
if (host->ops && host->ops->platform_init)
host->ops->platform_init(host);
platform_set_drvdata(pdev, host); platform_set_drvdata(pdev, host);
return host; return host;
......
...@@ -211,8 +211,8 @@ static void sdhci_s3c_set_clock(struct sdhci_host *host, unsigned int clock) ...@@ -211,8 +211,8 @@ static void sdhci_s3c_set_clock(struct sdhci_host *host, unsigned int clock)
if (ourhost->cur_clk != best_src) { if (ourhost->cur_clk != best_src) {
struct clk *clk = ourhost->clk_bus[best_src]; struct clk *clk = ourhost->clk_bus[best_src];
clk_enable(clk); clk_prepare_enable(clk);
clk_disable(ourhost->clk_bus[ourhost->cur_clk]); clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
/* turn clock off to card before changing clock source */ /* turn clock off to card before changing clock source */
writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL); writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL);
...@@ -607,7 +607,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) ...@@ -607,7 +607,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
} }
/* enable the local io clock and keep it running for the moment. */ /* enable the local io clock and keep it running for the moment. */
clk_enable(sc->clk_io); clk_prepare_enable(sc->clk_io);
for (clks = 0, ptr = 0; ptr < MAX_BUS_CLK; ptr++) { for (clks = 0, ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
struct clk *clk; struct clk *clk;
...@@ -638,7 +638,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) ...@@ -638,7 +638,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
} }
#ifndef CONFIG_PM_RUNTIME #ifndef CONFIG_PM_RUNTIME
clk_enable(sc->clk_bus[sc->cur_clk]); clk_prepare_enable(sc->clk_bus[sc->cur_clk]);
#endif #endif
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
...@@ -747,13 +747,14 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) ...@@ -747,13 +747,14 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
sdhci_s3c_setup_card_detect_gpio(sc); sdhci_s3c_setup_card_detect_gpio(sc);
#ifdef CONFIG_PM_RUNTIME #ifdef CONFIG_PM_RUNTIME
clk_disable(sc->clk_io); if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
clk_disable_unprepare(sc->clk_io);
#endif #endif
return 0; return 0;
err_req_regs: err_req_regs:
#ifndef CONFIG_PM_RUNTIME #ifndef CONFIG_PM_RUNTIME
clk_disable(sc->clk_bus[sc->cur_clk]); clk_disable_unprepare(sc->clk_bus[sc->cur_clk]);
#endif #endif
for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) { for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
if (sc->clk_bus[ptr]) { if (sc->clk_bus[ptr]) {
...@@ -762,7 +763,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) ...@@ -762,7 +763,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
} }
err_no_busclks: err_no_busclks:
clk_disable(sc->clk_io); clk_disable_unprepare(sc->clk_io);
clk_put(sc->clk_io); clk_put(sc->clk_io);
err_io_clk: err_io_clk:
...@@ -794,7 +795,8 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev) ...@@ -794,7 +795,8 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
gpio_free(sc->ext_cd_gpio); gpio_free(sc->ext_cd_gpio);
#ifdef CONFIG_PM_RUNTIME #ifdef CONFIG_PM_RUNTIME
clk_enable(sc->clk_io); if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
clk_prepare_enable(sc->clk_io);
#endif #endif
sdhci_remove_host(host, 1); sdhci_remove_host(host, 1);
...@@ -802,14 +804,14 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev) ...@@ -802,14 +804,14 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
#ifndef CONFIG_PM_RUNTIME #ifndef CONFIG_PM_RUNTIME
clk_disable(sc->clk_bus[sc->cur_clk]); clk_disable_unprepare(sc->clk_bus[sc->cur_clk]);
#endif #endif
for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) { for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
if (sc->clk_bus[ptr]) { if (sc->clk_bus[ptr]) {
clk_put(sc->clk_bus[ptr]); clk_put(sc->clk_bus[ptr]);
} }
} }
clk_disable(sc->clk_io); clk_disable_unprepare(sc->clk_io);
clk_put(sc->clk_io); clk_put(sc->clk_io);
if (pdev->dev.of_node) { if (pdev->dev.of_node) {
...@@ -849,8 +851,8 @@ static int sdhci_s3c_runtime_suspend(struct device *dev) ...@@ -849,8 +851,8 @@ static int sdhci_s3c_runtime_suspend(struct device *dev)
ret = sdhci_runtime_suspend_host(host); ret = sdhci_runtime_suspend_host(host);
clk_disable(ourhost->clk_bus[ourhost->cur_clk]); clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
clk_disable(busclk); clk_disable_unprepare(busclk);
return ret; return ret;
} }
...@@ -861,8 +863,8 @@ static int sdhci_s3c_runtime_resume(struct device *dev) ...@@ -861,8 +863,8 @@ static int sdhci_s3c_runtime_resume(struct device *dev)
struct clk *busclk = ourhost->clk_io; struct clk *busclk = ourhost->clk_io;
int ret; int ret;
clk_enable(busclk); clk_prepare_enable(busclk);
clk_enable(ourhost->clk_bus[ourhost->cur_clk]); clk_prepare_enable(ourhost->clk_bus[ourhost->cur_clk]);
ret = sdhci_runtime_resume_host(host); ret = sdhci_runtime_resume_host(host);
return ret; return ret;
} }
......
...@@ -1315,16 +1315,19 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) ...@@ -1315,16 +1315,19 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
*/ */
if ((host->flags & SDHCI_NEEDS_RETUNING) && if ((host->flags & SDHCI_NEEDS_RETUNING) &&
!(present_state & (SDHCI_DOING_WRITE | SDHCI_DOING_READ))) { !(present_state & (SDHCI_DOING_WRITE | SDHCI_DOING_READ))) {
/* eMMC uses cmd21 while sd and sdio use cmd19 */ if (mmc->card) {
tuning_opcode = mmc->card->type == MMC_TYPE_MMC ? /* eMMC uses cmd21 but sd and sdio use cmd19 */
MMC_SEND_TUNING_BLOCK_HS200 : tuning_opcode =
MMC_SEND_TUNING_BLOCK; mmc->card->type == MMC_TYPE_MMC ?
spin_unlock_irqrestore(&host->lock, flags); MMC_SEND_TUNING_BLOCK_HS200 :
sdhci_execute_tuning(mmc, tuning_opcode); MMC_SEND_TUNING_BLOCK;
spin_lock_irqsave(&host->lock, flags); spin_unlock_irqrestore(&host->lock, flags);
sdhci_execute_tuning(mmc, tuning_opcode);
/* Restore original mmc_request structure */ spin_lock_irqsave(&host->lock, flags);
host->mrq = mrq;
/* Restore original mmc_request structure */
host->mrq = mrq;
}
} }
if (mrq->sbc && !(host->flags & SDHCI_AUTO_CMD23)) if (mrq->sbc && !(host->flags & SDHCI_AUTO_CMD23))
...@@ -2837,6 +2840,9 @@ int sdhci_add_host(struct sdhci_host *host) ...@@ -2837,6 +2840,9 @@ int sdhci_add_host(struct sdhci_host *host)
if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA)) if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA))
mmc->caps |= MMC_CAP_4_BIT_DATA; mmc->caps |= MMC_CAP_4_BIT_DATA;
if (host->quirks2 & SDHCI_QUIRK2_HOST_NO_CMD23)
mmc->caps &= ~MMC_CAP_CMD23;
if (caps[0] & SDHCI_CAN_DO_HISPD) if (caps[0] & SDHCI_CAN_DO_HISPD)
mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED; mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;
...@@ -2846,9 +2852,12 @@ int sdhci_add_host(struct sdhci_host *host) ...@@ -2846,9 +2852,12 @@ int sdhci_add_host(struct sdhci_host *host)
/* If vqmmc regulator and no 1.8V signalling, then there's no UHS */ /* If vqmmc regulator and no 1.8V signalling, then there's no UHS */
host->vqmmc = regulator_get(mmc_dev(mmc), "vqmmc"); host->vqmmc = regulator_get(mmc_dev(mmc), "vqmmc");
if (IS_ERR(host->vqmmc)) { if (IS_ERR_OR_NULL(host->vqmmc)) {
pr_info("%s: no vqmmc regulator found\n", mmc_hostname(mmc)); if (PTR_ERR(host->vqmmc) < 0) {
host->vqmmc = NULL; pr_info("%s: no vqmmc regulator found\n",
mmc_hostname(mmc));
host->vqmmc = NULL;
}
} }
else if (regulator_is_supported_voltage(host->vqmmc, 1800000, 1800000)) else if (regulator_is_supported_voltage(host->vqmmc, 1800000, 1800000))
regulator_enable(host->vqmmc); regulator_enable(host->vqmmc);
...@@ -2904,9 +2913,12 @@ int sdhci_add_host(struct sdhci_host *host) ...@@ -2904,9 +2913,12 @@ int sdhci_add_host(struct sdhci_host *host)
ocr_avail = 0; ocr_avail = 0;
host->vmmc = regulator_get(mmc_dev(mmc), "vmmc"); host->vmmc = regulator_get(mmc_dev(mmc), "vmmc");
if (IS_ERR(host->vmmc)) { if (IS_ERR_OR_NULL(host->vmmc)) {
pr_info("%s: no vmmc regulator found\n", mmc_hostname(mmc)); if (PTR_ERR(host->vmmc) < 0) {
host->vmmc = NULL; pr_info("%s: no vmmc regulator found\n",
mmc_hostname(mmc));
host->vmmc = NULL;
}
} else } else
regulator_enable(host->vmmc); regulator_enable(host->vmmc);
......
...@@ -278,6 +278,7 @@ struct sdhci_ops { ...@@ -278,6 +278,7 @@ struct sdhci_ops {
void (*hw_reset)(struct sdhci_host *host); void (*hw_reset)(struct sdhci_host *host);
void (*platform_suspend)(struct sdhci_host *host); void (*platform_suspend)(struct sdhci_host *host);
void (*platform_resume)(struct sdhci_host *host); void (*platform_resume)(struct sdhci_host *host);
void (*platform_init)(struct sdhci_host *host);
}; };
#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
......
...@@ -1466,9 +1466,9 @@ static int __devexit sh_mmcif_remove(struct platform_device *pdev) ...@@ -1466,9 +1466,9 @@ static int __devexit sh_mmcif_remove(struct platform_device *pdev)
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
clk_disable(host->hclk);
mmc_free_host(host->mmc); mmc_free_host(host->mmc);
pm_runtime_put_sync(&pdev->dev); pm_runtime_put_sync(&pdev->dev);
clk_disable(host->hclk);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
return 0; return 0;
......
...@@ -137,7 +137,7 @@ struct dw_mci { ...@@ -137,7 +137,7 @@ struct dw_mci {
dma_addr_t sg_dma; dma_addr_t sg_dma;
void *sg_cpu; void *sg_cpu;
struct dw_mci_dma_ops *dma_ops; const struct dw_mci_dma_ops *dma_ops;
#ifdef CONFIG_MMC_DW_IDMAC #ifdef CONFIG_MMC_DW_IDMAC
unsigned int ring_size; unsigned int ring_size;
#else #else
...@@ -162,7 +162,7 @@ struct dw_mci { ...@@ -162,7 +162,7 @@ struct dw_mci {
u16 data_offset; u16 data_offset;
struct device *dev; struct device *dev;
struct dw_mci_board *pdata; struct dw_mci_board *pdata;
struct dw_mci_drv_data *drv_data; const struct dw_mci_drv_data *drv_data;
void *priv; void *priv;
struct clk *biu_clk; struct clk *biu_clk;
struct clk *ciu_clk; struct clk *ciu_clk;
...@@ -186,7 +186,7 @@ struct dw_mci { ...@@ -186,7 +186,7 @@ struct dw_mci {
struct regulator *vmmc; /* Power regulator */ struct regulator *vmmc; /* Power regulator */
unsigned long irq_flags; /* IRQ flags */ unsigned long irq_flags; /* IRQ flags */
unsigned int irq; int irq;
}; };
/* DMA ops for Internal/External DMAC interface */ /* DMA ops for Internal/External DMAC interface */
......
...@@ -91,6 +91,7 @@ struct sdhci_host { ...@@ -91,6 +91,7 @@ struct sdhci_host {
unsigned int quirks2; /* More deviations from spec. */ unsigned int quirks2; /* More deviations from spec. */
#define SDHCI_QUIRK2_HOST_OFF_CARD_ON (1<<0) #define SDHCI_QUIRK2_HOST_OFF_CARD_ON (1<<0)
#define SDHCI_QUIRK2_HOST_NO_CMD23 (1<<1)
int irq; /* Device IRQ */ int irq; /* Device IRQ */
void __iomem *ioaddr; /* Mapped address */ void __iomem *ioaddr; /* Mapped address */
......
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