omsal400.c revision 1.9
11.9Smatt/* $NetBSD: omsal400.c,v 1.9 2011/07/10 00:03:52 matt 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.9Smatt__KERNEL_RCSID(0, "$NetBSD: omsal400.c,v 1.9 2011/07/10 00:03:52 matt Exp $"); 401.1Sshige 411.1Sshige#include <sys/param.h> 421.8Sdyoung#include <sys/bus.h> 431.9Smatt 441.9Smatt#include <mips/locore.h> 451.9Smatt 461.4Skiyohara#include <mips/alchemy/dev/augpiovar.h> 471.4Skiyohara#include <mips/alchemy/dev/aupcmciavar.h> 481.9Smatt 491.1Sshige#include <evbmips/alchemy/obiovar.h> 501.1Sshige#include <evbmips/alchemy/board.h> 511.1Sshige#include <evbmips/alchemy/omsal400reg.h> 521.1Sshige 531.1Sshige#define GET16(x) \ 541.1Sshige (*((volatile uint16_t *)MIPS_PHYS_TO_KSEG1(x))) 551.1Sshige#define PUT16(x, v) \ 561.1Sshige (*((volatile uint16_t *)MIPS_PHYS_TO_KSEG1(x)) = (v)) 571.1Sshige 581.1Sshigestatic void omsal400_init(void); 591.7Sdyoungstatic int omsal400_pci_intr_map(const struct pci_attach_args *, 601.1Sshige pci_intr_handle_t *); 611.1Sshigestatic void omsal400_poweroff(void); 621.1Sshigestatic void omsal400_reboot(void); 631.4Skiyoharastatic bus_addr_t omsal400_slot_offset(int); 641.4Skiyoharastatic int omsal400_slot_irq(int, int); 651.4Skiyoharastatic void omsal400_slot_enable(int); 661.4Skiyoharastatic void omsal400_slot_disable(int); 671.4Skiyoharastatic int omsal400_slot_status(int); 681.4Skiyoharastatic const char *omsal400_slot_name(int); 691.1Sshige 701.1Sshigestatic const struct obiodev omsal400_devices[] = { 711.1Sshige { NULL }, 721.1Sshige}; 731.1Sshige 741.4Skiyoharastatic struct aupcmcia_machdep omsal400_pcmcia = { 751.4Skiyohara 1, /* nslots */ 761.4Skiyohara omsal400_slot_offset, 771.4Skiyohara omsal400_slot_irq, 781.4Skiyohara omsal400_slot_enable, 791.4Skiyohara omsal400_slot_disable, 801.4Skiyohara omsal400_slot_status, 811.4Skiyohara omsal400_slot_name, 821.4Skiyohara}; 831.4Skiyohara 841.1Sshigestatic struct alchemy_board omsal400_info = { 851.5Skiyohara "Plathome Open Micro Server AL400/AMD Alchemy Au1550", 861.1Sshige omsal400_devices, 871.1Sshige omsal400_init, 881.1Sshige omsal400_pci_intr_map, 891.1Sshige omsal400_reboot, 901.1Sshige omsal400_poweroff, 911.4Skiyohara &omsal400_pcmcia, 921.1Sshige}; 931.1Sshige 941.1Sshigeconst struct alchemy_board * 951.1Sshigeboard_info(void) 961.1Sshige{ 971.1Sshige 981.1Sshige return &omsal400_info; 991.1Sshige} 1001.1Sshige 1011.1Sshigevoid 1021.1Sshigeomsal400_init(void) 1031.1Sshige{ 1041.1Sshige /* uint16_t whoami; */ 1051.1Sshige 1061.6Smatt if (MIPS_PRID_COPTS(mips_options.mips_cpu_id) != MIPS_AU1550) 1071.1Sshige panic("omsal400: CPU not Au1550"); 1081.1Sshige 1091.1Sshige#if 0 /* XXX: TODO borad identification */ 1101.1Sshige /* check the whoami register for a match */ 1111.1Sshige whoami = GET16(DBAU1550_WHOAMI); 1121.1Sshige 1131.1Sshige if (DBAU1550_WHOAMI_BOARD(whoami) != DBAU1550_WHOAMI_DBAU1550_REV1) 1141.1Sshige panic("dbau1550: WHOAMI (%x) not DBAu1550!", whoami); 1151.1Sshige 1161.1Sshige printf("DBAu1550 (cabernet), CPLDv%d, ", 1171.1Sshige DBAU1550_WHOAMI_CPLD(whoami)); 1181.1Sshige 1191.1Sshige if (DBAU1550_WHOAMI_DAUGHTER(whoami) != 0xf) 1201.1Sshige printf("daughtercard 0x%x\n", 1211.1Sshige DBAU1550_WHOAMI_DAUGHTER(whoami)); 1221.1Sshige else 1231.1Sshige printf("no daughtercard\n"); 1241.1Sshige#endif 1251.1Sshige 1261.1Sshige /* leave console and clocks alone -- YAMON should have got it right! */ 1271.1Sshige} 1281.1Sshige 1291.1Sshigeint 1301.7Sdyoungomsal400_pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp) 1311.1Sshige{ 1321.1Sshige /* 1331.1Sshige * This platform has 4 PCI devices: 1341.1Sshige * dev 1 (PCI_INTD): PCI Connector 1351.1Sshige * dev 2 (PCI_INTC): NEC USB 2.0 uPD720101 1361.1Sshige * dev 3 (PCI_INTB): Intel GB Ether 82541PI 1371.1Sshige * dev 4 (PCI_INTA): Intel GB Ether 82541PI 1381.1Sshige */ 1391.3Sshige static const int irqmap[4/*device*/][4/*pin*/] = { 1401.1Sshige { 6, -1, -1, -1 }, /* 1: PCI Connecter (not used) */ 1411.1Sshige { 5, 5, 5, -1 }, /* 2: NEC USB 2.0 */ 1421.1Sshige { 2, -1, -1, -1 }, /* 3: Intel GbE */ 1431.1Sshige { 1, -1, -1, -1 }, /* 4: Intel GbE */ 1441.1Sshige }; 1451.1Sshige 1461.1Sshige int pin, dev, irq; 1471.1Sshige 1481.1Sshige /* if interrupt pin not used... */ 1491.1Sshige if ((pin = pa->pa_intrpin) == 0) 1501.1Sshige return 1; 1511.1Sshige 1521.1Sshige if (pin > 4) { 1531.1Sshige printf("pci: bad interrupt pin %d\n", pin); 1541.1Sshige return 1; 1551.1Sshige } 1561.1Sshige 1571.1Sshige pci_decompose_tag(pa->pa_pc, pa->pa_intrtag, NULL, &dev, NULL); 1581.1Sshige 1591.1Sshige if ((dev < 1) || (dev > 4)) { 1601.1Sshige printf("pci: bad device %d\n", dev); 1611.1Sshige return 1; 1621.1Sshige } 1631.1Sshige 1641.1Sshige if ((irq = irqmap[dev - 1][pin - 1]) == -1) { 1651.1Sshige printf("pci: no IRQ routing for device %d pin %d\n", dev, pin); 1661.1Sshige return 1; 1671.1Sshige } 1681.1Sshige 1691.1Sshige *ihp = irq; 1701.1Sshige return 0; 1711.1Sshige} 1721.1Sshige 1731.1Sshigevoid 1741.1Sshigeomsal400_reboot(void) 1751.1Sshige{ 1761.1Sshige 1771.1Sshige /* XXX */ 1781.1Sshige} 1791.1Sshige 1801.1Sshigevoid 1811.1Sshigeomsal400_poweroff(void) 1821.1Sshige{ 1831.1Sshige 1841.1Sshige printf("\n- poweroff -\n"); 1851.1Sshige /* XXX */ 1861.1Sshige} 1871.4Skiyohara 1881.4Skiyohara 1891.4Skiyoharaint 1901.4Skiyoharaomsal400_slot_irq(int slot, int which) 1911.4Skiyohara{ 1921.4Skiyohara static const int irqmap[1/*slot*/][2/*which*/] = { 1931.4Skiyohara { 35, 37 }, /* Slot 0: CF connector Type2 */ 1941.4Skiyohara }; 1951.4Skiyohara 1961.4Skiyohara if ((slot >= 1) || (which >= 2)) 1971.4Skiyohara return -1; 1981.4Skiyohara 1991.4Skiyohara return irqmap[slot][which]; 2001.4Skiyohara} 2011.4Skiyohara 2021.4Skiyoharabus_addr_t 2031.4Skiyoharaomsal400_slot_offset(int slot) 2041.4Skiyohara{ 2051.4Skiyohara 2061.4Skiyohara switch (slot) { 2071.4Skiyohara case 0: 2081.4Skiyohara return (0); /* offset 0 */ 2091.4Skiyohara } 2101.4Skiyohara return (bus_addr_t)-1; 2111.4Skiyohara} 2121.4Skiyohara 2131.4Skiyoharavoid 2141.4Skiyoharaomsal400_slot_enable(int slot) 2151.4Skiyohara{ 2161.4Skiyohara 2171.4Skiyohara /* nothing todo */ 2181.4Skiyohara} 2191.4Skiyohara 2201.4Skiyoharavoid 2211.4Skiyoharaomsal400_slot_disable(int slot) 2221.4Skiyohara{ 2231.4Skiyohara 2241.4Skiyohara /* nothing todo */ 2251.4Skiyohara} 2261.4Skiyohara 2271.4Skiyoharaint 2281.4Skiyoharaomsal400_slot_status(int slot) 2291.4Skiyohara{ 2301.4Skiyohara uint16_t inserted = 0; 2311.4Skiyohara 2321.4Skiyohara switch (slot) { 2331.4Skiyohara case 0: 2341.4Skiyohara inserted = !AUGPIO_READ(5); /* pin 5 */ 2351.4Skiyohara break; 2361.4Skiyohara } 2371.4Skiyohara 2381.4Skiyohara return inserted; 2391.4Skiyohara} 2401.4Skiyohara 2411.4Skiyoharaconst char * 2421.4Skiyoharaomsal400_slot_name(int slot) 2431.4Skiyohara{ 2441.4Skiyohara switch (slot) { 2451.4Skiyohara case 0: 2461.4Skiyohara return "CF connector Type2 on Static BUS#3"; 2471.4Skiyohara default: 2481.4Skiyohara return "???"; 2491.4Skiyohara } 2501.4Skiyohara} 251