1 /*******************************************************************************
2 Header File to describe Normal/enhanced descriptor functions used for RING
5 Copyright(C) 2011 STMicroelectronics Ltd
7 It defines all the functions used to handle the normal/enhanced
8 descriptors in case of the DMA is configured to work in chained or
11 This program is free software; you can redistribute it and/or modify it
12 under the terms and conditions of the GNU General Public License,
13 version 2, as published by the Free Software Foundation.
15 This program is distributed in the hope it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
20 You should have received a copy of the GNU General Public License along with
21 this program; if not, write to the Free Software Foundation, Inc.,
22 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
24 The full GNU General Public License is included in this distribution in
25 the file called "COPYING".
27 Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
28 *******************************************************************************/
30 #ifndef __DESC_COM_H__
31 #define __DESC_COM_H__
33 /* Specific functions used for Ring mode */
35 /* Enhanced descriptors */
36 static inline void ehn_desc_rx_set_on_ring(struct dma_desc
*p
, int end
)
38 p
->des01
.erx
.buffer2_size
= BUF_SIZE_8KiB
- 1;
40 p
->des01
.erx
.end_ring
= 1;
43 static inline void ehn_desc_tx_set_on_ring(struct dma_desc
*p
, int end
)
46 p
->des01
.etx
.end_ring
= 1;
49 static inline void enh_desc_end_tx_desc_on_ring(struct dma_desc
*p
, int ter
)
51 p
->des01
.etx
.end_ring
= ter
;
54 static inline void enh_set_tx_desc_len_on_ring(struct dma_desc
*p
, int len
)
56 if (unlikely(len
> BUF_SIZE_4KiB
)) {
57 p
->des01
.etx
.buffer1_size
= BUF_SIZE_4KiB
;
58 p
->des01
.etx
.buffer2_size
= len
- BUF_SIZE_4KiB
;
60 p
->des01
.etx
.buffer1_size
= len
;
63 /* Normal descriptors */
64 static inline void ndesc_rx_set_on_ring(struct dma_desc
*p
, int end
)
66 p
->des01
.rx
.buffer2_size
= BUF_SIZE_2KiB
- 1;
68 p
->des01
.rx
.end_ring
= 1;
71 static inline void ndesc_tx_set_on_ring(struct dma_desc
*p
, int end
)
74 p
->des01
.tx
.end_ring
= 1;
77 static inline void ndesc_end_tx_desc_on_ring(struct dma_desc
*p
, int ter
)
79 p
->des01
.tx
.end_ring
= ter
;
82 static inline void norm_set_tx_desc_len_on_ring(struct dma_desc
*p
, int len
)
84 if (unlikely(len
> BUF_SIZE_2KiB
)) {
85 p
->des01
.etx
.buffer1_size
= BUF_SIZE_2KiB
- 1;
86 p
->des01
.etx
.buffer2_size
= len
- p
->des01
.etx
.buffer1_size
;
88 p
->des01
.tx
.buffer1_size
= len
;
91 /* Specific functions used for Chain mode */
93 /* Enhanced descriptors */
94 static inline void ehn_desc_rx_set_on_chain(struct dma_desc
*p
, int end
)
96 p
->des01
.erx
.second_address_chained
= 1;
99 static inline void ehn_desc_tx_set_on_chain(struct dma_desc
*p
, int end
)
101 p
->des01
.etx
.second_address_chained
= 1;
104 static inline void enh_desc_end_tx_desc_on_chain(struct dma_desc
*p
, int ter
)
106 p
->des01
.etx
.second_address_chained
= 1;
109 static inline void enh_set_tx_desc_len_on_chain(struct dma_desc
*p
, int len
)
111 p
->des01
.etx
.buffer1_size
= len
;
114 /* Normal descriptors */
115 static inline void ndesc_rx_set_on_chain(struct dma_desc
*p
, int end
)
117 p
->des01
.rx
.second_address_chained
= 1;
120 static inline void ndesc_tx_set_on_chain(struct dma_desc
*p
, int ring_size
)
122 p
->des01
.tx
.second_address_chained
= 1;
125 static inline void ndesc_end_tx_desc_on_chain(struct dma_desc
*p
, int ter
)
127 p
->des01
.tx
.second_address_chained
= 1;
130 static inline void norm_set_tx_desc_len_on_chain(struct dma_desc
*p
, int len
)
132 p
->des01
.tx
.buffer1_size
= len
;
134 #endif /* __DESC_COM_H__ */