1 /*
2  * Applied Micro X-Gene SoC Ethernet v2 Driver
3  *
4  * Copyright (c) 2017, Applied Micro Circuits Corporation
5  * Author(s): Iyappan Subramanian <isubramanian@apm.com>
6  *	      Keyur Chudgar <kchudgar@apm.com>
7  *
8  * This program is free software; you can redistribute  it and/or modify it
9  * under  the terms of  the GNU General  Public License as published by the
10  * Free Software Foundation;  either version 2 of the  License, or (at your
11  * option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef __XGENE_ENET_V2_MAIN_H__
23 #define __XGENE_ENET_V2_MAIN_H__
24 
25 #include <linux/acpi.h>
26 #include <linux/clk.h>
27 #include <linux/efi.h>
28 #include <linux/if_vlan.h>
29 #include <linux/irq.h>
30 #include <linux/io.h>
31 #include <linux/module.h>
32 #include <linux/of_platform.h>
33 #include <linux/of_net.h>
34 #include <linux/of_mdio.h>
35 #include <linux/prefetch.h>
36 #include <linux/phy.h>
37 #include <net/ip.h>
38 #include "mac.h"
39 #include "enet.h"
40 #include "ring.h"
41 #include "ethtool.h"
42 
43 #define XGENE_ENET_V2_VERSION	"v1.0"
44 #define XGENE_ENET_STD_MTU	1536
45 #define XGENE_ENET_MIN_FRAME	60
46 #define IRQ_ID_SIZE             16
47 
48 struct xge_resource {
49 	void __iomem *base_addr;
50 	int phy_mode;
51 	u32 irq;
52 };
53 
54 struct xge_stats {
55 	u64 tx_packets;
56 	u64 tx_bytes;
57 	u64 rx_packets;
58 	u64 rx_bytes;
59 	u64 rx_errors;
60 };
61 
62 /* ethernet private data */
63 struct xge_pdata {
64 	struct xge_resource resources;
65 	struct xge_desc_ring *tx_ring;
66 	struct xge_desc_ring *rx_ring;
67 	struct platform_device *pdev;
68 	char irq_name[IRQ_ID_SIZE];
69 	struct mii_bus *mdio_bus;
70 	struct net_device *ndev;
71 	struct napi_struct napi;
72 	struct xge_stats stats;
73 	int phy_speed;
74 	u8 nbufs;
75 };
76 
77 int xge_mdio_config(struct net_device *ndev);
78 void xge_mdio_remove(struct net_device *ndev);
79 
80 #endif /* __XGENE_ENET_V2_MAIN_H__ */
81