/*
* Copyright (c) 2004 Jochen Kunz.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of Jochen Kunz may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY JOCHEN KUNZ
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JOCHEN KUNZ
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 2003 Michael Shalayeff
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
switch (cpu_modelno) {
case HPPA_BOARD_HP712_60:
case HPPA_BOARD_HP712_80:
case HPPA_BOARD_HP712_100:
case HPPA_BOARD_HP712_120:
sc->sc_kicker = power_thread_dr;
/*
* If the power switch is turned off we schedule a sysmon task
* to register that event for this power switch device.
*/
static void
check_pwr_state(struct power_softc *sc)
{
if (pswitch_on == false && pwr_sw_control != PWR_SW_CTRL_LOCK)
sysmon_task_queue_sched(0, pwr_sw_sysmon_cb, NULL);
else
callout_reset(&sc->sc_callout, sc->sc_timeout,
sc->sc_kicker, sc);
}
/* Get Power Fail status from CPU Diagnose Register 25 */
mfcpu(25, r);
/*
* On power failure, the hardware clears bit DR25_PCXL_POWFAIL
* in CPU Diagnose Register 25.
*/
if (r & (1 << DR25_PCXL_POWFAIL))
sc->sc_dr_cnt = 0;
else
sc->sc_dr_cnt++;
/*
* the bit is undampened straight wire from the power
* switch and thus we have do dampen it ourselves.
*/
if (sc->sc_dr_cnt == sc->sc_timeout)
pswitch_on = false;
else
pswitch_on = true;
/*
* Ensure that we are on a PCX-L / PA7100LC CPU if it is a
* 712 style machine.
*/
if (pdc_power_info.addr == 0 && hppa_cpu_info->hci_cputype != hpcxl) {
aprint_error_dev(sc->sc_dev, "No soft power available.\n");
return error;
}
switch(enable) {
case PWR_SW_CTRL_DISABLE:
on = HPPA_COLD_OFF;
break;
case PWR_SW_CTRL_ENABLE:
case PWR_SW_CTRL_LOCK:
on = HPPA_COLD_HOT;
break;
default:
panic("invalid power state in pwr_sw_control: %d", enable);
}
pwr_sw_control = enable;
if (cold_hook)
(*cold_hook)(on);
}
int
pwr_sw_sysctl_state(SYSCTLFN_ARGS)
{
struct sysctlnode node;
const char *status;
if (pswitch_on == true)
status = "on";
else
status = "off";