Skip to contentSkip to conversation

Add device tree support for mxs-dma

PATCH New Shawn Guo 3 participants 19 messages May 7, 2012 – May 9, 2012

Subsystems (7)
lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

cover Add device tree support for mxs-dma

This series is a rebase of Dong Aisheng's patchset on common-clk and pinctrl. It also adds one patch to address Marek's comment on dma_is_apbh and apbh_is_old macros.

Dong Aisheng (5):
dma: mxs-dma: use global stmp_device functionality
dma: mxs-dma: make platform_device_id more generic
dma: mxs-dma: add device tree probe support
ARM: mxs: do not add dma device by default
ARM: mxs: add mxs-dma dt support

Shawn Guo (1):
dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter

 .../devicetree/bindings/dma/fsl-mxs-dma.txt        |   19 ++
 arch/arm/boot/dts/imx23.dtsi                       |    4 +-
 arch/arm/boot/dts/imx28.dtsi                       |    4 +-
 arch/arm/mach-mxs/devices/platform-dma.c           |   21 +--
 arch/arm/mach-mxs/include/mach/common.h            |    3 +
 arch/arm/mach-mxs/mm.c                             |    6 +
 drivers/clk/mxs/clk-imx23.c                        |    4 +-
 drivers/clk/mxs/clk-imx28.c                        |    4 +-
 drivers/dma/Kconfig                                |    1 +
 drivers/dma/mxs-dma.c                              |  184 +++++++++++++-------
 include/linux/fsl/mxs-dma.h                        |   12 +-
 11 files changed, 163 insertions(+), 99 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt
Signature · 1 line
1.7.5.4
author
#1 lore raw

PATCH 1/6 dma: mxs-dma: use global stmp_device functionality

From: Dong Aisheng <[email protected]>

This can get rid of the mach-dependency.

---
 drivers/dma/Kconfig   |    1 +
 drivers/dma/mxs-dma.c |   26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 13 deletions(-)
drivers/dma/Kconfig +1 -0
index ef378b5..aadeb5b 100644
@@ -238,6 +238,7 @@ config IMX_DMA
 config MXS_DMA
 	bool "MXS DMA support"
 	depends on SOC_IMX23 || SOC_IMX28
+	select STMP_DEVICE
 	select DMA_ENGINE
 	help
 	  Support the MXS DMA engine. This engine including APBH-DMA
drivers/dma/mxs-dma.c +13 -13
index 655d4ce..bd27818 100644
@@ -23,10 +23,10 @@
 #include <linux/dmaengine.h>
 #include <linux/delay.h>
 #include <linux/fsl/mxs-dma.h>
+#include <linux/stmp_device.h>
 
 #include <asm/irq.h>
 #include <mach/mxs.h>
-#include <mach/common.h>
 
 #include "dmaengine.h"
 
@@ -138,10 +138,10 @@ static void mxs_dma_reset_chan(struct mxs_dma_chan *mxs_chan)
 
 	if (dma_is_apbh() && apbh_is_old())
 		writel(1 << (chan_id + BP_APBH_CTRL0_RESET_CHANNEL),
-			mxs_dma->base + HW_APBHX_CTRL0 + MXS_SET_ADDR);
+			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 	else
 		writel(1 << (chan_id + BP_APBHX_CHANNEL_CTRL_RESET_CHANNEL),
-			mxs_dma->base + HW_APBHX_CHANNEL_CTRL + MXS_SET_ADDR);
+			mxs_dma->base + HW_APBHX_CHANNEL_CTRL + STMP_OFFSET_REG_SET);
 }
 
 static void mxs_dma_enable_chan(struct mxs_dma_chan *mxs_chan)
@@ -170,10 +170,10 @@ static void mxs_dma_pause_chan(struct mxs_dma_chan *mxs_chan)
 	/* freeze the channel */
 	if (dma_is_apbh() && apbh_is_old())
 		writel(1 << chan_id,
-			mxs_dma->base + HW_APBHX_CTRL0 + MXS_SET_ADDR);
+			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 	else
 		writel(1 << chan_id,
-			mxs_dma->base + HW_APBHX_CHANNEL_CTRL + MXS_SET_ADDR);
+			mxs_dma->base + HW_APBHX_CHANNEL_CTRL + STMP_OFFSET_REG_SET);
 
 	mxs_chan->status = DMA_PAUSED;
 }
@@ -186,10 +186,10 @@ static void mxs_dma_resume_chan(struct mxs_dma_chan *mxs_chan)
 	/* unfreeze the channel */
 	if (dma_is_apbh() && apbh_is_old())
 		writel(1 << chan_id,
-			mxs_dma->base + HW_APBHX_CTRL0 + MXS_CLR_ADDR);
+			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_CLR);
 	else
 		writel(1 << chan_id,
-			mxs_dma->base + HW_APBHX_CHANNEL_CTRL + MXS_CLR_ADDR);
+			mxs_dma->base + HW_APBHX_CHANNEL_CTRL + STMP_OFFSET_REG_CLR);
 
 	mxs_chan->status = DMA_IN_PROGRESS;
 }
@@ -220,11 +220,11 @@ static irqreturn_t mxs_dma_int_handler(int irq, void *dev_id)
 	/* completion status */
 	stat1 = readl(mxs_dma->base + HW_APBHX_CTRL1);
 	stat1 &= MXS_DMA_CHANNELS_MASK;
-	writel(stat1, mxs_dma->base + HW_APBHX_CTRL1 + MXS_CLR_ADDR);
+	writel(stat1, mxs_dma->base + HW_APBHX_CTRL1 + STMP_OFFSET_REG_CLR);
 
 	/* error status */
 	stat2 = readl(mxs_dma->base + HW_APBHX_CTRL2);
-	writel(stat2, mxs_dma->base + HW_APBHX_CTRL2 + MXS_CLR_ADDR);
+	writel(stat2, mxs_dma->base + HW_APBHX_CTRL2 + STMP_OFFSET_REG_CLR);
 
 	/*
 	 * When both completion and error of termination bits set at the
@@ -567,7 +567,7 @@ static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma)
 	if (ret)
 		return ret;
 
-	ret = mxs_reset_block(mxs_dma->base);
+	ret = stmp_reset_block(mxs_dma->base);
 	if (ret)
 		goto err_out;
 
@@ -580,14 +580,14 @@ static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma)
 	/* enable apbh burst */
 	if (dma_is_apbh()) {
 		writel(BM_APBH_CTRL0_APB_BURST_EN,
-			mxs_dma->base + HW_APBHX_CTRL0 + MXS_SET_ADDR);
+			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 		writel(BM_APBH_CTRL0_APB_BURST8_EN,
-			mxs_dma->base + HW_APBHX_CTRL0 + MXS_SET_ADDR);
+			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 	}
 
 	/* enable irq for all the channels */
 	writel(MXS_DMA_CHANNELS_MASK << MXS_DMA_CHANNELS,
-		mxs_dma->base + HW_APBHX_CTRL1 + MXS_SET_ADDR);
+		mxs_dma->base + HW_APBHX_CTRL1 + STMP_OFFSET_REG_SET);
 
 err_out:
 	clk_disable_unprepare(mxs_dma->clk);
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 1/6 dma: mxs-dma: use global stmp_device functionality

Dear Shawn Guo,

Quoted 9 lines

From: Dong Aisheng <[email protected]>

This can get rid of the mach-dependency.

Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Huang Shijie <[email protected]>
Quoted 37 lines
---
 drivers/dma/Kconfig   |    1 +
 drivers/dma/mxs-dma.c |   26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 13 deletions(-)
drivers/dma/Kconfig +1 -0
index ef378b5..aadeb5b 100644
@@ -238,6 +238,7 @@ config IMX_DMA
 config MXS_DMA
 	bool "MXS DMA support"
 	depends on SOC_IMX23 || SOC_IMX28
+	select STMP_DEVICE
 	select DMA_ENGINE
 	help
 	  Support the MXS DMA engine. This engine including APBH-DMA
