/*1* linux/amba/pl08x.h - ARM PrimeCell DMA Controller driver2*3* Copyright (C) 2005 ARM Ltd4* Copyright (C) 2010 ST-Ericsson SA5*6* This program is free software; you can redistribute it and/or modify7* it under the terms of the GNU General Public License version 2 as8* published by the Free Software Foundation.9*10* pl08x information required by platform code11*12* Please credit ARM.com13* Documentation: ARM DDI 0196D14*/1516#ifndef AMBA_PL08X_H17#define AMBA_PL08X_H1819/* We need sizes of structs from this header */20#include <linux/dmaengine.h>21#include <linux/interrupt.h>2223struct pl08x_lli;24struct pl08x_driver_data;2526/* Bitmasks for selecting AHB ports for DMA transfers */27enum {28PL08X_AHB1 = (1 << 0),29PL08X_AHB2 = (1 << 1)30};3132/**33* struct pl08x_channel_data - data structure to pass info between34* platform and PL08x driver regarding channel configuration35* @bus_id: name of this device channel, not just a device name since36* devices may have more than one channel e.g. "foo_tx"37* @min_signal: the minimum DMA signal number to be muxed in for this38* channel (for platforms supporting muxed signals). If you have39* static assignments, make sure this is set to the assigned signal40* number, PL08x have 16 possible signals in number 0 thru 15 so41* when these are not enough they often get muxed (in hardware)42* disabling simultaneous use of the same channel for two devices.43* @max_signal: the maximum DMA signal number to be muxed in for44* the channel. Set to the same as min_signal for45* devices with static assignments46* @muxval: a number usually used to poke into some mux regiser to47* mux in the signal to this channel48* @cctl_opt: default options for the channel control register49* @addr: source/target address in physical memory for this DMA channel,50* can be the address of a FIFO register for burst requests for example.51* This can be left undefined if the PrimeCell API is used for configuring52* this.53* @circular_buffer: whether the buffer passed in is circular and54* shall simply be looped round round (like a record baby round55* round round round)56* @single: the device connected to this channel will request single DMA57* transfers, not bursts. (Bursts are default.)58* @periph_buses: the device connected to this channel is accessible via59* these buses (use PL08X_AHB1 | PL08X_AHB2).60*/61struct pl08x_channel_data {62char *bus_id;63int min_signal;64int max_signal;65u32 muxval;66u32 cctl;67dma_addr_t addr;68bool circular_buffer;69bool single;70u8 periph_buses;71};7273/**74* Struct pl08x_bus_data - information of source or destination75* busses for a transfer76* @addr: current address77* @maxwidth: the maximum width of a transfer on this bus78* @buswidth: the width of this bus in bytes: 1, 2 or 479* @fill_bytes: bytes required to fill to the next bus memory boundary80*/81struct pl08x_bus_data {82dma_addr_t addr;83u8 maxwidth;84u8 buswidth;85size_t fill_bytes;86};8788/**89* struct pl08x_phy_chan - holder for the physical channels90* @id: physical index to this channel91* @lock: a lock to use when altering an instance of this struct92* @signal: the physical signal (aka channel) serving this physical channel93* right now94* @serving: the virtual channel currently being served by this physical95* channel96*/97struct pl08x_phy_chan {98unsigned int id;99void __iomem *base;100spinlock_t lock;101int signal;102struct pl08x_dma_chan *serving;103};104105/**106* struct pl08x_txd - wrapper for struct dma_async_tx_descriptor107* @llis_bus: DMA memory address (physical) start for the LLIs108* @llis_va: virtual memory address start for the LLIs109*/110struct pl08x_txd {111struct dma_async_tx_descriptor tx;112struct list_head node;113enum dma_data_direction direction;114dma_addr_t src_addr;115dma_addr_t dst_addr;116size_t len;117dma_addr_t llis_bus;118struct pl08x_lli *llis_va;119/* Default cctl value for LLIs */120u32 cctl;121/*122* Settings to be put into the physical channel when we123* trigger this txd. Other registers are in llis_va[0].124*/125u32 ccfg;126};127128/**129* struct pl08x_dma_chan_state - holds the PL08x specific virtual channel130* states131* @PL08X_CHAN_IDLE: the channel is idle132* @PL08X_CHAN_RUNNING: the channel has allocated a physical transport133* channel and is running a transfer on it134* @PL08X_CHAN_PAUSED: the channel has allocated a physical transport135* channel, but the transfer is currently paused136* @PL08X_CHAN_WAITING: the channel is waiting for a physical transport137* channel to become available (only pertains to memcpy channels)138*/139enum pl08x_dma_chan_state {140PL08X_CHAN_IDLE,141PL08X_CHAN_RUNNING,142PL08X_CHAN_PAUSED,143PL08X_CHAN_WAITING,144};145146/**147* struct pl08x_dma_chan - this structure wraps a DMA ENGINE channel148* @chan: wrappped abstract channel149* @phychan: the physical channel utilized by this channel, if there is one150* @phychan_hold: if non-zero, hold on to the physical channel even if we151* have no pending entries152* @tasklet: tasklet scheduled by the IRQ to handle actual work etc153* @name: name of channel154* @cd: channel platform data155* @runtime_addr: address for RX/TX according to the runtime config156* @runtime_direction: current direction of this channel according to157* runtime config158* @lc: last completed transaction on this channel159* @pend_list: queued transactions pending on this channel160* @at: active transaction on this channel161* @lock: a lock for this channel data162* @host: a pointer to the host (internal use)163* @state: whether the channel is idle, paused, running etc164* @slave: whether this channel is a device (slave) or for memcpy165* @waiting: a TX descriptor on this channel which is waiting for a physical166* channel to become available167*/168struct pl08x_dma_chan {169struct dma_chan chan;170struct pl08x_phy_chan *phychan;171int phychan_hold;172struct tasklet_struct tasklet;173char *name;174struct pl08x_channel_data *cd;175dma_addr_t runtime_addr;176enum dma_data_direction runtime_direction;177dma_cookie_t lc;178struct list_head pend_list;179struct pl08x_txd *at;180spinlock_t lock;181struct pl08x_driver_data *host;182enum pl08x_dma_chan_state state;183bool slave;184struct pl08x_txd *waiting;185};186187/**188* struct pl08x_platform_data - the platform configuration for the PL08x189* PrimeCells.190* @slave_channels: the channels defined for the different devices on the191* platform, all inclusive, including multiplexed channels. The available192* physical channels will be multiplexed around these signals as they are193* requested, just enumerate all possible channels.194* @get_signal: request a physical signal to be used for a DMA transfer195* immediately: if there is some multiplexing or similar blocking the use196* of the channel the transfer can be denied by returning less than zero,197* else it returns the allocated signal number198* @put_signal: indicate to the platform that this physical signal is not199* running any DMA transfer and multiplexing can be recycled200* @lli_buses: buses which LLIs can be fetched from: PL08X_AHB1 | PL08X_AHB2201* @mem_buses: buses which memory can be accessed from: PL08X_AHB1 | PL08X_AHB2202*/203struct pl08x_platform_data {204struct pl08x_channel_data *slave_channels;205unsigned int num_slave_channels;206struct pl08x_channel_data memcpy_channel;207int (*get_signal)(struct pl08x_dma_chan *);208void (*put_signal)(struct pl08x_dma_chan *);209u8 lli_buses;210u8 mem_buses;211};212213#ifdef CONFIG_AMBA_PL08X214bool pl08x_filter_id(struct dma_chan *chan, void *chan_id);215#else216static inline bool pl08x_filter_id(struct dma_chan *chan, void *chan_id)217{218return false;219}220#endif221222#endif /* AMBA_PL08X_H */223224225