Commit 92bf3d09 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull MMC changes from Chris Ball
 - at91-mci: This driver will be replaced by atmel-mci in 3.7.
 - atmel-mci: Add support for old at91-mci hardware.
 - dw_mmc: Allow multiple controllers; this previously caused
   corruption.
 - imxmmc: Remove this driver, replaced by mxcmmc.
 - mmci: Add device tree support.
 - omap: Allow multiple controllers.
 - omap_hsmmc: Auto CMD12, DDR support.
 - tegra: Support SD 3.0 spec.

Fix up the usual trivial conflicts in feature-removal-schedule.txt

* tag 'mmc-merge-for-3.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc: (38 commits)
  mmc: at91-mci: this driver is now deprecated
  mmc: omap_hsmmc: pass IRQF_ONESHOT to request_threaded_irq
  mmc: block: Allow disabling 512B sector size emulation
  mmc: atmel-mci: add debug logs
  mmc: atmel-mci: add support for version lower than v2xx
  mmc: atmel-mci: change the state machine for compatibility with old IP
  mmc: atmel-mci: the r/w proof capability lack was not well managed
  mmc: dw_mmc: Fixed sdio interrupt mask bit setting bug
  mmc: omap: convert to module_platform_driver
  mmc: omap: make it behave well as a module
  mmc: omap: convert to per instance workqueue
  mmc: core: Remove dead code
  mmc: card: Avoid null pointer dereference
  mmc: core: Prevent eMMC VCC supply to be cut from late init
  mmc: dw_mmc: make multiple instances of dw_mci_card_workqueue
  mmc: queue: remove redundant memsets
  mmc: queue: rename mmc_request function
  mmc: core: skip card initialization if power class selection fails
  mmc: core: fix the signaling 1.8V for HS200
  mmc: core: fix the decision of HS200/DDR card-type
  ...
