2011-06-17 22:30:58 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2012-12-29 00:32:59 +00:00
|
|
|
* Copyright (C) 2011 by Amaury Pouly
|
2011-06-17 22:30:58 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef __DMA_IMX233_H__
|
|
|
|
#define __DMA_IMX233_H__
|
|
|
|
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "system-target.h"
|
|
|
|
|
2013-06-16 16:19:59 +00:00
|
|
|
/************
|
|
|
|
* CHANNELS *
|
|
|
|
************/
|
2011-06-17 22:30:58 +00:00
|
|
|
|
2013-06-16 16:19:59 +00:00
|
|
|
#define APBH_DMA_CHANNEL(i) i
|
|
|
|
#define APBX_DMA_CHANNEL(i) ((i) | 0x10)
|
|
|
|
#define APB_IS_APBX_CHANNEL(x) ((x) & 0x10)
|
|
|
|
#define APB_GET_DMA_CHANNEL(x) ((x) & 0xf)
|
2011-06-17 22:30:58 +00:00
|
|
|
|
2013-06-16 22:16:19 +00:00
|
|
|
#if IMX233_SUBTARGET >= 3700
|
2013-06-16 16:19:59 +00:00
|
|
|
// NOTE: although undocumented, the iMX233 channel 0 is actually the LCDIF one
|
|
|
|
#define APB_LCDIF APBH_DMA_CHANNEL(0)
|
2013-06-16 22:16:19 +00:00
|
|
|
#else
|
|
|
|
#define APB_LCDIF APBX_DMA_CHANNEL(4)
|
|
|
|
#endif
|
2011-06-17 22:30:58 +00:00
|
|
|
|
2013-06-16 16:19:59 +00:00
|
|
|
#define APB_SSP(ssp) APBH_DMA_CHANNEL(ssp)
|
|
|
|
#define APB_GPMI(dev) APBH_DMA_CHANNEL(4 + (dev))
|
2011-06-17 22:30:58 +00:00
|
|
|
|
2013-06-16 16:19:59 +00:00
|
|
|
#define APB_AUDIO_ADC APBX_DMA_CHANNEL(0)
|
|
|
|
#define APB_AUDIO_DAC APBX_DMA_CHANNEL(1)
|
|
|
|
#define APB_I2C APBX_DMA_CHANNEL(3)
|
|
|
|
// NOTE: although undocumented, the IMX233 channel 5 is actually the DRI one
|
|
|
|
#define APB_DRI APBX_DMA_CHANNEL(5)
|
2011-06-17 22:30:58 +00:00
|
|
|
|
|
|
|
/**********
|
|
|
|
* COMMON *
|
|
|
|
**********/
|
|
|
|
|
2012-05-19 23:23:17 +00:00
|
|
|
/* DMA structures should be cache aligned and be padded so that their size
|
|
|
|
* is a multiple of a cache line size. Otherwise some nasty side effects
|
|
|
|
* could occur with adjacents data fields.
|
|
|
|
* The same apply to DMA buffers for the same reasons */
|
2011-06-17 22:30:58 +00:00
|
|
|
struct apb_dma_command_t
|
|
|
|
{
|
|
|
|
struct apb_dma_command_t *next;
|
|
|
|
uint32_t cmd;
|
|
|
|
void *buffer;
|
|
|
|
/* PIO words follow */
|
2013-01-26 18:22:54 +00:00
|
|
|
} __attribute__((packed));
|
2011-06-17 22:30:58 +00:00
|
|
|
|
2011-10-18 22:03:25 +00:00
|
|
|
#define DMA_INFO_CURCMDADDR (1 << 0)
|
|
|
|
#define DMA_INFO_NXTCMDADDR (1 << 1)
|
|
|
|
#define DMA_INFO_CMD (1 << 2)
|
|
|
|
#define DMA_INFO_BAR (1 << 3)
|
|
|
|
#define DMA_INFO_APB_BYTES (1 << 4)
|
|
|
|
#define DMA_INFO_AHB_BYTES (1 << 5)
|
2014-02-03 23:27:06 +00:00
|
|
|
#define DMA_INFO_FROZEN (1 << 6)
|
2011-10-18 22:03:25 +00:00
|
|
|
#define DMA_INFO_GATED (1 << 7)
|
|
|
|
#define DMA_INFO_INTERRUPT (1 << 8)
|
|
|
|
#define DMA_INFO_ALL 0x1ff
|
|
|
|
|
|
|
|
struct imx233_dma_info_t
|
|
|
|
{
|
|
|
|
unsigned long cur_cmd_addr;
|
|
|
|
unsigned long nxt_cmd_addr;
|
|
|
|
unsigned long cmd;
|
|
|
|
unsigned long bar;
|
|
|
|
unsigned apb_bytes;
|
|
|
|
unsigned ahb_bytes;
|
2014-02-03 23:27:06 +00:00
|
|
|
bool frozen;
|
2011-10-18 22:03:25 +00:00
|
|
|
bool gated;
|
|
|
|
bool int_enabled;
|
|
|
|
bool int_cmdcomplt;
|
|
|
|
bool int_error;
|
2012-08-18 13:22:51 +00:00
|
|
|
int nr_unaligned;
|
2011-10-18 22:03:25 +00:00
|
|
|
};
|
|
|
|
|
2013-06-16 16:19:59 +00:00
|
|
|
#define BM_APB_CHx_CMD_COMMAND 0x3
|
|
|
|
#define BP_APB_CHx_CMD_COMMAND 0
|
|
|
|
#define BF_APB_CHx_CMD_COMMAND(v) ((v) & 0x3)
|
|
|
|
#define BF_APB_CHx_CMD_COMMAND_V(v) BF_APB_CHx_CMD_COMMAND(BV_APB_CHx_CMD_COMMAND__##v)
|
|
|
|
#define BV_APB_CHx_CMD_COMMAND__NO_XFER 0
|
|
|
|
#define BV_APB_CHx_CMD_COMMAND__WRITE 1
|
|
|
|
#define BV_APB_CHx_CMD_COMMAND__READ 2
|
|
|
|
#define BV_APB_CHx_CMD_COMMAND__SENSE 3
|
|
|
|
#define BM_APB_CHx_CMD_CHAIN (1 << 2)
|
|
|
|
#define BP_APB_CHx_CMD_CHAIN 2
|
|
|
|
#define BF_APB_CHx_CMD_CHAIN(v) (((v) & 1) << 2)
|
|
|
|
#define BM_APB_CHx_CMD_IRQONCMPLT (1 << 3)
|
|
|
|
#define BP_APB_CHx_CMD_IRQONCMPLT 3
|
|
|
|
#define BF_APB_CHx_CMD_IRQONCMPLT(v) (((v) & 1) << 3)
|
2011-06-17 22:30:58 +00:00
|
|
|
/* those two are only available on APHB */
|
2013-06-16 16:19:59 +00:00
|
|
|
#define BM_APBH_CHx_CMD_NANDLOCK (1 << 4)
|
|
|
|
#define BP_APBH_CHx_CMD_NANDLOCK 4
|
|
|
|
#define BF_APBH_CHx_CMD_NANDLOCK(v) (((v) & 1) << 4)
|
|
|
|
#define BM_APBH_CHx_CMD_NANDWAIT4READY (1 << 5)
|
|
|
|
#define BP_APBH_CHx_CMD_NANDWAIT4READY 5
|
|
|
|
#define BF_APBH_CHx_CMD_NANDWAIT4READY(v) (((v) & 1) << 5)
|
|
|
|
|
|
|
|
#define BM_APB_CHx_CMD_SEMAPHORE (1 << 6)
|
|
|
|
#define BP_APB_CHx_CMD_SEMAPHORE 6
|
|
|
|
#define BF_APB_CHx_CMD_SEMAPHORE(v) (((v) & 1) << 6)
|
|
|
|
#define BM_APB_CHx_CMD_WAIT4ENDCMD (1 << 7)
|
|
|
|
#define BP_APB_CHx_CMD_WAIT4ENDCMD 7
|
|
|
|
#define BF_APB_CHx_CMD_WAIT4ENDCMD(v) (((v) & 1) << 7)
|
|
|
|
/** WARNING: An errata advise not to use it */
|
|
|
|
#define BM_APB_CHx_CMD_HALTONTERMINATE (1 << 8)
|
|
|
|
#define BP_APB_CHx_CMD_HALTONTERMINATE 8
|
|
|
|
#define BF_APB_CHx_CMD_HALTONTERMINATE(v) (((v) & 1) << 8)
|
|
|
|
#define BM_APB_CHx_CMD_CMDWORDS 0xf000
|
|
|
|
#define BP_APB_CHx_CMD_CMDWORDS 12
|
|
|
|
#define BF_APB_CHx_CMD_CMDWORDS(v) (((v) & 0xf) << 12)
|
|
|
|
#define BM_APB_CHx_CMD_XFER_COUNT 0xffff0000
|
|
|
|
#define BP_APB_CHx_CMD_XFER_COUNT 16
|
|
|
|
#define BF_APB_CHx_CMD_XFER_COUNT(v) (((v) & 0xffff) << 16)
|
2011-07-23 11:45:22 +00:00
|
|
|
/* For software use */
|
2013-06-16 16:19:59 +00:00
|
|
|
#define BP_APB_CHx_CMD_UNUSED 8
|
|
|
|
#define BM_APB_CHx_CMD_UNUSED (0xf << 8)
|
|
|
|
#define BF_APB_CHx_CMD_UNUSED(v) (((v) & 0xf) << 8)
|
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
2016-05-24 19:29:56 +00:00
|
|
|
#define BF_APB_CHx_CMD_UNUSED_V(n) BF_APB_CHx_CMD_UNUSED(BV_APB_CHx_CMD_UNUSED__##n)
|
|
|
|
#define BFM_APB_CHx_CMD_UNUSED(v) BM_APB_CHx_CMD_UNUSED
|
2013-06-16 16:19:59 +00:00
|
|
|
#define BV_APB_CHx_CMD_UNUSED__MAGIC 0xa
|
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
2016-05-24 19:29:56 +00:00
|
|
|
#define BFM_APB_CHx_CMD_UNUSED_V(v) BM_APB_CHx_CMD_UNUSED
|
2011-06-17 22:30:58 +00:00
|
|
|
|
2012-08-18 13:22:51 +00:00
|
|
|
/* A single descriptor cannot transfer more than 2^16 bytes but because of the
|
|
|
|
* weird 0=64KiB, it's safer to restrict to 2^15 */
|
2013-08-20 16:28:40 +00:00
|
|
|
#define IMX233_MAX_SINGLE_DMA_XFER_SIZE (1 << 16)
|
2011-09-13 23:38:56 +00:00
|
|
|
|
2011-06-17 22:30:58 +00:00
|
|
|
void imx233_dma_init(void);
|
|
|
|
void imx233_dma_reset_channel(unsigned chan);
|
|
|
|
/* only apbh channel have clkgate control */
|
|
|
|
void imx233_dma_clkgate_channel(unsigned chan, bool enable_clock);
|
|
|
|
|
2011-10-18 22:03:25 +00:00
|
|
|
void imx233_dma_freeze_channel(unsigned chan, bool freeze);
|
2011-06-17 22:30:58 +00:00
|
|
|
void imx233_dma_enable_channel_interrupt(unsigned chan, bool enable);
|
|
|
|
/* clear both channel complete and error bits */
|
|
|
|
void imx233_dma_clear_channel_interrupt(unsigned chan);
|
|
|
|
bool imx233_dma_is_channel_error_irq(unsigned chan);
|
|
|
|
/* assume no command is in progress */
|
2013-06-16 22:16:19 +00:00
|
|
|
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) */
|
2011-06-17 22:30:58 +00:00
|
|
|
void imx233_dma_start_command(unsigned chan, struct apb_dma_command_t *cmd);
|
2012-08-18 13:22:51 +00:00
|
|
|
/* return value of the semaphore */
|
|
|
|
int imx233_dma_wait_completion(unsigned chan, unsigned tmo);
|
2011-10-18 22:03:25 +00:00
|
|
|
/* get some info
|
|
|
|
* WARNING: if channel is not freezed, data might not be coherent ! */
|
|
|
|
struct imx233_dma_info_t imx233_dma_get_info(unsigned chan, unsigned flags);
|
2011-06-17 22:30:58 +00:00
|
|
|
|
|
|
|
#endif // __DMA_IMX233_H__
|