linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys
@ 2022-10-08 18:51 Colin Foster
  2022-10-08 18:51 ` [RFC v4 net-next 01/17] net: mscc: ocelot: expose ocelot wm functions Colin Foster
                   ` (17 more replies)
  0 siblings, 18 replies; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

This patch series is a continuation to add support for the VSC7512:
https://patchwork.kernel.org/project/netdevbpf/list/?series=674168&state=*

That series added the framework and initial functionality for the
VSC7512 chip. Several of these patches grew during the initial
development of the framework, which is why v1 will include changelogs.
It was during v9 of that original MFD patch set that these were dropped.

With that out of the way, the VSC7512 is mainly a subset of the VSC7514
chip. The 7512 lacks an internal MIPS processor, but otherwise many of
the register definitions are identical. That is why several of these
patches are simply to expose common resources from
drivers/net/ethernet/mscc/*.

This patch only adds support for the first four ports (swp0-swp3). The
remaining ports require more significant changes to the felix driver,
and will be handled in the future.


*** Notes on V4
The patch set is growing long. My apologies. There isn't much that can
reasonably be broken out. Perhaps these could be standalone:

  net: dsa: felix: add functionality when not all ports are supported
  dt-bindings: mfd: ocelot: remove spi-max-frequency from required
    properties

And I'm not certain if these two patches should be combined, as they are
co-dependent:

  dt-bindings: mfd: ocelot: add ethernet-switch hardware support
  dt-bindings: net: dsa: ocelot: add ocelot-ext documentation

The only warning I know about is about the reg array being too long:
/Documentation/devicetree/bindings/net/dsa/mscc,ocelot.example.dtb: soc@0: ethernet-switch@0:reg: [[1895890944, 65536], [1896022016, 65536], [1896349696, 256], [1896742912, 65536], [1897791488, 256], [1897857024, 256], [1897922560, 256], [1897988096, 256], [1898053632, 256], [1898119168, 256], [1898184704, 256], [1898250240, 256], [1898315776, 256], [1898381312, 256], [1898446848, 256], [1904214016, 524288], [1904738304, 65536], [1896087552, 65536], [1896153088, 65536], [1896218624, 65536]] is too long

Also I know there is still ongoing discussion regarding what the documentation
should reflect. I hope I'm not getting ahead of myself by submitting this
RFC at this time.
***


v4
    * Update documentation to include all ports / modes (patch 15)
    * Fix dt_bindings_check warnings (patch 13, 14, 15)
    * Utilize new "resource_names" reference (patch 9, 12, 16)
    * Drop unnecessary #undef REG patch in pinctl: ocelot
    * Utilize standard MFD resource addition (patch 17)
    * Utilize shared vsc7514_regmap (new patch 6)
    * Allow forward-compatibility on fully-defined device trees
      (patch 10,14)

v3
    * Fix allmodconfig build (patch 8)
    * Change documentation wording (patch 12)
    * Import module namespace (patch 13)
    * Fix array initializer (patch 13)

v2
    * Utilize common ocelot_reset routine (new patch 5, modified patch 13)
    * Change init_regmap() routine to be string-based (new patch 8)
    * Split patches where necessary (patches 9 and 14)
    * Add documentation (patch 12) and MAINTAINERS (patch 13)
    * Upgrade to PATCH status

v1 (from RFC v8 suggested above):
    * Utilize the MFD framework for creating regmaps, as well as
      dev_get_regmap() (patches 7 and 8 of this series)

Colin Foster (17):
  net: mscc: ocelot: expose ocelot wm functions
  net: mscc: ocelot: expose regfield definition to be used by other
    drivers
  net: mscc: ocelot: expose stats layout definition to be used by other
    drivers
  net: mscc: ocelot: expose vcap_props structure
  net: mscc: ocelot: expose ocelot_reset routine
  net: mscc: ocelot: expose vsc7514_regmap definition
  net: dsa: felix: add configurable device quirks
  net: dsa: felix: populate mac_capabilities for all ports
  net: dsa: felix: add support for MFD configurations
  net: dsa: felix: add functionality when not all ports are supported
  mfd: ocelot: prepend resource size macros to be 32-bit
  mfd: ocelot: add shared resource names for switch functionality
  dt-bindings: mfd: ocelot: remove spi-max-frequency from required
    properties
  dt-bindings: mfd: ocelot: add ethernet-switch hardware support
  dt-bindings: net: dsa: ocelot: add ocelot-ext documentation
  net: dsa: ocelot: add external ocelot switch control
  mfd: ocelot: add external ocelot switch control

 .../devicetree/bindings/mfd/mscc,ocelot.yaml  |   9 +-
 .../bindings/net/dsa/mscc,ocelot.yaml         | 112 ++++++++++
 MAINTAINERS                                   |   1 +
 drivers/mfd/ocelot-core.c                     |  68 +++++-
 drivers/net/dsa/ocelot/Kconfig                |  19 ++
 drivers/net/dsa/ocelot/Makefile               |   5 +
 drivers/net/dsa/ocelot/felix.c                |  28 ++-
 drivers/net/dsa/ocelot/felix.h                |   2 +
 drivers/net/dsa/ocelot/felix_vsc9959.c        |   1 +
 drivers/net/dsa/ocelot/ocelot_ext.c           | 178 ++++++++++++++++
 drivers/net/dsa/ocelot/seville_vsc9953.c      |   1 +
 drivers/net/ethernet/mscc/ocelot.c            |  48 ++++-
 drivers/net/ethernet/mscc/ocelot_devlink.c    |  31 +++
 drivers/net/ethernet/mscc/ocelot_vsc7514.c    | 196 +-----------------
 drivers/net/ethernet/mscc/vsc7514_regs.c      | 122 +++++++++++
 include/linux/mfd/ocelot.h                    |   9 +
 include/soc/mscc/ocelot.h                     |   6 +
 include/soc/mscc/vsc7514_regs.h               |   8 +
 18 files changed, 640 insertions(+), 204 deletions(-)
 create mode 100644 drivers/net/dsa/ocelot/ocelot_ext.c

-- 
2.25.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 01/17] net: mscc: ocelot: expose ocelot wm functions
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-08 18:51 ` [RFC v4 net-next 02/17] net: mscc: ocelot: expose regfield definition to be used by other drivers Colin Foster
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones, Vladimir Oltean

Expose ocelot_wm functions so they can be shared with other drivers.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---

v1 - v4:
    * No changes since previous RFC

---
 drivers/net/ethernet/mscc/ocelot_devlink.c | 31 ++++++++++++++++++++++
 drivers/net/ethernet/mscc/ocelot_vsc7514.c | 28 -------------------
 include/soc/mscc/ocelot.h                  |  5 ++++
 3 files changed, 36 insertions(+), 28 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot_devlink.c b/drivers/net/ethernet/mscc/ocelot_devlink.c
index b8737efd2a85..d9ea75a14f2f 100644
--- a/drivers/net/ethernet/mscc/ocelot_devlink.c
+++ b/drivers/net/ethernet/mscc/ocelot_devlink.c
@@ -487,6 +487,37 @@ static void ocelot_watermark_init(struct ocelot *ocelot)
 	ocelot_setup_sharing_watermarks(ocelot);
 }
 
+/* Watermark encode
+ * Bit 8:   Unit; 0:1, 1:16
+ * Bit 7-0: Value to be multiplied with unit
+ */
+u16 ocelot_wm_enc(u16 value)
+{
+	WARN_ON(value >= 16 * BIT(8));
+
+	if (value >= BIT(8))
+		return BIT(8) | (value / 16);
+
+	return value;
+}
+EXPORT_SYMBOL(ocelot_wm_enc);
+
+u16 ocelot_wm_dec(u16 wm)
+{
+	if (wm & BIT(8))
+		return (wm & GENMASK(7, 0)) * 16;
+
+	return wm;
+}
+EXPORT_SYMBOL(ocelot_wm_dec);
+
+void ocelot_wm_stat(u32 val, u32 *inuse, u32 *maxuse)
+{
+	*inuse = (val & GENMASK(23, 12)) >> 12;
+	*maxuse = val & GENMASK(11, 0);
+}
+EXPORT_SYMBOL(ocelot_wm_stat);
+
 /* Pool size and type are fixed up at runtime. Keeping this structure to
  * look up the cell size multipliers.
  */
diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
index 6f22aea08a64..bac0ee9126f8 100644
--- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c
+++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
@@ -234,34 +234,6 @@ static int ocelot_reset(struct ocelot *ocelot)
 	return regmap_field_write(ocelot->regfields[SYS_RESET_CFG_CORE_ENA], 1);
 }
 
-/* Watermark encode
- * Bit 8:   Unit; 0:1, 1:16
- * Bit 7-0: Value to be multiplied with unit
- */
-static u16 ocelot_wm_enc(u16 value)
-{
-	WARN_ON(value >= 16 * BIT(8));
-
-	if (value >= BIT(8))
-		return BIT(8) | (value / 16);
-
-	return value;
-}
-
-static u16 ocelot_wm_dec(u16 wm)
-{
-	if (wm & BIT(8))
-		return (wm & GENMASK(7, 0)) * 16;
-
-	return wm;
-}
-
-static void ocelot_wm_stat(u32 val, u32 *inuse, u32 *maxuse)
-{
-	*inuse = (val & GENMASK(23, 12)) >> 12;
-	*maxuse = val & GENMASK(11, 0);
-}
-
 static const struct ocelot_ops ocelot_ops = {
 	.reset			= ocelot_reset,
 	.wm_enc			= ocelot_wm_enc,
diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h
index 967ba30ea636..55bbd5319128 100644
--- a/include/soc/mscc/ocelot.h
+++ b/include/soc/mscc/ocelot.h
@@ -1145,6 +1145,11 @@ void ocelot_port_assign_dsa_8021q_cpu(struct ocelot *ocelot, int port, int cpu);
 void ocelot_port_unassign_dsa_8021q_cpu(struct ocelot *ocelot, int port);
 u32 ocelot_port_assigned_dsa_8021q_cpu_mask(struct ocelot *ocelot, int port);
 
+/* Watermark interface */
+u16 ocelot_wm_enc(u16 value);
+u16 ocelot_wm_dec(u16 wm);
+void ocelot_wm_stat(u32 val, u32 *inuse, u32 *maxuse);
+
 /* DSA callbacks */
 void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data);
 void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 02/17] net: mscc: ocelot: expose regfield definition to be used by other drivers
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
  2022-10-08 18:51 ` [RFC v4 net-next 01/17] net: mscc: ocelot: expose ocelot wm functions Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-08 18:51 ` [RFC v4 net-next 03/17] net: mscc: ocelot: expose stats layout " Colin Foster
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones, Vladimir Oltean

The ocelot_regfields struct is common between several different chips, some
of which can only be controlled externally. Export this structure so it
doesn't have to be duplicated in these other drivers.

Rename the structure as well, to follow the conventions of other shared
resources.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---

v3-v4
    * No changes

v2
    * Add Reviewed tag

v1 from previous RFC:
    * Remove GCB_SOFT_RST_SWC_RST entry from the regfields struct - it
      isn't used.
    * Export the vsc7514_regfields symbol so it can be used as a module.

---
 drivers/net/ethernet/mscc/ocelot_vsc7514.c | 60 +---------------------
 drivers/net/ethernet/mscc/vsc7514_regs.c   | 59 +++++++++++++++++++++
 include/soc/mscc/vsc7514_regs.h            |  2 +
 3 files changed, 62 insertions(+), 59 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
index bac0ee9126f8..6d695375b14b 100644
--- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c
+++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
@@ -42,64 +42,6 @@ static const u32 *ocelot_regmap[TARGET_MAX] = {
 	[DEV_GMII] = vsc7514_dev_gmii_regmap,
 };
 
