dbau1500.c revision 1.8
11.8Smatt/* $NetBSD: dbau1500.c,v 1.8 2015/06/09 22:49:55 matt Exp $ */ 21.1Sgdamore 31.1Sgdamore/*- 41.1Sgdamore * Copyright (c) 2006 Itronix Inc. 51.1Sgdamore * All rights reserved. 61.1Sgdamore * 71.1Sgdamore * Written by Garrett D'Amore for Itronix Inc. 81.1Sgdamore * 91.1Sgdamore * Redistribution and use in source and binary forms, with or without 101.1Sgdamore * modification, are permitted provided that the following conditions 111.1Sgdamore * are met: 121.1Sgdamore * 1. Redistributions of source code must retain the above copyright 131.1Sgdamore * notice, this list of conditions and the following disclaimer. 141.1Sgdamore * 2. Redistributions in binary form must reproduce the above copyright 151.1Sgdamore * notice, this list of conditions and the following disclaimer in the 161.1Sgdamore * documentation and/or other materials provided with the distribution. 171.1Sgdamore * 3. The name of Itronix Inc. may not be used to endorse 181.1Sgdamore * or promote products derived from this software without specific 191.1Sgdamore * prior written permission. 201.1Sgdamore * 211.1Sgdamore * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND 221.1Sgdamore * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 231.1Sgdamore * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 241.1Sgdamore * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY 251.1Sgdamore * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 261.1Sgdamore * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 271.1Sgdamore * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 281.1Sgdamore * ON ANY THEORY OF LIABILITY, WHETHER IN 291.1Sgdamore * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 301.1Sgdamore * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 311.1Sgdamore * POSSIBILITY OF SUCH DAMAGE. 321.1Sgdamore */ 331.1Sgdamore 341.1Sgdamore#include <sys/cdefs.h> 351.8Smatt__KERNEL_RCSID(0, "$NetBSD: dbau1500.c,v 1.8 2015/06/09 22:49:55 matt Exp $"); 361.1Sgdamore 371.1Sgdamore#include <sys/param.h> 381.6Sdyoung#include <sys/bus.h> 391.8Smatt#include <sys/cpu.h> 401.7Smatt 411.7Smatt#include <mips/locore.h> 421.7Smatt 431.1Sgdamore#include <evbmips/alchemy/obiovar.h> 441.1Sgdamore#include <evbmips/alchemy/board.h> 451.1Sgdamore#include <evbmips/alchemy/dbau1500reg.h> 461.1Sgdamore 471.3Sgdamore#define GET16(x) \ 481.3Sgdamore (*((volatile uint16_t *)MIPS_PHYS_TO_KSEG1(x))) 491.3Sgdamore#define PUT16(x, v) \ 501.3Sgdamore (*((volatile uint16_t *)MIPS_PHYS_TO_KSEG1(x)) = (v)) 511.3Sgdamore 521.1Sgdamorestatic void dbau1500_init(void); 531.5Sdyoungstatic int dbau1500_pci_intr_map(const struct pci_attach_args *, 541.1Sgdamore pci_intr_handle_t *); 551.3Sgdamorestatic void dbau1500_reboot(void); 561.1Sgdamore 571.1Sgdamorestatic const struct obiodev dbau1500_devices[] = { 581.1Sgdamore#if 0 591.1Sgdamore { "aupcmcia", -1, -1 }, 601.1Sgdamore { "auaudio", -1, -1 }, 611.1Sgdamore#endif 621.1Sgdamore { NULL }, 631.1Sgdamore}; 641.1Sgdamore 651.1Sgdamorestatic struct alchemy_board dbau1500_info = { 661.1Sgdamore "AMD Alchemy DBAu1500", 671.1Sgdamore dbau1500_devices, 681.1Sgdamore dbau1500_init, 691.1Sgdamore dbau1500_pci_intr_map, 701.3Sgdamore dbau1500_reboot, 711.3Sgdamore NULL, /* poweroff */ 721.1Sgdamore}; 731.1Sgdamore 741.1Sgdamoreconst struct alchemy_board * 751.1Sgdamoreboard_info(void) 761.1Sgdamore{ 771.1Sgdamore 781.1Sgdamore return &dbau1500_info; 791.1Sgdamore} 801.1Sgdamore 811.1Sgdamorevoid 821.1Sgdamoredbau1500_init(void) 831.1Sgdamore{ 841.1Sgdamore uint32_t whoami; 851.1Sgdamore 861.4Smatt if (MIPS_PRID_COPTS(mips_options.mips_cpu_id) != MIPS_AU1500) 871.1Sgdamore panic("dbau1500: CPU not an AU1500!"); 881.1Sgdamore 891.1Sgdamore /* check the whoami register for a match */ 901.2Sgdamore whoami = *((volatile uint32_t *)MIPS_PHYS_TO_KSEG1(DBAU1500_WHOAMI)); 911.1Sgdamore 921.1Sgdamore if (DBAU1500_WHOAMI_BOARD(whoami) != DBAU1500_WHOAMI_DBAU1500) 931.1Sgdamore panic("dbau1500: WHOAMI (%x) not DBAu1500!", whoami); 941.1Sgdamore 951.1Sgdamore printf("DBAu1500 (zinfandel), CPLDv%d, ", 961.1Sgdamore DBAU1500_WHOAMI_CPLD(whoami)); 971.1Sgdamore 981.1Sgdamore if (DBAU1500_WHOAMI_DAUGHTER(whoami) != 0xf) 991.1Sgdamore printf("daughtercard 0x%x\n", 1001.1Sgdamore DBAU1500_WHOAMI_DAUGHTER(whoami)); 1011.1Sgdamore else 1021.1Sgdamore printf("no daughtercard\n"); 1031.1Sgdamore 1041.1Sgdamore /* leave console and clocks alone -- YAMON should have got it right! */ 1051.1Sgdamore} 1061.1Sgdamore 1071.1Sgdamoreint 1081.5Sdyoungdbau1500_pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp) 1091.1Sgdamore{ 1101.1Sgdamore /* 1111.1Sgdamore * This platform has PCI slot and IDE interrupts mapped 1121.1Sgdamore * identically. So we just need to look at which of the four 1131.1Sgdamore * PCI interrupts it is. 1141.1Sgdamore */ 1151.1Sgdamore 1161.1Sgdamore switch (pa->pa_intrpin) { 1171.1Sgdamore case 0: 1181.1Sgdamore /* not used */ 1191.1Sgdamore return 1; 1201.1Sgdamore case 1: 1211.1Sgdamore *ihp = 1; 1221.1Sgdamore break; 1231.1Sgdamore case 2: 1241.1Sgdamore *ihp = 2; 1251.1Sgdamore break; 1261.1Sgdamore case 3: 1271.1Sgdamore *ihp = 4; 1281.1Sgdamore break; 1291.1Sgdamore case 4: 1301.1Sgdamore *ihp = 5; 1311.1Sgdamore break; 1321.1Sgdamore default: 1331.1Sgdamore printf("pci: bad interrupt pin %d\n", pa->pa_intrpin); 1341.1Sgdamore return 1; 1351.1Sgdamore } 1361.1Sgdamore return 0; 1371.1Sgdamore} 1381.3Sgdamore 1391.3Sgdamorevoid 1401.3Sgdamoredbau1500_reboot(void) 1411.3Sgdamore{ 1421.3Sgdamore PUT16(DBAU1500_SOFTWARE_RESET, 0); 1431.3Sgdamore delay(100000); /* 100 msec */ 1441.3Sgdamore} 145