Skip to contentSkip to conversation

mscc: ocelot: add support for SerDes muxing configuration

PATCH Superseded Quentin Schulz 5 participants 21 messages Sep 3, 2018 – Sep 5, 2018

Subsystems (7)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover mscc: ocelot: add support for SerDes muxing configuration

The Ocelot switch has currently an hardcoded SerDes muxing that suits only a particular use case. Any other board setup will fail to work.

To prepare for upcoming boards' support that do not have the same muxing, create a PHY driver that will handle all possible cases.

A SerDes can work in SGMII, QSGMII or PCIe and is also muxed to use a given port depending on the selected mode or board design.

The SerDes configuration is in the middle of an address space (HSIO) that is used to configure some parts in the MAC controller driver, that is why we need to use a syscon so that we can write to the same address space from different drivers safely using regmap.

Patches from generic PHY and net should be safe to be merged separately.

This breaks backward compatibility but it's fine because there's only one board at the moment that is using what's modified in this patch series. This will break git bisect.

Even though this patch series is about SerDes __muxing__ configuration, the DT node is named serdes for the simple reason that I couldn't find any mention to SerDes anywhere else from the address space handled by this driver.

I suggest patches 1 and 8 go through MIPS tree, 2 to 5 and 11 go through net while the others (6, 7, 9 and 10) go through the generic PHY subsystem.

Thanks,
Quentin

v2:

- use a switch case for setting the phy_mode in the SerDes driver as suggested by Andrew,
- stop replacing the value of the error pointer in the SerDes driver,
- use a dev_dbg for the deferring of the probe in the SerDes driver,
- use constants in the Device Tree to select the SerDes macro in use with a port,
- adapt the SerDes driver to use those constants,
- add a header file in include/dt-bindings for the constants,
- fix space/tab issue,

Quentin Schulz (11):
MIPS: mscc: ocelot: make HSIO registers address range a syscon
dt-bindings: net: ocelot: remove hsio from the list of register
address spaces
net: mscc: ocelot: get HSIO regmap from syscon
net: mscc: ocelot: move the HSIO header to include/soc
net: mscc: ocelot: simplify register access for PLL5 configuration
phy: add QSGMII and PCIE modes
dt-bindings: phy: add DT binding for Microsemi Ocelot SerDes muxing
MIPS: mscc: ocelot: add SerDes mux DT node
dt-bindings: add constants for Microsemi Ocelot SerDes driver
phy: add driver for Microsemi Ocelot SerDes muxing
net: mscc: ocelot: make use of SerDes PHYs for handling their
configuration

 .../devicetree/bindings/mips/mscc.txt         |  16 +
 .../devicetree/bindings/net/mscc-ocelot.txt   |   9 +-
 .../bindings/phy/phy-ocelot-serdes.txt        |  40 +++
 arch/mips/boot/dts/mscc/ocelot.dtsi           |  19 +-
 drivers/net/ethernet/mscc/Kconfig             |   2 +
 drivers/net/ethernet/mscc/ocelot.c            |  16 +-
 drivers/net/ethernet/mscc/ocelot.h            |  79 +----
 drivers/net/ethernet/mscc/ocelot_board.c      |  61 +++-
 drivers/net/ethernet/mscc/ocelot_regs.c       |  93 +-----
 drivers/phy/Kconfig                           |   1 +
 drivers/phy/Makefile                          |   1 +
 drivers/phy/mscc/Kconfig                      |  11 +
 drivers/phy/mscc/Makefile                     |   5 +
 drivers/phy/mscc/phy-ocelot-serdes.c          | 288 ++++++++++++++++++
 include/dt-bindings/phy/phy-ocelot-serdes.h   |  19 ++
 include/linux/phy/phy.h                       |   2 +
 .../soc}/mscc/ocelot_hsio.h                   |  74 +++++
 17 files changed, 556 insertions(+), 180 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-ocelot-serdes.txt
 create mode 100644 drivers/phy/mscc/Kconfig
 create mode 100644 drivers/phy/mscc/Makefile
 create mode 100644 drivers/phy/mscc/phy-ocelot-serdes.c
 create mode 100644 include/dt-bindings/phy/phy-ocelot-serdes.h
 rename {drivers/net/ethernet => include/soc}/mscc/ocelot_hsio.h (95%)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/11 MIPS: mscc: ocelot: make HSIO registers address range a syscon

HSIO contains registers for PLL5 configuration, SerDes/switch port muxing and a thermal sensor, hence we can't keep it in the switch DT node.

---
 arch/mips/boot/dts/mscc/ocelot.dtsi | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
arch/mips/boot/dts/mscc/ocelot.dtsi +9 -5
index f7eb612b46ba..149b1a7e7091 100644
@@ -107,7 +107,6 @@
 			reg = <0x1010000 0x10000>,
 			      <0x1030000 0x10000>,
 			      <0x1080000 0x100>,
