2019-04-26 20:12:23 +03:00
/* SPDX-License-Identifier: GPL-2.0 */
2010-09-15 10:11:28 -04:00
/*
* Texas Instruments CPDMA Driver
*
* Copyright ( C ) 2010 Texas Instruments
*
*/
# ifndef __DAVINCI_CPDMA_H__
# define __DAVINCI_CPDMA_H__
# define CPDMA_MAX_CHANNELS BITS_PER_LONG
2013-02-11 09:52:18 +00:00
# define CPDMA_RX_SOURCE_PORT(__status__) ((__status__ >> 16) & 0x7)
2018-03-15 15:15:50 -05:00
# define CPDMA_RX_VLAN_ENCAP BIT(19)
2013-02-17 22:19:20 +00:00
# define CPDMA_EOI_RX_THRESH 0x0
# define CPDMA_EOI_RX 0x1
# define CPDMA_EOI_TX 0x2
# define CPDMA_EOI_MISC 0x3
2010-09-15 10:11:28 -04:00
struct cpdma_params {
struct device * dev ;
void __iomem * dmaregs ;
void __iomem * txhdp , * rxhdp , * txcp , * rxcp ;
void __iomem * rxthresh , * rxfree ;
int num_chan ;
bool has_soft_reset ;
int min_packet_size ;
2019-04-26 20:12:38 +03:00
dma_addr_t desc_mem_phys ;
dma_addr_t desc_hw_addr ;
2010-09-15 10:11:28 -04:00
int desc_mem_size ;
int desc_align ;
2016-11-29 17:00:48 +02:00
u32 bus_freq_mhz ;
2017-01-06 14:07:33 -06:00
u32 descs_pool_size ;
2010-09-15 10:11:28 -04:00
/*
* Some instances of embedded cpdma controllers have extra control and
* status registers . The following flag enables access to these
* " extended " registers .
*/
bool has_ext_regs ;
} ;
struct cpdma_chan_stats {
u32 head_enqueue ;
u32 tail_enqueue ;
u32 pad_enqueue ;
u32 misqueued ;
u32 desc_alloc_fail ;
u32 pad_alloc_fail ;
u32 runt_receive_buff ;
u32 runt_transmit_buff ;
u32 empty_dequeue ;
u32 busy_dequeue ;
u32 good_dequeue ;
u32 requeue ;
u32 teardown_dequeue ;
} ;
struct cpdma_ctlr ;
struct cpdma_chan ;
typedef void ( * cpdma_handler_fn ) ( void * token , int len , int status ) ;
struct cpdma_ctlr * cpdma_ctlr_create ( struct cpdma_params * params ) ;
int cpdma_ctlr_destroy ( struct cpdma_ctlr * ctlr ) ;
int cpdma_ctlr_start ( struct cpdma_ctlr * ctlr ) ;
int cpdma_ctlr_stop ( struct cpdma_ctlr * ctlr ) ;
struct cpdma_chan * cpdma_chan_create ( struct cpdma_ctlr * ctlr , int chan_num ,
2016-08-22 21:18:27 +03:00
cpdma_handler_fn handler , int rx_type ) ;
2016-08-22 21:18:24 +03:00
int cpdma_chan_get_rx_buf_num ( struct cpdma_chan * chan ) ;
2010-09-15 10:11:28 -04:00
int cpdma_chan_destroy ( struct cpdma_chan * chan ) ;
int cpdma_chan_start ( struct cpdma_chan * chan ) ;
int cpdma_chan_stop ( struct cpdma_chan * chan ) ;
int cpdma_chan_get_stats ( struct cpdma_chan * chan ,
struct cpdma_chan_stats * stats ) ;
2019-07-09 00:34:29 +03:00
int cpdma_chan_submit_mapped ( struct cpdma_chan * chan , void * token ,
dma_addr_t data , int len , int directed ) ;
2010-09-15 10:11:28 -04:00
int cpdma_chan_submit ( struct cpdma_chan * chan , void * token , void * data ,
2013-04-23 07:31:38 +00:00
int len , int directed ) ;
2019-07-09 00:34:29 +03:00
int cpdma_chan_idle_submit_mapped ( struct cpdma_chan * chan , void * token ,
dma_addr_t data , int len , int directed ) ;
2019-06-15 14:01:32 +03:00
int cpdma_chan_idle_submit ( struct cpdma_chan * chan , void * token , void * data ,
int len , int directed ) ;
2010-09-15 10:11:28 -04:00
int cpdma_chan_process ( struct cpdma_chan * chan , int quota ) ;
int cpdma_ctlr_int_ctrl ( struct cpdma_ctlr * ctlr , bool enable ) ;
2013-02-17 22:19:20 +00:00
void cpdma_ctlr_eoi ( struct cpdma_ctlr * ctlr , u32 value ) ;
2010-09-15 10:11:28 -04:00
int cpdma_chan_int_ctrl ( struct cpdma_chan * chan , bool enable ) ;
2016-08-22 21:18:26 +03:00
u32 cpdma_ctrl_rxchs_state ( struct cpdma_ctlr * ctlr ) ;
u32 cpdma_ctrl_txchs_state ( struct cpdma_ctlr * ctlr ) ;
2013-01-17 06:31:34 +00:00
bool cpdma_check_free_tx_desc ( struct cpdma_chan * chan ) ;
2016-11-29 17:00:47 +02:00
int cpdma_chan_set_weight ( struct cpdma_chan * ch , int weight ) ;
2016-11-29 17:00:48 +02:00
int cpdma_chan_set_rate ( struct cpdma_chan * ch , u32 rate ) ;
u32 cpdma_chan_get_rate ( struct cpdma_chan * ch ) ;
u32 cpdma_chan_get_min_rate ( struct cpdma_ctlr * ctlr ) ;
2010-09-15 10:11:28 -04:00
enum cpdma_control {
2016-11-29 17:00:48 +02:00
CPDMA_TX_RLIM , /* read-write */
2010-09-15 10:11:28 -04:00
CPDMA_CMD_IDLE , /* write-only */
CPDMA_COPY_ERROR_FRAMES , /* read-write */
CPDMA_RX_OFF_LEN_UPDATE , /* read-write */
CPDMA_RX_OWNERSHIP_FLIP , /* read-write */
CPDMA_TX_PRIO_FIXED , /* read-write */
CPDMA_STAT_IDLE , /* read-only */
CPDMA_STAT_TX_ERR_CHAN , /* read-only */
CPDMA_STAT_TX_ERR_CODE , /* read-only */
CPDMA_STAT_RX_ERR_CHAN , /* read-only */
CPDMA_STAT_RX_ERR_CODE , /* read-only */
CPDMA_RX_BUFFER_OFFSET , /* read-write */
} ;
int cpdma_control_get ( struct cpdma_ctlr * ctlr , int control ) ;
int cpdma_control_set ( struct cpdma_ctlr * ctlr , int control , int value ) ;
2017-01-06 14:07:34 -06:00
int cpdma_get_num_rx_descs ( struct cpdma_ctlr * ctlr ) ;
2019-07-09 00:34:30 +03:00
int cpdma_set_num_rx_descs ( struct cpdma_ctlr * ctlr , int num_rx_desc ) ;
2017-01-06 14:07:34 -06:00
int cpdma_get_num_tx_descs ( struct cpdma_ctlr * ctlr ) ;
2010-09-15 10:11:28 -04:00
# endif