linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] imx-sdma: patches when I enable imx6q sabrelite audio
@ 2012-01-13  3:09 Richard Zhao
  2012-01-13  3:09 ` [PATCH v2 1/6] dma/imx-sdma: let sdma_run_channel call sdma_enable_channel Richard Zhao
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Richard Zhao @ 2012-01-13  3:09 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: dan.j.williams, vinod.koul, shawn.guo, kernel, eric.miao, patches

[PATCH v2 1/6] dma/imx-sdma: let sdma_run_channel call
[PATCH v2 2/6] dma/imx-sdma: use readl_relaxed/writel_relaxed and
[PATCH v2 3/6] dma/imx-sdma: call sdma_set_channel_priority after
[PATCH v2 4/6] dma/imx-sdma: move clk_enable out of
[PATCH v2 5/6] dma/imx-sdma: use num_events to validate event_id0
[PATCH v2 6/6] dma/imx-sdma: convernt to use bit ops

Thanks
Richard


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

* [PATCH v2 1/6] dma/imx-sdma: let sdma_run_channel call sdma_enable_channel
  2012-01-13  3:09 [PATCH v2 0/6] imx-sdma: patches when I enable imx6q sabrelite audio Richard Zhao
@ 2012-01-13  3:09 ` Richard Zhao
  2012-01-13  3:09 ` [PATCH v2 2/6] dma/imx-sdma: use readl_relaxed/writel_relaxed and use writel when necessary Richard Zhao
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Richard Zhao @ 2012-01-13  3:09 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: dan.j.williams, vinod.koul, shawn.guo, kernel, eric.miao,
	patches, Richard Zhao

Let all enable channel code call sdma_enable_channel.

Signed-off-by: Richard Zhao <richard.zhao@linaro.org>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/dma/imx-sdma.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index f59fd8f..c2bc4f1 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -394,6 +394,11 @@ static int sdma_config_ownership(struct sdma_channel *sdmac,
 	return 0;
 }
 
+static void sdma_enable_channel(struct sdma_engine *sdma, int channel)
+{
+	__raw_writel(1 << channel, sdma->regs + SDMA_H_START);
+}
+
 /*
  * sdma_run_channel - run a channel and wait till it's done
  */
@@ -405,7 +410,7 @@ static int sdma_run_channel(struct sdma_channel *sdmac)
 
 	init_completion(&sdmac->done);
 
-	__raw_writel(1 << channel, sdma->regs + SDMA_H_START);
+	sdma_enable_channel(sdma, channel);
 
 	ret = wait_for_completion_timeout(&sdmac->done, HZ);
 
@@ -811,11 +816,6 @@ out:
 	return ret;
 }
 
-static void sdma_enable_channel(struct sdma_engine *sdma, int channel)
-{
-	__raw_writel(1 << channel, sdma->regs + SDMA_H_START);
-}
-
 static dma_cookie_t sdma_assign_cookie(struct sdma_channel *sdmac)
 {
 	dma_cookie_t cookie = sdmac->chan.cookie;
-- 
1.7.5.4



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

* [PATCH v2 2/6] dma/imx-sdma: use readl_relaxed/writel_relaxed and use writel when necessary
  2012-01-13  3:09 [PATCH v2 0/6] imx-sdma: patches when I enable imx6q sabrelite audio Richard Zhao
  2012-01-13  3:09 ` [PATCH v2 1/6] dma/imx-sdma: let sdma_run_channel call sdma_enable_channel Richard Zhao
@ 2012-01-13  3:09 ` Richard Zhao
  2012-01-13  3:09 ` [PATCH v2 3/6] dma/imx-sdma: call sdma_set_channel_priority after sdma_request_channel Richard Zhao
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Richard Zhao @ 2012-01-13  3:09 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: dan.j.williams, vinod.koul, shawn.guo, kernel, eric.miao,
	patches, Richard Zhao

use readl_relaxed/writel_relaxed in most places, and use writel when
enable channel, because it needs memory barrier.