-			      <0x10d0000 0x10000>,
 			      <0x11e0000 0x100>,
 			      <0x11f0000 0x100>,
 			      <0x1200000 0x100>,
@@ -121,10 +120,10 @@
 			      <0x1280000 0x100>,
 			      <0x1800000 0x80000>,
 			      <0x1880000 0x10000>;
-			reg-names = "sys", "rew", "qs", "hsio", "port0",
-				    "port1", "port2", "port3", "port4", "port5",
-				    "port6", "port7", "port8", "port9", "port10",
-				    "qsys", "ana";
+			reg-names = "sys", "rew", "qs", "port0", "port1",
+				    "port2", "port3", "port4", "port5", "port6",
+				    "port7", "port8", "port9", "port10", "qsys",
+				    "ana";
 			interrupts = <21 22>;
 			interrupt-names = "xtr", "inj";
 
@@ -231,5 +230,10 @@
 			pinctrl-0 = <&miim1>;
 			status = "disabled";
 		};
+
+		hsio: syscon@10d0000 {
+			compatible = "mscc,ocelot-hsio", "syscon", "simple-mfd";
+			reg = <0x10d0000 0x10000>;
+		};
 	};
 };
Signature · 1 line
2.17.1
#2 lore raw

PATCH v2 2/11 dt-bindings: net: ocelot: remove hsio from the list of register address spaces

In reply to Quentin Schulz

HSIO register address space should be handled outside of the MAC controller as there are some registers for PLL5 configuring, SerDes/switch port muxing and a thermal sensor IP, so let's remove it.

---
 Documentation/devicetree/bindings/mips/mscc.txt  | 16 ++++++++++++++++
 .../devicetree/bindings/net/mscc-ocelot.txt      |  9 +++------
 2 files changed, 19 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/mips/mscc.txt +16 -0
index ae15ec333542..bc817e984628 100644
@@ -41,3 +41,19 @@ Example:
 		compatible = "mscc,ocelot-cpu-syscon", "syscon";
 		reg = <0x70000000 0x2c>;
 	};
+
+o HSIO regs:
+
+The SoC has a few registers (HSIO) handling miscellaneous functionalities:
+configuration and status of PLL5, RCOMP, SyncE, SerDes configurations and
+status, SerDes muxing and a thermal sensor.
+
+Required properties:
+- compatible: Should be "mscc,ocelot-hsio", "syscon", "simple-mfd"
+- reg : Should contain registers location and length
+
+Example:
+	syscon@10d0000 {
+		compatible = "mscc,ocelot-hsio", "syscon", "simple-mfd";
+		reg = <0x10d0000 0x10000>;
+	};
Documentation/devicetree/bindings/net/mscc-ocelot.txt +3 -6
index 0a84711abece..9e5c17d426ce 100644
@@ -12,7 +12,6 @@ Required properties:
   - "sys"
   - "rew"
   - "qs"
-  - "hsio"
   - "qsys"
   - "ana"
   - "portX" with X from 0 to the number of last port index available on that
@@ -45,7 +44,6 @@ Example:
 		reg = <0x1010000 0x10000>,
 		      <0x1030000 0x10000>,
 		      <0x1080000 0x100>,
-		      <0x10d0000 0x10000>,
 		      <0x11e0000 0x100>,
 		      <0x11f0000 0x100>,
 		      <0x1200000 0x100>,
@@ -59,10 +57,9 @@ Example:
 		      <0x1280000 0x100>,
 		      <0x1800000 0x80000>,
 		      <0x1880000 0x10000>;
-		reg-names = "sys", "rew", "qs", "hsio", "port0",
-			    "port1", "port2", "port3", "port4", "port5",
-			    "port6", "port7", "port8", "port9", "port10",
-			    "qsys", "ana";
+		reg-names = "sys", "rew", "qs", "port0", "port1", "port2",
+			    "port3", "port4", "port5", "port6", "port7",
+			    "port8", "port9", "port10", "qsys", "ana";
 		interrupts = <21 22>;
 		interrupt-names = "xtr", "inj";
 
Signature · 1 line
2.17.1
#3 lore raw

PATCH v2 3/11 net: mscc: ocelot: get HSIO regmap from syscon

In reply to Quentin Schulz

HSIO address space was moved to a syscon, hence we need to get the regmap of this address space from there and no more from the device node.

---
 drivers/net/ethernet/mscc/ocelot_board.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/ethernet/mscc/ocelot_board.c +10 -1
index 26bb3b18f3be..b7d755b90117 100644
@@ -9,6 +9,7 @@
 #include <linux/netdevice.h>
 #include <linux/of_mdio.h>
 #include <linux/of_platform.h>
+#include <linux/mfd/syscon.h>
 #include <linux/skbuff.h>
 
 #include "ocelot.h"
@@ -162,6 +163,7 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
 	struct device_node *np = pdev->dev.of_node;
 	struct device_node *ports, *portnp;
 	struct ocelot *ocelot;
