From: Timur Tabi Date: Fri, 10 Aug 2012 17:01:33 -0500 Subject: [U-Boot] [PATCH 3/6] powerpc/85xx: introduce function serdes_device_from_fm_port() In-Reply-To: <1344636096-11669-1-git-send-email-timur@freescale.com> References: <1344636096-11669-1-git-send-email-timur@freescale.com> Message-ID: <1344636096-11669-3-git-send-email-timur@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- board/freescale/common/fman.c | 40 ++++++++++++++++++++++++++++++++++++++++ board/freescale/common/fman.h | 2 ++ 2 files changed, 42 insertions(+), 0 deletions(-) diff --git a/board/freescale/common/fman.c b/board/freescale/common/fman.c index 6ddf816..58b7c44 100644 --- a/board/freescale/common/fman.c +++ b/board/freescale/common/fman.c @@ -25,6 +25,9 @@ #include #include +#include +#include + /* * Given the following ... * @@ -67,3 +70,40 @@ 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) +{ + switch (port) { + case FM1_DTSEC1: + return SGMII_FM1_DTSEC1; + case FM1_DTSEC2: + return SGMII_FM1_DTSEC2; + case FM1_DTSEC3: + return SGMII_FM1_DTSEC3; + case FM1_DTSEC4: + return SGMII_FM1_DTSEC4; + case FM1_DTSEC5: + return SGMII_FM1_DTSEC5; + case FM1_10GEC1: + return XAUI_FM1; + case FM2_DTSEC1: + return SGMII_FM2_DTSEC1; + case FM2_DTSEC2: + return SGMII_FM2_DTSEC2; + case FM2_DTSEC3: + return SGMII_FM2_DTSEC3; + case FM2_DTSEC4: + return SGMII_FM2_DTSEC4; + case FM2_DTSEC5: + return SGMII_FM2_DTSEC5; + case FM2_10GEC1: + return XAUI_FM2; + default: + return NONE; + } +} diff --git a/board/freescale/common/fman.h b/board/freescale/common/fman.h index d39ef08..734b1da 100644 --- a/board/freescale/common/fman.h +++ b/board/freescale/common/fman.h @@ -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 -- 1.7.3.4