*/
#include <linux/module.h>
-#include <linux/dma-mapping.h>
-#include <linux/clk.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sd.h>
#include <linux/mmc/host.h>
#include <linux/spinlock.h>
#include <linux/workqueue.h>
#include <linux/crc7.h>
-
-#include <asm/dma.h>
-#include <asm/dma-mapping.h>
-#include <asm/io.h>
+#include <linux/scatterlist.h>
+#include <linux/io.h>
+#include <linux/mfd/glamo.h>
#include "glamo-mci.h"
#include "glamo-core.h"
{
unsigned long flags;
- spin_lock_irqsave(&host->pdata->pglamo->lock, flags);
+ spin_lock_irqsave(&host->pdata->core->lock, flags);
if (div < 0) {
/* stop clock - remove clock from divider input */
- writew(readw(host->pdata->pglamo->base +
+ writew(readw(host->pdata->core->base +
GLAMO_REG_CLOCK_GEN5_1) & (~GLAMO_CLOCK_GEN51_EN_DIV_TCLK),
- host->pdata->pglamo->base + GLAMO_REG_CLOCK_GEN5_1);
+ host->pdata->core->base + GLAMO_REG_CLOCK_GEN5_1);
} else {
if (host->force_slow_during_powerup)
div = host->clk_rate / sd_post_power_clock;
- else if (host->pdata->glamo_mci_use_slow &&
- host->pdata->glamo_mci_use_slow())
+ else if (host->pdata->glamo_mmc_use_slow &&
+ host->pdata->glamo_mmc_use_slow())
div = div * sd_slow_ratio;
if (div > 255)
* register shared with SCLK divisor -- no chance of race because
* we don't use sensor interface
*/
- writew((readw(host->pdata->pglamo->base +
+ writew((readw(host->pdata->core->base +
GLAMO_REG_CLOCK_GEN8) & 0xff00) | div,
- host->pdata->pglamo->base + GLAMO_REG_CLOCK_GEN8);
+ host->pdata->core->base + GLAMO_REG_CLOCK_GEN8);
/* enable clock to divider input */
- writew(readw(host->pdata->pglamo->base +
+ writew(readw(host->pdata->core->base +
GLAMO_REG_CLOCK_GEN5_1) | GLAMO_CLOCK_GEN51_EN_DIV_TCLK,
- host->pdata->pglamo->base + GLAMO_REG_CLOCK_GEN5_1);
- mdelay(5);
+ host->pdata->core->base + GLAMO_REG_CLOCK_GEN5_1);
}
- spin_unlock_irqrestore(&host->pdata->pglamo->lock, flags);
+ spin_unlock_irqrestore(&host->pdata->core->lock, flags);
+ mdelay(5);
}
static int glamo_mci_set_card_clock(struct glamo_mci_host *host, int freq)
struct mmc_command *cmd = mrq->cmd;
int timeout = 1000000;
- host->request_counter++;
+ host->request_counter++;
/* this guy has data to read/write? */
if (cmd->data) {
if(glamo_mci_prepare_pio(host, cmd->data)) {
* I'm afraid we have to spin on the IRQ status bit and "be
* our own INT# line"
*/
- if (!host->pdata->pglamo->irq_works) {
+ if (!host->pdata->core->irq_works) {
/*
* we have faith we will get an "interrupt"...
* but something insane like suspend problems can mean
* we spin here forever, so we timeout after a LONG time
*/
- while ((!(readw(host->pdata->pglamo->base +
+ while ((!(readw(host->pdata->core->base +
GLAMO_REG_IRQ_STATUS) & GLAMO_IRQ_MMC)) &&
(timeout--));
goto bail;
}
/* ack this interrupt source */
- writew(GLAMO_IRQ_MMC, host->pdata->pglamo->base +
+ writew(GLAMO_IRQ_MMC, host->pdata->core->base +
GLAMO_REG_IRQ_CLEAR);
/* yay we are an interrupt controller! -- call the ISR
*/
glamo_mci_irq(IRQ_GLAMO(GLAMO_IRQIDX_MMC), host);
}
- return;
+ return;
done:
host->mrq = NULL;
mmc_request_done(host->mmc, cmd->mrq);
struct glamo_mci_host *host = mmc_priv(mmc);
int bus_width = 0;
int powering = 0;
+ int ret;
if (host->suspending) {
dev_err(&host->pdev->dev, "IGNORING glamo_mci_set_ios while "
/* Set power */
switch(ios->power_mode) {
case MMC_POWER_UP:
- mmc_regulator_set_ocr(host->regulator, ios->vdd);
- host->vdd_current = ios->vdd;
+ ret = regulator_enable(host->regulator);
+ if (ret)
+ dev_err(&host->pdev->dev, "Failed to enable regulator: %d\n", ret);
break;
case MMC_POWER_ON:
/*
*/
host->force_slow_during_powerup = 1;
- if (host->vdd_current != ios->vdd) {
- mmc_regulator_set_ocr(host->regulator, ios->vdd);
- host->vdd_current = ios->vdd;
- }
if (host->power_mode_current == MMC_POWER_OFF) {
- glamo_engine_enable(host->pdata->pglamo,
+ glamo_engine_enable(host->pdata->core,
GLAMO_ENGINE_MMC);
powering = 1;
}
/* never want clocking with dead card */
glamo_mci_fix_card_div(host, -1);
- glamo_engine_disable(host->pdata->pglamo,
+ glamo_engine_disable(host->pdata->core,
GLAMO_ENGINE_MMC);
- mmc_regulator_set_ocr(host->regulator, 0);
- host->vdd_current = -1;
+ ret = regulator_disable(host->regulator);
+ if (ret)
+ dev_warn(&host->pdev->dev, "Failed to disable regulator: %d\n", ret);
break;
}
host->power_mode_current = ios->power_mode;
+ if (host->vdd_current != ios->vdd) {
+ ret = mmc_regulator_set_ocr(host->regulator, ios->vdd);
+ if (ret)
+ dev_err(&host->pdev->dev, "Failed to set regulator voltage: %d\n", ret);
+ else
+ host->vdd_current = ios->vdd;
+ }
glamo_mci_set_card_clock(host, ios->clock);
/* after power-up, we are meant to give it >= 74 clocks so it can
spin_lock_init(&host->lock);
INIT_WORK(&host->irq_work, glamo_mci_irq_worker);
- host->regulator = regulator_get(&pdev->dev, "SD_3V3");
+ host->regulator = regulator_get(pdev->dev.parent, "SD_3V3");
if (!host->regulator) {
dev_err(&pdev->dev, "Cannot proceed without regulator.\n");
ret = -ENODEV;
ret = request_irq(IRQ_GLAMO(GLAMO_IRQIDX_MMC), glamo_mci_irq, IRQF_SHARED,
pdev->name, host);
- if (ret) {
+ if (ret) {
dev_err(&pdev->dev, "failed to register irq.\n");
goto probe_iounmap_data;
}
- host->vdd_current = -1;
+ host->vdd_current = 0;
host->clk_rate = 50000000; /* really it's 49152000 */
host->clk_div = 16;
mmc->max_phys_segs = 128;
mmc->max_hw_segs = 128;
+ if (mmc->ocr_avail < 0) {
+ dev_warn(&pdev->dev, "Failed to get ocr list for regulator: %d.\n",
+ mmc->ocr_avail);
+ mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
+ }
+
platform_set_drvdata(pdev, mmc);
- glamo_engine_enable(host->pdata->pglamo, GLAMO_ENGINE_MMC);
- glamo_engine_reset(host->pdata->pglamo, GLAMO_ENGINE_MMC);
+ glamo_engine_enable(host->pdata->core, GLAMO_ENGINE_MMC);
+ glamo_engine_reset(host->pdata->core, GLAMO_ENGINE_MMC);
if ((ret = mmc_add_host(mmc))) {
dev_err(&pdev->dev, "failed to add mmc host.\n");
probe_freeirq:
free_irq(IRQ_GLAMO(GLAMO_IRQIDX_MMC), host);
probe_iounmap_data:
- iounmap(host->data_base);
+ iounmap(host->data_base);
probe_free_mem_region_data:
release_mem_region(host->data_mem->start, resource_size(host->data_mem));
probe_iounmap_mmio:
probe_free_mem_region_mmio:
release_mem_region(host->mmio_mem->start, resource_size(host->mmio_mem));
probe_regulator_put:
- regulator_put(host->regulator);
+ regulator_put(host->regulator);
probe_free_host:
mmc_free_host(mmc);
probe_out:
mmc_free_host(mmc);
- glamo_engine_disable(host->pdata->pglamo, GLAMO_ENGINE_MMC);
+ glamo_engine_disable(host->pdata->core, GLAMO_ENGINE_MMC);
return 0;
}
sd_idleclk = 1;
- glamo_engine_enable(host->pdata->pglamo, GLAMO_ENGINE_MMC);
- glamo_engine_reset(host->pdata->pglamo, GLAMO_ENGINE_MMC);
+ glamo_engine_enable(host->pdata->core, GLAMO_ENGINE_MMC);
+ glamo_engine_reset(host->pdata->core, GLAMO_ENGINE_MMC);
host->suspending--;