From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C47BC43381 for ; Thu, 21 Mar 2019 19:56:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 28E332183E for ; Thu, 21 Mar 2019 19:56:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i3yeaXQv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728615AbfCUT4z (ORCPT ); Thu, 21 Mar 2019 15:56:55 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41867 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727881AbfCUT4y (ORCPT ); Thu, 21 Mar 2019 15:56:54 -0400 Received: by mail-wr1-f66.google.com with SMTP id p1so7990005wrs.8 for ; Thu, 21 Mar 2019 12:56:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AoR0AzDXWUss2vn3MWA7FG0vbNLj2GfRROUPxZS+W4o=; b=i3yeaXQvBmJhnNuf7MAPbl3G6WNdauSFJL8ttuh41u+ssCcQVVM34QmX7fkMzLRvaM +i5N+uSHcTNyznqkRDhBJUn50Fj3txB509MbYo9ygbYYI4BUjeJCBBBntQwnYfr/z0nK xUYf/6svTP0cYRkUUPCp0bj+g4zqJ5LESSDOY4KQZiYkGYTQutSmKdQ3QdHj/fC1YZeV cdxxfNNzRVPvjKlL72pO/83+2sOuVEnYNL41g3raoNI5WhNjXLDpMDznvXleq71YSeCk J/jcYcg9Eba91UpcL+h9Ipd26WrFk92SryO5iD095PXP/x+t5GFIAM2dvIk+PxhRj4re riVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AoR0AzDXWUss2vn3MWA7FG0vbNLj2GfRROUPxZS+W4o=; b=Mo2fgsdoed3VfDG3GGJzXVqRcOxpj5syIhl3g1u5mHRwf8bguwKFZl8aRSXtHsyxWg 200TEclmutjyJVEeL3TJoyRsnzwTvclTTCeEfUhVyV0bHpiTHYNecBVeXsebRTjju6hY /Qx82UWhtjCFY8zrWDYS5iPbyWjkJxv8zjcUUoQldt1NnDkwHuy4LUT9Ei5FlmIZSlxp 10EsOPh0XBnzTXfDgOFCBdwzqmN48oWcUKtyn9hxreZ6VXsAQVixJ75t1w/dCkLGrsXo f24IRxGMYIhrmh2DyGZXOPFU4maxhl2tejiQP4rYKp7ZrVrBQAlJVhSObzxjkKQOgy2i melw== X-Gm-Message-State: APjAAAVwj1xZlRnuv2GKQEE0ALdpSAa+EG48plT+d9nmv9wRcQvdYuIA Cd9pzdXD9wu4dKysvaEzwyw= X-Google-Smtp-Source: APXvYqzdKchE7SucCuCr4ADNqIgVTpGbhfVD79QBW3MfJJvXD2zUj+rgFz634/Qbwxfln1YGatbLLQ== X-Received: by 2002:a5d:6050:: with SMTP id j16mr3871080wrt.253.1553198212942; Thu, 21 Mar 2019 12:56:52 -0700 (PDT) Received: from debian64.daheim (p4FD091E7.dip0.t-ipconnect.de. [79.208.145.231]) by smtp.gmail.com with ESMTPSA id d7sm6406940wmf.31.2019.03.21.12.56.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2019 12:56:52 -0700 (PDT) Received: from localhost.daheim ([127.0.0.1] helo=debian64.localnet) by debian64.daheim with esmtp (Exim 4.92) (envelope-from ) id 1h73o3-0005m8-MO; Thu, 21 Mar 2019 20:56:51 +0100 From: Christian Lamparter To: Florian Fainelli Cc: Marek =?ISO-8859-1?Q?Beh=FAn?= , netdev@vger.kernel.org, Andrew Lunn , Michal =?utf-8?B?Vm9rw6HEjQ==?= , John Crispin , Wei Yongjun Subject: Re: [PATCH net-next 1/1] net: dsa: qca8k: Fix internal PHY MDIO address Date: Thu, 21 Mar 2019 20:56:51 +0100 Message-ID: <1709445.Zob874UQW2@debian64> In-Reply-To: <4f2160f2-28f1-bd61-86ee-3db77fd67ba4@gmail.com> References: <20190321182319.10664-1-marek.behun@nic.cz> <4f2160f2-28f1-bd61-86ee-3db77fd67ba4@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thursday, March 21, 2019 7:26:08 PM CET Florian Fainelli wrote: > +Christian, >=20 > On 3/21/19 11:23 AM, Marek Beh=C3=BAn wrote: > > The MDIO addresses of the internal PHYs on this switch for ports 1-5 > > have addresses 0-4, not 1-5. > >=20 >=20 > Can you provide a Fixes: tag for this? Your change will conflicts with > Christian's patch series here: >=20 > http://patchwork.ozlabs.org/project/netdev/list/?series=3D98063 http://patchwork.ozlabs.org/patch/1058655/ (link to the patch) So, Yes and no ;) We both have the same idea: +static int +qca8k_port_to_phy(int port) +{ + if (port < 1 || port > QCA8K_MDIO_MASTER_MAX_PORTS) + return -EINVAL; + + return port - 1; +} I plan to sent v4 tomorrow, since I need to test it on the device first. > > Signed-off-by: Marek Beh=C3=BAn > > Cc: Andrew Lunn > > Cc: Florian Fainelli > > Cc: Michal Vok=C3=A1=C4=8D > > Cc: John Crispin > > Cc: Wei Yongjun > > --- > > drivers/net/dsa/qca8k.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > >=20 > > diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c > > index cdcde7f8e0b2..eb199193cc3b 100644 > > --- a/drivers/net/dsa/qca8k.c > > +++ b/drivers/net/dsa/qca8k.c > > @@ -625,7 +625,7 @@ qca8k_phy_read(struct dsa_switch *ds, int phy, int = regnum) > > { > > struct qca8k_priv *priv =3D (struct qca8k_priv *)ds->priv; > > =20 > > - return mdiobus_read(priv->bus, phy, regnum); > > + return mdiobus_read(priv->bus, phy - 1, regnum); > > } > > =20 > > static int > > @@ -633,7 +633,7 @@ qca8k_phy_write(struct dsa_switch *ds, int phy, int= regnum, u16 val) > > { > > struct qca8k_priv *priv =3D (struct qca8k_priv *)ds->priv; > > =20 > > - return mdiobus_write(priv->bus, phy, regnum, val); > > + return mdiobus_write(priv->bus, phy - 1, regnum, val); > > } Word of Warning: The priv->bus is pointing to the external mdio-bus that the QCA8337 is connected to, so in my case I noticed that the *same* PHYs are registered twice. The first time on the external mdio, which is fine since we need that for the phy-handle of the "ports" node and a s second time by the slave-mdio that net/dsa/slave.c provides. In my case I found =46lorian's explanation in https://patchwork.ozlabs.org/patch/1036309/#2084184 very useful: |I don't think you should have to do any of this translation, because you |can do a couple of things with DSA/Device Tree: | |- you can not provide a phy-handle property at all, in which case, the |core DSA layer assumes that the PHY is part of the switch's internal |MDIO bus which is implictly created by dsa_slave_mii_bus_create() | |- you can specify a phy-handle property and then the PHY device tree |node can be placed pretty much anywhere in Device Tree, including on a |separate MDIO bus Device Tre node which is "external" to the switch | |In either case, the PHY device's MDIO bus parent and its address are |taken care of by drivers/of/of_mdio.c. You can look at mx88e6xxx for how |it deals with its internal vs. external MDIO bus controller and that |driver is used on a wide variety of configuration.