+	struct regmap *hsio;
 	u32 val;
 
 	struct {
@@ -173,7 +175,6 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
 		{ QSYS, "qsys" },
 		{ ANA, "ana" },
 		{ QS, "qs" },
-		{ HSIO, "hsio" },
 	};
 
 	if (!np && !pdev->dev.platform_data)
@@ -196,6 +197,14 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
 		ocelot->targets[res[i].id] = target;
 	}
 
+	hsio = syscon_regmap_lookup_by_compatible("mscc,ocelot-hsio");
+	if (IS_ERR(hsio)) {
+		dev_err(&pdev->dev, "missing hsio syscon\n");
+		return PTR_ERR(hsio);
+	}
+
+	ocelot->targets[HSIO] = hsio;
+
 	err = ocelot_chip_init(ocelot);
 	if (err)
 		return err;
Signature · 1 line
2.17.1
#4 lore raw

PATCH v2 4/11 net: mscc: ocelot: move the HSIO header to include/soc

In reply to Quentin Schulz

Since HSIO address space can be used by different drivers (PLL, SerDes muxing, temperature sensor), let's move it somewhere it can be included by all drivers.

---
 drivers/net/ethernet/mscc/ocelot.h                       | 1 -
 drivers/net/ethernet/mscc/ocelot_regs.c                  | 1 +
 {drivers/net/ethernet => include/soc}/mscc/ocelot_hsio.h | 0
 3 files changed, 1 insertion(+), 1 deletion(-)
 rename {drivers/net/ethernet => include/soc}/mscc/ocelot_hsio.h (100%)
drivers/net/ethernet/mscc/ocelot.h +0 -1
index 616bec30dfa3..2da20a352120 100644
@@ -16,7 +16,6 @@
 
 #include "ocelot_ana.h"
 #include "ocelot_dev.h"
-#include "ocelot_hsio.h"
 #include "ocelot_qsys.h"
 #include "ocelot_rew.h"
 #include "ocelot_sys.h"
drivers/net/ethernet/mscc/ocelot_regs.c +1 -0
index e334b406c40c..bf0c609caea5 100644
@@ -5,6 +5,7 @@
  * Copyright (c) 2017 Microsemi Corporation
  */
 #include "ocelot.h"
