Merge "[qca-ssdk]: Add register access for Malibu"
diff --git a/include/api/api_desc.h b/include/api/api_desc.h
index 47e339b..09531ec 100755
--- a/include/api/api_desc.h
+++ b/include/api/api_desc.h
@@ -358,18 +358,18 @@
 #define SW_API_PT_MAGIC_FRAME_MAC_SET_DESC \
     SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \
     SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \
-    SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_SET, SW_MACADDR, sizeof(fal_mac_addr_t), SW_PARAM_PTR|SW_PARAM_IN, "Magic mac"),
+    SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_SET, SW_MACADDR, sizeof(fal_mac_addr_t), SW_PARAM_PTR|SW_PARAM_IN, "[Magic mac]"),
 
 #define SW_API_PT_MAGIC_FRAME_MAC_GET_DESC \
     SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \
     SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \
-    SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_GET, SW_MACADDR, sizeof(fal_mac_addr_t), SW_PARAM_PTR|SW_PARAM_OUT, "Magic mac"),
+    SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_GET, SW_MACADDR, sizeof(fal_mac_addr_t), SW_PARAM_PTR|SW_PARAM_OUT, "[Magic mac]"),
 
 #define SW_API_PT_PHY_ID_GET_DESC \
     SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \
     SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \
-    SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT16, 4, SW_PARAM_PTR|SW_PARAM_OUT, "Org ID"), \
-    SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT16, 4, SW_PARAM_PTR|SW_PARAM_OUT, "Rev ID"),
+    SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT16, 2, SW_PARAM_PTR|SW_PARAM_OUT, "Org ID"), \
+    SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT16, 2, SW_PARAM_PTR|SW_PARAM_OUT, "Rev ID"),
 
 #define SW_API_PT_WOL_STATUS_SET_DESC \
     SW_PARAM_DEF(SW_API_PT_WOL_STATUS_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \
diff --git a/src/hsl/dess/dess_port_ctrl.c b/src/hsl/dess/dess_port_ctrl.c
index 2599321..618302d 100755
--- a/src/hsl/dess/dess_port_ctrl.c
+++ b/src/hsl/dess/dess_port_ctrl.c
@@ -73,7 +73,12 @@
     {
       return SW_BAD_PARAM;
     }
+  rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id);
+      SW_RTN_ON_ERROR (rv);
 
+      rv = phy_drv->phy_duplex_set (dev_id, phy_id, duplex);
+      SW_RTN_ON_ERROR (rv);
+#if 0
   HSL_REG_ENTRY_GET (rv, dev_id, PORT_STATUS, port_id,
 		     (a_uint8_t *) (&reg_val), sizeof (a_uint32_t));
 
@@ -126,6 +131,7 @@
 
   HSL_REG_ENTRY_SET (rv, dev_id, PORT_STATUS, port_id,
 		     (a_uint8_t *) (&reg_save), sizeof (a_uint32_t));
+  #endif
   return rv;
 }
 
@@ -134,7 +140,8 @@
 		       fal_port_duplex_t * pduplex)
 {
   sw_error_t rv = SW_OK;
-  a_uint32_t reg, field;
+  a_uint32_t phy_id,reg, field;
+  hsl_phy_ops_t *phy_drv;
 
   HSL_DEV_ID_CHECK (dev_id);
 
@@ -143,6 +150,17 @@
       return SW_BAD_PARAM;
     }
 
+  SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id));
+  if (NULL == phy_drv->phy_duplex_get)
+    return SW_NOT_SUPPORTED;
+
+  rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id);
+      SW_RTN_ON_ERROR (rv);
+
+      rv = phy_drv->phy_duplex_get (dev_id, phy_id, pduplex);
+      SW_RTN_ON_ERROR (rv);
+
+#if 0
   HSL_REG_ENTRY_GET (rv, dev_id, PORT_STATUS, port_id,
 		     (a_uint8_t *) (&reg), sizeof (a_uint32_t));
   SW_GET_FIELD_BY_REG (PORT_STATUS, DUPLEX_MODE, field, reg);
@@ -155,6 +173,8 @@
       *pduplex = FAL_HALF_DUPLEX;
     }
 
+#endif
+
   return rv;
 }
 
