spi-topcliff-pch: supports a spi mode setup and bit order setup by IO control
[zen-stable.git] / drivers / net / ethernet / stmicro / stmmac / descs_com.h
blobdd8d6e19dff6b2c1182dfb0f31ca8c4696c84931
1 /*******************************************************************************
2 Header File to describe Normal/enhanced descriptor functions used for RING
3 and CHAINED modes.
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
9 in ring mode.
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
18 more details.
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 #if defined(CONFIG_STMMAC_RING)
31 static inline void ehn_desc_rx_set_on_ring_chain(struct dma_desc *p, int end)
33 p->des01.erx.buffer2_size = BUF_SIZE_8KiB - 1;
34 if (end)
35 p->des01.erx.end_ring = 1;
38 static inline void ehn_desc_tx_set_on_ring_chain(struct dma_desc *p, int end)
40 if (end)
41 p->des01.etx.end_ring = 1;
44 static inline void enh_desc_end_tx_desc(struct dma_desc *p, int ter)
46 p->des01.etx.end_ring = ter;
49 static inline void enh_set_tx_desc_len(struct dma_desc *p, int len)
51 if (unlikely(len > BUF_SIZE_4KiB)) {
52 p->des01.etx.buffer1_size = BUF_SIZE_4KiB;
53 p->des01.etx.buffer2_size = len - BUF_SIZE_4KiB;
54 } else
55 p->des01.etx.buffer1_size = len;
58 static inline void ndesc_rx_set_on_ring_chain(struct dma_desc *p, int end)
60 p->des01.rx.buffer2_size = BUF_SIZE_2KiB - 1;
61 if (end)
62 p->des01.rx.end_ring = 1;
65 static inline void ndesc_tx_set_on_ring_chain(struct dma_desc *p, int end)
67 if (end)
68 p->des01.tx.end_ring = 1;
71 static inline void ndesc_end_tx_desc(struct dma_desc *p, int ter)
73 p->des01.tx.end_ring = ter;
76 static inline void norm_set_tx_desc_len(struct dma_desc *p, int len)
78 if (unlikely(len > BUF_SIZE_2KiB)) {
79 p->des01.etx.buffer1_size = BUF_SIZE_2KiB - 1;
80 p->des01.etx.buffer2_size = len - p->des01.etx.buffer1_size;
81 } else
82 p->des01.tx.buffer1_size = len;
85 #else
87 static inline void ehn_desc_rx_set_on_ring_chain(struct dma_desc *p, int end)
89 p->des01.erx.second_address_chained = 1;
92 static inline void ehn_desc_tx_set_on_ring_chain(struct dma_desc *p, int end)
94 p->des01.etx.second_address_chained = 1;
97 static inline void enh_desc_end_tx_desc(struct dma_desc *p, int ter)
99 p->des01.etx.second_address_chained = 1;
102 static inline void enh_set_tx_desc_len(struct dma_desc *p, int len)
104 p->des01.etx.buffer1_size = len;
107 static inline void ndesc_rx_set_on_ring_chain(struct dma_desc *p, int end)
109 p->des01.rx.second_address_chained = 1;
112 static inline void ndesc_tx_set_on_ring_chain(struct dma_desc *p, int ring_size)
114 p->des01.tx.second_address_chained = 1;
117 static inline void ndesc_end_tx_desc(struct dma_desc *p, int ter)
119 p->des01.tx.second_address_chained = 1;
122 static inline void norm_set_tx_desc_len(struct dma_desc *p, int len)
124 p->des01.tx.buffer1_size = len;
126 #endif