blob: 6f2cc78c5cf513ddcf8abc6e9094725a1ebfe977 [file] [log] [blame]
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +00001/*******************************************************************************
2 Header File to describe Normal/enhanced descriptor functions used for RING
3 and CHAINED modes.
4
5 Copyright(C) 2011 STMicroelectronics Ltd
6
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
9 in ring mode.
10
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.
14
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
18 more details.
19
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.
23
24 The full GNU General Public License is included in this distribution in
25 the file called "COPYING".
26
27 Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
28*******************************************************************************/
29
Rayagond Kokatanurbd4242d2012-08-22 21:28:18 +000030#ifndef __DESC_COM_H__
31#define __DESC_COM_H__
32
Giuseppe CAVALLARO4a7d6662013-03-26 04:43:05 +000033/* Specific functions used for Ring mode */
34
35/* Enhanced descriptors */
36static inline void ehn_desc_rx_set_on_ring(struct dma_desc *p, int end)
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +000037{
38 p->des01.erx.buffer2_size = BUF_SIZE_8KiB - 1;
39 if (end)
40 p->des01.erx.end_ring = 1;
41}
42
Giuseppe CAVALLARO4a7d6662013-03-26 04:43:05 +000043static inline void ehn_desc_tx_set_on_ring(struct dma_desc *p, int end)
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +000044{
45 if (end)
46 p->des01.etx.end_ring = 1;
47}
48
Giuseppe CAVALLARO4a7d6662013-03-26 04:43:05 +000049static inline void enh_desc_end_tx_desc_on_ring(struct dma_desc *p, int ter)
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +000050{
51 p->des01.etx.end_ring = ter;
52}
53
Giuseppe CAVALLARO4a7d6662013-03-26 04:43:05 +000054static inline void enh_set_tx_desc_len_on_ring(struct dma_desc *p, int len)
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +000055{
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;
59 } else
60 p->des01.etx.buffer1_size = len;
61}
62
Giuseppe CAVALLARO4a7d6662013-03-26 04:43:05 +000063/* Normal descriptors */
64static inline void ndesc_rx_set_on_ring(struct dma_desc *p, int end)
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +000065{
66 p->des01.rx.buffer2_size = BUF_SIZE_2KiB - 1;
67 if (end)
68 p->des01.rx.end_ring = 1;
69}
70
Giuseppe CAVALLARO4a7d6662013-03-26 04:43:05 +000071static inline void ndesc_tx_set_on_ring(struct dma_desc *p, int end)
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +000072{
73 if (end)
74 p->des01.tx.end_ring = 1;
75}
76
Giuseppe CAVALLARO4a7d6662013-03-26 04:43:05 +000077static inline void ndesc_end_tx_desc_on_ring(struct dma_desc *p, int ter)
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +000078{
79 p->des01.tx.end_ring = ter;
80}
81
Giuseppe CAVALLARO4a7d6662013-03-26 04:43:05 +000082static inline void norm_set_tx_desc_len_on_ring(struct dma_desc *p, int len)
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +000083{
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;
87 } else
88 p->des01.tx.buffer1_size = len;
89}
90
Giuseppe CAVALLARO4a7d6662013-03-26 04:43:05 +000091/* Specific functions used for Chain mode */
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +000092
Giuseppe CAVALLARO4a7d6662013-03-26 04:43:05 +000093/* Enhanced descriptors */
94static inline void ehn_desc_rx_set_on_chain(struct dma_desc *p, int end)
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +000095{
96 p->des01.erx.second_address_chained = 1;
97}
98
Giuseppe CAVALLARO4a7d6662013-03-26 04:43:05 +000099static inline void ehn_desc_tx_set_on_chain(struct dma_desc *p, int end)
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +0000100{
101 p->des01.etx.second_address_chained = 1;
102}
103
Giuseppe CAVALLARO4a7d6662013-03-26 04:43:05 +0000104static inline void enh_desc_end_tx_desc_on_chain(struct dma_desc *p, int ter)
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +0000105{
106 p->des01.etx.second_address_chained = 1;
107}
108
Giuseppe CAVALLARO4a7d6662013-03-26 04:43:05 +0000109static inline void enh_set_tx_desc_len_on_chain(struct dma_desc *p, int len)
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +0000110{
111 p->des01.etx.buffer1_size = len;
112}
113
Giuseppe CAVALLARO4a7d6662013-03-26 04:43:05 +0000114/* Normal descriptors */
115static inline void ndesc_rx_set_on_chain(struct dma_desc *p, int end)
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +0000116{
117 p->des01.rx.second_address_chained = 1;
118}
119
Giuseppe CAVALLAROceb694992013-04-08 02:10:01 +0000120static inline void ndesc_tx_set_on_chain(struct dma_desc *p, int ring_size)
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +0000121{
122 p->des01.tx.second_address_chained = 1;
123}
124
Giuseppe CAVALLARO4a7d6662013-03-26 04:43:05 +0000125static inline void ndesc_end_tx_desc_on_chain(struct dma_desc *p, int ter)
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +0000126{
127 p->des01.tx.second_address_chained = 1;
128}
129
Giuseppe CAVALLARO4a7d6662013-03-26 04:43:05 +0000130static inline void norm_set_tx_desc_len_on_chain(struct dma_desc *p, int len)
Giuseppe CAVALLARO286a8372011-10-18 00:01:24 +0000131{
132 p->des01.tx.buffer1_size = len;
133}
Rayagond Kokatanurbd4242d2012-08-22 21:28:18 +0000134#endif /* __DESC_COM_H__ */