@@ -182,6 +202,12 @@
       return SW_BAD_PARAM;
     }
 
+  rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id);
+      SW_RTN_ON_ERROR (rv);
+
+      rv = phy_drv->phy_speed_set (dev_id, phy_id, speed);
+      SW_RTN_ON_ERROR (rv);
+#if 0
   HSL_REG_ENTRY_GET (rv, dev_id, PORT_STATUS, port_id,
 		     (a_uint8_t *) (&reg_val), sizeof (a_uint32_t));
 
@@ -243,6 +269,7 @@
 
   HSL_REG_ENTRY_SET (rv, dev_id, PORT_STATUS, port_id,
 		     (a_uint8_t *) (&reg_save), sizeof (a_uint32_t));
+  #endif
   return rv;
 }
 
@@ -251,7 +278,8 @@
 		      fal_port_speed_t * pspeed)
 {
   sw_error_t rv = SW_OK;
-  a_uint32_t reg, field;
+  a_uint32_t phy_id,reg, field;
+  hsl_phy_ops_t *phy_drv;
 
   HSL_DEV_ID_CHECK (dev_id);
 
@@ -260,6 +288,17 @@
       return SW_BAD_PARAM;
     }
 
+  SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id));
+  if (NULL == phy_drv->phy_speed_get)
+    return SW_NOT_SUPPORTED;
+
+  rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id);
+      SW_RTN_ON_ERROR (rv);
+
+      rv = phy_drv->phy_speed_get (dev_id, phy_id, pspeed);
+      SW_RTN_ON_ERROR (rv);
+
+#if 0
   HSL_REG_ENTRY_GET (rv, dev_id, PORT_STATUS, port_id,
 		     (a_uint8_t *) (&reg), sizeof (a_uint32_t));
   SW_RTN_ON_ERROR (rv);
@@ -282,6 +321,7 @@
       *pspeed = FAL_SPEED_BUTT;
       rv = SW_READ_ERROR;
     }
+#endif
 
   return rv;
 }
