public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Josua Mayer <josua@solid-run.com>
To: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: "u-boot@lists.denx.de" <u-boot@lists.denx.de>,
	Yazan Shhady <yazan.shhady@solid-run.com>,
	Tom Rini <trini@konsulko.com>, Stefano Babic <sbabic@denx.de>,
	Fabio Estevam <festevam@gmail.com>,
	NXP i.MX U-Boot Team <uboot-imx@nxp.com>,
	Baruch Siach <baruch@tkos.co.il>,
	Marcel Ziswiler <marcel.ziswiler@toradex.com>
Subject: Re: [PATCH] mx6cuboxi: fix ethernet after synchronise device-tree
Date: Wed, 27 Mar 2024 13:20:04 +0000	[thread overview]
Message-ID: <1c077133-dbd4-4255-89af-259a2ca686c2@solid-run.com> (raw)
In-Reply-To: <CAH9NwWd2smg+vC=hHx1XbRPS569Mxzr4HNghwA9DUQUyYf-OKA@mail.gmail.com>

Am 27.03.24 um 13:17 schrieb Christian Gmeiner:
> Hi Josua
>
> My bisect showed me that after a device-tree sync the ethernet broke.
>
>> please take a look at this patch, I suspect it will (hack-)fix your
>> ethernet issue.
>>
> Yes.. it fixes the problem I am seeing.
>
>> Unfortunately I had no time to revisit this yet and implement a correct solution.
>>
> Would it be okay for you if I look into a proper solution?

Sure. I am swamped by other products at the moment.

However I will provide a rough overview what needs to be done:

Background: i.MX6 SoMs originally had a an atheros phy at unstable address,
either 0 or 4 depending on electrical noise on floating configuration signals.

Linux had solved this by placing 2 phy nodes in device-tree.
During boot the kernel would attempt in order to probe the phys,
then link the successful one to the ethernet netdev.
As a side-effect there is always an error in the kernel log for one of the
addresses.

U-Boot had something similar in that with a special address (I think 0xff)
in device-tree, the code will probe mdio bus for all addresses, but only
for a single phy node in dts.

With release of SoM 2.0 we changed to an analog devices phy at address 1,
which most importantly uses a different driver, and requires a different description
in device-tree.

When adding this new phy, as a third node in device-tree, kernel maintainers
requested a better solution, and we got u-boot to runtime patch dtb to update
status properties of the dtb for linux, after probing mdio bus for phys.


Now - what u-boot needs to do is probe the mdio bus, and then runtime-patch its own DTB.
Either with status properties, or for adding the phy-handle property (not sure which method will work).

This somehow has to happen after probing mdio driver, but before probing ethernet driver.