drivers/dma/mxs-dma.c +1 -1
index 655d4ce..bd27818 100644
@@ -23,10 +23,10 @@
 #include <linux/dmaengine.h>
 #include <linux/delay.h>
 #include <linux/fsl/mxs-dma.h>
+#include <linux/stmp_device.h>
 
 #include <asm/irq.h>
 #include <mach/mxs.h>
-#include <mach/common.h>
 
 #include "dmaengine.h"
 

drivers/dma/mxs-dma.c static void mxs_dma_reset_chan(struct mxs_dma_chan · line 145

Quoted 10 lines
drivers/dma/mxs-dma.c +2 -2
@@ -138,10 +138,10 @@ static void mxs_dma_reset_chan(struct mxs_dma_chan
 *mxs_chan)
 
 	if (dma_is_apbh() && apbh_is_old())
 		writel(1 << (chan_id + BP_APBH_CTRL0_RESET_CHANNEL),
-			mxs_dma->base + HW_APBHX_CTRL0 + MXS_SET_ADDR);
+			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 	else
 		writel(1 << (chan_id + BP_APBHX_CHANNEL_CTRL_RESET_CHANNEL),
-			mxs_dma->base + HW_APBHX_CHANNEL_CTRL + MXS_SET_ADDR);
+			mxs_dma->base + HW_APBHX_CHANNEL_CTRL + 

STMP_OFFSET_REG_SET);

drivers/dma/mxs-dma.c static void mxs_dma_pause_chan(struct mxs_dma_chan · line 176

Quoted 13 lines
drivers/dma/mxs-dma.c +0 -0
 }
 

static void mxs_dma_enable_chan(struct mxs_dma_chan *mxs_chan)

drivers/dma/mxs-dma.c +2 -2
@@ -170,10 +170,10 @@ static void mxs_dma_pause_chan(struct mxs_dma_chan
 *mxs_chan) /* freeze the channel */
 	if (dma_is_apbh() && apbh_is_old())
 		writel(1 << chan_id,
-			mxs_dma->base + HW_APBHX_CTRL0 + MXS_SET_ADDR);
+			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 	else
 		writel(1 << chan_id,
-			mxs_dma->base + HW_APBHX_CHANNEL_CTRL + MXS_SET_ADDR);
+			mxs_dma->base + HW_APBHX_CHANNEL_CTRL + 

STMP_OFFSET_REG_SET);

drivers/dma/mxs-dma.c static void mxs_dma_resume_chan(struct mxs_dma_chan · line 192

Quoted 13 lines
drivers/dma/mxs-dma.c +2 -2
 	mxs_chan->status = DMA_PAUSED;
 }
@@ -186,10 +186,10 @@ static void mxs_dma_resume_chan(struct mxs_dma_chan
 *mxs_chan) /* unfreeze the channel */
 	if (dma_is_apbh() && apbh_is_old())
 		writel(1 << chan_id,
-			mxs_dma->base + HW_APBHX_CTRL0 + MXS_CLR_ADDR);
+			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_CLR);
 	else
 		writel(1 << chan_id,
-			mxs_dma->base + HW_APBHX_CHANNEL_CTRL + MXS_CLR_ADDR);
+			mxs_dma->base + HW_APBHX_CHANNEL_CTRL + 

STMP_OFFSET_REG_CLR);

Quoted 34 lines
drivers/dma/mxs-dma.c +4 -5
 	mxs_chan->status = DMA_IN_PROGRESS;
 }
@@ -220,11 +220,11 @@ static irqreturn_t mxs_dma_int_handler(int irq, void
 *dev_id) /* completion status */
 	stat1 = readl(mxs_dma->base + HW_APBHX_CTRL1);
 	stat1 &= MXS_DMA_CHANNELS_MASK;
-	writel(stat1, mxs_dma->base + HW_APBHX_CTRL1 + MXS_CLR_ADDR);
+	writel(stat1, mxs_dma->base + HW_APBHX_CTRL1 + STMP_OFFSET_REG_CLR);
 
 	/* error status */
 	stat2 = readl(mxs_dma->base + HW_APBHX_CTRL2);
-	writel(stat2, mxs_dma->base + HW_APBHX_CTRL2 + MXS_CLR_ADDR);
+	writel(stat2, mxs_dma->base + HW_APBHX_CTRL2 + STMP_OFFSET_REG_CLR);
 
 	/*
 	 * When both completion and error of termination bits set at the
@@ -567,7 +567,7 @@ static int __init mxs_dma_init(struct mxs_dma_engine
 *mxs_dma) if (ret)
 		return ret;
 
-	ret = mxs_reset_block(mxs_dma->base);
+	ret = stmp_reset_block(mxs_dma->base);
 	if (ret)
 		goto err_out;
 
@@ -580,14 +580,14 @@ static int __init mxs_dma_init(struct mxs_dma_engine
 *mxs_dma) /* enable apbh burst */
 	if (dma_is_apbh()) {
 		writel(BM_APBH_CTRL0_APB_BURST_EN,
-			mxs_dma->base + HW_APBHX_CTRL0 + MXS_SET_ADDR);
+			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 		writel(BM_APBH_CTRL0_APB_BURST8_EN,
-			mxs_dma->base + HW_APBHX_CTRL0 + MXS_SET_ADDR);

drivers/dma/mxs-dma.c static int __init mxs_dma_init(struct mxs_dma_engine · line 593

Quoted 10 lines
drivers/dma/mxs-dma.c +2 -1
+			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 	}
 
 	/* enable irq for all the channels */
 	writel(MXS_DMA_CHANNELS_MASK << MXS_DMA_CHANNELS,
-		mxs_dma->base + HW_APBHX_CTRL1 + MXS_SET_ADDR);
+		mxs_dma->base + HW_APBHX_CTRL1 + STMP_OFFSET_REG_SET);
 
 err_out:
 	clk_disable_unprepare(mxs_dma->clk);

Best regards,
Marek Vasut

author
#3 lore raw

PATCH 2/6 dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter

In reply to Shawn Guo

Let macros dma_is_apbh and apbh_is_old take mxs_dma as parameter to make the code easy to read.

---
 drivers/dma/mxs-dma.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)
drivers/dma/mxs-dma.c +12 -12
index bd27818..e801fbf 100644
@@ -38,10 +38,10 @@
 
 #define MXS_DMA_APBH		0
 #define MXS_DMA_APBX		1
-#define dma_is_apbh()		(mxs_dma->dev_id == MXS_DMA_APBH)
+#define dma_is_apbh(mxs_dma)	(mxs_dma->dev_id == MXS_DMA_APBH)
 
 #define APBH_VERSION_LATEST	3
-#define apbh_is_old()		(mxs_dma->version < APBH_VERSION_LATEST)
+#define apbh_is_old(mxs_dma)	(mxs_dma->version < APBH_VERSION_LATEST)
 
 #define HW_APBHX_CTRL0				0x000
 #define BM_APBH_CTRL0_APB_BURST8_EN		(1 << 29)
@@ -54,10 +54,10 @@
 #define HW_APBH_VERSION				(cpu_is_mx23() ? 0x3f0 : 0x800)
 #define HW_APBX_VERSION				0x800
 #define BP_APBHX_VERSION_MAJOR			24