diff --git a/src/hsl/phy/malibu_phy.c b/src/hsl/phy/malibu_phy.c
index c74f1c9..7b873de 100755
--- a/src/hsl/phy/malibu_phy.c
+++ b/src/hsl/phy/malibu_phy.c
@@ -270,6 +270,26 @@
 
 /******************************************************************************
 *
+* malibu_phy_reset - reset the phy
+*
+* reset the phy
+*/
+sw_error_t malibu_phy_reset(a_uint32_t dev_id, a_uint32_t phy_id)
+{
+	a_uint16_t phy_data;
+
+	if (phy_id == COMBO_PHY_ID)
+		__phy_reg_pages_sel_by_active_medium(dev_id, phy_id);
+
+	phy_data = malibu_phy_reg_read(dev_id, phy_id, MALIBU_PHY_CONTROL);
+	malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_CONTROL,
+			     phy_data | MALIBU_CTRL_SOFTWARE_RESET);
+
+	return SW_OK;
+}
+
+/******************************************************************************
+*
 * malibu_phy_set_powersave - set power saving status
 *
 * set power saving status
@@ -582,6 +602,7 @@
 	if (mode == PHY_MDIX_AUTO) {
 		phy_data |= MALIBU_PHY_MDIX_AUTO;
 	} else if (mode == PHY_MDIX_MDIX) {
+		phy_data &= ~MALIBU_PHY_MDIX_AUTO;
 		phy_data |= MALIBU_PHY_MDIX;
 	} else if (mode == PHY_MDIX_MDI) {
 		phy_data &= ~MALIBU_PHY_MDIX_AUTO;
@@ -591,6 +612,7 @@
 
 	malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_SPEC_CONTROL, phy_data);
 
+	malibu_phy_reset(dev_id, phy_id);
 	return SW_OK;
 }
 
@@ -732,7 +754,7 @@
 {
 	a_uint16_t phy_data;
 
-	phy_data == malibu_phy_mmd_read(dev_id, phy_id, MALIBU_PHY_MMD3_NUM,
+	phy_data = malibu_phy_mmd_read(dev_id, phy_id, MALIBU_PHY_MMD3_NUM,
 					MALIBU_PHY_MMD3_ADDR_REMOTE_LOOPBACK_CTRL);
 
 	if (enable == A_TRUE) {
@@ -760,7 +782,7 @@
 {
 	a_uint16_t phy_data;
 
-	phy_data == malibu_phy_mmd_read(dev_id, phy_id, MALIBU_PHY_MMD3_NUM,
+	phy_data = malibu_phy_mmd_read(dev_id, phy_id, MALIBU_PHY_MMD3_NUM,
 					MALIBU_PHY_MMD3_ADDR_REMOTE_LOOPBACK_CTRL);
 
 	if (phy_data & 0x0001) {
@@ -1065,26 +1087,6 @@
 
 /******************************************************************************
 *
-* malibu_phy_reset - reset the phy
-*
-* reset the phy
-*/
-sw_error_t malibu_phy_reset(a_uint32_t dev_id, a_uint32_t phy_id)
-{
-	a_uint16_t phy_data;
-
-	if (phy_id == COMBO_PHY_ID)
-		__phy_reg_pages_sel_by_active_medium(dev_id, phy_id);
-
-	phy_data = malibu_phy_reg_read(dev_id, phy_id, MALIBU_PHY_CONTROL);
-	malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_CONTROL,
-			     phy_data | MALIBU_CTRL_SOFTWARE_RESET);
-
-	return SW_OK;
-}
-
-/******************************************************************************
-*
 * malibu_phy_off - power off the phy 
 *
 * Power off the phy
@@ -1608,88 +1610,6 @@
 
 /******************************************************************************
 *
-* malibu_phy_set_speed - Determines the speed of phy ports associated with the
-* specified device.
-*/
-sw_error_t
-malibu_phy_set_speed(a_uint32_t dev_id, a_uint32_t phy_id,
-		     fal_port_speed_t speed)
-{
-	a_uint16_t phy_data = 0;
-	a_uint16_t phy_status = 0;
-
-	a_uint32_t autoneg, oldneg;
-	fal_port_duplex_t old_duplex;
-
-	if (phy_id == COMBO_PHY_ID) {
-		if (MALIBU_PHY_MEDIUM_COPPER !=
-		    __phy_active_medium_get(dev_id, phy_id))
-
-			return SW_NOT_SUPPORTED;
-
-		__phy_reg_pages_sel(dev_id, phy_id, MALIBU_PHY_COPPER_PAGES);
-	}
-
-	if (FAL_SPEED_1000 == speed) {
-		phy_data |= MALIBU_CTRL_SPEED_1000;
-	} else if (FAL_SPEED_100 == speed) {
-		phy_data |= MALIBU_CTRL_SPEED_100;
-	} else if (FAL_SPEED_10 == speed) {
-		phy_data |= MALIBU_CTRL_SPEED_10;
-	} else {
-		return SW_BAD_PARAM;
-	}
-
-	phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
-
-	(void)malibu_phy_get_autoneg_adv(dev_id, phy_id, &autoneg);
-	oldneg = autoneg;
-	autoneg &= ~FAL_PHY_ADV_GE_SPEED_ALL;
-
-	(void)malibu_phy_get_duplex(dev_id, phy_id, &old_duplex);
-
-	if (old_duplex == FAL_FULL_DUPLEX) {
-		phy_data |= MALIBU_CTRL_FULL_DUPLEX;
-
-		if (FAL_SPEED_1000 == speed) {
-			autoneg |= FAL_PHY_ADV_1000T_FD;
-		} else if (FAL_SPEED_100 == speed) {
-			autoneg |= FAL_PHY_ADV_100TX_FD;
-		} else {
-			autoneg |= FAL_PHY_ADV_10T_FD;
-		}
-	} else if (old_duplex == FAL_HALF_DUPLEX) {
-		phy_data &= ~MALIBU_CTRL_FULL_DUPLEX;
-
-		if (FAL_SPEED_100 == speed) {
-			autoneg |= FAL_PHY_ADV_100TX_HD;
-		} else {
-			autoneg |= FAL_PHY_ADV_10T_HD;
-		}
-	} else {
-		return SW_FAIL;
-	}
-
-	(void)malibu_phy_set_autoneg_adv(dev_id, phy_id, autoneg);
-	(void)malibu_phy_restart_autoneg(dev_id, phy_id);
-	if (malibu_phy_get_link_status(dev_id, phy_id)) {
-		do {
-			phy_status =
-			    malibu_phy_reg_read(dev_id, phy_id,
-						MALIBU_PHY_STATUS);
-		}
-		while (!MALIBU_AUTONEG_DONE(phy_status));
-	}
-
-	malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_CONTROL, phy_data);
-	(void)malibu_phy_set_autoneg_adv(dev_id, phy_id, oldneg);
-
-	return SW_OK;
-
-}
-
-/******************************************************************************
-*
 * malibu_phy_get_duplex - Determines the speed of phy ports associated with the
 * specified device.
 */
