summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/imx233
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-06-17 00:16:19 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-06-17 00:29:25 +0200
commite671472c3f8bbbb4b5eaa94c283d0ade6cd50f5e (patch)
treefdcc26b996401532ba9fab765763ba2dc13d8628 /firmware/target/arm/imx233
parentbdc572b8a1bfc9fedb4a2158626647a801c3f177 (diff)
downloadrockbox-e671472c3f8bbbb4b5eaa94c283d0ade6cd50f5e.tar.gz
rockbox-e671472c3f8bbbb4b5eaa94c283d0ade6cd50f5e.tar.bz2
rockbox-e671472c3f8bbbb4b5eaa94c283d0ade6cd50f5e.zip
imx233: fix dma for stmp3600 and stmp3700, improve support
Add finer granularity to start command: now commands can be prepared, schedule and semaphore increased independently. Change-Id: Ib1ed1f20f4b46dc61b6dbab6ddec8b54e3d832b9
Diffstat (limited to 'firmware/target/arm/imx233')
-rw-r--r--firmware/target/arm/imx233/dma-imx233.c67
-rw-r--r--firmware/target/arm/imx233/dma-imx233.h8
2 files changed, 66 insertions, 9 deletions
diff --git a/firmware/target/arm/imx233/dma-imx233.c b/firmware/target/arm/imx233/dma-imx233.c
index 5808731eef..81ae5aeb72 100644
--- a/firmware/target/arm/imx233/dma-imx233.c
+++ b/firmware/target/arm/imx233/dma-imx233.c
@@ -39,8 +39,13 @@ void imx233_dma_reset_channel(unsigned chan)
uint32_t bm = 1 << APB_GET_DMA_CHANNEL(chan);
if(APB_IS_APBX_CHANNEL(chan))
{
+#if IMX233_SUBTARGET < 3780
+ BF_SETV(APBX_CTRL0, RESET_CHANNEL, bm);
+ while(BF_RD(APBX_CTRL0, RESET_CHANNEL) & bm);
+#else
BF_SETV(APBX_CHANNEL_CTRL, RESET_CHANNEL, bm);
while(BF_RD(APBX_CHANNEL_CTRL, RESET_CHANNEL) & bm);
+#endif
}
else
{
@@ -64,10 +69,17 @@ void imx233_dma_freeze_channel(unsigned chan, bool freeze)
uint32_t bm = 1 << APB_GET_DMA_CHANNEL(chan);
if(APB_IS_APBX_CHANNEL(chan))
{
+#if IMX233_SUBTARGET < 3780
+ if(freeze)
+ BF_SETV(APBX_CTRL0, FREEZE_CHANNEL, bm);
+ else
+ BF_CLRV(APBX_CTRL0, FREEZE_CHANNEL, bm);
+#else
if(freeze)
BF_SETV(APBX_CHANNEL_CTRL, FREEZE_CHANNEL, bm);
else
BF_CLRV(APBX_CHANNEL_CTRL, FREEZE_CHANNEL, bm);
+#endif
}
else
{
@@ -104,28 +116,46 @@ void imx233_dma_clear_channel_interrupt(unsigned chan)
if(APB_IS_APBX_CHANNEL(chan))
{
BF_CLRV(APBX_CTRL1, CH_CMDCMPLT_IRQ, bm);
+#if IMX233_SUBTARGET >= 3780
BF_CLRV(APBX_CTRL2, CH_ERROR_IRQ, bm);
+#elif IMX233_SUBTARGET >= 3700
+ BF_CLRV(APBX_CTRL1, CH_AHB_ERROR_IRQ, bm);
+#endif
}
else
{
BF_CLRV(APBH_CTRL1, CH_CMDCMPLT_IRQ, bm);
+#if IMX233_SUBTARGET >= 3780
BF_CLRV(APBH_CTRL2, CH_ERROR_IRQ, bm);
+#elif IMX233_SUBTARGET >= 3700
+ BF_CLRV(APBH_CTRL1, CH_AHB_ERROR_IRQ, bm);
+#endif
}
}
bool imx233_dma_is_channel_error_irq(unsigned chan)
{
uint32_t bm = 1 << APB_GET_DMA_CHANNEL(chan);
+#if IMX233_SUBTARGET >= 3780
if(APB_IS_APBX_CHANNEL(chan))
return !!(BF_RD(APBX_CTRL2, CH_ERROR_IRQ) & bm);
else
return !!(BF_RD(APBH_CTRL2, CH_ERROR_IRQ) & bm);
+#elif IMX233_SUBTARGET >= 3700
+ if(APB_IS_APBX_CHANNEL(chan))
+ return !!(BF_RD(APBX_CTRL1, CH_AHB_ERROR_IRQ) & bm);
+ else
+ return !!(BF_RD(APBH_CTRL1, CH_AHB_ERROR_IRQ) & bm);
+#else
+ (void) bm;
+ return false;
+#endif
}
/* Commit and/or discard all DMA descriptors and buffers pointed by them,
* handle circular lists. At the same time, convert virtual pointers to
* real ones */
-static void imx233_dma_commit_and_discard(unsigned chan, struct apb_dma_command_t *cmd)
+void imx233_dma_prepare_command(unsigned chan, struct apb_dma_command_t *cmd)
{
/* We handle circular descriptors by using unused bits:
* bits 8-11 are not used by the hardware so we first go through the whole
@@ -178,19 +208,27 @@ static void imx233_dma_commit_and_discard(unsigned chan, struct apb_dma_command_
}
}
-void imx233_dma_start_command(unsigned chan, struct apb_dma_command_t *cmd)
+void imx233_dma_set_next_command(unsigned chan, struct apb_dma_command_t *cmd)
{
- imx233_dma_commit_and_discard(chan, cmd);
if(APB_IS_APBX_CHANNEL(chan))
- {
HW_APBX_CHn_NXTCMDAR(APB_GET_DMA_CHANNEL(chan)) = (uint32_t)PHYSICAL_ADDR(cmd);
- HW_APBX_CHn_SEMA(APB_GET_DMA_CHANNEL(chan)) = 1;
- }
else
- {
HW_APBH_CHn_NXTCMDAR(APB_GET_DMA_CHANNEL(chan)) = (uint32_t)PHYSICAL_ADDR(cmd);
- HW_APBH_CHn_SEMA(APB_GET_DMA_CHANNEL(chan)) = 1;
- }
+}
+
+void imx233_dma_inc_sema(unsigned chan, unsigned amount)
+{
+ if(APB_IS_APBX_CHANNEL(chan))
+ HW_APBX_CHn_SEMA(APB_GET_DMA_CHANNEL(chan)) = amount;
+ else
+ HW_APBH_CHn_SEMA(APB_GET_DMA_CHANNEL(chan)) = amount;
+}
+
+void imx233_dma_start_command(unsigned chan, struct apb_dma_command_t *cmd)
+{
+ imx233_dma_prepare_command(chan, cmd);
+ imx233_dma_set_next_command(chan, cmd);
+ imx233_dma_inc_sema(chan, 1);
}
int imx233_dma_wait_completion(unsigned chan, unsigned tmo)
@@ -227,15 +265,26 @@ struct imx233_dma_info_t imx233_dma_get_info(unsigned chan, unsigned flags)
if(flags & DMA_INFO_APB_BYTES)
s.apb_bytes = apbx ? BF_RDn(APBX_CHn_DEBUG2, dmac, APB_BYTES) : BF_RDn(APBH_CHn_DEBUG2, dmac, APB_BYTES);
if(flags & DMA_INFO_FREEZED)
+#if IMX233_SUBTARGET < 3780
+ s.freezed = !!((apbx ? BF_RD(APBX_CTRL0, FREEZE_CHANNEL) : BF_RD(APBH_CTRL0, FREEZE_CHANNEL)) & bm);
+#else
s.freezed = !!((apbx ? BF_RD(APBX_CHANNEL_CTRL, FREEZE_CHANNEL) : BF_RD(APBH_CTRL0, FREEZE_CHANNEL)) & bm);
+#endif
if(flags & DMA_INFO_GATED)
s.gated = apbx ? false : !!(BF_RD(APBH_CTRL0, CLKGATE_CHANNEL) & bm);
if(flags & DMA_INFO_INTERRUPT)
{
s.int_enabled = !!((apbx ? BF_RD(APBX_CTRL1, CH_CMDCMPLT_IRQ_EN) : BF_RD(APBH_CTRL1, CH_CMDCMPLT_IRQ_EN)) & bm);
s.int_cmdcomplt = !!((apbx ? BF_RD(APBX_CTRL1, CH_CMDCMPLT_IRQ) : BF_RD(APBH_CTRL1, CH_CMDCMPLT_IRQ)) & bm);
+#if IMX233_SUBTARGET >= 3780
s.int_error = !!((apbx ? BF_RD(APBX_CTRL2, CH_ERROR_IRQ) : BF_RD(APBH_CTRL2, CH_ERROR_IRQ)) & bm);
+#elif IMX233_SUBTARGET >= 3700
+ s.int_error = !!((apbx ? BF_RD(APBX_CTRL1, CH_AHB_ERROR_IRQ) : BF_RD(APBH_CTRL1, CH_AHB_ERROR_IRQ)) & bm);
+#else
+ s.int_error = false;
+#endif
}
s.nr_unaligned = apb_nr_unaligned[chan];
return s;
}
+
diff --git a/firmware/target/arm/imx233/dma-imx233.h b/firmware/target/arm/imx233/dma-imx233.h
index 692b8dc16d..a64b8a64d1 100644
--- a/firmware/target/arm/imx233/dma-imx233.h
+++ b/firmware/target/arm/imx233/dma-imx233.h
@@ -37,8 +37,12 @@
#define APB_IS_APBX_CHANNEL(x) ((x) & 0x10)
#define APB_GET_DMA_CHANNEL(x) ((x) & 0xf)
+#if IMX233_SUBTARGET >= 3700
// NOTE: although undocumented, the iMX233 channel 0 is actually the LCDIF one
#define APB_LCDIF APBH_DMA_CHANNEL(0)
+#else
+#define APB_LCDIF APBX_DMA_CHANNEL(4)
+#endif
#define APB_SSP(ssp) APBH_DMA_CHANNEL(ssp)
#define APB_GPMI(dev) APBH_DMA_CHANNEL(4 + (dev))
@@ -151,6 +155,10 @@ void imx233_dma_enable_channel_interrupt(unsigned chan, bool enable);
void imx233_dma_clear_channel_interrupt(unsigned chan);
bool imx233_dma_is_channel_error_irq(unsigned chan);
/* assume no command is in progress */
+void imx233_dma_prepare_command(unsigned chan, struct apb_dma_command_t *cmd);
+void imx233_dma_set_next_command(unsigned chan, struct apb_dma_command_t *cmd);
+void imx233_dma_inc_sema(unsigned chan, unsigned amount);
+/* wrapper around prepare_command, set_next_command, inc_sema(1) */
void imx233_dma_start_command(unsigned chan, struct apb_dma_command_t *cmd);
/* return value of the semaphore */
int imx233_dma_wait_completion(unsigned chan, unsigned tmo);