-static const struct reg_field ocelot_regfields[REGFIELD_MAX] = {
-	[ANA_ADVLEARN_VLAN_CHK] = REG_FIELD(ANA_ADVLEARN, 11, 11),
-	[ANA_ADVLEARN_LEARN_MIRROR] = REG_FIELD(ANA_ADVLEARN, 0, 10),
-	[ANA_ANEVENTS_MSTI_DROP] = REG_FIELD(ANA_ANEVENTS, 27, 27),
-	[ANA_ANEVENTS_ACLKILL] = REG_FIELD(ANA_ANEVENTS, 26, 26),
-	[ANA_ANEVENTS_ACLUSED] = REG_FIELD(ANA_ANEVENTS, 25, 25),
-	[ANA_ANEVENTS_AUTOAGE] = REG_FIELD(ANA_ANEVENTS, 24, 24),
-	[ANA_ANEVENTS_VS2TTL1] = REG_FIELD(ANA_ANEVENTS, 23, 23),
-	[ANA_ANEVENTS_STORM_DROP] = REG_FIELD(ANA_ANEVENTS, 22, 22),
-	[ANA_ANEVENTS_LEARN_DROP] = REG_FIELD(ANA_ANEVENTS, 21, 21),
-	[ANA_ANEVENTS_AGED_ENTRY] = REG_FIELD(ANA_ANEVENTS, 20, 20),
-	[ANA_ANEVENTS_CPU_LEARN_FAILED] = REG_FIELD(ANA_ANEVENTS, 19, 19),
-	[ANA_ANEVENTS_AUTO_LEARN_FAILED] = REG_FIELD(ANA_ANEVENTS, 18, 18),
-	[ANA_ANEVENTS_LEARN_REMOVE] = REG_FIELD(ANA_ANEVENTS, 17, 17),
-	[ANA_ANEVENTS_AUTO_LEARNED] = REG_FIELD(ANA_ANEVENTS, 16, 16),
-	[ANA_ANEVENTS_AUTO_MOVED] = REG_FIELD(ANA_ANEVENTS, 15, 15),
-	[ANA_ANEVENTS_DROPPED] = REG_FIELD(ANA_ANEVENTS, 14, 14),
-	[ANA_ANEVENTS_CLASSIFIED_DROP] = REG_FIELD(ANA_ANEVENTS, 13, 13),
-	[ANA_ANEVENTS_CLASSIFIED_COPY] = REG_FIELD(ANA_ANEVENTS, 12, 12),
-	[ANA_ANEVENTS_VLAN_DISCARD] = REG_FIELD(ANA_ANEVENTS, 11, 11),
-	[ANA_ANEVENTS_FWD_DISCARD] = REG_FIELD(ANA_ANEVENTS, 10, 10),
-	[ANA_ANEVENTS_MULTICAST_FLOOD] = REG_FIELD(ANA_ANEVENTS, 9, 9),
-	[ANA_ANEVENTS_UNICAST_FLOOD] = REG_FIELD(ANA_ANEVENTS, 8, 8),
-	[ANA_ANEVENTS_DEST_KNOWN] = REG_FIELD(ANA_ANEVENTS, 7, 7),
-	[ANA_ANEVENTS_BUCKET3_MATCH] = REG_FIELD(ANA_ANEVENTS, 6, 6),
-	[ANA_ANEVENTS_BUCKET2_MATCH] = REG_FIELD(ANA_ANEVENTS, 5, 5),
-	[ANA_ANEVENTS_BUCKET1_MATCH] = REG_FIELD(ANA_ANEVENTS, 4, 4),
-	[ANA_ANEVENTS_BUCKET0_MATCH] = REG_FIELD(ANA_ANEVENTS, 3, 3),
-	[ANA_ANEVENTS_CPU_OPERATION] = REG_FIELD(ANA_ANEVENTS, 2, 2),
-	[ANA_ANEVENTS_DMAC_LOOKUP] = REG_FIELD(ANA_ANEVENTS, 1, 1),
-	[ANA_ANEVENTS_SMAC_LOOKUP] = REG_FIELD(ANA_ANEVENTS, 0, 0),
-	[ANA_TABLES_MACACCESS_B_DOM] = REG_FIELD(ANA_TABLES_MACACCESS, 18, 18),
-	[ANA_TABLES_MACTINDX_BUCKET] = REG_FIELD(ANA_TABLES_MACTINDX, 10, 11),
-	[ANA_TABLES_MACTINDX_M_INDEX] = REG_FIELD(ANA_TABLES_MACTINDX, 0, 9),
-	[QSYS_TIMED_FRAME_ENTRY_TFRM_VLD] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 20, 20),
-	[QSYS_TIMED_FRAME_ENTRY_TFRM_FP] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 8, 19),
-	[QSYS_TIMED_FRAME_ENTRY_TFRM_PORTNO] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 4, 7),
-	[QSYS_TIMED_FRAME_ENTRY_TFRM_TM_SEL] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 1, 3),
-	[QSYS_TIMED_FRAME_ENTRY_TFRM_TM_T] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 0, 0),
-	[SYS_RESET_CFG_CORE_ENA] = REG_FIELD(SYS_RESET_CFG, 2, 2),
-	[SYS_RESET_CFG_MEM_ENA] = REG_FIELD(SYS_RESET_CFG, 1, 1),
-	[SYS_RESET_CFG_MEM_INIT] = REG_FIELD(SYS_RESET_CFG, 0, 0),
-	/* Replicated per number of ports (12), register size 4 per port */
-	[QSYS_SWITCH_PORT_MODE_PORT_ENA] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 14, 14, 12, 4),
-	[QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 11, 13, 12, 4),
-	[QSYS_SWITCH_PORT_MODE_YEL_RSRVD] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 10, 10, 12, 4),
-	[QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 9, 9, 12, 4),
-	[QSYS_SWITCH_PORT_MODE_TX_PFC_ENA] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 1, 8, 12, 4),
-	[QSYS_SWITCH_PORT_MODE_TX_PFC_MODE] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 0, 0, 12, 4),
-	[SYS_PORT_MODE_DATA_WO_TS] = REG_FIELD_ID(SYS_PORT_MODE, 5, 6, 12, 4),
-	[SYS_PORT_MODE_INCL_INJ_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 3, 4, 12, 4),
-	[SYS_PORT_MODE_INCL_XTR_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 1, 2, 12, 4),
-	[SYS_PORT_MODE_INCL_HDR_ERR] = REG_FIELD_ID(SYS_PORT_MODE, 0, 0, 12, 4),
-	[SYS_PAUSE_CFG_PAUSE_START] = REG_FIELD_ID(SYS_PAUSE_CFG, 10, 18, 12, 4),
-	[SYS_PAUSE_CFG_PAUSE_STOP] = REG_FIELD_ID(SYS_PAUSE_CFG, 1, 9, 12, 4),
-	[SYS_PAUSE_CFG_PAUSE_ENA] = REG_FIELD_ID(SYS_PAUSE_CFG, 0, 1, 12, 4),
-};
-
 static const struct ocelot_stat_layout ocelot_stats_layout[OCELOT_NUM_STATS] = {
 	OCELOT_COMMON_STATS,
 };
@@ -142,7 +84,7 @@ static int ocelot_chip_init(struct ocelot *ocelot, const struct ocelot_ops *ops)
 	ocelot->num_mact_rows = 1024;
 	ocelot->ops = ops;
 
-	ret = ocelot_regfields_init(ocelot, ocelot_regfields);
+	ret = ocelot_regfields_init(ocelot, vsc7514_regfields);
 	if (ret)
 		return ret;
 
diff --git a/drivers/net/ethernet/mscc/vsc7514_regs.c b/drivers/net/ethernet/mscc/vsc7514_regs.c
index 9d2d3e13cacf..123175618251 100644
--- a/drivers/net/ethernet/mscc/vsc7514_regs.c
+++ b/drivers/net/ethernet/mscc/vsc7514_regs.c
@@ -9,6 +9,65 @@
 #include <soc/mscc/vsc7514_regs.h>
 #include "ocelot.h"
 
+const struct reg_field vsc7514_regfields[REGFIELD_MAX] = {
+	[ANA_ADVLEARN_VLAN_CHK] = REG_FIELD(ANA_ADVLEARN, 11, 11),
+	[ANA_ADVLEARN_LEARN_MIRROR] = REG_FIELD(ANA_ADVLEARN, 0, 10),
+	[ANA_ANEVENTS_MSTI_DROP] = REG_FIELD(ANA_ANEVENTS, 27, 27),
+	[ANA_ANEVENTS_ACLKILL] = REG_FIELD(ANA_ANEVENTS, 26, 26),
+	[ANA_ANEVENTS_ACLUSED] = REG_FIELD(ANA_ANEVENTS, 25, 25),
+	[ANA_ANEVENTS_AUTOAGE] = REG_FIELD(ANA_ANEVENTS, 24, 24),
+	[ANA_ANEVENTS_VS2TTL1] = REG_FIELD(ANA_ANEVENTS, 23, 23),
+	[ANA_ANEVENTS_STORM_DROP] = REG_FIELD(ANA_ANEVENTS, 22, 22),
+	[ANA_ANEVENTS_LEARN_DROP] = REG_FIELD(ANA_ANEVENTS, 21, 21),
+	[ANA_ANEVENTS_AGED_ENTRY] = REG_FIELD(ANA_ANEVENTS, 20, 20),
+	[ANA_ANEVENTS_CPU_LEARN_FAILED] = REG_FIELD(ANA_ANEVENTS, 19, 19),
+	[ANA_ANEVENTS_AUTO_LEARN_FAILED] = REG_FIELD(ANA_ANEVENTS, 18, 18),
+	[ANA_ANEVENTS_LEARN_REMOVE] = REG_FIELD(ANA_ANEVENTS, 17, 17),
+	[ANA_ANEVENTS_AUTO_LEARNED] = REG_FIELD(ANA_ANEVENTS, 16, 16),
+	[ANA_ANEVENTS_AUTO_MOVED] = REG_FIELD(ANA_ANEVENTS, 15, 15),
+	[ANA_ANEVENTS_DROPPED] = REG_FIELD(ANA_ANEVENTS, 14, 14),
+	[ANA_ANEVENTS_CLASSIFIED_DROP] = REG_FIELD(ANA_ANEVENTS, 13, 13),
+	[ANA_ANEVENTS_CLASSIFIED_COPY] = REG_FIELD(ANA_ANEVENTS, 12, 12),
+	[ANA_ANEVENTS_VLAN_DISCARD] = REG_FIELD(ANA_ANEVENTS, 11, 11),
+	[ANA_ANEVENTS_FWD_DISCARD] = REG_FIELD(ANA_ANEVENTS, 10, 10),
+	[ANA_ANEVENTS_MULTICAST_FLOOD] = REG_FIELD(ANA_ANEVENTS, 9, 9),
+	[ANA_ANEVENTS_UNICAST_FLOOD] = REG_FIELD(ANA_ANEVENTS, 8, 8),
+	[ANA_ANEVENTS_DEST_KNOWN] = REG_FIELD(ANA_ANEVENTS, 7, 7),
+	[ANA_ANEVENTS_BUCKET3_MATCH] = REG_FIELD(ANA_ANEVENTS, 6, 6),
+	[ANA_ANEVENTS_BUCKET2_MATCH] = REG_FIELD(ANA_ANEVENTS, 5, 5),
+	[ANA_ANEVENTS_BUCKET1_MATCH] = REG_FIELD(ANA_ANEVENTS, 4, 4),
+	[ANA_ANEVENTS_BUCKET0_MATCH] = REG_FIELD(ANA_ANEVENTS, 3, 3),
+	[ANA_ANEVENTS_CPU_OPERATION] = REG_FIELD(ANA_ANEVENTS, 2, 2),
+	[ANA_ANEVENTS_DMAC_LOOKUP] = REG_FIELD(ANA_ANEVENTS, 1, 1),
+	[ANA_ANEVENTS_SMAC_LOOKUP] = REG_FIELD(ANA_ANEVENTS, 0, 0),
+	[ANA_TABLES_MACACCESS_B_DOM] = REG_FIELD(ANA_TABLES_MACACCESS, 18, 18),
+	[ANA_TABLES_MACTINDX_BUCKET] = REG_FIELD(ANA_TABLES_MACTINDX, 10, 11),
+	[ANA_TABLES_MACTINDX_M_INDEX] = REG_FIELD(ANA_TABLES_MACTINDX, 0, 9),
+	[QSYS_TIMED_FRAME_ENTRY_TFRM_VLD] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 20, 20),
+	[QSYS_TIMED_FRAME_ENTRY_TFRM_FP] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 8, 19),
+	[QSYS_TIMED_FRAME_ENTRY_TFRM_PORTNO] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 4, 7),
+	[QSYS_TIMED_FRAME_ENTRY_TFRM_TM_SEL] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 1, 3),
+	[QSYS_TIMED_FRAME_ENTRY_TFRM_TM_T] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 0, 0),
+	[SYS_RESET_CFG_CORE_ENA] = REG_FIELD(SYS_RESET_CFG, 2, 2),
+	[SYS_RESET_CFG_MEM_ENA] = REG_FIELD(SYS_RESET_CFG, 1, 1),
+	[SYS_RESET_CFG_MEM_INIT] = REG_FIELD(SYS_RESET_CFG, 0, 0),
+	/* Replicated per number of ports (12), register size 4 per port */
+	[QSYS_SWITCH_PORT_MODE_PORT_ENA] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 14, 14, 12, 4),
+	[QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 11, 13, 12, 4),
+	[QSYS_SWITCH_PORT_MODE_YEL_RSRVD] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 10, 10, 12, 4),
+	[QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 9, 9, 12, 4),
+	[QSYS_SWITCH_PORT_MODE_TX_PFC_ENA] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 1, 8, 12, 4),
+	[QSYS_SWITCH_PORT_MODE_TX_PFC_MODE] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 0, 0, 12, 4),
+	[SYS_PORT_MODE_DATA_WO_TS] = REG_FIELD_ID(SYS_PORT_MODE, 5, 6, 12, 4),
+	[SYS_PORT_MODE_INCL_INJ_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 3, 4, 12, 4),
+	[SYS_PORT_MODE_INCL_XTR_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 1, 2, 12, 4),
+	[SYS_PORT_MODE_INCL_HDR_ERR] = REG_FIELD_ID(SYS_PORT_MODE, 0, 0, 12, 4),
+	[SYS_PAUSE_CFG_PAUSE_START] = REG_FIELD_ID(SYS_PAUSE_CFG, 10, 18, 12, 4),
+	[SYS_PAUSE_CFG_PAUSE_STOP] = REG_FIELD_ID(SYS_PAUSE_CFG, 1, 9, 12, 4),
+	[SYS_PAUSE_CFG_PAUSE_ENA] = REG_FIELD_ID(SYS_PAUSE_CFG, 0, 1, 12, 4),
+};
+EXPORT_SYMBOL(vsc7514_regfields);
+
 const u32 vsc7514_ana_regmap[] = {
 	REG(ANA_ADVLEARN,				0x009000),
 	REG(ANA_VLANMASK,				0x009004),
diff --git a/include/soc/mscc/vsc7514_regs.h b/include/soc/mscc/vsc7514_regs.h
index ceee26c96959..9b40e7d00ec5 100644
--- a/include/soc/mscc/vsc7514_regs.h
+++ b/include/soc/mscc/vsc7514_regs.h
@@ -10,6 +10,8 @@
 
 #include <soc/mscc/ocelot_vcap.h>
 
+extern const struct reg_field vsc7514_regfields[REGFIELD_MAX];
+
 extern const u32 vsc7514_ana_regmap[];
 extern const u32 vsc7514_qs_regmap[];
 extern const u32 vsc7514_qsys_regmap[];
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 03/17] net: mscc: ocelot: expose stats layout definition to be used by other drivers
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
  2022-10-08 18:51 ` [RFC v4 net-next 01/17] net: mscc: ocelot: expose ocelot wm functions Colin Foster
  2022-10-08 18:51 ` [RFC v4 net-next 02/17] net: mscc: ocelot: expose regfield definition to be used by other drivers Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-12  9:19   ` Vladimir Oltean
  2022-10-08 18:51 ` [RFC v4 net-next 04/17] net: mscc: ocelot: expose vcap_props structure Colin Foster
                   ` (14 subsequent siblings)
  17 siblings, 1 reply; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

The ocelot_stats_layout array is common between several different chips,
some of which can only be controlled externally. Export this structure so
it doesn't have to be duplicated in these other drivers.

Rename the structure as well, to follow the conventions of other shared
resources.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v2-v4
    * No change

v1 from previous RFC:
    * Utilize OCELOT_COMMON_STATS

---
 drivers/net/ethernet/mscc/ocelot_vsc7514.c | 6 +-----
 drivers/net/ethernet/mscc/vsc7514_regs.c   | 5 +++++
 include/soc/mscc/vsc7514_regs.h            | 3 +++
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
index 6d695375b14b..4fb525f071ac 100644
--- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c
+++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
@@ -42,10 +42,6 @@ static const u32 *ocelot_regmap[TARGET_MAX] = {
 	[DEV_GMII] = vsc7514_dev_gmii_regmap,
 };
 
-static const struct ocelot_stat_layout ocelot_stats_layout[OCELOT_NUM_STATS] = {
-	OCELOT_COMMON_STATS,
-};
-
 static void ocelot_pll5_init(struct ocelot *ocelot)
 {
 	/* Configure PLL5. This will need a proper CCF driver
@@ -80,7 +76,7 @@ static int ocelot_chip_init(struct ocelot *ocelot, const struct ocelot_ops *ops)
 	int ret;
 
 	ocelot->map = ocelot_regmap;
-	ocelot->stats_layout = ocelot_stats_layout;
+	ocelot->stats_layout = vsc7514_stats_layout;
 	ocelot->num_mact_rows = 1024;
 	ocelot->ops = ops;
 
diff --git a/drivers/net/ethernet/mscc/vsc7514_regs.c b/drivers/net/ethernet/mscc/vsc7514_regs.c
index 123175618251..d665522e18c6 100644
--- a/drivers/net/ethernet/mscc/vsc7514_regs.c
+++ b/drivers/net/ethernet/mscc/vsc7514_regs.c
@@ -9,6 +9,11 @@
 #include <soc/mscc/vsc7514_regs.h>
 #include "ocelot.h"
 
+const struct ocelot_stat_layout vsc7514_stats_layout[OCELOT_NUM_STATS] = {
+	OCELOT_COMMON_STATS,
+};
+EXPORT_SYMBOL(vsc7514_stats_layout);
+
 const struct reg_field vsc7514_regfields[REGFIELD_MAX] = {
 	[ANA_ADVLEARN_VLAN_CHK] = REG_FIELD(ANA_ADVLEARN, 11, 11),
 	[ANA_ADVLEARN_LEARN_MIRROR] = REG_FIELD(ANA_ADVLEARN, 0, 10),
diff --git a/include/soc/mscc/vsc7514_regs.h b/include/soc/mscc/vsc7514_regs.h
index 9b40e7d00ec5..d2b5b6b86aff 100644
--- a/include/soc/mscc/vsc7514_regs.h
+++ b/include/soc/mscc/vsc7514_regs.h
@@ -8,8 +8,11 @@
 #ifndef VSC7514_REGS_H
 #define VSC7514_REGS_H
 
+#include <soc/mscc/ocelot.h>
 #include <soc/mscc/ocelot_vcap.h>
 
+extern const struct ocelot_stat_layout vsc7514_stats_layout[];
+
 extern const struct reg_field vsc7514_regfields[REGFIELD_MAX];
 
 extern const u32 vsc7514_ana_regmap[];
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 04/17] net: mscc: ocelot: expose vcap_props structure
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
                   ` (2 preceding siblings ...)
  2022-10-08 18:51 ` [RFC v4 net-next 03/17] net: mscc: ocelot: expose stats layout " Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-08 18:51 ` [RFC v4 net-next 05/17] net: mscc: ocelot: expose ocelot_reset routine Colin Foster
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

