U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: u-boot@lists.denx.de
Subject: U-Boot atheros PHY support and cubox ethernet
Date: Wed, 17 Jun 2020 15:00:20 -0400	[thread overview]
Message-ID: <20200617190020.GF27801@bill-the-cat> (raw)
In-Reply-To: <CAOMZO5CFW1gnSUcji3mKxhdyEM-tyvFc+vta-Q9wvb1Uh3rPHg@mail.gmail.com>

On Wed, Jun 17, 2020 at 09:04:44AM -0300, Fabio Estevam wrote:
> Hi Tom,
> 
> On Tue, Jun 16, 2020 at 7:30 PM Tom Rini <trini@konsulko.com> wrote:
> 
> > Yeah, OK, I got far enough on trying to convert this that I see I don't
> > quite have time to pick it up and run with it.  It looks like there's
> > going to be some extra fun around resetting the PHY perhaps?  My quick
> > pass got things seeing a generic PHY and not the atheros one.  If you
> > have time to make something you'd like me to test for conversion let me
> > know.  But I'm going to pick up debugging the problem I see on the
> > platform right now in case there's a wider problem it's showing.
> 
> Here are two untested patches you could try.

Based on your follow-up patches, I think you'll be unsurprised it
doesn't work.  I get:
Net:   Could not get PHY for FEC0: addr 0

Now, question:
> -	ret = dm_gpio_lookup_name("GPIO4_15", &desc);
> -	if (ret) {
> -		printf("%s: phy reset lookup failed\n", __func__);
> -		return;
> -	}
> -
> -	ret = dm_gpio_request(&desc, "phy-reset");
> -	if (ret) {
> -		printf("%s: phy reset request failed\n", __func__);
> -		return;
> -	}
> -
> -	gpio_direction_output(ETH_PHY_RESET, 0);
> -	mdelay(10);
> -	gpio_set_value(ETH_PHY_RESET, 1);
> -	udelay(100);
> -
> -	gpio_free_list_nodev(&desc, 1);

Don't we need that still, but in a setup_fec() call?  I have a quick
test with:

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index a2c2bb9e354e..89b0d8680658 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -17,6 +17,7 @@
 #include <image.h>
 #include <init.h>
 #include <log.h>
+#include <net.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/iomux.h>
@@ -33,6 +34,7 @@
 #include <fsl_esdhc_imx.h>
 #include <malloc.h>
 #include <miiphy.h>
+#include <netdev.h>
 #include <asm/arch/crm_regs.h>
 #include <asm/io.h>
 #include <asm/arch/sys_proto.h>
@@ -50,15 +52,6 @@ DECLARE_GLOBAL_DATA_PTR;
 	PAD_CTL_SPEED_LOW | PAD_CTL_DSE_80ohm |			\
 	PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
 
-#define ENET_PAD_CTRL  (PAD_CTL_PUS_100K_UP |			\
-	PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
-
-#define ENET_PAD_CTRL_PD  (PAD_CTL_PUS_100K_DOWN |		\
-	PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
-
-#define ENET_PAD_CTRL_CLK  ((PAD_CTL_PUS_100K_UP & ~PAD_CTL_PKE) | \
-	PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
-
 #define ETH_PHY_RESET	IMX_GPIO_NR(4, 15)
 #define USB_H1_VBUS	IMX_GPIO_NR(1, 0)
 
@@ -235,6 +228,51 @@ int board_mmc_init(bd_t *bis)
 	return 0;
 }
 
