]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/net/fec_mxc.c
net: fec_mxc: autodetect PHY address if phy_id < 0
[karo-tx-uboot.git] / drivers / net / fec_mxc.c
index 7e732d4df487ea39bd984f9908d42504b539e2d1..343646c939b51f0389d69235f2374ad5ca074638 100644 (file)
@@ -69,15 +69,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #undef DEBUG
 
-struct nbuf {
-       uint8_t data[1500];     /**< actual data */
-       int length;             /**< actual length */
-       int used;               /**< buffer in use or not */
-       uint8_t head[16];       /**< MAC header(6 + 6 + 2) + 2(aligned) */
-};
-
-static int rx_idx;
-
 #ifdef CONFIG_FEC_MXC_SWAP_PACKET
 static void swap_packet(uint32_t *packet, int length)
 {
@@ -265,7 +256,7 @@ static int miiphy_wait_aneg(struct eth_device *dev)
 
 static inline void fec_rx_task_enable(struct fec_priv *fec)
 {
-       writel(1 << 24, &fec->eth->r_des_active);
+       writel(FEC_X_DES_ACTIVE_TDAR, &fec->eth->r_des_active);
 }
 
 static inline void fec_rx_task_disable(struct fec_priv *fec)
@@ -274,7 +265,7 @@ static inline void fec_rx_task_disable(struct fec_priv *fec)
 
 static inline void fec_tx_task_enable(struct fec_priv *fec)
 {
-       writel(1 << 24, &fec->eth->x_des_active);
+       writel(FEC_X_DES_ACTIVE_TDAR, &fec->eth->x_des_active);
 }
 
 static inline void fec_tx_task_disable(struct fec_priv *fec)
@@ -361,7 +352,7 @@ static int fec_get_hwaddr(struct eth_device *dev, int dev_id,
                                                unsigned char *mac)
 {
        imx_get_mac_from_fuse(dev_id, mac);
-       return !is_valid_ether_addr(mac);
+       return !is_valid_ethaddr(mac);
 }
 
 static int fec_set_hwaddr(struct eth_device *dev)
@@ -789,10 +780,10 @@ static int fec_recv(struct eth_device *dev)
        struct fec_bd *rbd = &fec->rbd_base[fec->rbd_index];
        unsigned long ievent;
        int frame_length, len = 0;
-       struct nbuf *frame;
        uint16_t bd_status;
        uint32_t addr, size, end;
        int i;
+       ALLOC_CACHE_ALIGN_BUFFER(uchar, buff, FEC_MAX_PKT_SIZE);
 
        /*
         * Check if any critical events have happened
@@ -851,13 +842,12 @@ static int fec_recv(struct eth_device *dev)
                        /*
                         * Get buffer address and size
                         */
-                       frame = (struct nbuf *)readl(&rbd->data_pointer);
+                       addr = readl(&rbd->data_pointer);
                        frame_length = readw(&rbd->data_length) - 4;
 
                        /*
                         * Invalidate data cache over the buffer
                         */
-                       addr = (uint32_t)frame;
                        end = roundup(addr + frame_length, ARCH_DMA_MINALIGN);
                        addr &= ~(ARCH_DMA_MINALIGN - 1);
                        invalidate_dcache_range(addr, end);
@@ -866,17 +856,15 @@ static int fec_recv(struct eth_device *dev)
                         *  Fill the buffer and pass it to upper layers
                         */
 #ifdef CONFIG_FEC_MXC_SWAP_PACKET
-                       swap_packet((uint32_t *)frame->data, frame_length);
+                       swap_packet((uint32_t *)addr, frame_length);
 #endif
-                       memcpy((void *)NetRxPackets[rx_idx], frame->data, frame_length);
-                       NetReceive(NetRxPackets[rx_idx], frame_length);
-                       rx_idx = (rx_idx + 1) % PKTBUFSRX;
+                       memcpy(buff, (char *)addr, frame_length);
+                       net_process_received_packet(buff, frame_length);
                        len = frame_length;
                } else {
                        if (bd_status & FEC_RBD_ERR)
-                               printf("error frame: 0x%08lx 0x%08x\n",
-                                               (ulong)rbd->data_pointer,
-                                               bd_status);
+                               printf("error frame: 0x%08x 0x%08x\n",
+                                      addr, bd_status);
                }
 
                /*
@@ -1118,7 +1106,8 @@ int fecmxc_initialize_multi(bd_t *bd, int dev_id, int phy_id, uint32_t addr)
        if (!bus)
                return -ENOMEM;
 #ifdef CONFIG_PHYLIB
-       phydev = phy_find_by_mask(bus, 1 << phy_id, PHY_INTERFACE_MODE_RGMII);
+       phydev = phy_find_by_mask(bus, phy_id < 0 ? 0xff : (1 << phy_id),
+                               PHY_INTERFACE_MODE_RGMII);
        if (!phydev) {
                free(bus);
                return -ENOMEM;