netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Helmut Grohne <helmut.grohne@intenta.de>
To: Woojung Huh <woojung.huh@microchip.com>,
	Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>, <netdev@vger.kernel.org>
Subject: net/dsa/microchip: correct placement of dt property phy-mode?
Date: Wed, 17 Jun 2020 10:22:37 +0200	[thread overview]
Message-ID: <20200617082235.GA1523@laureti-dev> (raw)

Hi,

According to Documentation/devicetree/bindings/net/dsa/dsa.txt, the
phy-mode property should be specified on port nodes rather than the
enclosing switch node.

In drivers/net/dsa/microchip/ksz_common.c, ksz_switch_register parses
the phy-mode property from the switch node instead:
| int ksz_switch_register(struct ksz_device *dev,
|                         const struct ksz_dev_ops *ops)
| {
...
|         /* Host port interface will be self detected, or specifically set in
|          * device tree.
|          */
|         if (dev->dev->of_node) {
|                 ret = of_get_phy_mode(dev->dev->of_node, &interface);
|                 if (ret == 0)
|                         dev->interface = interface;
...

In drivers/net/dsa/microchip/ksz9477.c, this phy_interface_t is used to
configure the MAC ports:
| static void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port)
| {
...
|                 switch (dev->interface) {
...
|                 }
|                 ksz_pwrite8(dev, port, REG_PORT_XMII_CTRL_1, data8);

KSZ9477 has two MAC interfaces (GMAC 6 -> RGMII/MII/RMII and GMAC 7 ->
SGMII). Now we're trying to configure the same interface mode for both
MACs here even though these MACs only support distinct interface modes.
This may not be problematic in practice as GMAC 7 ignores most of the
settings on the XMII Port Control 1 Register, but it still sounds wrong.

If nothing else, it makes the device tree unintuitive to use.

Is this placement of the phy-mode on the switch intentional?

If yes: I think this should be prominently documented in
Documentation/devicetree/bindings/net/dsa/ksz.txt.

If no: The microchip driver should follow the documented dsa convention
and place the phy-mode on the relevant port nodes.

If no: Do we have to support old device trees that have the phy-mode
property on the switch?

Helmut

             reply	other threads:[~2020-06-17  8:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17  8:22 Helmut Grohne [this message]
2020-06-17 21:18 ` Andrew Lunn
2020-07-14 12:08 ` [PATCH] net: dsa: microchip: look for phy-mode in port nodes Helmut Grohne
2020-07-14 22:27   ` Andrew Lunn
2020-07-15  7:31     ` Helmut Grohne
2020-07-15 13:00       ` Andrew Lunn
2020-07-16  7:00         ` Helmut Grohne
2020-07-16 10:07           ` Helmut Grohne
2020-08-20  6:03             ` [RESEND PATCH] " Helmut Grohne
2020-08-24 22:37               ` David Miller
2020-09-04  8:14                 ` [PATCH v2] " Helmut Grohne
2020-09-04 12:59                   ` Alexandre Belloni
2020-09-04 13:52                   ` Andrew Lunn
2020-09-07  6:15                     ` Helmut Grohne
2020-09-07 12:55                       ` Andrew Lunn
2020-09-08  8:01                         ` [PATCH v3] " Helmut Grohne
2020-09-10 19:32                           ` David Miller
2020-09-24  8:37                             ` [PATCH] net: dsa: microchip: really " Helmut Grohne
2020-09-25  3:10                               ` David Miller

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20200617082235.GA1523@laureti-dev \
    --to=helmut.grohne@intenta.de \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    --cc=woojung.huh@microchip.com \
    --subject='Re: net/dsa/microchip: correct placement of dt property phy-mode?' \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).