public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] powerpc/t2080qds: fixup dtb for 10g-kr
@ 2014-07-25 11:03 shh.xie at gmail.com
  2014-08-12 18:43 ` York Sun
  0 siblings, 1 reply; 2+ messages in thread
From: shh.xie at gmail.com @ 2014-07-25 11:03 UTC (permalink / raw)
  To: u-boot

From: Shaohui Xie <Shaohui.Xie@freescale.com>

XFI ports on t2080qds can work with fiber cable and direct attach
cable(copper). We use hwconfig to define cable type for XFI, and fixup
dtb based on the cable type.

For copper cable, set below env in hwconfig:

fsl_10gkr_copper:<10g_mac_name>

the <10g_mac_name> can be fm1_10g1, fm1_10g2, fm1_10g3, fm1_10g4.
fm1_10g1 stands for FM1-MAC9, fm1_10g2 stands for FM1-MAC10, fm1_10g3
stands for FM1-MAC1, fm1_10g4 stands for FM1-MAC2. The four
<10g_mac_name>s do not have to be coexist in hwconfig. For XFI ports, if
a given 10G port will use the copper cable for 10GBASE-KR, set the
<10g_mac_name> of the port in hwconfig, otherwise, fiber cable will be
assumed to be used for the port.

For ex. if four XFI ports will both use copper cable, the hwconfig
should contain:

fsl_10gkr_copper:fm1_10g1,fm1_10g2,fm1_10g3,fm1_10g4

Signed-off-by: Shaohui Xie <Shaohui.Xie@freescale.com>
---
 board/freescale/t208xqds/eth_t208xqds.c | 86 +++++++++++++++++++++++++++++----
 1 file changed, 77 insertions(+), 9 deletions(-)

diff --git a/board/freescale/t208xqds/eth_t208xqds.c b/board/freescale/t208xqds/eth_t208xqds.c
index 5879198..8675dbb 100644
--- a/board/freescale/t208xqds/eth_t208xqds.c
+++ b/board/freescale/t208xqds/eth_t208xqds.c
@@ -23,6 +23,7 @@
 #include <phy.h>
 #include <asm/fsl_dtsec.h>
 #include <asm/fsl_serdes.h>
+#include <hwconfig.h>
 #include "../common/qixis.h"
 #include "../common/fman.h"
 #include "t208xqds_qixis.h"
@@ -187,7 +188,12 @@ void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr,
 {
 	int phy;
 	char alias[20];
+	char lane_mode[2][20] = {"1000BASE-KX", "10GBASE-KR"};
+	char buf[32] = "serdes-1,";
 	struct fixed_link f_link;
+	int media_type = 0;
+	int off;
+
 	ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
 	u32 srds_s1 = in_be32(&gur->rcwsr[4]) &
 				FSL_CORENET2_RCWSR4_SRDS1_PRTCL;
@@ -265,15 +271,77 @@ void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr,
 		case 0x6c:
 		case 0x6d:
 		case 0x71:
-			f_link.phy_id = port;
-			f_link.duplex = 1;
-			f_link.link_speed = 10000;
-			f_link.pause = 0;
-			f_link.asym_pause = 0;
-			/* no PHY for XFI */
-			fdt_delprop(fdt, offset, "phy-handle");
-			fdt_setprop(fdt, offset, "fixed-link", &f_link,
-				    sizeof(f_link));
+			/*
+			* if the 10G is XFI, check hwconfig to see what is the
+			* media type, there are two types, fiber or copper,
+			* fix the dtb accordingly.
+			*/
+			switch (port) {
+			case FM1_10GEC1:
+			if (hwconfig_sub("fsl_10gkr_copper", "fm1_10g1")) {
+				/* it's MAC9 */
+				media_type = 1;
+				fdt_set_phy_handle(fdt, compat, addr,
+						"phy_xfi9");
+				fdt_status_okay_by_alias(fdt, "xfi_pcs_mdio9");
+				sprintf(buf, "%s%s%s", buf, "lane-a,",
+						(char *)lane_mode[1]);
+			}
+				break;
+			case FM1_10GEC2:
+			if (hwconfig_sub("fsl_10gkr_copper", "fm1_10g2")) {
+				/* it's MAC10 */
+				media_type = 1;
+				fdt_set_phy_handle(fdt, compat, addr,
+						"phy_xfi10");
+				fdt_status_okay_by_alias(fdt, "xfi_pcs_mdio10");
+				sprintf(buf, "%s%s%s", buf, "lane-b,",
+						(char *)lane_mode[1]);
+			}
+				break;
+			case FM1_10GEC3:
+			if (hwconfig_sub("fsl_10gkr_copper", "fm1_10g3")) {
+				/* it's MAC1 */
+				media_type = 1;
+				fdt_set_phy_handle(fdt, compat, addr,
+						"phy_xfi1");
+				fdt_status_okay_by_alias(fdt, "xfi_pcs_mdio1");
+				sprintf(buf, "%s%s%s", buf, "lane-c,",
+						(char *)lane_mode[1]);
+			}
+				break;
+			case FM1_10GEC4:
+			if (hwconfig_sub("fsl_10gkr_copper", "fm1_10g4")) {
+				/* it's MAC2 */
+				media_type = 1;
+				fdt_set_phy_handle(fdt, compat, addr,
+						"phy_xfi2");
+				fdt_status_okay_by_alias(fdt, "xfi_pcs_mdio2");
+				sprintf(buf, "%s%s%s", buf, "lane-d,",
+						(char *)lane_mode[1]);
+			}
+				break;
+			default:
+				return;
+			}
+
+			if (!media_type) {
+				/* fixed-link is used for XFI fiber cable */
+				f_link.phy_id = port;
+				f_link.duplex = 1;
+				f_link.link_speed = 10000;
+				f_link.pause = 0;
+				f_link.asym_pause = 0;
+				fdt_delprop(fdt, offset, "phy-handle");
+				fdt_setprop(fdt, offset, "fixed-link", &f_link,
+					sizeof(f_link));
+			} else {
+				/* set property for copper cable */
+				off = fdt_node_offset_by_compat_reg(fdt,
+					"fsl,fman-memac-mdio", addr + 0x1000);
+				fdt_setprop_string(fdt, off,
+					"lane-instance", buf);
+			}
 			break;
 		default:
 			break;
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH 1/2] powerpc/t2080qds: fixup dtb for 10g-kr
  2014-07-25 11:03 [U-Boot] [PATCH 1/2] powerpc/t2080qds: fixup dtb for 10g-kr shh.xie at gmail.com
@ 2014-08-12 18:43 ` York Sun
  0 siblings, 0 replies; 2+ messages in thread
