/*1* 2006-2009 (C) DENX Software Engineering.2*3* Author: Yuri Tikhonov <[email protected]>4*5* This file is licensed under the terms of the GNU General Public License6* version 2. This program is licensed "as is" without any warranty of7* any kind, whether express or implied.8*/910#ifndef _PPC440SPE_ADMA_H11#define _PPC440SPE_ADMA_H1213#include <linux/types.h>14#include "dma.h"15#include "xor.h"1617#define to_ppc440spe_adma_chan(chan) \18container_of(chan, struct ppc440spe_adma_chan, common)19#define to_ppc440spe_adma_device(dev) \20container_of(dev, struct ppc440spe_adma_device, common)21#define tx_to_ppc440spe_adma_slot(tx) \22container_of(tx, struct ppc440spe_adma_desc_slot, async_tx)2324/* Default polynomial (for 440SP is only available) */25#define PPC440SPE_DEFAULT_POLY 0x4d2627#define PPC440SPE_ADMA_ENGINES_NUM (XOR_ENGINES_NUM + DMA_ENGINES_NUM)2829#define PPC440SPE_ADMA_WATCHDOG_MSEC 330#define PPC440SPE_ADMA_THRESHOLD 13132#define PPC440SPE_DMA0_ID 033#define PPC440SPE_DMA1_ID 134#define PPC440SPE_XOR_ID 23536#define PPC440SPE_ADMA_DMA_MAX_BYTE_COUNT 0xFFFFFFUL37/* this is the XOR_CBBCR width */38#define PPC440SPE_ADMA_XOR_MAX_BYTE_COUNT (1 << 31)39#define PPC440SPE_ADMA_ZERO_SUM_MAX_BYTE_COUNT PPC440SPE_ADMA_XOR_MAX_BYTE_COUNT4041#define PPC440SPE_RXOR_RUN 04243#define MQ0_CF2H_RXOR_BS_MASK 0x1FF4445#undef ADMA_LL_DEBUG4647/**48* struct ppc440spe_adma_device - internal representation of an ADMA device49* @dev: device50* @dma_reg: base for DMAx register access51* @xor_reg: base for XOR register access52* @i2o_reg: base for I2O register access53* @id: HW ADMA Device selector54* @dma_desc_pool_virt: base of DMA descriptor region (CPU address)55* @dma_desc_pool: base of DMA descriptor region (DMA address)56* @pool_size: size of the pool57* @irq: DMAx or XOR irq number58* @err_irq: DMAx error irq number59* @common: embedded struct dma_device60*/61struct ppc440spe_adma_device {62struct device *dev;63struct dma_regs __iomem *dma_reg;64struct xor_regs __iomem *xor_reg;65struct i2o_regs __iomem *i2o_reg;66int id;67void *dma_desc_pool_virt;68dma_addr_t dma_desc_pool;69size_t pool_size;70int irq;71int err_irq;72struct dma_device common;73};7475/**76* struct ppc440spe_adma_chan - internal representation of an ADMA channel77* @lock: serializes enqueue/dequeue operations to the slot pool78* @device: parent device79* @chain: device chain view of the descriptors80* @common: common dmaengine channel object members81* @all_slots: complete domain of slots usable by the channel82* @pending: allows batching of hardware operations83* @completed_cookie: identifier for the most recently completed operation84* @slots_allocated: records the actual size of the descriptor slot pool85* @hw_chain_inited: h/w descriptor chain initialization flag86* @irq_tasklet: bottom half where ppc440spe_adma_slot_cleanup runs87* @needs_unmap: if buffers should not be unmapped upon final processing88* @pdest_page: P destination page for async validate operation89* @qdest_page: Q destination page for async validate operation90* @pdest: P dma addr for async validate operation91* @qdest: Q dma addr for async validate operation92*/93struct ppc440spe_adma_chan {94spinlock_t lock;95struct ppc440spe_adma_device *device;96struct list_head chain;97struct dma_chan common;98struct list_head all_slots;99struct ppc440spe_adma_desc_slot *last_used;100int pending;101dma_cookie_t completed_cookie;102int slots_allocated;103int hw_chain_inited;104struct tasklet_struct irq_tasklet;105u8 needs_unmap;106struct page *pdest_page;107struct page *qdest_page;108dma_addr_t pdest;109dma_addr_t qdest;110};111112struct ppc440spe_rxor {113u32 addrl;114u32 addrh;115int len;116int xor_count;117int addr_count;118int desc_count;119int state;120};121122/**123* struct ppc440spe_adma_desc_slot - PPC440SPE-ADMA software descriptor124* @phys: hardware address of the hardware descriptor chain125* @group_head: first operation in a transaction126* @hw_next: pointer to the next descriptor in chain127* @async_tx: support for the async_tx api128* @slot_node: node on the iop_adma_chan.all_slots list129* @chain_node: node on the op_adma_chan.chain list130* @group_list: list of slots that make up a multi-descriptor transaction131* for example transfer lengths larger than the supported hw max132* @unmap_len: transaction bytecount133* @hw_desc: virtual address of the hardware descriptor chain134* @stride: currently chained or not135* @idx: pool index136* @slot_cnt: total slots used in an transaction (group of operations)137* @src_cnt: number of sources set in this descriptor138* @dst_cnt: number of destinations set in the descriptor139* @slots_per_op: number of slots per operation140* @descs_per_op: number of slot per P/Q operation see comment141* for ppc440spe_prep_dma_pqxor function142* @flags: desc state/type143* @reverse_flags: 1 if a corresponding rxor address uses reversed address order144* @xor_check_result: result of zero sum145* @crc32_result: result crc calculation146*/147struct ppc440spe_adma_desc_slot {148dma_addr_t phys;149struct ppc440spe_adma_desc_slot *group_head;150struct ppc440spe_adma_desc_slot *hw_next;151struct dma_async_tx_descriptor async_tx;152struct list_head slot_node;153struct list_head chain_node; /* node in channel ops list */154struct list_head group_list; /* list */155unsigned int unmap_len;156void *hw_desc;157u16 stride;158u16 idx;159u16 slot_cnt;160u8 src_cnt;161u8 dst_cnt;162u8 slots_per_op;163u8 descs_per_op;164unsigned long flags;165unsigned long reverse_flags[8];166167#define PPC440SPE_DESC_INT 0 /* generate interrupt on complete */168#define PPC440SPE_ZERO_P 1 /* clear P destionaion */169#define PPC440SPE_ZERO_Q 2 /* clear Q destination */170#define PPC440SPE_COHERENT 3 /* src/dst are coherent */171172#define PPC440SPE_DESC_WXOR 4 /* WXORs are in chain */173#define PPC440SPE_DESC_RXOR 5 /* RXOR is in chain */174175#define PPC440SPE_DESC_RXOR123 8 /* CDB for RXOR123 operation */176#define PPC440SPE_DESC_RXOR124 9 /* CDB for RXOR124 operation */177#define PPC440SPE_DESC_RXOR125 10 /* CDB for RXOR125 operation */178#define PPC440SPE_DESC_RXOR12 11 /* CDB for RXOR12 operation */179#define PPC440SPE_DESC_RXOR_REV 12 /* CDB has srcs in reversed order */180181#define PPC440SPE_DESC_PCHECK 13182#define PPC440SPE_DESC_QCHECK 14183184#define PPC440SPE_DESC_RXOR_MSK 0x3185186struct ppc440spe_rxor rxor_cursor;187188union {189u32 *xor_check_result;190u32 *crc32_result;191};192};193194#endif /* _PPC440SPE_ADMA_H */195196197