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