Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/newsmips Add NWS-4000 support.



details:   https://anonhg.NetBSD.org/src/rev/bfcb71059cc6
branches:  trunk
changeset: 433954:bfcb71059cc6
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Oct 14 00:10:11 2018 +0000

description:
Add NWS-4000 support.

Based on nonaka@'s porting effort back in 2002.
See announcement on port-newsmips@ for more details:
 http://mail-index.netbsd.org/port-newsmips/2018/10/13/msg000231.html

diffstat:

 sys/arch/newsmips/apbus/apbus.c       |   34 +++-
 sys/arch/newsmips/apbus/apbusvar.h    |    7 +-
 sys/arch/newsmips/apbus/if_sn.c       |   27 +-
 sys/arch/newsmips/apbus/if_sn_ap.c    |   79 ++++++++--
 sys/arch/newsmips/apbus/if_snvar.h    |   13 +-
 sys/arch/newsmips/apbus/kb_ap.c       |    7 +-
 sys/arch/newsmips/apbus/spifi.c       |    6 +-
 sys/arch/newsmips/apbus/zs_ap.c       |  235 +++++++++++++++++++++++++-------
 sys/arch/newsmips/conf/GENERIC        |    6 +-
 sys/arch/newsmips/conf/files.newsmips |    5 +-
 sys/arch/newsmips/conf/std.newsmips   |    3 +-
 sys/arch/newsmips/include/adrsmap.h   |   55 +++++++-
 sys/arch/newsmips/include/apbus.h     |    3 +-
 sys/arch/newsmips/include/cpu.h       |    6 +-
 sys/arch/newsmips/include/intr.h      |    3 +-
 sys/arch/newsmips/newsmips/cpu_cons.c |   16 +-
 sys/arch/newsmips/newsmips/machdep.c  |   34 +++-
 sys/arch/newsmips/newsmips/machid.h   |    6 +-
 sys/arch/newsmips/newsmips/news4000.c |  242 ++++++++++++++++++++++++++++++++++
 sys/arch/newsmips/newsmips/news5000.c |    6 +-
 sys/arch/newsmips/stand/boot/boot.c   |   12 +-
 sys/arch/newsmips/stand/boot/version  |    3 +-
 22 files changed, 674 insertions(+), 134 deletions(-)

diffs (truncated from 1429 to 300 lines):

