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