All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 39/45] net: mvpp2: Add GoP and NetC support for port 0 (SFI)
Date: Thu, 23 Mar 2017 17:02:05 +0100	[thread overview]
Message-ID: <20170323160211.18072-40-sr@denx.de> (raw)
In-Reply-To: <20170323160211.18072-1-sr@denx.de>

This patch adds the GoP (Group of Ports) and NetC (Net Complex) setup to
the Marvell mvpp2 ethernet driver for the missing port 0. This code is
mostly copied from the Marvell U-Boot version and was written by Stefan
Chulski. Please note that only SFI support have been added, as this
is the only interface that this code has been tested with. XAUI and
RXAUI support might follow at a later stage.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Stefan Chulski <stefanc@marvell.com>
Cc: Kostya Porotchkin <kostap@marvell.com>
Cc: Nadav Haklai <nadavh@marvell.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>

---

Changes in v2:
- New patch

 drivers/net/mvpp2.c | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 161 insertions(+)

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 76370faff0..7b4f7a22bd 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -3234,6 +3234,130 @@ static int gop_gpcs_reset(struct mvpp2_port *port, enum mv_reset act)
 	return 0;
 }
 
+/* Set the internal mux's to the required PCS in the PI */
+static int gop_xpcs_mode(struct mvpp2_port *port, int num_of_lanes)
+{
+	u32 val;
+	int lane;
+
+	switch (num_of_lanes) {
+	case 1:
+		lane = 0;
+		break;
+	case 2:
+		lane = 1;
+		break;
+	case 4:
+		lane = 2;
+		break;
+	default:
+		return -1;
+	}
+
+	/* configure XG MAC mode */
+	val = readl(port->priv->xpcs_base + MVPP22_XPCS_GLOBAL_CFG_0_REG);
+	val &= ~MVPP22_XPCS_PCSMODE_OFFS;
+	val &= ~MVPP22_XPCS_LANEACTIVE_MASK;
+	val |= (2 * lane) << MVPP22_XPCS_LANEACTIVE_OFFS;
+	writel(val, port->priv->xpcs_base + MVPP22_XPCS_GLOBAL_CFG_0_REG);
+
+	return 0;
+}
+
+static int gop_mpcs_mode(struct mvpp2_port *port)
+{
+	u32 val;
+
+	/* configure PCS40G COMMON CONTROL */
+	val = readl(port->priv->mpcs_base + PCS40G_COMMON_CONTROL);
+	val &= ~FORWARD_ERROR_CORRECTION_MASK;
+	writel(val, port->priv->mpcs_base + PCS40G_COMMON_CONTROL);
+
+	/* configure PCS CLOCK RESET */
+	val = readl(port->priv->mpcs_base + PCS_CLOCK_RESET);
+	val &= ~CLK_DIVISION_RATIO_MASK;
+	val |= 1 << CLK_DIVISION_RATIO_OFFS;
+	writel(val, port->priv->mpcs_base + PCS_CLOCK_RESET);
+
+	val &= ~CLK_DIV_PHASE_SET_MASK;
+	val |= MAC_CLK_RESET_MASK;
+	val |= RX_SD_CLK_RESET_MASK;
+	val |= TX_SD_CLK_RESET_MASK;
+	writel(val, port->priv->mpcs_base + PCS_CLOCK_RESET);
+
+	return 0;
+}
+
+/* Set the internal mux's to the required MAC in the GOP */
+static int gop_xlg_mac_mode_cfg(struct mvpp2_port *port, int num_of_act_lanes)
+{
+	u32 val;
+
+	/* configure 10G MAC mode */
+	val = readl(port->base + MVPP22_XLG_CTRL0_REG);
+	val |= MVPP22_XLG_RX_FC_EN;
+	writel(val, port->base + MVPP22_XLG_CTRL0_REG);
+
+	val = readl(port->base + MVPP22_XLG_CTRL3_REG);
+	val &= ~MVPP22_XLG_CTRL3_MACMODESELECT_MASK;
+	val |= MVPP22_XLG_CTRL3_MACMODESELECT_10GMAC;
+	writel(val, port->base + MVPP22_XLG_CTRL3_REG);
+
+	/* read - modify - write */
+	val = readl(port->base + MVPP22_XLG_CTRL4_REG);
+	val &= ~MVPP22_XLG_MODE_DMA_1G;
+	val |= MVPP22_XLG_FORWARD_PFC_EN;
+	val |= MVPP22_XLG_FORWARD_802_3X_FC_EN;
+	val &= ~MVPP22_XLG_EN_IDLE_CHECK_FOR_LINK;
+	writel(val, port->base + MVPP22_XLG_CTRL4_REG);
+
+	/* Jumbo frame support: 0x1400 * 2 = 0x2800 bytes */
+	val = readl(port->base + MVPP22_XLG_CTRL1_REG);
+	val &= ~MVPP22_XLG_MAX_RX_SIZE_MASK;
+	val |= 0x1400 << MVPP22_XLG_MAX_RX_SIZE_OFFS;
+	writel(val, port->base + MVPP22_XLG_CTRL1_REG);
+
+	/* unmask link change interrupt */
+	val = readl(port->base + MVPP22_XLG_INTERRUPT_MASK_REG);
+	val |= MVPP22_XLG_INTERRUPT_LINK_CHANGE;
+	val |= 1; /* unmask summary bit */
+	writel(val, port->base + MVPP22_XLG_INTERRUPT_MASK_REG);
+
+	return 0;
+}
+
+/* Set PCS to reset or exit from reset */
+static int gop_xpcs_reset(struct mvpp2_port *port, enum mv_reset reset)
+{
+	u32 val;
+
+	/* read - modify - write */
+	val = readl(port->priv->xpcs_base + MVPP22_XPCS_GLOBAL_CFG_0_REG);
+	if (reset == RESET)
+		val &= ~MVPP22_XPCS_PCSRESET;
+	else
+		val |= MVPP22_XPCS_PCSRESET;
+	writel(val, port->priv->xpcs_base + MVPP22_XPCS_GLOBAL_CFG_0_REG);
+
+	return 0;
+}
+
+/* Set the MAC to reset or exit from reset */
+static int gop_xlg_mac_reset(struct mvpp2_port *port, enum mv_reset reset)
+{
+	u32 val;
+
+	/* read - modify - write */
+	val = readl(port->base + MVPP22_XLG_CTRL0_REG);
+	if (reset == RESET)
+		val &= ~MVPP22_XLG_MAC_RESETN;
+	else
+		val |= MVPP22_XLG_MAC_RESETN;
+	writel(val, port->base + MVPP22_XLG_CTRL0_REG);
+
+	return 0;
+}
+
 /*
  * gop_port_init
  *
@@ -3245,6 +3369,7 @@ static int gop_gpcs_reset(struct mvpp2_port *port, enum mv_reset act)
 static int gop_port_init(struct mvpp2_port *port)
 {
 	int mac_num = port->gop_id;
+	int num_of_act_lanes;
 
 	if (mac_num >= MVPP22_GOP_MAC_NUM) {
 		netdev_err(NULL, "%s: illegal port number %d", __func__,
@@ -3285,6 +3410,22 @@ static int gop_port_init(struct mvpp2_port *port)
 		gop_gmac_reset(port, UNRESET);
 		break;
 
+	case PHY_INTERFACE_MODE_SFI:
+		num_of_act_lanes = 2;
+		mac_num = 0;
+		/* configure PCS */
+		gop_xpcs_mode(port, num_of_act_lanes);
+		gop_mpcs_mode(port);
+		/* configure MAC */
+		gop_xlg_mac_mode_cfg(port, num_of_act_lanes);
+
+		/* pcs unreset */
+		gop_xpcs_reset(port, UNRESET);
+
+		/* mac unreset */
+		gop_xlg_mac_reset(port, UNRESET);
+		break;
+
 	default:
 		netdev_err(NULL, "%s: Requested port mode (%d) not supported\n",
 			   __func__, port->phy_interface);
