aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2013-10-20 14:55:19 -0400
committerChris Ball <cjb@laptop.org>2013-10-30 20:26:18 -0400
commit0a82e06e6183a252608df48cc4793b83e2d73dfd (patch)
treedd9804fa2794955c3f1566a46a7ed99974b5c28d /drivers/mmc
parente002264f7e45d7661b237045577052fd0b40f89c (diff)
mmc: omap_hsmmc: context save and restore for DT
We want to get rid of the omap specific platform init code callbacks as they don't play nice with device tree. Convert the context loss check to be based on a register state detection instead. Cc: Andreas Fenkart <afenkart@gmail.com> Signed-off-by: Tony Lindgren <tony@atomide.com> [add check for CON and HCTL in context save and restore function] Signed-off-by: Balaji T K <balajitk@ti.com> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/omap_hsmmc.c52
1 files changed, 20 insertions, 32 deletions
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index f5de0b7052a5..53b53b581687 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -171,6 +171,10 @@ struct omap_hsmmc_host {
171 unsigned char bus_mode; 171 unsigned char bus_mode;
172 unsigned char power_mode; 172 unsigned char power_mode;
173 int suspended; 173 int suspended;
174 u32 con;
175 u32 hctl;
176 u32 sysctl;
177 u32 capa;
174 int irq; 178 int irq;
175 int use_dma, dma_ch; 179 int use_dma, dma_ch;
176 struct dma_chan *tx_chan; 180 struct dma_chan *tx_chan;
@@ -183,7 +187,6 @@ struct omap_hsmmc_host {
183 int use_reg; 187 int use_reg;
184 int req_in_progress; 188 int req_in_progress;
185 struct omap_hsmmc_next next_data; 189 struct omap_hsmmc_next next_data;
186
187 struct omap_mmc_platform_data *pdata; 190 struct omap_mmc_platform_data *pdata;
188}; 191};
189 192
@@ -597,25 +600,20 @@ static void omap_hsmmc_set_bus_mode(struct omap_hsmmc_host *host)
597static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host) 600static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host)
598{ 601{
599 struct mmc_ios *ios = &host->mmc->ios; 602 struct mmc_ios *ios = &host->mmc->ios;
600 struct omap_mmc_platform_data *pdata = host->pdata;
601 int context_loss = 0;
602 u32 hctl, capa; 603 u32 hctl, capa;
603 unsigned long timeout; 604 unsigned long timeout;
604 605
605 if (pdata->get_context_loss_count) {
606 context_loss = pdata->get_context_loss_count(host->dev);
607 if (context_loss < 0)
608 return 1;
609 }
610
611 dev_dbg(mmc_dev(host->mmc), "context was %slost\n",
612 context_loss == host->context_loss ? "not " : "");
613 if (host->context_loss == context_loss)
614 return 1;
615
616 if (!OMAP_HSMMC_READ(host->base, SYSSTATUS) & RESETDONE) 606 if (!OMAP_HSMMC_READ(host->base, SYSSTATUS) & RESETDONE)
617 return 1; 607 return 1;
618 608
609 if (host->con == OMAP_HSMMC_READ(host->base, CON) &&
610 host->hctl == OMAP_HSMMC_READ(host->base, HCTL) &&
611 host->sysctl == OMAP_HSMMC_READ(host->base, SYSCTL) &&
612 host->capa == OMAP_HSMMC_READ(host->base, CAPA))
613 return 0;
614
615 host->context_loss++;
616
619 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) { 617 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) {
620 if (host->power_mode != MMC_POWER_OFF && 618 if (host->power_mode != MMC_POWER_OFF &&
621 (1 << ios->vdd) <= MMC_VDD_23_24) 619 (1 << ios->vdd) <= MMC_VDD_23_24)
@@ -655,9 +653,8 @@ static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host)
655 omap_hsmmc_set_bus_mode(host); 653 omap_hsmmc_set_bus_mode(host);
656 654
657out: 655out:
658 host->context_loss = context_loss; 656 dev_dbg(mmc_dev(host->mmc), "context is restored: restore count %d\n",
659 657 host->context_loss);
660 dev_dbg(mmc_dev(host->mmc), "context is restored\n");
661 return 0; 658 return 0;
662} 659}
663 660
@@ -666,15 +663,10 @@ out:
666 */ 663 */
667static void omap_hsmmc_context_save(struct omap_hsmmc_host *host) 664static void omap_hsmmc_context_save(struct omap_hsmmc_host *host)
668{ 665{
669 struct omap_mmc_platform_data *pdata = host->pdata; 666 host->con = OMAP_HSMMC_READ(host->base, CON);
670 int context_loss; 667 host->hctl = OMAP_HSMMC_READ(host->base, HCTL);
671 668 host->sysctl = OMAP_HSMMC_READ(host->base, SYSCTL);
672 if (pdata->get_context_loss_count) { 669 host->capa = OMAP_HSMMC_READ(host->base, CAPA);
673 context_loss = pdata->get_context_loss_count(host->dev);
674 if (context_loss < 0)
675 return;
676 host->context_loss = context_loss;
677 }
678} 670}
679 671
680#else 672#else
@@ -1635,13 +1627,9 @@ static int omap_hsmmc_regs_show(struct seq_file *s, void *data)
1635{ 1627{
1636 struct mmc_host *mmc = s->private; 1628 struct mmc_host *mmc = s->private;
1637 struct omap_hsmmc_host *host = mmc_priv(mmc); 1629 struct omap_hsmmc_host *host = mmc_priv(mmc);
1638 int context_loss = 0;
1639
1640 if (host->pdata->get_context_loss_count)
1641 context_loss = host->pdata->get_context_loss_count(host->dev);
1642 1630
1643 seq_printf(s, "mmc%d:\n ctx_loss:\t%d:%d\n\nregs:\n", 1631 seq_printf(s, "mmc%d:\n ctx_loss:\t%d\n\nregs:\n",
1644 mmc->index, host->context_loss, context_loss); 1632 mmc->index, host->context_loss);
1645 1633
1646 if (host->suspended) { 1634 if (host->suspended) {
1647 seq_printf(s, "host suspended, can't read registers\n"); 1635 seq_printf(s, "host suspended, can't read registers\n");