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/netboot Minor source cleanup. Sugge...



details:   https://anonhg.NetBSD.org/src/rev/1a5545cba221
branches:  trunk
changeset: 756944:1a5545cba221
user:      phx <phx%NetBSD.org@localhost>
date:      Sun Aug 08 11:54:45 2010 +0000

description:
Minor source cleanup. Suggested by Kiyohara.

diffstat:

 sys/arch/sandpoint/stand/netboot/dsk.c     |   3 +-
 sys/arch/sandpoint/stand/netboot/main.c    |   4 +-
 sys/arch/sandpoint/stand/netboot/siisata.c |  46 +++++++++++++++++++++++++++--
 3 files changed, 46 insertions(+), 7 deletions(-)

diffs (124 lines):

diff -r 5f2f5e17ccbc -r 1a5545cba221 sys/arch/sandpoint/stand/netboot/dsk.c
--- a/sys/arch/sandpoint/stand/netboot/dsk.c    Sun Aug 08 11:25:53 2010 +0000
+++ b/sys/arch/sandpoint/stand/netboot/dsk.c    Sun Aug 08 11:54:45 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.3 2010/07/23 20:01:27 phx Exp $ */
+/* $NetBSD: dsk.c,v 1.4 2010/08/08 11:54:45 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -365,6 +365,7 @@
        const char *err;
        int error;
 
+return EIO; /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
        l = d->dvops;
        n = d->unittag;
        p = (uint16_t *)buf;
diff -r 5f2f5e17ccbc -r 1a5545cba221 sys/arch/sandpoint/stand/netboot/main.c
--- a/sys/arch/sandpoint/stand/netboot/main.c   Sun Aug 08 11:25:53 2010 +0000
+++ b/sys/arch/sandpoint/stand/netboot/main.c   Sun Aug 08 11:54:45 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.34 2010/06/26 21:45:49 phx Exp $ */
+/* $NetBSD: main.c,v 1.35 2010/08/08 11:54:45 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -151,7 +151,7 @@
                if (i >= sizeof(bootargs) / sizeof(bootargs[0]))
                        break;  /* break on first unknown string */
        }
-       if (n == argc)
+       if (n >= argc)
                bname = BNAME_DEFAULT;
        else {
                bname = argv[n];
diff -r 5f2f5e17ccbc -r 1a5545cba221 sys/arch/sandpoint/stand/netboot/siisata.c
--- a/sys/arch/sandpoint/stand/netboot/siisata.c        Sun Aug 08 11:25:53 2010 +0000
+++ b/sys/arch/sandpoint/stand/netboot/siisata.c        Sun Aug 08 11:54:45 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.11 2010/07/23 20:04:52 phx Exp $ */
+/* $NetBSD: siisata.c,v 1.12 2010/08/08 11:54:46 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,9 +58,10 @@
 void *
 siisata_init(unsigned tag, void *data)
 {
-       unsigned val;
+       unsigned val, cls;
        int nchan, n;
        struct dkdev_ata *l;
+       static int ba5bccregs[] = { 0x40, 0x44, 0x240, 0x244 };
 
        l = alloc(sizeof(struct dkdev_ata));
        memset(l, 0, sizeof(struct dkdev_ata));
@@ -77,17 +78,24 @@
        val = pcicfgread(tag, PCI_ID_REG);
        if ((PCI_PRODUCT(val) & 0xf) == 0x2) {
                /* 3112/3512 */
+               /* reset BA5 indirect access enable */
+               val = pcicfgread(tag, 0x40);
+               pcicfgwrite(tag, 0x40, val & ~02);
+               /* reset everything, enable BA5 access */
+               pcicfgwrite(tag, 0x88, 0x100f3);
+               delay(50 * 1000);
+               pcicfgwrite(tag, 0x88, 0x10000);
+               delay(50 * 1000);               
                l->chan[0].cmd = l->bar[0];
                l->chan[0].ctl = l->chan[0].alt = l->bar[1] | 02;
                l->chan[0].dma = l->bar[4] + 0x0;
                l->chan[1].cmd = l->bar[2];
                l->chan[1].ctl = l->chan[1].alt = l->bar[3] | 02;
                l->chan[1].dma = l->bar[4] + 0x8;
-               /* assume BA5 access is possible */
                nchan = 2;
        }
        else {
-               /* 3114 */
+               /* 3114 - assume BA5 access is possible */
                l->chan[0].cmd = l->bar[5] + 0x080;
                l->chan[0].ctl = l->chan[0].alt = (l->bar[5] + 0x088) | 02;
                l->chan[1].cmd = l->bar[5] + 0x0c0;
@@ -98,10 +106,40 @@
                l->chan[3].ctl = l->chan[3].alt = (l->bar[5] + 0x2c8) | 02;
                nchan = 4;
        }
+
+       /* fixup cache line */
+       cls = (pcicfgread(tag, 0xc) & 0xff) << 2;
+       if (cls > 224) {
+               cls = (pcicfgread(tag, 0xc) & 0xff) | (224>>2);
+               pcicfgwrite(tag, 0xc, cls);
+               cls = 224;
+       } else if (cls < 32)
+               cls = 32;
+       cls = (cls + 31) / 32;
+       for (n = 0; n < nchan; n++) {
+               val = in32rb(l->bar[5] + ba5bccregs[n]);
+               if ((val & 0x7) < cls)
+                       out32rb(l->bar[5] + ba5bccregs[n], (val & 0x07) | cls);
+       }
+
+       /* detect presence */
        for (n = 0; n < nchan; n++) {
                l->presense[n] = satapresense(l, n);
                if (l->presense[n])
                        printf("port %d device present\n", n);
        }
+
+       out32rb(l->bar[5] + 0xb4, 01);
+       out32rb(l->bar[5] + 0xf4, 01);
+       out32rb(l->bar[5] + 0xa4, 0x328a);
+       out32rb(l->bar[5] + 0xe4, 0x328a);
+
+       for (val=0; val<0x100; val+=4) {
+               if ((val & 0xf) == 0)
+                       printf("0x%02x:",val);
+               printf(" 0x%08x",pcicfgread(tag,val));
+               if ((val & 0xf) == 0xc)
+                       printf("\n");
+       }
        return l;
 }



Home | Main Index | Thread Index | Old Index