The vcap_props structure is common to other devices, specifically the
VSC7512 chip that can only be controlled externally. Export this structure
so it doesn't need to be recreated.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v1 - v4 from previous RFC:
    * No changes

---
 drivers/net/ethernet/mscc/ocelot_vsc7514.c | 43 ---------------------
 drivers/net/ethernet/mscc/vsc7514_regs.c   | 44 ++++++++++++++++++++++
 include/soc/mscc/vsc7514_regs.h            |  1 +
 3 files changed, 45 insertions(+), 43 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
index 4fb525f071ac..19e5486d1dbd 100644
--- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c
+++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
@@ -181,49 +181,6 @@ static const struct ocelot_ops ocelot_ops = {
 	.netdev_to_port		= ocelot_netdev_to_port,
 };
 
-static struct vcap_props vsc7514_vcap_props[] = {
-	[VCAP_ES0] = {
-		.action_type_width = 0,
-		.action_table = {
-			[ES0_ACTION_TYPE_NORMAL] = {
-				.width = 73, /* HIT_STICKY not included */
-				.count = 1,
-			},
-		},
-		.target = S0,
-		.keys = vsc7514_vcap_es0_keys,
-		.actions = vsc7514_vcap_es0_actions,
-	},
-	[VCAP_IS1] = {
-		.action_type_width = 0,
-		.action_table = {
-			[IS1_ACTION_TYPE_NORMAL] = {
-				.width = 78, /* HIT_STICKY not included */
-				.count = 4,
-			},
-		},
-		.target = S1,
-		.keys = vsc7514_vcap_is1_keys,
-		.actions = vsc7514_vcap_is1_actions,
-	},
-	[VCAP_IS2] = {
-		.action_type_width = 1,
-		.action_table = {
-			[IS2_ACTION_TYPE_NORMAL] = {
-				.width = 49,
-				.count = 2
-			},
-			[IS2_ACTION_TYPE_SMAC_SIP] = {
-				.width = 6,
-				.count = 4
-			},
-		},
-		.target = S2,
-		.keys = vsc7514_vcap_is2_keys,
-		.actions = vsc7514_vcap_is2_actions,
-	},
-};
-
 static struct ptp_clock_info ocelot_ptp_clock_info = {
 	.owner		= THIS_MODULE,
 	.name		= "ocelot ptp",
diff --git a/drivers/net/ethernet/mscc/vsc7514_regs.c b/drivers/net/ethernet/mscc/vsc7514_regs.c
index d665522e18c6..c943da4dd1f1 100644
--- a/drivers/net/ethernet/mscc/vsc7514_regs.c
+++ b/drivers/net/ethernet/mscc/vsc7514_regs.c
@@ -644,3 +644,47 @@ const struct vcap_field vsc7514_vcap_is2_actions[] = {
 	[VCAP_IS2_ACT_HIT_CNT]			= { 49, 32 },
 };
 EXPORT_SYMBOL(vsc7514_vcap_is2_actions);
+
+struct vcap_props vsc7514_vcap_props[] = {
+	[VCAP_ES0] = {
+		.action_type_width = 0,
+		.action_table = {
+			[ES0_ACTION_TYPE_NORMAL] = {
+				.width = 73, /* HIT_STICKY not included */
+				.count = 1,
+			},
+		},
+		.target = S0,
+		.keys = vsc7514_vcap_es0_keys,
+		.actions = vsc7514_vcap_es0_actions,
+	},
+	[VCAP_IS1] = {
+		.action_type_width = 0,
+		.action_table = {
+			[IS1_ACTION_TYPE_NORMAL] = {
+				.width = 78, /* HIT_STICKY not included */
+				.count = 4,
+			},
+		},
+		.target = S1,
+		.keys = vsc7514_vcap_is1_keys,
+		.actions = vsc7514_vcap_is1_actions,
+	},
+	[VCAP_IS2] = {
+		.action_type_width = 1,
+		.action_table = {
+			[IS2_ACTION_TYPE_NORMAL] = {
+				.width = 49,
+				.count = 2
+			},
+			[IS2_ACTION_TYPE_SMAC_SIP] = {
+				.width = 6,
+				.count = 4
+			},
+		},
+		.target = S2,
+		.keys = vsc7514_vcap_is2_keys,
+		.actions = vsc7514_vcap_is2_actions,
+	},
+};
+EXPORT_SYMBOL(vsc7514_vcap_props);
diff --git a/include/soc/mscc/vsc7514_regs.h b/include/soc/mscc/vsc7514_regs.h
index d2b5b6b86aff..a939849efd91 100644
--- a/include/soc/mscc/vsc7514_regs.h
+++ b/include/soc/mscc/vsc7514_regs.h
@@ -12,6 +12,7 @@
 #include <soc/mscc/ocelot_vcap.h>
 
 extern const struct ocelot_stat_layout vsc7514_stats_layout[];
+extern struct vcap_props vsc7514_vcap_props[];
 
 extern const struct reg_field vsc7514_regfields[REGFIELD_MAX];
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 05/17] net: mscc: ocelot: expose ocelot_reset routine
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
                   ` (3 preceding siblings ...)
  2022-10-08 18:51 ` [RFC v4 net-next 04/17] net: mscc: ocelot: expose vcap_props structure Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-08 18:51 ` [RFC v4 net-next 06/17] net: mscc: ocelot: expose vsc7514_regmap definition Colin Foster
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

Resetting the switch core is the same whether it is done internally or
externally. Move this routine to the ocelot library so it can be used by
other drivers.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v3-v4
    * No changes

v2
    * New patch

---
 drivers/net/ethernet/mscc/ocelot.c         | 48 +++++++++++++++++++++-
 drivers/net/ethernet/mscc/ocelot_vsc7514.c | 44 +-------------------
 include/soc/mscc/ocelot.h                  |  1 +
 3 files changed, 48 insertions(+), 45 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index 13b14110a060..432eca7dcb11 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -6,12 +6,16 @@
  */
 #include <linux/dsa/ocelot.h>
 #include <linux/if_bridge.h>
+#include <linux/iopoll.h>
 #include <soc/mscc/ocelot_vcap.h>
 #include "ocelot.h"
 #include "ocelot_vcap.h"
 
-#define TABLE_UPDATE_SLEEP_US 10
-#define TABLE_UPDATE_TIMEOUT_US 100000
+#define TABLE_UPDATE_SLEEP_US	10
+#define TABLE_UPDATE_TIMEOUT_US	100000
+#define MEM_INIT_SLEEP_US	1000
+#define MEM_INIT_TIMEOUT_US	100000
+
 #define OCELOT_RSV_VLAN_RANGE_START 4000
 
 struct ocelot_mact_entry {
@@ -2715,6 +2719,46 @@ static void ocelot_detect_features(struct ocelot *ocelot)
 	ocelot->num_frame_refs = QSYS_MMGT_EQ_CTRL_FP_FREE_CNT(eq_ctrl);
 }
 
+static int ocelot_mem_init_status(struct ocelot *ocelot)
+{
+	unsigned int val;
+	int err;
+
+	err = regmap_field_read(ocelot->regfields[SYS_RESET_CFG_MEM_INIT],
+				&val);
+
+	return err ?: val;
+}
+
+int ocelot_reset(struct ocelot *ocelot)
+{
+	int err;
+	u32 val;
+
+	err = regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_INIT], 1);
+	if (err)
+		return err;
+
+	err = regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1);
+	if (err)
+		return err;
+
+	/* MEM_INIT is a self-clearing bit. Wait for it to be cleared (should be
+	 * 100us) before enabling the switch core.
+	 */
+	err = readx_poll_timeout(ocelot_mem_init_status, ocelot, val, !val,
+				 MEM_INIT_SLEEP_US, MEM_INIT_TIMEOUT_US);
+	if (err)
+		return err;
+
+	err = regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1);
+	if (err)
+		return err;
+
+	return regmap_field_write(ocelot->regfields[SYS_RESET_CFG_CORE_ENA], 1);
+}
+EXPORT_SYMBOL(ocelot_reset);
+
 int ocelot_init(struct ocelot *ocelot)
 {
 	int i, ret;
diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
index 19e5486d1dbd..822b11d33288 100644
--- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c
+++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
@@ -6,7 +6,6 @@
  */
 #include <linux/dsa/ocelot.h>
 #include <linux/interrupt.h>
-#include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/of_net.h>
 #include <linux/netdevice.h>
@@ -17,6 +16,7 @@
 #include <linux/skbuff.h>
 #include <net/switchdev.h>
 
+#include <soc/mscc/ocelot.h>
 #include <soc/mscc/ocelot_vcap.h>
 #include <soc/mscc/ocelot_hsio.h>
 #include <soc/mscc/vsc7514_regs.h>
@@ -26,9 +26,6 @@
 #define VSC7514_VCAP_POLICER_BASE			128
 #define VSC7514_VCAP_POLICER_MAX			191
 
-#define MEM_INIT_SLEEP_US				1000
-#define MEM_INIT_TIMEOUT_US				100000
-
 static const u32 *ocelot_regmap[TARGET_MAX] = {
 	[ANA] = vsc7514_ana_regmap,
 	[QS] = vsc7514_qs_regmap,
@@ -133,45 +130,6 @@ static const struct of_device_id mscc_ocelot_match[] = {
 };
 MODULE_DEVICE_TABLE(of, mscc_ocelot_match);
 
-static int ocelot_mem_init_status(struct ocelot *ocelot)
-{
-	unsigned int val;
-	int err;
-
-	err = regmap_field_read(ocelot->regfields[SYS_RESET_CFG_MEM_INIT],
-				&val);
-
-	return err ?: val;
-}
-
-static int ocelot_reset(struct ocelot *ocelot)
-{
-	int err;
-	u32 val;
-
-	err = regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_INIT], 1);
-	if (err)
-		return err;
-
-	err = regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1);
-	if (err)
-		return err;
-
-	/* MEM_INIT is a self-clearing bit. Wait for it to be cleared (should be
-	 * 100us) before enabling the switch core.
-	 */
-	err = readx_poll_timeout(ocelot_mem_init_status, ocelot, val, !val,
-				 MEM_INIT_SLEEP_US, MEM_INIT_TIMEOUT_US);
-	if (err)
-		return err;
-
-	err = regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1);
-	if (err)
-		return err;
-
-	return regmap_field_write(ocelot->regfields[SYS_RESET_CFG_CORE_ENA], 1);
-}
-
 static const struct ocelot_ops ocelot_ops = {
 	.reset			= ocelot_reset,
 	.wm_enc			= ocelot_wm_enc,
diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h
index 55bbd5319128..9c1c9b8c43f5 100644
--- a/include/soc/mscc/ocelot.h
+++ b/include/soc/mscc/ocelot.h
@@ -1134,6 +1134,7 @@ void ocelot_ptp_rx_timestamp(struct ocelot *ocelot, struct sk_buff *skb,
 int ocelot_regfields_init(struct ocelot *ocelot,
 			  const struct reg_field *const regfields);
 struct regmap *ocelot_regmap_init(struct ocelot *ocelot, struct resource *res);
+int ocelot_reset(struct ocelot *ocelot);
 int ocelot_init(struct ocelot *ocelot);
 void ocelot_deinit(struct ocelot *ocelot);
 void ocelot_init_port(struct ocelot *ocelot, int port);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 06/17] net: mscc: ocelot: expose vsc7514_regmap definition
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
                   ` (4 preceding siblings ...)
  2022-10-08 18:51 ` [RFC v4 net-next 05/17] net: mscc: ocelot: expose ocelot_reset routine Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-08 18:51 ` [RFC v4 net-next 07/17] net: dsa: felix: add configurable device quirks Colin Foster
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

