dbau1500.c revision 1.7
11.7Smatt/* $NetBSD: dbau1500.c,v 1.7 2011/07/10 00:03:52 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.7Smatt__KERNEL_RCSID(0, "$NetBSD: dbau1500.c,v 1.7 2011/07/10 00:03:52 matt Exp $");
361.1Sgdamore
371.1Sgdamore#include <sys/param.h>
381.6Sdyoung#include <sys/bus.h>
391.7Smatt
401.7Smatt#include <mips/locore.h>
411.7Smatt
421.1Sgdamore#include <evbmips/alchemy/obiovar.h>
431.1Sgdamore#include <evbmips/alchemy/board.h>
441.1Sgdamore#include <evbmips/alchemy/dbau1500reg.h>
451.1Sgdamore
461.3Sgdamore#define	GET16(x)	\
471.3Sgdamore	(*((volatile uint16_t *)MIPS_PHYS_TO_KSEG1(x)))
481.3Sgdamore#define	PUT16(x, v)	\
491.3Sgdamore	(*((volatile uint16_t *)MIPS_PHYS_TO_KSEG1(x)) = (v))
501.3Sgdamore
511.1Sgdamorestatic void dbau1500_init(void);
521.5Sdyoungstatic int dbau1500_pci_intr_map(const struct pci_attach_args *,
531.1Sgdamore				 pci_intr_handle_t *);
541.3Sgdamorestatic void dbau1500_reboot(void);
551.1Sgdamore
561.1Sgdamorestatic const struct obiodev dbau1500_devices[] = {
571.1Sgdamore#if 0
581.1Sgdamore	{ "aupcmcia", -1, -1 },
591.1Sgdamore	{ "auaudio", -1, -1 },
601.1Sgdamore#endif
611.1Sgdamore	{ NULL },
621.1Sgdamore};
631.1Sgdamore
641.1Sgdamorestatic struct alchemy_board dbau1500_info = {
651.1Sgdamore	"AMD Alchemy DBAu1500",
661.1Sgdamore	dbau1500_devices,
671.1Sgdamore	dbau1500_init,
681.1Sgdamore	dbau1500_pci_intr_map,
691.3Sgdamore	dbau1500_reboot,
701.3Sgdamore	NULL,	/* poweroff */
711.1Sgdamore};
721.1Sgdamore
731.1Sgdamoreconst struct alchemy_board *
741.1Sgdamoreboard_info(void)
751.1Sgdamore{
761.1Sgdamore
771.1Sgdamore	return &dbau1500_info;
781.1Sgdamore}
791.1Sgdamore
801.1Sgdamorevoid
811.1Sgdamoredbau1500_init(void)
821.1Sgdamore{
831.1Sgdamore	uint32_t	whoami;
841.1Sgdamore
851.4Smatt	if (MIPS_PRID_COPTS(mips_options.mips_cpu_id) != MIPS_AU1500)
861.1Sgdamore		panic("dbau1500: CPU not an AU1500!");
871.1Sgdamore
881.1Sgdamore	/* check the whoami register for a match */
891.2Sgdamore	whoami = *((volatile uint32_t *)MIPS_PHYS_TO_KSEG1(DBAU1500_WHOAMI));
901.1Sgdamore
911.1Sgdamore	if (DBAU1500_WHOAMI_BOARD(whoami) != DBAU1500_WHOAMI_DBAU1500)
921.1Sgdamore		panic("dbau1500: WHOAMI (%x) not DBAu1500!", whoami);
931.1Sgdamore
941.1Sgdamore	printf("DBAu1500 (zinfandel), CPLDv%d, ",
951.1Sgdamore	    DBAU1500_WHOAMI_CPLD(whoami));
961.1Sgdamore
971.1Sgdamore	if (DBAU1500_WHOAMI_DAUGHTER(whoami) != 0xf)
981.1Sgdamore		printf("daughtercard 0x%x\n",
991.1Sgdamore		    DBAU1500_WHOAMI_DAUGHTER(whoami));
1001.1Sgdamore	else
1011.1Sgdamore		printf("no daughtercard\n");
1021.1Sgdamore
1031.1Sgdamore	/* leave console and clocks alone -- YAMON should have got it right! */
1041.1Sgdamore}
1051.1Sgdamore
1061.1Sgdamoreint
1071.5Sdyoungdbau1500_pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
1081.1Sgdamore{
1091.1Sgdamore	/*
1101.1Sgdamore	 * This platform has PCI slot and IDE interrupts mapped
1111.1Sgdamore	 * identically.  So we just need to look at which of the four
1121.1Sgdamore	 * PCI interrupts it is.
1131.1Sgdamore	 */
1141.1Sgdamore
1151.1Sgdamore	switch (pa->pa_intrpin) {
1161.1Sgdamore	case 0:
1171.1Sgdamore		/* not used */
1181.1Sgdamore		return 1;
1191.1Sgdamore	case 1:
1201.1Sgdamore		*ihp = 1;
1211.1Sgdamore		break;
1221.1Sgdamore	case 2:
1231.1Sgdamore		*ihp = 2;
1241.1Sgdamore		break;
1251.1Sgdamore	case 3:
1261.1Sgdamore		*ihp = 4;
1271.1Sgdamore		break;
1281.1Sgdamore	case 4:
1291.1Sgdamore		*ihp = 5;
1301.1Sgdamore		break;
1311.1Sgdamore	default:
1321.1Sgdamore		printf("pci: bad interrupt pin %d\n", pa->pa_intrpin);
1331.1Sgdamore		return 1;
1341.1Sgdamore	}
1351.1Sgdamore	return 0;
1361.1Sgdamore}
1371.3Sgdamore
1381.3Sgdamorevoid
1391.3Sgdamoredbau1500_reboot(void)
1401.3Sgdamore{
1411.3Sgdamore	PUT16(DBAU1500_SOFTWARE_RESET, 0);
1421.3Sgdamore	delay(100000);	/* 100 msec */
1431.3Sgdamore}
144