Jiandong Zheng | 799e125 | 2014-08-01 20:37:16 -0700 | [diff] [blame] | 1 | /* |
Suji Velupillai | 5c624b9 | 2017-03-03 17:06:34 -0800 | [diff] [blame] | 2 | * Copyright 2014-2017 Broadcom. |
Jiandong Zheng | 799e125 | 2014-08-01 20:37:16 -0700 | [diff] [blame] | 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 | |
Jiandong Zheng | 799e125 | 2014-08-01 20:37:16 -0700 | [diff] [blame] | 23 | enum { |
| 24 | MAC_DMA_TX = 1, |
| 25 | MAC_DMA_RX = 2 |
| 26 | }; |
| 27 | |
| 28 | struct eth_dma { |
| 29 | void *tx_desc_aligned; |
| 30 | void *rx_desc_aligned; |
Jiandong Zheng | 799e125 | 2014-08-01 20:37:16 -0700 | [diff] [blame] | 31 | |
| 32 | uint8_t *tx_buf; |
| 33 | uint8_t *rx_buf; |
| 34 | |
| 35 | int cur_tx_index; |
| 36 | int cur_rx_index; |
| 37 | |
| 38 | int (*tx_packet)(struct eth_dma *dma, void *packet, int length); |
| 39 | bool (*check_tx_done)(struct eth_dma *dma); |
| 40 | |
| 41 | int (*check_rx_done)(struct eth_dma *dma, uint8_t *buf); |
| 42 | |
| 43 | int (*enable_dma)(struct eth_dma *dma, int dir); |
| 44 | int (*disable_dma)(struct eth_dma *dma, int dir); |
| 45 | }; |
| 46 | |
| 47 | struct eth_info { |
| 48 | struct eth_dma dma; |
| 49 | phy_interface_t phy_interface; |
| 50 | struct phy_device *port[BCM_ETH_MAX_PORT_NUM]; |
| 51 | int port_num; |
| 52 | |
Joe Hershberger | dfcc496 | 2016-08-08 11:28:39 -0500 | [diff] [blame] | 53 | int (*miiphy_read)(struct mii_dev *bus, int phyaddr, int devad, |
| 54 | int reg); |
| 55 | int (*miiphy_write)(struct mii_dev *bus, int phyaddr, int devad, |
| 56 | int reg, u16 value); |
Jiandong Zheng | 799e125 | 2014-08-01 20:37:16 -0700 | [diff] [blame] | 57 | |
| 58 | int (*mac_init)(struct eth_device *dev); |
| 59 | int (*enable_mac)(void); |
| 60 | int (*disable_mac)(void); |
| 61 | int (*set_mac_addr)(unsigned char *mac); |
| 62 | int (*set_mac_speed)(int speed, int duplex); |
| 63 | |
| 64 | }; |
| 65 | |
| 66 | #endif /* _BCM_SF2_ETH_H_ */ |