The VSC7514 target regmap is identical for ones shared with similar
hardware, specifically the VSC7512. Share this resource, and change the
name to match the pattern of other exported resources.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v4
    * New patch

---
 drivers/net/ethernet/mscc/ocelot_vsc7514.c | 15 +--------------
 drivers/net/ethernet/mscc/vsc7514_regs.c   | 14 ++++++++++++++
 include/soc/mscc/vsc7514_regs.h            |  2 ++
 3 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
index 822b11d33288..a30a3694f200 100644
--- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c
+++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
@@ -26,19 +26,6 @@
 #define VSC7514_VCAP_POLICER_BASE			128
 #define VSC7514_VCAP_POLICER_MAX			191
 
-static const u32 *ocelot_regmap[TARGET_MAX] = {
-	[ANA] = vsc7514_ana_regmap,
-	[QS] = vsc7514_qs_regmap,
-	[QSYS] = vsc7514_qsys_regmap,
-	[REW] = vsc7514_rew_regmap,
-	[SYS] = vsc7514_sys_regmap,
-	[S0] = vsc7514_vcap_regmap,
-	[S1] = vsc7514_vcap_regmap,
-	[S2] = vsc7514_vcap_regmap,
-	[PTP] = vsc7514_ptp_regmap,
-	[DEV_GMII] = vsc7514_dev_gmii_regmap,
-};
-
 static void ocelot_pll5_init(struct ocelot *ocelot)
 {
 	/* Configure PLL5. This will need a proper CCF driver
@@ -72,7 +59,7 @@ static int ocelot_chip_init(struct ocelot *ocelot, const struct ocelot_ops *ops)
 {
 	int ret;
 
-	ocelot->map = ocelot_regmap;
+	ocelot->map = vsc7514_regmap;
 	ocelot->stats_layout = vsc7514_stats_layout;
 	ocelot->num_mact_rows = 1024;
 	ocelot->ops = ops;
diff --git a/drivers/net/ethernet/mscc/vsc7514_regs.c b/drivers/net/ethernet/mscc/vsc7514_regs.c
index c943da4dd1f1..3a0b6307a13a 100644
--- a/drivers/net/ethernet/mscc/vsc7514_regs.c
+++ b/drivers/net/ethernet/mscc/vsc7514_regs.c
@@ -434,6 +434,20 @@ const u32 vsc7514_dev_gmii_regmap[] = {
 };
 EXPORT_SYMBOL(vsc7514_dev_gmii_regmap);
 
+const u32 *vsc7514_regmap[TARGET_MAX] = {
+	[ANA] = vsc7514_ana_regmap,
+	[QS] = vsc7514_qs_regmap,
+	[QSYS] = vsc7514_qsys_regmap,
+	[REW] = vsc7514_rew_regmap,
+	[SYS] = vsc7514_sys_regmap,
+	[S0] = vsc7514_vcap_regmap,
+	[S1] = vsc7514_vcap_regmap,
+	[S2] = vsc7514_vcap_regmap,
+	[PTP] = vsc7514_ptp_regmap,
+	[DEV_GMII] = vsc7514_dev_gmii_regmap,
+};
+EXPORT_SYMBOL(vsc7514_regmap);
+
 const struct vcap_field vsc7514_vcap_es0_keys[] = {
 	[VCAP_ES0_EGR_PORT]			= { 0,   4 },
 	[VCAP_ES0_IGR_PORT]			= { 4,   4 },
diff --git a/include/soc/mscc/vsc7514_regs.h b/include/soc/mscc/vsc7514_regs.h
index a939849efd91..38efc0fa73b1 100644
--- a/include/soc/mscc/vsc7514_regs.h
+++ b/include/soc/mscc/vsc7514_regs.h
@@ -25,6 +25,8 @@ extern const u32 vsc7514_vcap_regmap[];
 extern const u32 vsc7514_ptp_regmap[];
 extern const u32 vsc7514_dev_gmii_regmap[];
 
+extern const u32 *vsc7514_regmap[TARGET_MAX];
+
 extern const struct vcap_field vsc7514_vcap_es0_keys[];
 extern const struct vcap_field vsc7514_vcap_es0_actions[];
 extern const struct vcap_field vsc7514_vcap_is1_keys[];
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 07/17] net: dsa: felix: add configurable device quirks
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
                   ` (5 preceding siblings ...)
  2022-10-08 18:51 ` [RFC v4 net-next 06/17] net: mscc: ocelot: expose vsc7514_regmap definition Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-08 18:51 ` [RFC v4 net-next 08/17] net: dsa: felix: populate mac_capabilities for all ports Colin Foster
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones, Vladimir Oltean

The define FELIX_MAC_QUIRKS was used directly in the felix.c shared driver.
Other devices (VSC7512 for example) don't require the same quirks, so they
need to be configured on a per-device basis.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---

v2-v4
    * No changes

v1 from previous RFC:
    * No changes

---
 drivers/net/dsa/ocelot/felix.c           | 7 +++++--
 drivers/net/dsa/ocelot/felix.h           | 1 +
 drivers/net/dsa/ocelot/felix_vsc9959.c   | 1 +
 drivers/net/dsa/ocelot/seville_vsc9953.c | 1 +
 4 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index dd3a18cc89dd..d56f6f67f648 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -1082,9 +1082,12 @@ static void felix_phylink_mac_link_down(struct dsa_switch *ds, int port,
 					phy_interface_t interface)
 {
 	struct ocelot *ocelot = ds->priv;
+	struct felix *felix;
+
+	felix = ocelot_to_felix(ocelot);
 
 	ocelot_phylink_mac_link_down(ocelot, port, link_an_mode, interface,
-				     FELIX_MAC_QUIRKS);
+				     felix->info->quirks);
 }
 
 static void felix_phylink_mac_link_up(struct dsa_switch *ds, int port,
@@ -1099,7 +1102,7 @@ static void felix_phylink_mac_link_up(struct dsa_switch *ds, int port,
 
 	ocelot_phylink_mac_link_up(ocelot, port, phydev, link_an_mode,
 				   interface, speed, duplex, tx_pause, rx_pause,
-				   FELIX_MAC_QUIRKS);
+				   felix->info->quirks);
 
 	if (felix->info->port_sched_speed_set)
 		felix->info->port_sched_speed_set(ocelot, port, speed);
diff --git a/drivers/net/dsa/ocelot/felix.h b/drivers/net/dsa/ocelot/felix.h
index c9c29999c336..e6b7021036c2 100644
--- a/drivers/net/dsa/ocelot/felix.h
+++ b/drivers/net/dsa/ocelot/felix.h
@@ -37,6 +37,7 @@ struct felix_info {
 	u16				vcap_pol_base2;
 	u16				vcap_pol_max2;
 	const struct ptp_clock_info	*ptp_caps;
+	unsigned long			quirks;
 
 	/* Some Ocelot switches are integrated into the SoC without the
 	 * extraction IRQ line connected to the ARM GIC. By enabling this
diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
index 26a35ae322d1..8999c523c0be 100644
--- a/drivers/net/dsa/ocelot/felix_vsc9959.c
+++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
@@ -2584,6 +2584,7 @@ static const struct felix_info felix_info_vsc9959 = {
 	.num_mact_rows		= 2048,
 	.num_ports		= VSC9959_NUM_PORTS,
 	.num_tx_queues		= OCELOT_NUM_TC,
+	.quirks			= FELIX_MAC_QUIRKS,
 	.quirk_no_xtr_irq	= true,
 	.ptp_caps		= &vsc9959_ptp_caps,
 	.mdio_bus_alloc		= vsc9959_mdio_bus_alloc,
diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c
index 7af33b2c685d..3e2f988b2b40 100644
--- a/drivers/net/dsa/ocelot/seville_vsc9953.c
+++ b/drivers/net/dsa/ocelot/seville_vsc9953.c
@@ -1002,6 +1002,7 @@ static const struct felix_info seville_info_vsc9953 = {
 	.vcap_pol_max		= VSC9953_VCAP_POLICER_MAX,
 	.vcap_pol_base2		= VSC9953_VCAP_POLICER_BASE2,
 	.vcap_pol_max2		= VSC9953_VCAP_POLICER_MAX2,
+	.quirks			= FELIX_MAC_QUIRKS,
 	.num_mact_rows		= 2048,
 	.num_ports		= VSC9953_NUM_PORTS,
 	.num_tx_queues		= OCELOT_NUM_TC,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 08/17] net: dsa: felix: populate mac_capabilities for all ports
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
                   ` (6 preceding siblings ...)
  2022-10-08 18:51 ` [RFC v4 net-next 07/17] net: dsa: felix: add configurable device quirks Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-08 18:51 ` [RFC v4 net-next 09/17] net: dsa: felix: add support for MFD configurations Colin Foster
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

phylink_generic_validate() requires that mac_capabilities is correctly
populated. While no existing felix drivers have used
phylink_generic_validate(), the ocelot_ext.c driver will. Populate this
element so the use of existing functions is possible.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v3-v4
    * No change

v2
    * Updated commit message to indicate "no existing felix drivers"
      instead of "no existing drivers"

v1 from previous RFC:
    * New patch

---
 drivers/net/dsa/ocelot/felix.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index d56f6f67f648..1d938675bd3a 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -1050,6 +1050,9 @@ static void felix_phylink_get_caps(struct dsa_switch *ds, int port,
 
 	__set_bit(ocelot->ports[port]->phy_mode,
 		  config->supported_interfaces);
+
+	config->mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE | MAC_10 |
+				   MAC_100 | MAC_1000FD | MAC_2500FD;
 }
 
 static void felix_phylink_validate(struct dsa_switch *ds, int port,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 09/17] net: dsa: felix: add support for MFD configurations
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
                   ` (7 preceding siblings ...)
  2022-10-08 18:51 ` [RFC v4 net-next 08/17] net: dsa: felix: populate mac_capabilities for all ports Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-08 18:51 ` [RFC v4 net-next 10/17] net: dsa: felix: add functionality when not all ports are supported Colin Foster
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

The architecture around the VSC7512 differs from existing felix drivers. In
order to add support for all the chip's features (pinctrl, MDIO, gpio) the
device had to be laid out as a multi-function device (MFD).

One difference between an MFD and a standard platform device is that the
regmaps are allocated to the parent device before the child devices are
probed. As such, there is no need for felix to initialize new regmaps in
these configurations, they can simply be requested from the parent device.

Add support for MFD configurations by performing this request from the
parent device.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v4
    * New patch

---
 drivers/net/dsa/ocelot/felix.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index 1d938675bd3a..fb0a0f7e42ac 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -1325,6 +1325,13 @@ static struct regmap *felix_request_regmap_by_name(struct felix *felix,
 	struct resource res;
 	int i;
 
+	/* In an MFD configuration, regmaps are registered directly to the
+	 * parent device before the child devices are probed, so there is no
+	 * need to initialize a new one.
+	 */
+	if (!felix->info->resources)
+		return dev_get_regmap(ocelot->dev->parent, resource_name);
+
 	for (i = 0; i < felix->info->num_resources; i++) {
 		if (strcmp(resource_name, felix->info->resources[i].name))
 			continue;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 10/17] net: dsa: felix: add functionality when not all ports are supported
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
                   ` (8 preceding siblings ...)
  2022-10-08 18:51 ` [RFC v4 net-next 09/17] net: dsa: felix: add support for MFD configurations Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-08 18:51 ` [RFC v4 net-next 11/17] mfd: ocelot: prepend resource size macros to be 32-bit Colin Foster
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

When the Felix driver would probe the ports and verify functionality, it
would fail if it hit single port mode that wasn't supported by the driver.

The initial case for the VSC7512 driver will have physical ports that
exist, but aren't supported by the driver implementation. Add the
OCELOT_PORT_MODE_NONE macro to handle this scenario, and allow the Felix
driver to continue with all the ports that are currently functional.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v4
    * New patch

---
 drivers/net/dsa/ocelot/felix.c | 11 ++++++++---
 drivers/net/dsa/ocelot/felix.h |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index fb0a0f7e42ac..70c3e4e203c2 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -1283,10 +1283,15 @@ static int felix_parse_ports_node(struct felix *felix,
 
 		err = felix_validate_phy_mode(felix, port, phy_mode);
 		if (err < 0) {
-			dev_err(dev, "Unsupported PHY mode %s on port %d\n",
-				phy_modes(phy_mode), port);
+			dev_info(dev, "Unsupported PHY mode %s on port %d\n",
+				 phy_modes(phy_mode), port);
 			of_node_put(child);
-			return err;
+
+			/* Leave port_phy_modes[port] = 0, which is also
+			 * PHY_INTERFACE_MODE_NA. This will perform a
+			 * best-effort to bring up as many ports as possible.
+			 */
+			continue;
 		}
 
 		port_phy_modes[port] = phy_mode;
diff --git a/drivers/net/dsa/ocelot/felix.h b/drivers/net/dsa/ocelot/felix.h
index e6b7021036c2..90e04df0276a 100644
--- a/drivers/net/dsa/ocelot/felix.h
+++ b/drivers/net/dsa/ocelot/felix.h
@@ -7,6 +7,7 @@
 #define ocelot_to_felix(o)		container_of((o), struct felix, ocelot)
 #define FELIX_MAC_QUIRKS		OCELOT_QUIRK_PCS_PERFORMS_RATE_ADAPTATION
 
+#define OCELOT_PORT_MODE_NONE		0
 #define OCELOT_PORT_MODE_INTERNAL	BIT(0)
 #define OCELOT_PORT_MODE_SGMII		BIT(1)
 #define OCELOT_PORT_MODE_QSGMII		BIT(2)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 11/17] mfd: ocelot: prepend resource size macros to be 32-bit
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
                   ` (9 preceding siblings ...)
  2022-10-08 18:51 ` [RFC v4 net-next 10/17] net: dsa: felix: add functionality when not all ports are supported Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-31  9:32   ` Lee Jones
  2022-10-08 18:51 ` [RFC v4 net-next 12/17] mfd: ocelot: add shared resource names for switch functionality Colin Foster
                   ` (6 subsequent siblings)
  17 siblings, 1 reply; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

The *_RES_SIZE macros are initally <= 0x100. Future resource sizes will be
upwards of 0x200000 in size.

To keep things clean, fully align the RES_SIZE macros to 32-bit to do
nothing more than make the code more consistent.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v3-v4
    * No change

v2
    * New patch - broken out from a different one

---
 drivers/mfd/ocelot-core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/ocelot-core.c b/drivers/mfd/ocelot-core.c
index 1816d52c65c5..013e83173062 100644
--- a/drivers/mfd/ocelot-core.c
+++ b/drivers/mfd/ocelot-core.c
@@ -34,16 +34,16 @@
 
 #define VSC7512_MIIM0_RES_START		0x7107009c
 #define VSC7512_MIIM1_RES_START		0x710700c0
-#define VSC7512_MIIM_RES_SIZE		0x024
+#define VSC7512_MIIM_RES_SIZE		0x00000024
 
 #define VSC7512_PHY_RES_START		0x710700f0
-#define VSC7512_PHY_RES_SIZE		0x004
+#define VSC7512_PHY_RES_SIZE		0x00000004
 
 #define VSC7512_GPIO_RES_START		0x71070034
-#define VSC7512_GPIO_RES_SIZE		0x06c
+#define VSC7512_GPIO_RES_SIZE		0x0000006c
 
 #define VSC7512_SIO_CTRL_RES_START	0x710700f8
-#define VSC7512_SIO_CTRL_RES_SIZE	0x100
+#define VSC7512_SIO_CTRL_RES_SIZE	0x00000100
 
 #define VSC7512_GCB_RST_SLEEP_US	100
 #define VSC7512_GCB_RST_TIMEOUT_US	100000
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 12/17] mfd: ocelot: add shared resource names for switch functionality
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
                   ` (10 preceding siblings ...)
  2022-10-08 18:51 ` [RFC v4 net-next 11/17] mfd: ocelot: prepend resource size macros to be 32-bit Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-31  9:35   ` Lee Jones
  2022-10-08 18:51 ` [RFC v4 net-next 13/17] dt-bindings: mfd: ocelot: remove spi-max-frequency from required properties Colin Foster
                   ` (5 subsequent siblings)
  17 siblings, 1 reply; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

The switch portion of the Ocelot chip relies on several resources. Define
the resource names here, so they can be referenced by both the switch
driver and the MFD.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v4
    * New patch. Previous versions had entire structures shared,
      this only requires that the names be shared.

---
 include/linux/mfd/ocelot.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/linux/mfd/ocelot.h b/include/linux/mfd/ocelot.h
index dd72073d2d4f..b80f2f5ff1d6 100644
--- a/include/linux/mfd/ocelot.h
+++ b/include/linux/mfd/ocelot.h
@@ -13,6 +13,15 @@
 
 struct resource;
 
+#define OCELOT_RES_NAME_ANA	"ana"
+#define OCELOT_RES_NAME_QS	"qs"
+#define OCELOT_RES_NAME_QSYS	"qsys"
+#define OCELOT_RES_NAME_REW	"rew"
+#define OCELOT_RES_NAME_SYS	"sys"
+#define OCELOT_RES_NAME_S0	"s0"
+#define OCELOT_RES_NAME_S1	"s1"
+#define OCELOT_RES_NAME_S2	"s2"
+
 static inline struct regmap *
 ocelot_regmap_from_resource_optional(struct platform_device *pdev,
 				     unsigned int index,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 13/17] dt-bindings: mfd: ocelot: remove spi-max-frequency from required properties
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
                   ` (11 preceding siblings ...)
  2022-10-08 18:51 ` [RFC v4 net-next 12/17] mfd: ocelot: add shared resource names for switch functionality Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-09 15:49   ` Krzysztof Kozlowski
  2022-10-08 18:51 ` [RFC v4 net-next 14/17] dt-bindings: mfd: ocelot: add ethernet-switch hardware support Colin Foster
                   ` (4 subsequent siblings)
  17 siblings, 1 reply; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

