If using UCC as Ethernet Controller and type = FAST_ETH, it was
not possible to switch between 10 and 100 MBit interfaces. This
patch adds this for following interfaces:

10_MII
10_RMII
10_RGMII
100_MII
100_RMII
100_RGMII

Signed-off-by: Heiko Schocher <h...@denx.de>
---
 drivers/qe/uec.c |   73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/drivers/qe/uec.c b/drivers/qe/uec.c
index db95ada..9851cc4 100644
--- a/drivers/qe/uec.c
+++ b/drivers/qe/uec.c
@@ -65,6 +65,22 @@ static uec_info_t uec_info[] = {

 #define MAXCONTROLLERS (8)

+static char *enet_interface_name[] = {
+       "10_MII",
+       "10_RMII",
+       "10_RGMII",
+       "100_MII",
+       "100_RMII",
+       "100_RGMII",
+       "1000_GMII",
+       "1000_RGMII",
+       "1000_RGMII_ID",
+       "1000_RGMII_RXID",
+       "1000_TBI",
+       "1000_RTBI",
+       "1000_SGMII"
+};
+
 static struct eth_device *devlist[MAXCONTROLLERS];

 u16 phy_read (struct uec_mii_info *mii_info, u16 regnum);
@@ -497,6 +513,60 @@ bus_fail:
        return err;
 }

+static  void adjust_fast_enet_interface(int speed, struct eth_device *dev)
+{
+       uec_private_t   *uec = (uec_private_t *)dev->priv;
+       uec_t           *uec_regs;
+       int             change = 0;
+
+       extern void change_phy_interface_mode(struct eth_device *dev,
+                                        enet_interface_e mode);
+       uec_regs = uec->uec_regs;
+
+       switch (speed) {
+       case 100:
+               switch (uec->uec_info->enet_interface) {
+               case ENET_10_MII:
+               case ENET_10_RMII:
+               case ENET_10_RGMII:
+                       uec->uec_info->enet_interface += 3;
+                       change = 1;
+                       break;
+               default:
+                       break;
+               }
+               break;
+       case 10:
+               switch (uec->uec_info->enet_interface) {
+               case ENET_100_MII:
+               case ENET_100_RMII:
+               case ENET_100_RGMII:
+                       uec->uec_info->enet_interface -= 3;
+                       change = 1;
+                       break;
+               default:
+                       break;
+               }
+               break;
+       default:
+               /* do nothing, not supported yet */
+               printf("%s: speed: %d and mode: %d not supported yet.\n",
+                       __func__, speed, uec->uec_info->enet_interface);
+               break;
+       }
+       if (change) {
+               printf ("switching to %s\n",
+                       enet_interface_name[uec->uec_info->enet_interface]);
+               /* change phy */
+               change_phy_interface_mode(dev,
+                       uec->uec_info->enet_interface);
+               /* change the MAC interface mode */
+               uec_set_mac_if_mode(uec,
+                       uec->uec_info->enet_interface);
+
+       }
+}
+
 static void adjust_link(struct eth_device *dev)
 {
        uec_private_t           *uec = (uec_private_t *)dev->priv;
@@ -547,6 +617,8 @@ static void adjust_link(struct eth_device *dev)
                                                dev->name, mii_info->speed);
                                        break;
                                }
+                       } else if (uec->uec_info->uf_info.eth_type == FAST_ETH) 
{
+                               adjust_fast_enet_interface(mii_info->speed, 
dev);
                        }

                        printf("%s: Speed %dBT\n", dev->name, mii_info->speed);
@@ -1215,6 +1287,7 @@ static int uec_init(struct eth_device* dev, bd_t *bd)
                if (err || i <= 0)
                        printf("warning: %s: timeout on PHY link\n", dev->name);

+               adjust_link(dev);
                uec->the_first_run = 1;
        }

-- 
1.6.2.5

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to