From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 8 Jul 2009 13:12:10 +0200 Subject: [U-Boot] [PATCHv2 1/3] A320: driver for FTMAC100 ethernet controller In-Reply-To: References: Message-ID: <20090708111210.GM30395@game.jcrosoft.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 19:12 Wed 01 Jul , Po-Yu Chuang wrote: > This patch adds an FTMAC100 ethernet driver for Faraday A320 evaluation board. > > Signed-off-by: Po-Yu Chuang > --- > drivers/net/Makefile | 1 + > drivers/net/ftmac100.c | 268 ++++++++++++++++++++++++++++++++++++++++++++++++ > drivers/net/ftmac100.h | 154 +++++++++++++++++++++++++++ > include/netdev.h | 1 + > 4 files changed, 424 insertions(+), 0 deletions(-) > create mode 100644 drivers/net/ftmac100.c > create mode 100644 drivers/net/ftmac100.h it's seem good for me but I'll add it after the core soc > > diff --git a/drivers/net/Makefile b/drivers/net/Makefile > index c6097c3..8edf529 100644 > --- a/drivers/net/Makefile > +++ b/drivers/net/Makefile > @@ -38,6 +38,7 @@ COBJS-$(CONFIG_E1000) += e1000.o > COBJS-$(CONFIG_EEPRO100) += eepro100.o > COBJS-$(CONFIG_ENC28J60) += enc28j60.o > COBJS-$(CONFIG_FSLDMAFEC) += fsl_mcdmafec.o mcfmii.o > +COBJS-$(CONFIG_DRIVER_FTMAC100) += ftmac100.o please remove the DRIVER_ > COBJS-$(CONFIG_GRETH) += greth.o > COBJS-$(CONFIG_INCA_IP_SWITCH) += inca-ip_sw.o > COBJS-$(CONFIG_KIRKWOOD_EGIGA) += kirkwood_egiga.o > diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c > new file mode 100644 > index 0000000..3057822 > --- /dev/null > +++ b/drivers/net/ftmac100.c > @@ -0,0 +1,268 @@ > +/* > + * Faraday FTMAC100 Ethernet > + * > + * (C) Copyright 2009 Faraday Technology > + * Po-Yu Chuang > + * > + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. > + */ > + > +#undef DEBUG > + > +#include > +#include > +#include > +#include > +#include > + > +#include "ftmac100.h" > + > +struct ftmac100_data { > + volatile struct ftmac100_txdes txdes[1]; > + volatile struct ftmac100_rxdes rxdes[PKTBUFSRX]; > + int rx_index; > +}; > + > +/* > + * Reset MAC > + */ > +static void ftmac100_reset (struct eth_device *dev) > +{ > + volatile struct ftmac100 *ftmac100 = (struct ftmac100 *)dev->iobase; do you really need to have all the struct volatile? > + > + debug ("%s()\n", __func__); > + > + writel (FTMAC100_MACCR_SW_RST, &ftmac100->maccr); > + > + while (readl (&ftmac100->maccr) & FTMAC100_MACCR_SW_RST) ; > +} > + > +/* > + * Set MAC address > + */ > +int ftmac100_initialize (bd_t * bd) > +{ > + struct eth_device *dev; > + struct ftmac100_data *priv; > + > + if (!(dev = malloc (sizeof *dev))) { use calloc instead > + printf ("%s(): failed to allocate dev\n", __func__); > + goto out; > + } > + > + /* Transmit and receive descriptors should align to 16 bytes */ > + > + if (!(priv = memalign (16, sizeof (struct ftmac100_data)))) { > + printf ("%s(): failed to allocate priv\n", __func__); > + goto free_dev; > + } > + > + memset (dev, 0, sizeof (*dev)); > + memset (priv, 0, sizeof (*priv)); > + > + sprintf (dev->name, "FTMAC100"); > + dev->iobase = CONFIG_SYS_MAC100_BASE; > + dev->init = ftmac100_init; please use tab for indent > + dev->halt = ftmac100_halt; > + dev->send = ftmac100_send; > + dev->recv = ftmac100_recv; > + dev->priv = priv; > + Best Regards, J.