| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: brdsetup.c,v 1.21 2010/06/26 21:45:49 phx Exp $ */ | | 1 | /* $NetBSD: brdsetup.c,v 1.22 2011/01/10 18:35:49 phx Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Tohru Nishimura. | | 8 | * by Tohru Nishimura. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -190,26 +190,30 @@ brdsetup(void) | | | @@ -190,26 +190,30 @@ brdsetup(void) |
190 | else if ((pcicfgread(pcimaketag(0, 11, 0), PCI_CLASS_REG) >> 16) == | | 190 | else if ((pcicfgread(pcimaketag(0, 11, 0), PCI_CLASS_REG) >> 16) == |
191 | PCI_CLASS_ETH) { | | 191 | PCI_CLASS_ETH) { |
192 | /* tlp (ADMtek AN985) or re (RealTek 8169S) at dev 11 */ | | 192 | /* tlp (ADMtek AN985) or re (RealTek 8169S) at dev 11 */ |
193 | brdtype = BRD_KUROBOX; | | 193 | brdtype = BRD_KUROBOX; |
194 | } | | 194 | } |
195 | else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) == | | 195 | else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) == |
196 | 0x11ab) { /* PCI_VENDOR_MARVELL */ | | 196 | 0x11ab) { /* PCI_VENDOR_MARVELL */ |
197 | brdtype = BRD_SYNOLOGY; | | 197 | brdtype = BRD_SYNOLOGY; |
198 | } | | 198 | } |
199 | else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) == | | 199 | else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) == |
200 | 0x8086) { /* PCI_VENDOR_INTEL */ | | 200 | 0x8086) { /* PCI_VENDOR_INTEL */ |
201 | brdtype = BRD_QNAPTS101; | | 201 | brdtype = BRD_QNAPTS101; |
202 | } | | 202 | } |
| | | 203 | else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 13, 0), PCI_ID_REG)) == |
| | | 204 | 0x1106) { /* PCI_VENDOR_VIA */ |
| | | 205 | brdtype = BRD_STORCENTER; |
| | | 206 | } |
203 | | | 207 | |
204 | brdprop = brd_lookup(brdtype); | | 208 | brdprop = brd_lookup(brdtype); |
205 | | | 209 | |
206 | /* brd dependent adjustments */ | | 210 | /* brd dependent adjustments */ |
207 | setup(); | | 211 | setup(); |
208 | | | 212 | |
209 | /* determine clock frequencies */ | | 213 | /* determine clock frequencies */ |
210 | if (brdprop->extclk != 0) | | 214 | if (brdprop->extclk != 0) |
211 | extclk = brdprop->extclk; | | 215 | extclk = brdprop->extclk; |
212 | if (busclock == 0) { | | 216 | if (busclock == 0) { |
213 | if (cputype() == MPC8245) { | | 217 | if (cputype() == MPC8245) { |
214 | /* PLL_CFG from PCI host bridge register 0xe2 */ | | 218 | /* PLL_CFG from PCI host bridge register 0xe2 */ |
215 | val = pcicfgread(pchb, 0xe0); | | 219 | val = pcicfgread(pchb, 0xe0); |
| @@ -251,50 +255,54 @@ brd_lookup(int brd) | | | @@ -251,50 +255,54 @@ brd_lookup(int brd) |
251 | { | | 255 | { |
252 | u_int i; | | 256 | u_int i; |
253 | | | 257 | |
254 | for (i = 0; i < sizeof(brdlist)/sizeof(brdlist[0]); i++) { | | 258 | for (i = 0; i < sizeof(brdlist)/sizeof(brdlist[0]); i++) { |
255 | if (brdlist[i].brdtype == brd) | | 259 | if (brdlist[i].brdtype == brd) |
256 | return &brdlist[i]; | | 260 | return &brdlist[i]; |
257 | } | | 261 | } |
258 | return &brdlist[i - 1]; | | 262 | return &brdlist[i - 1]; |
259 | } | | 263 | } |
260 | | | 264 | |
261 | static void | | 265 | static void |
262 | setup() | | 266 | setup() |
263 | { | | 267 | { |
| | | 268 | |
264 | if (brdprop->setup == NULL) | | 269 | if (brdprop->setup == NULL) |
265 | return; | | 270 | return; |
266 | (*brdprop->setup)(brdprop); | | 271 | (*brdprop->setup)(brdprop); |
267 | } | | 272 | } |
268 | | | 273 | |
269 | static void | | 274 | static void |
270 | brdfixup() | | 275 | brdfixup() |
271 | { | | 276 | { |
| | | 277 | |
272 | if (brdprop->brdfix == NULL) | | 278 | if (brdprop->brdfix == NULL) |
273 | return; | | 279 | return; |
274 | (*brdprop->brdfix)(brdprop); | | 280 | (*brdprop->brdfix)(brdprop); |
275 | } | | 281 | } |
276 | | | 282 | |
277 | void | | 283 | void |
278 | pcifixup() | | 284 | pcifixup() |
279 | { | | 285 | { |
| | | 286 | |
280 | if (brdprop->pcifix == NULL) | | 287 | if (brdprop->pcifix == NULL) |
281 | return; | | 288 | return; |
282 | (*brdprop->pcifix)(brdprop); | | 289 | (*brdprop->pcifix)(brdprop); |
283 | } | | 290 | } |
284 | | | 291 | |
285 | void | | 292 | void |
286 | encsetup(struct brdprop *brd) | | 293 | encsetup(struct brdprop *brd) |
287 | { | | 294 | { |
| | | 295 | |
288 | #ifdef COSNAME | | 296 | #ifdef COSNAME |
289 | brd->consname = CONSNAME; | | 297 | brd->consname = CONSNAME; |
290 | #endif | | 298 | #endif |
291 | #ifdef CONSPORT | | 299 | #ifdef CONSPORT |
292 | brd->consport = CONSPORT; | | 300 | brd->consport = CONSPORT; |
293 | #endif | | 301 | #endif |
294 | #ifdef CONSSPEED | | 302 | #ifdef CONSSPEED |
295 | brd->consspeed = CONSSPEED; | | 303 | brd->consspeed = CONSSPEED; |
296 | #endif | | 304 | #endif |
297 | } | | 305 | } |
298 | | | 306 | |
299 | void | | 307 | void |
300 | encbrdfix(struct brdprop *brd) | | 308 | encbrdfix(struct brdprop *brd) |
| @@ -348,40 +356,42 @@ encbrdfix(struct brdprop *brd) | | | @@ -348,40 +356,42 @@ encbrdfix(struct brdprop *brd) |
348 | val |= 11; | | 356 | val |= 11; |
349 | pcicfgwrite(usb12, 0x3c, val); | | 357 | pcicfgwrite(usb12, 0x3c, val); |
350 | val = pcicfgread(umot4, 0x3c) &~ 0xff; | | 358 | val = pcicfgread(umot4, 0x3c) &~ 0xff; |
351 | val |= 11; | | 359 | val |= 11; |
352 | pcicfgwrite(umot4, 0x3c, val); | | 360 | pcicfgwrite(umot4, 0x3c, val); |
353 | val = pcicfgread(ac97, 0x3c) &~ 0xff; | | 361 | val = pcicfgread(ac97, 0x3c) &~ 0xff; |
354 | val |= 5; | | 362 | val |= 5; |
355 | pcicfgwrite(ac97, 0x3c, val); | | 363 | pcicfgwrite(ac97, 0x3c, val); |
356 | } | | 364 | } |
357 | | | 365 | |
358 | void | | 366 | void |
359 | motsetup(struct brdprop *brd) | | 367 | motsetup(struct brdprop *brd) |
360 | { | | 368 | { |
| | | 369 | |
361 | #ifdef COSNAME | | 370 | #ifdef COSNAME |
362 | brd->consname = CONSNAME; | | 371 | brd->consname = CONSNAME; |
363 | #endif | | 372 | #endif |
364 | #ifdef CONSPORT | | 373 | #ifdef CONSPORT |
365 | brd->consport = CONSPORT; | | 374 | brd->consport = CONSPORT; |
366 | #endif | | 375 | #endif |
367 | #ifdef CONSSPEED | | 376 | #ifdef CONSSPEED |
368 | brd->consspeed = CONSSPEED; | | 377 | brd->consspeed = CONSSPEED; |
369 | #endif | | 378 | #endif |
370 | } | | 379 | } |
371 | | | 380 | |
372 | void | | 381 | void |
373 | motbrdfix(struct brdprop *brd) | | 382 | motbrdfix(struct brdprop *brd) |
374 | { | | 383 | { |
| | | 384 | |
375 | /* | | 385 | /* |
376 | * WinBond/Symphony Lab 83C553 with PC87308 "SuperIO" | | 386 | * WinBond/Symphony Lab 83C553 with PC87308 "SuperIO" |
377 | * | | 387 | * |
378 | * 0.11.0 10ad.0565 PCI-ISA bridge | | 388 | * 0.11.0 10ad.0565 PCI-ISA bridge |
379 | * 0.11.1 10ad.0105 IDE (slide) | | 389 | * 0.11.1 10ad.0105 IDE (slide) |
380 | */ | | 390 | */ |
381 | } | | 391 | } |
382 | | | 392 | |
383 | void | | 393 | void |
384 | motpcifix(struct brdprop *brd) | | 394 | motpcifix(struct brdprop *brd) |
385 | { | | 395 | { |
386 | unsigned ide, nic, pcib, steer, val; | | 396 | unsigned ide, nic, pcib, steer, val; |
387 | int line; | | 397 | int line; |
| @@ -628,26 +638,27 @@ kuropcifix(struct brdprop *brd) | | | @@ -628,26 +638,27 @@ kuropcifix(struct brdprop *brd) |
628 | val = pcicfgread(usb, 0x3c) & 0xffffff00; | | 638 | val = pcicfgread(usb, 0x3c) & 0xffffff00; |
629 | val |= 14; | | 639 | val |= 14; |
630 | pcicfgwrite(usb, 0x3c, val); | | 640 | pcicfgwrite(usb, 0x3c, val); |
631 | | | 641 | |
632 | usb = pcimaketag(0, 14, 2); | | 642 | usb = pcimaketag(0, 14, 2); |
633 | val = pcicfgread(usb, 0x3c) & 0xffffff00; | | 643 | val = pcicfgread(usb, 0x3c) & 0xffffff00; |
634 | val |= 14; | | 644 | val |= 14; |
635 | pcicfgwrite(usb, 0x3c, val); | | 645 | pcicfgwrite(usb, 0x3c, val); |
636 | } | | 646 | } |
637 | | | 647 | |
638 | void | | 648 | void |
639 | synosetup(struct brdprop *brd) | | 649 | synosetup(struct brdprop *brd) |
640 | { | | 650 | { |
| | | 651 | |
641 | /* nothing */ | | 652 | /* nothing */ |
642 | } | | 653 | } |
643 | | | 654 | |
644 | void | | 655 | void |
645 | synobrdfix(struct brdprop *brd) | | 656 | synobrdfix(struct brdprop *brd) |
646 | { | | 657 | { |
647 | | | 658 | |
648 | init_uart(uart2base, 9600, LCR_8BITS | LCR_PNONE); | | 659 | init_uart(uart2base, 9600, LCR_8BITS | LCR_PNONE); |
649 | /* beep, power LED on, status LED off */ | | 660 | /* beep, power LED on, status LED off */ |
650 | send_sat("247"); | | 661 | send_sat("247"); |
651 | } | | 662 | } |
652 | | | 663 | |
653 | void | | 664 | void |
| @@ -713,26 +724,27 @@ qnappcifix(struct brdprop *brd) | | | @@ -713,26 +724,27 @@ qnappcifix(struct brdprop *brd) |
713 | } | | 724 | } |
714 | | | 725 | |
715 | void | | 726 | void |
716 | synoreset() | | 727 | synoreset() |
717 | { | | 728 | { |
718 | | | 729 | |
719 | send_sat("C"); | | 730 | send_sat("C"); |
720 | /*NOTRECHED*/ | | 731 | /*NOTRECHED*/ |
721 | } | | 732 | } |
722 | | | 733 | |
723 | void | | 734 | void |
724 | _rtt(void) | | 735 | _rtt(void) |
725 | { | | 736 | { |
| | | 737 | |
726 | if (brdprop->reset != NULL) | | 738 | if (brdprop->reset != NULL) |
727 | (*brdprop->reset)(); | | 739 | (*brdprop->reset)(); |
728 | else | | 740 | else |
729 | run(0, 0, 0, 0, (void *)0xFFF00100); /* reset entry */ | | 741 | run(0, 0, 0, 0, (void *)0xFFF00100); /* reset entry */ |
730 | /*NOTREACHED*/ | | 742 | /*NOTREACHED*/ |
731 | } | | 743 | } |
732 | | | 744 | |
733 | satime_t | | 745 | satime_t |
734 | getsecs(void) | | 746 | getsecs(void) |
735 | { | | 747 | { |
736 | u_quad_t tb = mftb(); | | 748 | u_quad_t tb = mftb(); |
737 | | | 749 | |
738 | return (tb / ticks_per_sec); | | 750 | return (tb / ticks_per_sec); |