Path: blob/master/drivers/dma/intel_mid_dma_regs.h
15109 views
/*1* intel_mid_dma_regs.h - Intel MID DMA Drivers2*3* Copyright (C) 2008-10 Intel Corp4* Author: Vinod Koul <[email protected]>5* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License as published by9* the Free Software Foundation; version 2 of the License.10*11* This program is distributed in the hope that it will be useful, but12* WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU14* General Public License for more details.15*16* You should have received a copy of the GNU General Public License along17* with this program; if not, write to the Free Software Foundation, Inc.,18* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.19*20* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~21*22*23*/24#ifndef __INTEL_MID_DMAC_REGS_H__25#define __INTEL_MID_DMAC_REGS_H__2627#include <linux/dmaengine.h>28#include <linux/dmapool.h>29#include <linux/pci_ids.h>3031#define INTEL_MID_DMA_DRIVER_VERSION "1.1.0"3233#define REG_BIT0 0x0000000134#define REG_BIT8 0x0000010035#define INT_MASK_WE 0x836#define CLEAR_DONE 0xFFFFEFFF37#define UNMASK_INTR_REG(chan_num) \38((REG_BIT0 << chan_num) | (REG_BIT8 << chan_num))39#define MASK_INTR_REG(chan_num) (REG_BIT8 << chan_num)4041#define ENABLE_CHANNEL(chan_num) \42((REG_BIT0 << chan_num) | (REG_BIT8 << chan_num))4344#define DISABLE_CHANNEL(chan_num) \45(REG_BIT8 << chan_num)4647#define DESCS_PER_CHANNEL 1648/*DMA Registers*/49/*registers associated with channel programming*/50#define DMA_REG_SIZE 0x40051#define DMA_CH_SIZE 0x585253/*CH X REG = (DMA_CH_SIZE)*CH_NO + REG*/54#define SAR 0x00 /* Source Address Register*/55#define DAR 0x08 /* Destination Address Register*/56#define LLP 0x10 /* Linked List Pointer Register*/57#define CTL_LOW 0x18 /* Control Register*/58#define CTL_HIGH 0x1C /* Control Register*/59#define CFG_LOW 0x40 /* Configuration Register Low*/60#define CFG_HIGH 0x44 /* Configuration Register high*/6162#define STATUS_TFR 0x2E863#define STATUS_BLOCK 0x2F064#define STATUS_ERR 0x3086566#define RAW_TFR 0x2C067#define RAW_BLOCK 0x2C868#define RAW_ERR 0x2E06970#define MASK_TFR 0x31071#define MASK_BLOCK 0x31872#define MASK_SRC_TRAN 0x32073#define MASK_DST_TRAN 0x32874#define MASK_ERR 0x3307576#define CLEAR_TFR 0x33877#define CLEAR_BLOCK 0x34078#define CLEAR_SRC_TRAN 0x34879#define CLEAR_DST_TRAN 0x35080#define CLEAR_ERR 0x3588182#define INTR_STATUS 0x36083#define DMA_CFG 0x39884#define DMA_CHAN_EN 0x3A08586/*DMA channel control registers*/87union intel_mid_dma_ctl_lo {88struct {89u32 int_en:1; /*enable or disable interrupts*/90/*should be 0*/91u32 dst_tr_width:3; /*destination transfer width*/92/*usually 32 bits = 010*/93u32 src_tr_width:3; /*source transfer width*/94/*usually 32 bits = 010*/95u32 dinc:2; /*destination address inc/dec*/96/*For mem:INC=00, Periphral NoINC=11*/97u32 sinc:2; /*source address inc or dec, as above*/98u32 dst_msize:3; /*destination burst transaction length*/99/*always = 16 ie 011*/100u32 src_msize:3; /*source burst transaction length*/101/*always = 16 ie 011*/102u32 reser1:3;103u32 tt_fc:3; /*transfer type and flow controller*/104/*M-M = 000105P-M = 010106M-P = 001*/107u32 dms:2; /*destination master select = 0*/108u32 sms:2; /*source master select = 0*/109u32 llp_dst_en:1; /*enable/disable destination LLP = 0*/110u32 llp_src_en:1; /*enable/disable source LLP = 0*/111u32 reser2:3;112} ctlx;113u32 ctl_lo;114};115116union intel_mid_dma_ctl_hi {117struct {118u32 block_ts:12; /*block transfer size*/119u32 done:1; /*Done - updated by DMAC*/120u32 reser:19; /*configured by DMAC*/121} ctlx;122u32 ctl_hi;123124};125126/*DMA channel configuration registers*/127union intel_mid_dma_cfg_lo {128struct {129u32 reser1:5;130u32 ch_prior:3; /*channel priority = 0*/131u32 ch_susp:1; /*channel suspend = 0*/132u32 fifo_empty:1; /*FIFO empty or not R bit = 0*/133u32 hs_sel_dst:1; /*select HW/SW destn handshaking*/134/*HW = 0, SW = 1*/135u32 hs_sel_src:1; /*select HW/SW src handshaking*/136u32 reser2:6;137u32 dst_hs_pol:1; /*dest HS interface polarity*/138u32 src_hs_pol:1; /*src HS interface polarity*/139u32 max_abrst:10; /*max AMBA burst len = 0 (no sw limit*/140u32 reload_src:1; /*auto reload src addr =1 if src is P*/141u32 reload_dst:1; /*AR destn addr =1 if dstn is P*/142} cfgx;143u32 cfg_lo;144};145146union intel_mid_dma_cfg_hi {147struct {148u32 fcmode:1; /*flow control mode = 1*/149u32 fifo_mode:1; /*FIFO mode select = 1*/150u32 protctl:3; /*protection control = 0*/151u32 rsvd:2;152u32 src_per:4; /*src hw HS interface*/153u32 dst_per:4; /*dstn hw HS interface*/154u32 reser2:17;155} cfgx;156u32 cfg_hi;157};158159160/**161* struct intel_mid_dma_chan - internal mid representation of a DMA channel162* @chan: dma_chan strcture represetation for mid chan163* @ch_regs: MMIO register space pointer to channel register164* @dma_base: MMIO register space DMA engine base pointer165* @ch_id: DMA channel id166* @lock: channel spinlock167* @completed: DMA cookie168* @active_list: current active descriptors169* @queue: current queued up descriptors170* @free_list: current free descriptors171* @slave: dma slave struture172* @descs_allocated: total number of decsiptors allocated173* @dma: dma device struture pointer174* @busy: bool representing if ch is busy (active txn) or not175* @in_use: bool representing if ch is in use or not176* @raw_tfr: raw trf interrupt received177* @raw_block: raw block interrupt received178*/179struct intel_mid_dma_chan {180struct dma_chan chan;181void __iomem *ch_regs;182void __iomem *dma_base;183int ch_id;184spinlock_t lock;185dma_cookie_t completed;186struct list_head active_list;187struct list_head queue;188struct list_head free_list;189unsigned int descs_allocated;190struct middma_device *dma;191bool busy;192bool in_use;193u32 raw_tfr;194u32 raw_block;195struct intel_mid_dma_slave *mid_slave;196};197198static inline struct intel_mid_dma_chan *to_intel_mid_dma_chan(199struct dma_chan *chan)200{201return container_of(chan, struct intel_mid_dma_chan, chan);202}203204enum intel_mid_dma_state {205RUNNING = 0,206SUSPENDED,207};208/**209* struct middma_device - internal representation of a DMA device210* @pdev: PCI device211* @dma_base: MMIO register space pointer of DMA212* @dma_pool: for allocating DMA descriptors213* @common: embedded struct dma_device214* @tasklet: dma tasklet for processing interrupts215* @ch: per channel data216* @pci_id: DMA device PCI ID217* @intr_mask: Interrupt mask to be used218* @mask_reg: MMIO register for periphral mask219* @chan_base: Base ch index (read from driver data)220* @max_chan: max number of chs supported (from drv_data)221* @block_size: Block size of DMA transfer supported (from drv_data)222* @pimr_mask: MMIO register addr for periphral interrupt (from drv_data)223* @state: dma PM device state224*/225struct middma_device {226struct pci_dev *pdev;227void __iomem *dma_base;228struct pci_pool *dma_pool;229struct dma_device common;230struct tasklet_struct tasklet;231struct intel_mid_dma_chan ch[MAX_CHAN];232unsigned int pci_id;233unsigned int intr_mask;234void __iomem *mask_reg;235int chan_base;236int max_chan;237int block_size;238unsigned int pimr_mask;239enum intel_mid_dma_state state;240};241242static inline struct middma_device *to_middma_device(struct dma_device *common)243{244return container_of(common, struct middma_device, common);245}246247struct intel_mid_dma_desc {248void __iomem *block; /*ch ptr*/249struct list_head desc_node;250struct dma_async_tx_descriptor txd;251size_t len;252dma_addr_t sar;253dma_addr_t dar;254u32 cfg_hi;255u32 cfg_lo;256u32 ctl_lo;257u32 ctl_hi;258struct pci_pool *lli_pool;259struct intel_mid_dma_lli *lli;260dma_addr_t lli_phys;261unsigned int lli_length;262unsigned int current_lli;263dma_addr_t next;264enum dma_data_direction dirn;265enum dma_status status;266enum dma_slave_buswidth width; /*width of DMA txn*/267enum intel_mid_dma_mode cfg_mode; /*mode configuration*/268269};270271struct intel_mid_dma_lli {272dma_addr_t sar;273dma_addr_t dar;274dma_addr_t llp;275u32 ctl_lo;276u32 ctl_hi;277} __attribute__ ((packed));278279static inline int test_ch_en(void __iomem *dma, u32 ch_no)280{281u32 en_reg = ioread32(dma + DMA_CHAN_EN);282return (en_reg >> ch_no) & 0x1;283}284285static inline struct intel_mid_dma_desc *to_intel_mid_dma_desc286(struct dma_async_tx_descriptor *txd)287{288return container_of(txd, struct intel_mid_dma_desc, txd);289}290291static inline struct intel_mid_dma_slave *to_intel_mid_dma_slave292(struct dma_slave_config *slave)293{294return container_of(slave, struct intel_mid_dma_slave, dma_slave);295}296297298int dma_resume(struct pci_dev *pci);299300#endif /*__INTEL_MID_DMAC_REGS_H__*/301302303