drv_enet.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (c) 2021 hpmicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef DRV_ENET_H
  8. #define DRV_ENET_H
  9. #include <netif/ethernetif.h>
  10. #include "../../applications/inc/netconf.h"
  11. #include "hpm_enet_drv.h"
  12. typedef struct {
  13. ENET_Type * instance;
  14. enet_desc_t desc;
  15. enet_mac_config_t mac_config;
  16. uint8_t media_interface;
  17. uint32_t mask;
  18. uint32_t dis_mask;
  19. uint32_t irq_number;
  20. bool int_refclk;
  21. uint8_t tx_delay;
  22. uint8_t rx_delay;
  23. bool ptp_enable;
  24. uint32_t ptp_clk_src;
  25. enet_ptp_config_t ptp_config;
  26. enet_ptp_time_t ptp_timestamp;
  27. } enet_device;
  28. typedef struct _hpm_enet
  29. {
  30. const char *name;
  31. ENET_Type *base;
  32. clock_name_t clock_name;
  33. int32_t irq_num;
  34. uint8_t inf;
  35. struct eth_device *eth_dev;
  36. enet_device *enet_dev;
  37. enet_buff_config_t *rx_buff_cfg;
  38. enet_buff_config_t *tx_buff_cfg;
  39. volatile enet_rx_desc_t *dma_rx_desc_tab;
  40. volatile enet_tx_desc_t *dma_tx_desc_tab;
  41. uint8_t tx_delay;
  42. uint8_t rx_delay;
  43. bool int_refclk;
  44. bool ptp_enable;
  45. uint32_t ptp_clk_src;
  46. enet_ptp_config_t *ptp_config;
  47. enet_ptp_time_t *ptp_timestamp;
  48. } hpm_enet_t;
  49. #ifndef ENET0_TX_BUFF_COUNT
  50. #define ENET0_TX_BUFF_COUNT (10U)
  51. #endif
  52. #ifndef ENET0_RX_BUFF_COUNT
  53. #define ENET0_RX_BUFF_COUNT (20U)
  54. #endif
  55. #ifndef ENET0_RX_BUFF_SIZE
  56. #define ENET0_RX_BUFF_SIZE ENET_MAX_FRAME_SIZE
  57. #endif
  58. #ifndef ENET0_TX_BUFF_SIZE
  59. #define ENET0_TX_BUFF_SIZE ENET_MAX_FRAME_SIZE
  60. #endif
  61. #ifndef ENET1_TX_BUFF_COUNT
  62. #define ENET1_TX_BUFF_COUNT (10U)
  63. #endif
  64. #ifndef ENET1_RX_BUFF_COUNT
  65. #define ENET1_RX_BUFF_COUNT (20U)
  66. #endif
  67. #ifndef ENET1_RX_BUFF_SIZE
  68. #define ENET1_RX_BUFF_SIZE ENET_MAX_FRAME_SIZE
  69. #endif
  70. #ifndef ENET1_TX_BUFF_SIZE
  71. #define ENET1_TX_BUFF_SIZE ENET_MAX_FRAME_SIZE
  72. #endif
  73. int rt_hw_eth_init(void);
  74. #endif /* DRV_ENET_H */
  75. /* DRV_GPIO_H */