-#define HW_APBHX_CHn_NXTCMDAR(n) \
-	(((dma_is_apbh() && apbh_is_old()) ? 0x050 : 0x110) + (n) * 0x70)
-#define HW_APBHX_CHn_SEMA(n) \
-	(((dma_is_apbh() && apbh_is_old()) ? 0x080 : 0x140) + (n) * 0x70)
+#define HW_APBHX_CHn_NXTCMDAR(d, n) \
+	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x050 : 0x110) + (n) * 0x70)
+#define HW_APBHX_CHn_SEMA(d, n) \
+	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x080 : 0x140) + (n) * 0x70)
 
 /*
  * ccw bits definitions
@@ -136,7 +136,7 @@ static void mxs_dma_reset_chan(struct mxs_dma_chan *mxs_chan)
 	struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma;
 	int chan_id = mxs_chan->chan.chan_id;
 
-	if (dma_is_apbh() && apbh_is_old())
+	if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma))
 		writel(1 << (chan_id + BP_APBH_CTRL0_RESET_CHANNEL),
 			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 	else
@@ -151,10 +151,10 @@ static void mxs_dma_enable_chan(struct mxs_dma_chan *mxs_chan)
 
 	/* set cmd_addr up */
 	writel(mxs_chan->ccw_phys,
-		mxs_dma->base + HW_APBHX_CHn_NXTCMDAR(chan_id));
+		mxs_dma->base + HW_APBHX_CHn_NXTCMDAR(mxs_dma, chan_id));
 
 	/* write 1 to SEMA to kick off the channel */
-	writel(1, mxs_dma->base + HW_APBHX_CHn_SEMA(chan_id));
+	writel(1, mxs_dma->base + HW_APBHX_CHn_SEMA(mxs_dma, chan_id));
 }
 
 static void mxs_dma_disable_chan(struct mxs_dma_chan *mxs_chan)
@@ -168,7 +168,7 @@ static void mxs_dma_pause_chan(struct mxs_dma_chan *mxs_chan)
 	int chan_id = mxs_chan->chan.chan_id;
 
 	/* freeze the channel */
-	if (dma_is_apbh() && apbh_is_old())
+	if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma))
 		writel(1 << chan_id,
 			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 	else
@@ -184,7 +184,7 @@ static void mxs_dma_resume_chan(struct mxs_dma_chan *mxs_chan)
 	int chan_id = mxs_chan->chan.chan_id;
 
 	/* unfreeze the channel */
-	if (dma_is_apbh() && apbh_is_old())
+	if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma))
 		writel(1 << chan_id,
 			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_CLR);
 	else
@@ -578,7 +578,7 @@ static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma)
 				BP_APBHX_VERSION_MAJOR;
 
 	/* enable apbh burst */
-	if (dma_is_apbh()) {
+	if (dma_is_apbh(mxs_dma)) {
 		writel(BM_APBH_CTRL0_APB_BURST_EN,
 			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 		writel(BM_APBH_CTRL0_APB_BURST8_EN,
Signature · 1 line
1.7.5.4
#4 lore raw

PATCH 2/6 dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter

Dear Shawn Guo,

Quoted 26 lines

Let macros dma_is_apbh and apbh_is_old take mxs_dma as parameter to make the code easy to read.

---
 drivers/dma/mxs-dma.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)
drivers/dma/mxs-dma.c +2 -2
index bd27818..e801fbf 100644
@@ -38,10 +38,10 @@
 
 #define MXS_DMA_APBH		0
 #define MXS_DMA_APBX		1
-#define dma_is_apbh()		(mxs_dma->dev_id == MXS_DMA_APBH)
+#define dma_is_apbh(mxs_dma)	(mxs_dma->dev_id == MXS_DMA_APBH)
 
 #define APBH_VERSION_LATEST	3
-#define apbh_is_old()		(mxs_dma->version < APBH_VERSION_LATEST)
+#define apbh_is_old(mxs_dma)	(mxs_dma->version < APBH_VERSION_LATEST)
 
 #define HW_APBHX_CTRL0				0x000
 #define BM_APBH_CTRL0_APB_BURST8_EN		(1 << 29)

drivers/dma/mxs-dma.c line 54

Quoted 1 line
drivers/dma/mxs-dma.c +0 -0
@@ -54,10 +54,10 @@
 #define HW_APBH_VERSION				(cpu_is_mx23() ? 0x3f0 : 

0x800)

drivers/dma/mxs-dma.c line 60

Quoted 10 lines
drivers/dma/mxs-dma.c +4 -4
 #define HW_APBX_VERSION				0x800
 #define BP_APBHX_VERSION_MAJOR			24
-#define HW_APBHX_CHn_NXTCMDAR(n) \
-	(((dma_is_apbh() && apbh_is_old()) ? 0x050 : 0x110) + (n) * 0x70)
-#define HW_APBHX_CHn_SEMA(n) \
-	(((dma_is_apbh() && apbh_is_old()) ? 0x080 : 0x140) + (n) * 0x70)
+#define HW_APBHX_CHn_NXTCMDAR(d, n) \
+	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x050 : 0x110) + (n) * 0x70)
+#define HW_APBHX_CHn_SEMA(d, n) \
+	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x080 : 0x140) + (n) * 0x70)

Well ... if you got rid of the above magic values, it'd be cool ;-)

Otherwise...

Best regards,
Marek Vasut

author
#5 lore raw

PATCH 2/6 dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter

Quoted 15 lines · Marek Vasut
Quoted 1 line

#define HW_APBH_VERSION (cpu_is_mx23() ? 0x3f0 :

0x800)

drivers/dma/mxs-dma.c line 60

Quoted 10 lines

#define HW_APBX_VERSION 0x800
#define BP_APBHX_VERSION_MAJOR 24

drivers/dma/mxs-dma.c +4 -4
-#define HW_APBHX_CHn_NXTCMDAR(n) \
-	(((dma_is_apbh() && apbh_is_old()) ? 0x050 : 0x110) + (n) * 0x70)
-#define HW_APBHX_CHn_SEMA(n) \
-	(((dma_is_apbh() && apbh_is_old()) ? 0x080 : 0x140) + (n) * 0x70)
+#define HW_APBHX_CHn_NXTCMDAR(d, n) \
+	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x050 : 0x110) + (n) * 0x70)
+#define HW_APBHX_CHn_SEMA(d, n) \
+	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x080 : 0x140) + (n) * 0x70)

Well ... if you got rid of the above magic values, it'd be cool ;-)

I just do not think it's really worth another set of marcos.

Signature · 2 lines
Regards,
Shawn
#6 lore raw

PATCH 2/6 dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter

In reply to Shawn Guo
Quoted 27 lines · Shawn Guo

Let macros dma_is_apbh and apbh_is_old take mxs_dma as parameter to make the code easy to read.

---
 drivers/dma/mxs-dma.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)
drivers/dma/mxs-dma.c +2 -2
index bd27818..e801fbf 100644
@@ -38,10 +38,10 @@
 
 #define MXS_DMA_APBH		0
 #define MXS_DMA_APBX		1
-#define dma_is_apbh()		(mxs_dma->dev_id == MXS_DMA_APBH)
+#define dma_is_apbh(mxs_dma)	(mxs_dma->dev_id == MXS_DMA_APBH)
 
 #define APBH_VERSION_LATEST	3
-#define apbh_is_old()		(mxs_dma->version < APBH_VERSION_LATEST)
+#define apbh_is_old(mxs_dma)	(mxs_dma->version < APBH_VERSION_LATEST)
 
 #define HW_APBHX_CTRL0				0x000
 #define BM_APBH_CTRL0_APB_BURST8_EN		(1 << 29)
@@ -54,10 +54,10 @@
 #define HW_APBH_VERSION				(cpu_is_mx23() ? 0x3f0 : 0x800)

drivers/dma/mxs-dma.c line 60

Quoted 10 lines
drivers/dma/mxs-dma.c +4 -4
 #define HW_APBX_VERSION				0x800
 #define BP_APBHX_VERSION_MAJOR			24
-#define HW_APBHX_CHn_NXTCMDAR(n) \
-	(((dma_is_apbh() && apbh_is_old()) ? 0x050 : 0x110) + (n) * 0x70)
-#define HW_APBHX_CHn_SEMA(n) \
-	(((dma_is_apbh() && apbh_is_old()) ? 0x080 : 0x140) + (n) * 0x70)
+#define HW_APBHX_CHn_NXTCMDAR(d, n) \
+	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x050 : 0x110) + (n) * 0x70)
+#define HW_APBHX_CHn_SEMA(d, n) \
+	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x080 : 0x140) + (n) * 0x70)

while at it, care to say what the above magic numbers mean. Isnt terrible clear to me.

