xref: /netbsd-src/sys/arch/evbmips/alchemy/dbau1500.c (revision b757af438b42b93f8c6571f026d8b8ef3eaf5fc9)
1 /* $NetBSD: dbau1500.c,v 1.7 2011/07/10 00:03:52 matt Exp $ */
2 
3 /*-
4  * Copyright (c) 2006 Itronix Inc.
5  * All rights reserved.
6  *
7  * Written by Garrett D'Amore for Itronix Inc.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. The name of Itronix Inc. may not be used to endorse
18  *    or promote products derived from this software without specific
19  *    prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
25  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28  * ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #include <sys/cdefs.h>
35 __KERNEL_RCSID(0, "$NetBSD: dbau1500.c,v 1.7 2011/07/10 00:03:52 matt Exp $");
36 
37 #include <sys/param.h>
38 #include <sys/bus.h>
39 
40 #include <mips/locore.h>
41 
42 #include <evbmips/alchemy/obiovar.h>
43 #include <evbmips/alchemy/board.h>
44 #include <evbmips/alchemy/dbau1500reg.h>
45 
46 #define	GET16(x)	\
47 	(*((volatile uint16_t *)MIPS_PHYS_TO_KSEG1(x)))
48 #define	PUT16(x, v)	\
49 	(*((volatile uint16_t *)MIPS_PHYS_TO_KSEG1(x)) = (v))
50 
51 static void dbau1500_init(void);
52 static int dbau1500_pci_intr_map(const struct pci_attach_args *,
53 				 pci_intr_handle_t *);
54 static void dbau1500_reboot(void);
55 
56 static const struct obiodev dbau1500_devices[] = {
57 #if 0
58 	{ "aupcmcia", -1, -1 },
59 	{ "auaudio", -1, -1 },
60 #endif
61 	{ NULL },
62 };
63 
64 static struct alchemy_board dbau1500_info = {
65 	"AMD Alchemy DBAu1500",
66 	dbau1500_devices,
67 	dbau1500_init,
68 	dbau1500_pci_intr_map,
69 	dbau1500_reboot,
70 	NULL,	/* poweroff */
71 };
72 
73 const struct alchemy_board *
74 board_info(void)
75 {
76 
77 	return &dbau1500_info;
78 }
79 
80 void
81 dbau1500_init(void)
82 {
83 	uint32_t	whoami;
84 
85 	if (MIPS_PRID_COPTS(mips_options.mips_cpu_id) != MIPS_AU1500)
86 		panic("dbau1500: CPU not an AU1500!");
87 
88 	/* check the whoami register for a match */
89 	whoami = *((volatile uint32_t *)MIPS_PHYS_TO_KSEG1(DBAU1500_WHOAMI));
90 
91 	if (DBAU1500_WHOAMI_BOARD(whoami) != DBAU1500_WHOAMI_DBAU1500)
92 		panic("dbau1500: WHOAMI (%x) not DBAu1500!", whoami);
93 
94 	printf("DBAu1500 (zinfandel), CPLDv%d, ",
95 	    DBAU1500_WHOAMI_CPLD(whoami));
96 
97 	if (DBAU1500_WHOAMI_DAUGHTER(whoami) != 0xf)
98 		printf("daughtercard 0x%x\n",
99 		    DBAU1500_WHOAMI_DAUGHTER(whoami));
100 	else
101 		printf("no daughtercard\n");
102 
103 	/* leave console and clocks alone -- YAMON should have got it right! */
104 }
105 
106 int
107 dbau1500_pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
108 {
109 	/*
110 	 * This platform has PCI slot and IDE interrupts mapped
111 	 * identically.  So we just need to look at which of the four
112 	 * PCI interrupts it is.
113 	 */
114 
115 	switch (pa->pa_intrpin) {
116 	case 0:
117 		/* not used */
118 		return 1;
119 	case 1:
120 		*ihp = 1;
121 		break;
122 	case 2:
123 		*ihp = 2;
124 		break;
125 	case 3:
126 		*ihp = 4;
127 		break;
128 	case 4:
129 		*ihp = 5;
130 		break;
131 	default:
132 		printf("pci: bad interrupt pin %d\n", pa->pa_intrpin);
133 		return 1;
134 	}
135 	return 0;
136 }
137 
138 void
139 dbau1500_reboot(void)
140 {
141 	PUT16(DBAU1500_SOFTWARE_RESET, 0);
142 	delay(100000);	/* 100 msec */
143 }
144