All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518.
@ 2012-08-07  3:10 Sonic Zhang
  2012-08-07  3:10 ` [PATCH 2/4] mmc: bfin_sdh: Port bf5xx SD host driver to support new RSI controller in bf60x Sonic Zhang
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Sonic Zhang @ 2012-08-07  3:10 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc, Bob Liu, uclinux-dist-devel, Sonic Zhang

From: Sonic Zhang <sonic.zhang@analog.com>

bf518 RSI dma doesn't work in array mode.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
 drivers/mmc/host/bfin_sdh.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/bfin_sdh.c b/drivers/mmc/host/bfin_sdh.c
index 0366617..fd25b0c 100644
--- a/drivers/mmc/host/bfin_sdh.c
+++ b/drivers/mmc/host/bfin_sdh.c
@@ -469,7 +469,11 @@ static int __devinit sdh_probe(struct platform_device *pdev)
 	}
 
 	mmc->ops = &sdh_ops;
+#if defined(CONFIG_BF54x)
 	mmc->max_segs = 32;
+#elif defined(CONFIG_BF51x)
+	mmc->max_segs = 1;
+#endif
 	mmc->max_seg_size = 1 << 16;
 	mmc->max_blk_size = 1 << 11;
 	mmc->max_blk_count = 1 << 11;
-- 
1.7.0.4



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/4] mmc: bfin_sdh: Port bf5xx SD host driver to support new RSI controller in bf60x.
  2012-08-07  3:10 [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518 Sonic Zhang
@ 2012-08-07  3:10 ` Sonic Zhang
  2012-08-08  4:15   ` Chris Ball
  2012-08-07  3:10 ` [PATCH 3/4] mmc: bfin_sdh: Remove redundent suspend and resume setting Sonic Zhang
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Sonic Zhang @ 2012-08-07  3:10 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc, Bob Liu, uclinux-dist-devel, Sonic Zhang

From: Sonic Zhang <sonic.zhang@analog.com>

In BF60x RSI controller:
1) MMR read/write width differs.
2) PWR and CTL MMRs are merged to together.
3) ROD and PD_DAT3 bit masks are obsolete.
4) New RSI block size MMR is defined.
5) The definition of DMA descriptor set size is changed.
6) set_ios should powers up controller in 2 steps.

In addition, this patch cleans up the spin locks.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
 drivers/mmc/host/bfin_sdh.c |  180 ++++++++++++++++++++++++++++++------------
 1 files changed, 128 insertions(+), 52 deletions(-)

diff --git a/drivers/mmc/host/bfin_sdh.c b/drivers/mmc/host/bfin_sdh.c
index fd25b0c..fa085a0 100644
--- a/drivers/mmc/host/bfin_sdh.c
+++ b/drivers/mmc/host/bfin_sdh.c
@@ -24,9 +24,7 @@
 #include <asm/portmux.h>
 #include <asm/bfin_sdh.h>
 
-#if defined(CONFIG_BF51x)
-#define bfin_read_SDH_PWR_CTL		bfin_read_RSI_PWR_CTL
-#define bfin_write_SDH_PWR_CTL		bfin_write_RSI_PWR_CTL
+#if defined(CONFIG_BF51x) || defined(__ADSPBF60x__)
 #define bfin_read_SDH_CLK_CTL		bfin_read_RSI_CLK_CTL
 #define bfin_write_SDH_CLK_CTL		bfin_write_RSI_CLK_CTL
 #define bfin_write_SDH_ARGUMENT		bfin_write_RSI_ARGUMENT
@@ -45,8 +43,16 @@
 #define bfin_write_SDH_E_STATUS		bfin_write_RSI_E_STATUS
 #define bfin_read_SDH_STATUS		bfin_read_RSI_STATUS
 #define bfin_write_SDH_MASK0		bfin_write_RSI_MASK0
+#define bfin_write_SDH_E_MASK		bfin_write_RSI_E_MASK
 #define bfin_read_SDH_CFG		bfin_read_RSI_CFG
 #define bfin_write_SDH_CFG		bfin_write_RSI_CFG