Signed-off-by: Richard Zhao <richard.zhao@linaro.org>
---
 drivers/dma/imx-sdma.c |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index c2bc4f1..63f4752 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -368,9 +368,9 @@ static int sdma_config_ownership(struct sdma_channel *sdmac,
 	if (event_override && mcu_override && dsp_override)
 		return -EINVAL;
 
-	evt = __raw_readl(sdma->regs + SDMA_H_EVTOVR);
-	mcu = __raw_readl(sdma->regs + SDMA_H_HOSTOVR);
-	dsp = __raw_readl(sdma->regs + SDMA_H_DSPOVR);
+	evt = readl_relaxed(sdma->regs + SDMA_H_EVTOVR);
+	mcu = readl_relaxed(sdma->regs + SDMA_H_HOSTOVR);
+	dsp = readl_relaxed(sdma->regs + SDMA_H_DSPOVR);
 
 	if (dsp_override)
 		dsp &= ~(1 << channel);
@@ -387,16 +387,16 @@ static int sdma_config_ownership(struct sdma_channel *sdmac,
 	else
 		mcu |= (1 << channel);
 
-	__raw_writel(evt, sdma->regs + SDMA_H_EVTOVR);
-	__raw_writel(mcu, sdma->regs + SDMA_H_HOSTOVR);
-	__raw_writel(dsp, sdma->regs + SDMA_H_DSPOVR);
+	writel_relaxed(evt, sdma->regs + SDMA_H_EVTOVR);
+	writel_relaxed(mcu, sdma->regs + SDMA_H_HOSTOVR);
+	writel_relaxed(dsp, sdma->regs + SDMA_H_DSPOVR);
 
 	return 0;
 }
 
 static void sdma_enable_channel(struct sdma_engine *sdma, int channel)
 {
-	__raw_writel(1 << channel, sdma->regs + SDMA_H_START);
+	writel(1 << channel, sdma->regs + SDMA_H_START);
 }
 
 /*
@@ -460,9 +460,9 @@ static void sdma_event_enable(struct sdma_channel *sdmac, unsigned int event)
 	u32 val;
 	u32 chnenbl = chnenbl_ofs(sdma, event);
 
-	val = __raw_readl(sdma->regs + chnenbl);
+	val = readl_relaxed(sdma->regs + chnenbl);
 	val |= (1 << channel);
-	__raw_writel(val, sdma->regs + chnenbl);
+	writel_relaxed(val, sdma->regs + chnenbl);
 }
 
 static void sdma_event_disable(struct sdma_channel *sdmac, unsigned int event)
@@ -472,9 +472,9 @@ static void sdma_event_disable(struct sdma_channel *sdmac, unsigned int event)
 	u32 chnenbl = chnenbl_ofs(sdma, event);
 	u32 val;
 
-	val = __raw_readl(sdma->regs + chnenbl);
+	val = readl_relaxed(sdma->regs + chnenbl);
 	val &= ~(1 << channel);
-	__raw_writel(val, sdma->regs + chnenbl);
+	writel_relaxed(val, sdma->regs + chnenbl);
 }
 
 static void sdma_handle_channel_loop(struct sdma_channel *sdmac)
@@ -552,8 +552,8 @@ static irqreturn_t sdma_int_handler(int irq, void *dev_id)
 	struct sdma_engine *sdma = dev_id;
 	u32 stat;
 
-	stat = __raw_readl(sdma->regs + SDMA_H_INTR);
-	__raw_writel(stat, sdma->regs + SDMA_H_INTR);
+	stat = readl_relaxed(sdma->regs + SDMA_H_INTR);
+	writel_relaxed(stat, sdma->regs + SDMA_H_INTR);
 
 	while (stat) {
 		int channel = fls(stat) - 1;
@@ -707,7 +707,7 @@ static void sdma_disable_channel(struct sdma_channel *sdmac)
 	struct sdma_engine *sdma = sdmac->sdma;
 	int channel = sdmac->channel;
 
-	__raw_writel(1 << channel, sdma->regs + SDMA_H_STATSTOP);
+	writel_relaxed(1 << channel, sdma->regs + SDMA_H_STATSTOP);
 	sdmac->status = DMA_ERROR;
 }
 
@@ -780,7 +780,7 @@ static int sdma_set_channel_priority(struct sdma_channel *sdmac,
 		return -EINVAL;
 	}
 
-	__raw_writel(priority, sdma->regs + SDMA_CHNPRI_0 + 4 * channel);
+	writel_relaxed(priority, sdma->regs + SDMA_CHNPRI_0 + 4 * channel);
 
 	return 0;
 }
@@ -1228,7 +1228,7 @@ static int __init sdma_init(struct sdma_engine *sdma)
 	clk_enable(sdma->clk);
 
 	/* Be sure SDMA has not started yet */
-	__raw_writel(0, sdma->regs + SDMA_H_C0PTR);
+	writel_relaxed(0, sdma->regs + SDMA_H_C0PTR);
 
 	sdma->channel_control = dma_alloc_coherent(NULL,
 			MAX_DMA_CHANNELS * sizeof (struct sdma_channel_control) +
@@ -1251,11 +1251,11 @@ static int __init sdma_init(struct sdma_engine *sdma)
 
 	/* disable all channels */
 	for (i = 0; i < sdma->num_events; i++)
-		__raw_writel(0, sdma->regs + chnenbl_ofs(sdma, i));
+		writel_relaxed(0, sdma->regs + chnenbl_ofs(sdma, i));
 
 	/* All channels have priority 0 */
 	for (i = 0; i < MAX_DMA_CHANNELS; i++)
-		__raw_writel(0, sdma->regs + SDMA_CHNPRI_0 + i * 4);
+		writel_relaxed(0, sdma->regs + SDMA_CHNPRI_0 + i * 4);
 
 	ret = sdma_request_channel(&sdma->channel[0]);
 	if (ret)
@@ -1264,16 +1264,16 @@ static int __init sdma_init(struct sdma_engine *sdma)
 	sdma_config_ownership(&sdma->channel[0], false, true, false);
 
 	/* Set Command Channel (Channel Zero) */
-	__raw_writel(0x4050, sdma->regs + SDMA_CHN0ADDR);
+	writel_relaxed(0x4050, sdma->regs + SDMA_CHN0ADDR);
 
 	/* Set bits of CONFIG register but with static context switching */
 	/* FIXME: Check whether to set ACR bit depending on clock ratios */
-	__raw_writel(0, sdma->regs + SDMA_H_CONFIG);
+	writel_relaxed(0, sdma->regs + SDMA_H_CONFIG);
 
-	__raw_writel(ccb_phys, sdma->regs + SDMA_H_C0PTR);
+	writel_relaxed(ccb_phys, sdma->regs + SDMA_H_C0PTR);
 
 	/* Set bits of CONFIG register with given context switching mode */
-	__raw_writel(SDMA_H_CONFIG_CSM, sdma->regs + SDMA_H_CONFIG);
+	writel_relaxed(SDMA_H_CONFIG_CSM, sdma->regs + SDMA_H_CONFIG);
 
 	/* Initializes channel's priorities */
 	sdma_set_channel_priority(&sdma->channel[0], 7);
-- 
1.7.5.4



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

* [PATCH v2 3/6] dma/imx-sdma: call sdma_set_channel_priority after sdma_request_channel
  2012-01-13  3:09 [PATCH v2 0/6] imx-sdma: patches when I enable imx6q sabrelite audio Richard Zhao
  2012-01-13  3:09 ` [PATCH v2 1/6] dma/imx-sdma: let sdma_run_channel call sdma_enable_channel Richard Zhao
  2012-01-13  3:09 ` [PATCH v2 2/6] dma/imx-sdma: use readl_relaxed/writel_relaxed and use writel when necessary Richard Zhao
@ 2012-01-13  3:09 ` Richard Zhao
  2012-01-13  3:09 ` [PATCH v2 4/6] dma/imx-sdma: move clk_enable out of sdma_request_channel Richard Zhao
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Richard Zhao @ 2012-01-13  3:09 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: dan.j.williams, vinod.koul, shawn.guo, kernel, eric.miao,
	patches, Richard Zhao

sdma_request_channel sets the default priority. sdma_alloc_chan_resources
should call sdma_set_channel_priority thereafter to over write it.

Signed-off-by: Richard Zhao <richard.zhao@linaro.org>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/dma/imx-sdma.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 63f4752..b40f630 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -875,11 +875,11 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan)
 
 	sdmac->peripheral_type = data->peripheral_type;
 	sdmac->event_id0 = data->dma_request;
-	ret = sdma_set_channel_priority(sdmac, prio);
+	ret = sdma_request_channel(sdmac);
 	if (ret)
 		return ret;
 
-	ret = sdma_request_channel(sdmac);
+	ret = sdma_set_channel_priority(sdmac, prio);
 	if (ret)
 		return ret;
 
-- 
1.7.5.4



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

* [PATCH v2 4/6] dma/imx-sdma: move clk_enable out of sdma_request_channel
  2012-01-13  3:09 [PATCH v2 0/6] imx-sdma: patches when I enable imx6q sabrelite audio Richard Zhao
                   ` (2 preceding siblings ...)
  2012-01-13  3:09 ` [PATCH v2 3/6] dma/imx-sdma: call sdma_set_channel_priority after sdma_request_channel Richard Zhao
@ 2012-01-13  3:09 ` Richard Zhao
  2012-01-13  3:10 ` [PATCH v2 5/6] dma/imx-sdma: use num_events to validate event_id0 Richard Zhao
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Richard Zhao @ 2012-01-13  3:09 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: dan.j.williams, vinod.koul, shawn.guo, kernel, eric.miao,
	patches, Richard Zhao

It makes clk_enable/disable pair more readable, and fix one bug:
sdma_init calls sdma_request_channel, but seems don't know
sdma_request_channel enabled the clok.

Signed-off-by: Richard Zhao <richard.zhao@linaro.org>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/dma/imx-sdma.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index b40f630..015d93f 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -802,8 +802,6 @@ static int sdma_request_channel(struct sdma_channel *sdmac)
 	sdma->channel_control[channel].base_bd_ptr = sdmac->bd_phys;
 	sdma->channel_control[channel].current_bd_ptr = sdmac->bd_phys;
 
-	clk_enable(sdma->clk);
-
 	sdma_set_channel_priority(sdmac, MXC_SDMA_DEFAULT_PRIORITY);
 
 	init_completion(&sdmac->done);
@@ -875,6 +873,9 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan)
 
 	sdmac->peripheral_type = data->peripheral_type;
 	sdmac->event_id0 = data->dma_request;