+#include <soc/mscc/ocelot_hsio.h>
 
 static const u32 ocelot_ana_regmap[] = {
 	REG(ANA_ADVLEARN,                  0x009000),
include/soc/mscc/ocelot_hsio.h renamed from drivers/net/ethernet/mscc/ocelot_hsio.h +0 -0
similarity index 100%
rename from drivers/net/ethernet/mscc/ocelot_hsio.h
rename to include/soc/mscc/ocelot_hsio.h
Signature · 1 line
2.17.1
#5 lore raw

PATCH v2 5/11 net: mscc: ocelot: simplify register access for PLL5 configuration

In reply to Quentin Schulz

Since HSIO address space can be accessed by different drivers, let's simplify the register address definitions so that it can be easily used by all drivers and put the register address definition in the include/soc/mscc/ocelot_hsio.h header file.

---
 drivers/net/ethernet/mscc/ocelot.h      | 73 --------------------
 drivers/net/ethernet/mscc/ocelot_regs.c | 92 +++----------------------
 include/soc/mscc/ocelot_hsio.h          | 74 ++++++++++++++++++++
 3 files changed, 83 insertions(+), 156 deletions(-)
drivers/net/ethernet/mscc/ocelot.h +0 -73
index 2da20a352120..3720e519cdd7 100644
@@ -332,79 +332,6 @@ enum ocelot_reg {
 	SYS_CM_DATA_RD,
 	SYS_CM_OP,
 	SYS_CM_DATA,
-	HSIO_PLL5G_CFG0 = HSIO << TARGET_OFFSET,
-	HSIO_PLL5G_CFG1,
-	HSIO_PLL5G_CFG2,
-	HSIO_PLL5G_CFG3,
-	HSIO_PLL5G_CFG4,
-	HSIO_PLL5G_CFG5,
-	HSIO_PLL5G_CFG6,
-	HSIO_PLL5G_STATUS0,
-	HSIO_PLL5G_STATUS1,
-	HSIO_PLL5G_BIST_CFG0,
-	HSIO_PLL5G_BIST_CFG1,
-	HSIO_PLL5G_BIST_CFG2,
-	HSIO_PLL5G_BIST_STAT0,
-	HSIO_PLL5G_BIST_STAT1,
-	HSIO_RCOMP_CFG0,
-	HSIO_RCOMP_STATUS,
-	HSIO_SYNC_ETH_CFG,
-	HSIO_SYNC_ETH_PLL_CFG,
-	HSIO_S1G_DES_CFG,
-	HSIO_S1G_IB_CFG,
-	HSIO_S1G_OB_CFG,
-	HSIO_S1G_SER_CFG,
-	HSIO_S1G_COMMON_CFG,
-	HSIO_S1G_PLL_CFG,
-	HSIO_S1G_PLL_STATUS,
-	HSIO_S1G_DFT_CFG0,
-	HSIO_S1G_DFT_CFG1,
-	HSIO_S1G_DFT_CFG2,
-	HSIO_S1G_TP_CFG,
-	HSIO_S1G_RC_PLL_BIST_CFG,
-	HSIO_S1G_MISC_CFG,
-	HSIO_S1G_DFT_STATUS,
-	HSIO_S1G_MISC_STATUS,
-	HSIO_MCB_S1G_ADDR_CFG,
-	HSIO_S6G_DIG_CFG,
-	HSIO_S6G_DFT_CFG0,
-	HSIO_S6G_DFT_CFG1,
-	HSIO_S6G_DFT_CFG2,
-	HSIO_S6G_TP_CFG0,
-	HSIO_S6G_TP_CFG1,
-	HSIO_S6G_RC_PLL_BIST_CFG,
-	HSIO_S6G_MISC_CFG,
-	HSIO_S6G_OB_ANEG_CFG,
-	HSIO_S6G_DFT_STATUS,
-	HSIO_S6G_ERR_CNT,
-	HSIO_S6G_MISC_STATUS,
-	HSIO_S6G_DES_CFG,
-	HSIO_S6G_IB_CFG,
-	HSIO_S6G_IB_CFG1,
-	HSIO_S6G_IB_CFG2,
-	HSIO_S6G_IB_CFG3,
-	HSIO_S6G_IB_CFG4,
-	HSIO_S6G_IB_CFG5,
-	HSIO_S6G_OB_CFG,
-	HSIO_S6G_OB_CFG1,
-	HSIO_S6G_SER_CFG,
-	HSIO_S6G_COMMON_CFG,
-	HSIO_S6G_PLL_CFG,
-	HSIO_S6G_ACJTAG_CFG,
-	HSIO_S6G_GP_CFG,
-	HSIO_S6G_IB_STATUS0,
-	HSIO_S6G_IB_STATUS1,
-	HSIO_S6G_ACJTAG_STATUS,
-	HSIO_S6G_PLL_STATUS,
-	HSIO_S6G_REVID,
-	HSIO_MCB_S6G_ADDR_CFG,
-	HSIO_HW_CFG,
-	HSIO_HW_QSGMII_CFG,
-	HSIO_HW_QSGMII_STAT,
-	HSIO_CLK_CFG,
-	HSIO_TEMP_SENSOR_CTRL,
-	HSIO_TEMP_SENSOR_CFG,
-	HSIO_TEMP_SENSOR_STAT,
 };
 
 enum ocelot_regfield {
drivers/net/ethernet/mscc/ocelot_regs.c +9 -83

120 lines not on this page · raw message

include/soc/mscc/ocelot_hsio.h +74 -0

80 lines not on this page · raw message

Signature · 1 line
2.17.1
#6 lore raw

PATCH v2 6/11 phy: add QSGMII and PCIE modes

In reply to Quentin Schulz

Prepare for upcoming phys that'll handle QSGMII or PCIe.

---
 include/linux/phy/phy.h | 2 ++
 1 file changed, 2 insertions(+)
include/linux/phy/phy.h +2 -0
index 9713aebdd348..03b319f89a34 100644
@@ -37,9 +37,11 @@ enum phy_mode {
 	PHY_MODE_USB_OTG,
 	PHY_MODE_SGMII,
 	PHY_MODE_2500SGMII,
+	PHY_MODE_QSGMII,
 	PHY_MODE_10GKR,
 	PHY_MODE_UFS_HS_A,
 	PHY_MODE_UFS_HS_B,
+	PHY_MODE_PCIE,
 };
 
 /**
Signature · 1 line
2.17.1
#7 lore raw

PATCH v2 7/11 dt-bindings: phy: add DT binding for Microsemi Ocelot SerDes muxing

In reply to Quentin Schulz
---
 .../bindings/phy/phy-ocelot-serdes.txt        | 40 +++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-ocelot-serdes.txt
Documentation/devicetree/bindings/phy/phy-ocelot-serdes.txt new file +40 -0
new file mode 100644
index 000000000000..2a88cc346162
@@ -0,0 +1,40 @@
+Microsemi Ocelot SerDes muxing driver
+-------------------------------------
+
+On Microsemi Ocelot, there is a handful of registers in HSIO address
+space for setting up the SerDes to switch port muxing.
+
+A SerDes X can be "muxed" to work with switch port Y or Z for example.
+One specific SerDes can also be used as a PCIe interface.
+
+Hence, a SerDes represents an interface, be it an Ethernet or a PCIe one.
+
+There are two kinds of SerDes: SERDES1G supports 10/100Mbps in
+half/full-duplex and 1000Mbps in full-duplex mode while SERDES6G supports
+10/100Mbps in half/full-duplex and 1000/2500Mbps in full-duplex mode.
+
+Also, SERDES6G number (aka "macro") 0 is the only interface supporting
+QSGMII.
+
+Required properties:
+
+- compatible: should be "mscc,vsc7514-serdes"
+- #phy-cells : from the generic phy bindings, must be 2.
+	       The first number defines the input port to use for a given
+	       SerDes macro. The second defines the macro to use. They are
+	       defined in dt-bindings/phy/phy-ocelot-serdes.h
+
+Example:
+
+	serdes: serdes {
+		compatible = "mscc,vsc7514-serdes";
+		#phy-cells = <2>;
+	};
+
+	ethernet {
+		port1 {
+			phy-handle = <&phy_foo>;
+			/* Link SERDES1G_5 to port1 */
+			phys = <&serdes 1 SERDES1G_5>;
+		};
+	};
Signature · 1 line
2.17.1
#8 lore raw

