#if defined(CONFIG_DEBUG_FS)
static int dw_mci_req_show(struct seq_file *s, void *v)
{
- struct dw_mci_slot *slot = s->private;
+ struct dw_mci *host = s->private;
struct mmc_request *mrq;
struct mmc_command *cmd;
struct mmc_command *stop;
struct mmc_data *data;
/* Make sure we get a consistent snapshot */
- spin_lock_bh(&slot->host->lock);
- mrq = slot->host->mrq;
+ spin_lock_bh(&host->lock);
+ mrq = host->mrq;
if (mrq) {
cmd = mrq->cmd;
stop->resp[2], stop->error);
}
- spin_unlock_bh(&slot->host->lock);
+ spin_unlock_bh(&host->lock);
return 0;
}
}
DEFINE_SHOW_ATTRIBUTE(dw_mci_regs);
-static void dw_mci_init_debugfs(struct dw_mci_slot *slot)
+static void dw_mci_init_debugfs(struct dw_mci *host)
{
- struct dw_mci *host = slot->host;
struct mmc_host *mmc = host->mmc;
struct dentry *root;
return;
debugfs_create_file("regs", 0400, root, host, &dw_mci_regs_fops);
- debugfs_create_file("req", 0400, root, slot, &dw_mci_req_fops);
+ debugfs_create_file("req", 0400, root, host, &dw_mci_req_fops);
debugfs_create_u32("state", 0400, root, &host->state);
debugfs_create_xul("pending_events", 0400, root,
&host->pending_events);
}
}
-static void mci_send_cmd(struct dw_mci_slot *slot, u32 cmd, u32 arg)
+static void mci_send_cmd(struct dw_mci *host, u32 cmd, u32 arg)
{
- struct dw_mci *host = slot->host;
unsigned int cmd_status = 0;
mci_writel(host, CMDARG, arg);
static u32 dw_mci_prepare_command(struct mmc_host *mmc, struct mmc_command *cmd)
{
- struct dw_mci_slot *slot = mmc_priv(mmc);
- struct dw_mci *host = slot->host;
+ struct dw_mci *host = mmc_priv(mmc);
u32 cmdr;
cmd->error = -EINPROGRESS;
cmdr |= SDMMC_CMD_VOLT_SWITCH;
/* Change state to continue to handle CMD11 weirdness */
- WARN_ON(slot->host->state != STATE_SENDING_CMD);
- slot->host->state = STATE_SENDING_CMD11;
+ WARN_ON(host->state != STATE_SENDING_CMD);
+ host->state = STATE_SENDING_CMD11;
/*
* We need to disable low power mode (automatic clock stop)
clk_en_a = mci_readl(host, CLKENA);
clk_en_a &= ~SDMMC_CLKEN_LOW_PWR;
mci_writel(host, CLKENA, clk_en_a);
- mci_send_cmd(slot, SDMMC_CMD_UPD_CLK |
+ mci_send_cmd(host, SDMMC_CMD_UPD_CLK |
SDMMC_CMD_PRV_DAT_WAIT, 0);
}
static void dw_mci_pre_req(struct mmc_host *mmc,
struct mmc_request *mrq)
{
- struct dw_mci_slot *slot = mmc_priv(mmc);
+ struct dw_mci *host = mmc_priv(mmc);
struct mmc_data *data = mrq->data;
- if (!slot->host->use_dma || !data)
+ if (!host->use_dma || !data)
return;
/* This data might be unmapped at this time */
data->host_cookie = COOKIE_UNMAPPED;
- if (dw_mci_pre_dma_transfer(slot->host, mrq->data,
+ if (dw_mci_pre_dma_transfer(host, mrq->data,
COOKIE_PRE_MAPPED) < 0)
data->host_cookie = COOKIE_UNMAPPED;
}
struct mmc_request *mrq,
int err)
{
- struct dw_mci_slot *slot = mmc_priv(mmc);
+ struct dw_mci *host = mmc_priv(mmc);
struct mmc_data *data = mrq->data;
- if (!slot->host->use_dma || !data)
+ if (!host->use_dma || !data)
return;
if (data->host_cookie != COOKIE_UNMAPPED)
- dma_unmap_sg(slot->host->dev,
+ dma_unmap_sg(host->dev,
data->sg,
data->sg_len,
mmc_get_dma_dir(data));
static int dw_mci_get_cd(struct mmc_host *mmc)
{
int present;
- struct dw_mci_slot *slot = mmc_priv(mmc);
- struct dw_mci *host = slot->host;
+ struct dw_mci *host = mmc_priv(mmc);
int gpio_cd = mmc_gpio_get_cd(mmc);
/* Use platform get_cd function, else try onboard card detect */
} else if (gpio_cd >= 0)
present = gpio_cd;
else
- present = (mci_readl(slot->host, CDETECT) & BIT(0))
+ present = (mci_readl(host, CDETECT) & BIT(0))
== 0 ? 1 : 0;
spin_lock_bh(&host->lock);
}
}
-static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit)
+static void dw_mci_setup_bus(struct dw_mci *host, bool force_clkinit)
{
- struct dw_mci *host = slot->host;
unsigned int clock = host->clock;
u32 div;
u32 clk_en_a;
if (!clock) {
mci_writel(host, CLKENA, 0);
- mci_send_cmd(slot, sdmmc_cmd_bits, 0);
+ mci_send_cmd(host, sdmmc_cmd_bits, 0);
} else if (clock != host->current_speed || force_clkinit) {
div = host->bus_hz / clock;
if (host->bus_hz % clock && host->bus_hz > clock)
/* Silent the verbose log if calling from PM context */
if (!force_clkinit)
dev_info(&host->mmc->class_dev,
- "Bus speed = %dHz (slot req %dHz, actual %dHZ div = %d)\n",
+ "Bus speed = %dHz (req %dHz, actual %dHZ div = %d)\n",
host->bus_hz, clock,
div ? ((host->bus_hz / div) >> 1) :
host->bus_hz, div);
mci_writel(host, CLKSRC, 0);
/* inform CIU */
- mci_send_cmd(slot, sdmmc_cmd_bits, 0);
+ mci_send_cmd(host, sdmmc_cmd_bits, 0);
/* set clock to desired speed */
mci_writel(host, CLKDIV, div);
/* inform CIU */
- mci_send_cmd(slot, sdmmc_cmd_bits, 0);
+ mci_send_cmd(host, sdmmc_cmd_bits, 0);
/* enable clock; only low power if no SDIO */
clk_en_a = SDMMC_CLKEN_ENABLE;
mci_writel(host, CLKENA, clk_en_a);
/* inform CIU */
- mci_send_cmd(slot, sdmmc_cmd_bits, 0);
+ mci_send_cmd(host, sdmmc_cmd_bits, 0);
/* keep the last clock value that was requested from core */
host->clk_old = clock;
host->current_speed = clock;
- /* Set the current slot bus width */
+ /* Set the current bus width */
mci_writel(host, CTYPE, host->ctype);
}
}
static void __dw_mci_start_request(struct dw_mci *host,
- struct dw_mci_slot *slot,
struct mmc_command *cmd)
{
struct mmc_request *mrq;
host->stop_cmdr = dw_mci_prep_stop_abort(host, cmd);
}
-static void dw_mci_start_request(struct dw_mci *host,
- struct dw_mci_slot *slot)
+static void dw_mci_start_request(struct dw_mci *host)
{
struct mmc_request *mrq = host->mrq;
struct mmc_command *cmd;
cmd = mrq->sbc ? mrq->sbc : mrq->cmd;
- __dw_mci_start_request(host, slot, cmd);
+ __dw_mci_start_request(host, cmd);
}
/* must be called with host->lock held */
-static void dw_mci_queue_request(struct dw_mci *host, struct dw_mci_slot *slot,
- struct mmc_request *mrq)
+static void dw_mci_queue_request(struct dw_mci *host, struct mmc_request *mrq)
{
dev_vdbg(&host->mmc->class_dev, "queue request: state=%d\n",
host->state);
if (host->state == STATE_IDLE) {
host->state = STATE_SENDING_CMD;
- dw_mci_start_request(host, slot);
+ dw_mci_start_request(host);
}
}
static void dw_mci_request(struct mmc_host *mmc, struct mmc_request *mrq)
{
- struct dw_mci_slot *slot = mmc_priv(mmc);
- struct dw_mci *host = slot->host;
+ struct dw_mci *host = mmc_priv(mmc);
WARN_ON(host->mrq);
spin_lock_bh(&host->lock);
- dw_mci_queue_request(host, slot, mrq);
+ dw_mci_queue_request(host, mrq);
spin_unlock_bh(&host->lock);
}
static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
{
- struct dw_mci_slot *slot = mmc_priv(mmc);
- const struct dw_mci_drv_data *drv_data = slot->host->drv_data;
+ struct dw_mci *host = mmc_priv(mmc);
+ const struct dw_mci_drv_data *drv_data = host->drv_data;
u32 regs;
int ret;
switch (ios->bus_width) {
case MMC_BUS_WIDTH_4:
- slot->host->ctype = SDMMC_CTYPE_4BIT;
+ host->ctype = SDMMC_CTYPE_4BIT;
break;
case MMC_BUS_WIDTH_8:
- slot->host->ctype = SDMMC_CTYPE_8BIT;
+ host->ctype = SDMMC_CTYPE_8BIT;
break;
default:
/* set default 1 bit mode */
- slot->host->ctype = SDMMC_CTYPE_1BIT;
+ host->ctype = SDMMC_CTYPE_1BIT;
}
- regs = mci_readl(slot->host, UHS_REG);
+ regs = mci_readl(host, UHS_REG);
/* DDR mode set */
if (ios->timing == MMC_TIMING_MMC_DDR52 ||
else
regs &= ~BIT(16);
- mci_writel(slot->host, UHS_REG, regs);
- slot->host->timing = ios->timing;
+ mci_writel(host, UHS_REG, regs);
+ host->timing = ios->timing;
/*
* Use mirror of ios->clock to prevent race with mmc
* core ios update when finding the minimum.
*/
- slot->host->clock = ios->clock;
+ host->clock = ios->clock;
if (drv_data && drv_data->set_ios)
- drv_data->set_ios(slot->host, ios);
+ drv_data->set_ios(host, ios);
switch (ios->power_mode) {
case MMC_POWER_UP:
ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd);
if (ret) {
- dev_err(slot->host->dev, "failed to enable vmmc regulator\n");
+ dev_err(host->dev, "failed to enable vmmc regulator\n");
return;
}
- set_bit(DW_MMC_CARD_NEED_INIT, &slot->host->flags);
- regs = mci_readl(slot->host, PWREN);
+ set_bit(DW_MMC_CARD_NEED_INIT, &host->flags);
+ regs = mci_readl(host, PWREN);
regs |= BIT(0);
- mci_writel(slot->host, PWREN, regs);
+ mci_writel(host, PWREN, regs);
break;
case MMC_POWER_ON:
mmc_regulator_enable_vqmmc(mmc);
/* Adjust clock / bus width after power is up */
- dw_mci_setup_bus(slot, false);
+ dw_mci_setup_bus(host, false);
break;
case MMC_POWER_OFF:
/* Turn clock off before power goes down */
- dw_mci_setup_bus(slot, false);
+ dw_mci_setup_bus(host, false);
if (!IS_ERR(mmc->supply.vmmc))
mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
mmc_regulator_disable_vqmmc(mmc);
- regs = mci_readl(slot->host, PWREN);
+ regs = mci_readl(host, PWREN);
regs &= ~BIT(0);
- mci_writel(slot->host, PWREN, regs);
+ mci_writel(host, PWREN, regs);
/* Reset our state machine after powering off */
- dw_mci_ctrl_reset(slot->host, SDMMC_CTRL_ALL_RESET_FLAGS);
+ dw_mci_ctrl_reset(host, SDMMC_CTRL_ALL_RESET_FLAGS);
break;
default:
break;
}
- if (slot->host->state == STATE_WAITING_CMD11_DONE && ios->clock != 0)
- slot->host->state = STATE_IDLE;
+ if (host->state == STATE_WAITING_CMD11_DONE && ios->clock != 0)
+ host->state = STATE_IDLE;
}
static int dw_mci_card_busy(struct mmc_host *mmc)
{
- struct dw_mci_slot *slot = mmc_priv(mmc);
+ struct dw_mci *host = mmc_priv(mmc);
u32 status;
/*
* Check the busy bit which is low when DAT[3:0]
* (the data lines) are 0000
*/
- status = mci_readl(slot->host, STATUS);
+ status = mci_readl(host, STATUS);
return !!(status & SDMMC_STATUS_BUSY);
}
static int dw_mci_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
{
- struct dw_mci_slot *slot = mmc_priv(mmc);
- struct dw_mci *host = slot->host;
+ struct dw_mci *host = mmc_priv(mmc);
const struct dw_mci_drv_data *drv_data = host->drv_data;
u32 uhs;
u32 v18 = SDMMC_UHS_18V;
static int dw_mci_get_ro(struct mmc_host *mmc)
{
int read_only;
- struct dw_mci_slot *slot = mmc_priv(mmc);
+ struct dw_mci *host = mmc_priv(mmc);
int gpio_ro = mmc_gpio_get_ro(mmc);
/* Use platform get_ro function, else try on board write protect */
read_only = gpio_ro;
else
read_only =
- mci_readl(slot->host, WRTPRT) & BIT(0) ? 1 : 0;
+ mci_readl(host, WRTPRT) & BIT(0) ? 1 : 0;
dev_dbg(&mmc->class_dev, "card is %s\n",
read_only ? "read-only" : "read-write");
static void dw_mci_hw_reset(struct mmc_host *mmc)
{
- struct dw_mci_slot *slot = mmc_priv(mmc);
- struct dw_mci *host = slot->host;
+ struct dw_mci *host = mmc_priv(mmc);
const struct dw_mci_drv_data *drv_data = host->drv_data;
int reset;
usleep_range(200, 300);
}
-static void dw_mci_prepare_sdio_irq(struct dw_mci_slot *slot, bool prepare)
+static void dw_mci_prepare_sdio_irq(struct dw_mci *host, bool prepare)
{
- struct dw_mci *host = slot->host;
const u32 clken_low_pwr = SDMMC_CLKEN_LOW_PWR;
u32 clk_en_a_old;
u32 clk_en_a;
if (clk_en_a != clk_en_a_old) {
mci_writel(host, CLKENA, clk_en_a);
- mci_send_cmd(slot, SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT,
+ mci_send_cmd(host, SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT,
0);
}
}
-static void __dw_mci_enable_sdio_irq(struct dw_mci_slot *slot, int enb)
+static void __dw_mci_enable_sdio_irq(struct dw_mci *host, int enb)
{
- struct dw_mci *host = slot->host;
unsigned long irqflags;
u32 int_mask;
static void dw_mci_enable_sdio_irq(struct mmc_host *mmc, int enb)
{
- struct dw_mci_slot *slot = mmc_priv(mmc);
- struct dw_mci *host = slot->host;
+ struct dw_mci *host = mmc_priv(mmc);
- dw_mci_prepare_sdio_irq(slot, enb);
- __dw_mci_enable_sdio_irq(slot, enb);
+ dw_mci_prepare_sdio_irq(host, enb);
+ __dw_mci_enable_sdio_irq(host, enb);
/* Avoid runtime suspending the device when SDIO IRQ is enabled */
if (enb)
static void dw_mci_ack_sdio_irq(struct mmc_host *mmc)
{
- struct dw_mci_slot *slot = mmc_priv(mmc);
+ struct dw_mci *host = mmc_priv(mmc);
- __dw_mci_enable_sdio_irq(slot, 1);
+ __dw_mci_enable_sdio_irq(host, 1);
}
static int dw_mci_execute_tuning(struct mmc_host *mmc, u32 opcode)
{
- struct dw_mci_slot *slot = mmc_priv(mmc);
- struct dw_mci *host = slot->host;
+ struct dw_mci *host = mmc_priv(mmc);
const struct dw_mci_drv_data *drv_data = host->drv_data;
int err = -EINVAL;
static int dw_mci_prepare_hs400_tuning(struct mmc_host *mmc,
struct mmc_ios *ios)
{
- struct dw_mci_slot *slot = mmc_priv(mmc);
- struct dw_mci *host = slot->host;
+ struct dw_mci *host = mmc_priv(mmc);
const struct dw_mci_drv_data *drv_data = host->drv_data;
if (drv_data && drv_data->prepare_hs400_tuning)
ciu_out:
/* After a CTRL reset we need to have CIU set clock registers */
- mci_send_cmd(host->slot, SDMMC_CMD_UPD_CLK, 0);
+ mci_send_cmd(host, SDMMC_CMD_UPD_CLK, 0);
return ret;
}
set_bit(EVENT_CMD_COMPLETE, &host->completed_events);
err = dw_mci_command_complete(host, cmd);
if (cmd == mrq->sbc && !err) {
- __dw_mci_start_request(host, host->slot,
- mrq->cmd);
+ __dw_mci_start_request(host, mrq->cmd);
goto unlock;
}
{
struct dw_mci *host = dev_id;
u32 pending;
- struct dw_mci_slot *slot = host->slot;
pending = mci_readl(host, MINTSTS); /* read-only mask reg */
if (pending & SDMMC_INT_SDIO(host->sdio_irq)) {
mci_writel(host, RINTSTS,
SDMMC_INT_SDIO(host->sdio_irq));
- __dw_mci_enable_sdio_irq(slot, 0);
+ __dw_mci_enable_sdio_irq(host, 0);
sdio_signal_irq(host->mmc);
}
return IRQ_HANDLED;
}
-static int dw_mci_init_slot_caps(struct dw_mci_slot *slot)
+static int dw_mci_init_host_caps(struct dw_mci *host)
{
- struct dw_mci *host = slot->host;
const struct dw_mci_drv_data *drv_data = host->drv_data;
struct mmc_host *mmc = host->mmc;
int ctrl_id;
return 0;
}
-static int dw_mci_init_slot(struct dw_mci *host)
+static int dw_mci_init_host(struct dw_mci *host)
{
- struct mmc_host *mmc;
- struct dw_mci_slot *slot;
+ struct mmc_host *mmc = host->mmc;
int ret;
- mmc = devm_mmc_alloc_host(host->dev, sizeof(*slot));
- if (!mmc)
- return -ENOMEM;
-
- slot = mmc_priv(mmc);
- host->mmc = mmc;
- slot->host = host;
- host->slot = slot;
-
mmc->ops = &dw_mci_ops;
/*if there are external regulators, get them*/
if (ret)
return ret;
- ret = dw_mci_init_slot_caps(slot);
+ ret = dw_mci_init_host_caps(host);
if (ret)
return ret;
return ret;
#if defined(CONFIG_DEBUG_FS)
- dw_mci_init_debugfs(slot);
+ dw_mci_init_debugfs(host);
#endif
return 0;
}
-static void dw_mci_cleanup_slot(struct dw_mci_slot *slot)
+static void dw_mci_cleanup_host(struct dw_mci *host)
{
/* Debugfs stuff is cleaned up by mmc core */
- mmc_remove_host(slot->host->mmc);
- slot->host->slot = NULL;
+ mmc_remove_host(host->mmc);
}
static void dw_mci_init_dma(struct dw_mci *host)
u32 temp;
/*
- * No need for CD if all slots have a non-error GPIO
+ * No need for CD if host has a non-error GPIO
* as well as broken card detection is found.
*/
if (host->mmc->caps & MMC_CAP_NEEDS_POLL)
"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 */
- ret = dw_mci_init_slot(host);
+ ret = dw_mci_init_host(host);
if (ret) {
- dev_dbg(host->dev, "slot %d init failed\n", i);
+ dev_dbg(host->dev, "host init failed\n");
goto err_dmaunmap;
}
- /* Now that slots are all setup, we can enable card detect */
+ /* Now that host is setup, we can enable card detect */
dw_mci_enable_cd(host);
return 0;
void dw_mci_remove(struct dw_mci *host)
{
- dev_dbg(host->dev, "remove slot\n");
- if (host->slot)
- dw_mci_cleanup_slot(host->slot);
+ dev_dbg(host->dev, "remove host\n");
+ dw_mci_cleanup_host(host);
mci_writel(host, RINTSTS, 0xFFFFFFFF);
mci_writel(host, INTMASK, 0); /* disable all mmc interrupt first */
}
EXPORT_SYMBOL(dw_mci_remove);
-
-
#ifdef CONFIG_PM
int dw_mci_runtime_suspend(struct device *dev)
{
clk_disable_unprepare(host->ciu_clk);
- if (host->slot &&
- (mmc_host_can_gpio_cd(host->mmc) ||
- !mmc_card_is_removable(host->mmc)))
+ if (mmc_host_can_gpio_cd(host->mmc) ||
+ !mmc_card_is_removable(host->mmc))
clk_disable_unprepare(host->biu_clk);
return 0;
int ret = 0;
struct dw_mci *host = dev_get_drvdata(dev);
- if (host->slot &&
- (mmc_host_can_gpio_cd(host->mmc) ||
- !mmc_card_is_removable(host->mmc))) {
+ if (mmc_host_can_gpio_cd(host->mmc) ||
+ !mmc_card_is_removable(host->mmc)) {
ret = clk_prepare_enable(host->biu_clk);
if (ret)
return ret;
mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE);
- if (host->slot && host->mmc->pm_flags & MMC_PM_KEEP_POWER)
+ if (host->mmc->pm_flags & MMC_PM_KEEP_POWER)
dw_mci_set_ios(host->mmc, &host->mmc->ios);
/* Force setup bus to guarantee available clock output */
- dw_mci_setup_bus(host->slot, true);
+ dw_mci_setup_bus(host, true);
/* Re-enable SDIO interrupts. */
if (sdio_irq_claimed(host->mmc))
- __dw_mci_enable_sdio_irq(host->slot, 1);
+ __dw_mci_enable_sdio_irq(host, 1);
- /* Now that slots are all setup, we can enable card detect */
+ /* Now that host is setup, we can enable card detect */
dw_mci_enable_cd(host);
return 0;
err:
- if (host->slot &&
- (mmc_host_can_gpio_cd(host->mmc) ||
- !mmc_card_is_removable(host->mmc)))
+ if (mmc_host_can_gpio_cd(host->mmc) ||
+ !mmc_card_is_removable(host->mmc))
clk_disable_unprepare(host->biu_clk);
return ret;