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