The property spi-max-frequency was initially documented as a required
property. It is not actually required, and will break bindings validation
if other control mediums (e.g. PCIe) are used.

Remove this property from the required arguments.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v4
    * New patch

---
 Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml b/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml
index 8bf45a5673a4..c6da91211a18 100644
--- a/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml
+++ b/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml
@@ -61,7 +61,6 @@ required:
   - reg
   - '#address-cells'
   - '#size-cells'
-  - spi-max-frequency
 
 additionalProperties: false
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 14/17] dt-bindings: mfd: ocelot: add ethernet-switch hardware support
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
                   ` (12 preceding siblings ...)
  2022-10-08 18:51 ` [RFC v4 net-next 13/17] dt-bindings: mfd: ocelot: remove spi-max-frequency from required properties Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-09 15:52   ` Krzysztof Kozlowski
  2022-10-08 18:51 ` [RFC v4 net-next 15/17] dt-bindings: net: dsa: ocelot: add ocelot-ext documentation Colin Foster
                   ` (3 subsequent siblings)
  17 siblings, 1 reply; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

The main purpose of the Ocelot chips are the Ethernet switching
functionalities. Document the support for these features.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v4
    * New patch

---
 Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml b/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml
index c6da91211a18..9ad42721418c 100644
--- a/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml
+++ b/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml
@@ -56,6 +56,14 @@ patternProperties:
         enum:
           - mscc,ocelot-miim
 
+  "^ethernet-switch@[0-9a-f]+$":
+    type: object
+    $ref: /schemas/net/dsa/mscc,ocelot.yaml
+    properties:
+      compatible:
+        enum:
+          - mscc,vsc7512-switch
+
 required:
   - compatible
   - reg
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 15/17] dt-bindings: net: dsa: ocelot: add ocelot-ext documentation
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
                   ` (13 preceding siblings ...)
  2022-10-08 18:51 ` [RFC v4 net-next 14/17] dt-bindings: mfd: ocelot: add ethernet-switch hardware support Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-09 15:58   ` Krzysztof Kozlowski
  2022-10-08 18:51 ` [RFC v4 net-next 16/17] net: dsa: ocelot: add external ocelot switch control Colin Foster
                   ` (2 subsequent siblings)
  17 siblings, 1 reply; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

The ocelot-ext driver is another sub-device of the Ocelot / Felix driver
system. It requires a register array similar to the VSC7514 and has
different ports layout than existing devices.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v4
    * Add documentation for all supported modes (qsgmii / sgmii)
    * /s/7412/7512
    * Changes to match the VSC7514 device tree, including:
      - Replace ethernet-switch@0 to ethernet-switch@71010000
      - Add all reg / reg-names entries
    * Add example entries for ports 4-7, which requires phy-ocelot-serdes.h
    * Add the last sentence to the commit description, which replaces
      the phrase "which currently supports the four internal copper
      phys"
    * Remove "spi {" node from the documentation
    * Remove "cpu" label from port 0
    * Add "soc { reg = <0 0>;" to fix dt_binding_check warning

v3
    * Remove "currently supported" verbage
        The Seville and Felix 9959 all list their supported modes following
        the sentence "The following PHY interface types are supported".
        During V2, I had used "currently supported" to suggest more interface
        modes are around the corner, though this had raised questions.

        The suggestion was to drop the entire sentence. I did leave the
        modified sentence there because it exactly matches the other two
        supported products.

v2
    * New patch

---
 .../bindings/net/dsa/mscc,ocelot.yaml         | 112 ++++++++++++++++++
 1 file changed, 112 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/dsa/mscc,ocelot.yaml b/Documentation/devicetree/bindings/net/dsa/mscc,ocelot.yaml
index 8d93ed9c172c..8a73fc9dbcaa 100644
--- a/Documentation/devicetree/bindings/net/dsa/mscc,ocelot.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/mscc,ocelot.yaml
@@ -54,9 +54,24 @@ description: |
       - phy-mode = "1000base-x": on ports 0, 1, 2, 3
       - phy-mode = "2500base-x": on ports 0, 1, 2, 3
 
+  VSC7512 (Ocelot-Ext):
+
+    The Ocelot family consists of four devices, the VSC7511, VSC7512, VSC7513,
+    and the VSC7514. The VSC7513 and VSC7514 both have an internal MIPS
+    processor that natively support Linux. Additionally, all four devices
+    support control over external interfaces, SPI and PCIe. The Ocelot-Ext
+    driver is for the external control portion.
+
+    The following PHY interface types are supported:
+
+      - phy-mode = "internal": on ports 0, 1, 2, 3
+      - phy-mode = "sgmii": on ports 4, 5, 7, 8, 9, 10
+      - phy-mode = "qsgmii": on ports 4, 5, 6, 7, 8, 10
+
 properties:
   compatible:
     enum:
+      - mscc,vsc7512-switch
       - mscc,vsc9953-switch
       - pci1957,eef0
 
@@ -258,3 +273,100 @@ examples:
             };
         };
     };
