Skip to contentSkip to conversation

A320: driver for FTMAC100 ethernet controller

PATCH Superseded Po-Yu Chuang 4 participants 9 messages Jul 1, 2009 – Jul 11, 2009

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 A320: driver for FTMAC100 ethernet controller

This patch adds an FTMAC100 ethernet driver for Faraday A320 evaluation board.

---
 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
drivers/net/Makefile +1 -0
index c6097c3..8edf529 100644
@@ -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
 COBJS-$(CONFIG_GRETH) += greth.o
 COBJS-$(CONFIG_INCA_IP_SWITCH) += inca-ip_sw.o
 COBJS-$(CONFIG_KIRKWOOD_EGIGA) += kirkwood_egiga.o
drivers/net/ftmac100.c new file +268 -0

268 lines not on this page · raw message

drivers/net/ftmac100.h new file +154 -0

154 lines not on this page · raw message

include/netdev.h +1 -0
index aed5c4c..88e286f 100644
@@ -50,6 +50,7 @@ int e1000_initialize(bd_t *bis);
 int eepro100_initialize(bd_t *bis);
 int eth_3com_initialize (bd_t * bis);
 int fec_initialize (bd_t *bis);
+int ftmac100_initialize(bd_t *bits);
 int greth_initialize(bd_t *bis);
 void gt6426x_eth_initialize(bd_t *bis);
 int inca_switch_initialize(bd_t *bis);
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH v3 1/3 A320: driver for FTMAC100 ethernet controller

This patch adds an FTMAC100 Ethernet driver for Faraday A320 evaluation board.

---
 drivers/net/Makefile   |    1 +
 drivers/net/ftmac100.c |  278 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/ftmac100.h |  154 ++++++++++++++++++++++++++
 include/netdev.h       |    1 +
 4 files changed, 434 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/ftmac100.c
 create mode 100644 drivers/net/ftmac100.h
drivers/net/Makefile +1 -0
index c6097c3..8edf529 100644
@@ -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
 COBJS-$(CONFIG_GRETH) += greth.o
 COBJS-$(CONFIG_INCA_IP_SWITCH) += inca-ip_sw.o
 COBJS-$(CONFIG_KIRKWOOD_EGIGA) += kirkwood_egiga.o
drivers/net/ftmac100.c new file +278 -0

278 lines not on this page · raw message

drivers/net/ftmac100.h new file +154 -0

154 lines not on this page · raw message

include/netdev.h +1 -0
index aed5c4c..88e286f 100644
@@ -50,6 +50,7 @@ int e1000_initialize(bd_t *bis);
 int eepro100_initialize(bd_t *bis);
 int eth_3com_initialize (bd_t * bis);
 int fec_initialize (bd_t *bis);
+int ftmac100_initialize(bd_t *bits);
 int greth_initialize(bd_t *bis);
 void gt6426x_eth_initialize(bd_t *bis);
 int inca_switch_initialize(bd_t *bis);
Signature · 1 line
1.6.3.3
#2 lore raw

PATCH v2 1/3 A320: driver for FTMAC100 ethernet controller

In reply to Po-Yu Chuang
Quoted 11 lines · Po-Yu Chuang

This patch adds an FTMAC100 ethernet driver for Faraday A320 evaluation board.

---
 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

drivers/net/Makefile COBJS-$(CONFIG_E1000) += e1000.o · line 41

Quoted 10 lines
drivers/net/Makefile +1 -0
index c6097c3..8edf529 100644
@@ -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_

Quoted 42 lines
drivers/net/Makefile +0 -0
 COBJS-$(CONFIG_GRETH) += greth.o
 COBJS-$(CONFIG_INCA_IP_SWITCH) += inca-ip_sw.o
 COBJS-$(CONFIG_KIRKWOOD_EGIGA) += kirkwood_egiga.o
