* [PATCH net-next v5 0/2] net: dsa: microchip: enable setting rmii reference
@ 2023-11-24 16:01 Ante Knezic
2023-11-24 16:01 ` [PATCH net-next v5 1/2] dt-bindings: net: microchip,ksz: document microchip,rmii-clk-internal Ante Knezic
2023-11-24 16:01 ` [PATCH net-next v5 2/2] net: dsa: microchip: add property to select internal RMII reference clock Ante Knezic
0 siblings, 2 replies; 5+ messages in thread
From: Ante Knezic @ 2023-11-24 16:01 UTC (permalink / raw)
To: netdev
Cc: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, robh+dt, krzysztof.kozlowski+dt, conor+dt, marex,
devicetree, linux-kernel, Ante Knezic
KSZ88X3 devices can select between internal and external RMII reference clock.
This patch series introduces new device tree property for setting reference
clock to internal.
---
V5:
- move rmii-clk-internal to be a port device tree property.
V4:
- remove rmii_clk_internal from ksz_device, as its not needed any more
- move rmii clk config as well as ksz8795_cpu_interface_select to
ksz8_config_cpu_port
V3:
- move ksz_cfg from global switch config to port config as suggested by Vladimir
Oltean
- reverse patch order as suggested by Vladimir Oltean
- adapt dt schema as suggested by Conor Dooley
V2:
- don't rely on default register settings - enforce set/clear property as
suggested by Andrew Lunn
- enforce dt schema as suggested by Conor Dooley
Ante Knezic (2):
dt-bindings: net: microchip,ksz: document microchip,rmii-clk-internal
net: dsa: microchip: add property to select internal RMII reference
clock
.../devicetree/bindings/net/dsa/microchip,ksz.yaml | 38 ++++++++++++++-
drivers/net/dsa/microchip/ksz8795.c | 56 +++++++++++++++++++---
drivers/net/dsa/microchip/ksz8795_reg.h | 3 ++
3 files changed, 90 insertions(+), 7 deletions(-)
--
2.11.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH net-next v5 1/2] dt-bindings: net: microchip,ksz: document microchip,rmii-clk-internal 2023-11-24 16:01 [PATCH net-next v5 0/2] net: dsa: microchip: enable setting rmii reference Ante Knezic @ 2023-11-24 16:01 ` Ante Knezic 2023-11-25 0:18 ` kernel test robot 2023-11-24 16:01 ` [PATCH net-next v5 2/2] net: dsa: microchip: add property to select internal RMII reference clock Ante Knezic 1 sibling, 1 reply; 5+ messages in thread From: Ante Knezic @ 2023-11-24 16:01 UTC (permalink / raw) To: netdev Cc: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba, pabeni, robh+dt, krzysztof.kozlowski+dt, conor+dt, marex, devicetree, linux-kernel, Ante Knezic Add documentation for selecting reference rmii clock on KSZ88X3 devices Signed-off-by: Ante Knezic <ante.knezic@helmholz.de> --- .../devicetree/bindings/net/dsa/microchip,ksz.yaml | 38 +++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml index b3029c64d0d5..3cebb9c9b1c8 100644 --- a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml +++ b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml @@ -11,7 +11,6 @@ maintainers: - Woojung Huh <Woojung.Huh@microchip.com> allOf: - - $ref: dsa.yaml#/$defs/ethernet-ports - $ref: /schemas/spi/spi-peripheral-props.yaml# properties: @@ -78,6 +77,43 @@ required: - compatible - reg +if: + not: + properties: + compatible: + enum: + - microchip,ksz8863 + - microchip,ksz8873 +then: + $ref: dsa.yaml#/$defs/ethernet-ports +else: + patternProperties: + "^(ethernet-)?ports$": + patternProperties: + "^(ethernet-)?port@[0-2]$": + $ref: dsa-port.yaml# + properties: + microchip,rmii-clk-internal: + $ref: /schemas/types.yaml#/definitions/flag + description: + When ksz88x3 is acting as clock provier (via REFCLKO) it + can select between internal and external RMII reference + clock. Internal reference clock means that the clock for + the RMII of ksz88x3 is provided by the ksz88x3 internally + and the REFCLKI pin is unconnected. For the external + reference clock, the clock needs to be fed back to ksz88x3 + via REFCLKI. + If microchip,rmii-clk-internal is set, ksz88x3 will provide + rmii reference clock internally, otherwise reference clock + should be provided externally. + if: + not: + required: [ ethernet ] + then: + properties: + microchip,rmii-clk-internal: false + unevaluatedProperties: false + unevaluatedProperties: false examples: -- 2.11.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v5 1/2] dt-bindings: net: microchip,ksz: document microchip,rmii-clk-internal 2023-11-24 16:01 ` [PATCH net-next v5 1/2] dt-bindings: net: microchip,ksz: document microchip,rmii-clk-internal Ante Knezic @ 2023-11-25 0:18 ` kernel test robot 0 siblings, 0 replies; 5+ messages in thread From: kernel test robot @ 2023-11-25 0:18 UTC (permalink / raw) To: Ante Knezic, netdev Cc: oe-kbuild-all, woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba, pabeni, robh+dt, krzysztof.kozlowski+dt, conor+dt, marex, devicetree, linux-kernel, Ante Knezic Hi Ante, kernel test robot noticed the following build warnings: [auto build test WARNING on net-next/main] url: https://github.com/intel-lab-lkp/linux/commits/Ante-Knezic/dt-bindings-net-microchip-ksz-document-microchip-rmii-clk-internal/20231125-000625 base: net-next/main patch link: https://lore.kernel.org/r/0ea1db6b2f2e93c3531645f98888775a4d3165d4.1700841353.git.ante.knezic%40helmholz.de patch subject: [PATCH net-next v5 1/2] dt-bindings: net: microchip,ksz: document microchip,rmii-clk-internal compiler: loongarch64-linux-gcc (GCC) 13.2.0 reproduce: (https://download.01.org/0day-ci/archive/20231125/202311250528.gG5FVdW6-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202311250528.gG5FVdW6-lkp@intel.com/ dtcheck warnings: (new ones prefixed by >>) >> Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml:99:1: [error] syntax error: found character '\t' that cannot start any token (syntax) -- >> Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml:99:1: found character that cannot start any token -- >> Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml: ignoring, error parsing file vim +99 Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml 8 9 maintainers: 10 - Marek Vasut <marex@denx.de> 11 - Woojung Huh <Woojung.Huh@microchip.com> 12 13 allOf: 14 - $ref: /schemas/spi/spi-peripheral-props.yaml# 15 16 properties: 17 # See Documentation/devicetree/bindings/net/dsa/dsa.yaml for a list of additional 18 # required and optional properties. 19 compatible: 20 enum: 21 - microchip,ksz8765 22 - microchip,ksz8794 23 - microchip,ksz8795 24 - microchip,ksz8863 25 - microchip,ksz8873 26 - microchip,ksz9477 27 - microchip,ksz9897 28 - microchip,ksz9896 29 - microchip,ksz9567 30 - microchip,ksz8565 31 - microchip,ksz9893 32 - microchip,ksz9563 33 - microchip,ksz8563 34 35 reset-gpios: 36 description: 37 Should be a gpio specifier for a reset line. 38 maxItems: 1 39 40 wakeup-source: true 41 42 microchip,synclko-125: 43 $ref: /schemas/types.yaml#/definitions/flag 44 description: 45 Set if the output SYNCLKO frequency should be set to 125MHz instead of 25MHz. 46 47 microchip,synclko-disable: 48 $ref: /schemas/types.yaml#/definitions/flag 49 description: 50 Set if the output SYNCLKO clock should be disabled. Do not mix with 51 microchip,synclko-125. 52 53 microchip,io-drive-strength-microamp: 54 description: 55 IO Pad Drive Strength 56 enum: [8000, 16000] 57 default: 16000 58 59 microchip,hi-drive-strength-microamp: 60 description: 61 High Speed Drive Strength. Controls drive strength of GMII / RGMII / 62 MII / RMII (except TX_CLK/REFCLKI, COL and CRS) and CLKO_25_125 lines. 63 enum: [2000, 4000, 8000, 12000, 16000, 20000, 24000, 28000] 64 default: 24000 65 66 microchip,lo-drive-strength-microamp: 67 description: 68 Low Speed Drive Strength. Controls drive strength of TX_CLK / REFCLKI, 69 COL, CRS, LEDs, PME_N, NTRP_N, SDO and SDI/SDA/MDIO lines. 70 enum: [2000, 4000, 8000, 12000, 16000, 20000, 24000, 28000] 71 default: 8000 72 73 interrupts: 74 maxItems: 1 75 76 required: 77 - compatible 78 - reg 79 80 if: 81 not: 82 properties: 83 compatible: 84 enum: 85 - microchip,ksz8863 86 - microchip,ksz8873 87 then: 88 $ref: dsa.yaml#/$defs/ethernet-ports 89 else: 90 patternProperties: 91 "^(ethernet-)?ports$": 92 patternProperties: 93 "^(ethernet-)?port@[0-2]$": 94 $ref: dsa-port.yaml# 95 properties: 96 microchip,rmii-clk-internal: 97 $ref: /schemas/types.yaml#/definitions/flag 98 description: > 99 When ksz88x3 is acting as clock provier (via REFCLKO) it 100 can select between internal and external RMII reference 101 clock. Internal reference clock means that the clock for 102 the RMII of ksz88x3 is provided by the ksz88x3 internally 103 and the REFCLKI pin is unconnected. For the external 104 reference clock, the clock needs to be fed back to ksz88x3 105 via REFCLKI. 106 If microchip,rmii-clk-internal is set, ksz88x3 will provide 107 rmii reference clock internally, otherwise reference clock 108 should be provided externally. 109 if: 110 not: 111 required: [ ethernet ] 112 then: 113 properties: 114 microchip,rmii-clk-internal: false 115 unevaluatedProperties: false 116 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net-next v5 2/2] net: dsa: microchip: add property to select internal RMII reference clock 2023-11-24 16:01 [PATCH net-next v5 0/2] net: dsa: microchip: enable setting rmii reference Ante Knezic 2023-11-24 16:01 ` [PATCH net-next v5 1/2] dt-bindings: net: microchip,ksz: document microchip,rmii-clk-internal Ante Knezic @ 2023-11-24 16:01 ` Ante Knezic 2023-11-24 16:11 ` Vladimir Oltean 1 sibling, 1 reply; 5+ messages in thread From: Ante Knezic @ 2023-11-24 16:01 UTC (permalink / raw) To: netdev Cc: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba, pabeni, robh+dt, krzysztof.kozlowski+dt, conor+dt, marex, devicetree, linux-kernel, Ante Knezic Microchip KSZ8863/KSZ8873 have the ability to select between internal and external RMII reference clock. By default, reference clock needs to be provided via REFCLKI_3 pin. If required, device can be setup to provide RMII clock internally so that REFCLKI_3 pin can be left unconnected. Add a new "microchip,rmii-clk-internal" property which will set RMII clock reference to internal. If property is not set, reference clock needs to be provided externally. While at it, move the ksz8795_cpu_interface_select() to ksz8_config_cpu_port() to get a cleaner call path for cpu port. Signed-off-by: Ante Knezic <ante.knezic@helmholz.de> --- drivers/net/dsa/microchip/ksz8795.c | 56 +++++++++++++++++++++++++++++---- drivers/net/dsa/microchip/ksz8795_reg.h | 3 ++ 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index 4bf4d67557dc..a749a4a970ec 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -1358,6 +1358,9 @@ static void ksz8795_cpu_interface_select(struct ksz_device *dev, int port) { struct ksz_port *p = &dev->ports[port]; + if (!ksz_is_ksz87xx(dev)) + return; + if (!p->interface && dev->compat_interface) { dev_warn(dev->dev, "Using legacy switch \"phy-mode\" property, because it is missing on port %d node. " @@ -1391,18 +1394,55 @@ void ksz8_port_setup(struct ksz_device *dev, int port, bool cpu_port) /* enable 802.1p priority */ ksz_port_cfg(dev, port, P_PRIO_CTRL, PORT_802_1P_ENABLE, true); - if (cpu_port) { - if (!ksz_is_ksz88x3(dev)) - ksz8795_cpu_interface_select(dev, port); - + if (cpu_port) member = dsa_user_ports(ds); - } else { + else member = BIT(dsa_upstream_port(ds, port)); - } ksz8_cfg_port_member(dev, port, member); } +static int ksz88x3_config_rmii_clk(struct ksz_device *dev, int cpu_port) +{ + struct device_node *ports, *port, *cpu_node; + bool rmii_clk_internal; + + if (!ksz_is_ksz88x3(dev)) + return 0; + + cpu_node = NULL; + + ports = of_get_child_by_name(dev->dev->of_node, "ports"); + if (!ports) + ports = of_get_child_by_name(dev->dev->of_node, + "ethernet-ports"); + if (!ports) + return -ENODEV; + + for_each_available_child_of_node(ports, port) { + u32 index; + + if (of_property_read_u32(port, "reg", &index) < 0) + return -ENODEV; + + if (index == cpu_port) { + cpu_node = port; + break; + } + } + + if (!cpu_node) + return -ENODEV; + + rmii_clk_internal = of_property_read_bool(cpu_node, + "microchip,rmii-clk-internal"); + + ksz_cfg(dev, KSZ88X3_REG_FVID_AND_HOST_MODE, + KSZ88X3_PORT3_RMII_CLK_INTERNAL, rmii_clk_internal); + + return 0; +} + void ksz8_config_cpu_port(struct dsa_switch *ds) { struct ksz_device *dev = ds->priv; @@ -1419,6 +1459,10 @@ void ksz8_config_cpu_port(struct dsa_switch *ds) ksz8_port_setup(dev, dev->cpu_port, true); + ksz8795_cpu_interface_select(dev, dev->cpu_port); + if (ksz88x3_config_rmii_clk(dev, dev->cpu_port)) + dev_err(dev->dev, "Failed to set rmii reference clock source mode"); + for (i = 0; i < dev->phy_port_cnt; i++) { ksz_port_stp_state_set(ds, i, BR_STATE_DISABLED); } diff --git a/drivers/net/dsa/microchip/ksz8795_reg.h b/drivers/net/dsa/microchip/ksz8795_reg.h index 3c9dae53e4d8..beca974e0171 100644 --- a/drivers/net/dsa/microchip/ksz8795_reg.h +++ b/drivers/net/dsa/microchip/ksz8795_reg.h @@ -22,6 +22,9 @@ #define KSZ8863_GLOBAL_SOFTWARE_RESET BIT(4) #define KSZ8863_PCS_RESET BIT(0) +#define KSZ88X3_REG_FVID_AND_HOST_MODE 0xC6 +#define KSZ88X3_PORT3_RMII_CLK_INTERNAL BIT(3) + #define REG_SW_CTRL_0 0x02 #define SW_NEW_BACKOFF BIT(7) -- 2.11.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v5 2/2] net: dsa: microchip: add property to select internal RMII reference clock 2023-11-24 16:01 ` [PATCH net-next v5 2/2] net: dsa: microchip: add property to select internal RMII reference clock Ante Knezic @ 2023-11-24 16:11 ` Vladimir Oltean 0 siblings, 0 replies; 5+ messages in thread From: Vladimir Oltean @ 2023-11-24 16:11 UTC (permalink / raw) To: Ante Knezic Cc: netdev, woojung.huh, andrew, f.fainelli, davem, edumazet, kuba, pabeni, robh+dt, krzysztof.kozlowski+dt, conor+dt, marex, devicetree, linux-kernel On Fri, Nov 24, 2023 at 05:01:48PM +0100, Ante Knezic wrote: > +static int ksz88x3_config_rmii_clk(struct ksz_device *dev, int cpu_port) > +{ > + struct device_node *ports, *port, *cpu_node; > + bool rmii_clk_internal; > + > + if (!ksz_is_ksz88x3(dev)) > + return 0; > + > + cpu_node = NULL; > + > + ports = of_get_child_by_name(dev->dev->of_node, "ports"); > + if (!ports) > + ports = of_get_child_by_name(dev->dev->of_node, > + "ethernet-ports"); > + if (!ports) > + return -ENODEV; > + > + for_each_available_child_of_node(ports, port) { > + u32 index; > + > + if (of_property_read_u32(port, "reg", &index) < 0) > + return -ENODEV; > + > + if (index == cpu_port) { > + cpu_node = port; > + break; > + } > + } > + > + if (!cpu_node) > + return -ENODEV; Too much code. Assuming you have struct dsa_port *cpu_dp, you can access cpu_dp->dn instead of re-parsing the device tree. > + > + rmii_clk_internal = of_property_read_bool(cpu_node, > + "microchip,rmii-clk-internal"); > + > + ksz_cfg(dev, KSZ88X3_REG_FVID_AND_HOST_MODE, > + KSZ88X3_PORT3_RMII_CLK_INTERNAL, rmii_clk_internal); > + > + return 0; > +} Please wait for 24 hours before reposting, maybe you get more feedback. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-25 0:19 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-11-24 16:01 [PATCH net-next v5 0/2] net: dsa: microchip: enable setting rmii reference Ante Knezic 2023-11-24 16:01 ` [PATCH net-next v5 1/2] dt-bindings: net: microchip,ksz: document microchip,rmii-clk-internal Ante Knezic 2023-11-25 0:18 ` kernel test robot 2023-11-24 16:01 ` [PATCH net-next v5 2/2] net: dsa: microchip: add property to select internal RMII reference clock Ante Knezic 2023-11-24 16:11 ` 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).