blob: f4dbb4e1952d0b2e2d6784ee88dfe6332557cac9 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Jiandong Zheng799e1252014-08-01 20:37:16 -07002/*
Suji Velupillai5c624b92017-03-03 17:06:34 -08003 * Copyright 2014-2017 Broadcom.
Jiandong Zheng799e1252014-08-01 20:37:16 -07004 */
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 Zheng799e1252014-08-01 20:37:16 -070022enum {
23 MAC_DMA_TX = 1,
24 MAC_DMA_RX = 2
25};
26
27struct eth_dma {
28 void *tx_desc_aligned;
29 void *rx_desc_aligned;
Jiandong Zheng799e1252014-08-01 20:37:16 -070030
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
46struct 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 Hershbergerdfcc4962016-08-08 11:28:39 -050052 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 Zheng799e1252014-08-01 20:37:16 -070056
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_ */