summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/imx233/dma-imx233.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2016-05-24 20:29:56 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2016-05-28 16:49:22 +0200
commiteac1ca22bd4a6c1849880d0f8b6764befb60bc21 (patch)
tree681da66d77b9edcb33b868cf94886440d61997cc /firmware/target/arm/imx233/dma-imx233.c
parent28920ec5cc994dff19bec100a57de4557f72a7f5 (diff)
downloadrockbox-eac1ca22bd4a6c1849880d0f8b6764befb60bc21.tar.gz
rockbox-eac1ca22bd4a6c1849880d0f8b6764befb60bc21.tar.bz2
rockbox-eac1ca22bd4a6c1849880d0f8b6764befb60bc21.zip
imx233: generate register headers using headergen_v2 and update code for it
NOTE: this commit does not introduce any change, ideally even the binary should be almost the same. I checked the disassembly by hand and there are only a few differences here and there, mostly the compiler decides to compile very close expressions slightly differently. I tried to run the new code on several targets to make sure and saw no difference. The major syntax changes of the new headers are as follows: - BF_{WR,SET,CLR} are now superpowerful and allows to set several fileds at once: BF_WR(reg, field1(value1), field2(value2), ...) - BF_CS (use like BF_WR) does a write to reg_CLR and then reg_SET instead of RMW - there is no more need for macros like BF_{WR_,SET,CLR}_V, since one can simply BF_WR with field_V(name) - the old BF_SETV macro has no trivial equivalent and is replaced with its its equivalent for BF_WR(reg_SET, ...) I also rename the register headers: "regs/regs-x.h" -> "regs/x.h" to avoid the redundant "regs". Final note: the registers were generated using the following command: ./headergen_v2 -g imx -o ../../firmware/target/arm/imx233/regs/ desc/regs-stmp3{600,700,780}.xml Change-Id: I7485e8b4315a0929a8edb63e7fa1edcaa54b1edc
Diffstat (limited to 'firmware/target/arm/imx233/dma-imx233.c')
-rw-r--r--firmware/target/arm/imx233/dma-imx233.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/firmware/target/arm/imx233/dma-imx233.c b/firmware/target/arm/imx233/dma-imx233.c
index 8e55e5dc5d..390add481b 100644
--- a/firmware/target/arm/imx233/dma-imx233.c
+++ b/firmware/target/arm/imx233/dma-imx233.c
@@ -26,6 +26,9 @@
#include "lcd.h"
#include "string.h"
+#include "regs/apbh.h"
+#include "regs/apbx.h"
+
// statistics about unaligned transfers
static int apb_nr_unaligned[32];
@@ -42,16 +45,16 @@ void imx233_dma_reset_channel(unsigned chan)
if(APB_IS_APBX_CHANNEL(chan))
{
#if IMX233_SUBTARGET < 3780
- BF_SETV(APBX_CTRL0, RESET_CHANNEL, bm);
+ BF_WR(APBX_CTRL0_SET, RESET_CHANNEL(bm));
while(BF_RD(APBX_CTRL0, RESET_CHANNEL) & bm);
#else
- BF_SETV(APBX_CHANNEL_CTRL, RESET_CHANNEL, bm);
+ BF_WR(APBX_CHANNEL_CTRL_SET, RESET_CHANNEL(bm));
while(BF_RD(APBX_CHANNEL_CTRL, RESET_CHANNEL) & bm);
#endif
}
else
{
- BF_SETV(APBH_CTRL0, RESET_CHANNEL, bm);
+ BF_WR(APBH_CTRL0_SET, RESET_CHANNEL(bm));
while(BF_RD(APBH_CTRL0, RESET_CHANNEL) & bm);
}
}
@@ -61,9 +64,9 @@ void imx233_dma_clkgate_channel(unsigned chan, bool enable_clock)
if(APB_IS_APBX_CHANNEL(chan))
return;
if(enable_clock)
- BF_CLRV(APBH_CTRL0, CLKGATE_CHANNEL, 1 << APB_GET_DMA_CHANNEL(chan));
+ BF_WR(APBH_CTRL0_CLR, CLKGATE_CHANNEL(1 << APB_GET_DMA_CHANNEL(chan)));
else
- BF_SETV(APBH_CTRL0, CLKGATE_CHANNEL, 1 << APB_GET_DMA_CHANNEL(chan));
+ BF_WR(APBH_CTRL0_SET, CLKGATE_CHANNEL(1 << APB_GET_DMA_CHANNEL(chan)));
}
void imx233_dma_freeze_channel(unsigned chan, bool freeze)
@@ -73,22 +76,22 @@ void imx233_dma_freeze_channel(unsigned chan, bool freeze)
{
#if IMX233_SUBTARGET < 3780
if(freeze)
- BF_SETV(APBX_CTRL0, FREEZE_CHANNEL, bm);
+ BF_WR(APBX_CTRL0_SET, FREEZE_CHANNEL(bm));
else
- BF_CLRV(APBX_CTRL0, FREEZE_CHANNEL, bm);
+ BF_WR(APBX_CTRL0_CLR, FREEZE_CHANNEL(bm));
#else
if(freeze)
- BF_SETV(APBX_CHANNEL_CTRL, FREEZE_CHANNEL, bm);
+ BF_WR(APBX_CHANNEL_CTRL_SET, FREEZE_CHANNEL(bm));
else
- BF_CLRV(APBX_CHANNEL_CTRL, FREEZE_CHANNEL, bm);
+ BF_WR(APBX_CHANNEL_CTRL_CLR, FREEZE_CHANNEL(bm));
#endif
}
else
{
if(freeze)
- BF_SETV(APBH_CTRL0, FREEZE_CHANNEL, bm);
+ BF_WR(APBH_CTRL0_SET, FREEZE_CHANNEL(bm));
else
- BF_CLRV(APBH_CTRL0, FREEZE_CHANNEL, bm);
+ BF_WR(APBH_CTRL0_CLR, FREEZE_CHANNEL(bm));
}
}
@@ -98,16 +101,16 @@ void imx233_dma_enable_channel_interrupt(unsigned chan, bool enable)
if(APB_IS_APBX_CHANNEL(chan))
{
if(enable)
- BF_SETV(APBX_CTRL1, CH_CMDCMPLT_IRQ_EN, bm);
+ BF_WR(APBX_CTRL1_SET, CH_CMDCMPLT_IRQ_EN(bm));
else
- BF_CLRV(APBX_CTRL1, CH_CMDCMPLT_IRQ_EN, bm);
+ BF_WR(APBX_CTRL1_CLR, CH_CMDCMPLT_IRQ_EN(bm));
}
else
{
if(enable)
- BF_SETV(APBH_CTRL1, CH_CMDCMPLT_IRQ_EN, bm);
+ BF_WR(APBH_CTRL1_SET, CH_CMDCMPLT_IRQ_EN(bm));
else
- BF_CLRV(APBH_CTRL1, CH_CMDCMPLT_IRQ_EN, bm);
+ BF_WR(APBH_CTRL1_CLR, CH_CMDCMPLT_IRQ_EN(bm));
}
imx233_dma_clear_channel_interrupt(chan);
}
@@ -117,20 +120,20 @@ void imx233_dma_clear_channel_interrupt(unsigned chan)
uint32_t bm = 1 << APB_GET_DMA_CHANNEL(chan);
if(APB_IS_APBX_CHANNEL(chan))
{
- BF_CLRV(APBX_CTRL1, CH_CMDCMPLT_IRQ, bm);
+ BF_WR(APBX_CTRL1_CLR, CH_CMDCMPLT_IRQ(bm));
#if IMX233_SUBTARGET >= 3780
- BF_CLRV(APBX_CTRL2, CH_ERROR_IRQ, bm);
+ BF_WR(APBX_CTRL2_CLR, CH_ERROR_IRQ(bm));
#elif IMX233_SUBTARGET >= 3700
- BF_CLRV(APBX_CTRL1, CH_AHB_ERROR_IRQ, bm);
+ BF_WR(APBX_CTRL1_CLR, CH_AHB_ERROR_IRQ(bm));
#endif
}
else
{
- BF_CLRV(APBH_CTRL1, CH_CMDCMPLT_IRQ, bm);
+ BF_WR(APBH_CTRL1_CLR, CH_CMDCMPLT_IRQ(bm));
#if IMX233_SUBTARGET >= 3780
- BF_CLRV(APBH_CTRL2, CH_ERROR_IRQ, bm);
+ BF_WR(APBH_CTRL2_CLR, CH_ERROR_IRQ(bm));
#elif IMX233_SUBTARGET >= 3700
- BF_CLRV(APBH_CTRL1, CH_AHB_ERROR_IRQ, bm);
+ BF_WR(APBH_CTRL1_CLR, CH_AHB_ERROR_IRQ(bm));
#endif
}
}
@@ -168,7 +171,7 @@ void imx233_dma_prepare_command(unsigned chan, struct apb_dma_command_t *cmd)
while(BF_RDX(cur->cmd, APB_CHx_CMD, UNUSED) != BV_APB_CHx_CMD_UNUSED__MAGIC)
{
- BF_WR_VX(cur->cmd, APB_CHx_CMD, UNUSED, MAGIC);
+ BF_WRX(cur->cmd, APB_CHx_CMD, UNUSED_V(MAGIC));
int op = BF_RDX(cur->cmd, APB_CHx_CMD, COMMAND);
int sz = BF_RDX(cur->cmd, APB_CHx_CMD, XFER_COUNT);
/* device > host: discard */
@@ -191,7 +194,7 @@ void imx233_dma_prepare_command(unsigned chan, struct apb_dma_command_t *cmd)
cur = cmd;
while(BF_RDX(cur->cmd, APB_CHx, CMD_UNUSED) != 0)
{
- BF_WRX(cur->cmd, APB_CHx, CMD_UNUSED, 0);
+ BF_WRX(cur->cmd, APB_CHx, CMD_UNUSED(0));
int sz = BF_RDX(cur->cmd, APB_CHx_CMD, CMDWORDS) * sizeof(uint32_t);
/* commit descriptor and discard descriptor */
/* chain ? */
@@ -238,10 +241,10 @@ int imx233_dma_wait_completion(unsigned chan, unsigned tmo)
tmo += current_tick;
int value = 0;
if(APB_IS_APBX_CHANNEL(chan))
- while((value = BF_RDn(APBX_CHn_SEMA, APB_GET_DMA_CHANNEL(chan), PHORE)) && !TIME_AFTER(current_tick, tmo))
+ while((value = BF_RD(APBX_CHn_SEMA(APB_GET_DMA_CHANNEL(chan)), PHORE)) && !TIME_AFTER(current_tick, tmo))
yield();
else
- while((value = BF_RDn(APBH_CHn_SEMA, APB_GET_DMA_CHANNEL(chan), PHORE)) && !TIME_AFTER(current_tick, tmo))
+ while((value = BF_RD(APBH_CHn_SEMA(APB_GET_DMA_CHANNEL(chan)), PHORE)) && !TIME_AFTER(current_tick, tmo))
yield();
return value;
@@ -263,9 +266,9 @@ struct imx233_dma_info_t imx233_dma_get_info(unsigned chan, unsigned flags)
if(flags & DMA_INFO_BAR)
s.bar = apbx ? HW_APBX_CHn_BAR(dmac) : HW_APBH_CHn_BAR(dmac);
if(flags & DMA_INFO_AHB_BYTES)
- s.ahb_bytes = apbx ? BF_RDn(APBX_CHn_DEBUG2, dmac, AHB_BYTES) : BF_RDn(APBH_CHn_DEBUG2, dmac, AHB_BYTES);
+ s.ahb_bytes = apbx ? BF_RD(APBX_CHn_DEBUG2(dmac), AHB_BYTES) : BF_RD(APBH_CHn_DEBUG2(dmac), AHB_BYTES);
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);
+ s.apb_bytes = apbx ? BF_RD(APBX_CHn_DEBUG2(dmac), APB_BYTES) : BF_RD(APBH_CHn_DEBUG2(dmac), APB_BYTES);
if(flags & DMA_INFO_FROZEN)
#if IMX233_SUBTARGET < 3780
s.frozen = !!((apbx ? BF_RD(APBX_CTRL0, FREEZE_CHANNEL) : BF_RD(APBH_CTRL0, FREEZE_CHANNEL)) & bm);