#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dbau1500.c,v 1.8 2015/06/09 22:49:55 matt Exp $");
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/cpu.h>
#include <mips/locore.h>
#include <evbmips/alchemy/obiovar.h>
#include <evbmips/alchemy/board.h>
#include <evbmips/alchemy/dbau1500reg.h>
#define GET16(x) \
(*((volatile uint16_t *)MIPS_PHYS_TO_KSEG1(x)))
#define PUT16(x, v) \
(*((volatile uint16_t *)MIPS_PHYS_TO_KSEG1(x)) = (v))
static void dbau1500_init(void);
static int dbau1500_pci_intr_map(const struct pci_attach_args *,
pci_intr_handle_t *);
static void dbau1500_reboot(void);
static const struct obiodev dbau1500_devices[] = {
#if 0
{ "aupcmcia", -1, -1 },
{ "auaudio", -1, -1 },
#endif
{ NULL },
};
static struct alchemy_board dbau1500_info = {
"AMD Alchemy DBAu1500",
dbau1500_devices,
dbau1500_init,
dbau1500_pci_intr_map,
dbau1500_reboot,
NULL,
};
const struct alchemy_board *
board_info(void)
{
return &dbau1500_info;
}
void
dbau1500_init(void)
{
uint32_t whoami;
if (MIPS_PRID_COPTS(mips_options.mips_cpu_id) != MIPS_AU1500)
panic("dbau1500: CPU not an AU1500!");
whoami = *((volatile uint32_t *)MIPS_PHYS_TO_KSEG1(DBAU1500_WHOAMI));
if (DBAU1500_WHOAMI_BOARD(whoami) != DBAU1500_WHOAMI_DBAU1500)
panic("dbau1500: WHOAMI (%x) not DBAu1500!", whoami);
printf("DBAu1500 (zinfandel), CPLDv%d, ",
DBAU1500_WHOAMI_CPLD(whoami));
if (DBAU1500_WHOAMI_DAUGHTER(whoami) != 0xf)
printf("daughtercard 0x%x\n",
DBAU1500_WHOAMI_DAUGHTER(whoami));
else
printf("no daughtercard\n");
}
int
dbau1500_pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
{
switch (pa->pa_intrpin) {
case 0:
return 1;
case 1:
*ihp = 1;
break;
case 2:
*ihp = 2;
break;
case 3:
*ihp = 4;
break;
case 4:
*ihp = 5;
break;
default:
printf("pci: bad interrupt pin %d\n", pa->pa_intrpin);
return 1;
}
return 0;
}
void
dbau1500_reboot(void)
{
PUT16(DBAU1500_SOFTWARE_RESET, 0);
delay(100000);
}