[From nobody Thu Jun 25 05:55:14 2020
Received: from mx.0dd.nl ([5.2.79.48])
 by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux))
 id 1hcRCk-0003L5-Qf
 for openwrt-devel@lists.openwrt.org; Sun, 16 Jun 2019 09:12:05 +0000
Received: from mail.vdorst.com (mail.vdorst.com [IPv6:fd01::250])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mx.0dd.nl (Postfix) with ESMTPS id D0DE05FC18;
 Sun, 16 Jun 2019 11:11:58 +0200 (CEST)
Authentication-Results: mx.0dd.nl; dkim=pass (2048-bit key;
 secure) header.d=vdorst.com header.i=@vdorst.com header.b=&quot;Nld4QN7J&quot;; 
 dkim-atps=neutral
Received: from www (www.vdorst.com [192.168.2.222])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mail.vdorst.com (Postfix) with ESMTPSA id 950331C5D435;
 Sun, 16 Jun 2019 11:11:58 +0200 (CEST)
DKIM-Filter: OpenDKIM Filter v2.11.0 mail.vdorst.com 950331C5D435
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vdorst.com;
 s=default; t=1560676318;
 bh=QA2GaIAdcuc6GUp52PQ+9FOjLG/vjaQE48cxIlecqck=;
 h=Date:From:To:Cc:Subject:References:In-Reply-To:From;
 b=Nld4QN7Jl8JlZS0hRmlrAQbS7OqmeRi8L0RlFK0w+8ybM7q9RoOyEBysXw6Jgbbb3
 z0RG1kbJ2UkQxaiFrMG1yxDQT9eqEh05z7ouBjxJWeORQO2sSaJOv3Isc6i5oZkTYa
 m/fdZk8+qQF72x/RQ+JtZfe8KhgpJch04ivrYvmGEmcj7y8iII4ydY/a9x9F2v368+
 l6DxwVU2F+3qzFANPcSyHgvzI20D3YAqpMD73jf8i1/+JxI2WaopvhY8vXzQ6WmfSX
 IW+Mve3Le5Iutnywtb9j187NzsUOKgXQEbtCVMhLN0TrtRt/y0AB5cifuKoipEYUq0
 XQ3k3R8+QQrHg==
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by
 www.vdorst.com (Horde Framework) with HTTPS; Sun, 16 Jun 2019 09:11:58 +0000
Date: Sun, 16 Jun 2019 09:11:58 +0000
Message-ID: &lt;20190616091158.Horde.-Ajc7bdOXS4MeR2iDYzdOyd@www.vdorst.com&gt;
From: =?utf-8?b?UmVuw6k=?= van Dorst &lt;rene@vdorst.com&gt;
To: Daniel Santos &lt;daniel.santos@pobox.com&gt;
Cc: Daniel Golle &lt;daniel@makrotopia.org&gt;, Felix Fietkau &lt;nbd@nbd.name&gt;,
 openwrt-devel &lt;openwrt-devel@lists.openwrt.org&gt;, John Crispin
 &lt;blogic@openwrt.org&gt;, Michael Lee &lt;igvtee@gmail.com&gt;, netdev@vger.kernel.org
Subject: Re: Understanding Ethernet Architecture (I/O --&gt; MDIO --&gt; MII vs
 I/O --&gt; MAC) for mt7620 (OpenWRT)
References: &lt;2766c2b3-3262-78f5-d736-990aaa385eeb@pobox.com&gt;
 &lt;6f21e283-60ef-7e0f-359b-fbd547ea7e2a@pobox.com&gt;
In-Reply-To: &lt;6f21e283-60ef-7e0f-359b-fbd547ea7e2a@pobox.com&gt;
User-Agent: Horde Application Framework 5
Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes
MIME-Version: 1.0
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 
X-CRM114-CacheID: sfid-20190616_021203_720304_8DA303B5 
X-CRM114-Status: GOOD (  20.14  )
X-Spam-Score: -0.2 (/)
X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary:
 Content analysis details:   (-0.2 points)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 -0.1 DKIM_VALID_EF          Message has a valid DKIM or DK signature from
 envelope-from domain
 -0.1 DKIM_VALID_AU          Message has a valid DKIM or DK signature from
 author's domain
 -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature
 0.1 DKIM_SIGNED            Message has a DKIM or DK signature, not necessarily
 valid
 0.0 FROM_EXCESS_BASE64     From: base64 encoded unnecessarily

