Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sandpoint/stand/altboot New experimental driver for...



details:   https://anonhg.NetBSD.org/src/rev/a202c7086f35
branches:  trunk
changeset: 762944:a202c7086f35
user:      phx <phx%NetBSD.org@localhost>
date:      Sun Mar 06 13:55:12 2011 +0000

description:
New experimental driver for SundanceIT ST1023 / IP1000+ NICs.
PHY initialization, media select and MAC address are working, but I found no
way to make the chip transmit any frame yet (although it clears the DONE flag).

Moved DSK_DECL to globals.h, where NIF_DECL already was.

diffstat:

 sys/arch/sandpoint/stand/altboot/Makefile   |    6 +-
 sys/arch/sandpoint/stand/altboot/brdsetup.c |   24 +-
 sys/arch/sandpoint/stand/altboot/dsk.c      |    9 +-
 sys/arch/sandpoint/stand/altboot/globals.h  |   11 +-
 sys/arch/sandpoint/stand/altboot/main.c     |    8 +-
 sys/arch/sandpoint/stand/altboot/nif.c      |    3 +-
 sys/arch/sandpoint/stand/altboot/pciide.c   |   10 +-
 sys/arch/sandpoint/stand/altboot/siisata.c  |    5 +-
 sys/arch/sandpoint/stand/altboot/stg.c      |  542 ++++++++++++++++++++++++++++
 9 files changed, 591 insertions(+), 27 deletions(-)

diffs (truncated from 778 to 300 lines):

diff -r 7c937ea30c45 -r a202c7086f35 sys/arch/sandpoint/stand/altboot/Makefile
--- a/sys/arch/sandpoint/stand/altboot/Makefile Sun Mar 06 10:33:40 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/Makefile Sun Mar 06 13:55:12 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.8 2011/02/26 20:11:24 phx Exp $
+#      $NetBSD: Makefile,v 1.9 2011/03/06 13:55:12 phx Exp $
 
 S=             ${.CURDIR}/../../../..
 
@@ -6,8 +6,8 @@
 FILES+=                ${PROG}.bin ${PROG}.img
 NOMAN=         # defined
 SRCS=          entry.S main.c brdsetup.c pci.c devopen.c dev_net.c nif.c
-SRCS+=         fxp.c tlp.c rge.c skg.c dsk.c pciide.c siisata.c printf.c
-SRCS+=         vers.c
+SRCS+=         fxp.c tlp.c rge.c skg.c stg.c dsk.c pciide.c siisata.c
+SRCS+=         printf.c vers.c
 CLEANFILES+=   vers.c ${PROG} ${PROG}.bin ${PROG}.img
 CFLAGS+=       -Wall -Wno-main -ffreestanding -msoft-float -mmultiple
 CFLAGS+=       -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
diff -r 7c937ea30c45 -r a202c7086f35 sys/arch/sandpoint/stand/altboot/brdsetup.c
--- a/sys/arch/sandpoint/stand/altboot/brdsetup.c       Sun Mar 06 10:33:40 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/brdsetup.c       Sun Mar 06 13:55:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.5 2011/02/14 06:21:29 nisimura Exp $ */
+/* $NetBSD: brdsetup.c,v 1.6 2011/03/06 13:55:12 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -959,6 +959,22 @@
        return NULL;
 }
 
+static uint8_t hex2nibble(char c)
+{
+       if (c >= 'a')
+               c &= ~0x20;
+       return c > '9' ? c - 'A' + 10 : c - '0';
+}
+
+static void
+read_mac_string(uint8_t *mac, char *p)
+{
+       int i;
+
+       for (i = 0; i < 6; i++, p += 3)
+               *mac++ = (hex2nibble(p[0]) << 4) | hex2nibble(p[1]);
+}
+
 /*
  * For cost saving reasons some NAS boxes are missing the ROM for the
  * NIC's ethernet address and keep it in their Flash memory.
@@ -974,7 +990,11 @@
                        memcpy(mac, p, 6);
                        return;
                }
-       } else
+       } else if (brdtype == BRD_DLINKDSM) {
+               read_mac_string(mac, (char *)0xfff0ff80);
+               return;
+       }
+       else
                printf("Warning: This board has no known method defined "
                    "to determine its MAC address!\n");
 
diff -r 7c937ea30c45 -r a202c7086f35 sys/arch/sandpoint/stand/altboot/dsk.c
--- a/sys/arch/sandpoint/stand/altboot/dsk.c    Sun Mar 06 10:33:40 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/dsk.c    Sun Mar 06 13:55:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.4 2011/02/10 13:38:08 nisimura Exp $ */
+/* $NetBSD: dsk.c,v 1.5 2011/03/06 13:55:12 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -57,13 +57,6 @@
 #define CSR_READ_1(r)          *(volatile uint8_t *)(r)
 #define CSR_WRITE_1(r,v)       *(volatile uint8_t *)(r)=(v)
 
-#define DSK_DECL(xxx) \
-    int xxx ## _match(unsigned, void *); \
-    void * xxx ## _init(unsigned, void *)
-
-DSK_DECL(pciide);
-DSK_DECL(siisata);
-
 struct dskdv {
        char *name;
        int (*match)(unsigned, void *);
diff -r 7c937ea30c45 -r a202c7086f35 sys/arch/sandpoint/stand/altboot/globals.h
--- a/sys/arch/sandpoint/stand/altboot/globals.h        Sun Mar 06 10:33:40 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/globals.h        Sun Mar 06 13:55:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.6 2011/02/14 06:21:29 nisimura Exp $ */
+/* $NetBSD: globals.h,v 1.7 2011/03/06 13:55:12 phx Exp $ */
 
 #ifdef DEBUG
 #define        DPRINTF(x)      printf x
