]>
Commit | Line | Data |
---|---|---|
42de047d JA |
1 | // SPDX-License-Identifier: (GPL-2.0 OR MIT) |
2 | // Copyright (c) 2018 Synopsys, Inc. and/or its affiliates. | |
3 | // stmmac HW Interface Callbacks | |
4 | ||
5 | #ifndef __STMMAC_HWIF_H__ | |
6 | #define __STMMAC_HWIF_H__ | |
7 | ||
4dbbe8dd JA |
8 | #include <linux/netdevice.h> |
9 | ||
42de047d JA |
10 | #define stmmac_do_void_callback(__priv, __module, __cname, __arg0, __args...) \ |
11 | ({ \ | |
12 | int __result = -EINVAL; \ | |
4dbbe8dd | 13 | if ((__priv)->hw->__module && (__priv)->hw->__module->__cname) { \ |
42de047d JA |
14 | (__priv)->hw->__module->__cname((__arg0), ##__args); \ |
15 | __result = 0; \ | |
16 | } \ | |
17 | __result; \ | |
18 | }) | |
19 | #define stmmac_do_callback(__priv, __module, __cname, __arg0, __args...) \ | |
20 | ({ \ | |
21 | int __result = -EINVAL; \ | |
4dbbe8dd | 22 | if ((__priv)->hw->__module && (__priv)->hw->__module->__cname) \ |
42de047d JA |
23 | __result = (__priv)->hw->__module->__cname((__arg0), ##__args); \ |
24 | __result; \ | |
25 | }) | |
26 | ||
27 | struct stmmac_extra_stats; | |
28 | struct stmmac_safety_stats; | |
29 | struct dma_desc; | |
30 | struct dma_extended_desc; | |
31 | ||
32 | /* Descriptors helpers */ | |
33 | struct stmmac_desc_ops { | |
34 | /* DMA RX descriptor ring initialization */ | |
35 | void (*init_rx_desc)(struct dma_desc *p, int disable_rx_ic, int mode, | |
36 | int end); | |
37 | /* DMA TX descriptor ring initialization */ | |
38 | void (*init_tx_desc)(struct dma_desc *p, int mode, int end); | |
39 | /* Invoked by the xmit function to prepare the tx descriptor */ | |
40 | void (*prepare_tx_desc)(struct dma_desc *p, int is_fs, int len, | |
41 | bool csum_flag, int mode, bool tx_own, bool ls, | |
42 | unsigned int tot_pkt_len); | |
43 | void (*prepare_tso_tx_desc)(struct dma_desc *p, int is_fs, int len1, | |
44 | int len2, bool tx_own, bool ls, unsigned int tcphdrlen, | |
45 | unsigned int tcppayloadlen); | |
46 | /* Set/get the owner of the descriptor */ | |
47 | void (*set_tx_owner)(struct dma_desc *p); | |
48 | int (*get_tx_owner)(struct dma_desc *p); | |
49 | /* Clean the tx descriptor as soon as the tx irq is received */ | |
50 | void (*release_tx_desc)(struct dma_desc *p, int mode); | |
51 | /* Clear interrupt on tx frame completion. When this bit is | |
52 | * set an interrupt happens as soon as the frame is transmitted */ | |
53 | void (*set_tx_ic)(struct dma_desc *p); | |
54 | /* Last tx segment reports the transmit status */ | |
55 | int (*get_tx_ls)(struct dma_desc *p); | |
56 | /* Return the transmit status looking at the TDES1 */ | |
57 | int (*tx_status)(void *data, struct stmmac_extra_stats *x, | |
58 | struct dma_desc *p, void __iomem *ioaddr); | |
59 | /* Get the buffer size from the descriptor */ | |
60 | int (*get_tx_len)(struct dma_desc *p); | |
61 | /* Handle extra events on specific interrupts hw dependent */ | |
357951cd | 62 | void (*set_rx_owner)(struct dma_desc *p, int disable_rx_ic); |
42de047d JA |
63 | /* Get the receive frame size */ |
64 | int (*get_rx_frame_len)(struct dma_desc *p, int rx_coe_type); | |
65 | /* Return the reception status looking at the RDES1 */ | |
66 | int (*rx_status)(void *data, struct stmmac_extra_stats *x, | |
67 | struct dma_desc *p); | |
68 | void (*rx_extended_status)(void *data, struct stmmac_extra_stats *x, | |
69 | struct dma_extended_desc *p); | |
70 | /* Set tx timestamp enable bit */ | |
71 | void (*enable_tx_timestamp) (struct dma_desc *p); | |
72 | /* get tx timestamp status */ | |
73 | int (*get_tx_timestamp_status) (struct dma_desc *p); | |
74 | /* get timestamp value */ | |
75 | void (*get_timestamp)(void *desc, u32 ats, u64 *ts); | |
76 | /* get rx timestamp status */ | |
77 | int (*get_rx_timestamp_status)(void *desc, void *next_desc, u32 ats); | |
78 | /* Display ring */ | |
79 | void (*display_ring)(void *head, unsigned int size, bool rx); | |
80 | /* set MSS via context descriptor */ | |
81 | void (*set_mss)(struct dma_desc *p, unsigned int mss); | |
6844171d JA |
82 | /* set descriptor skbuff address */ |
83 | void (*set_addr)(struct dma_desc *p, dma_addr_t addr); | |
44c67f85 JA |
84 | /* clear descriptor */ |
85 | void (*clear)(struct dma_desc *p); | |
42de047d JA |
86 | }; |
87 | ||
88 | #define stmmac_init_rx_desc(__priv, __args...) \ | |
89 | stmmac_do_void_callback(__priv, desc, init_rx_desc, __args) | |
90 | #define stmmac_init_tx_desc(__priv, __args...) \ | |
91 | stmmac_do_void_callback(__priv, desc, init_tx_desc, __args) | |
92 | #define stmmac_prepare_tx_desc(__priv, __args...) \ | |
93 | stmmac_do_void_callback(__priv, desc, prepare_tx_desc, __args) | |
94 | #define stmmac_prepare_tso_tx_desc(__priv, __args...) \ | |
95 | stmmac_do_void_callback(__priv, desc, prepare_tso_tx_desc, __args) | |
96 | #define stmmac_set_tx_owner(__priv, __args...) \ | |
97 | stmmac_do_void_callback(__priv, desc, set_tx_owner, __args) | |
98 | #define stmmac_get_tx_owner(__priv, __args...) \ | |
99 | stmmac_do_callback(__priv, desc, get_tx_owner, __args) | |
100 | #define stmmac_release_tx_desc(__priv, __args...) \ | |
101 | stmmac_do_void_callback(__priv, desc, release_tx_desc, __args) | |
102 | #define stmmac_set_tx_ic(__priv, __args...) \ | |
103 | stmmac_do_void_callback(__priv, desc, set_tx_ic, __args) | |
104 | #define stmmac_get_tx_ls(__priv, __args...) \ | |
105 | stmmac_do_callback(__priv, desc, get_tx_ls, __args) | |
106 | #define stmmac_tx_status(__priv, __args...) \ | |
107 | stmmac_do_callback(__priv, desc, tx_status, __args) | |
108 | #define stmmac_get_tx_len(__priv, __args...) \ | |
109 | stmmac_do_callback(__priv, desc, get_tx_len, __args) | |
110 | #define stmmac_set_rx_owner(__priv, __args...) \ | |
111 | stmmac_do_void_callback(__priv, desc, set_rx_owner, __args) | |
112 | #define stmmac_get_rx_frame_len(__priv, __args...) \ | |
113 | stmmac_do_callback(__priv, desc, get_rx_frame_len, __args) | |
114 | #define stmmac_rx_status(__priv, __args...) \ | |
115 | stmmac_do_callback(__priv, desc, rx_status, __args) | |
116 | #define stmmac_rx_extended_status(__priv, __args...) \ | |
117 | stmmac_do_void_callback(__priv, desc, rx_extended_status, __args) | |
118 | #define stmmac_enable_tx_timestamp(__priv, __args...) \ | |
119 | stmmac_do_void_callback(__priv, desc, enable_tx_timestamp, __args) | |
120 | #define stmmac_get_tx_timestamp_status(__priv, __args...) \ | |
121 | stmmac_do_callback(__priv, desc, get_tx_timestamp_status, __args) | |
122 | #define stmmac_get_timestamp(__priv, __args...) \ | |
123 | stmmac_do_void_callback(__priv, desc, get_timestamp, __args) | |
124 | #define stmmac_get_rx_timestamp_status(__priv, __args...) \ | |
125 | stmmac_do_callback(__priv, desc, get_rx_timestamp_status, __args) | |
126 | #define stmmac_display_ring(__priv, __args...) \ | |
127 | stmmac_do_void_callback(__priv, desc, display_ring, __args) | |
128 | #define stmmac_set_mss(__priv, __args...) \ | |
129 | stmmac_do_void_callback(__priv, desc, set_mss, __args) | |
6844171d JA |
130 | #define stmmac_set_desc_addr(__priv, __args...) \ |
131 | stmmac_do_void_callback(__priv, desc, set_addr, __args) | |
44c67f85 JA |
132 | #define stmmac_clear_desc(__priv, __args...) \ |
133 | stmmac_do_void_callback(__priv, desc, clear, __args) | |
42de047d | 134 | |
a4e887fa JA |
135 | struct stmmac_dma_cfg; |
136 | struct dma_features; | |
137 | ||
138 | /* Specific DMA helpers */ | |
139 | struct stmmac_dma_ops { | |
140 | /* DMA core initialization */ | |
141 | int (*reset)(void __iomem *ioaddr); | |
142 | void (*init)(void __iomem *ioaddr, struct stmmac_dma_cfg *dma_cfg, | |
24aaed0c | 143 | int atds); |
a4e887fa JA |
144 | void (*init_chan)(void __iomem *ioaddr, |
145 | struct stmmac_dma_cfg *dma_cfg, u32 chan); | |
146 | void (*init_rx_chan)(void __iomem *ioaddr, | |
147 | struct stmmac_dma_cfg *dma_cfg, | |
148 | u32 dma_rx_phy, u32 chan); | |
149 | void (*init_tx_chan)(void __iomem *ioaddr, | |
150 | struct stmmac_dma_cfg *dma_cfg, | |
151 | u32 dma_tx_phy, u32 chan); | |
152 | /* Configure the AXI Bus Mode Register */ | |
153 | void (*axi)(void __iomem *ioaddr, struct stmmac_axi *axi); | |
154 | /* Dump DMA registers */ | |
155 | void (*dump_regs)(void __iomem *ioaddr, u32 *reg_space); | |
a4e887fa JA |
156 | void (*dma_rx_mode)(void __iomem *ioaddr, int mode, u32 channel, |
157 | int fifosz, u8 qmode); | |
158 | void (*dma_tx_mode)(void __iomem *ioaddr, int mode, u32 channel, | |
159 | int fifosz, u8 qmode); | |
160 | /* To track extra statistic (if supported) */ | |
161 | void (*dma_diagnostic_fr) (void *data, struct stmmac_extra_stats *x, | |
162 | void __iomem *ioaddr); | |
163 | void (*enable_dma_transmission) (void __iomem *ioaddr); | |
164 | void (*enable_dma_irq)(void __iomem *ioaddr, u32 chan); | |
165 | void (*disable_dma_irq)(void __iomem *ioaddr, u32 chan); | |
166 | void (*start_tx)(void __iomem *ioaddr, u32 chan); | |
167 | void (*stop_tx)(void __iomem *ioaddr, u32 chan); | |
168 | void (*start_rx)(void __iomem *ioaddr, u32 chan); | |
169 | void (*stop_rx)(void __iomem *ioaddr, u32 chan); | |
170 | int (*dma_interrupt) (void __iomem *ioaddr, | |
171 | struct stmmac_extra_stats *x, u32 chan); | |
172 | /* If supported then get the optional core features */ | |
173 | void (*get_hw_feature)(void __iomem *ioaddr, | |
174 | struct dma_features *dma_cap); | |
175 | /* Program the HW RX Watchdog */ | |
176 | void (*rx_watchdog)(void __iomem *ioaddr, u32 riwt, u32 number_chan); | |
177 | void (*set_tx_ring_len)(void __iomem *ioaddr, u32 len, u32 chan); | |
178 | void (*set_rx_ring_len)(void __iomem *ioaddr, u32 len, u32 chan); | |
179 | void (*set_rx_tail_ptr)(void __iomem *ioaddr, u32 tail_ptr, u32 chan); | |
180 | void (*set_tx_tail_ptr)(void __iomem *ioaddr, u32 tail_ptr, u32 chan); | |
181 | void (*enable_tso)(void __iomem *ioaddr, bool en, u32 chan); | |
182 | }; | |
183 | ||
184 | #define stmmac_reset(__priv, __args...) \ | |
185 | stmmac_do_callback(__priv, dma, reset, __args) | |
186 | #define stmmac_dma_init(__priv, __args...) \ | |
187 | stmmac_do_void_callback(__priv, dma, init, __args) | |
188 | #define stmmac_init_chan(__priv, __args...) \ | |
189 | stmmac_do_void_callback(__priv, dma, init_chan, __args) | |
190 | #define stmmac_init_rx_chan(__priv, __args...) \ | |
191 | stmmac_do_void_callback(__priv, dma, init_rx_chan, __args) | |
192 | #define stmmac_init_tx_chan(__priv, __args...) \ | |
193 | stmmac_do_void_callback(__priv, dma, init_tx_chan, __args) | |
194 | #define stmmac_axi(__priv, __args...) \ | |
195 | stmmac_do_void_callback(__priv, dma, axi, __args) | |
196 | #define stmmac_dump_dma_regs(__priv, __args...) \ | |
197 | stmmac_do_void_callback(__priv, dma, dump_regs, __args) | |
a4e887fa JA |
198 | #define stmmac_dma_rx_mode(__priv, __args...) \ |
199 | stmmac_do_void_callback(__priv, dma, dma_rx_mode, __args) | |
200 | #define stmmac_dma_tx_mode(__priv, __args...) \ | |
201 | stmmac_do_void_callback(__priv, dma, dma_tx_mode, __args) | |
202 | #define stmmac_dma_diagnostic_fr(__priv, __args...) \ | |
203 | stmmac_do_void_callback(__priv, dma, dma_diagnostic_fr, __args) | |
204 | #define stmmac_enable_dma_transmission(__priv, __args...) \ | |
205 | stmmac_do_void_callback(__priv, dma, enable_dma_transmission, __args) | |
206 | #define stmmac_enable_dma_irq(__priv, __args...) \ | |
207 | stmmac_do_void_callback(__priv, dma, enable_dma_irq, __args) | |
208 | #define stmmac_disable_dma_irq(__priv, __args...) \ | |
209 | stmmac_do_void_callback(__priv, dma, disable_dma_irq, __args) | |
210 | #define stmmac_start_tx(__priv, __args...) \ | |
211 | stmmac_do_void_callback(__priv, dma, start_tx, __args) | |
212 | #define stmmac_stop_tx(__priv, __args...) \ | |
213 | stmmac_do_void_callback(__priv, dma, stop_tx, __args) | |
214 | #define stmmac_start_rx(__priv, __args...) \ | |
215 | stmmac_do_void_callback(__priv, dma, start_rx, __args) | |
216 | #define stmmac_stop_rx(__priv, __args...) \ | |
217 | stmmac_do_void_callback(__priv, dma, stop_rx, __args) | |
218 | #define stmmac_dma_interrupt_status(__priv, __args...) \ | |
219 | stmmac_do_callback(__priv, dma, dma_interrupt, __args) | |
220 | #define stmmac_get_hw_feature(__priv, __args...) \ | |
221 | stmmac_do_void_callback(__priv, dma, get_hw_feature, __args) | |
222 | #define stmmac_rx_watchdog(__priv, __args...) \ | |
223 | stmmac_do_void_callback(__priv, dma, rx_watchdog, __args) | |
224 | #define stmmac_set_tx_ring_len(__priv, __args...) \ | |
225 | stmmac_do_void_callback(__priv, dma, set_tx_ring_len, __args) | |
226 | #define stmmac_set_rx_ring_len(__priv, __args...) \ | |
227 | stmmac_do_void_callback(__priv, dma, set_rx_ring_len, __args) | |
228 | #define stmmac_set_rx_tail_ptr(__priv, __args...) \ | |
229 | stmmac_do_void_callback(__priv, dma, set_rx_tail_ptr, __args) | |
230 | #define stmmac_set_tx_tail_ptr(__priv, __args...) \ | |
231 | stmmac_do_void_callback(__priv, dma, set_tx_tail_ptr, __args) | |
232 | #define stmmac_enable_tso(__priv, __args...) \ | |
233 | stmmac_do_void_callback(__priv, dma, enable_tso, __args) | |
234 | ||
c10d4c82 JA |
235 | struct mac_device_info; |
236 | struct net_device; | |
237 | struct rgmii_adv; | |
238 | struct stmmac_safety_stats; | |
4dbbe8dd | 239 | struct stmmac_tc_entry; |
c10d4c82 JA |
240 | |
241 | /* Helpers to program the MAC core */ | |
242 | struct stmmac_ops { | |
243 | /* MAC core initialization */ | |
244 | void (*core_init)(struct mac_device_info *hw, struct net_device *dev); | |
245 | /* Enable the MAC RX/TX */ | |
246 | void (*set_mac)(void __iomem *ioaddr, bool enable); | |
247 | /* Enable and verify that the IPC module is supported */ | |
248 | int (*rx_ipc)(struct mac_device_info *hw); | |
249 | /* Enable RX Queues */ | |
250 | void (*rx_queue_enable)(struct mac_device_info *hw, u8 mode, u32 queue); | |
251 | /* RX Queues Priority */ | |
252 | void (*rx_queue_prio)(struct mac_device_info *hw, u32 prio, u32 queue); | |
253 | /* TX Queues Priority */ | |
254 | void (*tx_queue_prio)(struct mac_device_info *hw, u32 prio, u32 queue); | |
255 | /* RX Queues Routing */ | |
256 | void (*rx_queue_routing)(struct mac_device_info *hw, u8 packet, | |
257 | u32 queue); | |
258 | /* Program RX Algorithms */ | |
259 | void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 rx_alg); | |
260 | /* Program TX Algorithms */ | |
261 | void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 tx_alg); | |
262 | /* Set MTL TX queues weight */ | |
263 | void (*set_mtl_tx_queue_weight)(struct mac_device_info *hw, | |
264 | u32 weight, u32 queue); | |
265 | /* RX MTL queue to RX dma mapping */ | |
266 | void (*map_mtl_to_dma)(struct mac_device_info *hw, u32 queue, u32 chan); | |
267 | /* Configure AV Algorithm */ | |
268 | void (*config_cbs)(struct mac_device_info *hw, u32 send_slope, | |
269 | u32 idle_slope, u32 high_credit, u32 low_credit, | |
270 | u32 queue); | |
271 | /* Dump MAC registers */ | |
272 | void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space); | |
273 | /* Handle extra events on specific interrupts hw dependent */ | |
274 | int (*host_irq_status)(struct mac_device_info *hw, | |
275 | struct stmmac_extra_stats *x); | |
276 | /* Handle MTL interrupts */ | |
277 | int (*host_mtl_irq_status)(struct mac_device_info *hw, u32 chan); | |
278 | /* Multicast filter setting */ | |
279 | void (*set_filter)(struct mac_device_info *hw, struct net_device *dev); | |
280 | /* Flow control setting */ | |
281 | void (*flow_ctrl)(struct mac_device_info *hw, unsigned int duplex, | |
282 | unsigned int fc, unsigned int pause_time, u32 tx_cnt); | |
283 | /* Set power management mode (e.g. magic frame) */ | |
284 | void (*pmt)(struct mac_device_info *hw, unsigned long mode); | |
285 | /* Set/Get Unicast MAC addresses */ | |
286 | void (*set_umac_addr)(struct mac_device_info *hw, unsigned char *addr, | |
287 | unsigned int reg_n); | |
288 | void (*get_umac_addr)(struct mac_device_info *hw, unsigned char *addr, | |
289 | unsigned int reg_n); | |
290 | void (*set_eee_mode)(struct mac_device_info *hw, | |
291 | bool en_tx_lpi_clockgating); | |
292 | void (*reset_eee_mode)(struct mac_device_info *hw); | |
293 | void (*set_eee_timer)(struct mac_device_info *hw, int ls, int tw); | |
294 | void (*set_eee_pls)(struct mac_device_info *hw, int link); | |
295 | void (*debug)(void __iomem *ioaddr, struct stmmac_extra_stats *x, | |
296 | u32 rx_queues, u32 tx_queues); | |
297 | /* PCS calls */ | |
298 | void (*pcs_ctrl_ane)(void __iomem *ioaddr, bool ane, bool srgmi_ral, | |
299 | bool loopback); | |
300 | void (*pcs_rane)(void __iomem *ioaddr, bool restart); | |
301 | void (*pcs_get_adv_lp)(void __iomem *ioaddr, struct rgmii_adv *adv); | |
302 | /* Safety Features */ | |
303 | int (*safety_feat_config)(void __iomem *ioaddr, unsigned int asp); | |
304 | int (*safety_feat_irq_status)(struct net_device *ndev, | |
305 | void __iomem *ioaddr, unsigned int asp, | |
306 | struct stmmac_safety_stats *stats); | |
307 | int (*safety_feat_dump)(struct stmmac_safety_stats *stats, | |
308 | int index, unsigned long *count, const char **desc); | |
4dbbe8dd JA |
309 | /* Flexible RX Parser */ |
310 | int (*rxp_config)(void __iomem *ioaddr, struct stmmac_tc_entry *entries, | |
311 | unsigned int count); | |
c10d4c82 JA |
312 | }; |
313 | ||
314 | #define stmmac_core_init(__priv, __args...) \ | |
315 | stmmac_do_void_callback(__priv, mac, core_init, __args) | |
316 | #define stmmac_mac_set(__priv, __args...) \ | |
317 | stmmac_do_void_callback(__priv, mac, set_mac, __args) | |
318 | #define stmmac_rx_ipc(__priv, __args...) \ | |
319 | stmmac_do_callback(__priv, mac, rx_ipc, __args) | |
320 | #define stmmac_rx_queue_enable(__priv, __args...) \ | |
321 | stmmac_do_void_callback(__priv, mac, rx_queue_enable, __args) | |
322 | #define stmmac_rx_queue_prio(__priv, __args...) \ | |
323 | stmmac_do_void_callback(__priv, mac, rx_queue_prio, __args) | |
324 | #define stmmac_tx_queue_prio(__priv, __args...) \ | |
325 | stmmac_do_void_callback(__priv, mac, tx_queue_prio, __args) | |
326 | #define stmmac_rx_queue_routing(__priv, __args...) \ | |
327 | stmmac_do_void_callback(__priv, mac, rx_queue_routing, __args) | |
328 | #define stmmac_prog_mtl_rx_algorithms(__priv, __args...) \ | |
329 | stmmac_do_void_callback(__priv, mac, prog_mtl_rx_algorithms, __args) | |
330 | #define stmmac_prog_mtl_tx_algorithms(__priv, __args...) \ | |
331 | stmmac_do_void_callback(__priv, mac, prog_mtl_tx_algorithms, __args) | |
332 | #define stmmac_set_mtl_tx_queue_weight(__priv, __args...) \ | |
333 | stmmac_do_void_callback(__priv, mac, set_mtl_tx_queue_weight, __args) | |
334 | #define stmmac_map_mtl_to_dma(__priv, __args...) \ | |
335 | stmmac_do_void_callback(__priv, mac, map_mtl_to_dma, __args) | |
336 | #define stmmac_config_cbs(__priv, __args...) \ | |
337 | stmmac_do_void_callback(__priv, mac, config_cbs, __args) | |
338 | #define stmmac_dump_mac_regs(__priv, __args...) \ | |
339 | stmmac_do_void_callback(__priv, mac, dump_regs, __args) | |
340 | #define stmmac_host_irq_status(__priv, __args...) \ | |
341 | stmmac_do_callback(__priv, mac, host_irq_status, __args) | |
342 | #define stmmac_host_mtl_irq_status(__priv, __args...) \ | |
343 | stmmac_do_callback(__priv, mac, host_mtl_irq_status, __args) | |
344 | #define stmmac_set_filter(__priv, __args...) \ | |
345 | stmmac_do_void_callback(__priv, mac, set_filter, __args) | |
346 | #define stmmac_flow_ctrl(__priv, __args...) \ | |
347 | stmmac_do_void_callback(__priv, mac, flow_ctrl, __args) | |
348 | #define stmmac_pmt(__priv, __args...) \ | |
349 | stmmac_do_void_callback(__priv, mac, pmt, __args) | |
350 | #define stmmac_set_umac_addr(__priv, __args...) \ | |
351 | stmmac_do_void_callback(__priv, mac, set_umac_addr, __args) | |
352 | #define stmmac_get_umac_addr(__priv, __args...) \ | |
353 | stmmac_do_void_callback(__priv, mac, get_umac_addr, __args) | |
354 | #define stmmac_set_eee_mode(__priv, __args...) \ | |
355 | stmmac_do_void_callback(__priv, mac, set_eee_mode, __args) | |
356 | #define stmmac_reset_eee_mode(__priv, __args...) \ | |
357 | stmmac_do_void_callback(__priv, mac, reset_eee_mode, __args) | |
358 | #define stmmac_set_eee_timer(__priv, __args...) \ | |
359 | stmmac_do_void_callback(__priv, mac, set_eee_timer, __args) | |
360 | #define stmmac_set_eee_pls(__priv, __args...) \ | |
361 | stmmac_do_void_callback(__priv, mac, set_eee_pls, __args) | |
362 | #define stmmac_mac_debug(__priv, __args...) \ | |
363 | stmmac_do_void_callback(__priv, mac, debug, __args) | |
364 | #define stmmac_pcs_ctrl_ane(__priv, __args...) \ | |
365 | stmmac_do_void_callback(__priv, mac, pcs_ctrl_ane, __args) | |
366 | #define stmmac_pcs_rane(__priv, __args...) \ | |
367 | stmmac_do_void_callback(__priv, mac, pcs_rane, __args) | |
368 | #define stmmac_pcs_get_adv_lp(__priv, __args...) \ | |
369 | stmmac_do_void_callback(__priv, mac, pcs_get_adv_lp, __args) | |
370 | #define stmmac_safety_feat_config(__priv, __args...) \ | |
371 | stmmac_do_callback(__priv, mac, safety_feat_config, __args) | |
372 | #define stmmac_safety_feat_irq_status(__priv, __args...) \ | |
373 | stmmac_do_callback(__priv, mac, safety_feat_irq_status, __args) | |
374 | #define stmmac_safety_feat_dump(__priv, __args...) \ | |
375 | stmmac_do_callback(__priv, mac, safety_feat_dump, __args) | |
4dbbe8dd JA |
376 | #define stmmac_rxp_config(__priv, __args...) \ |
377 | stmmac_do_callback(__priv, mac, rxp_config, __args) | |
c10d4c82 | 378 | |
cc4c9001 JA |
379 | /* PTP and HW Timer helpers */ |
380 | struct stmmac_hwtimestamp { | |
381 | void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data); | |
382 | void (*config_sub_second_increment)(void __iomem *ioaddr, u32 ptp_clock, | |
383 | int gmac4, u32 *ssinc); | |
384 | int (*init_systime) (void __iomem *ioaddr, u32 sec, u32 nsec); | |
385 | int (*config_addend) (void __iomem *ioaddr, u32 addend); | |
386 | int (*adjust_systime) (void __iomem *ioaddr, u32 sec, u32 nsec, | |
387 | int add_sub, int gmac4); | |
388 | void (*get_systime) (void __iomem *ioaddr, u64 *systime); | |
389 | }; | |
390 | ||
391 | #define stmmac_config_hw_tstamping(__priv, __args...) \ | |
392 | stmmac_do_void_callback(__priv, ptp, config_hw_tstamping, __args) | |
393 | #define stmmac_config_sub_second_increment(__priv, __args...) \ | |
394 | stmmac_do_void_callback(__priv, ptp, config_sub_second_increment, __args) | |
395 | #define stmmac_init_systime(__priv, __args...) \ | |
396 | stmmac_do_callback(__priv, ptp, init_systime, __args) | |
397 | #define stmmac_config_addend(__priv, __args...) \ | |
398 | stmmac_do_callback(__priv, ptp, config_addend, __args) | |
399 | #define stmmac_adjust_systime(__priv, __args...) \ | |
400 | stmmac_do_callback(__priv, ptp, adjust_systime, __args) | |
401 | #define stmmac_get_systime(__priv, __args...) \ | |
402 | stmmac_do_void_callback(__priv, ptp, get_systime, __args) | |
403 | ||
2c520b1c JA |
404 | /* Helpers to manage the descriptors for chain and ring modes */ |
405 | struct stmmac_mode_ops { | |
406 | void (*init) (void *des, dma_addr_t phy_addr, unsigned int size, | |
407 | unsigned int extend_desc); | |
408 | unsigned int (*is_jumbo_frm) (int len, int ehn_desc); | |
409 | int (*jumbo_frm)(void *priv, struct sk_buff *skb, int csum); | |
410 | int (*set_16kib_bfsize)(int mtu); | |
411 | void (*init_desc3)(struct dma_desc *p); | |
412 | void (*refill_desc3) (void *priv, struct dma_desc *p); | |
413 | void (*clean_desc3) (void *priv, struct dma_desc *p); | |
414 | }; | |
415 | ||
416 | #define stmmac_mode_init(__priv, __args...) \ | |
417 | stmmac_do_void_callback(__priv, mode, init, __args) | |
418 | #define stmmac_is_jumbo_frm(__priv, __args...) \ | |
419 | stmmac_do_callback(__priv, mode, is_jumbo_frm, __args) | |
420 | #define stmmac_jumbo_frm(__priv, __args...) \ | |
421 | stmmac_do_callback(__priv, mode, jumbo_frm, __args) | |
422 | #define stmmac_set_16kib_bfsize(__priv, __args...) \ | |
423 | stmmac_do_callback(__priv, mode, set_16kib_bfsize, __args) | |
424 | #define stmmac_init_desc3(__priv, __args...) \ | |
425 | stmmac_do_void_callback(__priv, mode, init_desc3, __args) | |
426 | #define stmmac_refill_desc3(__priv, __args...) \ | |
427 | stmmac_do_void_callback(__priv, mode, refill_desc3, __args) | |
428 | #define stmmac_clean_desc3(__priv, __args...) \ | |
429 | stmmac_do_void_callback(__priv, mode, clean_desc3, __args) | |
430 | ||
5f0456b4 | 431 | struct stmmac_priv; |
4dbbe8dd JA |
432 | struct tc_cls_u32_offload; |
433 | ||
434 | struct stmmac_tc_ops { | |
435 | int (*init)(struct stmmac_priv *priv); | |
436 | int (*setup_cls_u32)(struct stmmac_priv *priv, | |
437 | struct tc_cls_u32_offload *cls); | |
438 | }; | |
439 | ||
440 | #define stmmac_tc_init(__priv, __args...) \ | |
441 | stmmac_do_callback(__priv, tc, init, __args) | |
442 | #define stmmac_tc_setup_cls_u32(__priv, __args...) \ | |
443 | stmmac_do_callback(__priv, tc, setup_cls_u32, __args) | |
5f0456b4 | 444 | |
758d5c73 JA |
445 | struct stmmac_regs_off { |
446 | u32 ptp_off; | |
447 | u32 mmc_off; | |
448 | }; | |
449 | ||
5f0456b4 JA |
450 | extern const struct stmmac_ops dwmac100_ops; |
451 | extern const struct stmmac_dma_ops dwmac100_dma_ops; | |
452 | extern const struct stmmac_ops dwmac1000_ops; | |
453 | extern const struct stmmac_dma_ops dwmac1000_dma_ops; | |
454 | extern const struct stmmac_ops dwmac4_ops; | |
455 | extern const struct stmmac_dma_ops dwmac4_dma_ops; | |
456 | extern const struct stmmac_ops dwmac410_ops; | |
457 | extern const struct stmmac_dma_ops dwmac410_dma_ops; | |
458 | extern const struct stmmac_ops dwmac510_ops; | |
4dbbe8dd | 459 | extern const struct stmmac_tc_ops dwmac510_tc_ops; |
5f0456b4 JA |
460 | |
461 | #define GMAC_VERSION 0x00000020 /* GMAC CORE Version */ | |
462 | #define GMAC4_VERSION 0x00000110 /* GMAC4+ CORE Version */ | |
463 | ||
464 | int stmmac_hwif_init(struct stmmac_priv *priv); | |
465 | ||
42de047d | 466 | #endif /* __STMMAC_HWIF_H__ */ |