Merge with git://www.denx.de/git/u-boot.git
[platform/kernel/u-boot.git] / cpu / mpc8xx / fec.c
index 6006478..08a3715 100644 (file)
@@ -31,7 +31,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #undef ET_DEBUG
 
-#if (CONFIG_COMMANDS & CFG_CMD_NET) && \
+#if defined(CONFIG_CMD_NET) && \
        (defined(FEC_ENET) || defined(CONFIG_ETHER_ON_FEC1) || defined(CONFIG_ETHER_ON_FEC2))
 
 /* compatibility test, if only FEC_ENET defined assume ETHER on FEC1 */
@@ -49,7 +49,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #if defined(WANT_MII)
 #include <miiphy.h>
 
-#if !(defined(CONFIG_MII) || (CONFIG_COMMANDS & CFG_CMD_MII))
+#if !(defined(CONFIG_MII) || defined(CONFIG_CMD_MII))
 #error "CONFIG_MII has to be defined!"
 #endif
 
@@ -182,7 +182,7 @@ int fec_initialize(bd_t *bis)
 
                eth_register(dev);
 
-#if defined(CONFIG_MII) || (CONFIG_COMMANDS & CFG_CMD_MII)
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
                miiphy_register(dev->name,
                        fec8xx_miiphy_read, fec8xx_miiphy_write);
 #endif
@@ -268,7 +268,7 @@ static int fec_recv (struct eth_device *dev)
 
                        length -= 4;
 
-#if (CONFIG_COMMANDS & CFG_CMD_CDP)
+#if defined(CONFIG_CMD_CDP)
                        if ((rx[0] & 1) != 0
                            && memcmp ((uchar *) rx, NetBcastAddr, 6) != 0
                            && memcmp ((uchar *) rx, NetCDPAddr, 6) != 0)
@@ -396,8 +396,10 @@ static void fec_pin_init(int fecidx)
         * * to 2.5 MHz.
         * * This MDC frequency is equal to system clock / (2 * MII_SPEED).
         * * Then MII_SPEED = system_clock / 2 * 2,5 Mhz.
+        *
+        * All MII configuration is done via FEC1 registers:
         */
-       fecp->fec_mii_speed = ((bd->bi_intfreq + 4999999) / 5000000) << 1;
+       immr->im_cpm.cp_fec1.fec_mii_speed = ((bd->bi_intfreq + 4999999) / 5000000) << 1;
 
 #if defined(CONFIG_NETTA) || defined(CONFIG_NETPHONE) || defined(CONFIG_NETTA2)
        /* our PHYs are the limit at 2.5 MHz */
@@ -508,8 +510,6 @@ static void fec_pin_init(int fecidx)
 #if defined(CONFIG_MPC885_FAMILY) /* MPC87x/88x have got 2 FECs and different pinout */
 
 #if !defined(CONFIG_RMII)
-
-#warning this configuration is not tested; please report if it works
                immr->im_cpm.cp_pepar     |=  0x0003fffc;
                immr->im_cpm.cp_pedir     |=  0x0003fffc;
                immr->im_cpm.cp_peso      &= ~0x000087fc;
@@ -608,7 +608,7 @@ static int fec_init (struct eth_device *dev, bd_t * bd)
        fecp->fec_addr_high = (ea[4] << 8) | (ea[5]);
 #undef ea
 
-#if (CONFIG_COMMANDS & CFG_CMD_CDP)
+#if defined(CONFIG_CMD_CDP)
        /*
         * Turn on multicast address hash table
         */
@@ -787,7 +787,7 @@ static void fec_halt(struct eth_device* dev)
        efis->initialized = 0;
 }
 
-#if defined(CFG_DISCOVER_PHY) || defined(CONFIG_MII) || (CONFIG_COMMANDS & CFG_CMD_MII)
+#if defined(CFG_DISCOVER_PHY) || defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
 
 /* Make MII read/write commands for the FEC.
 */
@@ -822,6 +822,7 @@ static void fec_halt(struct eth_device* dev)
 #define PHY_ID_LSI80225                0x0016f870      /* LSI 80225 */
 #define PHY_ID_LSI80225B       0x0016f880      /* LSI 80225/B */
 #define PHY_ID_DM9161          0x0181B880      /* Davicom DM9161 */
+#define PHY_ID_KSM8995M                0x00221450      /* MICREL KS8995MA */
 
 /* send command to phy using mii, wait for result */
 static uint
@@ -851,7 +852,7 @@ mii_send(uint mii_cmd)
 #endif
        return (mii_reply & 0xffff);            /* data read from phy */
 }
-#endif /* CFG_DISCOVER_PHY || (CONFIG_COMMANDS & CFG_CMD_MII) */
+#endif
 
 #if defined(CFG_DISCOVER_PHY)
 static int mii_discover_phy(struct eth_device *dev)
@@ -907,6 +908,9 @@ static int mii_discover_phy(struct eth_device *dev)
                                case PHY_ID_DM9161:
                                        printf("Davicom DM9161\n");
                                        break;
+                               case PHY_ID_KSM8995M:
+                                       printf("MICREL KS8995M\n");
+                                       break;
                                default:
                                        printf("0x%08x\n", phytype);
                                        break;
@@ -922,7 +926,7 @@ static int mii_discover_phy(struct eth_device *dev)
 }
 #endif /* CFG_DISCOVER_PHY */
 
-#if (defined(CONFIG_MII) || (CONFIG_COMMANDS & CFG_CMD_MII)) && !defined(CONFIG_BITBANGMII)
+#if (defined(CONFIG_MII) || defined(CONFIG_CMD_MII)) && !defined(CONFIG_BITBANGMII)
 
 /****************************************************************************
  * mii_init -- Initialize the MII for MII command without ethernet
@@ -1016,6 +1020,6 @@ int fec8xx_miiphy_write(char *devname, unsigned char  addr,
 #endif
        return 0;
 }
-#endif /* (CONFIG_COMMANDS & CFG_CMD_MII) && !defined(CONFIG_BITBANGMII)*/
+#endif
 
-#endif /* CFG_CMD_NET, FEC_ENET */
+#endif