PATCH v2 8/11 MIPS: mscc: ocelot: add SerDes mux DT node

In reply to Quentin Schulz

The Microsemi Ocelot has a set of register for SerDes/switch port muxing as well as PCIe muxing for a specific SerDes, so let's add the device and all SerDes in the Device Tree.

---
 arch/mips/boot/dts/mscc/ocelot.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/mips/boot/dts/mscc/ocelot.dtsi +5 -0
index 149b1a7e7091..8ce317c5b9ed 100644
@@ -234,6 +234,11 @@
 		hsio: syscon@10d0000 {
 			compatible = "mscc,ocelot-hsio", "syscon", "simple-mfd";
 			reg = <0x10d0000 0x10000>;
+
+			serdes: serdes {
+				compatible = "mscc,vsc7514-serdes";
+				#phy-cells = <2>;
+			};
 		};
 	};
 };
Signature · 1 line
2.17.1
#9 lore raw

PATCH v2 9/11 dt-bindings: add constants for Microsemi Ocelot SerDes driver

In reply to Quentin Schulz

The Microsemi Ocelot has multiple SerDes and requires that the SerDes be muxed accordingly to the hardware representation.

Let's add a constant for each SerDes available in the Microsemi Ocelot.

---
 include/dt-bindings/phy/phy-ocelot-serdes.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 include/dt-bindings/phy/phy-ocelot-serdes.h
include/dt-bindings/phy/phy-ocelot-serdes.h new file +19 -0
new file mode 100644
index 000000000000..cf111baa87c8
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
+/* Copyright (c) 2018 Microsemi Corporation */
+#ifndef __PHY_OCELOT_SERDES_H__
+#define __PHY_OCELOT_SERDES_H__
+
+#define SERDES1G_0	0
+#define SERDES1G_1	1
+#define SERDES1G_2	2
+#define SERDES1G_3	3
+#define SERDES1G_4	4
+#define SERDES1G_5	5
+#define SERDES1G_MAX	6
+#define SERDES6G_0	SERDES1G_MAX
+#define SERDES6G_1	(SERDES1G_MAX + 1)
+#define SERDES6G_2	(SERDES1G_MAX + 2)
+#define SERDES6G_MAX	(SERDES1G_MAX + 3)
+#define SERDES_MAX	(SERDES1G_MAX + SERDES6G_MAX)
+
+#endif
Signature · 1 line
2.17.1
#10 lore raw

PATCH v2 10/11 phy: add driver for Microsemi Ocelot SerDes muxing

In reply to Quentin Schulz

The Microsemi Ocelot can mux SerDes lanes (aka macros) to different switch ports or even make it act as a PCIe interface.

This adds support for the muxing of the SerDes.

---
 drivers/phy/Kconfig                  |   1 +
 drivers/phy/Makefile                 |   1 +
 drivers/phy/mscc/Kconfig             |  11 +
 drivers/phy/mscc/Makefile            |   5 +
 drivers/phy/mscc/phy-ocelot-serdes.c | 288 +++++++++++++++++++++++++++
 5 files changed, 306 insertions(+)
 create mode 100644 drivers/phy/mscc/Kconfig
 create mode 100644 drivers/phy/mscc/Makefile
 create mode 100644 drivers/phy/mscc/phy-ocelot-serdes.c
drivers/phy/Kconfig +1 -0
index 5c8d452e35e2..c89d3effd99d 100644
@@ -48,6 +48,7 @@ source "drivers/phy/lantiq/Kconfig"
 source "drivers/phy/marvell/Kconfig"
 source "drivers/phy/mediatek/Kconfig"
 source "drivers/phy/motorola/Kconfig"
+source "drivers/phy/mscc/Kconfig"
 source "drivers/phy/qualcomm/Kconfig"
 source "drivers/phy/ralink/Kconfig"
 source "drivers/phy/renesas/Kconfig"
drivers/phy/Makefile +1 -0
index 84e3bd9c5665..ce8339ff0022 100644
@@ -18,6 +18,7 @@ obj-y					+= broadcom/	\
 					   hisilicon/	\
 					   marvell/	\
 					   motorola/	\
