* [PATCH 0/6] Add device tree support for mxs-dma
@ 2012-05-07 14:23 Shawn Guo
2012-05-07 14:23 ` [PATCH 1/6] dma: mxs-dma: use global stmp_device functionality Shawn Guo
` (5 more replies)
0 siblings, 6 replies; 19+ messages in thread
From: Shawn Guo @ 2012-05-07 14:23 UTC (permalink / raw)
To: linux-arm-kernel
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
--
1.7.5.4
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 1/6] dma: mxs-dma: use global stmp_device functionality
2012-05-07 14:23 [PATCH 0/6] Add device tree support for mxs-dma Shawn Guo
@ 2012-05-07 14:23 ` Shawn Guo
2012-05-07 23:34 ` Marek Vasut
2012-05-07 14:23 ` [PATCH 2/6] dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter Shawn Guo
` (4 subsequent siblings)
5 siblings, 1 reply; 19+ messages in thread
From: Shawn Guo @ 2012-05-07 14:23 UTC (permalink / raw)
To: linux-arm-kernel
From: Dong Aisheng <dong.aisheng@linaro.org>
This can get rid of the mach-dependency.
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Huang Shijie <b32955@freescale.com>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Wolfram Sang <w.sang@pengutronix.de>
---
drivers/dma/Kconfig | 1 +
drivers/dma/mxs-dma.c | 26 +++++++++++++-------------
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index ef378b5..aadeb5b 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -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
diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index 655d4ce..bd27818 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -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);
--
1.7.5.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 2/6] dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter
2012-05-07 14:23 [PATCH 0/6] Add device tree support for mxs-dma Shawn Guo
2012-05-07 14:23 ` [PATCH 1/6] dma: mxs-dma: use global stmp_device functionality Shawn Guo
@ 2012-05-07 14:23 ` Shawn Guo
2012-05-07 23:37 ` Marek Vasut
2012-05-09 8:40 ` Vinod Koul
2012-05-07 14:23 ` [PATCH 3/6] dma: mxs-dma: make platform_device_id more generic Shawn Guo
` (3 subsequent siblings)
5 siblings, 2 replies; 19+ messages in thread
From: Shawn Guo @ 2012-05-07 14:23 UTC (permalink / raw)
To: linux-arm-kernel
Let macros dma_is_apbh and apbh_is_old take mxs_dma as parameter
to make the code easy to read.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/dma/mxs-dma.c | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index bd27818..e801fbf 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -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,
--
1.7.5.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 3/6] dma: mxs-dma: make platform_device_id more generic
2012-05-07 14:23 [PATCH 0/6] Add device tree support for mxs-dma Shawn Guo
2012-05-07 14:23 ` [PATCH 1/6] dma: mxs-dma: use global stmp_device functionality Shawn Guo
2012-05-07 14:23 ` [PATCH 2/6] dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter Shawn Guo
@ 2012-05-07 14:23 ` Shawn Guo
2012-05-07 23:38 ` Marek Vasut
2012-05-07 14:23 ` [PATCH 4/6] dma: mxs-dma: add device tree probe support Shawn Guo
` (2 subsequent siblings)
5 siblings, 1 reply; 19+ messages in thread
From: Shawn Guo @ 2012-05-07 14:23 UTC (permalink / raw)
To: linux-arm-kernel
From: Dong Aisheng <dong.aisheng@linaro.org>
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.
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Huang Shijie <b32955@freescale.com>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
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(-)
diff --git a/arch/arm/mach-mxs/devices/platform-dma.c b/arch/arm/mach-mxs/devices/platform-dma.c
index 6a0202b..aff4813 100644
--- a/arch/arm/mach-mxs/devices/platform-dma.c
+++ b/arch/arm/mach-mxs/devices/platform-dma.c
@@ -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;
diff --git a/drivers/clk/mxs/clk-imx23.c b/drivers/clk/mxs/clk-imx23.c
index 07fe1f1..96562f5 100644
--- a/drivers/clk/mxs/clk-imx23.c
+++ b/drivers/clk/mxs/clk-imx23.c
@@ -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", },
};
diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c
index 92b6ce0..e18cac9 100644
--- a/drivers/clk/mxs/clk-imx28.c
+++ b/drivers/clk/mxs/clk-imx28.c
@@ -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", },
};
diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index e801fbf..5d9813c 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -36,12 +36,8 @@
* dma can program the controller registers of peripheral devices.
*/
-#define MXS_DMA_APBH 0
-#define MXS_DMA_APBX 1
-#define dma_is_apbh(mxs_dma) (mxs_dma->dev_id == MXS_DMA_APBH)
-
-#define APBH_VERSION_LATEST 3
-#define apbh_is_old(mxs_dma) (mxs_dma->version < APBH_VERSION_LATEST)
+#define dma_is_apbh(mxs_dma) (mxs_dma->type == MXS_DMA_APBH)
+#define apbh_is_old(mxs_dma) (mxs_dma->dev_id == IMX23_DMA)
#define HW_APBHX_CTRL0 0x000
#define BM_APBH_CTRL0_APB_BURST8_EN (1 << 29)
@@ -51,9 +47,6 @@
#define HW_APBHX_CTRL2 0x020
#define HW_APBHX_CHANNEL_CTRL 0x030
#define BP_APBHX_CHANNEL_CTRL_RESET_CHANNEL 16
-#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(d, n) \
(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x050 : 0x110) + (n) * 0x70)
#define HW_APBHX_CHn_SEMA(d, n) \
@@ -121,9 +114,19 @@ struct mxs_dma_chan {
#define MXS_DMA_CHANNELS 16
#define MXS_DMA_CHANNELS_MASK 0xffff
+enum mxs_dma_devtype {
+ MXS_DMA_APBH,
+ MXS_DMA_APBX,
+};
+
+enum mxs_dma_id {
+ IMX23_DMA,
+ IMX28_DMA,
+};
+
struct mxs_dma_engine {
- int dev_id;
- unsigned int version;
+ enum mxs_dma_id dev_id;
+ enum mxs_dma_devtype type;
void __iomem *base;
struct clk *clk;
struct dma_device dma_device;
@@ -131,6 +134,66 @@ struct mxs_dma_engine {
struct mxs_dma_chan mxs_chans[MXS_DMA_CHANNELS];
};
+struct mxs_dma_type {
+ enum mxs_dma_id id;
+ enum mxs_dma_devtype type;
+};
+
+static struct mxs_dma_type mxs_dma_types[] = {
+ {
+ .id = IMX23_DMA,
+ .type = MXS_DMA_APBH,
+ }, {
+ .id = IMX23_DMA,
+ .type = MXS_DMA_APBX,
+ }, {
+ .id = IMX28_DMA,
+ .type = MXS_DMA_APBH,
+ }, {
+ .id = IMX28_DMA,
+ .type = MXS_DMA_APBX,
+ }
+};
+
+static struct platform_device_id mxs_dma_ids[] = {
+ {
+ .name = "imx23-dma-apbh",
+ .driver_data = (kernel_ulong_t) &mxs_dma_types[0],
+ }, {
+ .name = "imx23-dma-apbx",
+ .driver_data = (kernel_ulong_t) &mxs_dma_types[1],
+ }, {
+ .name = "imx28-dma-apbh",
+ .driver_data = (kernel_ulong_t) &mxs_dma_types[2],
+ }, {
+ .name = "imx28-dma-apbx",
+ .driver_data = (kernel_ulong_t) &mxs_dma_types[3],
+ }, {
+ /* end of list */
+ }
+};
+
+static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan)
+{
+ return container_of(chan, struct mxs_dma_chan, chan);
+}
+
+int mxs_dma_is_apbh(struct dma_chan *chan)
+{
+ struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan);
+ struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma;
+
+ return dma_is_apbh(mxs_dma);
+}
+
+int mxs_dma_is_apbx(struct dma_chan *chan)
+{
+ struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan);
+ struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma;
+
+ return !dma_is_apbh(mxs_dma);
+}
+
static void mxs_dma_reset_chan(struct mxs_dma_chan *mxs_chan)
{
struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma;
@@ -194,11 +257,6 @@ static void mxs_dma_resume_chan(struct mxs_dma_chan *mxs_chan)
mxs_chan->status = DMA_IN_PROGRESS;
}
-static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan)
-{
- return container_of(chan, struct mxs_dma_chan, chan);
-}
-
static dma_cookie_t mxs_dma_tx_submit(struct dma_async_tx_descriptor *tx)
{
return dma_cookie_assign(tx);
@@ -571,12 +629,6 @@ static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma)
if (ret)
goto err_out;
- /* only major version matters */
- mxs_dma->version = readl(mxs_dma->base +
- ((mxs_dma->dev_id == MXS_DMA_APBX) ?
- HW_APBX_VERSION : HW_APBH_VERSION)) >>
- BP_APBHX_VERSION_MAJOR;
-
/* enable apbh burst */
if (dma_is_apbh(mxs_dma)) {
writel(BM_APBH_CTRL0_APB_BURST_EN,
@@ -598,6 +650,8 @@ 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;
struct mxs_dma_engine *mxs_dma;
struct resource *iores;
int ret, i;
@@ -606,7 +660,8 @@ static int __init mxs_dma_probe(struct platform_device *pdev)
if (!mxs_dma)
return -ENOMEM;
- mxs_dma->dev_id = id_entry->driver_data;
+ mxs_dma->dev_id = dma_type->id;
+ mxs_dma->type = dma_type->type;
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -689,23 +744,11 @@ err_request_region:
return ret;
}
-static struct platform_device_id mxs_dma_type[] = {
- {
- .name = "mxs-dma-apbh",
- .driver_data = MXS_DMA_APBH,
- }, {
- .name = "mxs-dma-apbx",
- .driver_data = MXS_DMA_APBX,
- }, {
- /* end of list */
- }
-};
-
static struct platform_driver mxs_dma_driver = {
.driver = {
.name = "mxs-dma",
},
- .id_table = mxs_dma_type,
+ .id_table = mxs_dma_ids,
};
static int __init mxs_dma_module_init(void)
diff --git a/include/linux/fsl/mxs-dma.h b/include/linux/fsl/mxs-dma.h
index 203d7c4..55d8702 100644
--- a/include/linux/fsl/mxs-dma.h
+++ b/include/linux/fsl/mxs-dma.h
@@ -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__ */
--
1.7.5.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 4/6] dma: mxs-dma: add device tree probe support
2012-05-07 14:23 [PATCH 0/6] Add device tree support for mxs-dma Shawn Guo
` (2 preceding siblings ...)
2012-05-07 14:23 ` [PATCH 3/6] dma: mxs-dma: make platform_device_id more generic Shawn Guo
@ 2012-05-07 14:23 ` Shawn Guo
2012-05-07 23:39 ` Marek Vasut
2012-05-07 14:23 ` [PATCH 5/6] ARM: mxs: do not add dma device by default Shawn Guo
2012-05-07 14:23 ` [PATCH 6/6] ARM: mxs: add mxs-dma dt support Shawn Guo
5 siblings, 1 reply; 19+ messages in thread
From: Shawn Guo @ 2012-05-07 14:23 UTC (permalink / raw)
To: linux-arm-kernel
From: Dong Aisheng <dong.aisheng@linaro.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Rob Landley <rob@landley.net>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Huang Shijie <b32955@freescale.com>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
.../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
diff --git a/Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt b/Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt
new file mode 100644
index 0000000..ded0398
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt
@@ -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>;
+};
diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index 5d9813c..fe8c498 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -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,
};
--
1.7.5.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 5/6] ARM: mxs: do not add dma device by default
2012-05-07 14:23 [PATCH 0/6] Add device tree support for mxs-dma Shawn Guo
` (3 preceding siblings ...)
2012-05-07 14:23 ` [PATCH 4/6] dma: mxs-dma: add device tree probe support Shawn Guo
@ 2012-05-07 14:23 ` Shawn Guo
2012-05-07 23:40 ` Marek Vasut
2012-05-07 14:23 ` [PATCH 6/6] ARM: mxs: add mxs-dma dt support Shawn Guo
5 siblings, 1 reply; 19+ messages in thread
From: Shawn Guo @ 2012-05-07 14:23 UTC (permalink / raw)
To: linux-arm-kernel
From: Dong Aisheng <dong.aisheng@linaro.org>
This will cause conflict when dt is enabled.
So let each platform add dma devices respectively.
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Huang Shijie <b32955@freescale.com>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
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(-)
diff --git a/arch/arm/mach-mxs/devices/platform-dma.c b/arch/arm/mach-mxs/devices/platform-dma.c
index aff4813..4682450 100644
--- a/arch/arm/mach-mxs/devices/platform-dma.c
+++ b/arch/arm/mach-mxs/devices/platform-dma.c
@@ -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);
diff --git a/arch/arm/mach-mxs/include/mach/common.h b/arch/arm/mach-mxs/include/mach/common.h
index 84af61c..5f9a358 100644
--- a/arch/arm/mach-mxs/include/mach/common.h
+++ b/arch/arm/mach-mxs/include/mach/common.h
@@ -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__ */
diff --git a/arch/arm/mach-mxs/mm.c b/arch/arm/mach-mxs/mm.c
index 67a384e..6af4371 100644
--- a/arch/arm/mach-mxs/mm.c
+++ b/arch/arm/mach-mxs/mm.c
@@ -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);
}
--
1.7.5.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 6/6] ARM: mxs: add mxs-dma dt support
2012-05-07 14:23 [PATCH 0/6] Add device tree support for mxs-dma Shawn Guo
` (4 preceding siblings ...)
2012-05-07 14:23 ` [PATCH 5/6] ARM: mxs: do not add dma device by default Shawn Guo
@ 2012-05-07 14:23 ` Shawn Guo
2012-05-07 23:40 ` Marek Vasut
5 siblings, 1 reply; 19+ messages in thread
From: Shawn Guo @ 2012-05-07 14:23 UTC (permalink / raw)
To: linux-arm-kernel
From: Dong Aisheng <dong.aisheng@linaro.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Huang Shijie <b32955@freescale.com>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
arch/arm/boot/dts/imx23.dtsi | 4 ++--
arch/arm/boot/dts/imx28.dtsi | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm/boot/dts/imx23.dtsi b/arch/arm/boot/dts/imx23.dtsi
index fb09ccd..a85ef55 100644
--- a/arch/arm/boot/dts/imx23.dtsi
+++ b/arch/arm/boot/dts/imx23.dtsi
@@ -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 {
diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index 5daf757..a17fbfc 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -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 {
--
1.7.5.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 1/6] dma: mxs-dma: use global stmp_device functionality
2012-05-07 14:23 ` [PATCH 1/6] dma: mxs-dma: use global stmp_device functionality Shawn Guo
@ 2012-05-07 23:34 ` Marek Vasut
0 siblings, 0 replies; 19+ messages in thread
From: Marek Vasut @ 2012-05-07 23:34 UTC (permalink / raw)
To: linux-arm-kernel
Dear Shawn Guo,
> From: Dong Aisheng <dong.aisheng@linaro.org>
>
> This can get rid of the mach-dependency.
>
> Cc: Vinod Koul <vinod.koul@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Huang Shijie <b32955@freescale.com>
> Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Acked-by: Marek Vasut <marex@denx.de>
> Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> Acked-by: Wolfram Sang <w.sang@pengutronix.de>
> ---
> drivers/dma/Kconfig | 1 +
> drivers/dma/mxs-dma.c | 26 +++++++++++++-------------
> 2 files changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
> index ef378b5..aadeb5b 100644
> --- a/drivers/dma/Kconfig
> +++ b/drivers/dma/Kconfig
> @@ -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
> diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
> index 655d4ce..bd27818 100644
> --- a/drivers/dma/mxs-dma.c
> +++ b/drivers/dma/mxs-dma.c
> @@ -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);
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 2/6] dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter
2012-05-07 14:23 ` [PATCH 2/6] dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter Shawn Guo
@ 2012-05-07 23:37 ` Marek Vasut
2012-05-08 14:03 ` Shawn Guo
2012-05-09 8:40 ` Vinod Koul
1 sibling, 1 reply; 19+ messages in thread
From: Marek Vasut @ 2012-05-07 23:37 UTC (permalink / raw)
To: linux-arm-kernel
Dear Shawn Guo,
> Let macros dma_is_apbh and apbh_is_old take mxs_dma as parameter
> to make the code easy to read.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
> drivers/dma/mxs-dma.c | 24 ++++++++++++------------
> 1 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
> index bd27818..e801fbf 100644
> --- a/drivers/dma/mxs-dma.c
> +++ b/drivers/dma/mxs-dma.c
> @@ -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)
Well ... if you got rid of the above magic values, it'd be cool ;-)
Otherwise...
Acked-by: Marek Vasut <marex@denx.de>
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 3/6] dma: mxs-dma: make platform_device_id more generic
2012-05-07 14:23 ` [PATCH 3/6] dma: mxs-dma: make platform_device_id more generic Shawn Guo
@ 2012-05-07 23:38 ` Marek Vasut
0 siblings, 0 replies; 19+ messages in thread
From: Marek Vasut @ 2012-05-07 23:38 UTC (permalink / raw)
To: linux-arm-kernel
Dear Shawn Guo,
> From: Dong Aisheng <dong.aisheng@linaro.org>
>
> 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.
>
> Cc: Vinod Koul <vinod.koul@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Huang Shijie <b32955@freescale.com>
> Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
> Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
> 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(-)
>
> diff --git a/arch/arm/mach-mxs/devices/platform-dma.c
> b/arch/arm/mach-mxs/devices/platform-dma.c index 6a0202b..aff4813 100644
> --- a/arch/arm/mach-mxs/devices/platform-dma.c
> +++ b/arch/arm/mach-mxs/devices/platform-dma.c
> @@ -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 ... :-)
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 4/6] dma: mxs-dma: add device tree probe support
2012-05-07 14:23 ` [PATCH 4/6] dma: mxs-dma: add device tree probe support Shawn Guo
@ 2012-05-07 23:39 ` Marek Vasut
0 siblings, 0 replies; 19+ messages in thread
From: Marek Vasut @ 2012-05-07 23:39 UTC (permalink / raw)
To: linux-arm-kernel
Dear Shawn Guo,
> From: Dong Aisheng <dong.aisheng@linaro.org>
>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Cc: Rob Landley <rob@landley.net>
> Cc: Vinod Koul <vinod.koul@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Huang Shijie <b32955@freescale.com>
> Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Acked-by: Marek Vasut <marex@denx.de>
> Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
> .../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
>
> diff --git a/Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt
> b/Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt new file mode
> 100644
> index 0000000..ded0398
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt
> @@ -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>;
> +};
> diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
> index 5d9813c..fe8c498 100644
> --- a/drivers/dma/mxs-dma.c
> +++ b/drivers/dma/mxs-dma.c
> @@ -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,
> };
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 5/6] ARM: mxs: do not add dma device by default
2012-05-07 14:23 ` [PATCH 5/6] ARM: mxs: do not add dma device by default Shawn Guo
@ 2012-05-07 23:40 ` Marek Vasut
0 siblings, 0 replies; 19+ messages in thread
From: Marek Vasut @ 2012-05-07 23:40 UTC (permalink / raw)
To: linux-arm-kernel
Dear Shawn Guo,
> From: Dong Aisheng <dong.aisheng@linaro.org>
>
> This will cause conflict when dt is enabled.
> So let each platform add dma devices respectively.
>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Huang Shijie <b32955@freescale.com>
> Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
> Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Ok, I see (ref. 3/5) ... this is good then, screw those nitpicks
Acked-by: Marek Vasut <marex@denx.de>
> ---
> 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(-)
>
> diff --git a/arch/arm/mach-mxs/devices/platform-dma.c
> b/arch/arm/mach-mxs/devices/platform-dma.c index aff4813..4682450 100644
> --- a/arch/arm/mach-mxs/devices/platform-dma.c
> +++ b/arch/arm/mach-mxs/devices/platform-dma.c
> @@ -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);
> diff --git a/arch/arm/mach-mxs/include/mach/common.h
> b/arch/arm/mach-mxs/include/mach/common.h index 84af61c..5f9a358 100644
> --- a/arch/arm/mach-mxs/include/mach/common.h
> +++ b/arch/arm/mach-mxs/include/mach/common.h
> @@ -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__ */
> diff --git a/arch/arm/mach-mxs/mm.c b/arch/arm/mach-mxs/mm.c
> index 67a384e..6af4371 100644
> --- a/arch/arm/mach-mxs/mm.c
> +++ b/arch/arm/mach-mxs/mm.c
> @@ -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);
> }
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 6/6] ARM: mxs: add mxs-dma dt support
2012-05-07 14:23 ` [PATCH 6/6] ARM: mxs: add mxs-dma dt support Shawn Guo
@ 2012-05-07 23:40 ` Marek Vasut
0 siblings, 0 replies; 19+ messages in thread
From: Marek Vasut @ 2012-05-07 23:40 UTC (permalink / raw)
To: linux-arm-kernel
Dear Shawn Guo,
> From: Dong Aisheng <dong.aisheng@linaro.org>
>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Huang Shijie <b32955@freescale.com>
> Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Acked-by: Marek Vasut <marex@denx.de>
> Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
> arch/arm/boot/dts/imx23.dtsi | 4 ++--
> arch/arm/boot/dts/imx28.dtsi | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/boot/dts/imx23.dtsi b/arch/arm/boot/dts/imx23.dtsi
> index fb09ccd..a85ef55 100644
> --- a/arch/arm/boot/dts/imx23.dtsi
> +++ b/arch/arm/boot/dts/imx23.dtsi
> @@ -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 {
> diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
> index 5daf757..a17fbfc 100644
> --- a/arch/arm/boot/dts/imx28.dtsi
> +++ b/arch/arm/boot/dts/imx28.dtsi
> @@ -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 {
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 2/6] dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter
2012-05-07 23:37 ` Marek Vasut
@ 2012-05-08 14:03 ` Shawn Guo
0 siblings, 0 replies; 19+ messages in thread
From: Shawn Guo @ 2012-05-08 14:03 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, May 08, 2012 at 01:37:00AM +0200, Marek Vasut wrote:
> > #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)
>
> 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.
--
Regards,
Shawn
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 2/6] dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter
2012-05-07 14:23 ` [PATCH 2/6] dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter Shawn Guo
2012-05-07 23:37 ` Marek Vasut
@ 2012-05-09 8:40 ` Vinod Koul
2012-05-09 9:00 ` Marek Vasut
1 sibling, 1 reply; 19+ messages in thread
From: Vinod Koul @ 2012-05-09 8:40 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 2012-05-07 at 22:23 +0800, Shawn Guo wrote:
> Let macros dma_is_apbh and apbh_is_old take mxs_dma as parameter
> to make the code easy to read.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
> drivers/dma/mxs-dma.c | 24 ++++++++++++------------
> 1 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
> index bd27818..e801fbf 100644
> --- a/drivers/dma/mxs-dma.c
> +++ b/drivers/dma/mxs-dma.c
> @@ -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)
while at it, care to say what the above magic numbers mean. Isnt
terrible clear to me.
>
> /*
> * 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,
--
~Vinod
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 2/6] dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter
2012-05-09 8:40 ` Vinod Koul
@ 2012-05-09 9:00 ` Marek Vasut
2012-05-09 9:02 ` Vinod Koul
0 siblings, 1 reply; 19+ messages in thread
From: Marek Vasut @ 2012-05-09 9:00 UTC (permalink / raw)
To: linux-arm-kernel
Dear Vinod Koul,
> On Mon, 2012-05-07 at 22:23 +0800, Shawn Guo wrote:
> > Let macros dma_is_apbh and apbh_is_old take mxs_dma as parameter
> > to make the code easy to read.
> >
> > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > ---
> >
> > drivers/dma/mxs-dma.c | 24 ++++++++++++------------
> > 1 files changed, 12 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
> > index bd27818..e801fbf 100644
> > --- a/drivers/dma/mxs-dma.c
> > +++ b/drivers/dma/mxs-dma.c
> > @@ -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)
>
> 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.
>
> > /*
> >
> > * 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,
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 2/6] dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter
2012-05-09 9:00 ` Marek Vasut
@ 2012-05-09 9:02 ` Vinod Koul
2012-05-09 9:16 ` Marek Vasut
0 siblings, 1 reply; 19+ messages in thread
From: Vinod Koul @ 2012-05-09 9:02 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, 2012-05-09 at 11:00 +0200, Marek Vasut wrote:
> Dear Vinod Koul,
>
> > On Mon, 2012-05-07 at 22:23 +0800, Shawn Guo wrote:
> > > Let macros dma_is_apbh and apbh_is_old take mxs_dma as parameter
> > > to make the code easy to read.
> > >
> > > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > > ---
> > >
> > > drivers/dma/mxs-dma.c | 24 ++++++++++++------------
> > > 1 files changed, 12 insertions(+), 12 deletions(-)
> > >
> > > diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
> > > index bd27818..e801fbf 100644
> > > --- a/drivers/dma/mxs-dma.c
> > > +++ b/drivers/dma/mxs-dma.c
> > > @@ -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)
> >
> > 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.
--
~Vinod
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 2/6] dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter
2012-05-09 9:02 ` Vinod Koul
@ 2012-05-09 9:16 ` Marek Vasut
2012-05-09 9:32 ` Shawn Guo
0 siblings, 1 reply; 19+ messages in thread
From: Marek Vasut @ 2012-05-09 9:16 UTC (permalink / raw)
To: linux-arm-kernel
Dear Vinod Koul,
> On Wed, 2012-05-09 at 11:00 +0200, Marek Vasut wrote:
> > Dear Vinod Koul,
> >
> > > On Mon, 2012-05-07 at 22:23 +0800, Shawn Guo wrote:
> > > > Let macros dma_is_apbh and apbh_is_old take mxs_dma as parameter
> > > > to make the code easy to read.
> > > >
> > > > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > > > ---
> > > >
> > > > drivers/dma/mxs-dma.c | 24 ++++++++++++------------
> > > > 1 files changed, 12 insertions(+), 12 deletions(-)
> > > >
> > > > diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
> > > > index bd27818..e801fbf 100644
> > > > --- a/drivers/dma/mxs-dma.c
> > > > +++ b/drivers/dma/mxs-dma.c
> > > > @@ -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)
> > >
> > > 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
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 2/6] dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter
2012-05-09 9:16 ` Marek Vasut
@ 2012-05-09 9:32 ` Shawn Guo
0 siblings, 0 replies; 19+ messages in thread
From: Shawn Guo @ 2012-05-09 9:32 UTC (permalink / raw)
To: linux-arm-kernel
On 9 May 2012 17:16, Marek Vasut <marex@denx.de> wrote:
> 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
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2012-05-09 9:32 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-07 14:23 [PATCH 0/6] Add device tree support for mxs-dma Shawn Guo
2012-05-07 14:23 ` [PATCH 1/6] dma: mxs-dma: use global stmp_device functionality Shawn Guo
2012-05-07 23:34 ` Marek Vasut
2012-05-07 14:23 ` [PATCH 2/6] dma: mxs-dma: let dma_is_apbh and apbh_is_old take parameter Shawn Guo
2012-05-07 23:37 ` Marek Vasut
2012-05-08 14:03 ` Shawn Guo
2012-05-09 8:40 ` Vinod Koul
2012-05-09 9:00 ` Marek Vasut
2012-05-09 9:02 ` Vinod Koul
2012-05-09 9:16 ` Marek Vasut
2012-05-09 9:32 ` Shawn Guo
2012-05-07 14:23 ` [PATCH 3/6] dma: mxs-dma: make platform_device_id more generic Shawn Guo
2012-05-07 23:38 ` Marek Vasut
2012-05-07 14:23 ` [PATCH 4/6] dma: mxs-dma: add device tree probe support Shawn Guo
2012-05-07 23:39 ` Marek Vasut
2012-05-07 14:23 ` [PATCH 5/6] ARM: mxs: do not add dma device by default Shawn Guo
2012-05-07 23:40 ` Marek Vasut
2012-05-07 14:23 ` [PATCH 6/6] ARM: mxs: add mxs-dma dt support Shawn Guo
2012-05-07 23:40 ` Marek Vasut
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.