X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fgreth.c;h=9bc8a8d1aa1543a74923f90f605684e6281cc18a;hb=0f9258228e2b2070368ffccf5c243218128770a8;hp=cb68d45e0275f24cc49b076594a293d1e1f4a356;hpb=e780d82b96b43a0dafc7b6511127a4c807b80012;p=oweals%2Fu-boot.git diff --git a/drivers/net/greth.c b/drivers/net/greth.c index cb68d45e02..9bc8a8d1aa 100644 --- a/drivers/net/greth.c +++ b/drivers/net/greth.c @@ -5,29 +5,14 @@ * (C) Copyright 2007 * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA + * SPDX-License-Identifier: GPL-2.0+ */ /* #define DEBUG */ #include #include +#include #include #include #include @@ -152,13 +137,23 @@ int greth_init(struct eth_device *dev, bd_t * bis) debug("greth_init\n"); + /* Reset core */ + GRETH_REGSAVE(®s->control, (GRETH_RESET | (greth->gb << 8) | + (greth->sp << 7) | (greth->fd << 4))); + + /* Wait for Reset to complete */ + while ( GRETH_REGLOAD(®s->control) & GRETH_RESET) ; + + GRETH_REGSAVE(®s->control, + ((greth->gb << 8) | (greth->sp << 7) | (greth->fd << 4))); + if (!greth->rxbd_base) { /* allocate descriptors */ greth->rxbd_base = (greth_bd *) memalign(0x1000, GRETH_RXBD_CNT * sizeof(greth_bd)); greth->txbd_base = (greth_bd *) - memalign(0x1000, GRETH_RXBD_CNT * sizeof(greth_bd)); + memalign(0x1000, GRETH_TXBD_CNT * sizeof(greth_bd)); /* allocate buffers to all descriptors */ greth->rxbuf_base = @@ -190,7 +185,7 @@ int greth_init(struct eth_device *dev, bd_t * bis) for (i = 0; i < GRETH_TXBD_CNT; i++) { greth->txbd_base[i].addr = 0; /* enable desciptor & set wrap bit if last descriptor */ - if (i >= (GRETH_RXBD_CNT - 1)) { + if (i >= (GRETH_TXBD_CNT - 1)) { greth->txbd_base[i].stat = GRETH_BD_WR; } else { greth->txbd_base[i].stat = 0; @@ -393,7 +388,7 @@ void greth_halt(struct eth_device *dev) } } -int greth_send(struct eth_device *dev, volatile void *eth_data, int data_length) +int greth_send(struct eth_device *dev, void *eth_data, int data_length) { greth_priv *greth = dev->priv; greth_regs *regs = greth->regs; @@ -473,7 +468,7 @@ int greth_recv(struct eth_device *dev) greth_regs *regs = greth->regs; greth_bd *rxbd; unsigned int status, len = 0, bad; - unsigned char *d; + char *d; int enable = 0; int i; @@ -494,7 +489,7 @@ int greth_recv(struct eth_device *dev) goto done; } - debug("greth_recv: packet 0x%lx, 0x%lx, len: %d\n", + debug("greth_recv: packet 0x%x, 0x%x, len: %d\n", (unsigned int)rxbd, status, status & GRETH_BD_LEN); /* Check status for errors. @@ -539,7 +534,7 @@ int greth_recv(struct eth_device *dev) sparc_dcache_flush_all(); /* pass packet on to network subsystem */ - NetReceive((void *)d, len); + net_process_received_packet((void *)d, len); /* bump stats counters */ greth->stats.rx_packets++; @@ -566,7 +561,7 @@ int greth_recv(struct eth_device *dev) GRETH_REGORIN(®s->control, GRETH_RXEN); } done: - /* return positive length of packet or 0 if non recieved */ + /* return positive length of packet or 0 if non received */ return len; } @@ -610,7 +605,7 @@ int greth_initialize(bd_t * bis) greth->regs = (greth_regs *) apbdev.address; greth->irq = apbdev.irq; - debug("Found GRETH at 0x%lx, irq %d\n", greth->regs, greth->irq); + debug("Found GRETH at %p, irq %d\n", greth->regs, greth->irq); dev->priv = (void *)greth; dev->iobase = (unsigned int)greth->regs; dev->init = greth_init; @@ -634,15 +629,15 @@ int greth_initialize(bd_t * bis) /* Make descriptor string */ if (greth->gbit_mac) { - sprintf(dev->name, "GRETH 10/100/GB"); + sprintf(dev->name, "GRETH_10/100/GB"); } else { - sprintf(dev->name, "GRETH 10/100"); + sprintf(dev->name, "GRETH_10/100"); } /* initiate PHY, select speed/duplex depending on connected PHY */ if (greth_init_phy(greth, bis)) { /* Failed to init PHY (timedout) */ - debug("GRETH[0x%08x]: Failed to init PHY\n", greth->regs); + debug("GRETH[%p]: Failed to init PHY\n", greth->regs); return -1; } @@ -659,18 +654,13 @@ int greth_initialize(bd_t * bis) } } } else { - /* HW Address not found in environment, Set default HW address */ - addr[0] = GRETH_HWADDR_0; /* MSB */ - addr[1] = GRETH_HWADDR_1; - addr[2] = GRETH_HWADDR_2; - addr[3] = GRETH_HWADDR_3; - addr[4] = GRETH_HWADDR_4; - addr[5] = GRETH_HWADDR_5; /* LSB */ + /* No ethaddr set */ + return -EINVAL; } /* set and remember MAC address */ greth_set_hwaddr(greth, addr); - debug("GRETH[0x%08x]: Initialized successfully\n", greth->regs); + debug("GRETH[%p]: Initialized successfully\n", greth->regs); return 0; }