+
+	clk_enable(sdmac->sdma->clk);
+
 	ret = sdma_request_channel(sdmac);
 	if (ret)
 		return ret;
-- 
1.7.5.4



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

* [PATCH v2 5/6] dma/imx-sdma: use num_events to validate event_id0
  2012-01-13  3:09 [PATCH v2 0/6] imx-sdma: patches when I enable imx6q sabrelite audio Richard Zhao
                   ` (3 preceding siblings ...)
  2012-01-13  3:09 ` [PATCH v2 4/6] dma/imx-sdma: move clk_enable out of sdma_request_channel Richard Zhao
@ 2012-01-13  3:10 ` Richard Zhao
  2012-01-13  3:10 ` [PATCH v2 6/6] dma/imx-sdma: convernt to use bit ops Richard Zhao
  2012-01-13  3:13 ` [PATCH v2 0/6] imx-sdma: patches when I enable imx6q sabrelite audio Richard Zhao
  6 siblings, 0 replies; 9+ messages in thread
From: Richard Zhao @ 2012-01-13  3:10 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: dan.j.williams, vinod.koul, shawn.guo, kernel, eric.miao,
	patches, Richard Zhao

event number is not always 32. use num_events for checking instead.

Signed-off-by: Richard Zhao <richard.zhao@linaro.org>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/dma/imx-sdma.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 015d93f..22fd561 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -723,7 +723,7 @@ static int sdma_config_channel(struct sdma_channel *sdmac)
 	sdmac->per_addr = 0;
 
 	if (sdmac->event_id0) {
-		if (sdmac->event_id0 > 32)
+		if (sdmac->event_id0 >= sdmac->sdma->num_events)
 			return -EINVAL;
 		sdma_event_enable(sdmac, sdmac->event_id0);
 	}
-- 
1.7.5.4



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

* [PATCH v2 6/6] dma/imx-sdma: convernt to use bit ops
  2012-01-13  3:09 [PATCH v2 0/6] imx-sdma: patches when I enable imx6q sabrelite audio Richard Zhao
                   ` (4 preceding siblings ...)
  2012-01-13  3:10 ` [PATCH v2 5/6] dma/imx-sdma: use num_events to validate event_id0 Richard Zhao
@ 2012-01-13  3:10 ` Richard Zhao
  2012-01-13  3:13 ` [PATCH v2 0/6] imx-sdma: patches when I enable imx6q sabrelite audio Richard Zhao
  6 siblings, 0 replies; 9+ messages in thread
From: Richard Zhao @ 2012-01-13  3:10 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: dan.j.williams, vinod.koul, shawn.guo, kernel, eric.miao,
	patches, Richard Zhao

We don't need extra lock, so we use non-atomic bit ops to set/clear bits,

merge event_mask0 and event_mask1 into an array, it helps use bit ops.

It also fixs the issue:

sdmac->event_mask0 = 1 << sdmac->event_id0;
sdmac->event_mask1 = 1 << (sdmac->event_id0 - 32);

It event_id0 < 32, it shifts negative number. If event_id0 >= 32, it
shifts number >= sizeof(int). Both the cases behavior is undefined.

Signed-off-by: Richard Zhao <richard.zhao@linaro.org>
---
 drivers/dma/imx-sdma.c |   68 ++++++++++++++++++++++++------------------------
 1 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 22fd561..984c0f7 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -20,6 +20,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/bitops.h>
 #include <linux/mm.h>
 #include <linux/interrupt.h>
 #include <linux/clk.h>
@@ -260,8 +261,8 @@ struct sdma_channel {
 	unsigned int			pc_from_device, pc_to_device;
 	unsigned long			flags;
 	dma_addr_t			per_address;
-	u32				event_mask0, event_mask1;
-	u32				watermark_level;
+	unsigned long			event_mask[2];
+	unsigned long			watermark_level;
 	u32				shp_addr, per_addr;
 	struct dma_chan			chan;
 	spinlock_t			lock;
@@ -272,7 +273,7 @@ struct sdma_channel {
 	unsigned int			chn_real_count;
 };
 
-#define IMX_DMA_SG_LOOP		(1 << 0)
+#define IMX_DMA_SG_LOOP		BIT(0)
 
 #define MAX_DMA_CHANNELS 32
 #define MXC_SDMA_DEFAULT_PRIORITY 1
@@ -346,9 +347,9 @@ static const struct of_device_id sdma_dt_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, sdma_dt_ids);
 
-#define SDMA_H_CONFIG_DSPDMA	(1 << 12) /* indicates if the DSPDMA is used */
-#define SDMA_H_CONFIG_RTD_PINS	(1 << 11) /* indicates if Real-Time Debug pins are enabled */
-#define SDMA_H_CONFIG_ACR	(1 << 4)  /* indicates if AHB freq /core freq = 2 or 1 */
+#define SDMA_H_CONFIG_DSPDMA	BIT(12) /* indicates if the DSPDMA is used */
+#define SDMA_H_CONFIG_RTD_PINS	BIT(11) /* indicates if Real-Time Debug pins are enabled */
+#define SDMA_H_CONFIG_ACR	BIT(4)  /* indicates if AHB freq /core freq = 2 or 1 */
 #define SDMA_H_CONFIG_CSM	(3)       /* indicates which context switch mode is selected*/
 
 static inline u32 chnenbl_ofs(struct sdma_engine *sdma, unsigned int event)
@@ -363,7 +364,7 @@ static int sdma_config_ownership(struct sdma_channel *sdmac,
 {
 	struct sdma_engine *sdma = sdmac->sdma;
 	int channel = sdmac->channel;
-	u32 evt, mcu, dsp;
+	unsigned long evt, mcu, dsp;
 
 	if (event_override && mcu_override && dsp_override)
 		return -EINVAL;
@@ -373,19 +374,19 @@ static int sdma_config_ownership(struct sdma_channel *sdmac,
 	dsp = readl_relaxed(sdma->regs + SDMA_H_DSPOVR);
 
 	if (dsp_override)
-		dsp &= ~(1 << channel);
+		__clear_bit(channel, &dsp);
 	else
-		dsp |= (1 << channel);
+		__set_bit(channel, &dsp);
 
 	if (event_override)
-		evt &= ~(1 << channel);
+		__clear_bit(channel, &evt);
 	else
-		evt |= (1 << channel);
+		__set_bit(channel, &evt);
 
 	if (mcu_override)
-		mcu &= ~(1 << channel);
+		__clear_bit(channel, &mcu);
 	else
-		mcu |= (1 << channel);
+		__set_bit(channel, &mcu);
 
 	writel_relaxed(evt, sdma->regs + SDMA_H_EVTOVR);
 	writel_relaxed(mcu, sdma->regs + SDMA_H_HOSTOVR);
@@ -396,7 +397,7 @@ static int sdma_config_ownership(struct sdma_channel *sdmac,
 
 static void sdma_enable_channel(struct sdma_engine *sdma, int channel)
 {
-	writel(1 << channel, sdma->regs + SDMA_H_START);
+	writel(BIT(channel), sdma->regs + SDMA_H_START);
 }
 
 /*
@@ -457,11 +458,11 @@ static void sdma_event_enable(struct sdma_channel *sdmac, unsigned int event)
 {
 	struct sdma_engine *sdma = sdmac->sdma;
 	int channel = sdmac->channel;
-	u32 val;
+	unsigned long val;
 	u32 chnenbl = chnenbl_ofs(sdma, event);
 
 	val = readl_relaxed(sdma->regs + chnenbl);
-	val |= (1 << channel);
+	__set_bit(channel, &val);
 	writel_relaxed(val, sdma->regs + chnenbl);
 }
 
@@ -470,10 +471,10 @@ static void sdma_event_disable(struct sdma_channel *sdmac, unsigned int event)
 	struct sdma_engine *sdma = sdmac->sdma;
 	int channel = sdmac->channel;
 	u32 chnenbl = chnenbl_ofs(sdma, event);
-	u32 val;
+	unsigned long val;
 
 	val = readl_relaxed(sdma->regs + chnenbl);
-	val &= ~(1 << channel);
+	__clear_bit(channel, &val);
 	writel_relaxed(val, sdma->regs + chnenbl);
 }
 
@@ -550,7 +551,7 @@ static void mxc_sdma_handle_channel(struct sdma_channel *sdmac)
 static irqreturn_t sdma_int_handler(int irq, void *dev_id)
 {
 	struct sdma_engine *sdma = dev_id;
-	u32 stat;
+	unsigned long stat;
 
 	stat = readl_relaxed(sdma->regs + SDMA_H_INTR);
 	writel_relaxed(stat, sdma->regs + SDMA_H_INTR);
@@ -561,7 +562,7 @@ static irqreturn_t sdma_int_handler(int irq, void *dev_id)
 
 		mxc_sdma_handle_channel(sdmac);
 
-		stat &= ~(1 << channel);
+		__clear_bit(channel, &stat);
 	}
 
 	return IRQ_HANDLED;
@@ -669,11 +670,11 @@ static int sdma_load_context(struct sdma_channel *sdmac)
 		return load_address;
 
 	dev_dbg(sdma->dev, "load_address = %d\n", load_address);
-	dev_dbg(sdma->dev, "wml = 0x%08x\n", sdmac->watermark_level);
+	dev_dbg(sdma->dev, "wml = 0x%08x\n", (u32)sdmac->watermark_level);
 	dev_dbg(sdma->dev, "shp_addr = 0x%08x\n", sdmac->shp_addr);
 	dev_dbg(sdma->dev, "per_addr = 0x%08x\n", sdmac->per_addr);
-	dev_dbg(sdma->dev, "event_mask0 = 0x%08x\n", sdmac->event_mask0);
-	dev_dbg(sdma->dev, "event_mask1 = 0x%08x\n", sdmac->event_mask1);
+	dev_dbg(sdma->dev, "event_mask0 = 0x%08x\n", (u32)sdmac->event_mask[0]);
+	dev_dbg(sdma->dev, "event_mask1 = 0x%08x\n", (u32)sdmac->event_mask[1]);
 
 	mutex_lock(&sdma->channel_0_lock);
 
@@ -683,8 +684,8 @@ static int sdma_load_context(struct sdma_channel *sdmac)
 	/* Send by context the event mask,base address for peripheral
 	 * and watermark level
 	 */
-	context->gReg[0] = sdmac->event_mask1;
-	context->gReg[1] = sdmac->event_mask0;
+	context->gReg[0] = sdmac->event_mask[1];
+	context->gReg[1] = sdmac->event_mask[0];
 	context->gReg[2] = sdmac->per_addr;
 	context->gReg[6] = sdmac->shp_addr;
 	context->gReg[7] = sdmac->watermark_level;
@@ -707,7 +708,7 @@ static void sdma_disable_channel(struct sdma_channel *sdmac)
 	struct sdma_engine *sdma = sdmac->sdma;
 	int channel = sdmac->channel;
 
-	writel_relaxed(1 << channel, sdma->regs + SDMA_H_STATSTOP);
+	writel_relaxed(BIT(channel), sdma->regs + SDMA_H_STATSTOP);
 	sdmac->status = DMA_ERROR;
 }
 
@@ -717,8 +718,8 @@ static int sdma_config_channel(struct sdma_channel *sdmac)
 
 	sdma_disable_channel(sdmac);
 
-	sdmac->event_mask0 = 0;
-	sdmac->event_mask1 = 0;
+	sdmac->event_mask[0] = 0;
+	sdmac->event_mask[1] = 0;
 	sdmac->shp_addr = 0;
 	sdmac->per_addr = 0;
 
@@ -746,15 +747,14 @@ static int sdma_config_channel(struct sdma_channel *sdmac)
 			(sdmac->peripheral_type != IMX_DMATYPE_DSP)) {
 		/* Handle multiple event channels differently */
 		if (sdmac->event_id1) {
-			sdmac->event_mask1 = 1 << (sdmac->event_id1 % 32);
+			sdmac->event_mask[1] = BIT(sdmac->event_id1 % 32);
 			if (sdmac->event_id1 > 31)
-				sdmac->watermark_level |= 1 << 31;
-			sdmac->event_mask0 = 1 << (sdmac->event_id0 % 32);
+				__set_bit(31, &sdmac->watermark_level);
+			sdmac->event_mask[0] = BIT(sdmac->event_id0 % 32);
 			if (sdmac->event_id0 > 31)
-				sdmac->watermark_level |= 1 << 30;
+				__set_bit(30, &sdmac->watermark_level);
 		} else {
-			sdmac->event_mask0 = 1 << sdmac->event_id0;
-			sdmac->event_mask1 = 1 << (sdmac->event_id0 - 32);
+			__set_bit(sdmac->event_id0, sdmac->event_mask);
 		}
 		/* Watermark Level */
 		sdmac->watermark_level |= sdmac->watermark_level;
-- 
1.7.5.4



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

* Re: [PATCH v2 0/6] imx-sdma: patches when I enable imx6q sabrelite audio
  2012-01-13  3:09 [PATCH v2 0/6] imx-sdma: patches when I enable imx6q sabrelite audio Richard Zhao
                   ` (5 preceding siblings ...)
  2012-01-13  3:10 ` [PATCH v2 6/6] dma/imx-sdma: convernt to use bit ops Richard Zhao
@ 2012-01-13  3:13 ` Richard Zhao
  2012-01-31  3:35   ` Vinod Koul
  6 siblings, 1 reply; 9+ messages in thread
From: Richard Zhao @ 2012-01-13  3:13 UTC (permalink / raw)
  To: Richard Zhao
  Cc: linux-kernel, linux-arm-kernel, patches, vinod.koul, eric.miao,
	kernel, dan.j.williams, shawn.guo

Changes in v2:
 - convert to use bit ops

> [PATCH v2 1/6] dma/imx-sdma: let sdma_run_channel call
> [PATCH v2 2/6] dma/imx-sdma: use readl_relaxed/writel_relaxed and
> [PATCH v2 3/6] dma/imx-sdma: call sdma_set_channel_priority after
> [PATCH v2 4/6] dma/imx-sdma: move clk_enable out of
> [PATCH v2 5/6] dma/imx-sdma: use num_events to validate event_id0
> [PATCH v2 6/6] dma/imx-sdma: convernt to use bit ops
> 
> Thanks
> Richard
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 


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

* Re: [PATCH v2 0/6] imx-sdma: patches when I enable imx6q sabrelite audio
  2012-01-13  3:13 ` [PATCH v2 0/6] imx-sdma: patches when I enable imx6q sabrelite audio Richard Zhao