+# if defined(__ADSPBF60x__)
+#  define bfin_read_SDH_BLK_SIZE	bfin_read_RSI_BLKSZ
+#  define bfin_write_SDH_BLK_SIZE	bfin_write_RSI_BLKSZ
+# else
+#  define bfin_read_SDH_PWR_CTL		bfin_read_RSI_PWR_CTL
+#  define bfin_write_SDH_PWR_CTL	bfin_write_RSI_PWR_CTL
+# endif
 #endif
 
 struct dma_desc_array {
@@ -69,6 +75,7 @@ struct sdh_host {
 	dma_addr_t		sg_dma;
 	int			dma_len;
 
+	unsigned long		sclk;
 	unsigned int		imask;
 	unsigned int		power_mode;
 	unsigned int		clk_div;
@@ -134,11 +141,15 @@ static int sdh_setup_data(struct sdh_host *host, struct mmc_data *data)
 	/* Only supports power-of-2 block size */
 	if (data->blksz & (data->blksz - 1))
 		return -EINVAL;
+#ifndef RSI_BLKSZ
 	data_ctl |= ((ffs(data->blksz) - 1) << 4);
+#else
+        bfin_write_SDH_BLK_SIZE(data->blksz);
+#endif
 
 	bfin_write_SDH_DATA_CTL(data_ctl);
 	/* the time of a host clock period in ns */
-	cycle_ns = 1000000000 / (get_sclk() / (2 * (host->clk_div + 1)));
+	cycle_ns = 1000000000 / (host->sclk / (2 * (host->clk_div + 1)));
 	timeout = data->timeout_ns / cycle_ns;
 	timeout += data->timeout_clks;
 	bfin_write_SDH_DATA_TIMER(timeout);
@@ -152,8 +163,13 @@ static int sdh_setup_data(struct sdh_host *host, struct mmc_data *data)
 
 	sdh_enable_stat_irq(host, (DAT_CRC_FAIL | DAT_TIME_OUT | DAT_END));
 	host->dma_len = dma_map_sg(mmc_dev(host->mmc), data->sg, data->sg_len, host->dma_dir);
-#if defined(CONFIG_BF54x)
-	dma_cfg |= DMAFLOW_ARRAY | NDSIZE_5 | RESTART | WDSIZE_32 | DMAEN;
+#if defined(CONFIG_BF54x) || defined(CONFIG_BF60x)
+	dma_cfg |= DMAFLOW_ARRAY | RESTART | WDSIZE_32 | DMAEN;
+# ifdef RSI_BLKSZ
+	dma_cfg |= PSIZE_32 | NDSIZE_3;
+# else
+	dma_cfg |= NDSIZE_5;
+# endif
 	{
 		struct scatterlist *sg;
 		int i;
@@ -163,7 +179,7 @@ static int sdh_setup_data(struct sdh_host *host, struct mmc_data *data)
 			host->sg_cpu[i].x_count = sg_dma_len(sg) / 4;
 			host->sg_cpu[i].x_modify = 4;
 			dev_dbg(mmc_dev(host->mmc), "%d: start_addr:0x%lx, "
-				"cfg:0x%x, x_count:0x%x, x_modify:0x%x\n",
+				"cfg:0x%lx, x_count:0x%lx, x_modify:0x%lx\n",
 				i, host->sg_cpu[i].start_addr,
 				host->sg_cpu[i].cfg, host->sg_cpu[i].x_count,
 				host->sg_cpu[i].x_modify);
@@ -179,6 +195,7 @@ static int sdh_setup_data(struct sdh_host *host, struct mmc_data *data)
 	set_dma_curr_desc_addr(host->dma_ch, (unsigned long *)host->sg_dma);
 	set_dma_x_count(host->dma_ch, 0);
 	set_dma_x_modify(host->dma_ch, 0);
+	SSYNC();
 	set_dma_config(host->dma_ch, dma_cfg);
 #elif defined(CONFIG_BF51x)
 	/* RSI DMA doesn't work in array mode */
@@ -186,6 +203,7 @@ static int sdh_setup_data(struct sdh_host *host, struct mmc_data *data)
 	set_dma_start_addr(host->dma_ch, sg_dma_address(&data->sg[0]));
 	set_dma_x_count(host->dma_ch, length / 4);
 	set_dma_x_modify(host->dma_ch, 4);
+	SSYNC();
 	set_dma_config(host->dma_ch, dma_cfg);
 #endif
 	bfin_write_SDH_DATA_CTL(bfin_read_SDH_DATA_CTL() | DTX_DMA_E | DTX_E);
@@ -303,7 +321,6 @@ static int sdh_data_done(struct sdh_host *host, unsigned int stat)
 	else
 		data->bytes_xfered = 0;
 
-	sdh_disable_stat_irq(host, DAT_END | DAT_TIME_OUT | DAT_CRC_FAIL | RX_OVERRUN | TX_UNDERRUN);
 	bfin_write_SDH_STATUS_CLR(DAT_END_STAT | DAT_TIMEOUT_STAT | \
 			DAT_CRC_FAIL_STAT | DAT_BLK_END_STAT | RX_OVERRUN | TX_UNDERRUN);
 	bfin_write_SDH_DATA_CTL(0);
@@ -328,74 +345,115 @@ static void sdh_request(struct mmc_host *mmc, struct mmc_request *mrq)
 	dev_dbg(mmc_dev(host->mmc), "%s enter, mrp:%p, cmd:%p\n", __func__, mrq, mrq->cmd);
 	WARN_ON(host->mrq != NULL);
 
+	spin_lock(&host->lock);
 	host->mrq = mrq;
 	host->data = mrq->data;
 
 	if (mrq->data && mrq->data->flags & MMC_DATA_READ) {
 		ret = sdh_setup_data(host, mrq->data);
 		if (ret)
-			return;
+			goto data_err;
 	}
 
 	sdh_start_cmd(host, mrq->cmd);
+data_err:
+	spin_unlock(&host->lock);
 }
 
 static void sdh_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 {
 	struct sdh_host *host;
-	unsigned long flags;
 	u16 clk_ctl = 0;
+#ifndef RSI_BLKSZ
 	u16 pwr_ctl = 0;
+#endif
 	u16 cfg;
 	host = mmc_priv(mmc);
 
-	spin_lock_irqsave(&host->lock, flags);
-	if (ios->clock) {
-		unsigned long  sys_clk, ios_clk;
-		unsigned char clk_div;
-		ios_clk = 2 * ios->clock;
-		sys_clk = get_sclk();
-		clk_div = sys_clk / ios_clk;
-		if (sys_clk % ios_clk == 0)
-			clk_div -= 1;
-		clk_div = min_t(unsigned char, clk_div, 0xFF);
-		clk_ctl |= clk_div;
-		clk_ctl |= CLK_E;
-		host->clk_div = clk_div;
-	} else
-		sdh_stop_clock(host);
-
-	if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
-#ifdef CONFIG_SDH_BFIN_MISSING_CMD_PULLUP_WORKAROUND
-		pwr_ctl |= ROD_CTL;
-#else
-		pwr_ctl |= SD_CMD_OD | ROD_CTL;
-#endif
+	spin_lock(&host->lock);
 
-	if (ios->bus_width == MMC_BUS_WIDTH_4) {
-		cfg = bfin_read_SDH_CFG();
+	cfg = bfin_read_SDH_CFG();
+	cfg |= MWE;
+	switch (ios->bus_width) {
+	case MMC_BUS_WIDTH_4:
+#ifndef RSI_BLKSZ
 		cfg &= ~PD_SDDAT3;
+#endif
 		cfg |= PUP_SDDAT3;
 		/* Enable 4 bit SDIO */
-		cfg |= (SD4E | MWE);
-		bfin_write_SDH_CFG(cfg);
-		clk_ctl |= WIDE_BUS;
-	} else {
-		cfg = bfin_read_SDH_CFG();
-		cfg |= MWE;
-		bfin_write_SDH_CFG(cfg);
+		cfg |= SD4E;
+		clk_ctl |= WIDE_BUS_4;
+		break;
+	case MMC_BUS_WIDTH_8:
+#ifndef RSI_BLKSZ
+		cfg &= ~PD_SDDAT3;
+#endif
+		cfg |= PUP_SDDAT3;
+		/* Disable 4 bit SDIO */
+		cfg &= ~SD4E;
+		clk_ctl |= BYTE_BUS_8;
+		break;
+	default:
+		cfg &= ~PUP_SDDAT3;
+		/* Disable 4 bit SDIO */
+		cfg &= ~SD4E;
 	}
 
-	bfin_write_SDH_CLK_CTL(clk_ctl);
-
 	host->power_mode = ios->power_mode;
-	if (ios->power_mode == MMC_POWER_ON)
+#ifndef RSI_BLKSZ
+	if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) {
+		pwr_ctl |= ROD_CTL;
+# ifndef CONFIG_SDH_BFIN_MISSING_CMD_PULLUP_WORKAROUND
+		pwr_ctl |= SD_CMD_OD;
+# endif
+	}
+
+	if (ios->power_mode != MMC_POWER_OFF)
 		pwr_ctl |= PWR_ON;
+	else
+		pwr_ctl &= ~PWR_ON;
 
 	bfin_write_SDH_PWR_CTL(pwr_ctl);
+#else
+# ifndef CONFIG_SDH_BFIN_MISSING_CMD_PULLUP_WORKAROUND
+	if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
+		cfg |= SD_CMD_OD;
+	else
+		cfg &= ~SD_CMD_OD;
+# endif
+
+
+	if (ios->power_mode != MMC_POWER_OFF)
+		cfg |= PWR_ON;
+	else
+		cfg &= ~PWR_ON;
+
+	bfin_write_SDH_CFG(cfg);
+#endif
 	SSYNC();
 
-	spin_unlock_irqrestore(&host->lock, flags);
+	if (ios->power_mode == MMC_POWER_ON && ios->clock) {
+		unsigned char clk_div;
+		clk_div = (get_sclk() / ios->clock - 1) / 2;
+		clk_div = min_t(unsigned char, clk_div, 0xFF);
+		clk_ctl |= clk_div;
+		clk_ctl |= CLK_E;
+		host->clk_div = clk_div;
+		bfin_write_SDH_CLK_CTL(clk_ctl);
+
+	} else
+		sdh_stop_clock(host);
+
+	/* set up sdh interrupt mask*/
+	if (ios->power_mode == MMC_POWER_ON)
+		bfin_write_SDH_MASK0(DAT_END | DAT_TIME_OUT | DAT_CRC_FAIL |
+			RX_OVERRUN | TX_UNDERRUN | CMD_SENT | CMD_RESP_END |
+			CMD_TIME_OUT | CMD_CRC_FAIL);
+	else
+		bfin_write_SDH_MASK0(0);
+	SSYNC();
+
+	spin_unlock(&host->lock);
 
 	dev_dbg(mmc_dev(host->mmc), "SDH: clk_div = 0x%x actual clock:%ld expected clock:%d\n",
 		host->clk_div,
@@ -412,7 +470,7 @@ static irqreturn_t sdh_dma_irq(int irq, void *devid)
 {
 	struct sdh_host *host = devid;
 
-	dev_dbg(mmc_dev(host->mmc), "%s enter, irq_stat: 0x%04x\n", __func__,
+	dev_dbg(mmc_dev(host->mmc), "%s enter, irq_stat: 0x%04lx\n", __func__,
 		get_dma_curr_irqstat(host->dma_ch));
 	clear_dma_irqstat(host->dma_ch);
 	SSYNC();
@@ -427,6 +485,9 @@ static irqreturn_t sdh_stat_irq(int irq, void *devid)
 	int handled = 0;
 
 	dev_dbg(mmc_dev(host->mmc), "%s enter\n", __func__);
+
+	spin_lock(&host->lock);
+
 	status = bfin_read_SDH_E_STATUS();
 	if (status & SD_CARD_DET) {
 		mmc_detect_change(host->mmc, 0);
@@ -444,6 +505,8 @@ static irqreturn_t sdh_stat_irq(int irq, void *devid)
 	if (status & (DAT_END | DAT_TIME_OUT | DAT_CRC_FAIL | RX_OVERRUN | TX_UNDERRUN))
 		handled |= sdh_data_done(host, status);
 
+	spin_unlock(&host->lock);
+
 	dev_dbg(mmc_dev(host->mmc), "%s exit\n\n", __func__);
 
 	return IRQ_RETVAL(handled);
@@ -469,12 +532,16 @@ static int __devinit sdh_probe(struct platform_device *pdev)
 	}
 
 	mmc->ops = &sdh_ops;
-#if defined(CONFIG_BF54x)
-	mmc->max_segs = 32;
-#elif defined(CONFIG_BF51x)
+#if defined(CONFIG_BF51x)
 	mmc->max_segs = 1;
+#else
+	mmc->max_segs = PAGE_SIZE / sizeof(struct dma_desc_array);
 #endif
+#ifdef RSI_BLKSZ
+	mmc->max_seg_size = -1;
+#else
 	mmc->max_seg_size = 1 << 16;
+#endif
 	mmc->max_blk_size = 1 << 11;
 	mmc->max_blk_count = 1 << 11;
 	mmc->max_req_size = PAGE_SIZE;
@@ -484,6 +551,7 @@ static int __devinit sdh_probe(struct platform_device *pdev)
 	mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_NEEDS_POLL;
 	host = mmc_priv(mmc);
 	host->mmc = mmc;
+	host->sclk = get_sclk();
 
 	spin_lock_init(&host->lock);
 	host->irq = drv_data->irq_int0;
@@ -508,7 +576,6 @@ static int __devinit sdh_probe(struct platform_device *pdev)
 	}
 
 	platform_set_drvdata(pdev, mmc);
-	mmc_add_host(mmc);
 
 	ret = request_irq(host->irq, sdh_stat_irq, 0, "SDH Status IRQ", host);
 	if (ret) {
@@ -529,12 +596,13 @@ static int __devinit sdh_probe(struct platform_device *pdev)
 	bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN);
 	SSYNC();
 
-	/* Disable card inserting detection pin. set MMC_CAP_NEES_POLL, and
+	/* Disable card inserting detection pin. set MMC_CAP_NEEDS_POLL, and
 	 * mmc stack will do the detection.
 	 */
 	bfin_write_SDH_CFG((bfin_read_SDH_CFG() & 0x1F) | (PUP_SDDAT | PUP_SDDAT3));
 	SSYNC();
 
+	mmc_add_host(mmc);
 	return 0;
 
 out4:
@@ -582,7 +650,11 @@ static int sdh_suspend(struct platform_device *dev, pm_message_t state)
 	if (mmc)
 		ret = mmc_suspend_host(mmc);
 
+#ifndef RSI_BLKSZ
 	bfin_write_SDH_PWR_CTL(bfin_read_SDH_PWR_CTL() & ~PWR_ON);
+#else
+	bfin_write_SDH_CFG(bfin_read_SDH_CFG() & ~PWR_ON);
+#endif
 	peripheral_free_list(drv_data->pin_req);
 
 	return ret;
@@ -600,12 +672,16 @@ static int sdh_resume(struct platform_device *dev)
 		return ret;
 	}
 
-	bfin_write_SDH_PWR_CTL(bfin_read_SDH_PWR_CTL() | PWR_ON);
 #if defined(CONFIG_BF54x)
 	/* Secure Digital Host shares DMA with Nand controller */
 	bfin_write_DMAC1_PERIMUX(bfin_read_DMAC1_PERIMUX() | 0x1);
 #endif
+#ifndef RSI_BLKSZ
+	bfin_write_SDH_PWR_CTL(bfin_read_SDH_PWR_CTL() | PWR_ON);
 	bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN);
+#else
+	bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN | PWR_ON);
+#endif
 	SSYNC();
 
 	bfin_write_SDH_CFG((bfin_read_SDH_CFG() & 0x1F) | (PUP_SDDAT | PUP_SDDAT3));
-- 
1.7.0.4



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/4] mmc: bfin_sdh: Remove redundent suspend and resume setting.
  2012-08-07  3:10 [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518 Sonic Zhang
  2012-08-07  3:10 ` [PATCH 2/4] mmc: bfin_sdh: Port bf5xx SD host driver to support new RSI controller in bf60x Sonic Zhang
@ 2012-08-07  3:10 ` Sonic Zhang
  2012-08-08  4:20   ` Chris Ball
  2012-08-07  3:10 ` [PATCH 4/4] mmc: bfin_sdh: Reset SD controller when resume from power saving mode Sonic Zhang
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Sonic Zhang @ 2012-08-07  3:10 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc, Bob Liu, uclinux-dist-devel, Sonic Zhang, Bob Liu

From: Sonic Zhang <sonic.zhang@analog.com>

mmc core suspend and resume functions had already called sdh_set_ios with proper flags.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Bob Liu <lliubbo@gmail.com>
---
 drivers/mmc/host/bfin_sdh.c |   15 ---------------
 1 files changed, 0 insertions(+), 15 deletions(-)

diff --git a/drivers/mmc/host/bfin_sdh.c b/drivers/mmc/host/bfin_sdh.c
index fa085a0..57b7548 100644
--- a/drivers/mmc/host/bfin_sdh.c
+++ b/drivers/mmc/host/bfin_sdh.c
@@ -650,11 +650,6 @@ static int sdh_suspend(struct platform_device *dev, pm_message_t state)
 	if (mmc)
 		ret = mmc_suspend_host(mmc);
 
-#ifndef RSI_BLKSZ
-	bfin_write_SDH_PWR_CTL(bfin_read_SDH_PWR_CTL() & ~PWR_ON);
-#else
-	bfin_write_SDH_CFG(bfin_read_SDH_CFG() & ~PWR_ON);
-#endif
 	peripheral_free_list(drv_data->pin_req);
 
 	return ret;
@@ -676,16 +671,6 @@ static int sdh_resume(struct platform_device *dev)
 	/* Secure Digital Host shares DMA with Nand controller */
 	bfin_write_DMAC1_PERIMUX(bfin_read_DMAC1_PERIMUX() | 0x1);
 #endif
-#ifndef RSI_BLKSZ
-	bfin_write_SDH_PWR_CTL(bfin_read_SDH_PWR_CTL() | PWR_ON);
-	bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN);
-#else
-	bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN | PWR_ON);
-#endif
-	SSYNC();
-
-	bfin_write_SDH_CFG((bfin_read_SDH_CFG() & 0x1F) | (PUP_SDDAT | PUP_SDDAT3));
-	SSYNC();
 
 	if (mmc)
 		ret = mmc_resume_host(mmc);