Quoted 52 lines
drivers/dma/mxs-dma.c +6 -6
 /*
  * ccw bits definitions
@@ -136,7 +136,7 @@ static void mxs_dma_reset_chan(struct mxs_dma_chan *mxs_chan)
 	struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma;
 	int chan_id = mxs_chan->chan.chan_id;
 
-	if (dma_is_apbh() && apbh_is_old())
+	if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma))
 		writel(1 << (chan_id + BP_APBH_CTRL0_RESET_CHANNEL),
 			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 	else
@@ -151,10 +151,10 @@ static void mxs_dma_enable_chan(struct mxs_dma_chan *mxs_chan)
 
 	/* set cmd_addr up */
 	writel(mxs_chan->ccw_phys,
-		mxs_dma->base + HW_APBHX_CHn_NXTCMDAR(chan_id));
+		mxs_dma->base + HW_APBHX_CHn_NXTCMDAR(mxs_dma, chan_id));
 
 	/* write 1 to SEMA to kick off the channel */
-	writel(1, mxs_dma->base + HW_APBHX_CHn_SEMA(chan_id));
+	writel(1, mxs_dma->base + HW_APBHX_CHn_SEMA(mxs_dma, chan_id));
 }
 
 static void mxs_dma_disable_chan(struct mxs_dma_chan *mxs_chan)
@@ -168,7 +168,7 @@ static void mxs_dma_pause_chan(struct mxs_dma_chan *mxs_chan)
 	int chan_id = mxs_chan->chan.chan_id;
 
 	/* freeze the channel */
-	if (dma_is_apbh() && apbh_is_old())
+	if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma))
 		writel(1 << chan_id,
 			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 	else
@@ -184,7 +184,7 @@ static void mxs_dma_resume_chan(struct mxs_dma_chan *mxs_chan)
 	int chan_id = mxs_chan->chan.chan_id;
 
 	/* unfreeze the channel */
-	if (dma_is_apbh() && apbh_is_old())
+	if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma))
 		writel(1 << chan_id,
 			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_CLR);
 	else
@@ -578,7 +578,7 @@ static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma)
 				BP_APBHX_VERSION_MAJOR;
 
 	/* enable apbh burst */
-	if (dma_is_apbh()) {
+	if (dma_is_apbh(mxs_dma)) {
 		writel(BM_APBH_CTRL0_APB_BURST_EN,
 			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 		writel(BM_APBH_CTRL0_APB_BURST8_EN,
Signature · 1 line
~Vinod
#7 lore raw

PATCH 2/6 dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter

Dear Vinod Koul,

Quoted 27 lines · Shawn Guo
Quoted 26 lines

Let macros dma_is_apbh and apbh_is_old take mxs_dma as parameter to make the code easy to read.

---

 drivers/dma/mxs-dma.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)
drivers/dma/mxs-dma.c +2 -2
index bd27818..e801fbf 100644
@@ -38,10 +38,10 @@
 
 #define MXS_DMA_APBH		0
 #define MXS_DMA_APBX		1
 
-#define dma_is_apbh()		(mxs_dma->dev_id == MXS_DMA_APBH)
+#define dma_is_apbh(mxs_dma)	(mxs_dma->dev_id == MXS_DMA_APBH)
 
 #define APBH_VERSION_LATEST	3
 
-#define apbh_is_old()		(mxs_dma->version < APBH_VERSION_LATEST)
+#define apbh_is_old(mxs_dma)	(mxs_dma->version < APBH_VERSION_LATEST)
 
Quoted 6 lines

drivers/dma/mxs-dma.c line 55

Quoted 6 lines

#define HW_APBHX_CTRL0 0x000
#define BM_APBH_CTRL0_APB_BURST8_EN (1 << 29)

drivers/dma/mxs-dma.c +0 -0
@@ -54,10 +54,10 @@
 
 #define HW_APBH_VERSION				(cpu_is_mx23() ? 0x3f0 : 

0x800)

Quoted 14 lines

drivers/dma/mxs-dma.c line 60

Quoted 11 lines
drivers/dma/mxs-dma.c +4 -4
 #define HW_APBX_VERSION				0x800
 #define BP_APBHX_VERSION_MAJOR			24
 
-#define HW_APBHX_CHn_NXTCMDAR(n) \
-	(((dma_is_apbh() && apbh_is_old()) ? 0x050 : 0x110) + (n) * 0x70)
-#define HW_APBHX_CHn_SEMA(n) \
-	(((dma_is_apbh() && apbh_is_old()) ? 0x080 : 0x140) + (n) * 0x70)
+#define HW_APBHX_CHn_NXTCMDAR(d, n) \
+	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x050 : 0x110) + (n) * 0x70)
+#define HW_APBHX_CHn_SEMA(d, n) \
+	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x080 : 0x140) + (n) * 0x70)

while at it, care to say what the above magic numbers mean. Isnt terrible clear to me.

Check the email above ;-) I think simple comment would be enough here, but defining those would not hurt either.

Quoted 77 lines
Quoted 77 lines
drivers/dma/mxs-dma.c +0 -0
 /*

* ccw bits definitions

drivers/dma/mxs-dma.c +1 -1
@@ -136,7 +136,7 @@ static void mxs_dma_reset_chan(struct mxs_dma_chan
 *mxs_chan)
 
 	struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma;
 	int chan_id = mxs_chan->chan.chan_id;
 
-	if (dma_is_apbh() && apbh_is_old())
+	if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma))
 
drivers/dma/mxs-dma.c +2 -2
 		writel(1 << (chan_id + BP_APBH_CTRL0_RESET_CHANNEL),
 
 			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 
 	else
@@ -151,10 +151,10 @@ static void mxs_dma_enable_chan(struct mxs_dma_chan
 *mxs_chan)
 
 	/* set cmd_addr up */
 	writel(mxs_chan->ccw_phys,
 
-		mxs_dma->base + HW_APBHX_CHn_NXTCMDAR(chan_id));
+		mxs_dma->base + HW_APBHX_CHn_NXTCMDAR(mxs_dma, chan_id));
 
 	/* write 1 to SEMA to kick off the channel */
 
-	writel(1, mxs_dma->base + HW_APBHX_CHn_SEMA(chan_id));
+	writel(1, mxs_dma->base + HW_APBHX_CHn_SEMA(mxs_dma, chan_id));

}

static void mxs_dma_disable_chan(struct mxs_dma_chan *mxs_chan)

drivers/dma/mxs-dma.c +1 -1
@@ -168,7 +168,7 @@ static void mxs_dma_pause_chan(struct mxs_dma_chan
 *mxs_chan)
 
 	int chan_id = mxs_chan->chan.chan_id;
 
 	/* freeze the channel */
 
-	if (dma_is_apbh() && apbh_is_old())
+	if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma))
drivers/dma/mxs-dma.c +1 -1
 		writel(1 << chan_id,
 
 			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 
 	else
@@ -184,7 +184,7 @@ static void mxs_dma_resume_chan(struct mxs_dma_chan
 *mxs_chan)
 
 	int chan_id = mxs_chan->chan.chan_id;
 
 	/* unfreeze the channel */
 
-	if (dma_is_apbh() && apbh_is_old())
+	if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma))
drivers/dma/mxs-dma.c +0 -0
 		writel(1 << chan_id,
 
 			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_CLR);
 
 	else
@@ -578,7 +578,7 @@ static int __init mxs_dma_init(struct mxs_dma_engine
 *mxs_dma)
 
 				BP_APBHX_VERSION_MAJOR;
 
 	/* enable apbh burst */
 
Quoted 8 lines

drivers/dma/mxs-dma.c static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma) · line 584