@@ -1716,6 +1636,80 @@
 
 /******************************************************************************
 *
+* malibu_phy_set_speed - Determines the speed of phy ports associated with the
+* specified device.
+*/
+sw_error_t
+malibu_phy_set_speed(a_uint32_t dev_id, a_uint32_t phy_id,
+		     fal_port_speed_t speed)
+{
+	a_uint16_t phy_data = 0;
+	a_uint16_t phy_status = 0;
+
+	a_uint32_t autoneg, oldneg;
+	fal_port_duplex_t old_duplex;
+
+	if (phy_id == COMBO_PHY_ID) {
+		if (MALIBU_PHY_MEDIUM_COPPER !=
+		    __phy_active_medium_get(dev_id, phy_id))
+
+			return SW_NOT_SUPPORTED;
+
+		__phy_reg_pages_sel(dev_id, phy_id, MALIBU_PHY_COPPER_PAGES);
+	}
+
+	phy_data = malibu_phy_reg_read(dev_id, phy_id, MALIBU_PHY_CONTROL);
+
+	malibu_phy_get_duplex(dev_id, phy_id, &old_duplex);
+
+	if (old_duplex == FAL_FULL_DUPLEX) {
+		phy_data |= MALIBU_CTRL_FULL_DUPLEX;
+
+		if (FAL_SPEED_1000 == speed) {
+			phy_data |= MALIBU_CTRL_SPEED_1000;
+			phy_data &= ~MALIBU_CTRL_SPEED_100;
+			phy_data |= MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+		} else if (FAL_SPEED_100 == speed) {
+			phy_data |= MALIBU_CTRL_SPEED_100;
+			phy_data &= ~MALIBU_CTRL_SPEED_1000;
+			phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+		} else if (FAL_SPEED_10 == speed){
+			phy_data &= ~MALIBU_CTRL_SPEED_100;
+			phy_data &= ~MALIBU_CTRL_SPEED_1000;
+			phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+		} else {
+		return SW_BAD_PARAM;
+		}
+	} else if (old_duplex == FAL_HALF_DUPLEX) {
+		phy_data &= ~MALIBU_CTRL_FULL_DUPLEX;
+
+		if (FAL_SPEED_100 == speed) {
+			phy_data |= MALIBU_CTRL_SPEED_100;
+			phy_data &= ~MALIBU_CTRL_SPEED_1000;
+			phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+		} else if (FAL_SPEED_10 == speed) {
+			phy_data &= ~MALIBU_CTRL_SPEED_100;
+			phy_data &= ~MALIBU_CTRL_SPEED_1000;
+			phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+		} else if (FAL_SPEED_10000== speed){
+            phy_data |= MALIBU_CTRL_FULL_DUPLEX;
+            phy_data |= MALIBU_CTRL_SPEED_1000;
+		    phy_data &= ~MALIBU_CTRL_SPEED_100;
+		    phy_data |= MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+		} else {
+		return SW_BAD_PARAM;
+	       }
+	} else {
+		return SW_FAIL;
+	}
+
+	malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_CONTROL, phy_data);
+	return SW_OK;
+
+}
+
+/******************************************************************************
+*
 * malibu_phy_set_duplex - Determines the speed of phy ports associated with the
 * specified device.
 */
@@ -1749,6 +1743,18 @@
 				} else {
 					return SW_BAD_PARAM;
 				}