-- 
1.7.0.4



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/4] mmc: bfin_sdh: Reset SD controller when resume from power saving mode.
  2012-08-07  3:10 [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518 Sonic Zhang
  2012-08-07  3:10 ` [PATCH 2/4] mmc: bfin_sdh: Port bf5xx SD host driver to support new RSI controller in bf60x Sonic Zhang
  2012-08-07  3:10 ` [PATCH 3/4] mmc: bfin_sdh: Remove redundent suspend and resume setting Sonic Zhang
@ 2012-08-07  3:10 ` Sonic Zhang
  2012-08-08  4:20   ` Chris Ball
  2012-08-08  3:23 ` [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518 Sonic Zhang
  2012-08-08  4:11 ` Chris Ball
  4 siblings, 1 reply; 14+ messages in thread
From: Sonic Zhang @ 2012-08-07  3:10 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc, Bob Liu, uclinux-dist-devel, Sonic Zhang

From: Sonic Zhang <sonic.zhang@analog.com>

Without reset, SD controller may stay in disable mode, SD card can't
be detected when resume from power saving mode.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
 drivers/mmc/host/bfin_sdh.c |   35 +++++++++++++++++++----------------
 1 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/mmc/host/bfin_sdh.c b/drivers/mmc/host/bfin_sdh.c
index 57b7548..a95a09a 100644
--- a/drivers/mmc/host/bfin_sdh.c
+++ b/drivers/mmc/host/bfin_sdh.c
@@ -512,6 +512,23 @@ static irqreturn_t sdh_stat_irq(int irq, void *devid)
 	return IRQ_RETVAL(handled);
 }
 