Quoted 8 lines
drivers/dma/mxs-dma.c +1 -1
-	if (dma_is_apbh()) {
+	if (dma_is_apbh(mxs_dma)) {
drivers/dma/mxs-dma.c +0 -0
 		writel(BM_APBH_CTRL0_APB_BURST_EN,
 
 			mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET);
 
 		writel(BM_APBH_CTRL0_APB_BURST8_EN,

Best regards,
Marek Vasut

#8 lore raw

PATCH 2/6 dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter

Quoted 51 lines · Marek Vasut

Dear Vinod Koul,

Quoted 27 lines · Shawn Guo
Quoted 26 lines

Let macros dma_is_apbh and apbh_is_old take mxs_dma as parameter to make the code easy to read.

---

 drivers/dma/mxs-dma.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)
drivers/dma/mxs-dma.c +2 -2
index bd27818..e801fbf 100644
@@ -38,10 +38,10 @@
 
 #define MXS_DMA_APBH		0
 #define MXS_DMA_APBX		1
 
-#define dma_is_apbh()		(mxs_dma->dev_id == MXS_DMA_APBH)
+#define dma_is_apbh(mxs_dma)	(mxs_dma->dev_id == MXS_DMA_APBH)
 
 #define APBH_VERSION_LATEST	3
 
-#define apbh_is_old()		(mxs_dma->version < APBH_VERSION_LATEST)
+#define apbh_is_old(mxs_dma)	(mxs_dma->version < APBH_VERSION_LATEST)
 
Quoted 6 lines

drivers/dma/mxs-dma.c line 55

Quoted 6 lines

#define HW_APBHX_CTRL0 0x000
#define BM_APBH_CTRL0_APB_BURST8_EN (1 << 29)

drivers/dma/mxs-dma.c +0 -0
@@ -54,10 +54,10 @@
 
 #define HW_APBH_VERSION				(cpu_is_mx23() ? 0x3f0 : 

0x800)

Quoted 14 lines

drivers/dma/mxs-dma.c line 60

Quoted 11 lines
drivers/dma/mxs-dma.c +4 -4
 #define HW_APBX_VERSION				0x800
 #define BP_APBHX_VERSION_MAJOR			24
 
-#define HW_APBHX_CHn_NXTCMDAR(n) \
-	(((dma_is_apbh() && apbh_is_old()) ? 0x050 : 0x110) + (n) * 0x70)
-#define HW_APBHX_CHn_SEMA(n) \
-	(((dma_is_apbh() && apbh_is_old()) ? 0x080 : 0x140) + (n) * 0x70)
+#define HW_APBHX_CHn_NXTCMDAR(d, n) \
+	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x050 : 0x110) + (n) * 0x70)
+#define HW_APBHX_CHn_SEMA(d, n) \
+	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x080 : 0x140) + (n) * 0x70)

while at it, care to say what the above magic numbers mean. Isnt terrible clear to me.

Quoted 2 lines

Check the email above ;-) I think simple comment would be enough here, but defining those would not hurt either.

what does 050, 080... and other magic numbers here mean? Why is everything getting multiplied by 0x70.

Signature · 1 line
~Vinod
#9 lore raw

PATCH 2/6 dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter

Dear Vinod Koul,

Quoted 31 lines · Marek Vasut
Quoted 30 lines

Dear Vinod Koul,

Quoted 28 lines · Shawn Guo
Quoted 27 lines

Let macros dma_is_apbh and apbh_is_old take mxs_dma as parameter to make the code easy to read.

---

 drivers/dma/mxs-dma.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)
drivers/dma/mxs-dma.c +2 -2
index bd27818..e801fbf 100644
@@ -38,10 +38,10 @@
 
 #define MXS_DMA_APBH		0
 #define MXS_DMA_APBX		1
 
-#define dma_is_apbh()		(mxs_dma->dev_id == MXS_DMA_APBH)
+#define dma_is_apbh(mxs_dma)	(mxs_dma->dev_id == MXS_DMA_APBH)
 
 #define APBH_VERSION_LATEST	3
 
-#define apbh_is_old()		(mxs_dma->version < APBH_VERSION_LATEST)
+#define apbh_is_old(mxs_dma)	(mxs_dma->version <
 APBH_VERSION_LATEST)
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/dma/mxs-dma.c line 55

Quoted 6 lines

#define HW_APBHX_CTRL0 0x000
#define BM_APBH_CTRL0_APB_BURST8_EN (1 << 29)

drivers/dma/mxs-dma.c +0 -0
@@ -54,10 +54,10 @@
 
 #define HW_APBH_VERSION				(cpu_is_mx23() ? 

0x3f0 :

Quoted 7 lines
Quoted 7 lines

0x800)

Quoted 5 lines

drivers/dma/mxs-dma.c

Quoted 5 lines
drivers/dma/mxs-dma.c +0 -2
 #define HW_APBX_VERSION				0x800
 #define BP_APBHX_VERSION_MAJOR			24
 
-#define HW_APBHX_CHn_NXTCMDAR(n) \
-	(((dma_is_apbh() && apbh_is_old()) ? 0x050 : 0x110) + (n) * 

0x70)

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

drivers/dma/mxs-dma.c line 62

Quoted 2 lines
drivers/dma/mxs-dma.c +0 -2
-#define HW_APBHX_CHn_SEMA(n) \
-	(((dma_is_apbh() && apbh_is_old()) ? 0x080 : 0x140) + (n) * 

0x70)

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

drivers/dma/mxs-dma.c line 60

Quoted 2 lines
drivers/dma/mxs-dma.c +2 -0
+#define HW_APBHX_CHn_NXTCMDAR(d, n) \
+	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x050 : 0x110) + (n) * 

0x70)

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

drivers/dma/mxs-dma.c line 62

Quoted 2 lines
drivers/dma/mxs-dma.c +2 -0
+#define HW_APBHX_CHn_SEMA(d, n) \
+	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x080 : 0x140) + (n) * 

0x70)

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

while at it, care to say what the above magic numbers mean. Isnt terrible clear to me.

Check the email above ;-) I think simple comment would be enough here, but defining those would not hurt either.

what does 050, 080... and other magic numbers here mean? Why is everything getting multiplied by 0x70.

Yep, I'm on the same boat with you. Check Shawn's reply to my mail, carrying the same concern. Well ... Shawn, I guess now that we're two, you better make another set of macros ;-)

Best regards,
Marek Vasut

author
#10 lore raw

PATCH 2/6 dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter

Quoted 4 lines · Marek Vasut

Yep, I'm on the same boat with you. Check Shawn's reply to my mail, carrying the same concern. Well ... Shawn, I guess now that we're two, you better make another set of macros ;-)

I still do not think we need to necessarily have another set of macros. I would take your suggestion to add a comment there.

/*
* The offset of NXTCMDAR register is different per both dma type and version,
* while stride for each channel is all the same 0x70.
*/

#define HW_APBHX_CHn_NXTCMDAR(d, n) \
        (((dma_is_apbh(d) && apbh_is_old(d)) ? 0x050 : 0x110) + (n) * 0x70)
#define HW_APBHX_CHn_SEMA(d, n) \
        (((dma_is_apbh(d) && apbh_is_old(d)) ? 0x080 : 0x140) + (n) * 0x70)

Regards,
Shawn

author
#11 lore raw

PATCH 3/6 dma: mxs-dma: make platform_device_id more generic

In reply to Shawn Guo

From: Dong Aisheng <[email protected]>

Rewrite mxs_dma_is_apbh and mxs_dma_is_apbx in order to support other SoCs like imx6q and reform the platform_device_id for the better further dt support.

---
 arch/arm/mach-mxs/devices/platform-dma.c |   14 ++--
 drivers/clk/mxs/clk-imx23.c              |    4 +-
 drivers/clk/mxs/clk-imx28.c              |    4 +-
 drivers/dma/mxs-dma.c                    |  115 ++++++++++++++++++++---------
 include/linux/fsl/mxs-dma.h              |   12 +---
 5 files changed, 93 insertions(+), 56 deletions(-)
