Added board support for hard-reset (reboot) and power off.

This commit is contained in:
gdamore 2006-02-13 02:37:05 +00:00
parent 2bc42dde61
commit 8ea5188929
3 changed files with 63 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: board.h,v 1.1 2006/02/08 09:04:01 gdamore Exp $ */
/* $NetBSD: board.h,v 1.2 2006/02/13 02:37:05 gdamore Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@ -42,6 +42,8 @@ struct alchemy_board {
void (*ab_init)(void);
int (*ab_pci_intr_map)(struct pci_attach_args *,
pci_intr_handle_t *);
void (*ab_reboot)(void);
void (*ab_poweroff)(void);
/*
* XXX: csb250 (and perhaps others) will require pci_idsel

View File

@ -1,4 +1,4 @@
/* $NetBSD: dbau1550.c,v 1.2 2006/02/12 06:43:03 gdamore Exp $ */
/* $NetBSD: dbau1550.c,v 1.3 2006/02/13 02:37:05 gdamore Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dbau1550.c,v 1.2 2006/02/12 06:43:03 gdamore Exp $");
__KERNEL_RCSID(0, "$NetBSD: dbau1550.c,v 1.3 2006/02/13 02:37:05 gdamore Exp $");
#include <sys/param.h>
#include <machine/bus.h>
@ -41,9 +41,18 @@ __KERNEL_RCSID(0, "$NetBSD: dbau1550.c,v 1.2 2006/02/12 06:43:03 gdamore Exp $")
#include <evbmips/alchemy/board.h>
#include <evbmips/alchemy/dbau1550reg.h>
#define GET32(x) \
(*((volatile uint32_t *)MIPS_PHYS_TO_KSEG1(x)))
#define PUT32(x, v) \
(*((volatile uint32_t *)MIPS_PHYS_TO_KSEG1(x)) = (v))
#define PUT16(x, v) \
(*((volatile uint16_t *)MIPS_PHYS_TO_KSEG1(x)) = (v))
static void dbau1550_init(void);
static int dbau1550_pci_intr_map(struct pci_attach_args *,
pci_intr_handle_t *);
static void dbau1550_poweroff(void);
static void dbau1550_reboot(void);
static const struct obiodev dbau1550_devices[] = {
#if 0
@ -60,6 +69,8 @@ static struct alchemy_board dbau1550_info = {
dbau1550_devices,
dbau1550_init,
dbau1550_pci_intr_map,
dbau1550_reboot,
dbau1550_poweroff,
};
const struct alchemy_board *
@ -132,3 +143,19 @@ dbau1550_pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
*ihp = irq;
return 0;
}
void
dbau1550_reboot(void)
{
PUT16(DBAU1550_SOFTWARE_RESET, 0);
delay(100000); /* 100 msec */
}
void
dbau1550_poweroff(void)
{
printf("\n- poweroff -\n");
PUT16(DBAU1550_SOFTWARE_RESET,
DBAU1550_SOFTWARE_RESET_PWROFF | DBAU1550_SOFTWARE_RESET_RESET);
delay(100000); /* 100 msec */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.25 2006/02/09 00:26:39 gdamore Exp $ */
/* $NetBSD: machdep.c,v 1.26 2006/02/13 02:37:05 gdamore Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@ -107,7 +107,7 @@
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.25 2006/02/09 00:26:39 gdamore Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.26 2006/02/13 02:37:05 gdamore Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -446,11 +446,15 @@ void
cpu_reboot(int howto, char *bootstr)
{
static int waittime = -1;
const struct alchemy_board *board;
/* Take a snapshot before clobbering any registers. */
if (curproc)
savectx((struct user *)curpcb);
board = board_info();
KASSERT(board != NULL);
/* If "always halt" was specified as a boot flag, obey. */
if (boothowto & RB_HALT)
howto |= RB_HALT;
@ -488,6 +492,31 @@ cpu_reboot(int howto, char *bootstr)
/* Run any shutdown hooks. */
doshutdownhooks();
if ((boothowto & RB_POWERDOWN) == RB_POWERDOWN)
if (board && board->ab_poweroff)
board->ab_poweroff();
/*
* YAMON may autoboot (depending on settings), and we cannot pass
* flags to it (at least I haven't figured out how to yet), so
* we "pseudo-halt" now.
*/
if (boothowto & RB_HALT) {
printf("\n");
printf("The operating system has halted.\n");
printf("Please press any key to reboot.\n\n");
cnpollc(1); /* For proper keyboard command handling */
cngetc();
cnpollc(0);
}
/*
* Try to use board-specific reset logic, which might involve a better
* hardware reset.
*/
if (board->ab_reboot)
board->ab_reboot();
#if 1
/* XXX
* For some reason we are leaving the ethernet MAC in a state where