powerpc/85xx: introduce function serdes_device_from_fm_port()
authorTimur Tabi <timur@freescale.com>
Tue, 14 Aug 2012 06:47:23 +0000 (06:47 +0000)
committerAndy Fleming <afleming@freescale.com>
Thu, 23 Aug 2012 15:24:18 +0000 (10:24 -0500)
In order to figure out which SerDes lane a given Fman port is connected
to, we need a function that maps the fm_port namespace to the srds_prtcl
namespace.

Signed-off-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Andy Fleming <afleming@freescale.com>
board/freescale/common/fman.c
board/freescale/common/fman.h

index 6ddf816201219f14efc37fa83c907d54f8ee5f3e..3ef49369a4738fca3dbe25e7a39e006170df8f85 100644 (file)
@@ -25,6 +25,9 @@
 #include <libfdt_env.h>
 #include <fdt_support.h>
 
+#include <fm_eth.h>
+#include <asm/fsl_serdes.h>
+
 /*
  * Given the following ...
  *
@@ -67,3 +70,31 @@ int fdt_set_phy_handle(void *fdt, char *compat, phys_addr_t addr,
 
        return fdt_setprop(fdt, offset, "phy-handle", &ph, sizeof(ph));
 }
+
+/*
+ * Return the SerDes device enum for a given Fman port
+ *
+ * This function just maps the fm_port namespace to the srds_prtcl namespace.
+ */
+enum srds_prtcl serdes_device_from_fm_port(enum fm_port port)
+{
+       static const enum srds_prtcl srds_table[] = {
+               [FM1_DTSEC1] = SGMII_FM1_DTSEC1,
+               [FM1_DTSEC2] = SGMII_FM1_DTSEC2,
+               [FM1_DTSEC3] = SGMII_FM1_DTSEC3,
+               [FM1_DTSEC4] = SGMII_FM1_DTSEC4,
+               [FM1_DTSEC5] = SGMII_FM1_DTSEC5,
+               [FM1_10GEC1] = XAUI_FM1,
+               [FM2_DTSEC1] = SGMII_FM2_DTSEC1,
+               [FM2_DTSEC2] = SGMII_FM2_DTSEC2,
+               [FM2_DTSEC3] = SGMII_FM2_DTSEC3,
+               [FM2_DTSEC4] = SGMII_FM2_DTSEC4,
+               [FM2_DTSEC5] = SGMII_FM2_DTSEC5,
+               [FM2_10GEC1] = XAUI_FM2,
+       };
+
+       if ((port < FM1_DTSEC1) || (port > FM2_10GEC1))
+               return NONE;
+       else
+               return srds_table[port];
+}
index d39ef080c1f7eeb7159b828293a0d81e23431daa..734b1da1d6791b91e7924f07ccad9e290216d8c2 100644 (file)
@@ -23,4 +23,6 @@
 int fdt_set_phy_handle(void *fdt, char *compat, phys_addr_t addr,
                        const char *alias);
 
+enum srds_prtcl serdes_device_from_fm_port(enum fm_port port);
+
 #endif