From: York Sun @ 2014-08-12 18:43 UTC (permalink / raw)
  To: u-boot

On 07/25/2014 04:03 AM, shh.xie at gmail.com wrote:
> From: Shaohui Xie <Shaohui.Xie@freescale.com>
> 
> XFI ports on t2080qds can work with fiber cable and direct attach
> cable(copper). We use hwconfig to define cable type for XFI, and fixup
> dtb based on the cable type.
> 
> For copper cable, set below env in hwconfig:
> 
> fsl_10gkr_copper:<10g_mac_name>
> 
> the <10g_mac_name> can be fm1_10g1, fm1_10g2, fm1_10g3, fm1_10g4.
> fm1_10g1 stands for FM1-MAC9, fm1_10g2 stands for FM1-MAC10, fm1_10g3
> stands for FM1-MAC1, fm1_10g4 stands for FM1-MAC2. The four
> <10g_mac_name>s do not have to be coexist in hwconfig. For XFI ports, if
> a given 10G port will use the copper cable for 10GBASE-KR, set the
> <10g_mac_name> of the port in hwconfig, otherwise, fiber cable will be
> assumed to be used for the port.
> 
> For ex. if four XFI ports will both use copper cable, the hwconfig
> should contain:
> 
> fsl_10gkr_copper:fm1_10g1,fm1_10g2,fm1_10g3,fm1_10g4
> 

This information is useful. I think you should put it into a README file so it
can be easily found. Don't you agree?

York

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-12 18:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-25 11:03 [U-Boot] [PATCH 1/2] powerpc/t2080qds: fixup dtb for 10g-kr shh.xie at gmail.com
2014-08-12 18:43 ` York Sun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox