Skip to contentSkip to conversation

net: xgmac: add EEE(Energy Efficient Ethernet) for Samsung xgmac

PATCH Superseded Byungho An 1 participant 1 message Mar 5, 2014

Subsystems (3)

v1 of 14 Superseded Latest is v14 →

lore
Share & tools
lore

Byungho An

author
#0 lore raw

PATCH 3/7 net: xgmac: add EEE(Energy Efficient Ethernet) for Samsung xgmac

From: Girish K S <[email protected]>

Added support for the EEE(Energy Efficient Ethernet) in 10G ethernet driver.

---
 drivers/net/ethernet/samsung/xgmac_common.h   |   54 +++++++++
 drivers/net/ethernet/samsung/xgmac_core.c     |   86 +++++++++++++-
 drivers/net/ethernet/samsung/xgmac_ethtool.c  |   47 ++++++++
 drivers/net/ethernet/samsung/xgmac_main.c     |  152 ++++++++++++++++++++++++-
 drivers/net/ethernet/samsung/xgmac_platform.c |    4 +
 drivers/net/ethernet/samsung/xgmac_reg.h      |    5 +
 6 files changed, 346 insertions(+), 2 deletions(-)
drivers/net/ethernet/samsung/xgmac_common.h +54 -0
index eb78c84..6b7f1de 100644
@@ -118,6 +118,33 @@ struct xgmac_mtl_ops;
 #define RX_PTP_SIGNAL		0x0A
 #define RX_PTP_RESV_MSG		0x0F
 
+/* EEE-LPI mode  flags*/
+#define TX_ENTRY_LPI_MODE	0x10
+#define TX_EXIT_LPI_MODE	0x20
+#define RX_ENTRY_LPI_MODE	0x40
+#define RX_EXIT_LPI_MODE	0x80
+
+/* EEE-LPI Interrupt status flag */
+#define LPI_INT_STATUS		BIT(5)
+
+/* EEE-LPI Default timer values */
+#define LPI_LINK_STATUS_TIMER	0x3E8
+#define LPI_MAC_WAIT_TIMER	0x00
+
+/* EEE-LPI Control and status definitions */
+#define LPI_CTRL_STATUS_TXA	BIT(19)
+#define LPI_CTRL_STATUS_PLSDIS	BIT(18)
+#define LPI_CTRL_STATUS_PLS	BIT(17)
+#define LPI_CTRL_STATUS_LPIEN	BIT(16)
+#define LPI_CTRL_STATUS_TXRSTP	BIT(11)
+#define LPI_CTRL_STATUS_RXRSTP	BIT(10)
+#define LPI_CTRL_STATUS_RLPIST	BIT(9)
+#define LPI_CTRL_STATUS_TLPIST	BIT(8)
+#define LPI_CTRL_STATUS_RLPIEX	BIT(3)
+#define LPI_CTRL_STATUS_RLPIEN	BIT(2)
+#define LPI_CTRL_STATUS_TLPIEX	BIT(1)
+#define LPI_CTRL_STATUS_TLPIEN	BIT(0)
+
 enum dma_irq_status {
 	tx_hard_error = BIT(0),
 	tx_bump_tc = BIT(1),
@@ -202,6 +229,13 @@ struct xgmac_extra_stats {
 	unsigned long rx_buffer_access_err;
 	unsigned long rx_data_transfer_err;
 
+	/* EEE-LPI stats */
+	unsigned long tx_lpi_entry_n;
+	unsigned long tx_lpi_exit_n;
+	unsigned long rx_lpi_entry_n;
+	unsigned long rx_lpi_exit_n;
+	unsigned long eee_wakeup_error_n;
+
 	/* RX specific */
 	/* L2 error */
 	unsigned long rx_code_gmii_err;
@@ -310,6 +344,13 @@ struct xgmac_core_ops {
 						unsigned char feature_index);
 	/* adjust XGMAC speed */
 	void (*set_speed)(void __iomem *ioaddr, unsigned char speed);
+
+	/* EEE-LPI specific operations */
+	void (*set_eee_mode)(void __iomem *ioaddr);
+	void (*reset_eee_mode)(void __iomem *ioaddr);
+	void (*set_eee_timer)(void __iomem *ioaddr, const int ls,
+			const int tw);
+	void (*set_eee_pls)(void __iomem *ioaddr, const int link);
 };
 
 const struct xgmac_core_ops *xgmac_get_core_ops(void);
@@ -371,6 +412,8 @@ struct xgmac_hw_features {
 	/* IEEE 1588-2008 */
 	unsigned int atime_stamp;
 
+	unsigned int eee;
+
 	unsigned int tx_csum_offload;
 	unsigned int rx_csum_offload;
 	unsigned int multi_macaddr;
@@ -451,6 +494,14 @@ struct xgmac_priv_data {
 	u32 adv_ts;
 	int use_riwt;
 	spinlock_t ptp_lock;
+
+	/* EEE-LPI specific members */
+	struct timer_list eee_ctrl_timer;
+	bool tx_path_in_lpi_mode;
+	int lpi_irq;
+	int eee_enabled;
+	int eee_active;
+	int tx_lpi_timer;
 };
 
 /* Function prototypes */
@@ -473,4 +524,7 @@ extern int xgmac_restore(struct net_device *ndev);
 
 extern const struct xgmac_mtl_ops *xgmac_get_mtl_ops(void);
 
+void xgmac_disable_eee_mode(struct xgmac_priv_data * const priv);
+bool xgmac_eee_init(struct xgmac_priv_data * const priv);
+
 #endif /* __XGMAC_COMMON_H__ */
drivers/net/ethernet/samsung/xgmac_core.c +85 -1

108 lines not on this page · raw message

drivers/net/ethernet/samsung/xgmac_ethtool.c +47 -0

57 lines not on this page · raw message

drivers/net/ethernet/samsung/xgmac_main.c +151 -1

243 lines not on this page · raw message

drivers/net/ethernet/samsung/xgmac_platform.c +4 -0
index 1bb327a2..e988e38 100644
@@ -166,6 +166,10 @@ static int xgmac_platform_probe(struct platform_device *pdev)
 		}
 	}
 
+	priv->lpi_irq = irq_of_parse_and_map(dev->of_node, loop++);
+	if (priv->lpi_irq == -ENXIO)
+		priv->lpi_irq = priv->dev->irq;
+
 	platform_set_drvdata(pdev, priv->dev);
 
 	pr_debug("XGMAC platform driver registration completed");
drivers/net/ethernet/samsung/xgmac_reg.h +5 -0
index 11ae281..87fbff0 100644
@@ -25,6 +25,11 @@
 #define XGMAC_CORE_HASH_TABLE_REG5	0x0024
 #define XGMAC_CORE_HASH_TABLE_REG6	0x0028
 #define XGMAC_CORE_HASH_TABLE_REG7	0x002C
+
+/* EEE-LPI Registers */
+#define XGMAC_CORE_LPI_CTRL_STATUS	0x00D0
+#define XGMAC_CORE_LPI_TIMER_CTRL	0x00D4
+
 /* VLAN Specific Registers */
 #define XGMAC_CORE_VLAN_TAG_REG		0x0050
 #define XGMAC_CORE_VLAN_HASHTAB_REG	0x0058
Signature · 1 line
1.7.10.4