bcm-sf2-eth.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright 2014-2017 Broadcom.
  4. */
  5. #ifndef _BCM_SF2_ETH_H_
  6. #define _BCM_SF2_ETH_H_
  7. #include <phy.h>
  8. #define RX_BUF_SIZE 2048
  9. /* RX_BUF_NUM must be power of 2 */
  10. #define RX_BUF_NUM 32
  11. #define TX_BUF_SIZE 2048
  12. /* TX_BUF_NUM must be power of 2 */
  13. #define TX_BUF_NUM 2
  14. /* Support 2 Ethernet ports now */
  15. #define BCM_ETH_MAX_PORT_NUM 2
  16. enum {
  17. MAC_DMA_TX = 1,
  18. MAC_DMA_RX = 2
  19. };
  20. struct eth_dma {
  21. void *tx_desc_aligned;
  22. void *rx_desc_aligned;
  23. uint8_t *tx_buf;
  24. uint8_t *rx_buf;
  25. int cur_tx_index;
  26. int cur_rx_index;
  27. int (*tx_packet)(struct eth_dma *dma, void *packet, int length);
  28. bool (*check_tx_done)(struct eth_dma *dma);
  29. int (*check_rx_done)(struct eth_dma *dma, uint8_t *buf);
  30. int (*enable_dma)(struct eth_dma *dma, int dir);
  31. int (*disable_dma)(struct eth_dma *dma, int dir);
  32. };
  33. struct eth_info {
  34. struct eth_dma dma;
  35. phy_interface_t phy_interface;
  36. struct phy_device *port[BCM_ETH_MAX_PORT_NUM];
  37. int port_num;
  38. int (*miiphy_read)(struct mii_dev *bus, int phyaddr, int devad,
  39. int reg);
  40. int (*miiphy_write)(struct mii_dev *bus, int phyaddr, int devad,
  41. int reg, u16 value);
  42. int (*mac_init)(struct eth_device *dev);
  43. int (*enable_mac)(void);
  44. int (*disable_mac)(void);
  45. int (*set_mac_addr)(unsigned char *mac);
  46. int (*set_mac_speed)(int speed, int duplex);
  47. };
  48. #endif /* _BCM_SF2_ETH_H_ */