diff -r 6cc90e193753 -r bfcb71059cc6 sys/arch/newsmips/apbus/apbus.c
--- a/sys/arch/newsmips/apbus/apbus.c   Sat Oct 13 21:02:34 2018 +0000
+++ b/sys/arch/newsmips/apbus/apbus.c   Sun Oct 14 00:10:11 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apbus.c,v 1.24 2018/09/30 14:09:35 tsutsui Exp $       */
+/*     $NetBSD: apbus.c,v 1.25 2018/10/14 00:10:11 tsutsui Exp $       */
 
 /*-
  * Copyright (C) 1999 SHIMIZU Ryo.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: apbus.c,v 1.24 2018/09/30 14:09:35 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apbus.c,v 1.25 2018/10/14 00:10:11 tsutsui Exp $");
 
 #define __INTR_PRIVATE
 
@@ -78,6 +78,8 @@
 #define        NLEVEL  2
 static struct newsmips_intr apintr_tab[NLEVEL];
 
+volatile uint32_t *news_wbflush;
+
 static int
 apbusmatch(device_t parent, cfdata_t cf, void *aux)
 {
@@ -102,10 +104,17 @@
        apbus_map_romwork();
        mips_set_wbflush(apbus_wbflush);
 
-       *(volatile uint32_t *)(NEWS5000_APBUS_INTST) = 0xffffffff;
-       *(volatile uint32_t *)(NEWS5000_APBUS_INTMSK) = 0xffffffff;
-       *(volatile uint32_t *)(NEWS5000_APBUS_CTRL) = 0x00000004;
-       *(volatile uint32_t *)(NEWS5000_APBUS_DMA) = 0xffffffff;
+       if (systype == NEWS5000) {
+               *(volatile uint32_t *)(NEWS5000_APBUS_INTST) = 0xffffffff;
+               *(volatile uint32_t *)(NEWS5000_APBUS_INTMSK) = 0xffffffff;
+               *(volatile uint32_t *)(NEWS5000_APBUS_CTRL) = 0x00000004;
+               *(volatile uint32_t *)(NEWS5000_APBUS_DMA) = 0xffffffff;
+       }
+       if (systype == NEWS4000) {
+               *(volatile uint32_t *)0xb60000a4 = 0x1fffffff;
+               *(volatile uint32_t *)0xb6000070 = 0xffffffff;
+               *(volatile uint32_t *)0xb6000098 = 0xffffffff;
+       }
 
        aprint_normal("\n");
 
@@ -181,10 +190,9 @@
 void
 apbus_wbflush(void)
 {
-       volatile int32_t * const our_wbflush = (int32_t *)NEWS5000_WBFLUSH;
 
        (*mips_locore_jumpvec.ljv_wbflush)();
-       (void)*our_wbflush;
+       (void)*news_wbflush;
 }
 
 /*
@@ -249,13 +257,19 @@
        LIST_INSERT_AFTER(curih, ih, ih_q);
 
  done:
+       if (systype == NEWS5000) {
+               inten0 = (uint32_t *)NEWS5000_INTEN0;
+               inten1 = (uint32_t *)NEWS5000_INTEN1;
+       }
+       if (systype == NEWS4000) {
+               inten0 = (uint32_t *)NEWS4000_INTEN0;
+               inten1 = (uint32_t *)NEWS4000_INTEN1;
+       }
        switch (level) {
        case 0:
-               inten0 = (volatile uint32_t *)NEWS5000_INTEN0;
                *inten0 |= mask;
                break;
        case 1:
-               inten1 = (volatile uint32_t *)NEWS5000_INTEN1;
                *inten1 |= mask;
                break;
        }
diff -r 6cc90e193753 -r bfcb71059cc6 sys/arch/newsmips/apbus/apbusvar.h
--- a/sys/arch/newsmips/apbus/apbusvar.h        Sat Oct 13 21:02:34 2018 +0000
+++ b/sys/arch/newsmips/apbus/apbusvar.h        Sun Oct 14 00:10:11 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apbusvar.h,v 1.10 2018/09/30 06:14:23 tsutsui Exp $    */
+/*     $NetBSD: apbusvar.h,v 1.11 2018/10/14 00:10:11 tsutsui Exp $    */
 
 /*-
  * Copyright (C) 1999 SHIMIZU Ryo.  All rights reserved.
@@ -50,4 +50,7 @@
 struct newsmips_bus_dma_tag *apbus_dmatag_init(struct apbus_attach_args *);
 void apbus_wbflush(void);
 
-#define        SLOTTOMASK(slot)        ((slot) ? (0x0100 << ((slot) - 1)) : 0)
+#define        NEWS5000_SLOTTOMASK(slot)       ((slot) ? (0x0100 << ((slot) - 1)) : 0)
+#define        NEWS4000_SLOTTOMASK(slot)       ((slot) ? (0x0001 << ((slot) - 1)) : 0)
+#define        SLOTTOMASK(slot)                (systype == NEWS5000 ?          \
+           NEWS5000_SLOTTOMASK(slot) : NEWS4000_SLOTTOMASK(slot))
diff -r 6cc90e193753 -r bfcb71059cc6 sys/arch/newsmips/apbus/if_sn.c
--- a/sys/arch/newsmips/apbus/if_sn.c   Sat Oct 13 21:02:34 2018 +0000
+++ b/sys/arch/newsmips/apbus/if_sn.c   Sun Oct 14 00:10:11 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_sn.c,v 1.42 2018/09/03 16:29:26 riastradh Exp $     */
+/*     $NetBSD: if_sn.c,v 1.43 2018/10/14 00:10:11 tsutsui Exp $       */
 
 /*
  * National Semiconductor  DP8393X SONIC Driver
@@ -16,7 +16,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sn.c,v 1.42 2018/09/03 16:29:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sn.c,v 1.43 2018/10/14 00:10:11 tsutsui Exp $");
 
 #include "opt_inet.h"
 
@@ -109,7 +109,7 @@
        uint8_t *pp;
        int     i;
 
-       if (sc->space == NULL) {
+       if (sc->memory == NULL) {
                aprint_error_dev(sc->sc_dev,
                    "memory allocation for descriptors failed\n");
                return 1;
@@ -133,21 +133,21 @@
         * a higher buffer address to a 16 bit offset--this will cause wrap
         * around problems near the end of 64k !!
         */
