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 brdsetup() cleanup by Toru ...
details: https://anonhg.NetBSD.org/src/rev/fe9364fba876
branches: trunk
changeset: 755037:fe9364fba876
user: phx <phx%NetBSD.org@localhost>
date: Thu May 20 20:18:51 2010 +0000
description:
brdsetup() cleanup by Toru Nishimura.
Put all board-relevant data into a structure.
A few modifications by myself to use the new structure for generating the
BTINFO_PRODFAMILY boot node.
diffstat:
sys/arch/sandpoint/stand/netboot/brdsetup.c | 1040 +++++++++++++++-----------
sys/arch/sandpoint/stand/netboot/globals.h | 26 +-
sys/arch/sandpoint/stand/netboot/main.c | 44 +-
sys/arch/sandpoint/stand/netboot/version | 2 +
4 files changed, 617 insertions(+), 495 deletions(-)
diffs (truncated from 1281 to 300 lines):
diff -r 8da3285d98b8 -r fe9364fba876 sys/arch/sandpoint/stand/netboot/brdsetup.c
--- a/sys/arch/sandpoint/stand/netboot/brdsetup.c Thu May 20 19:27:25 2010 +0000
+++ b/sys/arch/sandpoint/stand/netboot/brdsetup.c Thu May 20 20:18:51 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.18 2010/05/19 15:04:51 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.19 2010/05/20 20:18:51 phx Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -39,16 +39,82 @@
#include "globals.h"
-const unsigned dcache_line_size = 32; /* 32B linesize */
-const unsigned dcache_range_size = 4 * 1024; /* 16KB / 4-way */
+#define BRD_DECL(xxx) \
+ void xxx ## setup(struct brdprop *); \
+ void xxx ## brdfix(struct brdprop *); \
+ void xxx ## pcifix(struct brdprop *); \
+ void xxx ## reset(void)
+
+BRD_DECL(enc);
+BRD_DECL(mot);
+BRD_DECL(kuro);
+BRD_DECL(syno);
+static struct brdprop brdlist[] = {
+ {
+ "sandpoint",
+ "Sandpoint X3",
+ BRD_SANDPOINTX3,
+ 0,
+ "com", 0x3f8, 115200,
+ motsetup, NULL, motpcifix },
+ {
+ "encpp1",
+ "EnCore PP1",
+ BRD_ENCOREPP1,
+ 0,
+ "com", 0x3f8, 115200,
+ encsetup, NULL, encpcifix },
+ {
+ "kurobox",
+ "KuroBox",
+ BRD_KUROBOX,
+ 32768000,
+ "eumb", 0x4600, 57600,
+ kurosetup, kurobrdfix, kuropcifix },
+ {
+ "synology",
+ "Synology DS",
+ BRD_SYNOLOGY,
+ 33164691, /* from Synology/Linux source */
+ /* 33168000, XXX better precision? */
+ "eumb", 0x4500, 115200,
+ synosetup, synobrdfix, synopcifix, synoreset },
+ {
+ "qnap",
+ "QNAP TS-101",
+ BRD_QNAPTS101,
+ 0,
+ "eumb", 0x4500, 115200,
+ NULL, NULL, NULL },
+ {
+ "iomega",
+ "IOMEGA Storcenter",
+ BRD_STORCENTER,
+ 0,
+ "eumb", 0x4500, 115200,
+ NULL, NULL, NULL },
+ {
+ "unknown",
+ "Unknown board",
+ BRD_UNKNOWN,
+ 0,
+ "eumb", 0x4500, 115200,
+ NULL, NULL, NULL }, /* must be the last */
+};
+
+static struct brdprop *brdprop;
static uint32_t ns_per_tick;
-void brdsetup(void);
-void setup_82C686B(void);
-void setup_83C553F(void);
+static void brdfixup(void);
+static void setup(void);
+static inline uint32_t cputype(void);
+static inline u_quad_t mftb(void);
+static void init_uart(unsigned, unsigned, uint8_t);
+static void send_sat(char *);
-static inline u_quad_t mftb(void);
+const unsigned dcache_line_size = 32; /* 32B linesize */
+const unsigned dcache_range_size = 4 * 1024; /* 16KB / 4-way */
unsigned uart1base; /* console */
unsigned uart2base; /* optional satellite processor */
@@ -71,42 +137,7 @@
#define UART_READ(base, r) *(volatile char *)(base + (r))
#define UART_WRITE(base, r, v) *(volatile char *)(base + (r)) = (v)
-static __inline uint32_t
-cputype(void)
-{
- uint32_t pvr;
-
- __asm volatile ("mfpvr %0" : "=r"(pvr));
- return pvr >> 16;
-}
-
-static void
-init_uart(unsigned base, unsigned speed, uint8_t lcr)
-{
- unsigned div;
-
- div = busclock / speed / 16;
- UART_WRITE(base, LCR, 0x80); /* turn on DLAB bit */
- UART_WRITE(base, FCR, 0x00);
- UART_WRITE(base, DMB, div >> 8); /* set speed */
- UART_WRITE(base, DLB, div & 0xff);
- UART_WRITE(base, LCR, lcr);
- UART_WRITE(base, FCR, 0x07); /* FIFO on, TXRX FIFO reset */
- UART_WRITE(base, IER, 0x00); /* make sure INT disabled */
-}
-
-/* talk to satellite processor */
-static void
-send_sat(char *msg)
-{
- unsigned savedbase;
-
- savedbase = uart1base;
- uart1base = uart2base;
- while (*msg)
- putchar(*msg++);
- uart1base = savedbase;
-}
+void brdsetup(void);
void
brdsetup(void)
@@ -143,50 +174,32 @@
if (pcifinddev(0x10ad, 0x0565, &pcib) == 0) {
brdtype = BRD_SANDPOINTX3;
- setup_83C553F();
}
else if (pcifinddev(0x1106, 0x0686, &pcib) == 0) {
brdtype = BRD_ENCOREPP1;
- setup_82C686B();
}
else if ((pcicfgread(pcimaketag(0, 11, 0), PCI_CLASS_REG) >> 16) ==
PCI_CLASS_ETH) {
/* tlp (ADMtek AN985) or re (RealTek 8169S) at dev 11 */
brdtype = BRD_KUROBOX;
- consname = "eumb";
- consport = 0x4600;
- consspeed = 57600;
- if (PCI_VENDOR(pcicfgread(pcimaketag(0, 11, 0), PCI_ID_REG))
- == 0x10ec)
- extclk = 32768000; /* decr 2457600Hz */
- else
- extclk = 32521333; /* decr 2439100Hz */
}
else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) ==
0x11ab) { /* PCI_VENDOR_MARVELL */
brdtype = BRD_SYNOLOGY;
- consname = "eumb";
- consport = 0x4500;
- consspeed = 115200;
- extclk = 33164691; /* from Synology/Linux source */
- /* extclk = 33168000; XXX better precision? */
}
else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) ==
0x8086) { /* PCI_VENDOR_INTEL */
brdtype = BRD_QNAPTS101;
- consname = "eumb";
- consport = 0x4500;
- consspeed = 115200;
- }
- else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) ==
- 0x10ec) { /* PCI_VENDOR_REALTEK */
- brdtype = BRD_STORCENTER;
- consname = "eumb";
- consport = 0x4500;
- consspeed = 115200;
}
+ brdprop = brd_lookup(brdtype);
+
+ /* brd dependent adjustments */
+ setup();
+
/* determine clock frequencies */
+ if (brdprop->extclk != 0)
+ extclk = brdprop->extclk;
if (busclock == 0) {
if (cputype() == MPC8245) {
/* PLL_CFG from PCI host bridge register 0xe2 */
@@ -203,6 +216,10 @@
ticks_per_sec = busclock >> 2;
ns_per_tick = 1000000000 / ticks_per_sec;
+ consname = brdprop->consname;
+ consport = brdprop->consport;
+ consspeed = brdprop->consspeed;
+
/* now prepare serial console */
if (strcmp(consname, "eumb") == 0) {
uart1base = 0xfc000000 + consport; /* 0x4500, 0x4600 */
@@ -211,64 +228,461 @@
} else
uart1base = 0xfe000000 + consport; /* 0x3f8, 0x2f8 */
- /* configure 2nd UART when needed */
- switch (brdtype) {
- case BRD_KUROBOX:
- init_uart(uart2base, 9600, LCR_8BITS | LCR_PEVEN);
- /* Stop Watchdog */
- send_sat("AAAAFFFFJJJJ>>>>VVVV>>>>ZZZZVVVVKKKK");
- break;
- case BRD_SYNOLOGY:
- init_uart(uart2base, 9600, LCR_8BITS | LCR_PNONE);
- /* beep, power LED on, status LED off */
- send_sat("247");
- break;
- case BRD_QNAPTS101:
- case BRD_STORCENTER:
- init_uart(uart2base, 9600, LCR_8BITS | LCR_PNONE);
- break;
+ /* more brd adjustments */
+ brdfixup();
+}
+
+struct brdprop *
+brd_lookup(int brd)
+{
+ u_int i;
+
+ for (i = 0; i < sizeof(brdlist)/sizeof(brdlist[0]); i++) {
+ if (brdlist[i].brdtype == brd)
+ return &brdlist[i];
}
+ return &brdlist[i - 1];
+}
+
+static void
+setup()
+{
+ if (brdprop->setup == NULL)
+ return;
+ (*brdprop->setup)(brdprop);
+}
+
+static void
+brdfixup()
+{
+ if (brdprop->brdfix == NULL)
+ return;
+ (*brdprop->brdfix)(brdprop);
+}
+
+void
+pcifixup()
+{
+ if (brdprop->pcifix == NULL)
+ return;
+ (*brdprop->pcifix)(brdprop);
+}
+
+void
+encsetup(struct brdprop *brd)
+{
+#ifdef COSNAME
+ brd->consname = CONSNAME;
+#endif
+#ifdef CONSPORT
+ brd->consport = CONSPORT;
+#endif
+#ifdef CONSSPEED
+ brd->consspeed = CONSSPEED;
+#endif
+}
+
+void
+encbrdfix(struct brdprop *brd)
+{
+ unsigned ac97, ide, pcib, pmgt, usb12, umot4, val;
+
+/*
+ * VIA82C686B Southbridge
+ * 0.22.0 1106.0686 PCI-ISA bridge
+ * 0.22.1 1106.0571 IDE (viaide)
+ * 0.22.2 1106.3038 USB 0/1 (uhci)
+ * 0.22.3 1106.3038 USB 2/3 (uhci)
+ * 0.22.4 1106.3057 power management
+ * 0.22.5 1106.3058 AC97 (auvia)
+ */
+ pcib = pcimaketag(0, 22, 0);
Home |
Main Index |
Thread Index |
Old Index