dbau1550.c revision 1.2 1 /* $NetBSD: dbau1550.c,v 1.2 2006/02/12 06:43:03 gdamore 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: dbau1550.c,v 1.2 2006/02/12 06:43:03 gdamore Exp $");
36
37 #include <sys/param.h>
38 #include <machine/bus.h>
39 #include <machine/locore.h>
40 #include <evbmips/alchemy/obiovar.h>
41 #include <evbmips/alchemy/board.h>
42 #include <evbmips/alchemy/dbau1550reg.h>
43
44 static void dbau1550_init(void);
45 static int dbau1550_pci_intr_map(struct pci_attach_args *,
46 pci_intr_handle_t *);
47
48 static const struct obiodev dbau1550_devices[] = {
49 #if 0
50 { "aupcmcia", -1, -1 },
51 { "aupsc", -1, -1 },
52 { "aupsc", -1, -1 },
53 { "aupsc", -1, -1 },
54 #endif
55 { NULL },
56 };
57
58 static struct alchemy_board dbau1550_info = {
59 "AMD Alchemy DBAu1550",
60 dbau1550_devices,
61 dbau1550_init,
62 dbau1550_pci_intr_map,
63 };
64
65 const struct alchemy_board *
66 board_info(void)
67 {
68
69 return &dbau1550_info;
70 }
71
72 void
73 dbau1550_init(void)
74 {
75 uint32_t whoami;
76
77 if (MIPS_PRID_COPTS(cpu_id) != MIPS_AU1550)
78 panic("dbau1550: CPU not Au1550");
79
80 /* check the whoami register for a match */
81 whoami = *((volatile uint32_t *)MIPS_PHYS_TO_KSEG1(DBAU1550_WHOAMI));
82
83 if (DBAU1550_WHOAMI_BOARD(whoami) != DBAU1550_WHOAMI_DBAU1550_REV1)
84 panic("dbau1550: WHOAMI (%x) not DBAu1550!", whoami);
85
86 printf("DBAu1550 (cabernet), CPLDv%d, ",
87 DBAU1550_WHOAMI_CPLD(whoami));
88
89 if (DBAU1550_WHOAMI_DAUGHTER(whoami) != 0xf)
90 printf("daughtercard 0x%x\n",
91 DBAU1550_WHOAMI_DAUGHTER(whoami));
92 else
93 printf("no daughtercard\n");
94
95 /* leave console and clocks alone -- YAMON should have got it right! */
96 }
97
98 int
99 dbau1550_pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
100 {
101 /*
102 * This platform has one onboard PCI IDE controller, and two
103 * PCI expansion slots.
104 */
105 static const int irqmap[3/*device*/][4/*pin*/] = {
106 { 5, -1, -1, -1 }, /* 11: IDE */
107 { 2, 5, 6, 1 }, /* 12: PCI Slot 2 */
108 { 1, 2, 5, 6 }, /* 13: PCI Slot 3 */
109 };
110 int pin, dev, irq;
111
112 /* if interrupt pin not used... */
113 if ((pin = pa->pa_intrpin) == 0)
114 return 1;
115
116 if (pin > 4) {
117 printf("pci: bad interrupt pin %d\n", pin);
118 return 1;
119 }
120
121 pci_decompose_tag(pa->pa_pc, pa->pa_intrtag, NULL, &dev, NULL);
122 if ((dev < 11) || (dev > 13)) {
123 printf("pci: bad device %d\n", dev);
124 return 1;
125 }
126
127 if ((irq = irqmap[dev - 11][pin - 1]) == -1) {
128 printf("pci: no IRQ routing for device %d pin %d\n", dev, pin);
129 return 1;
130 }
131
132 *ihp = irq;
133 return 0;
134 }
135