tegra124: Clean up some #defines for DMA
This shortens the grostesquely huge APBDMACHAN_* defines by removing unecessary prefixes. Names of fields which appeared at the end of these huge #defines are preserved as they are presented in the manual, so searching for them is still easy. The goal is to make it so that we can actually use the #defines without the code becoming a hideous, line-broken mess. As they were, the #defines made code so ugly that it actually became less readable. Additionally, a couple trivial issues were found and fixed: - Removes duplicate AHB bus width #defines - Removes a non-sensical #define that seems to be a result of an incompleted copy+paste job. BUG=none BRANCH=none TEST=built and booted on Nyan Signed-off-by: David Hendricks <dhendrix@chromium.org> Change-Id: I72195ff08ef51bb645a1e1ae5a11346998a12635 Reviewed-on: https://chromium-review.googlesource.com/175631 Commit-Queue: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org> Reviewed-by: Gabe Black <gabeblack@chromium.org>
This commit is contained in:
parent
b8eb6ab4cd
commit
1a0a900f2d
3 changed files with 62 additions and 64 deletions
|
|
@ -73,7 +73,7 @@ int dma_busy(struct apb_dma_channel * const channel)
|
|||
* as the channel is enabled. So for this function we'll use the
|
||||
* DMA_ACTIVITY bit.
|
||||
*/
|
||||
return read32(&channel->regs->sta) & APBDMACHAN_STA_DMA_ACTIVITY ? 1 : 0;
|
||||
return read32(&channel->regs->sta) & APB_STA_DMA_ACTIVITY ? 1 : 0;
|
||||
}
|
||||
/* claim a DMA channel */
|
||||
struct apb_dma_channel * const dma_claim(void)
|
||||
|
|
@ -85,7 +85,7 @@ struct apb_dma_channel * const dma_claim(void)
|
|||
* Set global enable bit, otherwise register access to channel
|
||||
* DMA registers will not be possible.
|
||||
*/
|
||||
setbits_le32(&apb_dma->command, APBDMA_COMMAND_GEN);
|
||||
setbits_le32(&apb_dma->command, APB_COMMAND_GEN);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(apb_dma_channels); i++) {
|
||||
regs = apb_dma_channels[i].regs;
|
||||
|
|
@ -125,7 +125,7 @@ void dma_release(struct apb_dma_channel * const channel)
|
|||
return;
|
||||
}
|
||||
|
||||
clrbits_le32(&apb_dma->command, APBDMA_COMMAND_GEN);
|
||||
clrbits_le32(&apb_dma->command, APB_COMMAND_GEN);
|
||||
}
|
||||
|
||||
int dma_start(struct apb_dma_channel * const channel)
|
||||
|
|
@ -133,7 +133,7 @@ int dma_start(struct apb_dma_channel * const channel)
|
|||
struct apb_dma_channel_regs *regs = channel->regs;
|
||||
|
||||
/* Set ENB bit for this channel */
|
||||
setbits_le32(®s->csr, APBDMACHAN_CSR_ENB);
|
||||
setbits_le32(®s->csr, APB_CSR_ENB);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -143,7 +143,7 @@ int dma_stop(struct apb_dma_channel * const channel)
|
|||
struct apb_dma_channel_regs *regs = channel->regs;
|
||||
|
||||
/* Clear ENB bit for this channel */
|
||||
clrbits_le32(®s->csr, APBDMACHAN_CSR_ENB);
|
||||
clrbits_le32(®s->csr, APB_CSR_ENB);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,20 +33,20 @@
|
|||
* bit controls or represents the status for the corresponding channel.
|
||||
* So we will not bother to list each individual bit in this case.
|
||||
*/
|
||||
#define APBDMA_COMMAND_GEN (1 << 31)
|
||||
#define APB_COMMAND_GEN (1 << 31)
|
||||
|
||||
#define APBDMA_CNTRL_REG_COUNT_VALUE_MASK 0xffff
|
||||
#define APBDMA_CNTRL_REG_COUNT_VALUE_SHIFT 0
|
||||
#define APB_CNTRL_REG_COUNT_VALUE_MASK 0xffff
|
||||
#define APB_CNTRL_REG_COUNT_VALUE_SHIFT 0
|
||||
|
||||
/*
|
||||
* Note: Many APB DMA controller registers are laid out such that each
|
||||
* bit controls or represents the status for the corresponding channel.
|
||||
* So we will not bother to list each individual bit in this case.
|
||||
*/
|
||||
#define APBDMA_COMMAND_GEN (1 << 31)
|
||||
#define APB_COMMAND_GEN (1 << 31)
|
||||
|
||||
#define APBDMA_CNTRL_REG_COUNT_VALUE_MASK 0xffff
|
||||
#define APBDMA_CNTRL_REG_COUNT_VALUE_SHIFT 0
|
||||
#define APB_CNTRL_REG_COUNT_VALUE_MASK 0xffff
|
||||
#define APB_CNTRL_REG_COUNT_VALUE_SHIFT 0
|
||||
struct apb_dma {
|
||||
u32 command; /* 0x00 */
|
||||
u32 status; /* 0x04 */
|
||||
|
|
@ -75,14 +75,14 @@ struct apb_dma {
|
|||
* Naming in the doc included a superfluous _CHANNEL_n_ for
|
||||
* each entry and was left out for the sake of conciseness.
|
||||
*/
|
||||
#define APBDMACHAN_CSR_ENB (1 << 31)
|
||||
#define APBDMACHAN_CSR_IE_EOC (1 << 30)
|
||||
#define APBDMACHAN_CSR_HOLD (1 << 29)
|
||||
#define APBDMACHAN_CSR_DIR (1 << 28)
|
||||
#define APBDMACHAN_CSR_ONCE (1 << 27)
|
||||
#define APBDMACHAN_CSR_FLOW (1 << 21)
|
||||
#define APBDMACHAN_CSR_REQ_SEL_MASK 0x1f
|
||||
#define APBDMACHAN_CSR_REQ_SEL_SHIFT 16
|
||||
#define APB_CSR_ENB (1 << 31)
|
||||
#define APB_CSR_IE_EOC (1 << 30)
|
||||
#define APB_CSR_HOLD (1 << 29)
|
||||
#define APB_CSR_DIR (1 << 28)
|
||||
#define APB_CSR_ONCE (1 << 27)
|
||||
#define APB_CSR_FLOW (1 << 21)
|
||||
#define APB_CSR_REQ_SEL_MASK 0x1f
|
||||
#define APB_CSR_REQ_SEL_SHIFT 16
|
||||
|
||||
enum apbdmachan_req_sel {
|
||||
APBDMA_SLAVE_CNTR_REQ = 0,
|
||||
|
|
@ -119,46 +119,41 @@ enum apbdmachan_req_sel {
|
|||
APBDMA_SLAVE_NA31 = 31,
|
||||
};
|
||||
|
||||
#define APBDMACHAN_STA_BSY (1 << 31)
|
||||
#define APBDMACHAN_STA_ISE_EOC (1 << 30)
|
||||
#define APBDMACHAN_STA_HALT (1 << 29)
|
||||
#define APBDMACHAN_STA_PING_PONG_STA (1 << 28)
|
||||
#define APBDMACHAN_STA_DMA_ACTIVITY (1 << 27)
|
||||
#define APBDMACHAN_STA_CHANNEL_PAUSE (1 << 26)
|
||||
#define APB_STA_BSY (1 << 31)
|
||||
#define APB_STA_ISE_EOC (1 << 30)
|
||||
#define APB_STA_HALT (1 << 29)
|
||||
#define APB_STA_PING_PONG_STA (1 << 28)
|
||||
#define APB_STA_DMA_ACTIVITY (1 << 27)
|
||||
#define APB_STA_CHANNEL_PAUSE (1 << 26)
|
||||
|
||||
#define APBDMACHAN_CSRE_CHANNEL_PAUSE (1 << 31)
|
||||
#define APBDMACHAN_CSRE_TRIG_SEL_MASK 0x3f
|
||||
#define APBDMACHAN_CSRE_TRIG_SEL_SHIFT 14
|
||||
#define APB_CSRE_CHANNEL_PAUSE (1 << 31)
|
||||
#define APB_CSRE_TRIG_SEL_MASK 0x3f
|
||||
#define APB_CSRE_TRIG_SEL_SHIFT 14
|
||||
|
||||
#define APBDMACHAN_AHB_PTR_MASK (0x3fffffff)
|
||||
#define APBDMACHAN_AHB_PTR_SHIFT 2
|
||||
#define AHB_PTR_MASK (0x3fffffff)
|
||||
#define AHB_PTR_SHIFT 2
|
||||
|
||||
#define APBDMACHAN_AHB_SEQ_INTR_ENB (1 << 31)
|
||||
#define APBDMACHAN_AHB_SEQ_AHB_BUS_WIDTH_MASK 0x7
|
||||
#define APBDMACHAN_AHB_SEQ_AHB_BUS_WIDTH_SHIFT 28
|
||||
#define APBDMACHAN_AHB_SEQ_AHB_DATA_SWAP (1 << 27)
|
||||
#define APBDMACHAN_AHB_SEQ_AHB_BURST_MASK 0x7
|
||||
#define APBDMACHAN_AHB_SEQ_AHB_BURST_SHIFT 24
|
||||
#define APBDMACHAN_AHB_SEQ_DBL_BUF (1 << 19)
|
||||
#define APBDMACHAN_AHB_SEQ_WRAP_MASK 0x7
|
||||
#define APBDMACHAN_AHB_SEQ_WRAP_SHIFT 16
|
||||
#define AHB_SEQ_INTR_ENB (1 << 31)
|
||||
#define AHB_BUS_WIDTH_MASK 0x7
|
||||
#define AHB_BUS_WIDTH_SHIFT 28
|
||||
#define AHB_DATA_SWAP (1 << 27)
|
||||
#define AHB_BURST_MASK 0x7
|
||||
#define AHB_BURST_SHIFT 24
|
||||
#define AHB_SEQ_DBL_BUF (1 << 19)
|
||||
#define AHB_SEQ_WRAP_MASK 0x7
|
||||
#define AHB_SEQ_WRAP_SHIFT 16
|
||||
|
||||
#define APBDMACHAN_AHB_SEQ_AHB_BUS_WIDTH_MASK 0x7
|
||||
#define APBDMACHAN_AHB_SEQ_AHB_BUS_WIDTH_SHIFT 28
|
||||
#define APB_PTR_MASK 0x3fffffff
|
||||
#define APB_PTR_SHIFT 2
|
||||
|
||||
#define APBDMACHAN_APB_PTR_MASK 0x3fffffff
|
||||
#define APBDMACHAN_APB_PTR_SHIFT 2
|
||||
#define APB_BUS_WIDTH_MASK 0x7
|
||||
#define APB_BUS_WIDTH_SHIFT 28
|
||||
#define APB_DATA_SWAP (1 << 27)
|
||||
#define APB_ADDR_WRAP_MASK 0x7
|
||||
#define APB_ADDR_WRAP_SHIFT 16
|
||||
|
||||
#define APBDMACHAN_APB_SEQ_APB_BUS_WIDTH_MASK 0x7
|
||||
#define APBDMACHAN_APB_SEQ_APB_BUS_WIDTH_SHIFT 28
|
||||
#define APBDMACHAN_APB_SEQ_APB_DATA_SWAP (1 << 27)
|
||||
#define APBDMACHAN_APB_SEQ_APB_ADDR_WRAP_MASK 0x7
|
||||
#define APBDMACHAN_APB_SEQ_APB_ADDR_WRAP_SHIFT 16
|
||||
|
||||
#define APBDMACHAN_WORD_TRANSFER_
|
||||
|
||||
#define APBDMACHAN_WORD_TRANSFER_MASK 0x0fffffff
|
||||
#define APBDMACHAN_WORD_TRANSFER_SHIFT 2
|
||||
#define APB_WORD_TRANSFER_MASK 0x0fffffff
|
||||
#define APB_WORD_TRANSFER_SHIFT 2
|
||||
|
||||
struct apb_dma_channel_regs {
|
||||
u32 csr; /* 0x00 */
|
||||
|
|
|
|||
|
|
@ -408,13 +408,16 @@ static void setup_dma_params(struct tegra_spi_channel *spi,
|
|||
struct apb_dma_channel *dma)
|
||||
{
|
||||
/* APB bus width = 8-bits, address wrap for each word */
|
||||
clrbits_le32(&dma->regs->apb_seq, 0x7 << 28);
|
||||
clrbits_le32(&dma->regs->apb_seq,
|
||||
AHB_BUS_WIDTH_MASK << AHB_BUS_WIDTH_SHIFT);
|
||||
/* AHB 1 word burst, bus width = 32 bits (fixed in hardware),
|
||||
* no address wrapping */
|
||||
clrsetbits_le32(&dma->regs->ahb_seq,
|
||||
(0x7 << 24) | (0x7 << 16), 0x4 << 24);
|
||||
(AHB_BURST_MASK << AHB_BURST_SHIFT) |
|
||||
(AHB_SEQ_WRAP_MASK << AHB_SEQ_WRAP_SHIFT),
|
||||
AHB_BURST_MASK << AHB_BURST_SHIFT);
|
||||
/* Set ONCE mode to transfer one "blocK" at a time (64KB). */
|
||||
setbits_le32(&dma->regs->csr, 1 << 27);
|
||||
setbits_le32(&dma->regs->csr, APB_CSR_ONCE);
|
||||
}
|
||||
|
||||
static int tegra_spi_dma_prepare(struct tegra_spi_channel *spi,
|
||||
|
|
@ -447,7 +450,7 @@ static int tegra_spi_dma_prepare(struct tegra_spi_channel *spi,
|
|||
|
||||
write32((u32)&spi->regs->tx_fifo, &spi->dma_out->regs->apb_ptr);
|
||||
write32((u32)spi->out_buf, &spi->dma_out->regs->ahb_ptr);
|
||||
setbits_le32(&spi->dma_out->regs->csr, APBDMACHAN_CSR_DIR);
|
||||
setbits_le32(&spi->dma_out->regs->csr, APB_CSR_DIR);
|
||||
setup_dma_params(spi, spi->dma_out);
|
||||
write32(wcount, &spi->dma_out->regs->wcount);
|
||||
} else {
|
||||
|
|
@ -460,7 +463,7 @@ static int tegra_spi_dma_prepare(struct tegra_spi_channel *spi,
|
|||
|
||||
write32((u32)&spi->regs->rx_fifo, &spi->dma_in->regs->apb_ptr);
|
||||
write32((u32)spi->in_buf, &spi->dma_in->regs->ahb_ptr);
|
||||
clrbits_le32(&spi->dma_in->regs->csr, APBDMACHAN_CSR_DIR);
|
||||
clrbits_le32(&spi->dma_in->regs->csr, APB_CSR_DIR);
|
||||
setup_dma_params(spi, spi->dma_in);
|
||||
write32(wcount, &spi->dma_in->regs->wcount);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue