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=-4.1 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,SPF_PASS 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 76AF6C282CB for ; Tue, 5 Feb 2019 12:48:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D2442075C for ; Tue, 5 Feb 2019 12:48:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X+Qv2xdY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727097AbfBEMsu (ORCPT ); Tue, 5 Feb 2019 07:48:50 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:53097 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbfBEMst (ORCPT ); Tue, 5 Feb 2019 07:48:49 -0500 Received: by mail-wm1-f68.google.com with SMTP id m1so3498855wml.2 for ; Tue, 05 Feb 2019 04:48:47 -0800 (PST) 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=NHwLNwkvZP7XtFzA/VshRI5C4/LX1GbqEunMYGXMi2E=; b=X+Qv2xdYj8zyMQxamElYccdBOutZhE666JBXfADQPRG2+dfD2Yl6TeiAcQ5OlOm0lW AGW5vsnrbM6H60JsuNDjNo/rNlwaKBXYKuNMkRE01UjZuuPorpQkOCq4WjjO4RhQHj/m ydKiAezPZ+fqjTpJpQPBAMxJ5GHpZJUWygRWHU40tMBi3hVdWGl/DaXk6f/pKNx1jXzY OrQt+Om2Wow2uZS9GHi09ivqiD416RLipOLQNXJiQb2kJgUTprF8IErQHsiH2VkjdWVL S/bOd4ItUAZISqrTwUw/GZCn7tjbeXkxNwYCzPtgsy2rOTKmvf/ymLWrgp1phiqTEDuv 01oA== 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=NHwLNwkvZP7XtFzA/VshRI5C4/LX1GbqEunMYGXMi2E=; b=k+I3SXLXeRR4A9RuM9q/r34ZtdwAnxCjrBW63ukLOjXnmk+rO0iGMCHpqG148/geBs cyrUTedDK2hQap/AwjepLCd+8Lwfj4rYl++VH4hYOSPrd2+28ZKFtdvVjUVjAnhlX/XQ +MwZnFbm3nfvhmsGB+9WJIhA8tjtB9GRSdZAP5Lz/Eeu85itdT3B8QtkIzrzvsLrGH12 1aJpH69hYn4NJyD08ZgeGhtWDYXdAEZWkIB4IZ0W6dBLB9FZLLd0M0V65BWC4nxYnaie +p8JwczkJ5K7FiI+6t4NwDG/+d6BhHXgEgaQUpVojEqVIji48lkT/w3QbRZCwEh/nHht 8qpg== X-Gm-Message-State: AHQUAuZOIzJooObnjn/fwmXAa2oHN4URwLw5imiftIQBTuDII6s3QknE wt3yP/ZgSY+lMSXSHV6SBgBsReX0 X-Google-Smtp-Source: AHgI3IZxCL0V1y75tqnFnZZKRY60LYJigl/7zgxxWEBhby3qs5bzbLPR5WNsbEoirfcdnplirUlgJA== X-Received: by 2002:a1c:7ec4:: with SMTP id z187mr3597873wmc.43.1549370926668; Tue, 05 Feb 2019 04:48:46 -0800 (PST) Received: from debian64.daheim (p5B0D715E.dip0.t-ipconnect.de. [91.13.113.94]) by smtp.gmail.com with ESMTPSA id z18sm12203258wml.36.2019.02.05.04.48.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Feb 2019 04:48:45 -0800 (PST) Received: from localhost.daheim ([127.0.0.1] helo=debian64.localnet) by debian64.daheim with esmtp (Exim 4.92-RC5) (envelope-from ) id 1gr09c-0005UC-21; Tue, 05 Feb 2019 13:48:44 +0100 From: Christian Lamparter To: Andrew Lunn Cc: netdev@vger.kernel.org, Florian Fainelli , Vivien Didelot Subject: Re: [PATCH v1] net: dsa: qca8k: implement DT-based ports <-> phy translation Date: Tue, 05 Feb 2019 13:48:43 +0100 Message-ID: <24213401.HFHtFJUkrt@debian64> In-Reply-To: <20190205024533.GB10838@lunn.ch> References: <20190204213555.26054-1-chunkeey@gmail.com> <20190205024533.GB10838@lunn.ch> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tuesday, February 5, 2019 3:45:33 AM CET Andrew Lunn wrote: > On Mon, Feb 04, 2019 at 10:35:55PM +0100, Christian Lamparter wrote: > > The QCA8337 enumerates 5 PHYs on the MDC/MDIO access: PHY0-PHY4. > > Based on the System Block Diagram in Section 1.2 of the > > QCA8337's datasheet. These PHYs are internally connected > > to MACs of PORT 1 - PORT 5. However, neither qca8k's slave > > mdio access functions qca8k_phy_read()/qca8k_phy_write() > > nor the dsa framework is set up for that. > > > > This version of the patch uses the existing phy-handle > > properties of each specified DSA Port in the DT to map > > each PORT/MAC to its exposed PHY on the MDIO bus. This > > is supported by the current binding document qca8k.txt > > as well. > > Hi Christian > > Looking at Documentation/devicetree/bindings/net/dsa/qca8k.txt > > I think everything you need is already implemented. What problem do > you actually have? Thankfully, Florian's reply answered the question to me. The problem has to do with the qca8k's slave qca8k_phy_read and qca8k_phy_write. Here are the functions: |qca8k_phy_read(struct dsa_switch *ds, int phy, int regnum) |{ | struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; | | return mdiobus_read(priv->bus, phy, regnum); |} | |static int |qca8k_phy_write(struct dsa_switch *ds, int phy, int regnum, u16 val) |{ | struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; | | return mdiobus_write(priv->bus, phy, regnum, val); |} The trick here is that priv->bus is not the internal bus instead it's set to the SoC's (external) mii bus in qca8k_sw_probe()). So this isn't a slave bus! And as stated in the qca8k, the the external and internal PHY bus are not mapped 1:1. >From what I can tell from the datasheet, the QCA8337N does have dedicated MDIO master control register which is what is needed here. It's at 0x003C. So these mdiobus_read/writes on the SoCs MDIO bus would either need to be converted to read and write to 0x003c... Or the qca8k_phy_read() and qca8k_phy_write could be dropped all together. I've tested it on the WPQ864 and driver works without since it was never a real slave bus there to begin with. Thanks, Christian --- diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c index 7e97e620bd44..a26850c888cf 100644 --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -620,22 +620,6 @@ qca8k_adjust_link(struct dsa_switch *ds, int port, struct phy_device *phy) qca8k_port_set_status(priv, port, 1); } -static int -qca8k_phy_read(struct dsa_switch *ds, int phy, int regnum) -{ - struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; - - return mdiobus_read(priv->bus, phy, regnum); -} - -static int -qca8k_phy_write(struct dsa_switch *ds, int phy, int regnum, u16 val) -{ - struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; - - return mdiobus_write(priv->bus, phy, regnum, val); -} - static void qca8k_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *data) { @@ -876,8 +860,6 @@ static const struct dsa_switch_ops qca8k_switch_ops = { .setup = qca8k_setup, .adjust_link = qca8k_adjust_link, .get_strings = qca8k_get_strings, - .phy_read = qca8k_phy_read, - .phy_write = qca8k_phy_write, .get_ethtool_stats = qca8k_get_ethtool_stats, .get_sset_count = qca8k_get_sset_count, .get_mac_eee = qca8k_get_mac_eee,