public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jagan Teki <jagan@amarulasolutions.com>
To: u-boot@lists.denx.de
Subject: [PATCH 2/8] board: engicam: Fix the ethernet clock initialization
Date: Mon, 30 Dec 2019 17:34:03 +0530	[thread overview]
Message-ID: <20191230120409.884-3-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20191230120409.884-1-jagan@amarulasolutions.com>

From: Michael Trimarchi <michael@amarulasolutions.com>

According to the SOM and reference board the clock
can be taken from the external pin or provided from
ENET_REF_CLK. Add a new function that make the proper
set according the board type.

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 board/engicam/common/board.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/board/engicam/common/board.c b/board/engicam/common/board.c
index 992d209cbd..6472d382c9 100644
--- a/board/engicam/common/board.c
+++ b/board/engicam/common/board.c
@@ -10,6 +10,8 @@
 #include <env.h>
 #include <init.h>
 #include <mmc.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/imx-regs.h>
 #include <asm/arch/sys_proto.h>
 #include <watchdog.h>
 
@@ -101,6 +103,32 @@ static enum engicam_boards engicam_board_detect(void)
 	return -EINVAL;
 }
 
+static int fixup_enet_clock(enum engicam_boards board_detected)
+{
+	struct iomuxc *iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
+	int clk_internal = 0;
+
+	switch (board_detected) {
+	case IMX6Q_ICORE_MIPI:
+	case IMX6DL_ICORE_MIPI:
+		clk_internal = 1;
+		break;
+	default:
+		break;
+	}
+
+	/* set gpr1[21] to select anatop clock */
+	debug("fixup_enet_clock %d\n", clk_internal);
+	clrsetbits_le32(&iomuxc_regs->gpr[1], 0x1 << 21, clk_internal << 21);
+
+	if (!clk_internal) {
+		/* clock is external */
+		return 0;
+	}
+
+	return enable_fec_anatop_clock(0, ENET_50MHZ);
+}
+
 int board_late_init(void)
 {
 	enum engicam_boards board_detected = IMX6Q_ICORE;
@@ -133,6 +161,7 @@ int board_late_init(void)
 	if (board_detected < 0)
 		hang();
 
+	fixup_enet_clock(board_detected);
 	setenv_fdt_file(board_detected);
 
 #ifdef CONFIG_HW_WATCHDOG
-- 
2.18.0.321.gffc6fa0e3

  parent reply	other threads:[~2019-12-30 12:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-30 12:04 [PATCH 0/8] i.MX6: Engicam fixes/updates Jagan Teki
2019-12-30 12:04 ` [PATCH 1/8] board: engicam: Cleanup fdt file and board mapping Jagan Teki
2019-12-30 12:04 ` Jagan Teki [this message]
2019-12-30 12:04 ` [PATCH 3/8] configs: imx6-engicam: Drop fec phy address and mode Jagan Teki
2019-12-30 12:04 ` [PATCH 4/8] dt-bindings: sound: Add fsl-imx-audmux.h from v5.4 Jagan Teki
2019-12-30 12:04 ` [PATCH 5/8] ARM: dts: icorem6: Sync engicam device trees " Jagan Teki
2019-12-30 12:04 ` [PATCH 6/8] ARM: dts: imx6q-icore-mipi: Use 1.5 version of i.Core MX6DL Jagan Teki
2019-12-30 12:04 ` [PATCH 7/8] ARM: dts: imx6qdl-icore-1.5: Remove duplicate phy reset methods Jagan Teki
2019-12-30 12:04 ` [PATCH 8/8] ARM: dts: imx6qdli-icore: Add fec phy-handle Jagan Teki
2019-12-30 17:24   ` Michael Nazzareno Trimarchi
2019-12-31  6:21     ` Jagan Teki
2020-01-03 11:33       ` Stefano Babic
2020-01-03 16:43         ` Jagan Teki

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=20191230120409.884-3-jagan@amarulasolutions.com \
    --to=jagan@amarulasolutions.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