-       p = sc->space;
+       p = sc->memory;
        pp = (uint8_t *)roundup((int)p, PAGE_SIZE);
        p = pp;
 
        for (i = 0; i < NRRA; i++) {
                sc->p_rra[i] = (void *)p;
-               sc->v_rra[i] = SONIC_GETDMA(p);
+               sc->v_rra[i] = SONIC_GETDMA(sc, p);
                p += RXRSRC_SIZE(sc);
        }
-       sc->v_rea = SONIC_GETDMA(p);
+       sc->v_rea = SONIC_GETDMA(sc, p);
 
        p = (uint8_t *)SOALIGN(sc, p);
 
        sc->p_cda = (void *)(p);
-       sc->v_cda = SONIC_GETDMA(p);
+       sc->v_cda = SONIC_GETDMA(sc, p);
        p += CDA_SIZE(sc);
 
        p = (uint8_t *)SOALIGN(sc, p);
@@ -155,7 +155,7 @@
        for (i = 0; i < NTDA; i++) {
                struct mtd *mtdp = &sc->mtda[i];
                mtdp->mtd_txp = (void *)p;
-               mtdp->mtd_vtxp = SONIC_GETDMA(p);
+               mtdp->mtd_vtxp = SONIC_GETDMA(sc, p);
                p += TXP_SIZE(sc);
        }
 
@@ -176,12 +176,12 @@
 
        sc->sc_nrda = PAGE_SIZE / RXPKT_SIZE(sc);
        sc->p_rda = (void *)p;
-       sc->v_rda = SONIC_GETDMA(p);
+       sc->v_rda = SONIC_GETDMA(sc, p);
 
        p = pp + PAGE_SIZE;
 
        for (i = 0; i < NRBA; i++) {
-               sc->rbuf[i] = (void *)p;
+               sc->rbuf[i] = SONIC_BUFFER(sc, p);
                p += PAGE_SIZE;
        }
 
@@ -189,8 +189,8 @@
        for (i = 0; i < NTDA; i++) {
                struct mtd *mtdp = &sc->mtda[i];
 
-               mtdp->mtd_buf = p;
-               mtdp->mtd_vbuf = SONIC_GETDMA(p);
+               mtdp->mtd_buf = SONIC_BUFFER(sc, p);
+               mtdp->mtd_vbuf = SONIC_GETDMA(sc, p);
                p += TXBSIZE;
        }
 
@@ -738,6 +738,7 @@
 
        NIC_PUT(sc, SNR_UTDA, UPPER(sc->mtda[0].mtd_vtxp));
        NIC_PUT(sc, SNR_CTDA, LOWER(sc->mtda[0].mtd_vtxp));
+       wbflush();
 }
 
 static void