Quoting Daniel Santos &lt;daniel.santos@pobox.com&gt;:

Hi Daniel,

&gt; Ah hah! I've found my answer on page 340 (414. PIAC: PHY Indirect Access
&gt; Control(offset:0x7004)) and in mt7620_gsw_config:
&gt;
&gt; static int mt7620_gsw_config(struct fe_priv *priv)
&gt; {
&gt; 	struct mt7620_gsw *gsw = (struct mt7620_gsw *) priv-&gt;soc-&gt;swpriv;
&gt;
&gt; 	/* is the mt7530 internal or external */
&gt; 	if (priv-&gt;mii_bus &amp;&amp; mdiobus_get_phy(priv-&gt;mii_bus, 0x1f)) {
&gt; 		mt7530_probe(priv-&gt;dev, gsw-&gt;base, NULL, 0);
&gt; 		mt7530_probe(priv-&gt;dev, NULL, priv-&gt;mii_bus, 1);
&gt; 	} else {
&gt; 		mt7530_probe(priv-&gt;dev, gsw-&gt;base, NULL, 1);
&gt; 	}
&gt;
&gt; 	return 0;
&gt; }
&gt;
&gt; So priv-&gt;mii_bus is non-null when the chip's network hardware is
&gt; external because the similarly (and confusingly) named mt7530 is only
&gt; the switch hardware, where as the mt7620 is a full µC that has an mt7530
&gt; integrated into it.  Which leads me to the question of what &quot;GSW&quot;
&gt; means?  This is the name of the hardware that has the PIAC register, but
&gt; nowhere in the data sheet or programming guide can I find a definition.

GSW = Gigabit Switch.

Quote out of an old patch see https://lkml.org/lkml/2018/3/14/1044

&quot;Although the builtin MT7530 is gbit capable, the builtin PHYs are  
only 100mbit.&quot;

Greats,

René

&gt;
&gt; Thanks,
&gt; Daniel
&gt;
&gt;
&gt; On 6/14/19 5:53 PM, Daniel Santos wrote:
&gt;&gt; Hello,
&gt;&gt;
&gt;&gt; I'm still fairly new to Ethernet drivers and there are a lot of
&gt;&gt; interesting pieces.  What I need help with is understanding MDIO --&gt;
&gt;&gt; (R)MII vs direct I/O to the MAC (e.g., via ioread32, iowrite32).  Why is
&gt;&gt; there not always a struct mii_bus to talk to this hardware?  Is it
&gt;&gt; because the PHY and/or MAC hardware sometimes attached via an MDIO
&gt;&gt; device and sometimes directly to the I/O bus?  Or does some type of
&gt;&gt; &quot;indirect access&quot; need to be enabled for that to work?
&gt;&gt;
&gt;&gt; I might be trying to do something that's unnecessary however, I'm not
&gt;&gt; sure yet.  I need to add functionality to change a port's
&gt;&gt; auto-negotiate, duplex, etc.  I'm adding it to the swconfig first and
&gt;&gt; then will look at adding it for DSA afterwards.  When I run &quot;swconfig
&gt;&gt; dev switch0 port 0 show&quot;, the current mt7530 / mt7620 driver is querying
&gt;&gt; the MAC status register (at base + 0x3008 + 0x100 * port, described on
&gt;&gt; pages 323-324 of the MT7620 Programming Guide), so I implemented the
&gt;&gt; &quot;set&quot; functionality by modifying the MAC's control register (offset
&gt;&gt; 0x3000 on page 321), but it doesn't seem to change anything.  So I
&gt;&gt; figured maybe I need to modify the MII interface's control register for
&gt;&gt; the port (page 350), but upon debugging I can see that the struct
&gt;&gt; mii_bus *bus member is NULL.
&gt;&gt;
&gt;&gt; So should I be able to change it via the MAC's control register and
&gt;&gt; something else is wrong?  Why is there no struct mii_bus?  Can I talk to
&gt;&gt; the MII hardware in some other way?
&gt;&gt;
&gt;&gt; Thanks,
&gt;&gt; Daniel
&gt;&gt;
&gt;&gt; https://download.villagetelco.org/hardware/MT7620/MT7620_ProgrammingGuide.pdf
&gt;&gt;



-- 
Met vriendelijke groet,

René van Dorst


]