/*
* Copyright (c) 2000, 2001, 2015 Matthew R. Green
* 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 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.
*/
/*
* AUXIO registers support on the sbus & ebus2, used for the floppy driver
* and to control the system LED, for the BLINK option.
*/
mutex_enter(&sc->sc_lock);
led = auxio_read_led(sc);
led = led ^ AUXIO_LED_LED;
auxio_write_led(sc, led);
mutex_exit(&sc->sc_lock);
/*
* Blink rate is:
* full cycle every second if completely idle (loadav = 0)
* full cycle every 2 seconds if loadav = 1
* full cycle every 3 seconds if loadav = 2
* etc.
*/
s = (((averunnable.ldavg[0] + FSCALE) * hz) >> (FSHIFT + 1));
callout_reset(&blink_ch, s, auxio_blink, sc);
}
#endif
void
auxio_attach_common(struct auxio_softc *sc)
{
static int do_once = 1;
/* only start one blinker */
if (do_once) {
mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_HIGH);
#ifdef BLINK
callout_init(&blink_ch, CALLOUT_MPSAFE);
auxio_blink(sc);
#endif
do_once = 0;
}
printf("\n");
}
int
auxio_fd_control(u_int32_t bits)
{
struct auxio_softc *sc;
u_int32_t led;
if (auxio_cd.cd_ndevs == 0) {
return ENXIO;
}
/*
* XXX This does not handle > 1 auxio correctly.
* We'll assume the floppy drive is tied to first auxio found.
*/
sc = device_lookup_private(&auxio_cd, 0);
if (!sc) {
return ENXIO;
}
mutex_enter(&sc->sc_lock);
led = auxio_read_led(sc);
led = (led & ~AUXIO_LED_FLOPPY_MASK) | bits;
auxio_write_led(sc, led);
mutex_exit(&sc->sc_lock);