@@ -88,6 +88,7 @@
 #define PCI_CLASS_REG                  0x08
 #define  PCI_CLASS_PPB                 0x0604
 #define  PCI_CLASS_ETH                 0x0200
+#define  PCI_CLASS_SCSI                        0x0100
 #define  PCI_CLASS_IDE                 0x0101
 #define  PCI_CLASS_RAID                        0x0104
 #define  PCI_CLASS_SATA                        0x0106
@@ -138,6 +139,7 @@
 NIF_DECL(tlp);
 NIF_DECL(rge);
 NIF_DECL(skg);
+NIF_DECL(stg);
 
 /* DSK support */
 int dskdv_init(void *);
@@ -147,6 +149,13 @@
 int dsk_strategy(void *, int, daddr_t, size_t, void *, size_t *);
 struct fs_ops *dsk_fsops(struct open_file *);
 
+#define DSK_DECL(xxx) \
+    int xxx ## _match(unsigned, void *); \
+    void * xxx ## _init(unsigned, void *)
+
+DSK_DECL(pciide);
+DSK_DECL(siisata);
+
 /* status */
 #define ATA_STS_BUSY           0x80
 #define ATA_STS_DRDY           0x40
diff -r 7c937ea30c45 -r a202c7086f35 sys/arch/sandpoint/stand/altboot/main.c
--- a/sys/arch/sandpoint/stand/altboot/main.c   Sun Mar 06 10:33:40 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/main.c   Sun Mar 06 13:55:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.7 2011/02/26 20:11:24 phx Exp $ */
+/* $NetBSD: main.c,v 1.8 2011/03/06 13:55:12 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -125,6 +125,8 @@
        nata = pcilookup(PCI_CLASS_IDE, lata, 2);
        if (nata == 0)
                nata = pcilookup(PCI_CLASS_MISCSTORAGE, lata, 2);
+       if (nata == 0)
+               nata = pcilookup(PCI_CLASS_SCSI, lata, 2);
        nnif = pcilookup(PCI_CLASS_ETH, lnif, 1);
        nusb = pcilookup(PCI_CLASS_USB, lusb, 3);
 
@@ -231,8 +233,8 @@
        bi_add(&bi_path, BTINFO_BOOTPATH, sizeof(bi_path));
        bi_add(&bi_rdev, BTINFO_ROOTDEVICE, sizeof(bi_rdev));
        bi_add(&bi_fam, BTINFO_PRODFAMILY, sizeof(bi_fam));
-       if (brdtype == BRD_SYNOLOGY) {
-               /* need to set MAC address for Marvell-SKnet */
+       if (brdtype == BRD_SYNOLOGY || brdtype == BRD_DLINKDSM) {
+               /* need to set this MAC address in kernel driver later */
                bi_add(&bi_net, BTINFO_NET, sizeof(bi_net));
        }
 
