Jiandong Zheng | c36e42e | 2014-08-01 20:37:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Broadcom Corporation. |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #ifndef _BCM_SF2_ETH_H_ |
| 8 | #define _BCM_SF2_ETH_H_ |
| 9 | |
| 10 | #include <phy.h> |
| 11 | |
| 12 | #define RX_BUF_SIZE 2048 |
| 13 | /* RX_BUF_NUM must be power of 2 */ |
| 14 | #define RX_BUF_NUM 32 |
| 15 | |
| 16 | #define TX_BUF_SIZE 2048 |
| 17 | /* TX_BUF_NUM must be power of 2 */ |
| 18 | #define TX_BUF_NUM 2 |
| 19 | |
| 20 | /* Support 2 Ethernet ports now */ |
| 21 | #define BCM_ETH_MAX_PORT_NUM 2 |
| 22 | |
| 23 | #define CONFIG_BCM_SF2_ETH_DEFAULT_PORT 0 |
| 24 | |
| 25 | enum { |
| 26 | MAC_DMA_TX = 1, |
| 27 | MAC_DMA_RX = 2 |
| 28 | }; |
| 29 | |
| 30 | struct eth_dma { |
| 31 | void *tx_desc_aligned; |
| 32 | void *rx_desc_aligned; |
| 33 | void *tx_desc; |
| 34 | void *rx_desc; |
| 35 | |
| 36 | uint8_t *tx_buf; |
| 37 | uint8_t *rx_buf; |
| 38 | |
| 39 | int cur_tx_index; |
| 40 | int cur_rx_index; |
| 41 | |
| 42 | int (*tx_packet)(struct eth_dma *dma, void *packet, int length); |
| 43 | bool (*check_tx_done)(struct eth_dma *dma); |
| 44 | |
| 45 | int (*check_rx_done)(struct eth_dma *dma, uint8_t *buf); |
| 46 | |
| 47 | int (*enable_dma)(struct eth_dma *dma, int dir); |
| 48 | int (*disable_dma)(struct eth_dma *dma, int dir); |
| 49 | }; |
| 50 | |
| 51 | struct eth_info { |
| 52 | struct eth_dma dma; |
| 53 | phy_interface_t phy_interface; |
| 54 | struct phy_device *port[BCM_ETH_MAX_PORT_NUM]; |
| 55 | int port_num; |
| 56 | |
Joe Hershberger | 0c33319 | 2016-08-08 11:28:39 -0500 | [diff] [blame^] | 57 | int (*miiphy_read)(struct mii_dev *bus, int phyaddr, int devad, |
| 58 | int reg); |
| 59 | int (*miiphy_write)(struct mii_dev *bus, int phyaddr, int devad, |
| 60 | int reg, u16 value); |
Jiandong Zheng | c36e42e | 2014-08-01 20:37:16 -0700 | [diff] [blame] | 61 | |
| 62 | int (*mac_init)(struct eth_device *dev); |
| 63 | int (*enable_mac)(void); |
| 64 | int (*disable_mac)(void); |
| 65 | int (*set_mac_addr)(unsigned char *mac); |
| 66 | int (*set_mac_speed)(int speed, int duplex); |
| 67 | |
| 68 | }; |
| 69 | |
| 70 | #endif /* _BCM_SF2_ETH_H_ */ |