#define DRIVER_NAME "mvsdio"
-static int maxfreq = MVSD_CLOCKRATE_MAX;
+static int maxfreq;
static int nodma;
struct mvsd_host {
const struct mbus_dram_target_info *dram;
struct resource *r;
int ret, irq;
- int gpio_card_detect, gpio_write_protect;
struct pinctrl *pinctrl;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!IS_ERR(host->clk))
clk_prepare_enable(host->clk);
+ mmc->ops = &mvsd_ops;
+
+ mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
+
+ mmc->f_min = DIV_ROUND_UP(host->base_clock, MVSD_BASE_DIV_MAX);
+ mmc->f_max = MVSD_CLOCKRATE_MAX;
+
+ mmc->max_blk_size = 2048;
+ mmc->max_blk_count = 65535;
+
+ mmc->max_segs = 1;
+ mmc->max_seg_size = mmc->max_blk_size * mmc->max_blk_count;
+ mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
+
if (np) {
if (IS_ERR(host->clk)) {
dev_err(&pdev->dev, "DT platforms must have a clock associated\n");
}
host->base_clock = clk_get_rate(host->clk) / 2;
- gpio_card_detect = of_get_named_gpio(np, "cd-gpios", 0);
- gpio_write_protect = of_get_named_gpio(np, "wp-gpios", 0);
+ ret = mmc_of_parse(mmc);
+ if (ret < 0)
+ goto out;
} else {
const struct mvsdio_platform_data *mvsd_data;
+
mvsd_data = pdev->dev.platform_data;
if (!mvsd_data) {
ret = -ENXIO;
goto out;
}
+ mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
+ MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;
host->base_clock = mvsd_data->clock / 2;
- gpio_card_detect = mvsd_data->gpio_card_detect ? : -EINVAL;
- gpio_write_protect = mvsd_data->gpio_write_protect ? : -EINVAL;
- }
-
- mmc->ops = &mvsd_ops;
-
- mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
- mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
- MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;
-
- mmc->f_min = DIV_ROUND_UP(host->base_clock, MVSD_BASE_DIV_MAX);
- mmc->f_max = maxfreq;
+ /* GPIO 0 regarded as invalid for backward compatibility */
+ if (mvsd_data->gpio_card_detect &&
+ gpio_is_valid(mvsd_data->gpio_card_detect)) {
+ ret = mmc_gpio_request_cd(mmc,
+ mvsd_data->gpio_card_detect);
+ if (ret)
+ goto out;
+ } else {
+ mmc->caps |= MMC_CAP_NEEDS_POLL;
+ }
- mmc->max_blk_size = 2048;
- mmc->max_blk_count = 65535;
+ if (mvsd_data->gpio_write_protect &&
+ gpio_is_valid(mvsd_data->gpio_write_protect))
+ mmc_gpio_request_ro(mmc, mvsd_data->gpio_write_protect);
+ }
- mmc->max_segs = 1;
- mmc->max_seg_size = mmc->max_blk_size * mmc->max_blk_count;
- mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
+ if (maxfreq)
+ mmc->f_max = maxfreq;
spin_lock_init(&host->lock);
goto out;
}
- if (gpio_is_valid(gpio_card_detect)) {
- ret = mmc_gpio_request_cd(mmc, gpio_card_detect);
- if (ret)
- goto out;
- } else
- mmc->caps |= MMC_CAP_NEEDS_POLL;
-
- mmc_gpio_request_ro(mmc, gpio_write_protect);
-
setup_timer(&host->timer, mvsd_timeout_timer, (unsigned long)host);
platform_set_drvdata(pdev, mmc);
ret = mmc_add_host(mmc);
goto out;
if (!(mmc->caps & MMC_CAP_NEEDS_POLL))
- dev_notice(&pdev->dev, "using GPIO %d for card detection\n",
- gpio_card_detect);
+ dev_notice(&pdev->dev, "using GPIO for card detection\n");
else
- dev_notice(&pdev->dev, "lacking card detect (fall back to polling)\n");
+ dev_notice(&pdev->dev,
+ "lacking card detect (fall back to polling)\n");
return 0;
out: