Пример #1
0
void
pcppi_attach(struct pcppi_softc *sc)
{
        struct pcppi_attach_args pa;
	device_t self = sc->sc_dv;

	callout_init(&sc->sc_bell_ch, CALLOUT_MPSAFE);
	callout_setfunc(&sc->sc_bell_ch, pcppi_bell_callout, sc);
	cv_init(&sc->sc_slp, "bell");

        sc->sc_bellactive = sc->sc_bellpitch = 0;

#if NPCKBD > 0
	/* Provide a beeper for the PC Keyboard, if there isn't one already. */
	pckbd_hookup_bell(pcppi_pckbd_bell, sc);
#endif
#if NATTIMER > 0
	config_defer(sc->sc_dv, pcppi_attach_speaker);
#endif
	if (!pmf_device_register(self, NULL, NULL))
		aprint_error_dev(self, "couldn't establish power handler\n");

	pa.pa_cookie = sc;
	config_search_loc(pcppisearch, sc->sc_dv, "pcppi", NULL, &pa);
}
Пример #2
0
void
ykbec_attach(device_t parent, device_t self, void *aux)
{
	struct isa_attach_args *ia = aux;
	struct ykbec_softc *sc = device_private(self);
	int i;

	sc->sc_iot = ia->ia_iot;
	if (bus_space_map(sc->sc_iot, ia->ia_iobase, ia->ia_iosize, 0,
	    &sc->sc_ioh)) {
		aprint_error(": couldn't map I/O space");
		return;
	}

	/* Initialize sensor data. */
	strlcpy(sc->sc_sensordev.xname, device_xname(self),
	    sizeof(sc->sc_sensordev.xname));
	if (sensor_task_register(sc, ykbec_refresh, 5) == NULL) {
		aprint_error(", unable to register update task\n");
		return;
	}

#ifdef DEBUG
	ykbec_print_bat_info(sc);
#endif
	aprint_normal("\n");

	for (i = 0; i < YKBEC_NSENSORS; i++) {
		sc->sc_sensor[i].type = ykbec_table[i].type; 
		if (ykbec_table[i].desc) 
			strlcpy(sc->sc_sensor[i].desc, ykbec_table[i].desc,
			    sizeof(sc->sc_sensor[i].desc));
		sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]);
	}

	sensordev_install(&sc->sc_sensordev);

#if NAPM > 0
	/* make sure we have the apm state initialized before apm attaches */
	ykbec_refresh(sc);
	apm_setinfohook(ykbec_apminfo);
#endif
#if NPCKBD > 0 || NHIDKBD > 0
	timeout_set(&sc->sc_bell_tmo, ykbec_bell_stop, sc);
#if NPCKBD > 0
	pckbd_hookup_bell(ykbec_bell, sc);
#endif
#if NHIDKBD > 0
	hidkbd_hookup_bell(ykbec_bell, sc);
#endif
#endif
	ykbec_sc = sc;
}