xref: /titanic_53/usr/src/uts/sun4u/io/pmc.c (revision 6c9bfa0b39999e3f2c9448ede1e4cbd8bfaca728)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*6c9bfa0bSjan  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*6c9bfa0bSjan  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * Driver for the Power Management Controller (logical unit 8) of the
317c478bd9Sstevel@tonic-gate  * PC87317 SuperI/O chip. The PMC contains the hardware watchdog timer.
327c478bd9Sstevel@tonic-gate  */
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #include <sys/types.h>
357c478bd9Sstevel@tonic-gate #include <sys/time.h>
367c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
377c478bd9Sstevel@tonic-gate #include <sys/param.h>
387c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
397c478bd9Sstevel@tonic-gate #include <sys/conf.h>
407c478bd9Sstevel@tonic-gate #include <sys/stat.h>
417c478bd9Sstevel@tonic-gate #include <sys/clock.h>
427c478bd9Sstevel@tonic-gate #include <sys/reboot.h>
437c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
447c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
457c478bd9Sstevel@tonic-gate #include <sys/file.h>
467c478bd9Sstevel@tonic-gate #include <sys/note.h>
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #ifdef	DEBUG
497c478bd9Sstevel@tonic-gate int pmc_debug_flag = 0;
507c478bd9Sstevel@tonic-gate #define	DPRINTF(ARGLIST) if (pmc_debug_flag) printf ARGLIST;
517c478bd9Sstevel@tonic-gate #else
527c478bd9Sstevel@tonic-gate #define	DPRINTF(ARGLIST)
537c478bd9Sstevel@tonic-gate #endif /* DEBUG */
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate /* Driver soft state structure */
567c478bd9Sstevel@tonic-gate typedef struct pmc {
577c478bd9Sstevel@tonic-gate 	dev_info_t		*dip;
587c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t	pmc_handle;
597c478bd9Sstevel@tonic-gate } pmc_t;
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate static void *pmc_soft_state;
627c478bd9Sstevel@tonic-gate static int instance = -1;
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /* dev_ops and cb_ops entry point function declarations */
657c478bd9Sstevel@tonic-gate static int pmc_attach(dev_info_t *, ddi_attach_cmd_t);
667c478bd9Sstevel@tonic-gate static int pmc_detach(dev_info_t *, ddi_detach_cmd_t);
677c478bd9Sstevel@tonic-gate static int pmc_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate /* hardware watchdog parameters */
707c478bd9Sstevel@tonic-gate static uint_t pmc_set_watchdog_timer(uint_t);
717c478bd9Sstevel@tonic-gate static uint_t pmc_clear_watchdog_timer(void);
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate extern volatile uint8_t	*v_pmc_addr_reg;
747c478bd9Sstevel@tonic-gate extern volatile uint8_t	*v_pmc_data_reg;
757c478bd9Sstevel@tonic-gate extern int		watchdog_enable;
767c478bd9Sstevel@tonic-gate extern int		watchdog_available;
777c478bd9Sstevel@tonic-gate extern int		watchdog_activated;
787c478bd9Sstevel@tonic-gate extern int		boothowto;
797c478bd9Sstevel@tonic-gate extern uint_t		watchdog_timeout_seconds;
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate /*
827c478bd9Sstevel@tonic-gate  * Power Management Registers and values
837c478bd9Sstevel@tonic-gate  */
847c478bd9Sstevel@tonic-gate #define	PMC_WDTO	0x05	/* Watchdog Time Out */
857c478bd9Sstevel@tonic-gate #define	PMC_CLEAR_WDTO	0x00
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate struct cb_ops pmc_cb_ops = {
887c478bd9Sstevel@tonic-gate 	nodev,
897c478bd9Sstevel@tonic-gate 	nodev,
907c478bd9Sstevel@tonic-gate 	nodev,
917c478bd9Sstevel@tonic-gate 	nodev,
927c478bd9Sstevel@tonic-gate 	nodev,			/* dump */
937c478bd9Sstevel@tonic-gate 	nodev,
947c478bd9Sstevel@tonic-gate 	nodev,
957c478bd9Sstevel@tonic-gate 	nodev,
967c478bd9Sstevel@tonic-gate 	nodev,			/* devmap */
977c478bd9Sstevel@tonic-gate 	nodev,
987c478bd9Sstevel@tonic-gate 	nodev,
997c478bd9Sstevel@tonic-gate 	nochpoll,
1007c478bd9Sstevel@tonic-gate 	ddi_prop_op,
1017c478bd9Sstevel@tonic-gate 	NULL,			/* for STREAMS drivers */
1027c478bd9Sstevel@tonic-gate 	D_NEW | D_MP,		/* driver compatibility flag */
1037c478bd9Sstevel@tonic-gate 	CB_REV,
1047c478bd9Sstevel@tonic-gate 	nodev,
1057c478bd9Sstevel@tonic-gate 	nodev
1067c478bd9Sstevel@tonic-gate };
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate static struct dev_ops pmc_dev_ops = {
1097c478bd9Sstevel@tonic-gate 	DEVO_REV,			/* driver build version */
1107c478bd9Sstevel@tonic-gate 	0,				/* device reference count */
1117c478bd9Sstevel@tonic-gate 	pmc_getinfo,
1127c478bd9Sstevel@tonic-gate 	nulldev,
1137c478bd9Sstevel@tonic-gate 	nulldev,			/* probe */
1147c478bd9Sstevel@tonic-gate 	pmc_attach,
1157c478bd9Sstevel@tonic-gate 	pmc_detach,
1167c478bd9Sstevel@tonic-gate 	nulldev,			/* reset */
1177c478bd9Sstevel@tonic-gate 	&pmc_cb_ops,
1187c478bd9Sstevel@tonic-gate 	(struct bus_ops *)NULL,
1197c478bd9Sstevel@tonic-gate 	nulldev				/* power */
1207c478bd9Sstevel@tonic-gate };
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate /* module configuration stuff */
1237c478bd9Sstevel@tonic-gate extern struct mod_ops mod_driverops;
1247c478bd9Sstevel@tonic-gate static struct modldrv modldrv = {
1257c478bd9Sstevel@tonic-gate 	&mod_driverops,
1267c478bd9Sstevel@tonic-gate 	"pmc driver %I%",
1277c478bd9Sstevel@tonic-gate 	&pmc_dev_ops
1287c478bd9Sstevel@tonic-gate };
1297c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = {
1307c478bd9Sstevel@tonic-gate 	MODREV_1,
1317c478bd9Sstevel@tonic-gate 	&modldrv,
1327c478bd9Sstevel@tonic-gate 	0
1337c478bd9Sstevel@tonic-gate };
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate int
1377c478bd9Sstevel@tonic-gate _init(void)
1387c478bd9Sstevel@tonic-gate {
1397c478bd9Sstevel@tonic-gate 	int e;
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate 	e = ddi_soft_state_init(&pmc_soft_state, sizeof (pmc_t), 1);
1427c478bd9Sstevel@tonic-gate 	if (e != 0) {
1437c478bd9Sstevel@tonic-gate 		DPRINTF(("_init: ddi_soft_state_init failed\n"));
1447c478bd9Sstevel@tonic-gate 		return (e);
1457c478bd9Sstevel@tonic-gate 	}
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate 	e = mod_install(&modlinkage);
1487c478bd9Sstevel@tonic-gate 	if (e != 0) {
1497c478bd9Sstevel@tonic-gate 		DPRINTF(("_init: mod_install failed\n"));
1507c478bd9Sstevel@tonic-gate 		ddi_soft_state_fini(&pmc_soft_state);
1517c478bd9Sstevel@tonic-gate 		return (e);
1527c478bd9Sstevel@tonic-gate 	}
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate 	if (v_pmc_addr_reg != NULL) {
1557c478bd9Sstevel@tonic-gate 		tod_ops.tod_set_watchdog_timer = pmc_set_watchdog_timer;
1567c478bd9Sstevel@tonic-gate 		tod_ops.tod_clear_watchdog_timer = pmc_clear_watchdog_timer;
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate 		/*
1597c478bd9Sstevel@tonic-gate 		 * See if the user has enabled the watchdog timer, and if
1607c478bd9Sstevel@tonic-gate 		 * it's available.
1617c478bd9Sstevel@tonic-gate 		 */
1627c478bd9Sstevel@tonic-gate 		if (watchdog_enable) {
1637c478bd9Sstevel@tonic-gate 			if (!watchdog_available) {
1647c478bd9Sstevel@tonic-gate 				cmn_err(CE_WARN, "pmc: Hardware watchdog "
1657c478bd9Sstevel@tonic-gate 					"unavailable");
1667c478bd9Sstevel@tonic-gate 			} else if (boothowto & RB_DEBUG) {
1677c478bd9Sstevel@tonic-gate 				watchdog_available = 0;
1687c478bd9Sstevel@tonic-gate 				cmn_err(CE_WARN, "pmc: kernel debugger "
1697c478bd9Sstevel@tonic-gate 					"detected: hardware watchdog disabled");
1707c478bd9Sstevel@tonic-gate 			}
1717c478bd9Sstevel@tonic-gate 		}
1727c478bd9Sstevel@tonic-gate 	}
1737c478bd9Sstevel@tonic-gate 	return (e);
1747c478bd9Sstevel@tonic-gate }
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate int
1777c478bd9Sstevel@tonic-gate _fini(void)
1787c478bd9Sstevel@tonic-gate {
1797c478bd9Sstevel@tonic-gate 	int e;
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate 	if (v_pmc_addr_reg != NULL)
1827c478bd9Sstevel@tonic-gate 		return (DDI_FAILURE);
1837c478bd9Sstevel@tonic-gate 	else {
1847c478bd9Sstevel@tonic-gate 		e = mod_remove(&modlinkage);
1857c478bd9Sstevel@tonic-gate 		if (e != 0)
1867c478bd9Sstevel@tonic-gate 			return (e);
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate 		ddi_soft_state_fini(&pmc_soft_state);
1897c478bd9Sstevel@tonic-gate 		return (DDI_SUCCESS);
1907c478bd9Sstevel@tonic-gate 	}
1917c478bd9Sstevel@tonic-gate }
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate int
1957c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop)
1967c478bd9Sstevel@tonic-gate {
1977c478bd9Sstevel@tonic-gate 	return (mod_info(&modlinkage, modinfop));
1987c478bd9Sstevel@tonic-gate }
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate static int
2017c478bd9Sstevel@tonic-gate pmc_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
2027c478bd9Sstevel@tonic-gate {
2037c478bd9Sstevel@tonic-gate 	_NOTE(ARGUNUSED(dip))
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate 	pmc_t	*pmcp;
2067c478bd9Sstevel@tonic-gate 	int	instance;
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate 	switch (cmd) {
2097c478bd9Sstevel@tonic-gate 	case DDI_INFO_DEVT2DEVINFO:
2107c478bd9Sstevel@tonic-gate 		instance = getminor((dev_t)arg);
2117c478bd9Sstevel@tonic-gate 		pmcp = (pmc_t *)ddi_get_soft_state(pmc_soft_state, instance);
2127c478bd9Sstevel@tonic-gate 		if (pmcp == NULL) {
2137c478bd9Sstevel@tonic-gate 			*result = (void *)NULL;
2147c478bd9Sstevel@tonic-gate 			return (DDI_FAILURE);
2157c478bd9Sstevel@tonic-gate 		}
2167c478bd9Sstevel@tonic-gate 		*result = (void *)pmcp->dip;
2177c478bd9Sstevel@tonic-gate 		return (DDI_SUCCESS);
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate 	case DDI_INFO_DEVT2INSTANCE:
220*6c9bfa0bSjan 		*result = (void *)(uintptr_t)getminor((dev_t)arg);
2217c478bd9Sstevel@tonic-gate 		return (DDI_SUCCESS);
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate 	default:
2247c478bd9Sstevel@tonic-gate 		return (DDI_FAILURE);
2257c478bd9Sstevel@tonic-gate 	}
2267c478bd9Sstevel@tonic-gate }
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate static int
2307c478bd9Sstevel@tonic-gate pmc_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
2317c478bd9Sstevel@tonic-gate {
2327c478bd9Sstevel@tonic-gate 	pmc_t	*pmcp;
2337c478bd9Sstevel@tonic-gate 	uint_t	wd_timout;
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate 	switch (cmd) {
2367c478bd9Sstevel@tonic-gate 	case DDI_ATTACH:
2377c478bd9Sstevel@tonic-gate 		break;
2387c478bd9Sstevel@tonic-gate 	case DDI_RESUME:
2397c478bd9Sstevel@tonic-gate 		if (v_pmc_addr_reg != NULL && watchdog_enable) {
2407c478bd9Sstevel@tonic-gate 			int ret = 0;
2417c478bd9Sstevel@tonic-gate 			wd_timout = watchdog_timeout_seconds;
2427c478bd9Sstevel@tonic-gate 			mutex_enter(&tod_lock);
2437c478bd9Sstevel@tonic-gate 			ret = tod_ops.tod_set_watchdog_timer(wd_timout);
2447c478bd9Sstevel@tonic-gate 			mutex_exit(&tod_lock);
2457c478bd9Sstevel@tonic-gate 			if (ret == 0)
2467c478bd9Sstevel@tonic-gate 				return (DDI_FAILURE);
2477c478bd9Sstevel@tonic-gate 		}
2487c478bd9Sstevel@tonic-gate 		return (DDI_SUCCESS);
2497c478bd9Sstevel@tonic-gate 	default:
2507c478bd9Sstevel@tonic-gate 		return (DDI_FAILURE);
2517c478bd9Sstevel@tonic-gate 	}
2527c478bd9Sstevel@tonic-gate 
2537c478bd9Sstevel@tonic-gate 	if (instance != -1) {
2547c478bd9Sstevel@tonic-gate 		DPRINTF(("pmc_attach: Another instance is already attached."));
2557c478bd9Sstevel@tonic-gate 		return (DDI_FAILURE);
2567c478bd9Sstevel@tonic-gate 	}
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate 	instance = ddi_get_instance(dip);
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate 	if (ddi_soft_state_zalloc(pmc_soft_state, instance) != DDI_SUCCESS) {
2617c478bd9Sstevel@tonic-gate 		DPRINTF(("pmc_attach: Failed to allocate soft state."));
2627c478bd9Sstevel@tonic-gate 		return (DDI_FAILURE);
2637c478bd9Sstevel@tonic-gate 	}
2647c478bd9Sstevel@tonic-gate 
2657c478bd9Sstevel@tonic-gate 	pmcp = (pmc_t *)ddi_get_soft_state(pmc_soft_state, instance);
2667c478bd9Sstevel@tonic-gate 	pmcp->dip = dip;
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate 	return (DDI_SUCCESS);
2697c478bd9Sstevel@tonic-gate }
2707c478bd9Sstevel@tonic-gate 
2717c478bd9Sstevel@tonic-gate static int
2727c478bd9Sstevel@tonic-gate pmc_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
2737c478bd9Sstevel@tonic-gate {
2747c478bd9Sstevel@tonic-gate 	_NOTE(ARGUNUSED(dip))
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate 	pmc_t	*pmcp;
2777c478bd9Sstevel@tonic-gate 
2787c478bd9Sstevel@tonic-gate 	switch (cmd) {
2797c478bd9Sstevel@tonic-gate 	case DDI_DETACH:
2807c478bd9Sstevel@tonic-gate 		/* allow detach if no hardware watchdog */
2817c478bd9Sstevel@tonic-gate 		if (v_pmc_addr_reg == NULL || !watchdog_activated) {
2827c478bd9Sstevel@tonic-gate 			pmcp = (pmc_t *)ddi_get_soft_state(pmc_soft_state,
2837c478bd9Sstevel@tonic-gate 				instance);
2847c478bd9Sstevel@tonic-gate 			if (pmcp == NULL)
2857c478bd9Sstevel@tonic-gate 				return (ENXIO);
2867c478bd9Sstevel@tonic-gate 			ddi_soft_state_free(pmc_soft_state, instance);
2877c478bd9Sstevel@tonic-gate 			return (DDI_SUCCESS);
2887c478bd9Sstevel@tonic-gate 		} else
2897c478bd9Sstevel@tonic-gate 			return (DDI_FAILURE);
2907c478bd9Sstevel@tonic-gate 	case DDI_SUSPEND:
2917c478bd9Sstevel@tonic-gate 		if (v_pmc_addr_reg != NULL && watchdog_activated) {
2927c478bd9Sstevel@tonic-gate 			mutex_enter(&tod_lock);
2937c478bd9Sstevel@tonic-gate 			(void) tod_ops.tod_clear_watchdog_timer();
2947c478bd9Sstevel@tonic-gate 			mutex_exit(&tod_lock);
2957c478bd9Sstevel@tonic-gate 		}
2967c478bd9Sstevel@tonic-gate 		return (DDI_SUCCESS);
2977c478bd9Sstevel@tonic-gate 	default:
2987c478bd9Sstevel@tonic-gate 		return (DDI_FAILURE);
2997c478bd9Sstevel@tonic-gate 	}
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate }
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate /*
3047c478bd9Sstevel@tonic-gate  * Set the hardware watchdog timer; returning what we set it to.
3057c478bd9Sstevel@tonic-gate  */
3067c478bd9Sstevel@tonic-gate static uint_t
3077c478bd9Sstevel@tonic-gate pmc_set_watchdog_timer(uint_t timeoutval)
3087c478bd9Sstevel@tonic-gate {
3097c478bd9Sstevel@tonic-gate 	uint_t timeoutval_minutes;
3107c478bd9Sstevel@tonic-gate 	ASSERT(MUTEX_HELD(&tod_lock));
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate 	/* sanity checks */
3137c478bd9Sstevel@tonic-gate 	if (watchdog_enable == 0 || watchdog_available == 0 ||
3147c478bd9Sstevel@tonic-gate 	    timeoutval == 0)
3157c478bd9Sstevel@tonic-gate 		return (0);
3167c478bd9Sstevel@tonic-gate 
3177c478bd9Sstevel@tonic-gate 	/*
3187c478bd9Sstevel@tonic-gate 	 * Historically the timer has been counted out in seconds.
3197c478bd9Sstevel@tonic-gate 	 * The PC87317 counts the timeout in minutes. The default
3207c478bd9Sstevel@tonic-gate 	 * timeout is 10 seconds; the least we can do is one minute.
3217c478bd9Sstevel@tonic-gate 	 */
3227c478bd9Sstevel@tonic-gate 	timeoutval_minutes = (timeoutval + 59) / 60;
3237c478bd9Sstevel@tonic-gate 	if (timeoutval_minutes > UINT8_MAX)
3247c478bd9Sstevel@tonic-gate 		return (0);
3257c478bd9Sstevel@tonic-gate 
3267c478bd9Sstevel@tonic-gate 	*v_pmc_addr_reg = (uint8_t)PMC_WDTO;
3277c478bd9Sstevel@tonic-gate 	*v_pmc_data_reg = (uint8_t)timeoutval_minutes;
3287c478bd9Sstevel@tonic-gate 	watchdog_activated = 1;
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate 	/* we'll still return seconds */
3317c478bd9Sstevel@tonic-gate 	return (timeoutval_minutes * 60);
3327c478bd9Sstevel@tonic-gate }
3337c478bd9Sstevel@tonic-gate 
3347c478bd9Sstevel@tonic-gate /*
3357c478bd9Sstevel@tonic-gate  * Clear the hardware watchdog timer; returning what it was set to.
3367c478bd9Sstevel@tonic-gate  */
3377c478bd9Sstevel@tonic-gate static uint_t
3387c478bd9Sstevel@tonic-gate pmc_clear_watchdog_timer(void)
3397c478bd9Sstevel@tonic-gate {
3407c478bd9Sstevel@tonic-gate 	uint_t	wd_timeout;
3417c478bd9Sstevel@tonic-gate 
3427c478bd9Sstevel@tonic-gate 	ASSERT(MUTEX_HELD(&tod_lock));
3437c478bd9Sstevel@tonic-gate 	if (watchdog_activated == 0)
3447c478bd9Sstevel@tonic-gate 		return (0);
3457c478bd9Sstevel@tonic-gate 
3467c478bd9Sstevel@tonic-gate 	*v_pmc_addr_reg = (uint8_t)PMC_WDTO;
3477c478bd9Sstevel@tonic-gate 	wd_timeout = (uint_t)*v_pmc_data_reg;
3487c478bd9Sstevel@tonic-gate 	*v_pmc_data_reg = (uint8_t)PMC_CLEAR_WDTO;
3497c478bd9Sstevel@tonic-gate 	watchdog_activated = 0;
3507c478bd9Sstevel@tonic-gate 
3517c478bd9Sstevel@tonic-gate 	/* return seconds */
3527c478bd9Sstevel@tonic-gate 	return (wd_timeout * 60);
3537c478bd9Sstevel@tonic-gate }
354