Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 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 Kokatanur | bd4242d | 2012-08-22 21:28:18 +0000 | [diff] [blame] | 30 | #ifndef __DESC_COM_H__ |
| 31 | #define __DESC_COM_H__ |
| 32 | |
Giuseppe CAVALLARO | 4a7d666 | 2013-03-26 04:43:05 +0000 | [diff] [blame] | 33 | /* Specific functions used for Ring mode */ |
| 34 | |
| 35 | /* Enhanced descriptors */ |
| 36 | static inline void ehn_desc_rx_set_on_ring(struct dma_desc *p, int end) |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 37 | { |
| 38 | p->des01.erx.buffer2_size = BUF_SIZE_8KiB - 1; |
| 39 | if (end) |
| 40 | p->des01.erx.end_ring = 1; |
| 41 | } |
| 42 | |
Giuseppe CAVALLARO | 4a7d666 | 2013-03-26 04:43:05 +0000 | [diff] [blame] | 43 | static inline void ehn_desc_tx_set_on_ring(struct dma_desc *p, int end) |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 44 | { |
| 45 | if (end) |
| 46 | p->des01.etx.end_ring = 1; |
| 47 | } |
| 48 | |
Giuseppe CAVALLARO | 4a7d666 | 2013-03-26 04:43:05 +0000 | [diff] [blame] | 49 | static inline void enh_desc_end_tx_desc_on_ring(struct dma_desc *p, int ter) |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 50 | { |
| 51 | p->des01.etx.end_ring = ter; |
| 52 | } |
| 53 | |
Giuseppe CAVALLARO | 4a7d666 | 2013-03-26 04:43:05 +0000 | [diff] [blame] | 54 | static inline void enh_set_tx_desc_len_on_ring(struct dma_desc *p, int len) |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 55 | { |
| 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 CAVALLARO | 4a7d666 | 2013-03-26 04:43:05 +0000 | [diff] [blame] | 63 | /* Normal descriptors */ |
| 64 | static inline void ndesc_rx_set_on_ring(struct dma_desc *p, int end) |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 65 | { |
| 66 | p->des01.rx.buffer2_size = BUF_SIZE_2KiB - 1; |
| 67 | if (end) |
| 68 | p->des01.rx.end_ring = 1; |
| 69 | } |
| 70 | |
Giuseppe CAVALLARO | 4a7d666 | 2013-03-26 04:43:05 +0000 | [diff] [blame] | 71 | static inline void ndesc_tx_set_on_ring(struct dma_desc *p, int end) |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 72 | { |
| 73 | if (end) |
| 74 | p->des01.tx.end_ring = 1; |
| 75 | } |
| 76 | |
Giuseppe CAVALLARO | 4a7d666 | 2013-03-26 04:43:05 +0000 | [diff] [blame] | 77 | static inline void ndesc_end_tx_desc_on_ring(struct dma_desc *p, int ter) |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 78 | { |
| 79 | p->des01.tx.end_ring = ter; |
| 80 | } |
| 81 | |
Giuseppe CAVALLARO | 4a7d666 | 2013-03-26 04:43:05 +0000 | [diff] [blame] | 82 | static inline void norm_set_tx_desc_len_on_ring(struct dma_desc *p, int len) |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 83 | { |
| 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 CAVALLARO | 4a7d666 | 2013-03-26 04:43:05 +0000 | [diff] [blame] | 91 | /* Specific functions used for Chain mode */ |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 92 | |
Giuseppe CAVALLARO | 4a7d666 | 2013-03-26 04:43:05 +0000 | [diff] [blame] | 93 | /* Enhanced descriptors */ |
| 94 | static inline void ehn_desc_rx_set_on_chain(struct dma_desc *p, int end) |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 95 | { |
| 96 | p->des01.erx.second_address_chained = 1; |
| 97 | } |
| 98 | |
Giuseppe CAVALLARO | 4a7d666 | 2013-03-26 04:43:05 +0000 | [diff] [blame] | 99 | static inline void ehn_desc_tx_set_on_chain(struct dma_desc *p, int end) |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 100 | { |
| 101 | p->des01.etx.second_address_chained = 1; |
| 102 | } |
| 103 | |
Giuseppe CAVALLARO | 4a7d666 | 2013-03-26 04:43:05 +0000 | [diff] [blame] | 104 | static inline void enh_desc_end_tx_desc_on_chain(struct dma_desc *p, int ter) |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 105 | { |
| 106 | p->des01.etx.second_address_chained = 1; |
| 107 | } |
| 108 | |
Giuseppe CAVALLARO | 4a7d666 | 2013-03-26 04:43:05 +0000 | [diff] [blame] | 109 | static inline void enh_set_tx_desc_len_on_chain(struct dma_desc *p, int len) |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 110 | { |
| 111 | p->des01.etx.buffer1_size = len; |
| 112 | } |
| 113 | |
Giuseppe CAVALLARO | 4a7d666 | 2013-03-26 04:43:05 +0000 | [diff] [blame] | 114 | /* Normal descriptors */ |
| 115 | static inline void ndesc_rx_set_on_chain(struct dma_desc *p, int end) |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 116 | { |
| 117 | p->des01.rx.second_address_chained = 1; |
| 118 | } |
| 119 | |
Giuseppe CAVALLARO | ceb69499 | 2013-04-08 02:10:01 +0000 | [diff] [blame] | 120 | static inline void ndesc_tx_set_on_chain(struct dma_desc *p, int ring_size) |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 121 | { |
| 122 | p->des01.tx.second_address_chained = 1; |
| 123 | } |
| 124 | |
Giuseppe CAVALLARO | 4a7d666 | 2013-03-26 04:43:05 +0000 | [diff] [blame] | 125 | static inline void ndesc_end_tx_desc_on_chain(struct dma_desc *p, int ter) |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 126 | { |
| 127 | p->des01.tx.second_address_chained = 1; |
| 128 | } |
| 129 | |
Giuseppe CAVALLARO | 4a7d666 | 2013-03-26 04:43:05 +0000 | [diff] [blame] | 130 | static inline void norm_set_tx_desc_len_on_chain(struct dma_desc *p, int len) |
Giuseppe CAVALLARO | 286a837 | 2011-10-18 00:01:24 +0000 | [diff] [blame] | 131 | { |
| 132 | p->des01.tx.buffer1_size = len; |
| 133 | } |
Rayagond Kokatanur | bd4242d | 2012-08-22 21:28:18 +0000 | [diff] [blame] | 134 | #endif /* __DESC_COM_H__ */ |