diff -r 7c937ea30c45 -r a202c7086f35 sys/arch/sandpoint/stand/altboot/nif.c
--- a/sys/arch/sandpoint/stand/altboot/nif.c    Sun Mar 06 10:33:40 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/nif.c    Sun Mar 06 13:55:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nif.c,v 1.2 2011/02/10 13:38:08 nisimura Exp $ */
+/* $NetBSD: nif.c,v 1.3 2011/03/06 13:55:12 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -58,6 +58,7 @@
        { "tlp", tlp_match, tlp_init, tlp_send, tlp_recv },
        { "re",  rge_match, rge_init, rge_send, rge_recv },
        { "sk",  skg_match, skg_init, skg_send, skg_recv },
+       { "stg", stg_match, stg_init, stg_send, stg_recv },
 };
 static int nnifdv = sizeof(lnifdv)/sizeof(lnifdv[0]);
 
diff -r 7c937ea30c45 -r a202c7086f35 sys/arch/sandpoint/stand/altboot/pciide.c
--- a/sys/arch/sandpoint/stand/altboot/pciide.c Sun Mar 06 10:33:40 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/pciide.c Sun Mar 06 13:55:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pciide.c,v 1.2 2011/02/08 00:33:05 nisimura Exp $ */
+/* $NetBSD: pciide.c,v 1.3 2011/03/06 13:55:12 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -35,19 +35,18 @@
 
 #include "globals.h"
 
+static int cmdidefix(struct dkdev_ata *);
+
 static uint32_t pciiobase = PCI_XIOBASE;
 
 struct myops {
        int (*chipfix)(struct dkdev_ata *);
        int (*presense)(struct dkdev_ata *, int);
 };
-static int cmdidefix(struct dkdev_ata *);
+static struct myops defaultops = { NULL, NULL };
 static struct myops cmdideops = { cmdidefix, NULL };
 static struct myops *myops;
 
-int pciide_match(unsigned, void *);
-void *pciide_init(unsigned, void *);
-
 int
 pciide_match(unsigned tag, void *data)
 {
@@ -63,6 +62,7 @@
        case PCI_DEVICE(0x10ad, 0x0105): /* Symphony Labs 82C105 IDE */
        case PCI_DEVICE(0x10b8, 0x5229): /* ALi IDE */
        case PCI_DEVICE(0x1191, 0x0008): /* ACARD ATP865 */
+               myops = &defaultops;
                return 1;
        }
        return 0;
diff -r 7c937ea30c45 -r a202c7086f35 sys/arch/sandpoint/stand/altboot/siisata.c
--- a/sys/arch/sandpoint/stand/altboot/siisata.c        Sun Mar 06 10:33:40 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/siisata.c        Sun Mar 06 13:55:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.2 2011/01/27 17:38:04 phx Exp $ */
+/* $NetBSD: siisata.c,v 1.3 2011/03/06 13:55:12 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -37,9 +37,6 @@
 
 static uint32_t pciiobase = PCI_XIOBASE;
 
-int siisata_match(unsigned, void *);
-void *siisata_init(unsigned, void *);
-
 int
 siisata_match(unsigned tag, void *data)
 {
diff -r 7c937ea30c45 -r a202c7086f35 sys/arch/sandpoint/stand/altboot/stg.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sandpoint/stand/altboot/stg.c    Sun Mar 06 13:55:12 2011 +0000
@@ -0,0 +1,542 @@
+/* $NetBSD: stg.c,v 1.1 2011/03/06 13:55:12 phx Exp $ */
+
+/*-
+ * Copyright (c) 2011 Frank Wille.
+ * All rights reserved.
+ *
+ * Written by Frank Wille for The NetBSD Project.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+
+#include <lib/libsa/stand.h>
+#include <lib/libsa/net.h>
+
+#include "globals.h"
+
+#define CSR_WRITE_1(l, r, v)   *(volatile uint8_t *)((l)->csr+(r)) = (v)
+#define CSR_READ_1(l, r)       *(volatile uint8_t *)((l)->csr+(r))
+#define CSR_WRITE_2(l, r, v)   out16rb((l)->csr+(r), (v))
+#define CSR_READ_2(l, r)       in16rb((l)->csr+(r))
+#define CSR_WRITE_4(l, r, v)   out32rb((l)->csr+(r), (v))
+#define CSR_READ_4(l, r)       in32rb((l)->csr+(r))
+#define VTOPHYS(va)            (uint32_t)(va)
+#define DEVTOV(pa)             (uint32_t)(pa)
+#define wbinv(adr, siz)                _wbinv(VTOPHYS(adr), (uint32_t)(siz))
+#define inv(adr, siz)          _inv(VTOPHYS(adr), (uint32_t)(siz))
+#define DELAY(n)               delay(n)
+#define ALLOC(T,A)             (T *)allocaligned(sizeof(T),(A))
+
+struct desc {
+       uint64_t xd0, xd1, xd2;
+};
+/* xd1 */
+#define RXLEN(x)               ((x) & 0xffff)
+#define RXERRORMASK            0x3f0000LL
+#define TXNOALIGN              (1ULL << 16)
+#define TXFRAGCOUNT(x)         (((uint64_t)((x) & 0xf)) << 48)
+#define DONE                   (1ULL << 31)
+/* xd2 */
+#define FRAGADDR(x)            ((uint64_t)(x))



Home | Main Index | Thread Index | Old Index