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