+  # Ocelot-ext VSC7512
+  - |
+    #include <dt-bindings/phy/phy-ocelot-serdes.h>
+
+    soc@0 {
+        compatible = "mscc,vsc7512";
+        #address-cells = <1>;
+        #size-cells = <1>;
+        reg = <0 0>;
+
+        ethernet-switch@0 {
+            compatible = "mscc,vsc7512-switch";
+            reg = <0x71010000 0x00010000>,
+                  <0x71030000 0x00010000>,
+                  <0x71080000 0x00000100>,
+                  <0x710e0000 0x00010000>,
+                  <0x711e0000 0x00000100>,
+                  <0x711f0000 0x00000100>,
+                  <0x71200000 0x00000100>,
+                  <0x71210000 0x00000100>,
+                  <0x71220000 0x00000100>,
+                  <0x71230000 0x00000100>,
+                  <0x71240000 0x00000100>,
+                  <0x71250000 0x00000100>,
+                  <0x71260000 0x00000100>,
+                  <0x71270000 0x00000100>,
+                  <0x71280000 0x00000100>,
+                  <0x71800000 0x00080000>,
+                  <0x71880000 0x00010000>,
+                  <0x71040000 0x00010000>,
+                  <0x71050000 0x00010000>,
+                  <0x71060000 0x00010000>;
+            reg-names = "sys", "rew", "qs", "ptp", "port0", "port1",
+                        "port2", "port3", "port4", "port5", "port6",
+                        "port7", "port8", "port9", "port10", "qsys",
+                        "ana", "s0", "s1", "s2";
+
+            ethernet-ports {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                port@0 {
+                    reg = <0>;
+                    ethernet = <&mac_sw>;
+                    phy-handle = <&phy0>;
+                    phy-mode = "internal";
+                };
+
+                port@1 {
+                    reg = <1>;
+                    label = "swp1";
+                    phy-mode = "internal";
+                    phy-handle = <&phy1>;
+                };
+
+                port@2 {
+                    reg = <2>;
+                    phy-mode = "internal";
+                    phy-handle = <&phy2>;
+                };
+
+                port@3 {
+                    reg = <3>;
+                    phy-mode = "internal";
+                    phy-handle = <&phy3>;
+                };
+
+                port@4 {
+                    reg = <4>;
+                    phy-mode = "qsgmii";
+                    phy-handle = <&phy4>;
+                    phys = <&serdes 4 SERDES6G(0)>;
+                };
+
+                port@5 {
+                    reg = <5>;
+                    phy-mode = "qsgmii";
+                    phy-handle = <&phy5>;
+                    phys = <&serdes 5 SERDES6G(0)>;
+                };
+
+                port@6 {
+                    reg = <6>;
+                    phy-mode = "qsgmii";
+                    phy-handle = <&phy6>;
+                    phys = <&serdes 6 SERDES6G(0)>;
+                };
+
+                port@7 {
+                    reg = <7>;
+                    phy-mode = "qsgmii";
+                    phy-handle = <&phy7>;
+                    phys = <&serdes 7 SERDES6G(0)>;
+                };
+            };
+        };
+    };
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 16/17] net: dsa: ocelot: add external ocelot switch control
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
                   ` (14 preceding siblings ...)
  2022-10-08 18:51 ` [RFC v4 net-next 15/17] dt-bindings: net: dsa: ocelot: add ocelot-ext documentation Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-08 18:51 ` [RFC v4 net-next 17/17] mfd: " Colin Foster
  2022-10-08 23:35 ` [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Vladimir Oltean
  17 siblings, 0 replies; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

Add control of an external VSC7512 chip.

Currently the four copper phy ports are fully functional. Communication to
external phys is also functional, but the SGMII / QSGMII interfaces are
currently non-functional.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v4
    * Add forward-compatibility for device trees that have ports 4-7
      defined by saying they are OCELOT_PORT_MODE_NONE
    * Utilize new "resource_names" instead of "*_io_res". Many thanks
      to Vladimir for making this possible.
      - Also remove ocelot_ext_regmap_init() function
    * Remove dev_set_drvdata(dev, NULL) from remove() to match other
      drivers

v3
    * Remove additional entry in vsc7512_port_modes array
    * Add MFD_OCELOT namespace import, which is needed for
      vsc7512_*_io_res

v2
    * Add MAINTAINERS update
    * Remove phrase "by way of the ocelot-mfd interface" from the commit
      message
    * Move MFD resource addition to a separate patch
    * Update Kconfig help
    * Remove "ocelot_ext_reset()" - it is now shared with ocelot_lib
    * Remove unnecessary includes
    * Remove "_EXT" from OCELOT_EXT_PORT_MODE_SERDES
    * Remove _ext from the compatible string
    * Remove no-longer-necessary GCB register definitions

v1 from previous RFC:
    * Remove unnecessary byteorder and kconfig header includes.
    * Create OCELOT_EXT_PORT_MODE_SERDES macro to match vsc9959.
    * Utilize readx_poll_timeout for SYS_RESET_CFG_MEM_INIT.
    * *_io_res struct arrays have been moved to the MFD files.
    * Changes to utilize phylink_generic_validate() have been squashed.
    * dev_err_probe() is used in the probe function.
    * Make ocelot_ext_switch_of_match static.
    * Relocate ocelot_ext_ops structure to be next to vsc7512_info, to
      match what was done in other felix drivers.
    * Utilize dev_get_regmap() instead of the obsolete
      ocelot_init_regmap_from_resource() routine.

---
 MAINTAINERS                         |   1 +
 drivers/net/dsa/ocelot/Kconfig      |  19 +++
 drivers/net/dsa/ocelot/Makefile     |   5 +
 drivers/net/dsa/ocelot/ocelot_ext.c | 178 ++++++++++++++++++++++++++++
 4 files changed, 203 insertions(+)
 create mode 100644 drivers/net/dsa/ocelot/ocelot_ext.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 9ca84cb5ab4a..15593f0dd128 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14751,6 +14751,7 @@ M:	Colin Foster <colin.foster@in-advantage.com>
 S:	Supported
 F:	Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml
 F:	drivers/mfd/ocelot*
+F:	drivers/net/dsa/ocelot/ocelot_ext.c
 F:	include/linux/mfd/ocelot.h
 
 OCXL (Open Coherent Accelerator Processor Interface OpenCAPI) DRIVER
diff --git a/drivers/net/dsa/ocelot/Kconfig b/drivers/net/dsa/ocelot/Kconfig
index 08db9cf76818..74a900e16d76 100644
--- a/drivers/net/dsa/ocelot/Kconfig
+++ b/drivers/net/dsa/ocelot/Kconfig
@@ -1,4 +1,23 @@
 # SPDX-License-Identifier: GPL-2.0-only
+config NET_DSA_MSCC_OCELOT_EXT
+	tristate "Ocelot External Ethernet switch support"
+	depends on NET_DSA && SPI
+	depends on NET_VENDOR_MICROSEMI
+	select MDIO_MSCC_MIIM
+	select MFD_OCELOT_CORE
+	select MSCC_OCELOT_SWITCH_LIB
+	select NET_DSA_TAG_OCELOT_8021Q
+	select NET_DSA_TAG_OCELOT
+	help
+	  This driver supports the VSC7511, VSC7512, VSC7513 and VSC7514 chips
+	  when controlled through SPI.
+
+	  The Ocelot switch family is a set of multi-port networking chips. All
+	  of these chips have the ability to be controlled externally through
+	  SPI or PCIe interfaces.
+
+	  Say "Y" here to enable external control to these chips.
+
 config NET_DSA_MSCC_FELIX
 	tristate "Ocelot / Felix Ethernet switch support"
 	depends on NET_DSA && PCI
diff --git a/drivers/net/dsa/ocelot/Makefile b/drivers/net/dsa/ocelot/Makefile
index f6dd131e7491..d7f3f5a4461c 100644
--- a/drivers/net/dsa/ocelot/Makefile
+++ b/drivers/net/dsa/ocelot/Makefile
@@ -1,11 +1,16 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_NET_DSA_MSCC_FELIX) += mscc_felix.o
+obj-$(CONFIG_NET_DSA_MSCC_OCELOT_EXT) += mscc_ocelot_ext.o
 obj-$(CONFIG_NET_DSA_MSCC_SEVILLE) += mscc_seville.o
 
 mscc_felix-objs := \
 	felix.o \
 	felix_vsc9959.o
 
+mscc_ocelot_ext-objs := \
+	felix.o \
+	ocelot_ext.o
+
 mscc_seville-objs := \
 	felix.o \
 	seville_vsc9953.o
diff --git a/drivers/net/dsa/ocelot/ocelot_ext.c b/drivers/net/dsa/ocelot/ocelot_ext.c
new file mode 100644
index 000000000000..1340b017e37d
--- /dev/null
+++ b/drivers/net/dsa/ocelot/ocelot_ext.c
@@ -0,0 +1,178 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright 2021-2022 Innovative Advantage Inc.
+ */
+
+#include <linux/mfd/ocelot.h>
+#include <linux/phylink.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <soc/mscc/ocelot.h>
+#include <soc/mscc/vsc7514_regs.h>
+#include "felix.h"
+
+#define VSC7514_NUM_PORTS		11
+
+#define OCELOT_PORT_MODE_SERDES		(OCELOT_PORT_MODE_SGMII | \
+					 OCELOT_PORT_MODE_QSGMII)
+
+static const u32 vsc7512_port_modes[VSC7514_NUM_PORTS] = {
+	OCELOT_PORT_MODE_INTERNAL,
+	OCELOT_PORT_MODE_INTERNAL,
+	OCELOT_PORT_MODE_INTERNAL,
+	OCELOT_PORT_MODE_INTERNAL,
+	OCELOT_PORT_MODE_NONE,
+	OCELOT_PORT_MODE_NONE,
+	OCELOT_PORT_MODE_NONE,
+	OCELOT_PORT_MODE_NONE,
+	OCELOT_PORT_MODE_NONE,
+	OCELOT_PORT_MODE_NONE,
+	OCELOT_PORT_MODE_NONE,
+};
+
+static void ocelot_ext_phylink_validate(struct ocelot *ocelot, int port,
+					unsigned long *supported,
+					struct phylink_link_state *state)
+{
+	struct felix *felix = ocelot_to_felix(ocelot);
+	struct dsa_switch *ds = felix->ds;
+	struct dsa_port *dp;
+
+	dp = dsa_to_port(ds, port);
+
+	phylink_generic_validate(&dp->pl_config, supported, state);
+}
+
+static const struct ocelot_ops ocelot_ext_ops = {
+	.reset		= ocelot_reset,
+	.wm_enc		= ocelot_wm_enc,
+	.wm_dec		= ocelot_wm_dec,
+	.wm_stat	= ocelot_wm_stat,
+	.port_to_netdev	= felix_port_to_netdev,
+	.netdev_to_port	= felix_netdev_to_port,
+};
+
+static const char * const vsc7512_resource_names[TARGET_MAX] = {
+	[SYS] = OCELOT_RES_NAME_SYS,
+	[REW] = OCELOT_RES_NAME_REW,
+	[S0] = OCELOT_RES_NAME_S0,
+	[S1] = OCELOT_RES_NAME_S1,
+	[S2] = OCELOT_RES_NAME_S2,
+	[QS] = OCELOT_RES_NAME_QS,
+	[QSYS] = OCELOT_RES_NAME_QSYS,
+	[ANA] = OCELOT_RES_NAME_ANA,
+};
+
+static const struct felix_info vsc7512_info = {
+	.resource_names			= vsc7512_resource_names,
+	.regfields			= vsc7514_regfields,
+	.map				= vsc7514_regmap,
+	.ops				= &ocelot_ext_ops,
+	.stats_layout			= vsc7514_stats_layout,
+	.vcap				= vsc7514_vcap_props,
+	.num_mact_rows			= 1024,
+	.num_ports			= VSC7514_NUM_PORTS,
+	.num_tx_queues			= OCELOT_NUM_TC,
+	.phylink_validate		= ocelot_ext_phylink_validate,
+	.port_modes			= vsc7512_port_modes,
+};
+
+static int ocelot_ext_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct dsa_switch *ds;
+	struct ocelot *ocelot;
+	struct felix *felix;
+	int err;
+
+	felix = kzalloc(sizeof(*felix), GFP_KERNEL);
+	if (!felix)
+		return -ENOMEM;
+
+	dev_set_drvdata(dev, felix);
+
+	ocelot = &felix->ocelot;
+	ocelot->dev = dev;
+
+	ocelot->num_flooding_pgids = 1;
+
+	felix->info = &vsc7512_info;
+
+	ds = kzalloc(sizeof(*ds), GFP_KERNEL);
+	if (!ds) {
+		err = -ENOMEM;
+		dev_err_probe(dev, err, "Failed to allocate DSA switch\n");
+		goto err_free_felix;
+	}
+
+	ds->dev = dev;
+	ds->num_ports = felix->info->num_ports;
+	ds->num_tx_queues = felix->info->num_tx_queues;
+
+	ds->ops = &felix_switch_ops;
+	ds->priv = ocelot;
+	felix->ds = ds;
+	felix->tag_proto = DSA_TAG_PROTO_OCELOT;
+
+	err = dsa_register_switch(ds);
+	if (err) {
+		dev_err_probe(dev, err, "Failed to register DSA switch\n");
+		goto err_free_ds;
+	}
+
+	return 0;
+
+err_free_ds:
+	kfree(ds);
+err_free_felix:
+	kfree(felix);
+	return err;
+}
+
+static int ocelot_ext_remove(struct platform_device *pdev)
+{
+	struct felix *felix = dev_get_drvdata(&pdev->dev);
+
+	if (!felix)
+		return 0;
+
+	dsa_unregister_switch(felix->ds);
+
+	kfree(felix->ds);
+	kfree(felix);
+
+	return 0;
+}
+
+static void ocelot_ext_shutdown(struct platform_device *pdev)
+{
+	struct felix *felix = dev_get_drvdata(&pdev->dev);
+
+	if (!felix)
+		return;
+
+	dsa_switch_shutdown(felix->ds);
+
+	dev_set_drvdata(&pdev->dev, NULL);
+}
+
+static const struct of_device_id ocelot_ext_switch_of_match[] = {
+	{ .compatible = "mscc,vsc7512-switch" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, ocelot_ext_switch_of_match);
+
+static struct platform_driver ocelot_ext_switch_driver = {
+	.driver = {
+		.name = "ocelot-switch",
+		.of_match_table = of_match_ptr(ocelot_ext_switch_of_match),
+	},
+	.probe = ocelot_ext_probe,
+	.remove = ocelot_ext_remove,
+	.shutdown = ocelot_ext_shutdown,
+};
+module_platform_driver(ocelot_ext_switch_driver);
+
+MODULE_DESCRIPTION("External Ocelot Switch driver");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(MFD_OCELOT);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC v4 net-next 17/17] mfd: ocelot: add external ocelot switch control
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
                   ` (15 preceding siblings ...)
  2022-10-08 18:51 ` [RFC v4 net-next 16/17] net: dsa: ocelot: add external ocelot switch control Colin Foster
