[U-Boot] [PATCH 2/2] use MAC from environment and add support for new NET_MULTI api in ethernet driver of KS8695

Bernstein, Michael Michael.Bernstein at controlware.de
Thu Nov 4 11:15:09 CET 2010


Hello,

Add support for the new NET MULTI api in the ethernet driver of the KS8695.

Signed-off-by: Michael Bernstein <Michael.Bernstein at controlware.de>

---

diff --unified --recursive --new-file u-boot-2009.11/drivers/net/ks8695eth.c u-boot-2009.11.new/drivers/net/ks8695eth.c
--- u-boot-2009.11/drivers/net/ks8695eth.c      2010-02-09 16:16:18.000000000 +0100
+++ u-boot-2009.11.new/drivers/net/ks8695eth.c  2010-03-01 15:36:56.000000000 +0100
@@ -29,6 +29,26 @@
 /****************************************************************************/

 /*
+ * some defines to allow switching between NET_MULTI and old API
+ */
+#if defined(CONFIG_NET_MULTI)
+#define KS8695_ETH_RESET ks8695_eth_reset
+#define KS8695_ETH_HALT  ks8695_eth_halt
+#define KS8695_ETH_INIT  ks8695_eth_init
+#define KS8695_ETH_RX    ks8695_eth_rx
+#define KS8695_ETH_SEND  ks8695_eth_send
+#define KS8695_DRIVERNAME "KS8695"
+#else
+#define KS8695_ETH_RESET eth_reset
+#define KS8695_ETH_HALT  eth_halt
+#define KS8695_ETH_INIT  eth_init
+#define KS8695_ETH_RX    eth_rx
+#define KS8695_ETH_SEND  eth_send
+#endif
+
+/****************************************************************************/
+
+/*
  * Hardware register access to the KS8695 LAN ethernet port
  * (well, it is the 4 port switch really).
  */
@@ -103,7 +123,7 @@

 /****************************************************************************/

-void eth_reset(bd_t *bd)
+void KS8695_ETH_RESET(bd_t *bd)
 {
        int i;

@@ -159,28 +179,28 @@

 /****************************************************************************/

-int eth_init(bd_t *bd)
+int KS8695_ETH_INIT(bd_t *bd)
 {
        debug ("%s(%d): eth_init()\n", __FILE__, __LINE__);

-       eth_reset(bd);
+       KS8695_ETH_RESET(bd);
        return 0;
 }

 /****************************************************************************/

-void eth_halt(void)
+void KS8695_ETH_HALT(void)
 {
        debug ("%s(%d): eth_halt()\n", __FILE__, __LINE__);

        /* Reset the ethernet engines */
-       ks8695_write(KS8695_LAN_DMA_TX, 0x80000000);
-       ks8695_write(KS8695_LAN_DMA_RX, 0x80000000);
+/*     ks8695_write(KS8695_LAN_DMA_TX, 0x80000000); */
+/*     ks8695_write(KS8695_LAN_DMA_RX, 0x80000000); */
 }

 /****************************************************************************/

-int eth_rx(void)
+int KS8695_ETH_RX(void)
 {
        volatile struct ks8695_rxdesc *dp;
        int i, len = 0;
@@ -203,7 +223,7 @@

 /****************************************************************************/

-int eth_send(volatile void *packet, int len)
+int KS8695_ETH_SEND(volatile void *packet, int len)
 {
        volatile struct ks8695_txdesc *dp;
        static int next = 0;
@@ -230,3 +250,72 @@

        return len;
 }
+
+/****************************************************************************/
+
+#ifdef CONFIG_NET_MULTI
+
+static void ks8695_halt(struct eth_device *dev)
+{
+       KS8695_ETH_HALT();
+}
+
+static int ks8695_init(struct eth_device *dev, bd_t * bd)
+{
+       return KS8695_ETH_INIT(bd);
+}
+
+static int ks8695_recv(struct eth_device *dev)
+{
+       int i;
+
+       i = KS8695_ETH_RX();
+       return i;
+}
+
+static int ks8695_send(struct eth_device *dev, volatile void *packet, int length)
+{
+       KS8695_ETH_SEND(packet, length);
+       return 0;
+}
+
+static void ks8695_get_enetaddr(struct eth_device *dev)
+{
+       int i;
+
+       ks8695_getmac();        /* load MAC to eth_mac */
+       for (i = 0; i < 6; i++) {
+               dev->enetaddr[i] = eth_mac[i];
+       }
+}
+
+int ks8695_initialize(void)
+{
+       struct eth_device *dev;
+
+       dev = malloc(sizeof(*dev));
+       if (!dev) {
+               free(dev);
+               return 0;
+       }
+       else {
+               memset(dev, 0, sizeof(*dev));
+
+               dev->iobase = KS8695_IO_BASE;
+               dev->priv = NULL;
+               dev->init = ks8695_init;
+               dev->halt = ks8695_halt;
+               dev->send = ks8695_send;
+               dev->recv = ks8695_recv;
+
+               /* Load MAC address from EEPROM */
+               ks8695_get_enetaddr(dev);
+
+               sprintf(dev->name, "%s", KS8695_DRIVERNAME);
+
+               eth_register(dev);
+               return 0;
+       }
+}
+
+#endif

--

_________________________________________________
Michael Bernstein
NOC

Controlware GmbH
Waldstrasse 92, 63128 Dietzenbach, GERMANY
Tel.: +49 6074 858-177
Fax: +49 6074 858-148
Michael.Bernstein at controlware.de
www.controlware.de
_________________________________________________
State-of-the-art Technology for Worldwide Telecommunications
<<< Dienstleistung nach Maß >>>





Emergency Response Services
Schnelle und zuverlässige Unterstützung bei IT-Sicherheitsvorfällen aller Art.
Weitere Infos unter http://www.controlware.de/ers

Diese E-Mail kann vertrauliche oder rechtlich geschützte Informationen enthalten. Wenn Sie nicht der beabsichtigte Empfänger sind, informieren Sie bitte sofort den Absender und löschen Sie diese E-Mail. Das unbefugte Kopieren dieser E-Mail oder die unbefugte Weitergabe der enthaltenen Informationen ist nicht gestattet.

The information contained in this message is confidential or protected by law. If you are not the intended recipient, please contact the sender and delete this message. Any unauthorised copying of this message or unauthorised distribution of the information contained herein is prohibited.

Controlware GmbH Kommunikationssysteme
Telefon: (0 60 74) 8 58-0
E-Mail: info at controlware.de
http://www.controlware.de

Sitz: 63128 Dietzenbach, Registergericht: Offenbach a.M., HRB Nr. 6431, USt.-Id.-Nr. DE 113539225
Geschäftsführung: Helmut E. Wörner (Vorsitzender), Bernd Schwefing, Hubert Potthoff Beirat: Dr. Gert Sieger (Vorsitzender), Dr. Peter Pagé, Kurt Sibold


More information about the U-Boot mailing list