+#ifdef CONFIG_FEC_MXC
+static int setup_fec(void)
+{
+	struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
+	struct gpio_desc desc;
+
+	int ret = enable_fec_anatop_clock(0, ENET_25MHZ);
+	if (ret)
+		return ret;
+
+	/* set gpr1[ENET_CLK_SEL] */
+	setbits_le32(&iomuxc_regs->gpr[1], IOMUXC_GPR1_ENET_CLK_SEL_MASK);
+
+	/* Reset PHY */
+	ret = dm_gpio_lookup_name("GPIO4_15", &desc);
+	if (ret) {
+		printf("%s: phy reset lookup failed\n", __func__);
+		return ret;
+	}
+
+	ret = dm_gpio_request(&desc, "phy-reset");
+	if (ret) {
+		printf("%s: phy reset request failed\n", __func__);
+		return ret;
+	}
+
+	gpio_direction_output(ETH_PHY_RESET, 0);
+	mdelay(10);
+	gpio_set_value(ETH_PHY_RESET, 1);
+	udelay(100);
+
+	gpio_free_list_nodev(&desc, 1);
+
+	return 0;
+}
+#endif
+
+int board_phy_config(struct phy_device *phydev)
+{
+	if (phydev->drv->config)
+		phydev->drv->config(phydev);
+
+	return 0;
+}
+
 #ifdef CONFIG_VIDEO_IPUV3
 static void do_enable_hdmi(struct display_info_t const *dev)
 {
@@ -344,6 +382,12 @@ int board_init(void)
 	/* address of boot parameters */
 	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
 
+#ifdef CONFIG_FEC_MXC
+	ret = setup_fec();
+	if (ret)
+		return ret;
+#endif
+
 #ifdef CONFIG_VIDEO_IPUV3
 	ret = setup_display();
 #endif

And at run-time I get:
Warning: ethernet at 2188000 using MAC address from ROM
eth0: ethernet at 2188000
...
=> mdio list
FEC0:
0 - AR8035 <--> ethernet at 2188000

And I did the mdio write/read's from the previous part of the thread and
get the same values.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200617/c20b9ef4/attachment.sig>

  parent reply	other threads:[~2020-06-17 19:00 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-16 19:55 U-Boot atheros PHY support and cubox ethernet Tom Rini
2020-06-16 19:58 ` Vladimir Oltean
2020-06-16 20:10   ` Tom Rini
2020-06-16 20:21     ` Vladimir Oltean
2020-06-16 20:31       ` Tom Rini
2020-06-16 20:37         ` Vladimir Oltean
2020-06-16 21:35           ` Tom Rini
2020-06-16 21:57             ` Vladimir Oltean
2020-06-17  7:19               ` Michael Walle
2020-06-16 21:30       ` Michael Walle
2020-06-16 21:37         ` Tom Rini
2020-06-16 20:42 ` Fabio Estevam
2020-06-16 20:48   ` Vladimir Oltean
2020-06-16 20:51   ` Tom Rini
2020-06-16 20:55     ` Fabio Estevam
2020-06-16 20:58       ` Tom Rini
2020-06-16 21:01         ` Fabio Estevam
2020-06-16 22:30           ` Tom Rini
2020-06-17 12:04             ` Fabio Estevam
2020-06-17 13:06               ` Fabio Estevam
2020-06-17 13:23                 ` Tom Rini
2020-06-17 17:31                   ` Fabio Estevam
2020-06-17 19:00               ` Tom Rini [this message]
2020-06-17 19:09                 ` Fabio Estevam
2020-06-17 19:18                   ` Fabio Estevam
2020-06-17 19:24                     ` Tom Rini
2020-06-17 19:19                   ` Tom Rini
2020-06-17 21:28                 ` Fabio Estevam
2020-06-17 21:30                   ` Tom Rini
2020-06-18  0:41                     ` Fabio Estevam
2020-06-18 13:39                       ` Tom Rini
2020-06-20  2:14                         ` Fabio Estevam
2020-06-24 19:20                           ` Soeren Moch
2020-06-24 19:39                             ` Fabio Estevam
2020-06-24 20:13                               ` Soeren Moch
2020-06-24 20:29                                 ` Fabio Estevam
2020-06-24 20:45                                   ` Sören Moch
2020-06-24 21:35                                     ` Fabio Estevam
2020-06-24 22:29                                       ` Soeren Moch
2020-06-24 23:19                                         ` Fabio Estevam
2020-06-24 23:44                                           ` Fabio Estevam
2020-06-25  9:56                                           ` Soeren Moch
2020-06-25 10:26                                             ` Fabio Estevam
2020-06-18  3:05                   ` Fabio Estevam
2020-06-16 21:01         ` Vladimir Oltean
2020-06-16 21:04           ` Vladimir Oltean
2020-06-16 21:57             ` Tom Rini
2020-06-16 21:59               ` Vladimir Oltean
2020-06-16 21:50           ` 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=20200617190020.GF27801@bill-the-cat \
    --to=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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