@ 2022-10-08 18:51 ` Colin Foster
  2022-10-31  9:36   ` Lee Jones
  2022-10-08 23:35 ` [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Vladimir Oltean
  17 siblings, 1 reply; 27+ messages in thread
From: Colin Foster @ 2022-10-08 18:51 UTC (permalink / raw)
  To: netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

Utilize the existing ocelot MFD interface to add switch functionality to
the Microsemi VSC7512 chip.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v4
    * Integrate a different patch, so now this one
      - Adds the resources during this patch. Previouisly this
        was done in a separate patch
      - Utilize the standard {,num_}resources initializer

v3
    * No change

v2
    * New patch, broken out from a previous one

---
 drivers/mfd/ocelot-core.c | 60 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/drivers/mfd/ocelot-core.c b/drivers/mfd/ocelot-core.c
index 013e83173062..f35b4b2d4eec 100644
--- a/drivers/mfd/ocelot-core.c
+++ b/drivers/mfd/ocelot-core.c
@@ -45,6 +45,39 @@
 #define VSC7512_SIO_CTRL_RES_START	0x710700f8
 #define VSC7512_SIO_CTRL_RES_SIZE	0x00000100
 
+#define VSC7512_ANA_RES_START		0x71880000
+#define VSC7512_ANA_RES_SIZE		0x00010000
+
+#define VSC7512_QS_RES_START		0x71080000
+#define VSC7512_QS_RES_SIZE		0x00000100
+
+#define VSC7512_QSYS_RES_START		0x71800000
+#define VSC7512_QSYS_RES_SIZE		0x00200000
+
+#define VSC7512_REW_RES_START		0x71030000
+#define VSC7512_REW_RES_SIZE		0x00010000
+
+#define VSC7512_SYS_RES_START		0x71010000
+#define VSC7512_SYS_RES_SIZE		0x00010000
+
+#define VSC7512_S0_RES_START		0x71040000
+#define VSC7512_S1_RES_START		0x71050000
+#define VSC7512_S2_RES_START		0x71060000
+#define VCAP_RES_SIZE			0x00000400
+
+#define VSC7512_PORT_0_RES_START	0x711e0000
+#define VSC7512_PORT_1_RES_START	0x711f0000
+#define VSC7512_PORT_2_RES_START	0x71200000
+#define VSC7512_PORT_3_RES_START	0x71210000
+#define VSC7512_PORT_4_RES_START	0x71220000
+#define VSC7512_PORT_5_RES_START	0x71230000
+#define VSC7512_PORT_6_RES_START	0x71240000
+#define VSC7512_PORT_7_RES_START	0x71250000
+#define VSC7512_PORT_8_RES_START	0x71260000
+#define VSC7512_PORT_9_RES_START	0x71270000
+#define VSC7512_PORT_10_RES_START	0x71280000
+#define VSC7512_PORT_RES_SIZE		0x00010000
+
 #define VSC7512_GCB_RST_SLEEP_US	100
 #define VSC7512_GCB_RST_TIMEOUT_US	100000
 
@@ -96,6 +129,28 @@ static const struct resource vsc7512_sgpio_resources[] = {
 	DEFINE_RES_REG_NAMED(VSC7512_SIO_CTRL_RES_START, VSC7512_SIO_CTRL_RES_SIZE, "gcb_sio"),
 };
 
+static const struct resource vsc7512_switch_resources[] = {
+	DEFINE_RES_REG_NAMED(VSC7512_ANA_RES_START, VSC7512_ANA_RES_SIZE, OCELOT_RES_NAME_ANA),
+	DEFINE_RES_REG_NAMED(VSC7512_QS_RES_START, VSC7512_QS_RES_SIZE, OCELOT_RES_NAME_QS),
+	DEFINE_RES_REG_NAMED(VSC7512_QSYS_RES_START, VSC7512_QSYS_RES_SIZE, OCELOT_RES_NAME_QSYS),
+	DEFINE_RES_REG_NAMED(VSC7512_REW_RES_START, VSC7512_REW_RES_SIZE, OCELOT_RES_NAME_REW),
+	DEFINE_RES_REG_NAMED(VSC7512_SYS_RES_START, VSC7512_SYS_RES_SIZE, OCELOT_RES_NAME_SYS),
+	DEFINE_RES_REG_NAMED(VSC7512_S0_RES_START, VCAP_RES_SIZE, OCELOT_RES_NAME_S0),
+	DEFINE_RES_REG_NAMED(VSC7512_S1_RES_START, VCAP_RES_SIZE, OCELOT_RES_NAME_S1),
+	DEFINE_RES_REG_NAMED(VSC7512_S2_RES_START, VCAP_RES_SIZE, OCELOT_RES_NAME_S2),
+	DEFINE_RES_REG_NAMED(VSC7512_PORT_0_RES_START, VSC7512_PORT_RES_SIZE, "port0"),
+	DEFINE_RES_REG_NAMED(VSC7512_PORT_1_RES_START, VSC7512_PORT_RES_SIZE, "port1"),
+	DEFINE_RES_REG_NAMED(VSC7512_PORT_2_RES_START, VSC7512_PORT_RES_SIZE, "port2"),
+	DEFINE_RES_REG_NAMED(VSC7512_PORT_3_RES_START, VSC7512_PORT_RES_SIZE, "port3"),
+	DEFINE_RES_REG_NAMED(VSC7512_PORT_4_RES_START, VSC7512_PORT_RES_SIZE, "port4"),
+	DEFINE_RES_REG_NAMED(VSC7512_PORT_5_RES_START, VSC7512_PORT_RES_SIZE, "port5"),
+	DEFINE_RES_REG_NAMED(VSC7512_PORT_6_RES_START, VSC7512_PORT_RES_SIZE, "port6"),
+	DEFINE_RES_REG_NAMED(VSC7512_PORT_7_RES_START, VSC7512_PORT_RES_SIZE, "port7"),
+	DEFINE_RES_REG_NAMED(VSC7512_PORT_8_RES_START, VSC7512_PORT_RES_SIZE, "port8"),
+	DEFINE_RES_REG_NAMED(VSC7512_PORT_9_RES_START, VSC7512_PORT_RES_SIZE, "port9"),
+	DEFINE_RES_REG_NAMED(VSC7512_PORT_10_RES_START, VSC7512_PORT_RES_SIZE, "port10")
+};
+
 static const struct mfd_cell vsc7512_devs[] = {
 	{
 		.name = "ocelot-pinctrl",
@@ -121,6 +176,11 @@ static const struct mfd_cell vsc7512_devs[] = {
 		.use_of_reg = true,
 		.num_resources = ARRAY_SIZE(vsc7512_miim1_resources),
 		.resources = vsc7512_miim1_resources,
+	}, {
+		.name = "ocelot-switch",
+		.of_compatible = "mscc,vsc7512-switch",
+		.num_resources = ARRAY_SIZE(vsc7512_switch_resources),
+		.resources = vsc7512_switch_resources,
 	},
 };
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys
  2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
                   ` (16 preceding siblings ...)
  2022-10-08 18:51 ` [RFC v4 net-next 17/17] mfd: " Colin Foster
@ 2022-10-08 23:35 ` Vladimir Oltean
  17 siblings, 0 replies; 27+ messages in thread
From: Vladimir Oltean @ 2022-10-08 23:35 UTC (permalink / raw)
  To: Colin Foster
  Cc: netdev, linux-kernel, devicetree, Russell King, UNGLinuxDriver,
	Alexandre Belloni, Claudiu Manoil, Paolo Abeni, Jakub Kicinski,
	Eric Dumazet, David S. Miller, Florian Fainelli, Vivien Didelot,
	Andrew Lunn, Krzysztof Kozlowski, Rob Herring, Lee Jones

On Sat, Oct 08, 2022 at 11:51:35AM -0700, Colin Foster wrote:
> The only warning I know about is about the reg array being too long:
> /Documentation/devicetree/bindings/net/dsa/mscc,ocelot.example.dtb: soc@0: ethernet-switch@0:reg: [[1895890944, 65536], [1896022016, 65536], [1896349696, 256], [1896742912, 65536], [1897791488, 256], [1897857024, 256], [1897922560, 256], [1897988096, 256], [1898053632, 256], [1898119168, 256], [1898184704, 256], [1898250240, 256], [1898315776, 256], [1898381312, 256], [1898446848, 256], [1904214016, 524288], [1904738304, 65536], [1896087552, 65536], [1896153088, 65536], [1896218624, 65536]] is too long
> 
> Also I know there is still ongoing discussion regarding what the documentation
> should reflect. I hope I'm not getting ahead of myself by submitting this
> RFC at this time.

This is because 'reg' is longer than the schema was told it would be.
net/dsa/mscc,ocelot.yaml defines 'reg' with maxItems: 1, whereas
net/mscc,vsc7514-switch.yaml lists out all targets.

At this stage I wonder whether it wouldn't be better for you to patch up
net/mscc,vsc7514-switch.yaml with support for your compatible string and
reference dsa.yaml, rather than net/dsa/mscc,ocelot.yaml which should
perhaps be rebranded to make it clear it only applies to NXP
integrations of Microchip switches.

I also expressed something along these lines yesterday
https://lore.kernel.org/netdev/20221007231009.qgcirfezgib5vu6y@skbuf/
and I'd wait for a little bit more, to give Krzysztof a chance to
respond and share his thoughts.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC v4 net-next 13/17] dt-bindings: mfd: ocelot: remove spi-max-frequency from required properties
  2022-10-08 18:51 ` [RFC v4 net-next 13/17] dt-bindings: mfd: ocelot: remove spi-max-frequency from required properties Colin Foster
@ 2022-10-09 15:49   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 27+ messages in thread
From: Krzysztof Kozlowski @ 2022-10-09 15:49 UTC (permalink / raw)
  To: Colin Foster, netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

On 08/10/2022 20:51, Colin Foster wrote:
> The property spi-max-frequency was initially documented as a required
> property. It is not actually required, and will break bindings validation
> if other control mediums (e.g. PCIe) are used.
> 
> Remove this property from the required arguments.
> 
> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>


Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC v4 net-next 14/17] dt-bindings: mfd: ocelot: add ethernet-switch hardware support
  2022-10-08 18:51 ` [RFC v4 net-next 14/17] dt-bindings: mfd: ocelot: add ethernet-switch hardware support Colin Foster
@ 2022-10-09 15:52   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 27+ messages in thread
From: Krzysztof Kozlowski @ 2022-10-09 15:52 UTC (permalink / raw)
  To: Colin Foster, netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

On 08/10/2022 20:51, Colin Foster wrote:
> The main purpose of the Ocelot chips are the Ethernet switching
> functionalities. Document the support for these features.
> 
> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> ---
> 
> v4
>     * New patch
> 
> ---
>  Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml b/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml
> index c6da91211a18..9ad42721418c 100644
> --- a/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml
> +++ b/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml
> @@ -56,6 +56,14 @@ patternProperties:
>          enum:
>            - mscc,ocelot-miim
>  
> +  "^ethernet-switch@[0-9a-f]+$":
> +    type: object
> +    $ref: /schemas/net/dsa/mscc,ocelot.yaml

    unevaluatedProperties: false
(to be explicit even though they are not required)

> +    properties:
> +      compatible:
> +        enum:
> +          - mscc,vsc7512-switch
> +
>  required:
>    - compatible
>    - reg

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC v4 net-next 15/17] dt-bindings: net: dsa: ocelot: add ocelot-ext documentation
  2022-10-08 18:51 ` [RFC v4 net-next 15/17] dt-bindings: net: dsa: ocelot: add ocelot-ext documentation Colin Foster
@ 2022-10-09 15:58   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 27+ messages in thread
From: Krzysztof Kozlowski @ 2022-10-09 15:58 UTC (permalink / raw)
  To: Colin Foster, netdev, linux-kernel, devicetree
  Cc: Russell King, UNGLinuxDriver, Alexandre Belloni, Claudiu Manoil,
	Paolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Vladimir Oltean, Florian Fainelli, Vivien Didelot, Andrew Lunn,
	Krzysztof Kozlowski, Rob Herring, Lee Jones

On 08/10/2022 20:51, Colin Foster wrote:
> The ocelot-ext driver is another sub-device of the Ocelot / Felix driver
> system. It requires a register array similar to the VSC7514 and has
> different ports layout than existing devices.
> 

Thank you for your patch. There is something to discuss/improve.

> @@ -54,9 +54,24 @@ description: |
>        - phy-mode = "1000base-x": on ports 0, 1, 2, 3
>        - phy-mode = "2500base-x": on ports 0, 1, 2, 3
>  
> +  VSC7512 (Ocelot-Ext):
> +
> +    The Ocelot family consists of four devices, the VSC7511, VSC7512, VSC7513,
> +    and the VSC7514. The VSC7513 and VSC7514 both have an internal MIPS
> +    processor that natively support Linux. Additionally, all four devices
> +    support control over external interfaces, SPI and PCIe. The Ocelot-Ext
> +    driver is for the external control portion.
> +
> +    The following PHY interface types are supported:
> +
> +      - phy-mode = "internal": on ports 0, 1, 2, 3
> +      - phy-mode = "sgmii": on ports 4, 5, 7, 8, 9, 10
> +      - phy-mode = "qsgmii": on ports 4, 5, 6, 7, 8, 10
> +
>  properties:
>    compatible:
>      enum:
> +      - mscc,vsc7512-switch
>        - mscc,vsc9953-switch
>        - pci1957,eef0
>  
> @@ -258,3 +273,100 @@ examples:
>              };
>          };
>      };

Blank line

> +  # Ocelot-ext VSC7512
> +  - |
> +    #include <dt-bindings/phy/phy-ocelot-serdes.h>
> +
> +    soc@0 {
> +        compatible = "mscc,vsc7512";
> +        #address-cells = <1>;
> +        #size-cells = <1>;
> +        reg = <0 0>;
> +
> +        ethernet-switch@0 {

Does not look like you tested the bindings. Please run `make
dt_binding_check` (see
Documentation/devicetree/bindings/writing-schema.rst for instructions).

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC v4 net-next 03/17] net: mscc: ocelot: expose stats layout definition to be used by other drivers
  2022-10-08 18:51 ` [RFC v4 net-next 03/17] net: mscc: ocelot: expose stats layout " Colin Foster
@ 2022-10-12  9:19   ` Vladimir Oltean
  0 siblings, 0 replies; 27+ messages in thread
From: Vladimir Oltean @ 2022-10-12  9:19 UTC (permalink / raw)
  To: Colin Foster
  Cc: netdev, linux-kernel, devicetree, Russell King, UNGLinuxDriver,
	Alexandre Belloni, Claudiu Manoil, Paolo Abeni, Jakub Kicinski,
	Eric Dumazet, David S. Miller, Florian Fainelli, Vivien Didelot,
	Andrew Lunn, Krzysztof Kozlowski, Rob Herring, Lee Jones

On Sat, Oct 08, 2022 at 11:51:38AM -0700, Colin Foster wrote:
> The ocelot_stats_layout array is common between several different chips,
> some of which can only be controlled externally. Export this structure so
> it doesn't have to be duplicated in these other drivers.
> 
> Rename the structure as well, to follow the conventions of other shared
> resources.
> 
> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> ---

I see that ocelot->stats_layout has become a redundant indirection.
It no longer contains anything hardware-specific. The register offsets
are now part of the switch-specific sys_regmap.

Could you please refactor the code to use a single static const struct
ocelot_stats_layout in ocelot_stats.c, and remove felix->info->stats_layout
and ocelot->stats_layout?

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC v4 net-next 11/17] mfd: ocelot: prepend resource size macros to be 32-bit
  2022-10-08 18:51 ` [RFC v4 net-next 11/17] mfd: ocelot: prepend resource size macros to be 32-bit Colin Foster
@ 2022-10-31  9:32   ` Lee Jones
  0 siblings, 0 replies; 27+ messages in thread
From: Lee Jones @ 2022-10-31  9:32 UTC (permalink / raw)
  To: Colin Foster
  Cc: netdev, linux-kernel, devicetree, Russell King, UNGLinuxDriver,
	Alexandre Belloni, Claudiu Manoil, Paolo Abeni, Jakub Kicinski,
	Eric Dumazet, David S. Miller, Vladimir Oltean, Florian Fainelli,
	Vivien Didelot, Andrew Lunn, Krzysztof Kozlowski, Rob Herring

On Sat, 08 Oct 2022, Colin Foster wrote:

> The *_RES_SIZE macros are initally <= 0x100. Future resource sizes will be
> upwards of 0x200000 in size.
> 
> To keep things clean, fully align the RES_SIZE macros to 32-bit to do
> nothing more than make the code more consistent.
> 
> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> ---
> 
> v3-v4
>     * No change
> 
> v2
>     * New patch - broken out from a different one
> 
> ---
>  drivers/mfd/ocelot-core.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

I'm guessing some of the other patches depend on this?

How should it be handled?

For my own reference (apply this as-is to your sign-off block):

  Acked-for-MFD-by: Lee Jones <lee@kernel.org>

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC v4 net-next 12/17] mfd: ocelot: add shared resource names for switch functionality
  2022-10-08 18:51 ` [RFC v4 net-next 12/17] mfd: ocelot: add shared resource names for switch functionality Colin Foster
@ 2022-10-31  9:35   ` Lee Jones
  2022-11-01  2:39     ` Colin Foster
  0 siblings, 1 reply; 27+ messages in thread
From: Lee Jones @ 2022-10-31  9:35 UTC (permalink / raw)
  To: Colin Foster
  Cc: netdev, linux-kernel, devicetree, Russell King, UNGLinuxDriver,
	Alexandre Belloni, Claudiu Manoil, Paolo Abeni, Jakub Kicinski,
	Eric Dumazet, David S. Miller, Vladimir Oltean, Florian Fainelli,
	Vivien Didelot, Andrew Lunn, Krzysztof Kozlowski, Rob Herring

On Sat, 08 Oct 2022, Colin Foster wrote:

> The switch portion of the Ocelot chip relies on several resources. Define
> the resource names here, so they can be referenced by both the switch
> driver and the MFD.
> 
> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> ---
> 
> v4
>     * New patch. Previous versions had entire structures shared,
>       this only requires that the names be shared.
> 
> ---
>  include/linux/mfd/ocelot.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/include/linux/mfd/ocelot.h b/include/linux/mfd/ocelot.h
> index dd72073d2d4f..b80f2f5ff1d6 100644
> --- a/include/linux/mfd/ocelot.h
> +++ b/include/linux/mfd/ocelot.h
> @@ -13,6 +13,15 @@
>  
>  struct resource;
>  
> +#define OCELOT_RES_NAME_ANA	"ana"
> +#define OCELOT_RES_NAME_QS	"qs"
> +#define OCELOT_RES_NAME_QSYS	"qsys"
> +#define OCELOT_RES_NAME_REW	"rew"
> +#define OCELOT_RES_NAME_SYS	"sys"
> +#define OCELOT_RES_NAME_S0	"s0"
> +#define OCELOT_RES_NAME_S1	"s1"
> +#define OCELOT_RES_NAME_S2	"s2"

I've never been a fan of defining name strings.

The end of the define name is identical to the resource names.

This also makes grepping that much harder for little gain.

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC v4 net-next 17/17] mfd: ocelot: add external ocelot switch control
  2022-10-08 18:51 ` [RFC v4 net-next 17/17] mfd: " Colin Foster
@ 2022-10-31  9:36   ` Lee Jones
  0 siblings, 0 replies; 27+ messages in thread
From: Lee Jones @ 2022-10-31  9:36 UTC (permalink / raw)
  To: Colin Foster
  Cc: netdev, linux-kernel, devicetree, Russell King, UNGLinuxDriver,
	Alexandre Belloni, Claudiu Manoil, Paolo Abeni, Jakub Kicinski,
	Eric Dumazet, David S. Miller, Vladimir Oltean, Florian Fainelli,
	Vivien Didelot, Andrew Lunn, Krzysztof Kozlowski, Rob Herring

On Sat, 08 Oct 2022, Colin Foster wrote:

> Utilize the existing ocelot MFD interface to add switch functionality to
> the Microsemi VSC7512 chip.
> 
> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> ---
> 
> v4
>     * Integrate a different patch, so now this one
>       - Adds the resources during this patch. Previouisly this
>         was done in a separate patch
>       - Utilize the standard {,num_}resources initializer
> 
> v3
>     * No change
> 
> v2
>     * New patch, broken out from a previous one
> 
> ---
>  drivers/mfd/ocelot-core.c | 60 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 60 insertions(+)

For my own reference (apply this as-is to your sign-off block):

  Acked-for-MFD-by: Lee Jones <lee@kernel.org>

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC v4 net-next 12/17] mfd: ocelot: add shared resource names for switch functionality
  2022-10-31  9:35   ` Lee Jones
@ 2022-11-01  2:39     ` Colin Foster
  0 siblings, 0 replies; 27+ messages in thread
From: Colin Foster @ 2022-11-01  2:39 UTC (permalink / raw)
  To: Lee Jones
  Cc: netdev, linux-kernel, devicetree, Russell King, UNGLinuxDriver,
	Alexandre Belloni, Claudiu Manoil, Paolo Abeni, Jakub Kicinski,
	Eric Dumazet, David S. Miller, Vladimir Oltean, Florian Fainelli,
	Vivien Didelot, Andrew Lunn, Krzysztof Kozlowski, Rob Herring

Hi Lee,

On Mon, Oct 31, 2022 at 09:35:01AM +0000, Lee Jones wrote:
> On Sat, 08 Oct 2022, Colin Foster wrote:
> 
> > The switch portion of the Ocelot chip relies on several resources. Define
> > the resource names here, so they can be referenced by both the switch
> > driver and the MFD.
> > 
> > Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> > ---
> > 
> > v4
> >     * New patch. Previous versions had entire structures shared,
> >       this only requires that the names be shared.
> > 
> > ---
> >  include/linux/mfd/ocelot.h | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/include/linux/mfd/ocelot.h b/include/linux/mfd/ocelot.h
> > index dd72073d2d4f..b80f2f5ff1d6 100644
> > --- a/include/linux/mfd/ocelot.h
> > +++ b/include/linux/mfd/ocelot.h
> > @@ -13,6 +13,15 @@
> >  
> >  struct resource;
> >  
> > +#define OCELOT_RES_NAME_ANA	"ana"
> > +#define OCELOT_RES_NAME_QS	"qs"
> > +#define OCELOT_RES_NAME_QSYS	"qsys"
> > +#define OCELOT_RES_NAME_REW	"rew"
> > +#define OCELOT_RES_NAME_SYS	"sys"
> > +#define OCELOT_RES_NAME_S0	"s0"
> > +#define OCELOT_RES_NAME_S1	"s1"
> > +#define OCELOT_RES_NAME_S2	"s2"
> 
> I've never been a fan of defining name strings.
> 
> The end of the define name is identical to the resource names.
> 
> This also makes grepping that much harder for little gain.

I defined them here because they'll be directly used in multiple files.
In this case, drivers/net/dsa/ocelot/ocelot_ext.c uses all these defines
as well as drivers/mfd/ocelot-core.c. Future patch sets will also
utilize other resource names by string as well...

But I'll plan to drop this patch next round unless someone disagrees.

Thanks for the feedback!

> 
> -- 
> Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2022-11-01  2:39 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-08 18:51 [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Colin Foster
2022-10-08 18:51 ` [RFC v4 net-next 01/17] net: mscc: ocelot: expose ocelot wm functions Colin Foster
2022-10-08 18:51 ` [RFC v4 net-next 02/17] net: mscc: ocelot: expose regfield definition to be used by other drivers Colin Foster
2022-10-08 18:51 ` [RFC v4 net-next 03/17] net: mscc: ocelot: expose stats layout " Colin Foster
2022-10-12  9:19   ` Vladimir Oltean
2022-10-08 18:51 ` [RFC v4 net-next 04/17] net: mscc: ocelot: expose vcap_props structure Colin Foster
2022-10-08 18:51 ` [RFC v4 net-next 05/17] net: mscc: ocelot: expose ocelot_reset routine Colin Foster
2022-10-08 18:51 ` [RFC v4 net-next 06/17] net: mscc: ocelot: expose vsc7514_regmap definition Colin Foster
2022-10-08 18:51 ` [RFC v4 net-next 07/17] net: dsa: felix: add configurable device quirks Colin Foster
2022-10-08 18:51 ` [RFC v4 net-next 08/17] net: dsa: felix: populate mac_capabilities for all ports Colin Foster
2022-10-08 18:51 ` [RFC v4 net-next 09/17] net: dsa: felix: add support for MFD configurations Colin Foster
2022-10-08 18:51 ` [RFC v4 net-next 10/17] net: dsa: felix: add functionality when not all ports are supported Colin Foster
2022-10-08 18:51 ` [RFC v4 net-next 11/17] mfd: ocelot: prepend resource size macros to be 32-bit Colin Foster
2022-10-31  9:32   ` Lee Jones
2022-10-08 18:51 ` [RFC v4 net-next 12/17] mfd: ocelot: add shared resource names for switch functionality Colin Foster
2022-10-31  9:35   ` Lee Jones
2022-11-01  2:39     ` Colin Foster
2022-10-08 18:51 ` [RFC v4 net-next 13/17] dt-bindings: mfd: ocelot: remove spi-max-frequency from required properties Colin Foster
2022-10-09 15:49   ` Krzysztof Kozlowski
2022-10-08 18:51 ` [RFC v4 net-next 14/17] dt-bindings: mfd: ocelot: add ethernet-switch hardware support Colin Foster
2022-10-09 15:52   ` Krzysztof Kozlowski
2022-10-08 18:51 ` [RFC v4 net-next 15/17] dt-bindings: net: dsa: ocelot: add ocelot-ext documentation Colin Foster
2022-10-09 15:58   ` Krzysztof Kozlowski
2022-10-08 18:51 ` [RFC v4 net-next 16/17] net: dsa: ocelot: add external ocelot switch control Colin Foster
2022-10-08 18:51 ` [RFC v4 net-next 17/17] mfd: " Colin Foster
2022-10-31  9:36   ` Lee Jones
2022-10-08 23:35 ` [RFC v4 net-next 00/17] add support for the the vsc7512 internal copper phys Vladimir Oltean

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).