public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: "Stefan Roese" <sr@denx.de>, "Marek Behún" <marek.behun@nic.cz>
Cc: u-boot@lists.denx.de
Subject: [PATCH 1/2] arm: mvebu: turris_mox: Convert comphy_update_map() to board_fix_fdt()
Date: Tue, 18 Jan 2022 10:33:19 +0100	[thread overview]
Message-ID: <20220118093320.1150-2-pali@kernel.org> (raw)
In-Reply-To: <20220118093320.1150-1-pali@kernel.org>

Code in board_fix_fdt() already detects connected MOX modules so there is
no need to have custom comphy_update_map() function for setting serdes
speeds.

This change sets phy-mode for MOX SFP module (when present) to sgmii.
Comphy driver then sets sgmii serdes speed for this module to 1.25G.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 board/CZ.NIC/turris_mox/turris_mox.c | 48 +++++++++-------------------
 1 file changed, 15 insertions(+), 33 deletions(-)

diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c
index 3eb5cb425606..f0c5aa6a520b 100644
--- a/board/CZ.NIC/turris_mox/turris_mox.c
+++ b/board/CZ.NIC/turris_mox/turris_mox.c
@@ -21,7 +21,6 @@
 #include <linux/libfdt.h>
 #include <linux/string.h>
 #include <miiphy.h>
-#include <mvebu/comphy.h>
 #include <spi.h>
 
 #include "mox_sp.h"
@@ -49,6 +48,7 @@ int board_fix_fdt(void *blob)
 	enum fdt_status status_pcie, status_eth1;
 	u8 topology[MAX_MOX_MODULES];
 	int i, size, ret;
+	bool eth1_sgmii;
 
 	/*
 	 * SPI driver is not loaded in driver model yet, but we have to find out
@@ -69,6 +69,7 @@ int board_fix_fdt(void *blob)
 
 	status_pcie = FDT_STATUS_DISABLED;
 	status_eth1 = FDT_STATUS_DISABLED;
+	eth1_sgmii = false;
 
 	for (i = 0; i < MAX_MOX_MODULES; ++i) {
 		writel(0x0, ARMADA_37XX_SPI_DOUT);
@@ -82,6 +83,10 @@ int board_fix_fdt(void *blob)
 
 		topology[i] &= 0xf;
 
+		if (topology[i] == MOX_MODULE_SFP &&
+		    status_pcie == FDT_STATUS_DISABLED)
+			eth1_sgmii = true;
+
 		if (topology[i] == MOX_MODULE_SFP ||
 		    topology[i] == MOX_MODULE_TOPAZ ||
 		    topology[i] == MOX_MODULE_PERIDOT)
@@ -98,6 +103,15 @@ int board_fix_fdt(void *blob)
 		printf("Cannot set status for eth1 in U-Boot's device tree: %s!\n",
 		       fdt_strerror(ret));
 
+	if (eth1_sgmii) {
+		ret = fdt_path_offset(blob, "ethernet1");
+		if (ret >= 0)
+			ret = fdt_setprop_string(blob, ret, "phy-mode", "sgmii");
+		if (ret < 0)
+			printf("Cannot set phy-mode for eth1 to sgmii in U-Boot device tree: %s!\n",
+			       fdt_strerror(ret));
+	}
+
 	if (size > 1 && (topology[1] == MOX_MODULE_PCI ||
 			 topology[1] == MOX_MODULE_USB3 ||
 			 topology[1] == MOX_MODULE_PASSPCI))
@@ -199,38 +213,6 @@ static int mox_get_topology(const u8 **ptopology, int *psize, int *pis_sd)
 	return 0;
 }
 
-int comphy_update_map(struct comphy_map *serdes_map, int count)
-{
-	int ret, i, size, sfpindex = -1, swindex = -1;
-	const u8 *topology;
-
-	ret = mox_get_topology(&topology, &size, NULL);
-	if (ret)
-		return ret;
-
-	for (i = 0; i < size; ++i) {
-		if (topology[i] == MOX_MODULE_SFP && sfpindex == -1)
-			sfpindex = i;
-		else if ((topology[i] == MOX_MODULE_TOPAZ ||
-			  topology[i] == MOX_MODULE_PERIDOT) &&
-			 swindex == -1)
-			swindex = i;
-	}
-
-	if (sfpindex >= 0 && swindex >= 0) {
-		if (sfpindex < swindex)
-			serdes_map[0].speed = COMPHY_SPEED_1_25G;
-		else
-			serdes_map[0].speed = COMPHY_SPEED_3_125G;
-	} else if (sfpindex >= 0) {
-		serdes_map[0].speed = COMPHY_SPEED_1_25G;
-	} else if (swindex >= 0) {
-		serdes_map[0].speed = COMPHY_SPEED_3_125G;
-	}
-
-	return 0;
-}
-
 #define SW_SMI_CMD_R(d, r)	(0x9800 | (((d) & 0x1f) << 5) | ((r) & 0x1f))
 #define SW_SMI_CMD_W(d, r)	(0x9400 | (((d) & 0x1f) << 5) | ((r) & 0x1f))
 
-- 
2.20.1


  reply	other threads:[~2022-01-18  9:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18  9:33 [PATCH 0/2] arm: mvebu: Remove comphy_update_map() Pali Rohár
2022-01-18  9:33 ` Pali Rohár [this message]
2022-01-18 11:17   ` [PATCH 1/2] arm: mvebu: turris_mox: Convert comphy_update_map() to board_fix_fdt() Stefan Roese
2022-01-18  9:33 ` [PATCH 2/2] phy: marvell: Remove unused function comphy_update_map() Pali Rohár
2022-01-18 11:18   ` Stefan Roese
2022-01-20 16:22 ` [PATCH 0/2] arm: mvebu: Remove comphy_update_map() Stefan Roese

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=20220118093320.1150-2-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=marek.behun@nic.cz \
    --cc=sr@denx.de \
    --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