aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMatheos Worku <matheos.worku@sun.com>2008-05-12 06:10:59 -0400
committerDavid S. Miller <davem@davemloft.net>2008-05-12 06:10:59 -0400
commitf9af857489cc19ee3acd0d5248dca7d243e353a5 (patch)
treef3e57dd73eac47a651027182c823d9203000df64 /drivers
parent36ca34cc3b8335eb1fe8bd9a1d0a2592980c3f02 (diff)
niu: Determine the # of ports from the card's VPD data
Determine the number of physical ports from the card's VPD data. Previous fix failed on Maramba platform which doesn't have the "board-model" property. This fix uses the "model" property which exists on all cards and Neptune based motherboards. cstyle cleanup included. Signed-off-by: Matheos Worku <matheos.worku@sun.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/niu.c53
-rw-r--r--drivers/net/niu.h9
2 files changed, 30 insertions, 32 deletions
diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 57cfd72ffdf7..918f802fe089 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -865,7 +865,6 @@ static int link_status_1g_serdes(struct niu *np, int *link_up_p)
865 return 0; 865 return 0;
866} 866}
867 867
868
869static int link_status_10g_serdes(struct niu *np, int *link_up_p) 868static int link_status_10g_serdes(struct niu *np, int *link_up_p)
870{ 869{
871 unsigned long flags; 870 unsigned long flags;
@@ -900,7 +899,6 @@ static int link_status_10g_serdes(struct niu *np, int *link_up_p)
900 return 0; 899 return 0;
901} 900}
902 901
903
904static int link_status_1g_rgmii(struct niu *np, int *link_up_p) 902static int link_status_1g_rgmii(struct niu *np, int *link_up_p)
905{ 903{
906 struct niu_link_config *lp = &np->link_config; 904 struct niu_link_config *lp = &np->link_config;
@@ -957,7 +955,6 @@ out:
957 return err; 955 return err;
958} 956}
959 957
960
961static int bcm8704_reset(struct niu *np) 958static int bcm8704_reset(struct niu *np)
962{ 959{
963 int err, limit; 960 int err, limit;
@@ -1357,8 +1354,6 @@ static int mii_reset(struct niu *np)
1357 return 0; 1354 return 0;
1358} 1355}
1359 1356
1360
1361
1362static int xcvr_init_1g_rgmii(struct niu *np) 1357static int xcvr_init_1g_rgmii(struct niu *np)
1363{ 1358{
1364 int err; 1359 int err;
@@ -1419,7 +1414,6 @@ static int xcvr_init_1g_rgmii(struct niu *np)
1419 return 0; 1414 return 0;
1420} 1415}
1421 1416
1422
1423static int mii_init_common(struct niu *np) 1417static int mii_init_common(struct niu *np)
1424{ 1418{
1425 struct niu_link_config *lp = &np->link_config; 1419 struct niu_link_config *lp = &np->link_config;
@@ -7008,31 +7002,20 @@ static int __devinit niu_phy_type_prop_decode(struct niu *np,
7008 return 0; 7002 return 0;
7009} 7003}
7010 7004
7011/* niu board models have a trailing dash version incremented
7012 * with HW rev change. Need to ingnore the dash version while
7013 * checking for match
7014 *
7015 * for example, for the 10G card the current vpd.board_model
7016 * is 501-5283-04, of which -04 is the dash version and have
7017 * to be ignored
7018 */
7019static int niu_board_model_match(struct niu *np, const char *model)
7020{
7021 return !strncmp(np->vpd.board_model, model, strlen(model));
7022}
7023
7024static int niu_pci_vpd_get_nports(struct niu *np) 7005static int niu_pci_vpd_get_nports(struct niu *np)
7025{ 7006{
7026 int ports = 0; 7007 int ports = 0;
7027 7008
7028 if ((niu_board_model_match(np, NIU_QGC_LP_BM_STR)) || 7009 if ((!strcmp(np->vpd.model, NIU_QGC_LP_MDL_STR)) ||
7029 (niu_board_model_match(np, NIU_QGC_PEM_BM_STR)) || 7010 (!strcmp(np->vpd.model, NIU_QGC_PEM_MDL_STR)) ||
7030 (niu_board_model_match(np, NIU_ALONSO_BM_STR))) { 7011 (!strcmp(np->vpd.model, NIU_MARAMBA_MDL_STR)) ||
7012 (!strcmp(np->vpd.model, NIU_KIMI_MDL_STR)) ||
7013 (!strcmp(np->vpd.model, NIU_ALONSO_MDL_STR))) {
7031 ports = 4; 7014 ports = 4;
7032 } else if ((niu_board_model_match(np, NIU_2XGF_LP_BM_STR)) || 7015 } else if ((!strcmp(np->vpd.model, NIU_2XGF_LP_MDL_STR)) ||
7033 (niu_board_model_match(np, NIU_2XGF_PEM_BM_STR)) || 7016 (!strcmp(np->vpd.model, NIU_2XGF_PEM_MDL_STR)) ||
7034 (niu_board_model_match(np, NIU_FOXXY_BM_STR)) || 7017 (!strcmp(np->vpd.model, NIU_FOXXY_MDL_STR)) ||
7035 (niu_board_model_match(np, NIU_2XGF_MRVL_BM_STR))) { 7018 (!strcmp(np->vpd.model, NIU_2XGF_MRVL_MDL_STR))) {
7036 ports = 2; 7019 ports = 2;
7037 } 7020 }
7038 7021
@@ -7053,8 +7036,8 @@ static void __devinit niu_pci_vpd_validate(struct niu *np)
7053 return; 7036 return;
7054 } 7037 }
7055 7038
7056 if (!strcmp(np->vpd.model, "SUNW,CP3220") || 7039 if (!strcmp(np->vpd.model, NIU_ALONSO_MDL_STR) ||
7057 !strcmp(np->vpd.model, "SUNW,CP3260")) { 7040 !strcmp(np->vpd.model, NIU_KIMI_MDL_STR)) {
7058 np->flags |= NIU_FLAGS_10G; 7041 np->flags |= NIU_FLAGS_10G;
7059 np->flags &= ~NIU_FLAGS_FIBER; 7042 np->flags &= ~NIU_FLAGS_FIBER;
7060 np->flags |= NIU_FLAGS_XCVR_SERDES; 7043 np->flags |= NIU_FLAGS_XCVR_SERDES;
@@ -7065,7 +7048,7 @@ static void __devinit niu_pci_vpd_validate(struct niu *np)
7065 } 7048 }
7066 if (np->flags & NIU_FLAGS_10G) 7049 if (np->flags & NIU_FLAGS_10G)
7067 np->mac_xcvr = MAC_XCVR_XPCS; 7050 np->mac_xcvr = MAC_XCVR_XPCS;
7068 } else if (niu_board_model_match(np, NIU_FOXXY_BM_STR)) { 7051 } else if (!strcmp(np->vpd.model, NIU_FOXXY_MDL_STR)) {
7069 np->flags |= (NIU_FLAGS_10G | NIU_FLAGS_FIBER | 7052 np->flags |= (NIU_FLAGS_10G | NIU_FLAGS_FIBER |
7070 NIU_FLAGS_HOTPLUG_PHY); 7053 NIU_FLAGS_HOTPLUG_PHY);
7071 } else if (niu_phy_type_prop_decode(np, np->vpd.phy_type)) { 7054 } else if (niu_phy_type_prop_decode(np, np->vpd.phy_type)) {
@@ -7541,8 +7524,8 @@ static int __devinit walk_phys(struct niu *np, struct niu_parent *parent)
7541 u32 val; 7524 u32 val;
7542 int err; 7525 int err;
7543 7526
7544 if (!strcmp(np->vpd.model, "SUNW,CP3220") || 7527 if (!strcmp(np->vpd.model, NIU_ALONSO_MDL_STR) ||
7545 !strcmp(np->vpd.model, "SUNW,CP3260")) { 7528 !strcmp(np->vpd.model, NIU_KIMI_MDL_STR)) {
7546 num_10g = 0; 7529 num_10g = 0;
7547 num_1g = 2; 7530 num_1g = 2;
7548 parent->plat_type = PLAT_TYPE_ATCA_CP3220; 7531 parent->plat_type = PLAT_TYPE_ATCA_CP3220;
@@ -7551,7 +7534,7 @@ static int __devinit walk_phys(struct niu *np, struct niu_parent *parent)
7551 phy_encode(PORT_TYPE_1G, 1) | 7534 phy_encode(PORT_TYPE_1G, 1) |
7552 phy_encode(PORT_TYPE_1G, 2) | 7535 phy_encode(PORT_TYPE_1G, 2) |
7553 phy_encode(PORT_TYPE_1G, 3)); 7536 phy_encode(PORT_TYPE_1G, 3));
7554 } else if (niu_board_model_match(np, NIU_FOXXY_BM_STR)) { 7537 } else if (!strcmp(np->vpd.model, NIU_FOXXY_MDL_STR)) {
7555 num_10g = 2; 7538 num_10g = 2;
7556 num_1g = 0; 7539 num_1g = 0;
7557 parent->num_ports = 2; 7540 parent->num_ports = 2;
@@ -7946,6 +7929,7 @@ static int __devinit niu_get_of_props(struct niu *np)
7946 struct device_node *dp; 7929 struct device_node *dp;
7947 const char *phy_type; 7930 const char *phy_type;
7948 const u8 *mac_addr; 7931 const u8 *mac_addr;
7932 const char *model;
7949 int prop_len; 7933 int prop_len;
7950 7934
7951 if (np->parent->plat_type == PLAT_TYPE_NIU) 7935 if (np->parent->plat_type == PLAT_TYPE_NIU)
@@ -8000,6 +7984,11 @@ static int __devinit niu_get_of_props(struct niu *np)
8000 7984
8001 memcpy(dev->dev_addr, dev->perm_addr, dev->addr_len); 7985 memcpy(dev->dev_addr, dev->perm_addr, dev->addr_len);
8002 7986
7987 model = of_get_property(dp, "model", &prop_len);
7988
7989 if (model)
7990 strcpy(np->vpd.model, model);
7991
8003 return 0; 7992 return 0;
8004#else 7993#else
8005 return -EINVAL; 7994 return -EINVAL;
diff --git a/drivers/net/niu.h b/drivers/net/niu.h
index 97ffbe137bcb..12fd570b9423 100644
--- a/drivers/net/niu.h
+++ b/drivers/net/niu.h
@@ -2946,6 +2946,15 @@ struct rx_ring_info {
2946#define NIU_ALONSO_BM_STR "373-0202" 2946#define NIU_ALONSO_BM_STR "373-0202"
2947#define NIU_FOXXY_BM_STR "501-7961" 2947#define NIU_FOXXY_BM_STR "501-7961"
2948#define NIU_2XGF_MRVL_BM_STR "SK-6E82" 2948#define NIU_2XGF_MRVL_BM_STR "SK-6E82"
2949#define NIU_QGC_LP_MDL_STR "SUNW,pcie-qgc"
2950#define NIU_2XGF_LP_MDL_STR "SUNW,pcie-2xgf"
2951#define NIU_QGC_PEM_MDL_STR "SUNW,pcie-qgc-pem"
2952#define NIU_2XGF_PEM_MDL_STR "SUNW,pcie-2xgf-pem"
2953#define NIU_ALONSO_MDL_STR "SUNW,CP3220"
2954#define NIU_KIMI_MDL_STR "SUNW,CP3260"
2955#define NIU_MARAMBA_MDL_STR "SUNW,pcie-neptune"
2956#define NIU_FOXXY_MDL_STR "SUNW,pcie-rfem"
2957#define NIU_2XGF_MRVL_MDL_STR "SysKonnect,pcie-2xgf"
2949 2958
2950#define NIU_VPD_MIN_MAJOR 3 2959#define NIU_VPD_MIN_MAJOR 3
2951#define NIU_VPD_MIN_MINOR 4 2960#define NIU_VPD_MIN_MINOR 4