+				} else {
+
+					if (duplex == FAL_FULL_DUPLEX) {
+					phy_data |= MALIBU_CTRL_FULL_DUPLEX;
+					phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+				} else if (duplex == FAL_HALF_DUPLEX) {
+					phy_data &= ~MALIBU_CTRL_FULL_DUPLEX;
+					phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+				} else {
+					return SW_BAD_PARAM;
+				}
+					} 
 				malibu_phy_reg_write(dev_id, phy_id,
 						     MALIBU_PHY_CONTROL,
 						     phy_data);
@@ -1756,115 +1762,64 @@
 				return SW_OK;
 			}
 
-			if (A_TRUE == malibu_phy_autoneg_status(dev_id, phy_id))
-				phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
-
-			(void)malibu_phy_get_autoneg_adv(dev_id, phy_id,
-							 &autoneg);
-			oldneg = autoneg;
-			autoneg &= ~FAL_PHY_ADV_BX_SPEED_ALL;
-			(void)malibu_phy_get_speed(dev_id, phy_id, &old_speed);
-
-			if (FAL_SPEED_1000 == old_speed) {
-				phy_data |= MALIBU_CTRL_SPEED_1000;
-			} else {
-				return SW_FAIL;
-			}
-
-			if (duplex == FAL_FULL_DUPLEX) {
-				phy_data |= MALIBU_CTRL_FULL_DUPLEX;
-
-				if (FAL_SPEED_1000 == old_speed) {
-					autoneg = FAL_PHY_ADV_1000BX_FD;
-				}
-			} else if (duplex == FAL_HALF_DUPLEX) {
-				phy_data &= ~MALIBU_CTRL_FULL_DUPLEX;
-
-				if (FAL_SPEED_1000 == old_speed) {
-					autoneg = FAL_PHY_ADV_1000BX_HD;
-				}
-			} else {
-				return SW_BAD_PARAM;
-			}
-
-			(void)malibu_phy_set_autoneg_adv(dev_id, phy_id,
-							 autoneg);
-			(void)malibu_phy_restart_autoneg(dev_id, phy_id);
-			if (malibu_phy_get_link_status(dev_id, phy_id)) {
-				do {
-					phy_status =
-					    malibu_phy_reg_read(dev_id, phy_id,
-								MALIBU_PHY_STATUS);
-				}
-				while (!MALIBU_AUTONEG_DONE(phy_status));
-			}
-
-			malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_CONTROL,
-					     phy_data);
-			(void)malibu_phy_set_autoneg_adv(dev_id, phy_id,
-							 oldneg);
-
-			return SW_OK;
-
 		} else {
 			__phy_reg_pages_sel(dev_id, phy_id,
 					    MALIBU_PHY_COPPER_PAGES);
 		}
-	}
 
-	if (A_TRUE == malibu_phy_autoneg_status(dev_id, phy_id))
-		phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+	phy_data = malibu_phy_reg_read(dev_id, phy_id, MALIBU_PHY_CONTROL);
 
-	(void)malibu_phy_get_autoneg_adv(dev_id, phy_id, &autoneg);
-	oldneg = autoneg;
-	autoneg &= ~FAL_PHY_ADV_GE_SPEED_ALL;
-	(void)malibu_phy_get_speed(dev_id, phy_id, &old_speed);
+       malibu_phy_get_speed(dev_id, phy_id, &old_speed);
 