parents 603d6637 0caaa953
* ARM PrimeCell MultiMedia Card Interface (MMCI) PL180/1
The ARM PrimeCell MMCI PL180 and PL181 provides and interface for
reading and writing to MultiMedia and SD cards alike.
Required properties:
- compatible : contains "arm,pl18x", "arm,primecell".
- reg : contains pl18x registers and length.
- interrupts : contains the device IRQ(s).
- arm,primecell-periphid : contains the PrimeCell Peripheral ID.
Optional properties:
- wp-gpios : contains any write protect (ro) gpios
- cd-gpios : contains any card detection gpios
- cd-inverted : indicates whether the cd gpio is inverted
- max-frequency : contains the maximum operating frequency
- bus-width : number of data lines, can be <1>, <4>, or <8>
- mmc-cap-mmc-highspeed : indicates whether MMC is high speed capable
- mmc-cap-sd-highspeed : indicates whether SD is high speed capable
...@@ -595,3 +595,14 @@ Why: KVM tracepoints provide mostly equivalent information in a much more ...@@ -595,3 +595,14 @@ Why: KVM tracepoints provide mostly equivalent information in a much more
flexible fashion. flexible fashion.
---------------------------- ----------------------------
What: at91-mci driver ("CONFIG_MMC_AT91")
When: 3.7
Why: There are two mci drivers: at91-mci and atmel-mci. The PDC support
was added to atmel-mci as a first step to support more chips.
Then at91-mci was kept only for old IP versions (on at91rm9200 and
at91sam9261). The support of these IP versions has just been added
to atmel-mci, so atmel-mci can be used for all chips.
Who: Ludovic Desroches <ludovic.desroches@atmel.com>
----------------------------
...@@ -384,7 +384,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, ...@@ -384,7 +384,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
md = mmc_blk_get(bdev->bd_disk); md = mmc_blk_get(bdev->bd_disk);
if (!md) { if (!md) {
err = -EINVAL; err = -EINVAL;
goto cmd_done; goto cmd_err;
} }
card = md->queue.card; card = md->queue.card;
...@@ -483,6 +483,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, ...@@ -483,6 +483,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
cmd_done: cmd_done:
mmc_blk_put(md); mmc_blk_put(md);
cmd_err:
kfree(idata->buf); kfree(idata->buf);
kfree(idata); kfree(idata);
return err; return err;
...@@ -1283,7 +1284,7 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) ...@@ -1283,7 +1284,7 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)
int ret = 1, disable_multi = 0, retry = 0, type; int ret = 1, disable_multi = 0, retry = 0, type;
enum mmc_blk_status status; enum mmc_blk_status status;
struct mmc_queue_req *mq_rq; struct mmc_queue_req *mq_rq;
struct request *req; struct request *req = rqc;
struct mmc_async_req *areq; struct mmc_async_req *areq;
if (!rqc && !mq->mqrq_prev->req) if (!rqc && !mq->mqrq_prev->req)
...@@ -1291,6 +1292,16 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) ...@@ -1291,6 +1292,16 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)
do { do {
if (rqc) { if (rqc) {
/*
* When 4KB native sector is enabled, only 8 blocks
* multiple read or write is allowed
*/
if ((brq->data.blocks & 0x07) &&
(card->ext_csd.data_sector_size == 4096)) {
pr_err("%s: Transfer size is not 4KB sector size aligned\n",
req->rq_disk->disk_name);
goto cmd_abort;
}
mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq); mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
areq = &mq->mqrq_cur->mmc_active; areq = &mq->mqrq_cur->mmc_active;
} else } else
...@@ -1538,7 +1549,12 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, ...@@ -1538,7 +1549,12 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
snprintf(md->disk->disk_name, sizeof(md->disk->disk_name), snprintf(md->disk->disk_name, sizeof(md->disk->disk_name),
"mmcblk%d%s", md->name_idx, subname ? subname : ""); "mmcblk%d%s", md->name_idx, subname ? subname : "");
if (mmc_card_mmc(card))
blk_queue_logical_block_size(md->queue.queue,
card->ext_csd.data_sector_size);
else
blk_queue_logical_block_size(md->queue.queue, 512); blk_queue_logical_block_size(md->queue.queue, 512);
set_capacity(md->disk, size); set_capacity(md->disk, size);
if (mmc_host_cmd23(card->host)) { if (mmc_host_cmd23(card->host)) {
......
...@@ -96,7 +96,7 @@ static int mmc_queue_thread(void *d) ...@@ -96,7 +96,7 @@ static int mmc_queue_thread(void *d)
* on any queue on this host, and attempt to issue it. This may * on any queue on this host, and attempt to issue it. This may
* not be the queue we were asked to process. * not be the queue we were asked to process.
*/ */
static void mmc_request(struct request_queue *q) static void mmc_request_fn(struct request_queue *q)
{ {
struct mmc_queue *mq = q->queuedata; struct mmc_queue *mq = q->queuedata;
struct request *req; struct request *req;
...@@ -171,12 +171,10 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, ...@@ -171,12 +171,10 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
limit = *mmc_dev(host)->dma_mask; limit = *mmc_dev(host)->dma_mask;
mq->card = card; mq->card = card;
mq->queue = blk_init_queue(mmc_request, lock); mq->queue = blk_init_queue(mmc_request_fn, lock);
if (!mq->queue) if (!mq->queue)
return -ENOMEM; return -ENOMEM;
memset(&mq->mqrq_cur, 0, sizeof(mq->mqrq_cur));
memset(&mq->mqrq_prev, 0, sizeof(mq->mqrq_prev));
mq->mqrq_cur = mqrq_cur; mq->mqrq_cur = mqrq_cur;
mq->mqrq_prev = mqrq_prev; mq->mqrq_prev = mqrq_prev;
mq->queue->queuedata = mq; mq->queue->queuedata = mq;
......
...@@ -122,6 +122,7 @@ static int mmc_bus_remove(struct device *dev) ...@@ -122,6 +122,7 @@ static int mmc_bus_remove(struct device *dev)
return 0; return 0;
} }
#ifdef CONFIG_PM_SLEEP
static int mmc_bus_suspend(struct device *dev) static int mmc_bus_suspend(struct device *dev)
{ {
struct mmc_driver *drv = to_mmc_driver(dev->driver); struct mmc_driver *drv = to_mmc_driver(dev->driver);
...@@ -143,6 +144,7 @@ static int mmc_bus_resume(struct device *dev) ...@@ -143,6 +144,7 @@ static int mmc_bus_resume(struct device *dev)
ret = drv->resume(card); ret = drv->resume(card);
return ret; return ret;
} }
#endif
#ifdef CONFIG_PM_RUNTIME #ifdef CONFIG_PM_RUNTIME
......
...@@ -73,6 +73,9 @@ void mmc_cd_gpio_free(struct mmc_host *host) ...@@ -73,6 +73,9 @@ void mmc_cd_gpio_free(struct mmc_host *host)
{ {
struct mmc_cd_gpio *cd = host->hotplug.handler_priv; struct mmc_cd_gpio *cd = host->hotplug.handler_priv;
if (!cd)
return;
free_irq(host->hotplug.irq, host); free_irq(host->hotplug.irq, host);
gpio_free(cd->gpio); gpio_free(cd->gpio);
kfree(cd); kfree(cd);
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "sdio_ops.h" #include "sdio_ops.h"
static struct workqueue_struct *workqueue; static struct workqueue_struct *workqueue;
static const unsigned freqs[] = { 400000, 300000, 200000, 100000 };
/* /*
* Enabling software CRCs on the data blocks can be a significant (30%) * Enabling software CRCs on the data blocks can be a significant (30%)
...@@ -1157,6 +1158,9 @@ static void mmc_power_up(struct mmc_host *host) ...@@ -1157,6 +1158,9 @@ static void mmc_power_up(struct mmc_host *host)
{ {
int bit; int bit;
if (host->ios.power_mode == MMC_POWER_ON)
return;
mmc_host_clk_hold(host); mmc_host_clk_hold(host);
/* If ocr is set, we use it */ /* If ocr is set, we use it */
...@@ -1199,6 +1203,10 @@ static void mmc_power_up(struct mmc_host *host) ...@@ -1199,6 +1203,10 @@ static void mmc_power_up(struct mmc_host *host)
void mmc_power_off(struct mmc_host *host) void mmc_power_off(struct mmc_host *host)
{ {
int err = 0; int err = 0;
if (host->ios.power_mode == MMC_POWER_OFF)
return;
mmc_host_clk_hold(host); mmc_host_clk_hold(host);
host->ios.clock = 0; host->ios.clock = 0;
...@@ -2005,7 +2013,6 @@ EXPORT_SYMBOL(mmc_detect_card_removed); ...@@ -2005,7 +2013,6 @@ EXPORT_SYMBOL(mmc_detect_card_removed);
void mmc_rescan(struct work_struct *work) void mmc_rescan(struct work_struct *work)
{ {
static const unsigned freqs[] = { 400000, 300000, 200000, 100000 };
struct mmc_host *host = struct mmc_host *host =
container_of(work, struct mmc_host, detect.work); container_of(work, struct mmc_host, detect.work);
int i; int i;
...@@ -2044,8 +2051,12 @@ void mmc_rescan(struct work_struct *work) ...@@ -2044,8 +2051,12 @@ void mmc_rescan(struct work_struct *work)
*/ */
mmc_bus_put(host); mmc_bus_put(host);
if (host->ops->get_cd && host->ops->get_cd(host) == 0) if (host->ops->get_cd && host->ops->get_cd(host) == 0) {
mmc_claim_host(host);
mmc_power_off(host);
mmc_release_host(host);
goto out; goto out;
}
mmc_claim_host(host); mmc_claim_host(host);
for (i = 0; i < ARRAY_SIZE(freqs); i++) { for (i = 0; i < ARRAY_SIZE(freqs); i++) {
...@@ -2063,7 +2074,8 @@ void mmc_rescan(struct work_struct *work) ...@@ -2063,7 +2074,8 @@ void mmc_rescan(struct work_struct *work)
void mmc_start_host(struct mmc_host *host) void mmc_start_host(struct mmc_host *host)
{ {
mmc_power_off(host); host->f_init = max(freqs[0], host->f_min);
mmc_power_up(host);
mmc_detect_change(host, 0); mmc_detect_change(host, 0);
} }
......
...@@ -235,6 +235,36 @@ static int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd) ...@@ -235,6 +235,36 @@ static int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd)
return err; return err;
} }
static void mmc_select_card_type(struct mmc_card *card)
{
struct mmc_host *host = card->host;
u8 card_type = card->ext_csd.raw_card_type & EXT_CSD_CARD_TYPE_MASK;
unsigned int caps = host->caps, caps2 = host->caps2;
unsigned int hs_max_dtr = 0;
if (card_type & EXT_CSD_CARD_TYPE_26)
hs_max_dtr = MMC_HIGH_26_MAX_DTR;
if (caps & MMC_CAP_MMC_HIGHSPEED &&
card_type & EXT_CSD_CARD_TYPE_52)
hs_max_dtr = MMC_HIGH_52_MAX_DTR;
if ((caps & MMC_CAP_1_8V_DDR &&
card_type & EXT_CSD_CARD_TYPE_DDR_1_8V) ||
(caps & MMC_CAP_1_2V_DDR &&
card_type & EXT_CSD_CARD_TYPE_DDR_1_2V))
hs_max_dtr = MMC_HIGH_DDR_MAX_DTR;
if ((caps2 & MMC_CAP2_HS200_1_8V_SDR &&
card_type & EXT_CSD_CARD_TYPE_SDR_1_8V) ||
(caps2 & MMC_CAP2_HS200_1_2V_SDR &&
card_type & EXT_CSD_CARD_TYPE_SDR_1_2V))
hs_max_dtr = MMC_HS200_MAX_DTR;
card->ext_csd.hs_max_dtr = hs_max_dtr;
card->ext_csd.card_type = card_type;
}
/* /*
* Decode extended CSD. * Decode extended CSD.
*/ */
...@@ -284,56 +314,9 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) ...@@ -284,56 +314,9 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
if (card->ext_csd.sectors > (2u * 1024 * 1024 * 1024) / 512) if (card->ext_csd.sectors > (2u * 1024 * 1024 * 1024) / 512)
mmc_card_set_blockaddr(card); mmc_card_set_blockaddr(card);
} }
card->ext_csd.raw_card_type = ext_csd[EXT_CSD_CARD_TYPE]; card->ext_csd.raw_card_type = ext_csd[EXT_CSD_CARD_TYPE];
switch (ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_MASK) { mmc_select_card_type(card);
case EXT_CSD_CARD_TYPE_SDR_ALL:
case EXT_CSD_CARD_TYPE_SDR_ALL_DDR_1_8V:
case EXT_CSD_CARD_TYPE_SDR_ALL_DDR_1_2V:
case EXT_CSD_CARD_TYPE_SDR_ALL_DDR_52:
card->ext_csd.hs_max_dtr = 200000000;
card->ext_csd.card_type = EXT_CSD_CARD_TYPE_SDR_200;
break;
case EXT_CSD_CARD_TYPE_SDR_1_2V_ALL:
case EXT_CSD_CARD_TYPE_SDR_1_2V_DDR_1_8V:
case EXT_CSD_CARD_TYPE_SDR_1_2V_DDR_1_2V:
case EXT_CSD_CARD_TYPE_SDR_1_2V_DDR_52:
card->ext_csd.hs_max_dtr = 200000000;
card->ext_csd.card_type = EXT_CSD_CARD_TYPE_SDR_1_2V;
break;
case EXT_CSD_CARD_TYPE_SDR_1_8V_ALL:
case EXT_CSD_CARD_TYPE_SDR_1_8V_DDR_1_8V:
case EXT_CSD_CARD_TYPE_SDR_1_8V_DDR_1_2V:
case EXT_CSD_CARD_TYPE_SDR_1_8V_DDR_52:
card->ext_csd.hs_max_dtr = 200000000;
card->ext_csd.card_type = EXT_CSD_CARD_TYPE_SDR_1_8V;
break;
case EXT_CSD_CARD_TYPE_DDR_52 | EXT_CSD_CARD_TYPE_52 |
EXT_CSD_CARD_TYPE_26:
card->ext_csd.hs_max_dtr = 52000000;
card->ext_csd.card_type = EXT_CSD_CARD_TYPE_DDR_52;
break;
case EXT_CSD_CARD_TYPE_DDR_1_2V | EXT_CSD_CARD_TYPE_52 |
EXT_CSD_CARD_TYPE_26:
card->ext_csd.hs_max_dtr = 52000000;
card->ext_csd.card_type = EXT_CSD_CARD_TYPE_DDR_1_2V;
break;
case EXT_CSD_CARD_TYPE_DDR_1_8V | EXT_CSD_CARD_TYPE_52 |
EXT_CSD_CARD_TYPE_26:
card->ext_csd.hs_max_dtr = 52000000;
card->ext_csd.card_type = EXT_CSD_CARD_TYPE_DDR_1_8V;
break;
case EXT_CSD_CARD_TYPE_52 | EXT_CSD_CARD_TYPE_26:
card->ext_csd.hs_max_dtr = 52000000;
break;
case EXT_CSD_CARD_TYPE_26:
card->ext_csd.hs_max_dtr = 26000000;
break;
default:
/* MMC v4 spec says this cannot happen */
pr_warning("%s: card is mmc v4 but doesn't "
"support any high-speed modes.\n",
mmc_hostname(card->host));
}
card->ext_csd.raw_s_a_timeout = ext_csd[EXT_CSD_S_A_TIMEOUT]; card->ext_csd.raw_s_a_timeout = ext_csd[EXT_CSD_S_A_TIMEOUT];
card->ext_csd.raw_erase_timeout_mult = card->ext_csd.raw_erase_timeout_mult =
...@@ -533,6 +516,8 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) ...@@ -533,6 +516,8 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
} else { } else {
card->ext_csd.data_tag_unit_size = 0; card->ext_csd.data_tag_unit_size = 0;
} }
} else {
card->ext_csd.data_sector_size = 512;
} }
out: out:
...@@ -556,14 +541,10 @@ static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width) ...@@ -556,14 +541,10 @@ static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width)
err = mmc_get_ext_csd(card, &bw_ext_csd); err = mmc_get_ext_csd(card, &bw_ext_csd);
if (err || bw_ext_csd == NULL) { if (err || bw_ext_csd == NULL) {
if (bus_width != MMC_BUS_WIDTH_1)
err = -EINVAL; err = -EINVAL;
goto out; goto out;
} }
if (bus_width == MMC_BUS_WIDTH_1)
goto out;
/* only compare read only fields */ /* only compare read only fields */
err = !((card->ext_csd.raw_partition_support == err = !((card->ext_csd.raw_partition_support ==
bw_ext_csd[EXT_CSD_PARTITION_SUPPORT]) && bw_ext_csd[EXT_CSD_PARTITION_SUPPORT]) &&
...@@ -736,6 +717,10 @@ static int mmc_select_powerclass(struct mmc_card *card, ...@@ -736,6 +717,10 @@ static int mmc_select_powerclass(struct mmc_card *card,
card->ext_csd.generic_cmd6_time); card->ext_csd.generic_cmd6_time);
} }
if (err)
pr_err("%s: power class selection for ext_csd_bus_width %d"
" failed\n", mmc_hostname(card->host), bus_width);
return err; return err;
} }
...@@ -745,7 +730,7 @@ static int mmc_select_powerclass(struct mmc_card *card, ...@@ -745,7 +730,7 @@ static int mmc_select_powerclass(struct mmc_card *card,
*/ */
static int mmc_select_hs200(struct mmc_card *card) static int mmc_select_hs200(struct mmc_card *card)
{ {
int idx, err = 0; int idx, err = -EINVAL;
struct mmc_host *host; struct mmc_host *host;
static unsigned ext_csd_bits[] = { static unsigned ext_csd_bits[] = {
EXT_CSD_BUS_WIDTH_4, EXT_CSD_BUS_WIDTH_4,
...@@ -762,9 +747,11 @@ static int mmc_select_hs200(struct mmc_card *card) ...@@ -762,9 +747,11 @@ static int mmc_select_hs200(struct mmc_card *card)
if (card->ext_csd.card_type & EXT_CSD_CARD_TYPE_SDR_1_2V && if (card->ext_csd.card_type & EXT_CSD_CARD_TYPE_SDR_1_2V &&
host->caps2 & MMC_CAP2_HS200_1_2V_SDR) host->caps2 & MMC_CAP2_HS200_1_2V_SDR)
if (mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120, 0)) err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120, 0);
err = mmc_set_signal_voltage(host,
MMC_SIGNAL_VOLTAGE_180, 0); if (err && card->ext_csd.card_type & EXT_CSD_CARD_TYPE_SDR_1_8V &&
host->caps2 & MMC_CAP2_HS200_1_8V_SDR)
err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180, 0);
/* If fails try again during next card power cycle */ /* If fails try again during next card power cycle */
if (err) if (err)
...@@ -1117,9 +1104,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, ...@@ -1117,9 +1104,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
EXT_CSD_BUS_WIDTH_8 : EXT_CSD_BUS_WIDTH_4; EXT_CSD_BUS_WIDTH_8 : EXT_CSD_BUS_WIDTH_4;
err = mmc_select_powerclass(card, ext_csd_bits, ext_csd); err = mmc_select_powerclass(card, ext_csd_bits, ext_csd);
if (err) if (err)
pr_warning("%s: power class selection to bus width %d" goto err;
" failed\n", mmc_hostname(card->host),
1 << bus_width);
} }
/* /*
...@@ -1151,10 +1136,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, ...@@ -1151,10 +1136,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
err = mmc_select_powerclass(card, ext_csd_bits[idx][0], err = mmc_select_powerclass(card, ext_csd_bits[idx][0],
ext_csd); ext_csd);
if (err) if (err)
pr_warning("%s: power class selection to " goto err;
"bus width %d failed\n",
mmc_hostname(card->host),
1 << bus_width);
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH,
...@@ -1182,10 +1164,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, ...@@ -1182,10 +1164,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
err = mmc_select_powerclass(card, ext_csd_bits[idx][1], err = mmc_select_powerclass(card, ext_csd_bits[idx][1],
ext_csd); ext_csd);
if (err) if (err)
pr_warning("%s: power class selection to " goto err;
"bus width %d ddr %d failed\n",
mmc_hostname(card->host),
1 << bus_width, ddr);
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH,
......
...@@ -947,7 +947,7 @@ static int mmc_sdio_resume(struct mmc_host *host) ...@@ -947,7 +947,7 @@ static int mmc_sdio_resume(struct mmc_host *host)
} }
if (!err && host->sdio_irqs) if (!err && host->sdio_irqs)
mmc_signal_sdio_irq(host); wake_up_process(host->sdio_irq_thread);
mmc_release_host(host); mmc_release_host(host);
/* /*
......
...@@ -28,18 +28,20 @@ ...@@ -28,18 +28,20 @@
#include "sdio_ops.h" #include "sdio_ops.h"
static int process_sdio_pending_irqs(struct mmc_card *card) static int process_sdio_pending_irqs(struct mmc_host *host)
{ {
struct mmc_card *card = host->card;
int i, ret, count; int i, ret, count;
unsigned char pending; unsigned char pending;
struct sdio_func *func; struct sdio_func *func;
/* /*
* Optimization, if there is only 1 function interrupt registered * Optimization, if there is only 1 function interrupt registered
* call irq handler directly * and we know an IRQ was signaled then call irq handler directly.
* Otherwise do the full probe.
*/ */
func = card->sdio_single_irq; func = card->sdio_single_irq;
if (func) { if (func && host->sdio_irq_pending) {
func->irq_handler(func); func->irq_handler(func);
return 1; return 1;
} }
...@@ -116,7 +118,8 @@ static int sdio_irq_thread(void *_host) ...@@ -116,7 +118,8 @@ static int sdio_irq_thread(void *_host)
ret = __mmc_claim_host(host, &host->sdio_irq_thread_abort); ret = __mmc_claim_host(host, &host->sdio_irq_thread_abort);
if (ret) if (ret)
break; break;
ret = process_sdio_pending_irqs(host->card); ret = process_sdio_pending_irqs(host);
host->sdio_irq_pending = false;
mmc_release_host(host); mmc_release_host(host);
/* /*
......
...@@ -278,10 +278,13 @@ choice ...@@ -278,10 +278,13 @@ choice
Choose which driver to use for the Atmel MCI Silicon Choose which driver to use for the Atmel MCI Silicon
config MMC_AT91 config MMC_AT91
tristate "AT91 SD/MMC Card Interface support" tristate "AT91 SD/MMC Card Interface support (DEPRECATED)"
depends on ARCH_AT91 depends on ARCH_AT91
help help
This selects the AT91 MCI controller. This selects the AT91 MCI controller. This driver will
be removed soon (for more information have a look to
Documentation/feature-removal-schedule.txt). Please use
MMC_ATMEL_MCI.
If unsure, say N. If unsure, say N.
...@@ -307,16 +310,6 @@ config MMC_ATMELMCI_DMA ...@@ -307,16 +310,6 @@ config MMC_ATMELMCI_DMA
If unsure, say N. If unsure, say N.
config MMC_IMX
tristate "Motorola i.MX Multimedia Card Interface support"
depends on ARCH_MX1
help
This selects the Motorola i.MX Multimedia card Interface.
If you have a i.MX platform with a Multimedia Card slot,
say Y or M here.
If unsure, say N.
config MMC_MSM config MMC_MSM
tristate "Qualcomm SDCC Controller Support" tristate "Qualcomm SDCC Controller Support"
depends on MMC && ARCH_MSM depends on MMC && ARCH_MSM
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
obj-$(CONFIG_MMC_ARMMMCI) += mmci.o obj-$(CONFIG_MMC_ARMMMCI) += mmci.o
obj-$(CONFIG_MMC_PXA) += pxamci.o obj-$(CONFIG_MMC_PXA) += pxamci.o
obj-$(CONFIG_MMC_IMX) += imxmmc.o
obj-$(CONFIG_MMC_MXC) += mxcmmc.o obj-$(CONFIG_MMC_MXC) += mxcmmc.o
obj-$(CONFIG_MMC_MXS) += mxs-mmc.o obj-$(CONFIG_MMC_MXS) += mxs-mmc.o
obj-$(CONFIG_MMC_SDHCI) += sdhci.o obj-$(CONFIG_MMC_SDHCI) += sdhci.o
......
This diff is collapsed.
...@@ -1533,4 +1533,5 @@ module_exit(davinci_mmcsd_exit); ...@@ -1533,4 +1533,5 @@ module_exit(davinci_mmcsd_exit);
MODULE_AUTHOR("Texas Instruments India"); MODULE_AUTHOR("Texas Instruments India");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("MMC/SD driver for Davinci MMC controller"); MODULE_DESCRIPTION("MMC/SD driver for Davinci MMC controller");
MODULE_ALIAS("platform:davinci_mmc");
...@@ -100,8 +100,6 @@ struct dw_mci_slot { ...@@ -100,8 +100,6 @@ struct dw_mci_slot {
int last_detect_state; int last_detect_state;
}; };
static struct workqueue_struct *dw_mci_card_workqueue;
#if defined(CONFIG_DEBUG_FS) #if defined(CONFIG_DEBUG_FS)
static int dw_mci_req_show(struct seq_file *s, void *v) static int dw_mci_req_show(struct seq_file *s, void *v)
{ {
...@@ -859,10 +857,10 @@ static void dw_mci_enable_sdio_irq(struct mmc_host *mmc, int enb) ...@@ -859,10 +857,10 @@ static void dw_mci_enable_sdio_irq(struct mmc_host *mmc, int enb)
int_mask = mci_readl(host, INTMASK); int_mask = mci_readl(host, INTMASK);
if (enb) { if (enb) {
mci_writel(host, INTMASK, mci_writel(host, INTMASK,
(int_mask | (1 << SDMMC_INT_SDIO(slot->id)))); (int_mask | SDMMC_INT_SDIO(slot->id)));
} else { } else {
mci_writel(host, INTMASK, mci_writel(host, INTMASK,
(int_mask & ~(1 << SDMMC_INT_SDIO(slot->id)))); (int_mask & ~SDMMC_INT_SDIO(slot->id)));
} }
} }
...@@ -1605,7 +1603,7 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id) ...@@ -1605,7 +1603,7 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id)
if (pending & SDMMC_INT_CD) { if (pending & SDMMC_INT_CD) {
mci_writel(host, RINTSTS, SDMMC_INT_CD); mci_writel(host, RINTSTS, SDMMC_INT_CD);
queue_work(dw_mci_card_workqueue, &host->card_work); queue_work(host->card_workqueue, &host->card_work);
} }
/* Handle SDIO Interrupts */ /* Handle SDIO Interrupts */
...@@ -1844,7 +1842,7 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id) ...@@ -1844,7 +1842,7 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id)
* Card may have been plugged in prior to boot so we * Card may have been plugged in prior to boot so we
* need to run the detect tasklet * need to run the detect tasklet
*/ */
queue_work(dw_mci_card_workqueue, &host->card_work); queue_work(host->card_workqueue, &host->card_work);
return 0; return 0;
} }
...@@ -2021,9 +2019,9 @@ int dw_mci_probe(struct dw_mci *host) ...@@ -2021,9 +2019,9 @@ int dw_mci_probe(struct dw_mci *host)
mci_writel(host, CLKSRC, 0); mci_writel(host, CLKSRC, 0);
tasklet_init(&host->tasklet, dw_mci_tasklet_func, (unsigned long)host); tasklet_init(&host->tasklet, dw_mci_tasklet_func, (unsigned long)host);
dw_mci_card_workqueue = alloc_workqueue("dw-mci-card", host->card_workqueue = alloc_workqueue("dw-mci-card",
WQ_MEM_RECLAIM | WQ_NON_REENTRANT, 1); WQ_MEM_RECLAIM | WQ_NON_REENTRANT, 1);
if (!dw_mci_card_workqueue) if (!host->card_workqueue)
goto err_dmaunmap; goto err_dmaunmap;
INIT_WORK(&host->card_work, dw_mci_work_routine_card); INIT_WORK(&host->card_work, dw_mci_work_routine_card);
ret = request_irq(host->irq, dw_mci_interrupt, host->irq_flags, "dw-mci", host); ret = request_irq(host->irq, dw_mci_interrupt, host->irq_flags, "dw-mci", host);
...@@ -2085,7 +2083,7 @@ int dw_mci_probe(struct dw_mci *host) ...@@ -2085,7 +2083,7 @@ int dw_mci_probe(struct dw_mci *host)
free_irq(host->irq, host); free_irq(host->irq, host);
err_workqueue: err_workqueue:
destroy_workqueue(dw_mci_card_workqueue); destroy_workqueue(host->card_workqueue);
err_dmaunmap: err_dmaunmap:
if (host->use_dma && host->dma_ops->exit) if (host->use_dma && host->dma_ops->exit)
...@@ -2119,7 +2117,7 @@ void dw_mci_remove(struct dw_mci *host) ...@@ -2119,7 +2117,7 @@ void dw_mci_remove(struct dw_mci *host)
mci_writel(host, CLKSRC, 0); mci_writel(host, CLKSRC, 0);
free_irq(host->irq, host); free_irq(host->irq, host);
destroy_workqueue(dw_mci_card_workqueue); destroy_workqueue(host->card_workqueue);
dma_free_coherent(&host->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma); dma_free_coherent(&host->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
if (host->use_dma && host->dma_ops->exit) if (host->use_dma && host->dma_ops->exit)
......
This diff is collapsed.
#define MMC_REG_STR_STP_CLK 0x00
#define MMC_REG_STATUS 0x04
#define MMC_REG_CLK_RATE 0x08
#define MMC_REG_CMD_DAT_CONT 0x0C
#define MMC_REG_RES_TO 0x10
#define MMC_REG_READ_TO 0x14
#define MMC_REG_BLK_LEN 0x18
#define MMC_REG_NOB 0x1C
#define MMC_REG_REV_NO 0x20
#define MMC_REG_INT_MASK 0x24
#define MMC_REG_CMD 0x28
#define MMC_REG_ARGH 0x2C
#define MMC_REG_ARGL 0x30
#define MMC_REG_RES_FIFO 0x34
#define MMC_REG_BUFFER_ACCESS 0x38
#define STR_STP_CLK_IPG_CLK_GATE_DIS (1<<15)
#define STR_STP_CLK_IPG_PERCLK_GATE_DIS (1<<14)
#define STR_STP_CLK_ENDIAN (1<<5)
#define STR_STP_CLK_RESET (1<<3)
#define STR_STP_CLK_ENABLE (1<<2)
#define STR_STP_CLK_START_CLK (1<<1)
#define STR_STP_CLK_STOP_CLK (1<<0)
#define STATUS_CARD_PRESENCE (1<<15)
#define STATUS_SDIO_INT_ACTIVE (1<<14)
#define STATUS_END_CMD_RESP (1<<13)
#define STATUS_WRITE_OP_DONE (1<<12)
#define STATUS_DATA_TRANS_DONE (1<<11)
#define STATUS_WR_CRC_ERROR_CODE_MASK (3<<10)
#define STATUS_CARD_BUS_CLK_RUN (1<<8)
#define STATUS_APPL_BUFF_FF (1<<7)
#define STATUS_APPL_BUFF_FE (1<<6)
#define STATUS_RESP_CRC_ERR (1<<5)
#define STATUS_CRC_READ_ERR (1<<3)
#define STATUS_CRC_WRITE_ERR (1<<2)
#define STATUS_TIME_OUT_RESP (1<<1)
#define STATUS_TIME_OUT_READ (1<<0)
#define STATUS_ERR_MASK 0x2f
#define CLK_RATE_PRESCALER(x) ((x) & 0x7)
#define CLK_RATE_CLK_RATE(x) (((x) & 0x7) << 3)
#define CMD_DAT_CONT_CMD_RESP_LONG_OFF (1<<12)
#define CMD_DAT_CONT_STOP_READWAIT (1<<11)
#define CMD_DAT_CONT_START_READWAIT (1<<10)
#define CMD_DAT_CONT_BUS_WIDTH_1 (0<<8)
#define CMD_DAT_CONT_BUS_WIDTH_4 (2<<8)
#define CMD_DAT_CONT_INIT (1<<7)
#define CMD_DAT_CONT_BUSY (1<<6)
#define CMD_DAT_CONT_STREAM_BLOCK (1<<5)
#define CMD_DAT_CONT_WRITE (1<<4)
#define CMD_DAT_CONT_DATA_ENABLE (1<<3)
#define CMD_DAT_CONT_RESPONSE_FORMAT_R1 (1)
#define CMD_DAT_CONT_RESPONSE_FORMAT_R2 (2)
#define CMD_DAT_CONT_RESPONSE_FORMAT_R3 (3)
#define CMD_DAT_CONT_RESPONSE_FORMAT_R4 (4)
#define CMD_DAT_CONT_RESPONSE_FORMAT_R5 (5)
#define CMD_DAT_CONT_RESPONSE_FORMAT_R6 (6)
#define INT_MASK_AUTO_CARD_DETECT (1<<6)
#define INT_MASK_DAT0_EN (1<<5)
#define INT_MASK_SDIO (1<<4)
#define INT_MASK_BUF_READY (1<<3)
#define INT_MASK_END_CMD_RES (1<<2)
#define INT_MASK_WRITE_OP_DONE (1<<1)
#define INT_MASK_DATA_TRAN (1<<0)
#define INT_ALL (0x7f)
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/highmem.h> #include <linux/highmem.h>
...@@ -25,6 +26,7 @@ ...@@ -25,6 +26,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/of_gpio.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/dmaengine.h> #include <linux/dmaengine.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
...@@ -1207,21 +1209,76 @@ static const struct mmc_host_ops mmci_ops = { ...@@ -1207,21 +1209,76 @@ static const struct mmc_host_ops mmci_ops = {
.get_cd = mmci_get_cd, .get_cd = mmci_get_cd,
}; };
#ifdef CONFIG_OF
static void mmci_dt_populate_generic_pdata(struct device_node *np,
struct mmci_platform_data *pdata)
{
int bus_width = 0;
pdata->gpio_wp = of_get_named_gpio(np, "wp-gpios", 0);
if (!pdata->gpio_wp)
pdata->gpio_wp = -1;
pdata->gpio_cd = of_get_named_gpio(np, "cd-gpios", 0);
if (!pdata->gpio_cd)
pdata->gpio_cd = -1;
if (of_get_property(np, "cd-inverted", NULL))
pdata->cd_invert = true;
else
pdata->cd_invert = false;
of_property_read_u32(np, "max-frequency", &pdata->f_max);
if (!pdata->f_max)
pr_warn("%s has no 'max-frequency' property\n", np->full_name);
if (of_get_property(np, "mmc-cap-mmc-highspeed", NULL))
pdata->capabilities |= MMC_CAP_MMC_HIGHSPEED;
if (of_get_property(np, "mmc-cap-sd-highspeed", NULL))
pdata->capabilities |= MMC_CAP_SD_HIGHSPEED;
of_property_read_u32(np, "bus-width", &bus_width);
switch (bus_width) {
case 0 :
/* No bus-width supplied. */
break;
case 4 :
pdata->capabilities |= MMC_CAP_4_BIT_DATA;
break;
case 8 :
pdata->capabilities |= MMC_CAP_8_BIT_DATA;
break;
default :
pr_warn("%s: Unsupported bus width\n", np->full_name);
}
}
#else
static void mmci_dt_populate_generic_pdata(struct device_node *np,
struct mmci_platform_data *pdata)
{
return;
}
#endif
static int __devinit mmci_probe(struct amba_device *dev, static int __devinit mmci_probe(struct amba_device *dev,
const struct amba_id *id) const struct amba_id *id)
{ {
struct mmci_platform_data *plat = dev->dev.platform_data; struct mmci_platform_data *plat = dev->dev.platform_data;
struct device_node *np = dev->dev.of_node;
struct variant_data *variant = id->data; struct variant_data *variant = id->data;
struct mmci_host *host; struct mmci_host *host;
struct mmc_host *mmc; struct mmc_host *mmc;
int ret; int ret;
/* must have platform data */ /* Must have platform data or Device Tree. */
if (!plat) { if (!plat && !np) {
ret = -EINVAL; dev_err(&dev->dev, "No plat data or DT found\n");
goto out; return -EINVAL;
} }
if (np)
mmci_dt_populate_generic_pdata(np, plat);
ret = amba_request_regions(dev, DRIVER_NAME); ret = amba_request_regions(dev, DRIVER_NAME);
if (ret) if (ret)
goto out; goto out;
......
...@@ -169,11 +169,11 @@ struct mmc_omap_host { ...@@ -169,11 +169,11 @@ struct mmc_omap_host {
struct timer_list clk_timer; struct timer_list clk_timer;
spinlock_t clk_lock; /* for changing enabled state */ spinlock_t clk_lock; /* for changing enabled state */
unsigned int fclk_enabled:1; unsigned int fclk_enabled:1;
struct workqueue_struct *mmc_omap_wq;
struct omap_mmc_platform_data *pdata; struct omap_mmc_platform_data *pdata;
}; };
static struct workqueue_struct *mmc_omap_wq;
static void mmc_omap_fclk_offdelay(struct mmc_omap_slot *slot) static void mmc_omap_fclk_offdelay(struct mmc_omap_slot *slot)
{ {
...@@ -291,7 +291,7 @@ static void mmc_omap_release_slot(struct mmc_omap_slot *slot, int clk_enabled) ...@@ -291,7 +291,7 @@ static void mmc_omap_release_slot(struct mmc_omap_slot *slot, int clk_enabled)
host->next_slot = new_slot; host->next_slot = new_slot;
host->mmc = new_slot->mmc; host->mmc = new_slot->mmc;
spin_unlock_irqrestore(&host->slot_lock, flags); spin_unlock_irqrestore(&host->slot_lock, flags);
queue_work(mmc_omap_wq, &host->slot_release_work); queue_work(host->mmc_omap_wq, &host->slot_release_work);
return; return;
} }
...@@ -459,7 +459,7 @@ mmc_omap_xfer_done(struct mmc_omap_host *host, struct mmc_data *data) ...@@ -459,7 +459,7 @@ mmc_omap_xfer_done(struct mmc_omap_host *host, struct mmc_data *data)
} }
host->stop_data = data; host->stop_data = data;
queue_work(mmc_omap_wq, &host->send_stop_work); queue_work(host->mmc_omap_wq, &host->send_stop_work);
} }
static void static void
...@@ -639,7 +639,7 @@ mmc_omap_cmd_timer(unsigned long data) ...@@ -639,7 +639,7 @@ mmc_omap_cmd_timer(unsigned long data)
OMAP_MMC_WRITE(host, IE, 0); OMAP_MMC_WRITE(host, IE, 0);
disable_irq(host->irq); disable_irq(host->irq);
host->abort = 1; host->abort = 1;
queue_work(mmc_omap_wq, &host->cmd_abort_work); queue_work(host->mmc_omap_wq, &host->cmd_abort_work);
} }
spin_unlock_irqrestore(&host->slot_lock, flags); spin_unlock_irqrestore(&host->slot_lock, flags);
} }
...@@ -828,7 +828,7 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id) ...@@ -828,7 +828,7 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
host->abort = 1; host->abort = 1;
OMAP_MMC_WRITE(host, IE, 0); OMAP_MMC_WRITE(host, IE, 0);
disable_irq_nosync(host->irq); disable_irq_nosync(host->irq);
queue_work(mmc_omap_wq, &host->cmd_abort_work); queue_work(host->mmc_omap_wq, &host->cmd_abort_work);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -1389,13 +1389,13 @@ static void mmc_omap_remove_slot(struct mmc_omap_slot *slot) ...@@ -1389,13 +1389,13 @@ static void mmc_omap_remove_slot(struct mmc_omap_slot *slot)
tasklet_kill(&slot->cover_tasklet); tasklet_kill(&slot->cover_tasklet);
del_timer_sync(&slot->cover_timer); del_timer_sync(&slot->cover_timer);
flush_workqueue(mmc_omap_wq); flush_workqueue(slot->host->mmc_omap_wq);
mmc_remove_host(mmc); mmc_remove_host(mmc);
mmc_free_host(mmc); mmc_free_host(mmc);
} }
static int __init mmc_omap_probe(struct platform_device *pdev) static int __devinit mmc_omap_probe(struct platform_device *pdev)
{ {
struct omap_mmc_platform_data *pdata = pdev->dev.platform_data; struct omap_mmc_platform_data *pdata = pdev->dev.platform_data;
struct mmc_omap_host *host = NULL; struct mmc_omap_host *host = NULL;
...@@ -1497,6 +1497,10 @@ static int __init mmc_omap_probe(struct platform_device *pdev) ...@@ -1497,6 +1497,10 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
host->reg_shift = (cpu_is_omap7xx() ? 1 : 2); 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_plat_cleanup: err_plat_cleanup:
...@@ -1518,7 +1522,7 @@ static int __init mmc_omap_probe(struct platform_device *pdev) ...@@ -1518,7 +1522,7 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
return ret; return ret;
} }
static int mmc_omap_remove(struct platform_device *pdev) static int __devexit mmc_omap_remove(struct platform_device *pdev)
{ {
struct mmc_omap_host *host = platform_get_drvdata(pdev); struct mmc_omap_host *host = platform_get_drvdata(pdev);
int i; int i;
...@@ -1542,6 +1546,7 @@ static int mmc_omap_remove(struct platform_device *pdev) ...@@ -1542,6 +1546,7 @@ static int mmc_omap_remove(struct platform_device *pdev)
iounmap(host->virt_base); iounmap(host->virt_base);
release_mem_region(pdev->resource[0].start, release_mem_region(pdev->resource[0].start,
pdev->resource[0].end - pdev->resource[0].start + 1); pdev->resource[0].end - pdev->resource[0].start + 1);
destroy_workqueue(host->mmc_omap_wq);
kfree(host); kfree(host);
...@@ -1599,7 +1604,8 @@ static int mmc_omap_resume(struct platform_device *pdev) ...@@ -1599,7 +1604,8 @@ static int mmc_omap_resume(struct platform_device *pdev)
#endif #endif
static struct platform_driver mmc_omap_driver = { static struct platform_driver mmc_omap_driver = {
.remove = mmc_omap_remove, .probe = mmc_omap_probe,
.remove = __devexit_p(mmc_omap_remove),
.suspend = mmc_omap_suspend, .suspend = mmc_omap_suspend,
.resume = mmc_omap_resume, .resume = mmc_omap_resume,
.driver = { .driver = {
...@@ -1608,29 +1614,7 @@ static struct platform_driver mmc_omap_driver = { ...@@ -1608,29 +1614,7 @@ static struct platform_driver mmc_omap_driver = {
}, },
}; };
static int __init mmc_omap_init(void) module_platform_driver(mmc_omap_driver);
{
int ret;
mmc_omap_wq = alloc_workqueue("mmc_omap", 0, 0);
if (!mmc_omap_wq)
return -ENOMEM;
ret = platform_driver_probe(&mmc_omap_driver, mmc_omap_probe);
if (ret)
destroy_workqueue(mmc_omap_wq);
return ret;
}
static void __exit mmc_omap_exit(void)
{
platform_driver_unregister(&mmc_omap_driver);
destroy_workqueue(mmc_omap_wq);
}
module_init(mmc_omap_init);
module_exit(mmc_omap_exit);
MODULE_DESCRIPTION("OMAP Multimedia Card driver"); MODULE_DESCRIPTION("OMAP Multimedia Card driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:" DRIVER_NAME); MODULE_ALIAS("platform:" DRIVER_NAME);
......
...@@ -85,12 +85,14 @@ ...@@ -85,12 +85,14 @@
#define BRR_ENABLE (1 << 5) #define BRR_ENABLE (1 << 5)
#define DTO_ENABLE (1 << 20) #define DTO_ENABLE (1 << 20)
#define INIT_STREAM (1 << 1) #define INIT_STREAM (1 << 1)
#define ACEN_ACMD12 (1 << 2)
#define DP_SELECT (1 << 21) #define DP_SELECT (1 << 21)
#define DDIR (1 << 4) #define DDIR (1 << 4)
#define DMA_EN 0x1 #define DMA_EN 0x1
#define MSBS (1 << 5) #define MSBS (1 << 5)
#define BCE (1 << 1) #define BCE (1 << 1)
#define FOUR_BIT (1 << 1) #define FOUR_BIT (1 << 1)
#define DDR (1 << 19)
#define DW8 (1 << 5) #define DW8 (1 << 5)
#define CC 0x1 #define CC 0x1
#define TC 0x02 #define TC 0x02
...@@ -115,6 +117,7 @@ ...@@ -115,6 +117,7 @@
#define OMAP_MMC_MAX_CLOCK 52000000 #define OMAP_MMC_MAX_CLOCK 52000000
#define DRIVER_NAME "omap_hsmmc" #define DRIVER_NAME "omap_hsmmc"
#define AUTO_CMD12 (1 << 0) /* Auto CMD12 support */
/* /*
* One controller can have multiple slots, like on some omap boards using * One controller can have multiple slots, like on some omap boards using
* omap.c controller driver. Luckily this is not currently done on any known * omap.c controller driver. Luckily this is not currently done on any known
...@@ -167,7 +170,6 @@ struct omap_hsmmc_host { ...@@ -167,7 +170,6 @@ struct omap_hsmmc_host {
int use_dma, dma_ch; int use_dma, dma_ch;
int dma_line_tx, dma_line_rx; int dma_line_tx, dma_line_rx;
int slot_id; int slot_id;
int got_dbclk;
int response_busy; int response_busy;
int context_loss; int context_loss;
int vdd; int vdd;
...@@ -175,6 +177,7 @@ struct omap_hsmmc_host { ...@@ -175,6 +177,7 @@ struct omap_hsmmc_host {
int reqs_blocked; int reqs_blocked;
int use_reg; int use_reg;
int req_in_progress; int req_in_progress;
unsigned int flags;
struct omap_hsmmc_next next_data; struct omap_hsmmc_next next_data;
struct omap_mmc_platform_data *pdata; struct omap_mmc_platform_data *pdata;
...@@ -520,6 +523,10 @@ static void omap_hsmmc_set_bus_width(struct omap_hsmmc_host *host) ...@@ -520,6 +523,10 @@ static void omap_hsmmc_set_bus_width(struct omap_hsmmc_host *host)
u32 con; u32 con;
con = OMAP_HSMMC_READ(host->base, CON); con = OMAP_HSMMC_READ(host->base, CON);
if (ios->timing == MMC_TIMING_UHS_DDR50)
con |= DDR; /* configure in DDR mode */
else
con &= ~DDR;
switch (ios->bus_width) { switch (ios->bus_width) {
case MMC_BUS_WIDTH_8: case MMC_BUS_WIDTH_8:
OMAP_HSMMC_WRITE(host->base, CON, con | DW8); OMAP_HSMMC_WRITE(host->base, CON, con | DW8);
...@@ -766,6 +773,8 @@ omap_hsmmc_start_command(struct omap_hsmmc_host *host, struct mmc_command *cmd, ...@@ -766,6 +773,8 @@ omap_hsmmc_start_command(struct omap_hsmmc_host *host, struct mmc_command *cmd,
cmdtype = 0x3; cmdtype = 0x3;
cmdreg = (cmd->opcode << 24) | (resptype << 16) | (cmdtype << 22); cmdreg = (cmd->opcode << 24) | (resptype << 16) | (cmdtype << 22);
if ((host->flags & AUTO_CMD12) && mmc_op_multi(cmd->opcode))
cmdreg |= ACEN_ACMD12;
if (data) { if (data) {
cmdreg |= DP_SELECT | MSBS | BCE; cmdreg |= DP_SELECT | MSBS | BCE;
...@@ -796,11 +805,12 @@ omap_hsmmc_get_dma_dir(struct omap_hsmmc_host *host, struct mmc_data *data) ...@@ -796,11 +805,12 @@ omap_hsmmc_get_dma_dir(struct omap_hsmmc_host *host, struct mmc_data *data)
static void omap_hsmmc_request_done(struct omap_hsmmc_host *host, struct mmc_request *mrq) static void omap_hsmmc_request_done(struct omap_hsmmc_host *host, struct mmc_request *mrq)
{ {
int dma_ch; int dma_ch;
unsigned long flags;
spin_lock(&host->irq_lock); spin_lock_irqsave(&host->irq_lock, flags);
host->req_in_progress = 0; host->req_in_progress = 0;
dma_ch = host->dma_ch; dma_ch = host->dma_ch;
spin_unlock(&host->irq_lock); spin_unlock_irqrestore(&host->irq_lock, flags);
omap_hsmmc_disable_irq(host); omap_hsmmc_disable_irq(host);
/* Do not complete the request if DMA is still in progress */ /* Do not complete the request if DMA is still in progress */
...@@ -837,11 +847,14 @@ omap_hsmmc_xfer_done(struct omap_hsmmc_host *host, struct mmc_data *data) ...@@ -837,11 +847,14 @@ omap_hsmmc_xfer_done(struct omap_hsmmc_host *host, struct mmc_data *data)
else else
data->bytes_xfered = 0; data->bytes_xfered = 0;
if (!data->stop) { if (data->stop && ((!(host->flags & AUTO_CMD12)) || data->error)) {
omap_hsmmc_start_command(host, data->stop, NULL);
} else {
if (data->stop)
data->stop->resp[0] = OMAP_HSMMC_READ(host->base,
RSP76);
omap_hsmmc_request_done(host, data->mrq); omap_hsmmc_request_done(host, data->mrq);
return;
} }
omap_hsmmc_start_command(host, data->stop, NULL);
} }
/* /*
...@@ -874,13 +887,14 @@ omap_hsmmc_cmd_done(struct omap_hsmmc_host *host, struct mmc_command *cmd) ...@@ -874,13 +887,14 @@ omap_hsmmc_cmd_done(struct omap_hsmmc_host *host, struct mmc_command *cmd)
static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno)
{ {
int dma_ch; int dma_ch;
unsigned long flags;
host->data->error = errno; host->data->error = errno;
spin_lock(&host->irq_lock); spin_lock_irqsave(&host->irq_lock, flags);
dma_ch = host->dma_ch; dma_ch = host->dma_ch;
host->dma_ch = -1; host->dma_ch = -1;
spin_unlock(&host->irq_lock); spin_unlock_irqrestore(&host->irq_lock, flags);
if (host->use_dma && dma_ch != -1) { if (host->use_dma && dma_ch != -1) {
dma_unmap_sg(mmc_dev(host->mmc), host->data->sg, dma_unmap_sg(mmc_dev(host->mmc), host->data->sg,
...@@ -1082,7 +1096,7 @@ static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd) ...@@ -1082,7 +1096,7 @@ static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd)
/* Disable the clocks */ /* Disable the clocks */
pm_runtime_put_sync(host->dev); pm_runtime_put_sync(host->dev);
if (host->got_dbclk) if (host->dbclk)
clk_disable(host->dbclk); clk_disable(host->dbclk);
/* Turn the power off */ /* Turn the power off */
...@@ -1093,7 +1107,7 @@ static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd) ...@@ -1093,7 +1107,7 @@ static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd)
ret = mmc_slot(host).set_power(host->dev, host->slot_id, 1, ret = mmc_slot(host).set_power(host->dev, host->slot_id, 1,
vdd); vdd);
pm_runtime_get_sync(host->dev); pm_runtime_get_sync(host->dev);
if (host->got_dbclk) if (host->dbclk)
clk_enable(host->dbclk); clk_enable(host->dbclk);
if (ret != 0) if (ret != 0)
...@@ -1234,6 +1248,7 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data) ...@@ -1234,6 +1248,7 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data)
struct omap_hsmmc_host *host = cb_data; struct omap_hsmmc_host *host = cb_data;
struct mmc_data *data; struct mmc_data *data;
int dma_ch, req_in_progress; int dma_ch, req_in_progress;
unsigned long flags;
if (!(ch_status & OMAP_DMA_BLOCK_IRQ)) { if (!(ch_status & OMAP_DMA_BLOCK_IRQ)) {
dev_warn(mmc_dev(host->mmc), "unexpected dma status %x\n", dev_warn(mmc_dev(host->mmc), "unexpected dma status %x\n",
...@@ -1241,9 +1256,9 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data) ...@@ -1241,9 +1256,9 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data)
return; return;
} }
spin_lock(&host->irq_lock); spin_lock_irqsave(&host->irq_lock, flags);
if (host->dma_ch < 0) { if (host->dma_ch < 0) {
spin_unlock(&host->irq_lock); spin_unlock_irqrestore(&host->irq_lock, flags);
return; return;
} }
...@@ -1253,7 +1268,7 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data) ...@@ -1253,7 +1268,7 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data)
/* Fire up the next transfer. */ /* Fire up the next transfer. */
omap_hsmmc_config_dma_params(host, data, omap_hsmmc_config_dma_params(host, data,
data->sg + host->dma_sg_idx); data->sg + host->dma_sg_idx);
spin_unlock(&host->irq_lock); spin_unlock_irqrestore(&host->irq_lock, flags);
return; return;
} }
...@@ -1264,7 +1279,7 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data) ...@@ -1264,7 +1279,7 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data)
req_in_progress = host->req_in_progress; req_in_progress = host->req_in_progress;
dma_ch = host->dma_ch; dma_ch = host->dma_ch;
host->dma_ch = -1; host->dma_ch = -1;
spin_unlock(&host->irq_lock); spin_unlock_irqrestore(&host->irq_lock, flags);
omap_free_dma(dma_ch); omap_free_dma(dma_ch);
...@@ -1844,6 +1859,7 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev) ...@@ -1844,6 +1859,7 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev)
host->mapbase = res->start + pdata->reg_offset; host->mapbase = res->start + pdata->reg_offset;
host->base = ioremap(host->mapbase, SZ_4K); host->base = ioremap(host->mapbase, SZ_4K);
host->power_mode = MMC_POWER_OFF; host->power_mode = MMC_POWER_OFF;
host->flags = AUTO_CMD12;
host->next_data.cookie = 1; host->next_data.cookie = 1;
platform_set_drvdata(pdev, host); platform_set_drvdata(pdev, host);
...@@ -1885,21 +1901,17 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev) ...@@ -1885,21 +1901,17 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev)
omap_hsmmc_context_save(host); omap_hsmmc_context_save(host);
if (cpu_is_omap2430()) {
host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck"); host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
/* /*
* MMC can still work without debounce clock. * MMC can still work without debounce clock.
*/ */
if (IS_ERR(host->dbclk)) if (IS_ERR(host->dbclk)) {
dev_warn(mmc_dev(host->mmc), dev_warn(mmc_dev(host->mmc), "Failed to get debounce clk\n");
"Failed to get debounce clock\n"); host->dbclk = NULL;
else } else if (clk_enable(host->dbclk) != 0) {
host->got_dbclk = 1; dev_warn(mmc_dev(host->mmc), "Failed to enable debounce clk\n");
clk_put(host->dbclk);
if (host->got_dbclk) host->dbclk = NULL;
if (clk_enable(host->dbclk) != 0)
dev_dbg(mmc_dev(host->mmc), "Enabling debounce"
" clk failed\n");
} }
/* Since we do only SG emulation, we can have as many segs /* Since we do only SG emulation, we can have as many segs
...@@ -1969,7 +1981,7 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev) ...@@ -1969,7 +1981,7 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev)
ret = request_threaded_irq(mmc_slot(host).card_detect_irq, ret = request_threaded_irq(mmc_slot(host).card_detect_irq,
NULL, NULL,
omap_hsmmc_detect, omap_hsmmc_detect,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
mmc_hostname(mmc), host); mmc_hostname(mmc), host);
if (ret) { if (ret) {
dev_dbg(mmc_dev(host->mmc), dev_dbg(mmc_dev(host->mmc),
...@@ -2019,7 +2031,7 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev) ...@@ -2019,7 +2031,7 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev)
pm_runtime_put_sync(host->dev); pm_runtime_put_sync(host->dev);
pm_runtime_disable(host->dev); pm_runtime_disable(host->dev);
clk_put(host->fclk); clk_put(host->fclk);
if (host->got_dbclk) { if (host->dbclk) {
clk_disable(host->dbclk); clk_disable(host->dbclk);
clk_put(host->dbclk); clk_put(host->dbclk);
} }
...@@ -2030,6 +2042,8 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev) ...@@ -2030,6 +2042,8 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev)
err_alloc: err_alloc:
omap_hsmmc_gpio_free(pdata); omap_hsmmc_gpio_free(pdata);
err: err:
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res)
release_mem_region(res->start, resource_size(res)); release_mem_region(res->start, resource_size(res));
return ret; return ret;
} }
...@@ -2052,7 +2066,7 @@ static int __devexit omap_hsmmc_remove(struct platform_device *pdev) ...@@ -2052,7 +2066,7 @@ static int __devexit omap_hsmmc_remove(struct platform_device *pdev)
pm_runtime_put_sync(host->dev); pm_runtime_put_sync(host->dev);
pm_runtime_disable(host->dev); pm_runtime_disable(host->dev);
clk_put(host->fclk); clk_put(host->fclk);
if (host->got_dbclk) { if (host->dbclk) {
clk_disable(host->dbclk); clk_disable(host->dbclk);
clk_put(host->dbclk); clk_put(host->dbclk);
} }
...@@ -2110,7 +2124,7 @@ static int omap_hsmmc_suspend(struct device *dev) ...@@ -2110,7 +2124,7 @@ static int omap_hsmmc_suspend(struct device *dev)
OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP); OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP);
} }
if (host->got_dbclk) if (host->dbclk)
clk_disable(host->dbclk); clk_disable(host->dbclk);
err: err:
pm_runtime_put_sync(host->dev); pm_runtime_put_sync(host->dev);
...@@ -2131,7 +2145,7 @@ static int omap_hsmmc_resume(struct device *dev) ...@@ -2131,7 +2145,7 @@ static int omap_hsmmc_resume(struct device *dev)
pm_runtime_get_sync(host->dev); pm_runtime_get_sync(host->dev);
if (host->got_dbclk) if (host->dbclk)
clk_enable(host->dbclk); clk_enable(host->dbclk);
if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER))
......
...@@ -75,8 +75,6 @@ static int __devinit sdhci_probe(struct platform_device *pdev) ...@@ -75,8 +75,6 @@ static int __devinit sdhci_probe(struct platform_device *pdev)
struct spear_sdhci *sdhci; struct spear_sdhci *sdhci;
int ret; int ret;
BUG_ON(pdev == NULL);
iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!iomem) { if (!iomem) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -84,18 +82,18 @@ static int __devinit sdhci_probe(struct platform_device *pdev) ...@@ -84,18 +82,18 @@ static int __devinit sdhci_probe(struct platform_device *pdev)
goto err; goto err;
} }
if (!request_mem_region(iomem->start, resource_size(iomem), if (!devm_request_mem_region(&pdev->dev, iomem->start,
"spear-sdhci")) { resource_size(iomem), "spear-sdhci")) {
ret = -EBUSY; ret = -EBUSY;
dev_dbg(&pdev->dev, "cannot request region\n"); dev_dbg(&pdev->dev, "cannot request region\n");
goto err; goto err;
} }
sdhci = kzalloc(sizeof(*sdhci), GFP_KERNEL); sdhci = devm_kzalloc(&pdev->dev, sizeof(*sdhci), GFP_KERNEL);
if (!sdhci) { if (!sdhci) {
ret = -ENOMEM; ret = -ENOMEM;
dev_dbg(&pdev->dev, "cannot allocate memory for sdhci\n"); dev_dbg(&pdev->dev, "cannot allocate memory for sdhci\n");
goto err_kzalloc; goto err;
} }
/* clk enable */ /* clk enable */
...@@ -103,13 +101,13 @@ static int __devinit sdhci_probe(struct platform_device *pdev) ...@@ -103,13 +101,13 @@ static int __devinit sdhci_probe(struct platform_device *pdev)
if (IS_ERR(sdhci->clk)) { if (IS_ERR(sdhci->clk)) {
ret = PTR_ERR(sdhci->clk); ret = PTR_ERR(sdhci->clk);
dev_dbg(&pdev->dev, "Error getting clock\n"); dev_dbg(&pdev->dev, "Error getting clock\n");
goto err_clk_get; goto err;
} }
ret = clk_enable(sdhci->clk); ret = clk_enable(sdhci->clk);
if (ret) { if (ret) {
dev_dbg(&pdev->dev, "Error enabling clock\n"); dev_dbg(&pdev->dev, "Error enabling clock\n");
goto err_clk_enb; goto put_clk;
} }
/* overwrite platform_data */ /* overwrite platform_data */
...@@ -124,7 +122,7 @@ static int __devinit sdhci_probe(struct platform_device *pdev) ...@@ -124,7 +122,7 @@ static int __devinit sdhci_probe(struct platform_device *pdev)
if (IS_ERR(host)) { if (IS_ERR(host)) {
ret = PTR_ERR(host); ret = PTR_ERR(host);
dev_dbg(&pdev->dev, "error allocating host\n"); dev_dbg(&pdev->dev, "error allocating host\n");
goto err_alloc_host; goto disable_clk;
} }
host->hw_name = "sdhci"; host->hw_name = "sdhci";
...@@ -132,17 +130,18 @@ static int __devinit sdhci_probe(struct platform_device *pdev) ...@@ -132,17 +130,18 @@ static int __devinit sdhci_probe(struct platform_device *pdev)
host->irq = platform_get_irq(pdev, 0); host->irq = platform_get_irq(pdev, 0);
host->quirks = SDHCI_QUIRK_BROKEN_ADMA; host->quirks = SDHCI_QUIRK_BROKEN_ADMA;
host->ioaddr = ioremap(iomem->start, resource_size(iomem)); host->ioaddr = devm_ioremap(&pdev->dev, iomem->start,
resource_size(iomem));
if (!host->ioaddr) { if (!host->ioaddr) {
ret = -ENOMEM; ret = -ENOMEM;
dev_dbg(&pdev->dev, "failed to remap registers\n"); dev_dbg(&pdev->dev, "failed to remap registers\n");
goto err_ioremap; goto free_host;
} }
ret = sdhci_add_host(host); ret = sdhci_add_host(host);
if (ret) { if (ret) {
dev_dbg(&pdev->dev, "error adding host\n"); dev_dbg(&pdev->dev, "error adding host\n");
goto err_add_host; goto free_host;
} }
platform_set_drvdata(pdev, host); platform_set_drvdata(pdev, host);
...@@ -161,11 +160,12 @@ static int __devinit sdhci_probe(struct platform_device *pdev) ...@@ -161,11 +160,12 @@ static int __devinit sdhci_probe(struct platform_device *pdev)
if (sdhci->data->card_power_gpio >= 0) { if (sdhci->data->card_power_gpio >= 0) {
int val = 0; int val = 0;
ret = gpio_request(sdhci->data->card_power_gpio, "sdhci"); ret = devm_gpio_request(&pdev->dev,
sdhci->data->card_power_gpio, "sdhci");
if (ret < 0) { if (ret < 0) {
dev_dbg(&pdev->dev, "gpio request fail: %d\n", dev_dbg(&pdev->dev, "gpio request fail: %d\n",
sdhci->data->card_power_gpio); sdhci->data->card_power_gpio);
goto err_pgpio_request; goto set_drvdata;
} }
if (sdhci->data->power_always_enb) if (sdhci->data->power_always_enb)
...@@ -177,60 +177,48 @@ static int __devinit sdhci_probe(struct platform_device *pdev) ...@@ -177,60 +177,48 @@ static int __devinit sdhci_probe(struct platform_device *pdev)
if (ret) { if (ret) {
dev_dbg(&pdev->dev, "gpio set direction fail: %d\n", dev_dbg(&pdev->dev, "gpio set direction fail: %d\n",
sdhci->data->card_power_gpio); sdhci->data->card_power_gpio);
goto err_pgpio_direction; goto set_drvdata;
} }
} }
if (sdhci->data->card_int_gpio >= 0) { if (sdhci->data->card_int_gpio >= 0) {
ret = gpio_request(sdhci->data->card_int_gpio, "sdhci"); ret = devm_gpio_request(&pdev->dev, sdhci->data->card_int_gpio,
"sdhci");
if (ret < 0) { if (ret < 0) {
dev_dbg(&pdev->dev, "gpio request fail: %d\n", dev_dbg(&pdev->dev, "gpio request fail: %d\n",
sdhci->data->card_int_gpio); sdhci->data->card_int_gpio);
goto err_igpio_request; goto set_drvdata;
} }
ret = gpio_direction_input(sdhci->data->card_int_gpio); ret = gpio_direction_input(sdhci->data->card_int_gpio);
if (ret) { if (ret) {
dev_dbg(&pdev->dev, "gpio set direction fail: %d\n", dev_dbg(&pdev->dev, "gpio set direction fail: %d\n",
sdhci->data->card_int_gpio); sdhci->data->card_int_gpio);
goto err_igpio_direction; goto set_drvdata;
} }
ret = request_irq(gpio_to_irq(sdhci->data->card_int_gpio), ret = devm_request_irq(&pdev->dev,
gpio_to_irq(sdhci->data->card_int_gpio),
sdhci_gpio_irq, IRQF_TRIGGER_LOW, sdhci_gpio_irq, IRQF_TRIGGER_LOW,
mmc_hostname(host->mmc), pdev); mmc_hostname(host->mmc), pdev);
if (ret) { if (ret) {
dev_dbg(&pdev->dev, "gpio request irq fail: %d\n", dev_dbg(&pdev->dev, "gpio request irq fail: %d\n",
sdhci->data->card_int_gpio); sdhci->data->card_int_gpio);
goto err_igpio_request_irq; goto set_drvdata;
} }
} }
return 0; return 0;
err_igpio_request_irq: set_drvdata:
err_igpio_direction:
if (sdhci->data->card_int_gpio >= 0)
gpio_free(sdhci->data->card_int_gpio);
err_igpio_request:
err_pgpio_direction:
if (sdhci->data->card_power_gpio >= 0)
gpio_free(sdhci->data->card_power_gpio);
err_pgpio_request:
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
sdhci_remove_host(host, 1); sdhci_remove_host(host, 1);
err_add_host: free_host:
iounmap(host->ioaddr);
err_ioremap:
sdhci_free_host(host); sdhci_free_host(host);
err_alloc_host: disable_clk:
clk_disable(sdhci->clk); clk_disable(sdhci->clk);
err_clk_enb: put_clk:
clk_put(sdhci->clk); clk_put(sdhci->clk);
err_clk_get:
kfree(sdhci);
err_kzalloc:
release_mem_region(iomem->start, resource_size(iomem));
err: err:
dev_err(&pdev->dev, "spear-sdhci probe failed: %d\n", ret); dev_err(&pdev->dev, "spear-sdhci probe failed: %d\n", ret);
return ret; return ret;
...@@ -239,35 +227,19 @@ static int __devinit sdhci_probe(struct platform_device *pdev) ...@@ -239,35 +227,19 @@ static int __devinit sdhci_probe(struct platform_device *pdev)
static int __devexit sdhci_remove(struct platform_device *pdev) static int __devexit sdhci_remove(struct platform_device *pdev)
{ {
struct sdhci_host *host = platform_get_drvdata(pdev); struct sdhci_host *host = platform_get_drvdata(pdev);
struct resource *iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
struct spear_sdhci *sdhci = dev_get_platdata(&pdev->dev); struct spear_sdhci *sdhci = dev_get_platdata(&pdev->dev);
int dead; int dead = 0;
u32 scratch; u32 scratch;
if (sdhci->data) {
if (sdhci->data->card_int_gpio >= 0) {
free_irq(gpio_to_irq(sdhci->data->card_int_gpio), pdev);
gpio_free(sdhci->data->card_int_gpio);
}
if (sdhci->data->card_power_gpio >= 0)
gpio_free(sdhci->data->card_power_gpio);
}
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
dead = 0;
scratch = readl(host->ioaddr + SDHCI_INT_STATUS); scratch = readl(host->ioaddr + SDHCI_INT_STATUS);
if (scratch == (u32)-1) if (scratch == (u32)-1)
dead = 1; dead = 1;
sdhci_remove_host(host, dead); sdhci_remove_host(host, dead);
iounmap(host->ioaddr);
sdhci_free_host(host); sdhci_free_host(host);
clk_disable(sdhci->clk); clk_disable(sdhci->clk);
clk_put(sdhci->clk); clk_put(sdhci->clk);
kfree(sdhci);
if (iomem)
release_mem_region(iomem->start, resource_size(iomem));
return 0; return 0;
} }
......
...@@ -32,8 +32,13 @@ ...@@ -32,8 +32,13 @@
#include "sdhci-pltfm.h" #include "sdhci-pltfm.h"
/* Tegra SDHOST controller vendor register definitions */
#define SDHCI_TEGRA_VENDOR_MISC_CTRL 0x120
#define SDHCI_MISC_CTRL_ENABLE_SDHCI_SPEC_300 0x20
#define NVQUIRK_FORCE_SDHCI_SPEC_200 BIT(0) #define NVQUIRK_FORCE_SDHCI_SPEC_200 BIT(0)
#define NVQUIRK_ENABLE_BLOCK_GAP_DET BIT(1) #define NVQUIRK_ENABLE_BLOCK_GAP_DET BIT(1)
#define NVQUIRK_ENABLE_SDHCI_SPEC_300 BIT(2)
struct sdhci_tegra_soc_data { struct sdhci_tegra_soc_data {
struct sdhci_pltfm_data *pdata; struct sdhci_pltfm_data *pdata;
...@@ -120,6 +125,25 @@ static irqreturn_t carddetect_irq(int irq, void *data) ...@@ -120,6 +125,25 @@ static irqreturn_t carddetect_irq(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
}; };
static void tegra_sdhci_reset_exit(struct sdhci_host *host, u8 mask)
{
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
struct sdhci_tegra *tegra_host = pltfm_host->priv;
const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data;
if (!(mask & SDHCI_RESET_ALL))
return;
/* Erratum: Enable SDHCI spec v3.00 support */
if (soc_data->nvquirks & NVQUIRK_ENABLE_SDHCI_SPEC_300) {
u32 misc_ctrl;
misc_ctrl = sdhci_readb(host, SDHCI_TEGRA_VENDOR_MISC_CTRL);
misc_ctrl |= SDHCI_MISC_CTRL_ENABLE_SDHCI_SPEC_300;
sdhci_writeb(host, misc_ctrl, SDHCI_TEGRA_VENDOR_MISC_CTRL);
}
}
static int tegra_sdhci_8bit(struct sdhci_host *host, int bus_width) static int tegra_sdhci_8bit(struct sdhci_host *host, int bus_width)
{ {
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
...@@ -148,6 +172,7 @@ static struct sdhci_ops tegra_sdhci_ops = { ...@@ -148,6 +172,7 @@ static struct sdhci_ops tegra_sdhci_ops = {
.read_w = tegra_sdhci_readw, .read_w = tegra_sdhci_readw,
.write_l = tegra_sdhci_writel, .write_l = tegra_sdhci_writel,
.platform_8bit_width = tegra_sdhci_8bit, .platform_8bit_width = tegra_sdhci_8bit,
.platform_reset_exit = tegra_sdhci_reset_exit,
}; };
#ifdef CONFIG_ARCH_TEGRA_2x_SOC #ifdef CONFIG_ARCH_TEGRA_2x_SOC
...@@ -178,6 +203,7 @@ static struct sdhci_pltfm_data sdhci_tegra30_pdata = { ...@@ -178,6 +203,7 @@ static struct sdhci_pltfm_data sdhci_tegra30_pdata = {
static struct sdhci_tegra_soc_data soc_data_tegra30 = { static struct sdhci_tegra_soc_data soc_data_tegra30 = {
.pdata = &sdhci_tegra30_pdata, .pdata = &sdhci_tegra30_pdata,
.nvquirks = NVQUIRK_ENABLE_SDHCI_SPEC_300,
}; };
#endif #endif
......
...@@ -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 requested for CMD%d!\n", pr_warning("%s: Too large timeout 0x%x requested for CMD%d!\n",
mmc_hostname(host->mmc), cmd->opcode); mmc_hostname(host->mmc), count, cmd->opcode);
count = 0xE; count = 0xE;
} }
......
...@@ -58,6 +58,10 @@ struct mmc_ext_csd { ...@@ -58,6 +58,10 @@ struct mmc_ext_csd {
unsigned int generic_cmd6_time; /* Units: 10ms */ unsigned int generic_cmd6_time; /* Units: 10ms */
unsigned int power_off_longtime; /* Units: ms */ unsigned int power_off_longtime; /* Units: ms */
unsigned int hs_max_dtr; unsigned int hs_max_dtr;
#define MMC_HIGH_26_MAX_DTR 26000000
#define MMC_HIGH_52_MAX_DTR 52000000
#define MMC_HIGH_DDR_MAX_DTR 52000000
#define MMC_HS200_MAX_DTR 200000000
unsigned int sectors; unsigned int sectors;
unsigned int card_type; unsigned int card_type;
unsigned int hc_erase_size; /* In sectors */ unsigned int hc_erase_size; /* In sectors */
......
...@@ -125,6 +125,7 @@ struct dw_mci { ...@@ -125,6 +125,7 @@ struct dw_mci {
struct mmc_request *mrq; struct mmc_request *mrq;
struct mmc_command *cmd; struct mmc_command *cmd;
struct mmc_data *data; struct mmc_data *data;
struct workqueue_struct *card_workqueue;
/* DMA interface members*/ /* DMA interface members*/
int use_dma; int use_dma;
......
...@@ -297,6 +297,7 @@ struct mmc_host { ...@@ -297,6 +297,7 @@ struct mmc_host {
unsigned int sdio_irqs; unsigned int sdio_irqs;
struct task_struct *sdio_irq_thread; struct task_struct *sdio_irq_thread;
bool sdio_irq_pending;
atomic_t sdio_irq_thread_abort; atomic_t sdio_irq_thread_abort;
mmc_pm_flag_t pm_flags; /* requested pm features */ mmc_pm_flag_t pm_flags; /* requested pm features */
...@@ -352,6 +353,7 @@ extern int mmc_cache_ctrl(struct mmc_host *, u8); ...@@ -352,6 +353,7 @@ extern int mmc_cache_ctrl(struct mmc_host *, u8);
static inline void mmc_signal_sdio_irq(struct mmc_host *host) static inline void mmc_signal_sdio_irq(struct mmc_host *host)
{ {
host->ops->enable_sdio_irq(host, 0); host->ops->enable_sdio_irq(host, 0);
host->sdio_irq_pending = true;
wake_up_process(host->sdio_irq_thread); wake_up_process(host->sdio_irq_thread);
} }
......
...@@ -354,66 +354,6 @@ struct _mmc_csd { ...@@ -354,66 +354,6 @@ struct _mmc_csd {
#define EXT_CSD_CARD_TYPE_SDR_1_2V (1<<5) /* Card can run at 200MHz */ #define EXT_CSD_CARD_TYPE_SDR_1_2V (1<<5) /* Card can run at 200MHz */
/* SDR mode @1.2V I/O */ /* SDR mode @1.2V I/O */
#define EXT_CSD_CARD_TYPE_SDR_200 (EXT_CSD_CARD_TYPE_SDR_1_8V | \
EXT_CSD_CARD_TYPE_SDR_1_2V)
#define EXT_CSD_CARD_TYPE_SDR_ALL (EXT_CSD_CARD_TYPE_SDR_200 | \
EXT_CSD_CARD_TYPE_52 | \
EXT_CSD_CARD_TYPE_26)
#define EXT_CSD_CARD_TYPE_SDR_1_2V_ALL (EXT_CSD_CARD_TYPE_SDR_1_2V | \
EXT_CSD_CARD_TYPE_52 | \
EXT_CSD_CARD_TYPE_26)
#define EXT_CSD_CARD_TYPE_SDR_1_8V_ALL (EXT_CSD_CARD_TYPE_SDR_1_8V | \
EXT_CSD_CARD_TYPE_52 | \
EXT_CSD_CARD_TYPE_26)
#define EXT_CSD_CARD_TYPE_SDR_1_2V_DDR_1_8V (EXT_CSD_CARD_TYPE_SDR_1_2V | \
EXT_CSD_CARD_TYPE_DDR_1_8V | \
EXT_CSD_CARD_TYPE_52 | \
EXT_CSD_CARD_TYPE_26)
#define EXT_CSD_CARD_TYPE_SDR_1_8V_DDR_1_8V (EXT_CSD_CARD_TYPE_SDR_1_8V | \
EXT_CSD_CARD_TYPE_DDR_1_8V | \
EXT_CSD_CARD_TYPE_52 | \
EXT_CSD_CARD_TYPE_26)
#define EXT_CSD_CARD_TYPE_SDR_1_2V_DDR_1_2V (EXT_CSD_CARD_TYPE_SDR_1_2V | \
EXT_CSD_CARD_TYPE_DDR_1_2V | \
EXT_CSD_CARD_TYPE_52 | \
EXT_CSD_CARD_TYPE_26)
#define EXT_CSD_CARD_TYPE_SDR_1_8V_DDR_1_2V (EXT_CSD_CARD_TYPE_SDR_1_8V | \
EXT_CSD_CARD_TYPE_DDR_1_2V | \
EXT_CSD_CARD_TYPE_52 | \
EXT_CSD_CARD_TYPE_26)
#define EXT_CSD_CARD_TYPE_SDR_1_2V_DDR_52 (EXT_CSD_CARD_TYPE_SDR_1_2V | \
EXT_CSD_CARD_TYPE_DDR_52 | \
EXT_CSD_CARD_TYPE_52 | \
EXT_CSD_CARD_TYPE_26)
#define EXT_CSD_CARD_TYPE_SDR_1_8V_DDR_52 (EXT_CSD_CARD_TYPE_SDR_1_8V | \
EXT_CSD_CARD_TYPE_DDR_52 | \
EXT_CSD_CARD_TYPE_52 | \
EXT_CSD_CARD_TYPE_26)
#define EXT_CSD_CARD_TYPE_SDR_ALL_DDR_1_8V (EXT_CSD_CARD_TYPE_SDR_200 | \
EXT_CSD_CARD_TYPE_DDR_1_8V | \
EXT_CSD_CARD_TYPE_52 | \
EXT_CSD_CARD_TYPE_26)
#define EXT_CSD_CARD_TYPE_SDR_ALL_DDR_1_2V (EXT_CSD_CARD_TYPE_SDR_200 | \
EXT_CSD_CARD_TYPE_DDR_1_2V | \
EXT_CSD_CARD_TYPE_52 | \
EXT_CSD_CARD_TYPE_26)
#define EXT_CSD_CARD_TYPE_SDR_ALL_DDR_52 (EXT_CSD_CARD_TYPE_SDR_200 | \
EXT_CSD_CARD_TYPE_DDR_52 | \
EXT_CSD_CARD_TYPE_52 | \
EXT_CSD_CARD_TYPE_26)
#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */ #define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */
#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */ #define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */
#define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */ #define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */
......
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