arch/arm/mach-mxs/devices/platform-dma.c +8 -6
index 6a0202b..aff4813 100644
@@ -32,17 +32,19 @@ static struct platform_device *__init mxs_add_dma(const char *devid,
 
 static int __init mxs_add_mxs_dma(void)
 {
-	char *apbh = "mxs-dma-apbh";
-	char *apbx = "mxs-dma-apbx";
+	char *mx23_apbh = "imx23-dma-apbh";
+	char *mx23_apbx = "imx23-dma-apbx";
+	char *mx28_apbh = "imx28-dma-apbh";
+	char *mx28_apbx = "imx28-dma-apbx";
 
 	if (cpu_is_mx23()) {
-		mxs_add_dma(apbh, MX23_APBH_DMA_BASE_ADDR);
-		mxs_add_dma(apbx, MX23_APBX_DMA_BASE_ADDR);
+		mxs_add_dma(mx23_apbh, MX23_APBH_DMA_BASE_ADDR);
+		mxs_add_dma(mx23_apbx, MX23_APBX_DMA_BASE_ADDR);
 	}
 
 	if (cpu_is_mx28()) {
-		mxs_add_dma(apbh, MX28_APBH_DMA_BASE_ADDR);
-		mxs_add_dma(apbx, MX28_APBX_DMA_BASE_ADDR);
+		mxs_add_dma(mx28_apbh, MX28_APBH_DMA_BASE_ADDR);
+		mxs_add_dma(mx28_apbx, MX28_APBX_DMA_BASE_ADDR);
 	}
 
 	return 0;
drivers/clk/mxs/clk-imx23.c +2 -2
index 07fe1f1..96562f5 100644
@@ -81,14 +81,14 @@ static struct clk_lookup uart_lookups[] __initdata = {
 };
 
 static struct clk_lookup hbus_lookups[] __initdata = {
-	{ .dev_id = "mxs-dma-apbh", },
+	{ .dev_id = "imx23-dma-apbh", },
 	{ .dev_id = "80004000.dma-apbh", },
 };
 
 static struct clk_lookup xbus_lookups[] __initdata = {
 	{ .dev_id = "duart", .con_id = "apb_pclk"},
 	{ .dev_id = "80070000.serial", .con_id = "apb_pclk"},
-	{ .dev_id = "mxs-dma-apbx", },
+	{ .dev_id = "imx23-dma-apbx", },
 	{ .dev_id = "80024000.dma-apbx", },
 };
 
drivers/clk/mxs/clk-imx28.c +2 -2
index 92b6ce0..e18cac9 100644
@@ -127,14 +127,14 @@ static struct clk_lookup uart_lookups[] __initdata = {
 };
 
 static struct clk_lookup hbus_lookups[] __initdata = {
-	{ .dev_id = "mxs-dma-apbh", },
+	{ .dev_id = "imx28-dma-apbh", },
 	{ .dev_id = "80004000.dma-apbh", },
 };
 
 static struct clk_lookup xbus_lookups[] __initdata = {
 	{ .dev_id = "duart", .con_id = "apb_pclk"},
 	{ .dev_id = "80074000.serial", .con_id = "apb_pclk"},
-	{ .dev_id = "mxs-dma-apbx", },
+	{ .dev_id = "imx28-dma-apbx", },
 	{ .dev_id = "80024000.dma-apbx", },
 };
 
drivers/dma/mxs-dma.c +79 -36

174 lines not on this page · raw message

include/linux/fsl/mxs-dma.h +2 -10
index 203d7c4..55d8702 100644
@@ -15,14 +15,6 @@ struct mxs_dma_data {
 	int chan_irq;
 };
 
-static inline int mxs_dma_is_apbh(struct dma_chan *chan)
-{
-	return !strcmp(dev_name(chan->device->dev), "mxs-dma-apbh");
-}
-
-static inline int mxs_dma_is_apbx(struct dma_chan *chan)
-{
-	return !strcmp(dev_name(chan->device->dev), "mxs-dma-apbx");
-}
-
+extern int mxs_dma_is_apbh(struct dma_chan *chan);
+extern int mxs_dma_is_apbx(struct dma_chan *chan);
 #endif /* __MACH_MXS_DMA_H__ */
Signature · 1 line
1.7.5.4
#12 lore raw

PATCH 3/6 dma: mxs-dma: make platform_device_id more generic

Dear Shawn Guo,

Quoted 27 lines

From: Dong Aisheng <[email protected]>

Rewrite mxs_dma_is_apbh and mxs_dma_is_apbx in order to support other SoCs like imx6q and reform the platform_device_id for the better further dt support.

---
 arch/arm/mach-mxs/devices/platform-dma.c |   14 ++--
 drivers/clk/mxs/clk-imx23.c              |    4 +-
 drivers/clk/mxs/clk-imx28.c              |    4 +-
 drivers/dma/mxs-dma.c                    |  115
++++++++++++++++++++--------- include/linux/fsl/mxs-dma.h              |  
12 +---
 5 files changed, 93 insertions(+), 56 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-mxs/devices/platform-dma.c index 6a0202b..aff4813 100644

arch/arm/mach-mxs/devices/platform-dma.c static struct platform_device *__init mxs_add_dma(const · line 39

Quoted 10 lines
arch/arm/mach-mxs/devices/platform-dma.c +4 -2
@@ -32,17 +32,19 @@ static struct platform_device *__init mxs_add_dma(const
 char *devid,
 
 static int __init mxs_add_mxs_dma(void)
 {
-	char *apbh = "mxs-dma-apbh";
-	char *apbx = "mxs-dma-apbx";
+	char *mx23_apbh = "imx23-dma-apbh";
+	char *mx23_apbx = "imx23-dma-apbx";
+	char *mx28_apbh = "imx28-dma-apbh";
+	char *mx28_apbx = "imx28-dma-apbx";

Oh well ... :-)

author
#13 lore raw

PATCH 4/6 dma: mxs-dma: add device tree probe support

In reply to Shawn Guo

From: Dong Aisheng <[email protected]>

Cc Grant Likely <[email protected]>
Cc Rob Herring <[email protected]>
Cc Rob Landley <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Huang Shijie <[email protected]>
---
 .../devicetree/bindings/dma/fsl-mxs-dma.txt        |   19 +++++++++++++
 drivers/dma/mxs-dma.c                              |   29 ++++++++++++++++---
 2 files changed, 43 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt
Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt new file +19 -0
new file mode 100644
index 0000000..ded0398
@@ -0,0 +1,19 @@
+* Freescale MXS DMA
+
+Required properties:
+- compatible : Should be "fsl,<chip>-dma-apbh" or "fsl,<chip>-dma-apbx"
+- reg : Should contain registers location and length
+
+Supported chips:
+imx23, imx28.
+
+Examples:
+dma-apbh at 80004000 {
+	compatible = "fsl,imx28-dma-apbh";
+	reg = <0x80004000 2000>;
+};
+
+dma-apbx at 80024000 {
+	compatible = "fsl,imx28-dma-apbx";
+	reg = <0x80024000 2000>;
+};
drivers/dma/mxs-dma.c +24 -5
index 5d9813c..fe8c498 100644
@@ -22,8 +22,11 @@
 #include <linux/platform_device.h>
 #include <linux/dmaengine.h>
 #include <linux/delay.h>
+#include <linux/module.h>
 #include <linux/fsl/mxs-dma.h>
 #include <linux/stmp_device.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 #include <asm/irq.h>
 #include <mach/mxs.h>
@@ -173,6 +176,15 @@ static struct platform_device_id mxs_dma_ids[] = {
 	}
 };
 
+static const struct of_device_id mxs_dma_dt_ids[] = {
+	{ .compatible = "fsl,imx23-dma-apbh", .data = &mxs_dma_ids[0], },
+	{ .compatible = "fsl,imx23-dma-apbx", .data = &mxs_dma_ids[1], },
+	{ .compatible = "fsl,imx28-dma-apbh", .data = &mxs_dma_ids[2], },
+	{ .compatible = "fsl,imx28-dma-apbx", .data = &mxs_dma_ids[3], },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mxs_dma_dt_ids);
+
 static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan)
 {
 	return container_of(chan, struct mxs_dma_chan, chan);
@@ -648,10 +660,9 @@ err_out:
 
 static int __init mxs_dma_probe(struct platform_device *pdev)
 {
-	const struct platform_device_id *id_entry =
-				platform_get_device_id(pdev);
-	const struct mxs_dma_type *dma_type =
-			(struct mxs_dma_type *)id_entry->driver_data;
+	const struct platform_device_id *id_entry;
+	const struct of_device_id *of_id;
+	const struct mxs_dma_type *dma_type;
 	struct mxs_dma_engine *mxs_dma;
 	struct resource *iores;
 	int ret, i;
@@ -660,8 +671,15 @@ static int __init mxs_dma_probe(struct platform_device *pdev)
 	if (!mxs_dma)
 		return -ENOMEM;
 
-	mxs_dma->dev_id = dma_type->id;
+	of_id = of_match_device(mxs_dma_dt_ids, &pdev->dev);
+	if (of_id)
+		id_entry = of_id->data;
+	else
+		id_entry = platform_get_device_id(pdev);
+
+	dma_type = (struct mxs_dma_type *)id_entry->driver_data;
 	mxs_dma->type = dma_type->type;
+	mxs_dma->dev_id = dma_type->id;
 
 	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
@@ -747,6 +765,7 @@ err_request_region:
 static struct platform_driver mxs_dma_driver = {
 	.driver		= {
 		.name	= "mxs-dma",
+		.of_match_table = mxs_dma_dt_ids,
 	},
 	.id_table	= mxs_dma_ids,
 };
Signature · 1 line
1.7.5.4
#14 lore raw

PATCH 4/6 dma: mxs-dma: add device tree probe support

Dear Shawn Guo,

Quoted 10 lines

From: Dong Aisheng <[email protected]>

Cc Grant Likely <[email protected]>
Cc Rob Herring <[email protected]>
Cc Rob Landley <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Huang Shijie <[email protected]>
Quoted 98 lines
---
 .../devicetree/bindings/dma/fsl-mxs-dma.txt        |   19 +++++++++++++
 drivers/dma/mxs-dma.c                              |   29
++++++++++++++++--- 2 files changed, 43 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt
(quoted diff) +0 -0

b/Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt new file mode 100644
index 0000000..ded0398

Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt new file +19 -0
@@ -0,0 +1,19 @@
+* Freescale MXS DMA
+
+Required properties:
+- compatible : Should be "fsl,<chip>-dma-apbh" or "fsl,<chip>-dma-apbx"
+- reg : Should contain registers location and length
+
+Supported chips:
+imx23, imx28.
+
+Examples:
+dma-apbh at 80004000 {
+	compatible = "fsl,imx28-dma-apbh";
+	reg = <0x80004000 2000>;
+};
+
+dma-apbx at 80024000 {
+	compatible = "fsl,imx28-dma-apbx";
+	reg = <0x80024000 2000>;
+};
drivers/dma/mxs-dma.c +23 -5
index 5d9813c..fe8c498 100644
@@ -22,8 +22,11 @@
 #include <linux/platform_device.h>
 #include <linux/dmaengine.h>
 #include <linux/delay.h>
+#include <linux/module.h>
 #include <linux/fsl/mxs-dma.h>
 #include <linux/stmp_device.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 #include <asm/irq.h>
 #include <mach/mxs.h>
@@ -173,6 +176,15 @@ static struct platform_device_id mxs_dma_ids[] = {
 	}
 };
 
+static const struct of_device_id mxs_dma_dt_ids[] = {
+	{ .compatible = "fsl,imx23-dma-apbh", .data = &mxs_dma_ids[0], },
+	{ .compatible = "fsl,imx23-dma-apbx", .data = &mxs_dma_ids[1], },
+	{ .compatible = "fsl,imx28-dma-apbh", .data = &mxs_dma_ids[2], },
+	{ .compatible = "fsl,imx28-dma-apbx", .data = &mxs_dma_ids[3], },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mxs_dma_dt_ids);
+
 static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan)
 {
 	return container_of(chan, struct mxs_dma_chan, chan);
@@ -648,10 +660,9 @@ err_out:
 
 static int __init mxs_dma_probe(struct platform_device *pdev)
 {
-	const struct platform_device_id *id_entry =
-				platform_get_device_id(pdev);
-	const struct mxs_dma_type *dma_type =
-			(struct mxs_dma_type *)id_entry->driver_data;
+	const struct platform_device_id *id_entry;
+	const struct of_device_id *of_id;
+	const struct mxs_dma_type *dma_type;
 	struct mxs_dma_engine *mxs_dma;
 	struct resource *iores;
 	int ret, i;
@@ -660,8 +671,15 @@ static int __init mxs_dma_probe(struct platform_device
 *pdev) if (!mxs_dma)
 		return -ENOMEM;
 
-	mxs_dma->dev_id = dma_type->id;
+	of_id = of_match_device(mxs_dma_dt_ids, &pdev->dev);
+	if (of_id)
+		id_entry = of_id->data;
+	else
+		id_entry = platform_get_device_id(pdev);
+
+	dma_type = (struct mxs_dma_type *)id_entry->driver_data;
 	mxs_dma->type = dma_type->type;
+	mxs_dma->dev_id = dma_type->id;
 
 	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 

drivers/dma/mxs-dma.c err_request_region: · line 771

Quoted 7 lines
drivers/dma/mxs-dma.c +1 -0
@@ -747,6 +765,7 @@ err_request_region:
 static struct platform_driver mxs_dma_driver = {
 	.driver		= {
 		.name	= "mxs-dma",
+		.of_match_table = mxs_dma_dt_ids,
 	},
 	.id_table	= mxs_dma_ids,
 };

Best regards,
Marek Vasut

author
#15 lore raw

PATCH 5/6 ARM: mxs: do not add dma device by default

In reply to Shawn Guo

From: Dong Aisheng <[email protected]>

This will cause conflict when dt is enabled. So let each platform add dma devices respectively.

---
 arch/arm/mach-mxs/devices/platform-dma.c |   23 +----------------------
 arch/arm/mach-mxs/include/mach/common.h  |    3 +++
 arch/arm/mach-mxs/mm.c                   |    6 ++++++
 3 files changed, 10 insertions(+), 22 deletions(-)
arch/arm/mach-mxs/devices/platform-dma.c +1 -22
index aff4813..4682450 100644
@@ -14,7 +14,7 @@
 #include <mach/mx28.h>
 #include <mach/devices-common.h>
 
-static struct platform_device *__init mxs_add_dma(const char *devid,
+struct platform_device *__init mxs_add_dma(const char *devid,
 						resource_size_t base)
 {
 	struct resource res[] = {
@@ -29,24 +29,3 @@ static struct platform_device *__init mxs_add_dma(const char *devid,
 				res, ARRAY_SIZE(res), NULL, 0,
 				DMA_BIT_MASK(32));
 }
-
-static int __init mxs_add_mxs_dma(void)
-{
-	char *mx23_apbh = "imx23-dma-apbh";
-	char *mx23_apbx = "imx23-dma-apbx";
-	char *mx28_apbh = "imx28-dma-apbh";
-	char *mx28_apbx = "imx28-dma-apbx";
-
-	if (cpu_is_mx23()) {
-		mxs_add_dma(mx23_apbh, MX23_APBH_DMA_BASE_ADDR);
-		mxs_add_dma(mx23_apbx, MX23_APBX_DMA_BASE_ADDR);
-	}
-
-	if (cpu_is_mx28()) {
-		mxs_add_dma(mx28_apbh, MX28_APBH_DMA_BASE_ADDR);
-		mxs_add_dma(mx28_apbx, MX28_APBX_DMA_BASE_ADDR);
-	}
-
-	return 0;
-}
-arch_initcall(mxs_add_mxs_dma);
arch/arm/mach-mxs/include/mach/common.h +3 -0
index 84af61c..5f9a358 100644
@@ -31,4 +31,7 @@ extern void mx28_init_irq(void);
 
 extern void icoll_init_irq(void);
 
+extern struct platform_device *mxs_add_dma(const char *devid,
+						resource_size_t base);
+
 #endif /* __MACH_MXS_COMMON_H__ */
arch/arm/mach-mxs/mm.c +6 -0
index 67a384e..6af4371 100644
@@ -66,9 +66,15 @@ void __init mx28_init_irq(void)
 void __init mx23_soc_init(void)
 {
 	pinctrl_provide_dummies();
+
+	mxs_add_dma("imx23-dma-apbh", MX23_APBH_DMA_BASE_ADDR);
+	mxs_add_dma("imx23-dma-apbx", MX23_APBX_DMA_BASE_ADDR);
 }
 
 void __init mx28_soc_init(void)
 {
 	pinctrl_provide_dummies();
+
+	mxs_add_dma("imx28-dma-apbh", MX23_APBH_DMA_BASE_ADDR);
+	mxs_add_dma("imx28-dma-apbx", MX23_APBX_DMA_BASE_ADDR);
 }
Signature · 1 line
1.7.5.4
#16 lore raw

PATCH 5/6 ARM: mxs: do not add dma device by default

Dear Shawn Guo,

Quoted 10 lines

From: Dong Aisheng <[email protected]>

This will cause conflict when dt is enabled. So let each platform add dma devices respectively.

Ok, I see (ref. 3/5) ... this is good then, screw those nitpicks

Quoted 76 lines
---
 arch/arm/mach-mxs/devices/platform-dma.c |   23 +----------------------
 arch/arm/mach-mxs/include/mach/common.h  |    3 +++
 arch/arm/mach-mxs/mm.c                   |    6 ++++++
 3 files changed, 10 insertions(+), 22 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-mxs/devices/platform-dma.c index aff4813..4682450 100644

arch/arm/mach-mxs/devices/platform-dma.c +1 -22
@@ -14,7 +14,7 @@
 #include <mach/mx28.h>
 #include <mach/devices-common.h>
 
-static struct platform_device *__init mxs_add_dma(const char *devid,
+struct platform_device *__init mxs_add_dma(const char *devid,
 						resource_size_t base)
 {
 	struct resource res[] = {
@@ -29,24 +29,3 @@ static struct platform_device *__init mxs_add_dma(const
 char *devid, res, ARRAY_SIZE(res), NULL, 0,
 				DMA_BIT_MASK(32));
 }
-
-static int __init mxs_add_mxs_dma(void)
-{
-	char *mx23_apbh = "imx23-dma-apbh";
-	char *mx23_apbx = "imx23-dma-apbx";
-	char *mx28_apbh = "imx28-dma-apbh";
-	char *mx28_apbx = "imx28-dma-apbx";
-
-	if (cpu_is_mx23()) {
-		mxs_add_dma(mx23_apbh, MX23_APBH_DMA_BASE_ADDR);
-		mxs_add_dma(mx23_apbx, MX23_APBX_DMA_BASE_ADDR);
-	}
-
-	if (cpu_is_mx28()) {
-		mxs_add_dma(mx28_apbh, MX28_APBH_DMA_BASE_ADDR);
-		mxs_add_dma(mx28_apbx, MX28_APBX_DMA_BASE_ADDR);
-	}
-
-	return 0;
-}
-arch_initcall(mxs_add_mxs_dma);
(quoted diff) +0 -0

b/arch/arm/mach-mxs/include/mach/common.h index 84af61c..5f9a358 100644

arch/arm/mach-mxs/include/mach/common.h +3 -0
@@ -31,4 +31,7 @@ extern void mx28_init_irq(void);
 
 extern void icoll_init_irq(void);
 
+extern struct platform_device *mxs_add_dma(const char *devid,
+						resource_size_t base);
+
 #endif /* __MACH_MXS_COMMON_H__ */
arch/arm/mach-mxs/mm.c +6 -0
index 67a384e..6af4371 100644
@@ -66,9 +66,15 @@ void __init mx28_init_irq(void)
 void __init mx23_soc_init(void)
 {
 	pinctrl_provide_dummies();
+
+	mxs_add_dma("imx23-dma-apbh", MX23_APBH_DMA_BASE_ADDR);
+	mxs_add_dma("imx23-dma-apbx", MX23_APBX_DMA_BASE_ADDR);
 }
 
 void __init mx28_soc_init(void)
 {
 	pinctrl_provide_dummies();
+
+	mxs_add_dma("imx28-dma-apbh", MX23_APBH_DMA_BASE_ADDR);
+	mxs_add_dma("imx28-dma-apbx", MX23_APBX_DMA_BASE_ADDR);
 }
author
#17 lore raw

PATCH 6/6 ARM: mxs: add mxs-dma dt support

In reply to Shawn Guo

From: Dong Aisheng <[email protected]>

---
 arch/arm/boot/dts/imx23.dtsi |    4 ++--
 arch/arm/boot/dts/imx28.dtsi |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/imx23.dtsi +2 -2
index fb09ccd..a85ef55 100644
@@ -42,8 +42,8 @@
 			};
 
 			dma-apbh at 80004000 {
+				compatible = "fsl,imx23-dma-apbh";
 				reg = <0x80004000 2000>;
-				status = "disabled";
 			};
 
 			ecc at 80008000 {
@@ -97,8 +97,8 @@
 			};
 
 			dma-apbx at 80024000 {
+				compatible = "fsl,imx23-dma-apbx";
 				reg = <0x80024000 2000>;
-				status = "disabled";
 			};
 
 			dcp at 80028000 {
arch/arm/boot/dts/imx28.dtsi +2 -2
index 5daf757..a17fbfc 100644
@@ -48,8 +48,8 @@
 			};
 
 			dma-apbh at 80004000 {
+				compatible = "fsl,imx28-dma-apbh";
 				reg = <0x80004000 2000>;
-				status = "disabled";
 			};
 
 			perfmon at 80006000 {
@@ -140,8 +140,8 @@
 			};
 
 			dma-apbx at 80024000 {
+				compatible = "fsl,imx28-dma-apbx";
 				reg = <0x80024000 2000>;
-				status = "disabled";
 			};
 
 			dcp at 80028000 {
Signature · 1 line
1.7.5.4
#18 lore raw

PATCH 6/6 ARM: mxs: add mxs-dma dt support

Dear Shawn Guo,

Quoted 7 lines

From: Dong Aisheng <[email protected]>

Cc Grant Likely <[email protected]>
Cc Rob Herring <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Huang Shijie <[email protected]>
Quoted 46 lines
---
 arch/arm/boot/dts/imx23.dtsi |    4 ++--
 arch/arm/boot/dts/imx28.dtsi |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/imx23.dtsi +2 -2
index fb09ccd..a85ef55 100644
@@ -42,8 +42,8 @@
 			};
 
 			dma-apbh at 80004000 {
+				compatible = "fsl,imx23-dma-apbh";
 				reg = <0x80004000 2000>;
-				status = "disabled";
 			};
 
 			ecc at 80008000 {
@@ -97,8 +97,8 @@
 			};
 
 			dma-apbx at 80024000 {
+				compatible = "fsl,imx23-dma-apbx";
 				reg = <0x80024000 2000>;
-				status = "disabled";
 			};
 
 			dcp at 80028000 {
arch/arm/boot/dts/imx28.dtsi +1 -1
index 5daf757..a17fbfc 100644
@@ -48,8 +48,8 @@
 			};
 
 			dma-apbh at 80004000 {
+				compatible = "fsl,imx28-dma-apbh";
 				reg = <0x80004000 2000>;
-				status = "disabled";
 			};
 
 			perfmon at 80006000 {

arch/arm/boot/dts/imx28.dtsi line 147

Quoted 9 lines
arch/arm/boot/dts/imx28.dtsi +1 -1
@@ -140,8 +140,8 @@
 			};
 
 			dma-apbx at 80024000 {
+				compatible = "fsl,imx28-dma-apbx";
 				reg = <0x80024000 2000>;
-				status = "disabled";
 			};
 
 			dcp at 80028000 {

Best regards,
Marek Vasut