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