]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/net/ethoc.c
net: gem: Use phys_addr_t instead of int for addresses
[karo-tx-uboot.git] / drivers / net / ethoc.c
index b912e44650681f29c9b1ecf89499686c0ce4ddfe..46c82bbb40014a840231409bfbebd04df34d3075 100644 (file)
@@ -189,12 +189,12 @@ struct ethoc_bd {
        u32 addr;
 };
 
-static inline u32 ethoc_read(struct eth_device *dev, loff_t offset)
+static inline u32 ethoc_read(struct eth_device *dev, size_t offset)
 {
        return readl(dev->iobase + offset);
 }
 
-static inline void ethoc_write(struct eth_device *dev, loff_t offset, u32 data)
+static inline void ethoc_write(struct eth_device *dev, size_t offset, u32 data)
 {
        writel(data, dev->iobase + offset);
 }
@@ -202,7 +202,7 @@ static inline void ethoc_write(struct eth_device *dev, loff_t offset, u32 data)
 static inline void ethoc_read_bd(struct eth_device *dev, int index,
                                 struct ethoc_bd *bd)
 {
-       loff_t offset = ETHOC_BD_BASE + (index * sizeof(struct ethoc_bd));
+       size_t offset = ETHOC_BD_BASE + (index * sizeof(struct ethoc_bd));
        bd->stat = ethoc_read(dev, offset + 0);
        bd->addr = ethoc_read(dev, offset + 4);
 }
@@ -210,18 +210,19 @@ static inline void ethoc_read_bd(struct eth_device *dev, int index,
 static inline void ethoc_write_bd(struct eth_device *dev, int index,
                                  const struct ethoc_bd *bd)
 {
-       loff_t offset = ETHOC_BD_BASE + (index * sizeof(struct ethoc_bd));
+       size_t offset = ETHOC_BD_BASE + (index * sizeof(struct ethoc_bd));
        ethoc_write(dev, offset + 0, bd->stat);
        ethoc_write(dev, offset + 4, bd->addr);
 }
 
-static inline void ethoc_set_mac_address(struct eth_device *dev)
+static int ethoc_set_mac_address(struct eth_device *dev)
 {
        u8 *mac = dev->enetaddr;
 
        ethoc_write(dev, MAC_ADDR0, (mac[2] << 24) | (mac[3] << 16) |
                    (mac[4] << 8) | (mac[5] << 0));
        ethoc_write(dev, MAC_ADDR1, (mac[0] << 8) | (mac[1] << 0));
+       return 0;
 }
 
 static inline void ethoc_ack_irq(struct eth_device *dev, u32 mask)
@@ -270,7 +271,7 @@ static int ethoc_init_ring(struct eth_device *dev)
                if (i == priv->num_rx - 1)
                        bd.stat |= RX_BD_WRAP;
 
-               flush_dcache(bd.addr, PKTSIZE_ALIGN);
+               flush_dcache_range(bd.addr, bd.addr + PKTSIZE_ALIGN);
                ethoc_write_bd(dev, priv->num_tx + i, &bd);
        }
 
@@ -308,8 +309,6 @@ static int ethoc_init(struct eth_device *dev, bd_t * bd)
        struct ethoc *priv = (struct ethoc *)dev->priv;
        printf("ethoc\n");
 
-       ethoc_set_mac_address(dev);
-
        priv->num_tx = 1;
        priv->num_rx = PKTBUFSRX;
        ethoc_write(dev, TX_BD_NUM, priv->num_tx);
@@ -377,7 +376,7 @@ static int ethoc_rx(struct eth_device *dev, int limit)
                }
 
                /* clear the buffer descriptor so it can be reused */
-               flush_dcache(bd.addr, PKTSIZE_ALIGN);
+               flush_dcache_range(bd.addr, bd.addr + PKTSIZE_ALIGN);
                bd.stat &= ~RX_BD_STATS;
                bd.stat |= RX_BD_EMPTY;
                ethoc_write_bd(dev, entry, &bd);
@@ -415,7 +414,7 @@ static void ethoc_tx(struct eth_device *dev)
                (void)ethoc_update_tx_stats(&bd);
 }
 
-static int ethoc_send(struct eth_device *dev, volatile void *packet, int length)
+static int ethoc_send(struct eth_device *dev, void *packet, int length)
 {
        struct ethoc *priv = (struct ethoc *)dev->priv;
        struct ethoc_bd bd;
@@ -431,7 +430,7 @@ static int ethoc_send(struct eth_device *dev, volatile void *packet, int length)
                bd.stat &= ~TX_BD_PAD;
        bd.addr = (u32)packet;
 
-       flush_dcache(bd.addr, length);
+       flush_dcache_range(bd.addr, bd.addr + length);
        bd.stat &= ~(TX_BD_STATS | TX_BD_LEN_MASK);
        bd.stat |= TX_BD_LEN(length);
        ethoc_write_bd(dev, entry, &bd);
@@ -504,6 +503,7 @@ int ethoc_initialize(u8 dev_num, int base_addr)
        dev->halt = ethoc_halt;
        dev->send = ethoc_send;
        dev->recv = ethoc_recv;
+       dev->write_hwaddr = ethoc_set_mac_address;
        sprintf(dev->name, "%s-%hu", "ETHOC", dev_num);
 
        eth_register(dev);