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 Improved Synology CS/RS sup...



details:   https://anonhg.NetBSD.org/src/rev/0988a8803b44
branches:  trunk
changeset: 778845:0988a8803b44
user:      phx <phx%NetBSD.org@localhost>
date:      Mon Apr 16 16:55:29 2012 +0000

description:
Improved Synology CS/RS support: watch power-state of all SATA drives before
initializing them, configure drive LEDs to reflect SATA activity.
Configure drives on all ATA PCI devices, not only on the first one.

diffstat:

 sys/arch/sandpoint/stand/altboot/brdsetup.c |  78 ++++++++++++++++++++++++----
 sys/arch/sandpoint/stand/altboot/globals.h  |   9 ++-
 sys/arch/sandpoint/stand/altboot/main.c     |  10 +-
 3 files changed, 79 insertions(+), 18 deletions(-)

diffs (230 lines):

diff -r c363110f5843 -r 0988a8803b44 sys/arch/sandpoint/stand/altboot/brdsetup.c
--- a/sys/arch/sandpoint/stand/altboot/brdsetup.c       Mon Apr 16 16:07:24 2012 +0000
+++ b/sys/arch/sandpoint/stand/altboot/brdsetup.c       Mon Apr 16 16:55:29 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.30 2012/04/09 14:02:04 nisimura Exp $ */
+/* $NetBSD: brdsetup.c,v 1.31 2012/04/16 16:55:29 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -46,6 +46,7 @@
     void xxx ## setup(struct brdprop *); \
     void xxx ## brdfix(struct brdprop *); \
     void xxx ## pcifix(struct brdprop *); \
+    void xxx ## launch(struct brdprop *); \
     void xxx ## reset(void)
 
 BRD_DECL(mot);
@@ -119,28 +120,28 @@
        BRD_SANDPOINTX3,
        0,
        "com", 0x3f8, 115200,
-       motsetup, motbrdfix, motpcifix, NULL },
+       motsetup, motbrdfix, motpcifix, NULL, NULL },
     {
        "encpp1",
        "EnCore PP1",
        BRD_ENCOREPP1,
        0,
        "com", 0x3f8, 115200,
-       encsetup, encbrdfix, encpcifix, NULL },
+       encsetup, encbrdfix, encpcifix, NULL, NULL },
     {
        "kurobox",
        "KuroBox",
        BRD_KUROBOX,
        0,
        "eumb", 0x4600, 57600,
-       kurosetup, kurobrdfix, NULL, kuroreset },
+       kurosetup, kurobrdfix, NULL, NULL, kuroreset },
     {
        "synology",
-       "Synology DS",
+       "Synology CS/DS/RS",
        BRD_SYNOLOGY,
        0,
        "eumb", 0x4500, 115200,
-       synosetup, synobrdfix, NULL, synoreset },
+       synosetup, synobrdfix, synopcifix, synolaunch, synoreset },
     {
        "qnap",
        "QNAP TS",
@@ -148,42 +149,42 @@
        33164691,       /* Linux source says 33000000, but the Synology  */
                        /* clock value delivers a much better precision. */
        "eumb", 0x4500, 115200,
-       NULL, qnapbrdfix, NULL, qnapreset },
+       NULL, qnapbrdfix, NULL, NULL, qnapreset },
     {
        "iomega",
        "IOMEGA StorCenter G2",
        BRD_STORCENTER,
        0,
        "eumb", 0x4500, 115200,
-       NULL, iomegabrdfix, NULL, iomegareset },
+       NULL, iomegabrdfix, NULL, NULL, iomegareset },
     {
        "dlink",
        "D-Link DSM-G600",
        BRD_DLINKDSM,
        33000000,
        "eumb", 0x4500, 9600,
-       NULL, dlinkbrdfix, NULL, NULL },
+       NULL, dlinkbrdfix, NULL, NULL, NULL },
     {
        "nhnas",
        "Netronix NH-230/231",
        BRD_NH230NAS,
        33000000,
        "eumb", 0x4500, 9600,
-       NULL, nhnasbrdfix, NULL, nhnasreset },
+       NULL, nhnasbrdfix, NULL, NULL, nhnasreset },
     {
        "kurot4",
        "KuroBox/T4",
        BRD_KUROBOXT4,
        32768000,
        "eumb", 0x4600, 57600,
-       NULL, kurot4brdfix, NULL, NULL },
+       NULL, kurot4brdfix, NULL, NULL, NULL },
     {
        "unknown",
        "Unknown board",
        BRD_UNKNOWN,
        0,
        "eumb", 0x4500, 115200,
-       NULL, NULL, NULL, NULL }, /* must be the last */
+       NULL, NULL, NULL, NULL, NULL }, /* must be the last */
 };
 
 static struct brdprop *brdprop;