+static void sdh_reset(void)
+{
+#if defined(CONFIG_BF54x)
+	/* Secure Digital Host shares DMA with Nand controller */
+	bfin_write_DMAC1_PERIMUX(bfin_read_DMAC1_PERIMUX() | 0x1);
+#endif
+
+	bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN);
+	SSYNC();
+
+	/* Disable card inserting detection pin. set MMC_CAP_NEEDS_POLL, and
+	 * mmc stack will do the detection.
+	 */
+	bfin_write_SDH_CFG((bfin_read_SDH_CFG() & 0x1F) | (PUP_SDDAT | PUP_SDDAT3));
+	SSYNC();
+}
+
 static int __devinit sdh_probe(struct platform_device *pdev)
 {
 	struct mmc_host *mmc;
@@ -588,19 +605,8 @@ static int __devinit sdh_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "unable to request peripheral pins\n");
 		goto out4;
 	}
-#if defined(CONFIG_BF54x)
-	/* Secure Digital Host shares DMA with Nand controller */
-	bfin_write_DMAC1_PERIMUX(bfin_read_DMAC1_PERIMUX() | 0x1);
-#endif
 
-	bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN);
-	SSYNC();
-
-	/* Disable card inserting detection pin. set MMC_CAP_NEEDS_POLL, and
-	 * mmc stack will do the detection.
-	 */
-	bfin_write_SDH_CFG((bfin_read_SDH_CFG() & 0x1F) | (PUP_SDDAT | PUP_SDDAT3));
-	SSYNC();
+	sdh_reset();
 
 	mmc_add_host(mmc);
 	return 0;
