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