/*
sopc2dts - Devicetree generation for Altera systems

Copyright (C) 2011 Walter Goossens <waltergoossens@home.nl>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/
package sopc2dts.lib.components.altera;

import sopc2dts.lib.components.Interface;
import sopc2dts.lib.components.SopcComponentDescription;
import sopc2dts.lib.components.BasicComponent;
import sopc2dts.lib.components.base.SICEthernet;

public class SICTrippleSpeedEthernet extends SICEthernet {
	enum PhyMode { MII, GMII, RGMII, SGMII };
	private static final long serialVersionUID = -3828128314484790124L;

	public SICTrippleSpeedEthernet(String cName, String iName, String ver, SopcComponentDescription scd) {
		super(cName, iName, ver, scd);
	}

	protected BasicComponent getDMAEngineForIntf(Interface intf)
	{
		if((intf!=null) && (intf.getConnections().size()>0))
		{
			BasicComponent comp = null;
			if(intf.isMaster())
			{
				comp = intf.getConnections().firstElement().getSlaveModule();
			} else {
				comp = intf.getConnections().firstElement().getMasterModule();
			}
			return comp;
		}
		return null;
	}
	protected PhyMode getPhyMode()
	{
		String phyModeString = getParamValByName("ifGMII");
		PhyMode pm = PhyMode.RGMII;
		if(phyModeString.equals("MII"))
		{
			pm = PhyMode.MII;
		} else if(phyModeString.equals("MII_GMII"))
		{
			pm = PhyMode.GMII;
		} else if(phyModeString.equals("RGMII"))
		{
			pm = PhyMode.RGMII;
		} else if(phyModeString.equals("SGMII"))
		{
			pm = PhyMode.SGMII;
		}
		return pm;
	}
	protected String getPhyModeString()
	{
		switch(getPhyMode())
		{
		case MII:	return "mii";
		case GMII:	return "gmii";
		case RGMII:	return "rgmii";
		case SGMII:	return "sgmii";
		default:	return "unknown";
		}
	}
}

@@ -858,16 +858,74 @@
 ltera;%0A%0A
+import sopc2dts.Logger;%0Aimport sopc2dts.Logger.LogLevel;%0A%0A
 import s
@@ -1885,16 +1885,81 @@
 GMII%22);%0A
+%09%09String phyModeStringsgmii = getParamValByName(%22enable_sgmii%22);%0A
 %09%09PhyMod
@@ -1990,32 +1990,37 @@
 if(phyModeString
+sgmii
 .equals(%22MII%22))%0A
@@ -2012,19 +2012,20 @@
 equals(%22
-MII
+true
 %22))%0A%09%09%7B%0A
@@ -2019,32 +2019,73 @@
 %22true%22))%0A%09%09%7B%0A%09%09%09
+Logger.logln(%22enable_sgmii%22);%09%0A%09%09        
 pm = PhyMode.MII
@@ -2081,30 +2081,51 @@
 PhyMode.
+SG
 MII;%0A
-%09%09
+                
 %7D else 
+%7B%0A%09%09%09
 if(phyMo
@@ -2148,21 +2148,18 @@
 %22MII
-_GMII
 %22))%0A%09%09
+%09
 %7B%0A
+%09
 %09%09%09p
@@ -2170,24 +2170,24 @@
 PhyMode.
-G
 MII;%0A%09%09
+%09
 %7D else i
@@ -2210,17 +2210,20 @@
 equals(%22
-R
+MII_
 GMII%22))%0A
@@ -2216,34 +2216,36 @@
 (%22MII_GMII%22))%0A%09%09
+%09
 %7B%0A
+%09
 %09%09%09pm = PhyMode.
@@ -2244,23 +2244,23 @@
 PhyMode.
-R
 GMII;%0A
+%09
 %09%09%7D else
@@ -2285,17 +2285,17 @@
 equals(%22
-S
+R
 GMII%22))%0A
@@ -2296,18 +2296,20 @@
 II%22))%0A%09%09
+%09
 %7B%0A
+%09
 %09%09%09pm = 
@@ -2316,23 +2316,28 @@
 PhyMode.
-S
+R
 GMII;%0A
+%09%09%09%7D%0A
 %09%09%7D%0A%09%09re

Fix selection of Phy interface mode, ifGMII will not ever be SGMII, you need to check "enable_sgmii"