1 /* $NetBSD: omsal400.c,v 1.4 2006/04/02 17:32:57 kiyohara Exp $ */
4 * Copyright (c) 2006 Itronix Inc.
5 * Copyright (c) 2006 Shigeyuki Fukushima.
8 * Written by Garrett D'Amore for Itronix Inc
9 * Written by Shigeyuki Fukushima.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer in the documentation and/or other materials provided
19 * with the distribution.
20 * 3. The name of the author may not be used to endorse or promote
21 * products derived from this software without specific prior
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
25 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
28 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
30 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #include <sys/cdefs.h>
39 __KERNEL_RCSID(0, "$NetBSD: omsal400.c,v 1.4 2006/04/02 17:32:57 kiyohara Exp $");
41 #include <sys/param.h>
42 #include <machine/bus.h>
43 #include <machine/locore.h>
44 #include <mips/alchemy/dev/augpiovar.h>
45 #include <mips/alchemy/dev/aupcmciavar.h>
46 #include <evbmips/alchemy/obiovar.h>
47 #include <evbmips/alchemy/board.h>
48 #include <evbmips/alchemy/omsal400reg.h>
51 (*((volatile uint16_t *)MIPS_PHYS_TO_KSEG1(x)))
53 (*((volatile uint16_t *)MIPS_PHYS_TO_KSEG1(x)) = (v))
55 static void omsal400_init(void);
56 static int omsal400_pci_intr_map(struct pci_attach_args
*,
58 static void omsal400_poweroff(void);
59 static void omsal400_reboot(void);
60 static bus_addr_t
omsal400_slot_offset(int);
61 static int omsal400_slot_irq(int, int);
62 static void omsal400_slot_enable(int);
63 static void omsal400_slot_disable(int);
64 static int omsal400_slot_status(int);
65 static const char *omsal400_slot_name(int);
67 static const struct obiodev omsal400_devices
[] = {
71 static struct aupcmcia_machdep omsal400_pcmcia
= {
76 omsal400_slot_disable
,
81 static struct alchemy_board omsal400_info
= {
82 "Plathome Open Micro Server AL400/AMD Alchemy Au1550",
85 omsal400_pci_intr_map
,
91 const struct alchemy_board
*
95 return &omsal400_info
;
101 /* uint16_t whoami; */
103 if (MIPS_PRID_COPTS(cpu_id
) != MIPS_AU1550
)
104 panic("omsal400: CPU not Au1550");
106 #if 0 /* XXX: TODO borad identification */
107 /* check the whoami register for a match */
108 whoami
= GET16(DBAU1550_WHOAMI
);
110 if (DBAU1550_WHOAMI_BOARD(whoami
) != DBAU1550_WHOAMI_DBAU1550_REV1
)
111 panic("dbau1550: WHOAMI (%x) not DBAu1550!", whoami
);
113 printf("DBAu1550 (cabernet), CPLDv%d, ",
114 DBAU1550_WHOAMI_CPLD(whoami
));
116 if (DBAU1550_WHOAMI_DAUGHTER(whoami
) != 0xf)
117 printf("daughtercard 0x%x\n",
118 DBAU1550_WHOAMI_DAUGHTER(whoami
));
120 printf("no daughtercard\n");
123 /* leave console and clocks alone -- YAMON should have got it right! */
127 omsal400_pci_intr_map(struct pci_attach_args
*pa
, pci_intr_handle_t
*ihp
)
130 * This platform has 4 PCI devices:
131 * dev 1 (PCI_INTD): PCI Connector
132 * dev 2 (PCI_INTC): NEC USB 2.0 uPD720101
133 * dev 3 (PCI_INTB): Intel GB Ether 82541PI
134 * dev 4 (PCI_INTA): Intel GB Ether 82541PI
136 static const int irqmap
[4/*device*/][4/*pin*/] = {
137 { 6, -1, -1, -1 }, /* 1: PCI Connecter (not used) */
138 { 5, 5, 5, -1 }, /* 2: NEC USB 2.0 */
139 { 2, -1, -1, -1 }, /* 3: Intel GbE */
140 { 1, -1, -1, -1 }, /* 4: Intel GbE */
145 /* if interrupt pin not used... */
146 if ((pin
= pa
->pa_intrpin
) == 0)
150 printf("pci: bad interrupt pin %d\n", pin
);
154 pci_decompose_tag(pa
->pa_pc
, pa
->pa_intrtag
, NULL
, &dev
, NULL
);
156 if ((dev
< 1) || (dev
> 4)) {
157 printf("pci: bad device %d\n", dev
);
161 if ((irq
= irqmap
[dev
- 1][pin
- 1]) == -1) {
162 printf("pci: no IRQ routing for device %d pin %d\n", dev
, pin
);
171 omsal400_reboot(void)
178 omsal400_poweroff(void)
181 printf("\n- poweroff -\n");
187 omsal400_slot_irq(int slot
, int which
)
189 static const int irqmap
[1/*slot*/][2/*which*/] = {
190 { 35, 37 }, /* Slot 0: CF connector Type2 */
193 if ((slot
>= 1) || (which
>= 2))
196 return irqmap
[slot
][which
];
200 omsal400_slot_offset(int slot
)
205 return (0); /* offset 0 */
207 return (bus_addr_t
)-1;
211 omsal400_slot_enable(int slot
)
218 omsal400_slot_disable(int slot
)
225 omsal400_slot_status(int slot
)
227 uint16_t inserted
= 0;
231 inserted
= !AUGPIO_READ(5); /* pin 5 */
239 omsal400_slot_name(int slot
)
243 return "CF connector Type2 on Static BUS#3";