omsal400.c revision 1.1
11.1Sshige/* $NetBSD: omsal400.c,v 1.1 2006/02/23 17:14:01 shige Exp $ */ 21.1Sshige 31.1Sshige/*- 41.1Sshige * Copyright (c) 2006 Shigeyuki Fukushima. 51.1Sshige * All rights reserved. 61.1Sshige * 71.1Sshige * Written by Shigeyuki Fukushima. 81.1Sshige * 91.1Sshige * Redistribution and use in source and binary forms, with or without 101.1Sshige * modification, are permitted provided that the following conditions 111.1Sshige * are met: 121.1Sshige * 1. Redistributions of source code must retain the above copyright 131.1Sshige * notice, this list of conditions and the following disclaimer. 141.1Sshige * 2. Redistributions in binary form must reproduce the above 151.1Sshige * copyright notice, this list of conditions and the following 161.1Sshige * disclaimer in the documentation and/or other materials provided 171.1Sshige * with the distribution. 181.1Sshige * 3. The name of the author may not be used to endorse or promote 191.1Sshige * products derived from this software without specific prior 201.1Sshige * written permission. 211.1Sshige * 221.1Sshige * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 231.1Sshige * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 241.1Sshige * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 251.1Sshige * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 261.1Sshige * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 271.1Sshige * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 281.1Sshige * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 291.1Sshige * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 301.1Sshige * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 311.1Sshige * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 321.1Sshige * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 331.1Sshige */ 341.1Sshige 351.1Sshige 361.1Sshige#include <sys/cdefs.h> 371.1Sshige__KERNEL_RCSID(0, "$NetBSD: omsal400.c,v 1.1 2006/02/23 17:14:01 shige Exp $"); 381.1Sshige 391.1Sshige#include <sys/param.h> 401.1Sshige#include <machine/bus.h> 411.1Sshige#include <machine/locore.h> 421.1Sshige#include <evbmips/alchemy/obiovar.h> 431.1Sshige#include <evbmips/alchemy/board.h> 441.1Sshige#include <evbmips/alchemy/omsal400reg.h> 451.1Sshige 461.1Sshige#define GET16(x) \ 471.1Sshige (*((volatile uint16_t *)MIPS_PHYS_TO_KSEG1(x))) 481.1Sshige#define PUT16(x, v) \ 491.1Sshige (*((volatile uint16_t *)MIPS_PHYS_TO_KSEG1(x)) = (v)) 501.1Sshige 511.1Sshigestatic void omsal400_init(void); 521.1Sshigestatic int omsal400_pci_intr_map(struct pci_attach_args *, 531.1Sshige pci_intr_handle_t *); 541.1Sshigestatic void omsal400_poweroff(void); 551.1Sshigestatic void omsal400_reboot(void); 561.1Sshige 571.1Sshigestatic const struct obiodev omsal400_devices[] = { 581.1Sshige { NULL }, 591.1Sshige}; 601.1Sshige 611.1Sshigestatic struct alchemy_board omsal400_info = { 621.1Sshige "Plathome Open Micro Sever AL400/AMD Alchemy Au1550", 631.1Sshige omsal400_devices, 641.1Sshige omsal400_init, 651.1Sshige omsal400_pci_intr_map, 661.1Sshige omsal400_reboot, 671.1Sshige omsal400_poweroff, 681.1Sshige}; 691.1Sshige 701.1Sshigeconst struct alchemy_board * 711.1Sshigeboard_info(void) 721.1Sshige{ 731.1Sshige 741.1Sshige return &omsal400_info; 751.1Sshige} 761.1Sshige 771.1Sshigevoid 781.1Sshigeomsal400_init(void) 791.1Sshige{ 801.1Sshige /* uint16_t whoami; */ 811.1Sshige 821.1Sshige if (MIPS_PRID_COPTS(cpu_id) != MIPS_AU1550) 831.1Sshige panic("omsal400: CPU not Au1550"); 841.1Sshige 851.1Sshige#if 0 /* XXX: TODO borad identification */ 861.1Sshige /* check the whoami register for a match */ 871.1Sshige whoami = GET16(DBAU1550_WHOAMI); 881.1Sshige 891.1Sshige if (DBAU1550_WHOAMI_BOARD(whoami) != DBAU1550_WHOAMI_DBAU1550_REV1) 901.1Sshige panic("dbau1550: WHOAMI (%x) not DBAu1550!", whoami); 911.1Sshige 921.1Sshige printf("DBAu1550 (cabernet), CPLDv%d, ", 931.1Sshige DBAU1550_WHOAMI_CPLD(whoami)); 941.1Sshige 951.1Sshige if (DBAU1550_WHOAMI_DAUGHTER(whoami) != 0xf) 961.1Sshige printf("daughtercard 0x%x\n", 971.1Sshige DBAU1550_WHOAMI_DAUGHTER(whoami)); 981.1Sshige else 991.1Sshige printf("no daughtercard\n"); 1001.1Sshige#endif 1011.1Sshige 1021.1Sshige /* leave console and clocks alone -- YAMON should have got it right! */ 1031.1Sshige} 1041.1Sshige 1051.1Sshigeint 1061.1Sshigeomsal400_pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp) 1071.1Sshige{ 1081.1Sshige /* 1091.1Sshige * This platform has 4 PCI devices: 1101.1Sshige * dev 1 (PCI_INTD): PCI Connector 1111.1Sshige * dev 2 (PCI_INTC): NEC USB 2.0 uPD720101 1121.1Sshige * dev 3 (PCI_INTB): Intel GB Ether 82541PI 1131.1Sshige * dev 4 (PCI_INTA): Intel GB Ether 82541PI 1141.1Sshige */ 1151.1Sshige static const int irqmap[5/*device*/][4/*pin*/] = { 1161.1Sshige { 6, -1, -1, -1 }, /* 1: PCI Connecter (not used) */ 1171.1Sshige { 5, 5, 5, -1 }, /* 2: NEC USB 2.0 */ 1181.1Sshige { 2, -1, -1, -1 }, /* 3: Intel GbE */ 1191.1Sshige { 1, -1, -1, -1 }, /* 4: Intel GbE */ 1201.1Sshige }; 1211.1Sshige 1221.1Sshige int pin, dev, irq; 1231.1Sshige 1241.1Sshige /* if interrupt pin not used... */ 1251.1Sshige if ((pin = pa->pa_intrpin) == 0) 1261.1Sshige return 1; 1271.1Sshige 1281.1Sshige if (pin > 4) { 1291.1Sshige printf("pci: bad interrupt pin %d\n", pin); 1301.1Sshige return 1; 1311.1Sshige } 1321.1Sshige 1331.1Sshige pci_decompose_tag(pa->pa_pc, pa->pa_intrtag, NULL, &dev, NULL); 1341.1Sshige 1351.1Sshige if ((dev < 1) || (dev > 4)) { 1361.1Sshige printf("pci: bad device %d\n", dev); 1371.1Sshige return 1; 1381.1Sshige } 1391.1Sshige 1401.1Sshige if ((irq = irqmap[dev - 1][pin - 1]) == -1) { 1411.1Sshige printf("pci: no IRQ routing for device %d pin %d\n", dev, pin); 1421.1Sshige return 1; 1431.1Sshige } 1441.1Sshige 1451.1Sshige *ihp = irq; 1461.1Sshige return 0; 1471.1Sshige} 1481.1Sshige 1491.1Sshigevoid 1501.1Sshigeomsal400_reboot(void) 1511.1Sshige{ 1521.1Sshige 1531.1Sshige /* XXX */ 1541.1Sshige} 1551.1Sshige 1561.1Sshigevoid 1571.1Sshigeomsal400_poweroff(void) 1581.1Sshige{ 1591.1Sshige 1601.1Sshige printf("\n- poweroff -\n"); 1611.1Sshige /* XXX */ 1621.1Sshige} 163