Module Name:    src
Committed By:   phx
Date:           Mon Apr 16 16:55:29 UTC 2012

Modified Files:
        src/sys/arch/sandpoint/stand/altboot: brdsetup.c globals.h main.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sandpoint/stand/altboot/globals.h \
    src/sys/arch/sandpoint/stand/altboot/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sandpoint/stand/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.30 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.31
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.30	Mon Apr  9 14:02:04 2012
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Mon Apr 16 16:55:29 2012
@@ -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 @@ static struct brdprop brdlist[] = {
 	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 @@ static struct brdprop brdlist[] = {
 	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 @@ pcifixup()
 }
 
 void
+launchfixup()
+{
+
+	if (brdprop->launch == NULL)
+		return;
+	(*brdprop->launch)(brdprop);
+}
+
+void
 encsetup(struct brdprop *brd)
 {
 
@@ -707,6 +717,50 @@ synobrdfix(struct brdprop *brd)
 }
 
 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()
 {
 

Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.17 src/sys/arch/sandpoint/stand/altboot/globals.h:1.18
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.17	Sun Apr  8 10:38:34 2012
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Mon Apr 16 16:55:29 2012
@@ -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 @@ struct brdprop {
 	void (*setup)(struct brdprop *);
 	void (*brdfix)(struct brdprop *);
 	void (*pcifix)(struct brdprop *);
+	void (*launch)(struct brdprop *);
 	void (*reset)(void);
 };
 
@@ -79,8 +80,14 @@ struct pcidev {
 	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 *);
Index: src/sys/arch/sandpoint/stand/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.17 src/sys/arch/sandpoint/stand/altboot/main.c:1.18
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.17	Sun Jan 22 13:08:16 2012
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Mon Apr 16 16:55:29 2012
@@ -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 @@ main(int argc, char *argv[], char *boota
 	}
 
 	/* 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 @@ main(int argc, char *argv[], char *boota
 			    btinfo_modulelist_size);
 	}
 
+	launchfixup();
 	netif_shutdown_all();
 
 	__syncicache((void *)marks[MARK_ENTRY],

Reply via email to