@@ -3294,6 +3435,22 @@ static int gop_port_init(struct mvpp2_port *port)
 	return 0;
 }
 
+static void gop_xlg_mac_port_enable(struct mvpp2_port *port, bool enable)
+{
+	u32 val;
+
+	val = readl(port->base + MVPP22_XLG_CTRL0_REG);
+	if (enable) {
+		/* Enable port and MIB counters update */
+		val |= MVPP22_XLG_PORT_EN;
+		val &= ~MVPP22_XLG_MIBCNT_DIS;
+	} else {
+		/* Disable port */
+		val &= ~MVPP22_XLG_PORT_EN;
+	}
+	writel(val, port->base + MVPP22_XLG_CTRL0_REG);
+}
+
 static void gop_port_enable(struct mvpp2_port *port, bool enable)
 {
 	switch (port->phy_interface) {
@@ -3306,6 +3463,10 @@ static void gop_port_enable(struct mvpp2_port *port, bool enable)
 			mvpp2_port_disable(port);
 		break;
 
+	case PHY_INTERFACE_MODE_SFI:
+		gop_xlg_mac_port_enable(port, enable);
+
+		break;
 	default:
 		netdev_err(NULL, "%s: Wrong port mode (%d)\n", __func__,
 			   port->phy_interface);
-- 
2.12.1

  parent reply	other threads:[~2017-03-23 16:02 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-23 16:01 [U-Boot] [PATCH v2 00/45] Add PPv2.2 support to the mvpp2 ethernet driver and enable it for A7k/8k Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 01/45] bitops.h: Include bitsperlong.h as needed for GENMASK_ULL Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 02/45] net: mvpp2: Round up top tx buffer boundaries for dcache ops Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 03/45] net: mvpp2: simplify mvpp2_bm_bufs_add() Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 04/45] net: mvpp2: remove unused register definitions Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 05/45] net: mvpp2: fix indentation of MVPP2_EXT_GLOBAL_CTRL_DEFAULT Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 06/45] net: mvpp2: simplify MVPP2_PRS_RI_* definitions Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 07/45] net: mvpp2: enable building on 64-bit platforms Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 08/45] net: mvpp2: enable building on 64-bit platforms (more U-Boot specific) Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 09/45] net: mvpp2: use "dma" instead of "phys" where appropriate Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 10/45] net: mvpp2: remove support for buffer header Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 11/45] net: mvpp2: store physical address of buffer in rx_desc->buf_cookie Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 12/45] net: mvpp2: add and use accessors for TX/RX descriptors Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 13/45] net: mvpp2: add hw_version field in "struct mvpp2" Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 14/45] net: mvpp2: introduce an intermediate union for the TX/RX descriptors Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 15/45] net: mvpp2: introduce PPv2.2 HW descriptors and adapt accessors Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 16/45] net: mvpp2: adjust the allocation/free of BM pools for PPv2.2 Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 17/45] net: mvpp2: adapt the mvpp2_rxq_*_pool_set functions to PPv2.2 Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 18/45] net: mvpp2: adapt mvpp2_defaults_set() " Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 19/45] net: mvpp2: adjust mvpp2_{rxq, txq}_init for PPv2.2 Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 20/45] net: mvpp2: handle register mapping and access " Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 21/45] net: mvpp2: handle misc PPv2.1/PPv2.2 differences Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 22/45] net: mvpp2: add AXI bridge initialization for PPv2.2 Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 23/45] net: mvpp2: rework RXQ interrupt group " Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 24/45] net: mvpp2: adapt rxq distribution to PPv2.2 Stefan Roese