@ 2012-01-31  3:35   ` Vinod Koul
  0 siblings, 0 replies; 9+ messages in thread
From: Vinod Koul @ 2012-01-31  3:35 UTC (permalink / raw)
  To: Richard Zhao
  Cc: Richard Zhao, patches, linux-kernel, eric.miao, kernel,
	dan.j.williams, shawn.guo, linux-arm-kernel

On Fri, 2012-01-13 at 11:13 +0800, Richard Zhao wrote:
> Changes in v2:
>  - convert to use bit ops
> 
> > [PATCH v2 1/6] dma/imx-sdma: let sdma_run_channel call
> > [PATCH v2 2/6] dma/imx-sdma: use readl_relaxed/writel_relaxed and
> > [PATCH v2 3/6] dma/imx-sdma: call sdma_set_channel_priority after
> > [PATCH v2 4/6] dma/imx-sdma: move clk_enable out of
> > [PATCH v2 5/6] dma/imx-sdma: use num_events to validate event_id0
> > [PATCH v2 6/6] dma/imx-sdma: convernt to use bit ops
> > 
> > Thanks
> > Richard
> > 
Thanks Applied all, with a typo fix in 4 in change log

-- 
~Vinod


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

end of thread, other threads:[~2012-01-31  3:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-13  3:09 [PATCH v2 0/6] imx-sdma: patches when I enable imx6q sabrelite audio Richard Zhao
2012-01-13  3:09 ` [PATCH v2 1/6] dma/imx-sdma: let sdma_run_channel call sdma_enable_channel Richard Zhao
2012-01-13  3:09 ` [PATCH v2 2/6] dma/imx-sdma: use readl_relaxed/writel_relaxed and use writel when necessary Richard Zhao
2012-01-13  3:09 ` [PATCH v2 3/6] dma/imx-sdma: call sdma_set_channel_priority after sdma_request_channel Richard Zhao
2012-01-13  3:09 ` [PATCH v2 4/6] dma/imx-sdma: move clk_enable out of sdma_request_channel Richard Zhao
2012-01-13  3:10 ` [PATCH v2 5/6] dma/imx-sdma: use num_events to validate event_id0 Richard Zhao
2012-01-13  3:10 ` [PATCH v2 6/6] dma/imx-sdma: convernt to use bit ops Richard Zhao
2012-01-13  3:13 ` [PATCH v2 0/6] imx-sdma: patches when I enable imx6q sabrelite audio Richard Zhao
2012-01-31  3:35   ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).