powerpc/8xxx: Add fdt_fixup_phy_connection helper

Add a common helper that will set the PHY connection type based on enum.
We use this on eTSEC, UCC, and will with Fman in the future.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
This commit is contained in:
Kumar Gala
2010-09-30 09:15:03 -05:00
parent f8c42495e0
commit a1964ea5c2
5 changed files with 38 additions and 15 deletions

View File

@ -27,6 +27,7 @@
#include <libfdt.h> #include <libfdt.h>
#include <fdt_support.h> #include <fdt_support.h>
#include <asm/mp.h> #include <asm/mp.h>
#include <asm/fsl_enet.h>
#if defined(CONFIG_MP) && (defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)) #if defined(CONFIG_MP) && (defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx))
static int ft_del_cpuhandle(void *blob, int cpuhandle) static int ft_del_cpuhandle(void *blob, int cpuhandle)
@ -215,3 +216,26 @@ void fdt_fixup_crypto_node(void *blob, int sec_rev)
fdt_del_node_and_alias(blob, "crypto"); fdt_del_node_and_alias(blob, "crypto");
} }
#endif #endif
int fdt_fixup_phy_connection(void *blob, int offset, enum fsl_phy_enet_if phyc)
{
static const char *fsl_phy_enet_if_str[] = {
[MII] = "mii",
[RMII] = "rmii",
[GMII] = "gmii",
[RGMII] = "rgmii",
[RGMII_ID] = "rgmii-id",
[RGMII_RXID] = "rgmii-rxid",
[SGMII] = "sgmii",
[TBI] = "tbi",
[RTBI] = "rtbi",
[XAUI] = "xgmii",
[FSL_ETH_IF_NONE] = "",
};
if (phyc > ARRAY_SIZE(fsl_phy_enet_if_str))
return fdt_setprop_string(blob, offset, "phy-connection-type", "");
return fdt_setprop_string(blob, offset, "phy-connection-type",
fsl_phy_enet_if_str[phyc]);
}

View File

@ -28,4 +28,6 @@ enum fsl_phy_enet_if {
FSL_ETH_IF_NONE, FSL_ETH_IF_NONE,
}; };
int fdt_fixup_phy_connection(void *blob, int offset, enum fsl_phy_enet_if phyc);
#endif /* __ASM_PPC_FSL_ENET_H */ #endif /* __ASM_PPC_FSL_ENET_H */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2006 Freescale Semiconductor, Inc. * Copyright (C) 2006,2010 Freescale Semiconductor, Inc.
* Dave Liu <daveliu@freescale.com> * Dave Liu <daveliu@freescale.com>
* *
* See file CREDITS for list of people who contributed to this * See file CREDITS for list of people who contributed to this
@ -22,6 +22,7 @@
#include <spd_sdram.h> #include <spd_sdram.h>
#include <asm/mmu.h> #include <asm/mmu.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/fsl_enet.h>
#if defined(CONFIG_OF_LIBFDT) #if defined(CONFIG_OF_LIBFDT)
#include <libfdt.h> #include <libfdt.h>
#endif #endif
@ -396,10 +397,8 @@ void ft_board_setup(void *blob, bd_t *bd)
prop = fdt_getprop(blob, path, prop = fdt_getprop(blob, path,
"phy-connection-type", 0); "phy-connection-type", 0);
if (prop && (strcmp(prop, "rgmii-id") == 0)) if (prop && (strcmp(prop, "rgmii-id") == 0))
fdt_setprop(blob, path, fdt_fixup_phy_connection(blob, path,
"phy-connection-type", RGMII_RXID);
"rgmii-rxid",
sizeof("rgmii-rxid"));
} }
#endif #endif
#if defined(CONFIG_HAS_ETH1) #if defined(CONFIG_HAS_ETH1)
@ -410,10 +409,8 @@ void ft_board_setup(void *blob, bd_t *bd)
prop = fdt_getprop(blob, path, prop = fdt_getprop(blob, path,
"phy-connection-type", 0); "phy-connection-type", 0);
if (prop && (strcmp(prop, "rgmii-id") == 0)) if (prop && (strcmp(prop, "rgmii-id") == 0))
fdt_setprop(blob, path, fdt_fixup_phy_connection(blob, path,
"phy-connection-type", RGMII_RXID);
"rgmii-rxid",
sizeof("rgmii-rxid"));
} }
#endif #endif
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2007 Freescale Semiconductor, Inc. * Copyright (C) 2007,2010 Freescale Semiconductor, Inc.
* Dave Liu <daveliu@freescale.com> * Dave Liu <daveliu@freescale.com>
* *
* CREDITS: Kim Phillips contribute to LIBFDT code * CREDITS: Kim Phillips contribute to LIBFDT code
@ -15,6 +15,7 @@
#include <i2c.h> #include <i2c.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/fsl_mpc83xx_serdes.h> #include <asm/fsl_mpc83xx_serdes.h>
#include <asm/fsl_enet.h>
#include <spd_sdram.h> #include <spd_sdram.h>
#include <tsec.h> #include <tsec.h>
#include <libfdt.h> #include <libfdt.h>
@ -136,7 +137,6 @@ int board_eth_init(bd_t *bd)
static void __ft_tsec_fixup(void *blob, bd_t *bd, const char *alias, static void __ft_tsec_fixup(void *blob, bd_t *bd, const char *alias,
int phy_addr) int phy_addr)
{ {
const char *phy_type = "sgmii";
const u32 *ph; const u32 *ph;
int off; int off;
int err; int err;
@ -148,8 +148,8 @@ static void __ft_tsec_fixup(void *blob, bd_t *bd, const char *alias,
return; return;
} }
err = fdt_setprop(blob, off, "phy-connection-type", phy_type, err = fdt_fixup_phy_connection(blob, off, SGMII);
strlen(phy_type) + 1);
if (err) { if (err) {
printf("WARNING: could not set phy-connection-type for %s: " printf("WARNING: could not set phy-connection-type for %s: "
"%s.\n", alias, fdt_strerror(err)); "%s.\n", alias, fdt_strerror(err));

View File

@ -622,8 +622,8 @@ void ft_board_setup(void *blob, bd_t *bd)
break; break;
} }
err = fdt_setprop_string(blob, nodeoff, "phy-connection-type", err = fdt_fixup_phy_connection(blob, nodeoff, RMII);
"rmii");
if (err < 0) { if (err < 0) {
printf("WARNING: could not set phy-connection-type " printf("WARNING: could not set phy-connection-type "
"%s.\n", fdt_strerror(err)); "%s.\n", fdt_strerror(err));