mmc: omap_hsmmc: Fix pbias_disable for omap4
Subsystems (2)
PATCH 1/5 mmc: omap_hsmmc: Fix pbias_disable for omap4
pbias_disable is set to protect the mmc pbias i/o cells in DT boot by preventing voltage switch. Currently pbias_disable is enabled only for omap3 and not for omap4 due to reg_offset difference of 0x100. Enable pbias_disable for omap4+ too by using res->start which does not include the reg_offset.
--- drivers/mmc/host/omap_hsmmc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mmc/host/omap_hsmmc.c +1 -1
@@ -1876,7 +1876,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)omap_hsmmc_context_save (host);/* This can be removed once we support PBIAS with DT */ -if (host->dev->of_node && host->mapbase ==0x4809c000 ) +if (host->dev->of_node && res->start ==0x4809c000 ) host->pbias_disable =1 ; host->dbclk =clk_get (&pdev->dev,"mmchsdb_fck" );
Signature · 1 line
1.7.5.4
PATCH 2/5 mmc: omap_hsmmc: context save and restore for DT
From: Tony Lindgren <[email protected]>
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.
--- drivers/mmc/host/omap_hsmmc.c | 52 +++++++++++++++------------------------- 1 files changed, 20 insertions(+), 32 deletions(-)
drivers/mmc/host/omap_hsmmc.c +20 -32
@@ -171,6 +171,10 @@ struct omap_hsmmc_host {unsigned char bus_mode;unsigned char power_mode;int suspended; +u32 con; +u32 hctl; +u32 sysctl; +u32 capa;int irq;int use_dma, dma_ch;struct dma_chan *tx_chan;
@@ -183,7 +187,6 @@ struct omap_hsmmc_host {int use_reg;int req_in_progress;struct omap_hsmmc_next next_data; -struct omap_mmc_platform_data *pdata; };
@@ -597,25 +600,20 @@ static void omap_hsmmc_set_bus_mode(struct omap_hsmmc_host *host)static int omap_hsmmc_context_restore (struct omap_hsmmc_host *host) {struct mmc_ios *ios = &host->mmc->ios; -struct omap_mmc_platform_data *pdata = host->pdata; -int context_loss =0 ;u32 hctl, capa;unsigned long timeout; -if (pdata->get_context_loss_count) { - context_loss = pdata->get_context_loss_count (host->dev); -if (context_loss <0 ) -return 1 ; - } - -dev_dbg (mmc_dev (host->mmc),"context was %slost\n" , - context_loss == host->context_loss ?"not " :"" ); -if (host->context_loss == context_loss) -return 1 ; -if (!OMAP_HSMMC_READ (host->base,SYSSTATUS ) &RESETDONE )return 1 ; +if (host->con ==OMAP_HSMMC_READ (host->base,CON ) && + host->hctl ==OMAP_HSMMC_READ (host->base,HCTL ) && + host->sysctl ==OMAP_HSMMC_READ (host->base,SYSCTL ) && + host->capa ==OMAP_HSMMC_READ (host->base,CAPA )) +return 0 ; + + host->context_loss++; +if (host->pdata->controller_flags &OMAP_HSMMC_SUPPORTS_DUAL_VOLT ) {if (host->power_mode !=MMC_POWER_OFF && (1 << ios->vdd) <=MMC_VDD_23_24 )
@@ -655,9 +653,8 @@ static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host)omap_hsmmc_set_bus_mode (host); out: - host->context_loss = context_loss; - -dev_dbg (mmc_dev (host->mmc),"context is restored\n" ); +dev_dbg (mmc_dev (host->mmc),"context is restored: restore count %d\n" , + host->context_loss);return 0 ; }
@@ -666,15 +663,10 @@ out:*/ static void omap_hsmmc_context_save (struct omap_hsmmc_host *host) { -struct omap_mmc_platform_data *pdata = host->pdata; -int context_loss; - -if (pdata->get_context_loss_count) { - context_loss = pdata->get_context_loss_count (host->dev); -if (context_loss <0 ) -return ; - host->context_loss = context_loss; - } + host->con =OMAP_HSMMC_READ (host->base,CON ); + host->hctl =OMAP_HSMMC_READ (host->base,HCTL ); + host->sysctl =OMAP_HSMMC_READ (host->base,SYSCTL ); + host->capa =OMAP_HSMMC_READ (host->base,CAPA ); }#else
@@ -1635,13 +1627,9 @@ static int omap_hsmmc_regs_show(struct seq_file *s, void *data) {struct mmc_host *mmc = s->private;struct omap_hsmmc_host *host =mmc_priv (mmc); -int context_loss =0 ; - -if (host->pdata->get_context_loss_count) - context_loss = host->pdata->get_context_loss_count (host->dev); -seq_printf (s,"mmc%d:\n ctx_loss:\t%d:%d\n\nregs:\n" , - mmc->index, host->context_loss, context_loss); +seq_printf (s,"mmc%d:\n ctx_loss:\t%d\n\nregs:\n" , + mmc->index, host->context_loss);if (host->suspended) {seq_printf (s,"host suspended, can't read registers\n" );
Signature · 1 line
1.7.5.4
PATCH 3/5 mmc: omap_hsmmc: fix timeout for cmd and data soft reset
In reply to Balaji T KFrom: Jianpeng Ma <[email protected]>
With HSMMC_HAS_UPDATED_RESET reset of cmd/data (SRC/SRD) can be to quick and can be missed resulting in wait for software timeout. With cpu_relax timeout can be long and unpredictable. Use udelay instead for timeout implementation.
--- drivers/mmc/host/omap_hsmmc.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/mmc/host/omap_hsmmc.c +5 -5
@@ -119,7 +119,8 @@ BRR_EN | BWR_EN | TC_EN | CC_EN)#define MMC_AUTOSUSPEND_DELAY 100 -#define MMC_TIMEOUT_MS 20 +#define MMC_TIMEOUT_MS 20/* 20 mSec */ +#define MMC_TIMEOUT_US 20000/* 20000 micro Sec */ #define OMAP_MMC_MIN_CLOCK 400000#define OMAP_MMC_MAX_CLOCK 52000000#define DRIVER_NAME "omap_hsmmc"
@@ -967,8 +968,7 @@ static inline void omap_hsmmc_reset_controller_fsm(struct omap_hsmmc_host *host, unsigned long bit) {unsigned long i =0 ; -unsigned long limit = (loops_per_jiffy * -msecs_to_jiffies (MMC_TIMEOUT_MS )); +unsigned long limit =MMC_TIMEOUT_US ;OMAP_HSMMC_WRITE (host->base,SYSCTL ,OMAP_HSMMC_READ (host->base,SYSCTL ) | bit);
@@ -980,13 +980,13 @@ static inline void omap_hsmmc_reset_controller_fsm(struct omap_hsmmc_host *host,if (mmc_slot (host).features &HSMMC_HAS_UPDATED_RESET ) {while ((!(OMAP_HSMMC_READ (host->base,SYSCTL ) & bit)) && (i++ < limit)) -cpu_relax (); +udelay (1 ); } i =0 ;while ((OMAP_HSMMC_READ (host->base,SYSCTL ) & bit) && (i++ < limit)) -cpu_relax (); +udelay (1 );if (OMAP_HSMMC_READ (host->base,SYSCTL ) & bit) dev_err(mmc_dev(host->mmc),
Signature · 1 line
1.7.5.4
PATCH 4/5 mmc: omap_hsmmc: correct max value of clkd
In reply to Balaji T Kclock divisor can take a max value of 1023.
Update code so that card init can be handled at f_min even at higher IP clock frequencies from which clock to the card is derived.
--- drivers/mmc/host/omap_hsmmc.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/mmc/host/omap_hsmmc.c +3 -2
@@ -75,6 +75,7 @@#define ICE 0x1#define ICS 0x2#define CEN (1 << 2) +#define CLKD_MAX 0x3FF/* max clock divisor: 1023 */ #define CLKD_MASK 0x0000FFC0#define CLKD_SHIFT 6#define DTO_MASK 0x000F0000
@@ -497,8 +498,8 @@ static u16 calc_divisor(struct omap_hsmmc_host *host, struct mmc_ios *ios)if (ios->clock) { dsor =DIV_ROUND_UP (clk_get_rate (host->fclk), ios->clock); -if (dsor >250 ) - dsor =250 ; +if (dsor >CLKD_MAX ) + dsor =CLKD_MAX ; }return dsor;
Signature · 1 line
1.7.5.4
PATCH 5/5 mmc: omap_hsmmc: remove unused no_off
In reply to Balaji T KWith lazy disable gone, no_off is not used any more in omap_hsmmc
--- drivers/mmc/host/omap_hsmmc.c | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-)
drivers/mmc/host/omap_hsmmc.c +0 -7
@@ -1829,13 +1829,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev) mmc->ops = &omap_hsmmc_ops; -/* -* If regulator_disable can only put vcc_aux to sleep then there is -* no off state. -*/ -if (mmc_slot (host).vcc_aux_disable_is_sleep) -mmc_slot (host).no_off =1 ; - mmc->f_min =OMAP_MMC_MIN_CLOCK ;if (pdata->max_freq >0 )
Signature · 1 line
1.7.5.4
Hi Balaji,
Quoted 7 lines · Balaji T K
pbias_disableis set to protect the mmc pbias i/o cells in DT boot by preventing voltage switch. Currentlypbias_disableis enabled only for omap3 and not for omap4 due toreg_offsetdifference of0x100. Enablepbias_disablefor omap4+ too by usingres->startwhich does not include thereg_offset.Signed-off-by Balaji T K <[email protected]>
Thanks, all five patches in this series pushed to mmc-next for 3.13.
- Chris.
Signature · 1 line
Chris Ball <[email protected]> <http://printf.net/>