+					   mscc/	\
 					   qualcomm/	\
 					   ralink/	\
 					   samsung/	\
drivers/phy/mscc/Kconfig new file +11 -0
new file mode 100644
index 000000000000..2e2a466efd66
@@ -0,0 +1,11 @@
+#
+# Phy drivers for Microsemi devices
+#
+
+config PHY_OCELOT_SERDES
+	tristate "SerDes PHY driver for Microsemi Ocelot"
+	select GENERIC_PHY
+	depends on OF
+	depends on MFD_SYSCON
+	help
+	  Enable this for supporting SerDes muxing with Microsemi Ocelot.
drivers/phy/mscc/Makefile new file +5 -0
new file mode 100644
index 000000000000..e14749170fc9
@@ -0,0 +1,5 @@
+#
+# Makefile for the Microsemi phy drivers.
+#
+
+obj-$(CONFIG_PHY_OCELOT_SERDES) := phy-ocelot-serdes.o
drivers/phy/mscc/phy-ocelot-serdes.c new file +288 -0

288 lines not on this page · raw message

Signature · 1 line
2.17.1
#11 lore raw

PATCH v2 11/11 net: mscc: ocelot: make use of SerDes PHYs for handling their configuration

In reply to Quentin Schulz

Previously, the SerDes muxing was hardcoded to a given mode in the MAC controller driver. Now, the SerDes muxing is configured within the Device Tree and is enforced in the MAC controller driver so we can have a lot of different SerDes configurations.

Make use of the SerDes PHYs in the MAC controller to set up the SerDes according to the SerDes<->switch port mapping and the communication mode with the Ethernet PHY.

---
 drivers/net/ethernet/mscc/Kconfig        |  2 +
 drivers/net/ethernet/mscc/ocelot.c       | 16 +++++++-
 drivers/net/ethernet/mscc/ocelot.h       |  5 +++
 drivers/net/ethernet/mscc/ocelot_board.c | 50 +++++++++++++++++++-----
 4 files changed, 62 insertions(+), 11 deletions(-)
drivers/net/ethernet/mscc/Kconfig +2 -0
index 36c84625d54e..bcec0587cf61 100644
@@ -23,6 +23,8 @@ config MSCC_OCELOT_SWITCH
 config MSCC_OCELOT_SWITCH_OCELOT
 	tristate "Ocelot switch driver on Ocelot"
 	depends on MSCC_OCELOT_SWITCH
+	depends on GENERIC_PHY
+	depends on OF_NET
 	help
 	  This driver supports the Ocelot network switch device as present on
 	  the Ocelot SoCs.