2017-03-25 21:24   ` Joe Hershberger
2017-03-23 16:01 ` [U-Boot] [PATCH v2 25/45] net: mvpp2: finally add the PPv2.2 compatible string Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 26/45] net: mvpp2: Add MDIO support for PPv2.2 Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 27/45] net: mvpp2: Move probe function from MISC to ETH DM driver Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 28/45] net: mvpp2.c: Clear all buffer / descriptor areas before usage Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 29/45] net: mvpp2: Enable compilation for Armada 7K/8K platforms Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 30/45] arm64: marvell: dts: add PPv2.2 description to Armada 7K/8K Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 31/45] arm64: mvebu: armada-7k/8k: Enable MVPP2 ethernet driver Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 32/45] net: mvpp2: Handle eth device naming in multi-CP case correctly Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 33/45] net: mvpp2: Add remove function that is called before the OS is started Stefan Roese
2017-03-23 16:02 ` [U-Boot] [PATCH v2 34/45] net: mvpp2: Add RX and TX FIFO configuration for PPv2.2 Stefan Roese
2017-03-25 20:32   ` Joe Hershberger
2017-03-23 16:02 ` [U-Boot] [PATCH v2 35/45] net: include/phy.h: Add new PHY interface modes Stefan Roese
2017-03-23 16:02 ` [U-Boot] [PATCH v2 36/45] net: mvpp2: Restructure probe / init functions Stefan Roese
2017-03-25 21:30   ` Joe Hershberger
2017-03-23 16:02 ` [U-Boot] [PATCH v2 37/45] net: mvpp2: Read phy-speed from DT to select between 1GB and 2.5GB SGMII Stefan Roese
2017-03-25 21:31   ` Joe Hershberger
2017-03-23 16:02 ` [U-Boot] [PATCH v2 38/45] net: mvpp2: Add GoP and NetC support for ports 2 & 3 (RGMII & SGMII) Stefan Roese
2017-03-25 20:05   ` Joe Hershberger
2017-03-27 11:17     ` Stefan Roese
2017-03-23 16:02 ` Stefan Roese [this message]
2017-03-25 20:16   ` [U-Boot] [PATCH v2 39/45] net: mvpp2: Add GoP and NetC support for port 0 (SFI) Joe Hershberger
2017-03-23 16:02 ` [U-Boot] [PATCH v2 40/45] net: mvpp2: Add missing PHY_INTERFACE_MODE_RGMII_ID Stefan Roese
2017-03-25 21:34   ` Joe Hershberger
2017-03-23 16:02 ` [U-Boot] [PATCH v2 41/45] net: mvpp2: Enable PHY polling mode on PPv2.2 Stefan Roese
2017-03-23 16:02 ` [U-Boot] [PATCH v2 42/45] net: mvpp2: Configure SMI PHY address needed for PHY polling Stefan Roese
2017-03-23 16:02 ` [U-Boot] [PATCH v2 43/45] net: mvpp2: Remove unreferenced in_use_thresh from struct mvpp2_bm_pool Stefan Roese
2017-03-23 16:02 ` [U-Boot] [PATCH v2 44/45] arm64: mvebu: armada-7040-db.dts: Change eth1 speed from 2.5G to 1G Stefan Roese
2017-03-23 16:02 ` [U-Boot] [PATCH v2 45/45] arm64: mvebu: Enable CONFIG_PHY_MARVELL in Armada7k/8k-DB defconfig Stefan Roese
2017-03-25 21:42 ` [U-Boot] [PATCH v2 00/45] Add PPv2.2 support to the mvpp2 ethernet driver and enable it for A7k/8k Joe Hershberger
2017-03-27 12:02   ` Stefan Roese
2017-03-29  9:24 ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170323160211.18072-40-sr@denx.de \
    --to=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.