@@ -365,6 +366,15 @@
 }
 
 void
+launchfixup()
+{
+
+       if (brdprop->launch == NULL)
+               return;
+       (*brdprop->launch)(brdprop);
+}
+
+void
 encsetup(struct brdprop *brd)
 {
 
@@ -707,6 +717,50 @@
 }
 
 void
+synopcifix(struct brdprop *brd)
+{
+       static const char csmodel[4][7] = {
+               "CS406e", "CS406", "RS406", "CS407e"
+       };
+       volatile uint8_t *cpld = (volatile uint8_t *)0xff000000;
+       uint8_t pwrstate;
+
+       if (nata > 1) {
+               /*
+                * CS/RS stations power-up their disks one after another.
+                * We have to watch over the current power state in a CPLD
+                * register, until all disks become available.
+                */
+               printf("CPLD V1.%d for model %s\n", cpld[2] & 3,
+                   csmodel[(cpld[2] & 0x0c) >> 2]);
+               cpld[0] = 0x00; /* all drive LEDs blinking yellow */
+               do {
+                       delay(1000 * 1000);
+                       pwrstate = cpld[1];
+                       printf("Power state: %02x\r", pwrstate);
+               } while (pwrstate != 0xff);
+               putchar('\n');
+       }
+}
+
+void
+synolaunch(struct brdprop *brd)
+{
+       volatile uint8_t *cpld = (volatile uint8_t *)0xff000000;
+       struct dkdev_ata *sata1, *sata2;
+
+       if (nata > 1) {
+               /* enable drive LEDs for active disk drives on CS/RS models */
+               sata1 = lata[0].drv;
+               sata2 = lata[1].drv;
+               cpld[0] = (sata1->presense[0] ? 0x80 : 0xc0) |
+                   (sata1->presense[1] ? 0x20 : 0x30) |
+                   (sata2->presense[0] ? 0x08 : 0x0c) |
+                   (sata2->presense[1] ? 0x02 : 0x03);
+       }
+}
+
+void
 synoreset()
 {
 
diff -r c363110f5843 -r 0988a8803b44 sys/arch/sandpoint/stand/altboot/globals.h
--- a/sys/arch/sandpoint/stand/altboot/globals.h        Mon Apr 16 16:07:24 2012 +0000
+++ b/sys/arch/sandpoint/stand/altboot/globals.h        Mon Apr 16 16:55:29 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.17 2012/04/08 10:38:34 nisimura Exp $ */
+/* $NetBSD: globals.h,v 1.18 2012/04/16 16:55:29 phx Exp $ */
 
 #ifdef DEBUG
 #define        DPRINTF(x)      printf x
@@ -36,6 +36,7 @@
        void (*setup)(struct brdprop *);
        void (*brdfix)(struct brdprop *);
        void (*pcifix)(struct brdprop *);
+       void (*launch)(struct brdprop *);
        void (*reset)(void);
 };
 
@@ -79,8 +80,14 @@
        unsigned pvd;   /* device ID */
        void *drv;      /* driver */
 };
+extern struct pcidev lata[2];
+extern struct pcidev lnif[2];
+extern struct pcidev lusb[3];
+extern int nata, nnif, nusb;
+
 void  pcisetup(void);
 void  pcifixup(void);
+void  launchfixup(void);
 unsigned pcimaketag(int, int, int);
 void  pcidecomposetag(unsigned, int *, int *, int *);
 int   pcifinddev(unsigned, unsigned, unsigned *);
diff -r c363110f5843 -r 0988a8803b44 sys/arch/sandpoint/stand/altboot/main.c
--- a/sys/arch/sandpoint/stand/altboot/main.c   Mon Apr 16 16:07:24 2012 +0000
+++ b/sys/arch/sandpoint/stand/altboot/main.c   Mon Apr 16 16:55:29 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.17 2012/01/22 13:08:16 phx Exp $ */
+/* $NetBSD: main.c,v 1.18 2012/04/16 16:55:29 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -218,10 +218,9 @@
        }
 
        /* intialize a disk driver */
-       for (n = 0; n < nata; n++)
-               if (dskdv_init(&lata[n]) != 0)
-                       break;
-       if (n >= nata)
+       for (i = 0, n = 0; i < nata; i++)
+               n += dskdv_init(&lata[i]);
+       if (n == 0)
                printf("IDE/SATA device driver was not found\n");
 
        /* initialize a network interface */
@@ -339,6 +338,7 @@
                            btinfo_modulelist_size);
        }
 
+       launchfixup();
        netif_shutdown_all();
 
        __syncicache((void *)marks[MARK_ENTRY],



Home | Main Index | Thread Index | Old Index