drivers/net/ethernet/mscc/ocelot.c +15 -1
index 1a4f2bb48ead..8f11fdba8d0e 100644
@@ -472,6 +472,7 @@ static int ocelot_port_open(struct net_device *dev)
 {
 	struct ocelot_port *port = netdev_priv(dev);
 	struct ocelot *ocelot = port->ocelot;
+	enum phy_mode phy_mode;
 	int err;
 
 	/* Enable receiving frames on the port, and activate auto-learning of
@@ -482,8 +483,21 @@ static int ocelot_port_open(struct net_device *dev)
 			 ANA_PORT_PORT_CFG_PORTID_VAL(port->chip_port),
 			 ANA_PORT_PORT_CFG, port->chip_port);
 
+	if (port->serdes) {
+		if (port->phy_mode == PHY_INTERFACE_MODE_SGMII)
+			phy_mode = PHY_MODE_SGMII;
+		else
+			phy_mode = PHY_MODE_QSGMII;
+
+		err = phy_set_mode(port->serdes, phy_mode);
+		if (err) {
+			netdev_err(dev, "Could not set mode of SerDes\n");
+			return err;
+		}
+	}
+
 	err = phy_connect_direct(dev, port->phy, &ocelot_port_adjust_link,
-				 PHY_INTERFACE_MODE_NA);
+				 port->phy_mode);
 	if (err) {
 		netdev_err(dev, "Could not attach to PHY\n");
 		return err;
drivers/net/ethernet/mscc/ocelot.h +5 -0
index 3720e519cdd7..62c7c8eb00d9 100644
@@ -11,6 +11,8 @@
 #include <linux/bitops.h>
 #include <linux/etherdevice.h>
 #include <linux/if_vlan.h>
+#include <linux/phy.h>
+#include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 
@@ -453,6 +455,9 @@ struct ocelot_port {
 	u8 vlan_aware;
 
 	u64 *stats;
+
+	phy_interface_t phy_mode;
+	struct phy *serdes;
 };
 
 u32 __ocelot_read_ix(struct ocelot *ocelot, u32 reg, u32 offset);
drivers/net/ethernet/mscc/ocelot_board.c +40 -10

74 lines not on this page · raw message

Signature · 1 line
2.17.1
#12 lore raw
In reply to Quentin Schulz
Quoted 2 lines

I suggest patches 1 and 8 go through MIPS tree, 2 to 5 and 11 go through net while the others (6, 7, 9 and 10) go through the generic PHY subsystem.

Hi Quentin

Are you expecting merge conflicts? If not, it might be simpler to gets ACKs from each maintainer, and then merge it though one tree.

Andrew

#13 lore raw
Quoted 8 lines · Andrew Lunn
Quoted 2 lines

I suggest patches 1 and 8 go through MIPS tree, 2 to 5 and 11 go through net while the others (6, 7, 9 and 10) go through the generic PHY subsystem.

Hi Quentin

Are you expecting merge conflicts? If not, it might be simpler to gets ACKs from each maintainer, and then merge it though one tree.

There are some other DT changes for this cycle so those should probably go through MIPS.

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
maintainer Acked-by
#14 lore raw

From: Alexandre Belloni <[email protected]>
Date: Mon, 3 Sep 2018 15:45:22 +0200

Quoted 12 lines · Andrew Lunn
Quoted 8 lines
Quoted 2 lines

I suggest patches 1 and 8 go through MIPS tree, 2 to 5 and 11 go through net while the others (6, 7, 9 and 10) go through the generic PHY subsystem.

Hi Quentin

Are you expecting merge conflicts? If not, it might be simpler to gets ACKs from each maintainer, and then merge it though one tree.

There are some other DT changes for this cycle so those should probably go through MIPS.

No objection for this going through the MIPS tree, and from me:

#15 lore raw
Quoted 9 lines · David Miller

From: Alexandre Belloni <[email protected]>
Date: Mon, 3 Sep 2018 15:45:22 +0200

Quoted 6 lines · Andrew Lunn
Quoted 5 lines
Quoted 2 lines

I suggest patches 1 and 8 go through MIPS tree, 2 to 5 and 11 go through net while the others (6, 7, 9 and 10) go through the generic PHY subsystem.

Hi Quentin

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

Are you expecting merge conflicts? If not, it might be simpler to gets ACKs from each maintainer, and then merge it though one tree.

There are some other DT changes for this cycle so those should probably go through MIPS.

No objection for this going through the MIPS tree, and from me:

What I meant was that 1/11 and 8/11 should go through MIPS because of the potential conflicts. The other patches can go through net-next as that will make more sense. Maybe Quentin can split the series in two, one for MIPS and one for net if that makes it easier for you to apply.

Quoted 1 line
Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#16 lore raw

Hi Alexandre, Quentin, all,

Quoted 16 lines · Alexandre Belloni
Quoted 15 lines · David Miller

From: Alexandre Belloni <[email protected]>
Date: Mon, 3 Sep 2018 15:45:22 +0200

Quoted 11 lines · Andrew Lunn
Quoted 7 lines
Quoted 2 lines

I suggest patches 1 and 8 go through MIPS tree, 2 to 5 and 11 go through net while the others (6, 7, 9 and 10) go through the generic PHY subsystem.

Hi Quentin

Are you expecting merge conflicts? If not, it might be simpler to gets ACKs from each maintainer, and then merge it though one tree.

There are some other DT changes for this cycle so those should probably go through MIPS.

Quoted 8 lines
Quoted 3 lines

No objection for this going through the MIPS tree, and from me:

What I meant was that 1/11 and 8/11 should go through MIPS because of the potential conflicts. The other patches can go through net-next as that will make more sense. Maybe Quentin can split the series in two, one for MIPS and one for net if that makes it easier for you to apply.

I'd be happy to take the .dts changes through the MIPS tree, though looking at them won't patch 1 break bisection?

Since you remove the hsio reg entry it looks to me like mscc_ocelot_probe() will fail with -EINVAL (which comes from devm_ioremap_resource() with res=NULL) until patch 3.

I'd feel more comfortable merging this piecemeal if it doesn't result in us breaking bisection for however long it takes for both the trees involved to be merged.

Thanks,
Paul

#17 lore raw

Hi Paul,

Quoted 28 lines · Paul Burton

Hi Alexandre, Quentin, all,

Quoted 16 lines · Alexandre Belloni
Quoted 15 lines · David Miller

From: Alexandre Belloni <[email protected]>
Date: Mon, 3 Sep 2018 15:45:22 +0200

Quoted 11 lines · Andrew Lunn
Quoted 7 lines
Quoted 2 lines

I suggest patches 1 and 8 go through MIPS tree, 2 to 5 and 11 go through net while the others (6, 7, 9 and 10) go through the generic PHY subsystem.

Hi Quentin

Are you expecting merge conflicts? If not, it might be simpler to gets ACKs from each maintainer, and then merge it though one tree.

There are some other DT changes for this cycle so those should probably go through MIPS.

Quoted 8 lines
Quoted 3 lines

No objection for this going through the MIPS tree, and from me:

What I meant was that 1/11 and 8/11 should go through MIPS because of the potential conflicts. The other patches can go through net-next as that will make more sense. Maybe Quentin can split the series in two, one for MIPS and one for net if that makes it easier for you to apply.

Quoted 7 lines

I'd be happy to take the .dts changes through the MIPS tree, though looking at them won't patch 1 break bisection?

Since you remove the hsio reg entry it looks to me like mscc_ocelot_probe() will fail with -EINVAL (which comes from devm_ioremap_resource() with res=NULL) until patch 3.

That's correct.

Quoted 4 lines

I'd feel more comfortable merging this piecemeal if it doesn't result in us breaking bisection for however long it takes for both the trees involved to be merged.

How do you want to proceed then?

Quentin

Acked-by
#18 lore raw

Hi Quentin,

Quoted 37 lines · Quentin Schulz
Quoted 28 lines · Paul Burton

Hi Alexandre, Quentin, all,

Quoted 16 lines · Alexandre Belloni
Quoted 15 lines · David Miller

From: Alexandre Belloni <[email protected]>
Date: Mon, 3 Sep 2018 15:45:22 +0200

Quoted 11 lines · Andrew Lunn
Quoted 7 lines
Quoted 2 lines

I suggest patches 1 and 8 go through MIPS tree, 2 to 5 and 11 go through net while the others (6, 7, 9 and 10) go through the generic PHY subsystem.

Hi Quentin

Are you expecting merge conflicts? If not, it might be simpler to gets ACKs from each maintainer, and then merge it though one tree.

There are some other DT changes for this cycle so those should probably go through MIPS.

Quoted 8 lines
Quoted 3 lines

No objection for this going through the MIPS tree, and from me:

What I meant was that 1/11 and 8/11 should go through MIPS because of the potential conflicts. The other patches can go through net-next as that will make more sense. Maybe Quentin can split the series in two, one for MIPS and one for net if that makes it easier for you to apply.

Quoted 7 lines

I'd be happy to take the .dts changes through the MIPS tree, though looking at them won't patch 1 break bisection?

Since you remove the hsio reg entry it looks to me like mscc_ocelot_probe() will fail with -EINVAL (which comes from devm_ioremap_resource() with res=NULL) until patch 3.

Quoted 8 lines

That's correct.

Quoted 4 lines

I'd feel more comfortable merging this piecemeal if it doesn't result in us breaking bisection for however long it takes for both the trees involved to be merged.

How do you want to proceed then?

Well, it sounded like David is OK with this all going through the MIPS tree, though we'd need an ack for the PHY parts.

Alternatively I'd be happy for the DT changes to go through the net-next tree, which may make more sense given that the .dts changes are pretty trivial in comparison with the driver changes. If David wants to do that then for patches 1 & 8:

Either way there may be conflicts for ocelot.dtsi when it comes to merging to master, but they should be simple to resolve. It seems Wolfram already took your DT changes for I2C so there's probably going to be multiple trees updating that file this cycle already anyway.

Ideally I'd say "don't break bisection" but that's sort of a separate issue here since even if you restructure your series to do that it would still need to go through one tree. For example you could adjust mscc_ocelot_probe() to handle either the reg property or the syscon, then adjust the DT to use the syscon, then remove the code dealing with the reg property, and I'd consider that a good idea anyway but it would still probably all need to go through one tree to make sure things get merged in the right order & avoid breaking bisection.

Thanks,
Paul

#19 lore raw
Quoted 8 lines · Paul Burton

Well, it sounded like David is OK with this all going through the MIPS tree, though we'd need an ack for the PHY parts.

Alternatively I'd be happy for the DT changes to go through the net-next tree, which may make more sense given that the .dts changes are pretty trivial in comparison with the driver changes. If David wants to do that then for patches 1 & 8:

Quoted 7 lines

Either way there may be conflicts for ocelot.dtsi when it comes to merging to master, but they should be simple to resolve. It seems Wolfram already took your DT changes for I2C so there's probably going to be multiple trees updating that file this cycle already anyway.

Actually, I think Wolfram meant that he took the bindings so you can take the DT patches for i2c.

Quoted 9 lines

Ideally I'd say "don't break bisection" but that's sort of a separate issue here since even if you restructure your series to do that it would still need to go through one tree. For example you could adjust mscc_ocelot_probe() to handle either the reg property or the syscon, then adjust the DT to use the syscon, then remove the code dealing with the reg property, and I'd consider that a good idea anyway but it would still probably all need to go through one tree to make sure things get merged in the right order & avoid breaking bisection.

I don't really think bisection is important at this stage but if you don't want to break it, then I guess it makes more sense to have the whole series through net.

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
maintainer
#20 lore raw
In reply to Alexandre Belloni

From: Alexandre Belloni <[email protected]>
Date: Tue, 4 Sep 2018 17:16:53 +0200

Quoted 4 lines

What I meant was that 1/11 and 8/11 should go through MIPS because of the potential conflicts. The other patches can go through net-next as that will make more sense. Maybe Quentin can split the series in two, one for MIPS and one for net if that makes it easier for you to apply.

It would make things easier for me.