drivers/net/ftmac100.c new file +33 -0
new file mode 100644
index 0000000..3057822
@@ -0,0 +1,268 @@
+/*
+ * Faraday FTMAC100 Ethernet
+ *
+ * (C) Copyright 2009 Faraday Technology
+ * Po-Yu Chuang <[email protected]>
+ *
+ * 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 <config.h>
+#include <common.h>
+#include <malloc.h>
+#include <net.h>
+#include <asm/io.h>
+
+#include "ftmac100.h"
+
+struct ftmac100_data {
+	volatile struct ftmac100_txdes txdes[1];

drivers/net/ftmac100.c line 43

Quoted 10 lines
drivers/net/ftmac100.c new file +10 -0
+	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?

Quoted 8 lines
drivers/net/ftmac100.c new file +8 -0
+
+	debug ("%s()\n", __func__);
+
+	writel (FTMAC100_MACCR_SW_RST, &ftmac100->maccr);
+
+	while (readl (&ftmac100->maccr) & FTMAC100_MACCR_SW_RST) ;
+}
+

drivers/net/ftmac100.c

Quoted 10 lines
drivers/net/ftmac100.c new file +9 -0
+/*
+ * 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

Quoted 7 lines
drivers/net/ftmac100.c new file +7 -0
+		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)))) {

drivers/net/ftmac100.c line 254

Quoted 10 lines
drivers/net/ftmac100.c new file +10 -0
+		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

drivers/net/ftmac100.c line 259

Quoted 5 lines
drivers/net/ftmac100.c new file +5 -0
+	dev->halt   = ftmac100_halt;
+	dev->send   = ftmac100_send;
+	dev->recv   = ftmac100_recv;
+	dev->priv   = priv;
+

Best Regards,
J.

#3 lore raw

PATCH v2 1/3 A320: driver for FTMAC100 ethernet controller

Dear Jean-Christophe,

2009/7/8 Jean-Christophe PLAGNIOL-VILLARD <[email protected]>:

Quoted 4 lines · Po-Yu Chuang
Quoted 1 line

This patch adds an FTMAC100 ethernet driver for Faraday A320 evaluation board.

it's seem good for me
but I'll add it after the core soc

Thank you for your detailed review.
I will resubmit this patch with new soc patch.

Quoted 10 lines
Quoted 9 lines
drivers/net/Makefile +0 -0
index c6097c3..8edf529 100644
@@ -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_

OK, but some recent patches use DRIVER_ naming.

CONFIG_DRIVER_TI_EMAC
CONFIG_DRIVER_AX88180

Is it not the preferred style?

Quoted 4 lines
Quoted 4 lines

?COBJS-$(CONFIG_GRETH) += greth.o ?COBJS-$(CONFIG_INCA_IP_SWITCH) += inca-ip_sw.o ?COBJS-$(CONFIG_KIRKWOOD_EGIGA) += kirkwood_egiga.o

drivers/net/ftmac100.c +0 -0
Quoted 8 lines

drivers/net/ftmac100.c

Quoted 7 lines

new file mode 100644
index 0000000..3057822

drivers/net/ftmac100.c new file +3 -0
+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?

I had submitted a v3 of this driver which removed unnecessary volatiles according to the warnings told by checkpatch.pl.

http://lists.denx.de/pipermail/u-boot/2009-July/055421.html

Please ignore it, since I need to resubmit a new patch later.

Quoted 12 lines
Quoted 11 lines
drivers/net/ftmac100.c new file +11 -0
+
+ ? ? debug ("%s()\n", __func__);
+
+ ? ? writel (FTMAC100_MACCR_SW_RST, &ftmac100->maccr);
+
+ ? ? while (readl (&ftmac100->maccr) & FTMAC100_MACCR_SW_RST) ;
+}
+
+/*
+ * Set MAC address
+ */
Quoted 7 lines

drivers/net/ftmac100.c