@@ -789,7 +790,7 @@
 
        /* fill up SOME of the rra with buffers */
        for (i = 0; i < NRBA; i++) {
-               v = SONIC_GETDMA(sc->rbuf[i]);
+               v = SONIC_GETDMA(sc, sc->rbuf[i]);
                SWO(bitmode, sc->p_rra[i], RXRSRC_PTRHI, UPPER(v));
                SWO(bitmode, sc->p_rra[i], RXRSRC_PTRLO, LOWER(v));
                SWO(bitmode, sc->p_rra[i], RXRSRC_WCHI, UPPER(PAGE_SIZE/2));
diff -r 6cc90e193753 -r bfcb71059cc6 sys/arch/newsmips/apbus/if_sn_ap.c
--- a/sys/arch/newsmips/apbus/if_sn_ap.c        Sat Oct 13 21:02:34 2018 +0000
+++ b/sys/arch/newsmips/apbus/if_sn_ap.c        Sun Oct 14 00:10:11 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_sn_ap.c,v 1.12 2018/09/30 14:23:24 tsutsui Exp $    */
+/*     $NetBSD: if_sn_ap.c,v 1.13 2018/10/14 00:10:11 tsutsui Exp $    */
 
 /*
  * Copyright (C) 1997 Allen Briggs
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sn_ap.c,v 1.12 2018/09/30 14:23:24 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sn_ap.c,v 1.13 2018/10/14 00:10:11 tsutsui Exp $");
 
 #include "opt_inet.h"
 
@@ -53,6 +53,8 @@
 #include <newsmips/apbus/if_snreg.h>
 #include <newsmips/apbus/if_snvar.h>
 
+#include <newsmips/newsmips/machid.h>
+
 #define SONIC_MACROM_OFFSET    0x40
 
 #define SONIC_APBUS_REG_OFFSET 0x00010000
@@ -86,18 +88,36 @@
        struct sn_softc *sc = device_private(self);
        struct apbus_attach_args *apa = aux;
        uint8_t myaddr[ETHER_ADDR_LEN];
-       u_int intrmask;
+       uint32_t intrmask = 0;
 
        sc->sc_dev = self;
-       sc->sc_hwbase = (void *)apa->apa_hwbase;
-       sc->sc_regbase = (void *)(apa->apa_hwbase + SONIC_APBUS_REG_OFFSET);
-       sc->space = (void *)(apa->apa_hwbase + SONIC_APBUS_MEM_OFFSET);
+       sc->slotno = apa->apa_slotno;
+       if (systype == NEWS4000 && sc->slotno == 0) {
+               sc->sc_flags |= F_NWS40S0;
+       }
+       if ((sc->sc_flags & F_NWS40S0) != 0) {
+               sc->sc_hwbase = (void *)apa->apa_hwbase;
+               sc->sc_regbase = (void *)apa->apa_hwbase;
+               sc->memory = (void *)NEWS4000_SONIC_MEMORY;
+               sc->buffer = (void *)NEWS4000_SONIC_BUFFER;
+       } else {
+               sc->sc_hwbase = (void *)apa->apa_hwbase;
+               sc->sc_regbase =
+                   (void *)(apa->apa_hwbase + SONIC_APBUS_REG_OFFSET);
+               sc->memory =
+                   (void *)(apa->apa_hwbase + SONIC_APBUS_MEM_OFFSET);
+       }
 
        aprint_normal(" slot%d addr 0x%lx", apa->apa_slotno, apa->apa_hwbase);
 
-       sc->snr_dcr = DCR_WAIT0 | DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16;
-       sc->snr_dcr2 = 0;
-       sc->snr_dcr |= DCR_EXBUS;
+       if ((sc->sc_flags & F_NWS40S0) != 0) {
+               sc->snr_dcr = DCR_STERM | DCR_TFT28;
+               sc->snr_dcr2 = 0x0100;
+       } else {
+               sc->snr_dcr = DCR_WAIT0 | DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16;
+               sc->snr_dcr2 = 0;
+               sc->snr_dcr |= DCR_EXBUS;
+       }
        sc->bitmode = 1;
 
        if (sn_ap_getaddr(sc, myaddr)) {
@@ -111,8 +131,14 @@
        if (snsetup(sc, myaddr))
                return;
 
-       intrmask = (apa->apa_slotno == 0) ?
-           NEWS5000_INT0_SONIC : SLOTTOMASK(apa->apa_slotno);
+       if (systype == NEWS5000) {
+               intrmask = (apa->apa_slotno == 0) ?
+                   NEWS5000_INT0_SONIC : NEWS5000_SLOTTOMASK(apa->apa_slotno);
+       }
+       if (systype == NEWS4000) {
+               intrmask = (apa->apa_slotno == 0) ?
+                   NEWS4000_INT0_SONIC : NEWS4000_SLOTTOMASK(apa->apa_slotno);
+       }
 
        apbus_intr_establish(0, /* interrupt level (0 or 1) */
            intrmask,
@@ -123,14 +149,21 @@
 int
 sn_ap_getaddr(struct sn_softc *sc, uint8_t *lladdr)
 {
-       uint32_t *p;
-       int i;



Home | Main Index | Thread Index | Old Index