1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright 2014-2017 Broadcom.
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 
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;
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 
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);
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_ */
66