Quoted 6 lines
drivers/net/ftmac100.c new file +6 -0
+int ftmac100_initialize (bd_t * bd)
+{
+ ? ? struct eth_device *dev;
+ ? ? struct ftmac100_data *priv;
+
+ ? ? if (!(dev = malloc (sizeof *dev))) {

use calloc instead

Is it preferred way?
No driver in driver/net/ uses calloc.

Quoted 10 lines
Quoted 10 lines

+ ? ? ? ? ? ? printf ("%s(): failed to allocate dev\n", __func__);
+ ? ? ? ? ? ? goto out;
+ ? ? }

drivers/net/ftmac100.c new file +7 -0
+
+ ? ? /* 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;
+ ? ? }
Quoted 8 lines

drivers/net/ftmac100.c

Quoted 7 lines
drivers/net/ftmac100.c new file +7 -0
+
+ ? ? 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

ok, fixed.

Quoted 4 lines
Quoted 4 lines

+ ? ? dev->halt ? = ftmac100_halt;
+ ? ? dev->send ? = ftmac100_send;
+ ? ? dev->recv ? = ftmac100_recv;
+ ? ? dev->priv ? = priv;

best regards,
Po-Yu Chuang

#4 lore raw

PATCH v2 1/3 A320: driver for FTMAC100 ethernet controller

Hi Po-Yu Chang,

Quoted 29 lines · Po-Yu Chuang

Dear Jean-Christophe,

2009/7/8 Jean-Christophe PLAGNIOL-VILLARD <[email protected]>:

Quoted 7 lines · Po-Yu Chuang
Quoted 3 lines

This patch adds an FTMAC100 ethernet driver for Faraday A320 evaluation board.

it's seem good for me
but I'll add it after the core soc

Thank you for your detailed review.
I will resubmit this patch with new soc patch.

Quoted 12 lines

drivers/net/Makefile COBJS-$(CONFIG_E1000) += e1000.o · line 42

Quoted 10 lines
drivers/net/Makefile +1 -0
index c6097c3..8edf529 100644
@@ -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_

Quoted 8 lines

OK, but some recent patches use DRIVER_ naming.

CONFIG_DRIVER_TI_EMAC
CONFIG_DRIVER_AX88180

Is it not the preferred style?

I don't have a strong opinion, but don't think the 'DRIVER' part adds anything useful, so I guess remove.

Quoted 45 lines
Quoted 5 lines
Quoted 5 lines
drivers/net/Makefile +0 -0
 COBJS-$(CONFIG_GRETH) += greth.o
 COBJS-$(CONFIG_INCA_IP_SWITCH) += inca-ip_sw.o

COBJS-$(CONFIG_KIRKWOOD_EGIGA) += kirkwood_egiga.o

drivers/net/ftmac100.c new file +0 -0
new file mode 100644
Quoted 9 lines

drivers/net/ftmac100.c line 43

Quoted 7 lines

index 0000000..3057822

drivers/net/ftmac100.c new file +3 -0
+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?

I had submitted a v3 of this driver which removed unnecessary volatiles according to the warnings told by checkpatch.pl.

http://lists.denx.de/pipermail/u-boot/2009-July/055421.html

Please ignore it, since I need to resubmit a new patch later.

Quoted 12 lines
Quoted 12 lines
drivers/net/ftmac100.c new file +11 -0
+
+     debug ("%s()\n", __func__);
+
+     writel (FTMAC100_MACCR_SW_RST, &ftmac100->maccr);
+
+     while (readl (&ftmac100->maccr) & FTMAC100_MACCR_SW_RST) ;
+}
+
+/*
+ * Set MAC address
+ */
Quoted 9 lines

drivers/net/ftmac100.c line 237

Quoted 7 lines
drivers/net/ftmac100.c new file +6 -0
+int ftmac100_initialize (bd_t * bd)
+{
+     struct eth_device *dev;
+     struct ftmac100_data *priv;
+
+     if (!(dev = malloc (sizeof *dev))) {

use calloc instead

Quoted 4 lines

Is it preferred way?
No driver in driver/net/ uses calloc.

malloc() is OK.

Quoted 24 lines
Quoted 11 lines
Quoted 11 lines
drivers/net/ftmac100.c new file +11 -0
+             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;
+     }
+
Quoted 9 lines

drivers/net/ftmac100.c line 254

Quoted 7 lines
drivers/net/ftmac100.c new file +6 -0
+     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

ok, fixed.

Quoted 9 lines
Quoted 5 lines

drivers/net/ftmac100.c line 258

Quoted 5 lines
drivers/net/ftmac100.c new file +4 -0
+     dev->halt   = ftmac100_halt;
+     dev->send   = ftmac100_send;
+     dev->recv   = ftmac100_recv;
+     dev->priv   = priv;

best regards,
Po-Yu Chuang

Looking forward to the next spin.

regards,
B en

#5 lore raw

PATCH v2 1/3 A320: driver for FTMAC100 ethernet controller

Dear Ben Warren,

Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

+COBJS-$(CONFIG_DRIVER_FTMAC100) += ftmac100.o

please remove the DRIVER_

OK, but some recent patches use DRIVER_ naming.

Quoted 7 lines
Quoted 5 lines

CONFIG_DRIVER_TI_EMAC
CONFIG_DRIVER_AX88180

Is it not the preferred style?

I don't have a strong opinion, but don't think the 'DRIVER' part adds anything useful, so I guess remove.

Agreed. Please do not use 'DRIVER'.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"I haven't lost my mind - it's backed up on tape somewhere."
#6 lore raw

PATCH v2 2/3 A320: driver for FTRTC010 real time clock

This patch adds an FTRTC010 driver for Faraday A320 evaluation board.

---
 drivers/rtc/Makefile   |    1 +
 drivers/rtc/ftrtc010.c |  126 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 127 insertions(+), 0 deletions(-)
 create mode 100644 drivers/rtc/ftrtc010.c
drivers/rtc/Makefile +1 -0
index 822dc1a..25252b5 100644
@@ -40,6 +40,7 @@ COBJS-$(CONFIG_RTC_DS1556) += ds1556.o
 COBJS-$(CONFIG_RTC_DS164x) += ds164x.o
 COBJS-$(CONFIG_RTC_DS174x) += ds174x.o
 COBJS-$(CONFIG_RTC_DS3231) += ds3231.o
+COBJS-$(CONFIG_RTC_FTRTC010) += ftrtc010.o
 COBJS-$(CONFIG_RTC_ISL1208) += isl1208.o
 COBJS-$(CONFIG_RTC_M41T11) += m41t11.o
 COBJS-$(CONFIG_RTC_M41T60) += m41t60.o
drivers/rtc/ftrtc010.c new file +126 -0

126 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#7 lore raw

PATCH v3 2/3 A320: driver for FTRTC010 real time clock

This patch adds an FTRTC010 driver for Faraday A320 evaluation board.

---
 drivers/rtc/Makefile   |    1 +
 drivers/rtc/ftrtc010.c |  126 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 127 insertions(+), 0 deletions(-)
 create mode 100644 drivers/rtc/ftrtc010.c
drivers/rtc/Makefile +1 -0
index 822dc1a..25252b5 100644
@@ -40,6 +40,7 @@ COBJS-$(CONFIG_RTC_DS1556) += ds1556.o
 COBJS-$(CONFIG_RTC_DS164x) += ds164x.o
 COBJS-$(CONFIG_RTC_DS174x) += ds174x.o
 COBJS-$(CONFIG_RTC_DS3231) += ds3231.o
+COBJS-$(CONFIG_RTC_FTRTC010) += ftrtc010.o
 COBJS-$(CONFIG_RTC_ISL1208) += isl1208.o
 COBJS-$(CONFIG_RTC_M41T11) += m41t11.o
 COBJS-$(CONFIG_RTC_M41T60) += m41t60.o
drivers/rtc/ftrtc010.c new file +126 -0

126 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#8 lore raw

PATCH v2 2/3 A320: driver for FTRTC010 real time clock

In reply to Po-Yu Chuang
Quoted 8 lines · Po-Yu Chuang

This patch adds an FTRTC010 driver for Faraday A320 evaluation board.

---
 drivers/rtc/Makefile   |    1 +
 drivers/rtc/ftrtc010.c |  126 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 127 insertions(+), 0 deletions(-)
 create mode 100644 drivers/rtc/ftrtc010.c

ok

Best Regards,
J.