> I have a
> handful of such devices here
> that are already or will be used in a CI farm so I am interested in
> using the latest U-Boot for them.
>
>> sincerely
>> Josua Mayer
>>
>> Am 28.07.22 um 09:08 schrieb Josua Mayer:
>>> Please hold off merging this patch until someone tested it, I can not do so this week.
>>> @Tom Can you confirm if this fixes the networking on your Cubox?
>>> Also note that the phy-handle property may or may not be required, I am not sure.
>>>
>>> sincerely
>>> Josua Mayer
>>>
>>> On Thu, Jul 28, 2022 at 7:05 AM Josua Mayer <josua@solid-run.com> wrote:
>>>
>>>     The i.MX6 Cubox-i and HummingBoards can have different PHYs at varying
>>>     addresses. U-Boot needs to auto-detect which phy is actually present,
>>>     and at which address it is responding.
>>>
>>>     Auto-detection from multiple phy nodes specified in device-tree does not
>>>     currently work correct. As a work-around merge all three possible phys
>>>     into one node with the special address 0xffffffff which indicates to the
>>>     generic phy driver to probe all addresses.
>>>     Also fixup this fake address before booting Linux, *if* booting with
>>>     U-Boot's internal dtb.
>>>
>>>     Signed-off-by: Josua Mayer <josua@solid-run.com>
>>>     Fixes: d0399a46e7cd
>>>     ---
>>>      arch/arm/dts/imx6qdl-sr-som.dtsi     | 30 +++++++++-------------------
>>>      board/solidrun/mx6cuboxi/mx6cuboxi.c |  6 +++++-
>>>      2 files changed, 14 insertions(+), 22 deletions(-)
>>>
>>>     diff --git a/arch/arm/dts/imx6qdl-sr-som.dtsi b/arch/arm/dts/imx6qdl-sr-som.dtsi
>>>     index ce543e325c..2d7cbc26b3 100644
>>>     ---_a/arch/arm/dts/imx6qdl-sr-som.dtsi
>>>     +++ b/arch/arm/dts/imx6qdl-sr-som.dtsi
>>>     @@ -53,6 +53,7 @@
>>>      &fec {
>>>             pinctrl-names = "default";
>>>             pinctrl-0 = <&pinctrl_microsom_enet_ar8035>;
>>>     +       phy-handle = <&phy>;
>>>             phy-mode = "rgmii-id";
>>>
>>>             /*
>>>     @@ -68,30 +69,17 @@
>>>                     #address-cells = <1>;
>>>                     #size-cells = <0>;
>>>
>>>     -               /*
>>>     -                * The PHY can appear at either address 0 or 4 due to the
>>>     -                * configuration (LED) pin not being pulled sufficiently.
>>>     -                */
>>>     -               ethernet-phy@0 {
>>>     -                       reg = <0>;
>>>     +               phy: ethernet-phy@0 {
>>>     +                       /*
>>>     +                        * The PHY can appear either:
>>>     +                        * - AR8035: at address 0 or 4
>>>     +                        * - ADIN1300: at address 1
>>>     +                        * Actual address being detected at runtime.
>>>     +                        */
>>>     +                       reg = <0xffffffff>;
>>>                             qca,clk-out-frequency = <125000000>;
>>>                             qca,smarteee-tw-us-1g = <24>;
>>>     -               };
>>>     -
>>>     -               ethernet-phy@4 {
>>>     -                       reg = <4>;
>>>     -                       qca,clk-out-frequency = <125000000>;
>>>     -                       qca,smarteee-tw-us-1g = <24>;
>>>     -               };
>>>     -
>>>     -               /*
>>>     -                * ADIN1300 (som rev 1.9 or later) is always at address 1. It
>>>     -                * will be enabled automatically by U-Boot if detected.
>>>     -                */
>>>     -               ethernet-phy@1 {
>>>     -                       reg = <1>;
>>>                             adi,phy-output-clock = "125mhz-free-running";
>>>     -                       status = "disabled";
>>>                     };
>>>             };
>>>      };
>>>     diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
>>>     index debf4f6a3b..52172a03b1 100644
>>>     ---_a/board/solidrun/mx6cuboxi/mx6cuboxi.c
>>>     +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
>>>     @@ -446,7 +446,7 @@ static int find_ethernet_phy(void)
>>>       */
>>>      int ft_board_setup(void *fdt, struct bd_info *bd)
>>>      {
>>>     -       int node_phy0, node_phy1, node_phy4;
>>>     +       int node_phy, node_phy0, node_phy1, node_phy4;
>>>             int ret, phy;
>>>             bool enable_phy0 = false, enable_phy1 = false, enable_phy4 = false;
>>>             enum board_type board;
>>>     @@ -478,6 +478,10 @@ int ft_board_setup(void *fdt, struct bd_info *bd)
>>>                     return 0;
>>>             }
>>>
>>>     +       // update U-Boot's own unified phy node phy address, if present
>>>     +       node_phy = fdt_path_offset(fdt, "/soc/bus@2100000/ethernet@2188000/mdio/phy");
>>>     +       ret = fdt_setprop_u32(fdt, node_phy, "reg", phy);
>>>     +
>>>             // update all phy nodes status
>>>             node_phy0 = fdt_path_offset(fdt, "/soc/bus@2100000/ethernet@2188000/mdio/ethernet-phy@0");
>>>             ret = fdt_setprop_string(fdt, node_phy0, "status", enable_phy0 ? "okay" : "disabled");
>>>     --_
>>>     2.37.1
>>>

  reply	other threads:[~2024-03-27 13:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220728070540.28554-1-josua@solid-run.com>
2022-07-28  7:08 ` [PATCH] mx6cuboxi: fix ethernet after synchronise device-tree Josua Mayer
2022-07-28 11:11   ` Fabio Estevam
2022-07-28 11:16   ` Tom Rini
2024-03-27 12:06   ` Josua Mayer
2024-03-27 12:17     ` Christian Gmeiner
2024-03-27 13:20       ` Josua Mayer [this message]
2024-03-27 15:55         ` Christian Gmeiner
2024-03-27 16:54           ` Josua Mayer
2024-03-27 19:29     ` Fabio Estevam
2024-03-27 21:04       ` Fabio Estevam
2024-03-27 23:17         ` Fabio Estevam
2024-03-28  7:08           ` Christian Gmeiner
2022-07-28 11:41 ` Tom Rini
2022-07-28 11:51   ` Fabio Estevam
2022-07-28 12:01     ` Tom Rini

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=1c077133-dbd4-4255-89af-259a2ca686c2@solid-run.com \
    --to=josua@solid-run.com \
    --cc=baruch@tkos.co.il \
    --cc=christian.gmeiner@gmail.com \
    --cc=festevam@gmail.com \
    --cc=marcel.ziswiler@toradex.com \
    --cc=sbabic@denx.de \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-imx@nxp.com \
    --cc=yazan.shhady@solid-run.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox