2 * Texas Instruments CPDMA Driver
4 * Copyright (C) 2010 Texas Instruments
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation version 2.
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 #ifndef __DAVINCI_CPDMA_H__
16 #define __DAVINCI_CPDMA_H__
18 #define CPDMA_MAX_CHANNELS BITS_PER_LONG
20 #define CPDMA_RX_SOURCE_PORT(__status__) ((__status__ >> 16) & 0x7)
22 #define CPDMA_EOI_RX_THRESH 0x0
23 #define CPDMA_EOI_RX 0x1
24 #define CPDMA_EOI_TX 0x2
25 #define CPDMA_EOI_MISC 0x3
29 void __iomem *dmaregs;
30 void __iomem *txhdp, *rxhdp, *txcp, *rxcp;
31 void __iomem *rxthresh, *rxfree;
41 * Some instances of embedded cpdma controllers have extra control and
42 * status registers. The following flag enables access to these
43 * "extended" registers.
48 struct cpdma_chan_stats {
55 u32 runt_receive_buff;
56 u32 runt_transmit_buff;
67 typedef void (*cpdma_handler_fn)(void *token, int len, int status);
69 struct cpdma_ctlr *cpdma_ctlr_create(struct cpdma_params *params);
70 int cpdma_ctlr_destroy(struct cpdma_ctlr *ctlr);
71 int cpdma_ctlr_start(struct cpdma_ctlr *ctlr);
72 int cpdma_ctlr_stop(struct cpdma_ctlr *ctlr);
74 struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num,
75 cpdma_handler_fn handler, int rx_type);
76 int cpdma_chan_get_rx_buf_num(struct cpdma_chan *chan);
77 int cpdma_chan_destroy(struct cpdma_chan *chan);
78 int cpdma_chan_start(struct cpdma_chan *chan);
79 int cpdma_chan_stop(struct cpdma_chan *chan);
81 int cpdma_chan_get_stats(struct cpdma_chan *chan,
82 struct cpdma_chan_stats *stats);
83 int cpdma_chan_submit(struct cpdma_chan *chan, void *token, void *data,
84 int len, int directed);
85 int cpdma_chan_process(struct cpdma_chan *chan, int quota);
87 int cpdma_ctlr_int_ctrl(struct cpdma_ctlr *ctlr, bool enable);
88 void cpdma_ctlr_eoi(struct cpdma_ctlr *ctlr, u32 value);
89 int cpdma_chan_int_ctrl(struct cpdma_chan *chan, bool enable);
90 u32 cpdma_ctrl_rxchs_state(struct cpdma_ctlr *ctlr);
91 u32 cpdma_ctrl_txchs_state(struct cpdma_ctlr *ctlr);
92 bool cpdma_check_free_tx_desc(struct cpdma_chan *chan);
95 CPDMA_CMD_IDLE, /* write-only */
96 CPDMA_COPY_ERROR_FRAMES, /* read-write */
97 CPDMA_RX_OFF_LEN_UPDATE, /* read-write */
98 CPDMA_RX_OWNERSHIP_FLIP, /* read-write */
99 CPDMA_TX_PRIO_FIXED, /* read-write */
100 CPDMA_STAT_IDLE, /* read-only */
101 CPDMA_STAT_TX_ERR_CHAN, /* read-only */
102 CPDMA_STAT_TX_ERR_CODE, /* read-only */
103 CPDMA_STAT_RX_ERR_CHAN, /* read-only */
104 CPDMA_STAT_RX_ERR_CODE, /* read-only */
105 CPDMA_RX_BUFFER_OFFSET, /* read-write */
108 int cpdma_control_get(struct cpdma_ctlr *ctlr, int control);
109 int cpdma_control_set(struct cpdma_ctlr *ctlr, int control, int value);