@@ -667,10 +673,7 @@ static int sdh_resume(struct platform_device *dev)
 		return ret;
 	}
 
-#if defined(CONFIG_BF54x)
-	/* Secure Digital Host shares DMA with Nand controller */
-	bfin_write_DMAC1_PERIMUX(bfin_read_DMAC1_PERIMUX() | 0x1);
-#endif
+	sdh_reset();
 
 	if (mmc)
 		ret = mmc_resume_host(mmc);
-- 
1.7.0.4



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518.
  2012-08-07  3:10 [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518 Sonic Zhang
                   ` (2 preceding siblings ...)
  2012-08-07  3:10 ` [PATCH 4/4] mmc: bfin_sdh: Reset SD controller when resume from power saving mode Sonic Zhang
@ 2012-08-08  3:23 ` Sonic Zhang
  2012-08-08  3:31   ` Chris Ball
  2012-08-08  4:11 ` Chris Ball
  4 siblings, 1 reply; 14+ messages in thread
From: Sonic Zhang @ 2012-08-08  3:23 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc, Bob Liu, uclinux-dist-devel, Sonic Zhang

Hi Chris,

Could you review this series of patches for Blackfin on-chip SD
controller? The head file and new BF60x machine code have been merged
upstream. These patches are necessary to get SD driver built on BF60x.

Thanks

Sonic Zhang


On Tue, Aug 7, 2012 at 11:10 AM, Sonic Zhang <sonic.adi@gmail.com> wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> bf518 RSI dma doesn't work in array mode.
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> ---
>  drivers/mmc/host/bfin_sdh.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mmc/host/bfin_sdh.c b/drivers/mmc/host/bfin_sdh.c
> index 0366617..fd25b0c 100644
> --- a/drivers/mmc/host/bfin_sdh.c
> +++ b/drivers/mmc/host/bfin_sdh.c
> @@ -469,7 +469,11 @@ static int __devinit sdh_probe(struct platform_device *pdev)
>         }
>
>         mmc->ops = &sdh_ops;
> +#if defined(CONFIG_BF54x)
>         mmc->max_segs = 32;
> +#elif defined(CONFIG_BF51x)
> +       mmc->max_segs = 1;
> +#endif
>         mmc->max_seg_size = 1 << 16;
>         mmc->max_blk_size = 1 << 11;
>         mmc->max_blk_count = 1 << 11;
> --
> 1.7.0.4
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518.
  2012-08-08  3:23 ` [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518 Sonic Zhang
@ 2012-08-08  3:31   ` Chris Ball
       [not found]     ` <87zk66vz45.fsf-DGHOrqG7t0YzNDMTQreKSUB+6BGkLq7r@public.gmane.org>
  2012-08-08  3:39     ` Zhang, Sonic
  0 siblings, 2 replies; 14+ messages in thread
From: Chris Ball @ 2012-08-08  3:31 UTC (permalink / raw)
  To: Sonic Zhang
  Cc: linux-mmc, Bob Liu, uclinux-dist-devel, Sonic Zhang, Cliff Cai

Hi,

On Tue, Aug 07 2012, Sonic Zhang wrote:
> Could you review this series of patches for Blackfin on-chip SD
> controller? The head file and new BF60x machine code have been merged
> upstream. These patches are necessary to get SD driver built on BF60x.

I see that Cliff Cai <cliff.cai@analog.com> is listed as the maintainer
of bfin_sdh.c in MAINTAINERS -- is it possible for you to get his ACK?

Thanks,

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518.
       [not found]     ` <87zk66vz45.fsf-DGHOrqG7t0YzNDMTQreKSUB+6BGkLq7r@public.gmane.org>
@ 2012-08-08  3:36       ` Chris Ball
  2012-08-08  3:40         ` Zhang, Sonic
  0 siblings, 1 reply; 14+ messages in thread
From: Chris Ball @ 2012-08-08  3:36 UTC (permalink / raw)
  To: Sonic Zhang
  Cc: uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA, Bob Liu

Hi,

On Tue, Aug 07 2012, Chris Ball wrote:
> On Tue, Aug 07 2012, Sonic Zhang wrote:
>> Could you review this series of patches for Blackfin on-chip SD
>> controller? The head file and new BF60x machine code have been merged
>> upstream. These patches are necessary to get SD driver built on BF60x.
>
> I see that Cliff Cai <cliff.cai-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> is listed as the maintainer
> of bfin_sdh.c in MAINTAINERS -- is it possible for you to get his ACK?

Ah, Cliff's e-mail address bounced, and I see this was noticed last
November -- you said you'd send out a MAINTAINERS update.  Are you
planning on taking over as bfin_sdh maintainer?

Thanks,

- Chris.
-- 
Chris Ball   <cjb-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518.
  2012-08-08  3:31   ` Chris Ball
       [not found]     ` <87zk66vz45.fsf-DGHOrqG7t0YzNDMTQreKSUB+6BGkLq7r@public.gmane.org>
@ 2012-08-08  3:39     ` Zhang, Sonic
  2012-08-08  3:42       ` Chris Ball
  1 sibling, 1 reply; 14+ messages in thread
From: Zhang, Sonic @ 2012-08-08  3:39 UTC (permalink / raw)
  To: Chris Ball, Sonic Zhang; +Cc: linux-mmc, Bob Liu, uclinux-dist-devel

Hi Chris,

Cliff Cai was not working for Analog Devices since 2011. I take over this SD driver now. I will revise the maintainer for bfin_sdh.c soon.


Regards,

Sonic


>-----Original Message-----
>From: Chris Ball [mailto:cjb@laptop.org]
>Sent: Wednesday, August 08, 2012 11:31 AM
>To: Sonic Zhang
>Cc: linux-mmc@vger.kernel.org; Bob Liu; uclinux-dist-devel@blackfin.uclinux.org;
>Zhang, Sonic; Cliff Cai
>Subject: Re: [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for
>bf518.
>
>Hi,
>
>On Tue, Aug 07 2012, Sonic Zhang wrote:
>> Could you review this series of patches for Blackfin on-chip SD
>> controller? The head file and new BF60x machine code have been merged
>> upstream. These patches are necessary to get SD driver built on BF60x.
>
>I see that Cliff Cai <cliff.cai@analog.com> is listed as the maintainer
>of bfin_sdh.c in MAINTAINERS -- is it possible for you to get his ACK?
>
>Thanks,
>
>- Chris.
>--
>Chris Ball   <cjb@laptop.org>   <http://printf.net/>
>One Laptop Per Child



^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518.
  2012-08-08  3:36       ` Chris Ball
@ 2012-08-08  3:40         ` Zhang, Sonic
  0 siblings, 0 replies; 14+ messages in thread
From: Zhang, Sonic @ 2012-08-08  3:40 UTC (permalink / raw)
  To: Chris Ball, Sonic Zhang; +Cc: linux-mmc, Bob Liu, uclinux-dist-devel



>-----Original Message-----
>From: Chris Ball [mailto:cjb@laptop.org]
>Sent: Wednesday, August 08, 2012 11:37 AM
>To: Sonic Zhang
>Cc: linux-mmc@vger.kernel.org; Bob Liu; uclinux-dist-devel@blackfin.uclinux.org;
>Zhang, Sonic
>Subject: Re: [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for
>bf518.
>
>Hi,
>
>On Tue, Aug 07 2012, Chris Ball wrote:
>> On Tue, Aug 07 2012, Sonic Zhang wrote:
>>> Could you review this series of patches for Blackfin on-chip SD
>>> controller? The head file and new BF60x machine code have been merged
>>> upstream. These patches are necessary to get SD driver built on BF60x.
>>
>> I see that Cliff Cai <cliff.cai@analog.com> is listed as the maintainer
>> of bfin_sdh.c in MAINTAINERS -- is it possible for you to get his ACK?
>
>Ah, Cliff's e-mail address bounced, and I see this was noticed last
>November -- you said you'd send out a MAINTAINERS update.  Are you
>planning on taking over as bfin_sdh maintainer?
>

Yes.

Regards,

Sonic


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518.
  2012-08-08  3:39     ` Zhang, Sonic
@ 2012-08-08  3:42       ` Chris Ball
  0 siblings, 0 replies; 14+ messages in thread
From: Chris Ball @ 2012-08-08  3:42 UTC (permalink / raw)
  To: Zhang, Sonic; +Cc: Sonic Zhang, linux-mmc, Bob Liu, uclinux-dist-devel

Hi,

On Tue, Aug 07 2012, Zhang, Sonic wrote:
> Hi Chris,
>
> Cliff Cai was not working for Analog Devices since 2011. I take over
> this SD driver now. I will revise the maintainer for bfin_sdh.c soon.

Thanks.  Please can you send me that patch now?  I'll merge your other
this patchset at the same time.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518.
  2012-08-07  3:10 [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518 Sonic Zhang
                   ` (3 preceding siblings ...)
  2012-08-08  3:23 ` [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518 Sonic Zhang
@ 2012-08-08  4:11 ` Chris Ball
  4 siblings, 0 replies; 14+ messages in thread
From: Chris Ball @ 2012-08-08  4:11 UTC (permalink / raw)
  To: Sonic Zhang; +Cc: linux-mmc, Bob Liu, uclinux-dist-devel, Sonic Zhang

Hi,

On Mon, Aug 06 2012, Sonic Zhang wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> bf518 RSI dma doesn't work in array mode.
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> ---
>  drivers/mmc/host/bfin_sdh.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mmc/host/bfin_sdh.c b/drivers/mmc/host/bfin_sdh.c
> index 0366617..fd25b0c 100644
> --- a/drivers/mmc/host/bfin_sdh.c
> +++ b/drivers/mmc/host/bfin_sdh.c
> @@ -469,7 +469,11 @@ static int __devinit sdh_probe(struct platform_device *pdev)
>  	}
>  
>  	mmc->ops = &sdh_ops;
> +#if defined(CONFIG_BF54x)
>  	mmc->max_segs = 32;
> +#elif defined(CONFIG_BF51x)
> +	mmc->max_segs = 1;
> +#endif
>  	mmc->max_seg_size = 1 << 16;
>  	mmc->max_blk_size = 1 << 11;
>  	mmc->max_blk_count = 1 << 11;

Thanks, pushed to mmc-next for 3.7.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] mmc: bfin_sdh: Port bf5xx SD host driver to support new RSI controller in bf60x.
  2012-08-07  3:10 ` [PATCH 2/4] mmc: bfin_sdh: Port bf5xx SD host driver to support new RSI controller in bf60x Sonic Zhang
@ 2012-08-08  4:15   ` Chris Ball
  0 siblings, 0 replies; 14+ messages in thread
From: Chris Ball @ 2012-08-08  4:15 UTC (permalink / raw)
  To: Sonic Zhang; +Cc: linux-mmc, Bob Liu, uclinux-dist-devel, Sonic Zhang

Hi,

On Mon, Aug 06 2012, Sonic Zhang wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> In BF60x RSI controller:
> 1) MMR read/write width differs.
> 2) PWR and CTL MMRs are merged to together.
> 3) ROD and PD_DAT3 bit masks are obsolete.
> 4) New RSI block size MMR is defined.
> 5) The definition of DMA descriptor set size is changed.
> 6) set_ios should powers up controller in 2 steps.
>
> In addition, this patch cleans up the spin locks.
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>

Thanks, pushed to mmc-next for 3.7.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/4] mmc: bfin_sdh: Remove redundent suspend and resume setting.
  2012-08-07  3:10 ` [PATCH 3/4] mmc: bfin_sdh: Remove redundent suspend and resume setting Sonic Zhang
@ 2012-08-08  4:20   ` Chris Ball
  0 siblings, 0 replies; 14+ messages in thread
From: Chris Ball @ 2012-08-08  4:20 UTC (permalink / raw)
  To: Sonic Zhang; +Cc: linux-mmc, Bob Liu, uclinux-dist-devel, Sonic Zhang, Bob Liu

Hi,

On Mon, Aug 06 2012, Sonic Zhang wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> mmc core suspend and resume functions had already called sdh_set_ios with proper flags.
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> Signed-off-by: Bob Liu <lliubbo@gmail.com>
> ---
>  drivers/mmc/host/bfin_sdh.c |   15 ---------------
>  1 files changed, 0 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/mmc/host/bfin_sdh.c b/drivers/mmc/host/bfin_sdh.c
> index fa085a0..57b7548 100644
> --- a/drivers/mmc/host/bfin_sdh.c
> +++ b/drivers/mmc/host/bfin_sdh.c
> @@ -650,11 +650,6 @@ static int sdh_suspend(struct platform_device *dev, pm_message_t state)
>  	if (mmc)
>  		ret = mmc_suspend_host(mmc);
>  
> -#ifndef RSI_BLKSZ
> -	bfin_write_SDH_PWR_CTL(bfin_read_SDH_PWR_CTL() & ~PWR_ON);
> -#else
> -	bfin_write_SDH_CFG(bfin_read_SDH_CFG() & ~PWR_ON);
> -#endif
>  	peripheral_free_list(drv_data->pin_req);
>  
>  	return ret;
> @@ -676,16 +671,6 @@ static int sdh_resume(struct platform_device *dev)
>  	/* Secure Digital Host shares DMA with Nand controller */
>  	bfin_write_DMAC1_PERIMUX(bfin_read_DMAC1_PERIMUX() | 0x1);
>  #endif
> -#ifndef RSI_BLKSZ
> -	bfin_write_SDH_PWR_CTL(bfin_read_SDH_PWR_CTL() | PWR_ON);
> -	bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN);
> -#else
> -	bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN | PWR_ON);
> -#endif
> -	SSYNC();
> -
> -	bfin_write_SDH_CFG((bfin_read_SDH_CFG() & 0x1F) | (PUP_SDDAT | PUP_SDDAT3));
> -	SSYNC();
>  
>  	if (mmc)
>  		ret = mmc_resume_host(mmc);

Thanks, pushed to mmc-next for 3.7.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] mmc: bfin_sdh: Reset SD controller when resume from power saving mode.
  2012-08-07  3:10 ` [PATCH 4/4] mmc: bfin_sdh: Reset SD controller when resume from power saving mode Sonic Zhang
@ 2012-08-08  4:20   ` Chris Ball
  0 siblings, 0 replies; 14+ messages in thread
From: Chris Ball @ 2012-08-08  4:20 UTC (permalink / raw)
  To: Sonic Zhang; +Cc: linux-mmc, Bob Liu, uclinux-dist-devel, Sonic Zhang

Hi,

On Mon, Aug 06 2012, Sonic Zhang wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> Without reset, SD controller may stay in disable mode, SD card can't
> be detected when resume from power saving mode.
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>

Thanks, pushed to mmc-next for 3.7.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-08-08  4:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-07  3:10 [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518 Sonic Zhang
2012-08-07  3:10 ` [PATCH 2/4] mmc: bfin_sdh: Port bf5xx SD host driver to support new RSI controller in bf60x Sonic Zhang
2012-08-08  4:15   ` Chris Ball
2012-08-07  3:10 ` [PATCH 3/4] mmc: bfin_sdh: Remove redundent suspend and resume setting Sonic Zhang
2012-08-08  4:20   ` Chris Ball
2012-08-07  3:10 ` [PATCH 4/4] mmc: bfin_sdh: Reset SD controller when resume from power saving mode Sonic Zhang
2012-08-08  4:20   ` Chris Ball
2012-08-08  3:23 ` [PATCH 1/4] mmc: bfin_sdh: limit mmc DMA segment len to 1 for bf518 Sonic Zhang
2012-08-08  3:31   ` Chris Ball
     [not found]     ` <87zk66vz45.fsf-DGHOrqG7t0YzNDMTQreKSUB+6BGkLq7r@public.gmane.org>
2012-08-08  3:36       ` Chris Ball
2012-08-08  3:40         ` Zhang, Sonic
2012-08-08  3:39     ` Zhang, Sonic
2012-08-08  3:42       ` Chris Ball
2012-08-08  4:11 ` Chris Ball

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.