-	if (FAL_SPEED_1000 == old_speed) {
-		phy_data |= MALIBU_CTRL_SPEED_1000;
-	} else if (FAL_SPEED_100 == old_speed) {
-		phy_data |= MALIBU_CTRL_SPEED_100;
-	} else if (FAL_SPEED_10 == old_speed) {
-		phy_data |= MALIBU_CTRL_SPEED_10;
-	} else {
-		return SW_FAIL;
-	}
+       if (old_speed == FAL_SPEED_1000) {
 
-	if (duplex == FAL_FULL_DUPLEX) {
+	    phy_data |= MALIBU_CTRL_SPEED_1000;
+	    phy_data &= ~MALIBU_CTRL_SPEED_100;
+	    phy_data |= MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+
+		if (duplex == FAL_FULL_DUPLEX) {
 		phy_data |= MALIBU_CTRL_FULL_DUPLEX;
 
-		if (FAL_SPEED_1000 == old_speed) {
-			autoneg = FAL_PHY_ADV_1000T_FD;
-		} else if (FAL_SPEED_100 == old_speed) {
-			autoneg = FAL_PHY_ADV_100TX_FD;
+		} else if (duplex == FAL_HALF_DUPLEX) {
+
+		return SW_NOT_SUPPORTED;
 		} else {
-			autoneg = FAL_PHY_ADV_10T_FD;
+		return SW_BAD_PARAM;
 		}
-	} else if (duplex == FAL_HALF_DUPLEX) {
+         } else if (old_speed == FAL_SPEED_100) {
+	       phy_data |= MALIBU_CTRL_SPEED_100;
+		phy_data &= ~MALIBU_CTRL_SPEED_1000;
+		phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+
+         if (duplex == FAL_FULL_DUPLEX) {
+		phy_data |= MALIBU_CTRL_FULL_DUPLEX;
+		
+		} else if (duplex == FAL_HALF_DUPLEX) {
+
 		phy_data &= ~MALIBU_CTRL_FULL_DUPLEX;
 
-		if (FAL_SPEED_100 == old_speed) {
-			autoneg = FAL_PHY_ADV_100TX_HD;
 		} else {
-			autoneg = FAL_PHY_ADV_10T_HD;
-		}
-	} else {
 		return SW_BAD_PARAM;
-	}
+		} 
+          } else if (old_speed == FAL_SPEED_10) {
+          	phy_data &= ~MALIBU_CTRL_SPEED_100;
+		phy_data &= ~MALIBU_CTRL_SPEED_1000;
+		phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
 
-	(void)malibu_phy_set_autoneg_adv(dev_id, phy_id, autoneg);
-	(void)malibu_phy_restart_autoneg(dev_id, phy_id);
-	if (malibu_phy_get_link_status(dev_id, phy_id)) {
-		do {
-			phy_status =
-			    malibu_phy_reg_read(dev_id, phy_id,
-						MALIBU_PHY_STATUS);
+         if (duplex == FAL_FULL_DUPLEX) {
+		phy_data |= MALIBU_CTRL_FULL_DUPLEX;
+		
+		} else if (duplex == FAL_HALF_DUPLEX) {
+
+		phy_data &= ~MALIBU_CTRL_FULL_DUPLEX;
+
+		} else {
+		return SW_BAD_PARAM;
 		}
-		while (!MALIBU_AUTONEG_DONE(phy_status));
-	}
-
-	malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_CONTROL, phy_data);
-	(void)malibu_phy_set_autoneg_adv(dev_id, phy_id, oldneg);
+          } else {
+             return SW_FAIL;
+          }
+		malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_CONTROL, phy_data);
 
 	return SW_OK;
 }
@@ -2254,7 +2209,7 @@
 	malibu_phy_api_ops.phy_powersave_get = malibu_phy_get_powersave;
 	malibu_phy_api_ops.phy_cdt = malibu_phy_cdt;
 	malibu_phy_api_ops.phy_link_status_get = malibu_phy_get_link_status;
-       malibu_phy_api_ops.phy_mdix_set = malibu_phy_set_mdix;
+        malibu_phy_api_ops.phy_mdix_set = malibu_phy_set_mdix;
 	malibu_phy_api_ops.phy_mdix_get = malibu_phy_get_mdix;
 	malibu_phy_api_ops.phy_mdix_status_get = malibu_phy_get_mdix_status;
 	malibu_phy_api_ops.phy_8023az_set = malibu_phy_set_8023az;
@@ -2281,7 +2236,7 @@
 	malibu_phy_api_ops.phy_magic_frame_mac_set = malibu_phy_set_magic_frame_mac;
 	malibu_phy_api_ops.phy_magic_frame_mac_get = malibu_phy_get_magic_frame_mac;
 	malibu_phy_api_ops.phy_wol_status_set = malibu_phy_set_wol_status;
-	malibu_phy_api_ops.phy_wol_status_get = malibu_phy_set_wol_status;
+	malibu_phy_api_ops.phy_wol_status_get = malibu_phy_get_wol_status;
 	malibu_phy_api_ops.phy_interface_mode_set = malibu_phy_interface_set_mode;
 	malibu_phy_api_ops.phy_interface_mode_get = malibu_phy_interface_get_mode;
 	malibu_phy_api_ops.phy_interface_mode_status_get = malibu_phy_interface_get_mode_status;