Exemplo n.º 1
0
void
tda_attach(device_t parent, device_t self, void *aux)
{
	struct tda_softc *sc = device_private(self);
	struct i2c_attach_args *ia = aux;

	sc->sc_dev = self;
	sc->sc_tag = ia->ia_tag;
	sc->sc_addr = ia->ia_addr;

	aprint_normal(": %s\n", ia->ia_name);
	aprint_naive(": Environment sensor\n");

	/*
	 * Set the fans to maximum speed and save the power levels;
	 * the controller is write-only.
	 */
	sc->sc_cfan_speed = sc->sc_sfan_speed = (TDA_FANSPEED_MAX+TDA_FANSPEED_MIN)/2;
	tda_setspeed(sc);
	
	callout_init(&sc->sc_timer, CALLOUT_MPSAFE);
	callout_reset(&sc->sc_timer, hz*20, tda_timeout, sc);

	/* Initialise sensor data */
	sc->sc_sensor[SENSOR_FAN_CPU].state = ENVSYS_SINVALID;
	sc->sc_sensor[SENSOR_FAN_CPU].units = ENVSYS_INTEGER;
	sc->sc_sensor[SENSOR_FAN_CPU].flags = ENVSYS_FMONNOTSUPP;
	strlcpy(sc->sc_sensor[SENSOR_FAN_CPU].desc,
	    "fan.cpu",sizeof("fan.cpu"));
	sc->sc_sensor[SENSOR_FAN_SYS].state = ENVSYS_SINVALID;
	sc->sc_sensor[SENSOR_FAN_SYS].units = ENVSYS_INTEGER;
	sc->sc_sensor[SENSOR_FAN_SYS].flags = ENVSYS_FMONNOTSUPP;
	strlcpy(sc->sc_sensor[SENSOR_FAN_SYS].desc,
	    "fan.sys",sizeof("fan.sys"));
	sc->sc_sme = sysmon_envsys_create();
	if (sysmon_envsys_sensor_attach(
	    sc->sc_sme, &sc->sc_sensor[SENSOR_FAN_CPU])) {
		sysmon_envsys_destroy(sc->sc_sme);
		aprint_error_dev(self,
		    "unable to attach cpu fan at sysmon\n");
		return;
	}
	if (sysmon_envsys_sensor_attach(
	    sc->sc_sme, &sc->sc_sensor[SENSOR_FAN_SYS])) {
		sysmon_envsys_destroy(sc->sc_sme);
		aprint_error_dev(self,
		    "unable to attach sys fan at sysmon\n");
		return;
	}
        sc->sc_sme->sme_name = device_xname(self);
        sc->sc_sme->sme_cookie = sc;
        sc->sc_sme->sme_refresh = tda_refresh;
	if (sysmon_envsys_register(sc->sc_sme)) {
		aprint_error_dev(self,
		    "unable to register with sysmon\n");
		sysmon_envsys_destroy(sc->sc_sme);
		return;
	}
}
Exemplo n.º 2
0
static void
thinkpad_sensors_init(thinkpad_softc_t *sc)
{
	int i, j;

	if (sc->sc_ecdev == NULL)
		return;	/* no chance of this working */

	sc->sc_sme = sysmon_envsys_create();

	for (i = j = 0; i < THINKPAD_NTEMPSENSORS; i++) {

		sc->sc_sensor[i].units = ENVSYS_STEMP;
		sc->sc_sensor[i].state = ENVSYS_SINVALID;
		sc->sc_sensor[i].flags = ENVSYS_FHAS_ENTROPY;

		(void)snprintf(sc->sc_sensor[i].desc,
		    sizeof(sc->sc_sensor[i].desc), "temperature %d", i);

		if (sysmon_envsys_sensor_attach(sc->sc_sme,
			&sc->sc_sensor[i]) != 0)
			goto fail;
	}

	for (i = THINKPAD_NTEMPSENSORS; i < THINKPAD_NSENSORS; i++, j++) {

		sc->sc_sensor[i].units = ENVSYS_SFANRPM;
		sc->sc_sensor[i].state = ENVSYS_SINVALID;
		sc->sc_sensor[i].flags = ENVSYS_FHAS_ENTROPY;

		(void)snprintf(sc->sc_sensor[i].desc,
		    sizeof(sc->sc_sensor[i].desc), "fan speed %d", j);

		if (sysmon_envsys_sensor_attach(sc->sc_sme,
			&sc->sc_sensor[i]) != 0)
			goto fail;
	}

	sc->sc_sme->sme_name = device_xname(sc->sc_dev);
	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_refresh = thinkpad_sensors_refresh;

	if (sysmon_envsys_register(sc->sc_sme) != 0)
		goto fail;

	return;

fail:
	aprint_error_dev(sc->sc_dev, "failed to initialize sysmon\n");
	sysmon_envsys_destroy(sc->sc_sme);
	sc->sc_sme = NULL;
}
Exemplo n.º 3
0
static void
axp20x_attach(device_t parent, device_t self, void *aux)
{
    struct axp20x_softc *sc = device_private(self);
    struct i2c_attach_args *ia = aux;

    sc->sc_dev = self;
    sc->sc_i2c = ia->ia_tag;
    sc->sc_addr = ia->ia_addr;

    aprint_naive("\n");
    aprint_normal("\n");

    sc->sc_sme = sysmon_envsys_create();
    sc->sc_sme->sme_name = device_xname(self);
    sc->sc_sme->sme_cookie = sc;
    sc->sc_sme->sme_refresh = axp20x_sensors_refresh;

    sc->sc_sensor_temp.units = ENVSYS_STEMP;
    sc->sc_sensor_temp.state = ENVSYS_SINVALID;
    sc->sc_sensor_temp.flags = ENVSYS_FHAS_ENTROPY;
    snprintf(sc->sc_sensor_temp.desc, sizeof(sc->sc_sensor_temp.desc),
             "internal temperature");
    sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor_temp);

    sysmon_envsys_register(sc->sc_sme);
}
Exemplo n.º 4
0
static void
tmp121temp_attach(device_t parent, device_t self, void *aux)
{
	struct tmp121temp_softc *sc = device_private(self);
	struct spi_attach_args *sa = aux;

	aprint_naive(": Temperature Sensor\n");	
	aprint_normal(": TI TMP121 Temperature Sensor\n");

	sc->sc_sh = sa->sa_handle;

	sc->sc_sme = sysmon_envsys_create();
	sc->sc_sensor.units = ENVSYS_STEMP;
	strlcpy(sc->sc_sensor.desc, device_xname(self),
	    sizeof(sc->sc_sensor.desc));
	if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor)) {
		sysmon_envsys_destroy(sc->sc_sme);
		return;
	}

	sc->sc_sme->sme_name = device_xname(self);
	sc->sc_sme->sme_refresh = tmp121temp_refresh;
	sc->sc_sme->sme_cookie = sc;

	if (sysmon_envsys_register(sc->sc_sme)) {
		aprint_error_dev(self, "unable to register with sysmon\n");
		sysmon_envsys_destroy(sc->sc_sme);
	}
}
Exemplo n.º 5
0
static void
wmi_hp_switch_init(struct wmi_hp_softc *sc)
{
	int i, sensor[3];

	const char desc[][ENVSYS_DESCLEN] = {
		"wireless", "bluetooth", "mobile"
	};

	if (wmi_hp_method_read(sc, WMI_HP_METHOD_CMD_SWITCH) != true)
		return;

	sensor[0] = WMI_HP_SWITCH_WLAN;
	sensor[1] = WMI_HP_SWITCH_BT;
	sensor[2] = WMI_HP_SWITCH_WWAN;

	CTASSERT(WMI_HP_SENSOR_WLAN == 0);
	CTASSERT(WMI_HP_SENSOR_BT   == 1);
	CTASSERT(WMI_HP_SENSOR_WWAN == 2);

	for (i = 0; i < 3; i++) {

		if ((sc->sc_val & sensor[i]) == 0)
			continue;

		(void)strlcpy(sc->sc_sensor[i].desc, desc[i], ENVSYS_DESCLEN);

		sc->sc_sensor[i].state = ENVSYS_SINVALID;
		sc->sc_sensor[i].units = ENVSYS_INDICATOR;

		if (sysmon_envsys_sensor_attach(sc->sc_sme,
			&sc->sc_sensor[i]) != 0)
			break;
	}
}
Exemplo n.º 6
0
static void
tps65217pmic_envsys_register(struct tps65217pmic_softc *sc)
{
	int i;

	sc->sc_sme = sysmon_envsys_create();

	/* iterate over all regulators and attach them as sensors */
	for(i = 0; i <= SNUM_REGS; i++) {
		/* set name */
		strlcpy(sc->sc_regsensor[i].desc, tps_regulators[i].name,
		    sizeof(sc->sc_regsensor[i].desc));
		sc->sc_regsensor[i].units = ENVSYS_SVOLTS_DC;
		sc->sc_regsensor[i].state = ENVSYS_SINVALID;

		if (sysmon_envsys_sensor_attach(sc->sc_sme,
		    &sc->sc_regsensor[i]))
			aprint_error_dev(sc->sc_dev,
			    "error attaching regulator sensor %d\n", i);
	}

	/* attach power source indicators */
	strcpy(sc->sc_usbsensor.desc, "USB power source"); /* SNUM_USBSTATUS */
	sc->sc_usbsensor.units = ENVSYS_INDICATOR;
	sc->sc_usbsensor.state = ENVSYS_SINVALID; 
	if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_usbsensor))
		aprint_error_dev(sc->sc_dev, 
		    "error attaching USB power source sensor\n");
	strcpy(sc->sc_acsensor.desc, "AC power source"); /* SNUM_ACSTATUS */
	sc->sc_acsensor.units = ENVSYS_INDICATOR;
	sc->sc_acsensor.state = ENVSYS_SINVALID; 
	if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_acsensor))
		aprint_error_dev(sc->sc_dev, 
	 	    "error attaching AC power source sensor\n");

	/* register everything in sysmon */
	sc->sc_sme->sme_name = device_xname(sc->sc_dev);
	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_refresh = tps65217pmic_envsys_refresh;

	if (sysmon_envsys_register(sc->sc_sme)) {
		aprint_error_dev(sc->sc_dev, "unable to register in sysmon\n");
		sysmon_envsys_destroy(sc->sc_sme);
	}
}
Exemplo n.º 7
0
static void
adm1026_setup_temps(struct adm1026_softc *sc)
{
	int i;
	uint8_t val;

	/* Temperature offsets */
	if (adm1026_read_reg(sc, ADM1026_INT_TEMP_OFF, &val)
	    != 0) {
		aprint_error_dev(sc->sc_dev, "unable to read int temp. off.\n");
		return;
	}
	if (val & 0x80)
		sc->sc_temp_off[0] = 0 - 1000000 * (val & 0x7f);
	else
		sc->sc_temp_off[0] = 1000000 * (val & 0x7f);
	if (adm1026_read_reg(sc, ADM1026_TDM1_OFF, &val) != 0) {
		aprint_error_dev(sc->sc_dev, "unable to read tdm1 off.\n");
		return;
	}
	if (val & 0x80)
		sc->sc_temp_off[1] = 0 - 1000000 * (val & 0x7f);
	else
		sc->sc_temp_off[1] = 1000000 * (val & 0x7f);
	if (adm1026_read_reg(sc, ADM1026_TDM2_OFF, &val) != 0) {
		aprint_error_dev(sc->sc_dev, "unable to read tdm2 off.\n");
		return;
	}
	if (val & 0x80)
		sc->sc_temp_off[2] = 0 - 1000000 * (val & 0x7f);
	else
		sc->sc_temp_off[2] = 1000000 * (val & 0x7f);

	strlcpy(sc->sc_sensor[ADM1026_TEMP_NUM(0)].desc, "internal", 
	    sizeof(sc->sc_sensor[ADM1026_TEMP_NUM(0)].desc));
	strlcpy(sc->sc_sensor[ADM1026_TEMP_NUM(1)].desc, "external 1",
	    sizeof(sc->sc_sensor[ADM1026_TEMP_NUM(1)].desc));
	strlcpy(sc->sc_sensor[ADM1026_TEMP_NUM(2)].desc, "external 2",
	    sizeof(sc->sc_sensor[ADM1026_TEMP_NUM(2)].desc));
	for (i = 0; i < ADM1026_MAX_TEMPS; i++) {
		/* Check configuration1 register to see if TDM2 is configured */
		if (i == 2 && !ADM1026_PIN_IS_TDM2(sc->sc_cfg[0]))
			continue;
		sc->sc_sensor[ADM1026_TEMP_NUM(i)].units = ENVSYS_STEMP;
		sc->sc_sensor[ADM1026_TEMP_NUM(i)].state = ENVSYS_SINVALID;
		sc->sc_ntemps++;
		if (sysmon_envsys_sensor_attach(
		    sc->sc_sme, &sc->sc_sensor[ADM1026_TEMP_NUM(i)])) {
			sysmon_envsys_destroy(sc->sc_sme);
			aprint_error_dev(sc->sc_dev,
			    "unable to attach temp %d at sysmon\n", i);
			return;
		}
	}
}
Exemplo n.º 8
0
static void
thinkpad_sensors_init(thinkpad_softc_t *sc)
{
	char sname[5] = "TMP?";
	char fname[5] = "FAN?";
	int i, j, err;

	if (sc->sc_ecdev == NULL)
		return;	/* no chance of this working */

	sc->sc_sme = sysmon_envsys_create();
	for (i = 0; i < THINKPAD_NTEMPSENSORS; i++) {
		sname[3] = '0' + i;
		strcpy(sc->sc_sensor[i].desc, sname);
		sc->sc_sensor[i].units = ENVSYS_STEMP;

		if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor[i]))
			aprint_error_dev(sc->sc_dev,
			    "couldn't attach sensor %s\n", sname);
	}
	j = i; /* THINKPAD_NTEMPSENSORS */
	for (; i < (j + THINKPAD_NFANSENSORS); i++) {
		fname[3] = '0' + (i - j);
		strcpy(sc->sc_sensor[i].desc, fname);
		sc->sc_sensor[i].units = ENVSYS_SFANRPM;

		if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor[i]))
			aprint_error_dev(sc->sc_dev,
			    "couldn't attach sensor %s\n", fname);
	}

	sc->sc_sme->sme_name = device_xname(sc->sc_dev);
	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_refresh = thinkpad_sensors_refresh;

	err = sysmon_envsys_register(sc->sc_sme);
	if (err) {
		aprint_error_dev(sc->sc_dev,
		    "couldn't register with sysmon: %d\n", err);
		sysmon_envsys_destroy(sc->sc_sme);
	}
}
Exemplo n.º 9
0
static void
hytp14_attach(device_t parent, device_t self, void *aux)
{
	struct hytp14_sc *sc = device_private(self);
	struct i2c_attach_args *ia = aux;
	int i;

	sc->sc_dev = self;
	sc->sc_tag = ia->ia_tag;
	sc->sc_addr = ia->ia_addr;
	sc->sc_refresh = 0;
	sc->sc_valid = ENVSYS_SINVALID;
	sc->sc_numsensors = __arraycount(hytp14_sensors);

	if ((sc->sc_sme = sysmon_envsys_create()) == NULL) {
		aprint_error_dev(sc->sc_dev,
		    "unable to create sysmon structure\n");
		return;
	}
	
	for (i = 0; i < sc->sc_numsensors; i++) {
		strlcpy(sc->sc_sensors[i].desc,
			hytp14_sensors[i].desc,
			sizeof sc->sc_sensors[i].desc);
		
		sc->sc_sensors[i].units = hytp14_sensors[i].type;
		sc->sc_sensors[i].state = ENVSYS_SINVALID;
		
		DPRINTF(2, ("hytp14_attach: registering sensor %d (%s)\n", i,
			    sc->sc_sensors[i].desc));
		
		if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensors[i])) {
			aprint_error_dev(sc->sc_dev,
			    "unable to attach sensor\n");
			sysmon_envsys_destroy(sc->sc_sme);
			return;
		}
	}

	sc->sc_sme->sme_name = device_xname(sc->sc_dev);
	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_refresh = hytp14_refresh;

	DPRINTF(2, ("hytp14_attach: registering with envsys\n"));

	if (sysmon_envsys_register(sc->sc_sme)) {
		aprint_error_dev(sc->sc_dev,
		    "unable to register with sysmon\n");
		sysmon_envsys_destroy(sc->sc_sme);
		return;
	}

	aprint_normal(": HYT-221/271/939 humidity and temperature sensor\n");
}
Exemplo n.º 10
0
static void
adm1026_setup_fans(struct adm1026_softc *sc, int div2_val)
{
	int i, err = 0;
	uint8_t div1, div2;

	/* Read fan-related registers (configuration and divisors) */
	if ((err = adm1026_read_reg(sc, ADM1026_CONF2, &sc->sc_cfg[1])) != 0) {
		aprint_error_dev(sc->sc_dev, "unable to read conf2\n");
		return;
	}
	if ((err = adm1026_read_reg(sc, ADM1026_FAN_DIV1, &div1)) != 0) {
		aprint_error_dev(sc->sc_dev, "unable to read fan_div1\n");
		return;
	}
	sc->sc_fandiv[0] = 1 << ADM1026_FAN0_DIV(div1);
	sc->sc_fandiv[1] = 1 << ADM1026_FAN1_DIV(div1);
	sc->sc_fandiv[2] = 1 << ADM1026_FAN2_DIV(div1);
	sc->sc_fandiv[3] = 1 << ADM1026_FAN3_DIV(div1);
	if (div2_val < 0) {
		if ((err =
		    adm1026_read_reg(sc, ADM1026_FAN_DIV2, &div2)) != 0) {
			aprint_error_dev(sc->sc_dev,
			    "unable to read fan_div2\n");
			return;
		}
	} else
		div2 = div2_val;
	sc->sc_fandiv[4] = 1 << ADM1026_FAN4_DIV(div2);
	sc->sc_fandiv[5] = 1 << ADM1026_FAN5_DIV(div2);
	sc->sc_fandiv[6] = 1 << ADM1026_FAN6_DIV(div2);
	sc->sc_fandiv[7] = 1 << ADM1026_FAN7_DIV(div2);

	for (i = 0; i < ADM1026_MAX_FANS; i++) {
		sc->sc_sensor[ADM1026_FAN_NUM(i)].state = ENVSYS_SINVALID;
		/* Check configuration2 register to see which pins are fans. */
		if (ADM1026_PIN_IS_FAN(sc->sc_cfg[1], i)) {
			sc->sc_sensor[ADM1026_FAN_NUM(i)].units =
			    ENVSYS_SFANRPM;
			snprintf(sc->sc_sensor[ADM1026_FAN_NUM(i)].desc,
			    sizeof(sc->sc_sensor[ADM1026_FAN_NUM(i)].desc),
			    "fan %d", ADM1026_FAN_NUM(i));
			sc->sc_nfans++;
			if (sysmon_envsys_sensor_attach(
			    sc->sc_sme, &sc->sc_sensor[ADM1026_FAN_NUM(i)])) {
				sysmon_envsys_destroy(sc->sc_sme);
				aprint_error_dev(sc->sc_dev,
				    "unable to attach fan %d at sysmon\n", i);
				return;
			}
		}
	}
}
Exemplo n.º 11
0
static void
asus_attach(device_t parent, device_t self, void *opaque)
{
	struct asus_softc *sc = device_private(self);
	struct acpi_attach_args *aa = opaque;

	sc->sc_dev = self;
	sc->sc_node = aa->aa_node;

	aprint_naive("\n");
	aprint_normal("\n");

	asus_init(self);
	asus_sysctl_setup(sc);

	sc->sc_smpsw_valid = true;
	sc->sc_smpsw[ASUS_PSW_DISPLAY_CYCLE].smpsw_name =
	    PSWITCH_HK_DISPLAY_CYCLE;
	sc->sc_smpsw[ASUS_PSW_DISPLAY_CYCLE].smpsw_type =
	    PSWITCH_TYPE_HOTKEY;
	if (sysmon_pswitch_register(&sc->sc_smpsw[ASUS_PSW_DISPLAY_CYCLE])) {
		aprint_error_dev(self, "couldn't register with sysmon\n");
		sc->sc_smpsw_valid = false;
	}

	if (asus_get_fan_speed(sc, NULL) == false)
		goto out;

	sc->sc_sme = sysmon_envsys_create();

	strcpy(sc->sc_sensor[ASUS_SENSOR_FAN].desc, "fan");
	sc->sc_sensor[ASUS_SENSOR_FAN].units = ENVSYS_SFANRPM;
	sc->sc_sensor[ASUS_SENSOR_FAN].state = ENVSYS_SINVALID;
	sysmon_envsys_sensor_attach(sc->sc_sme,
	    &sc->sc_sensor[ASUS_SENSOR_FAN]);

	sc->sc_sme->sme_name = device_xname(self);
	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_refresh = asus_sensors_refresh;
	sc->sc_sme->sme_flags = SME_POLL_ONLY;

	if (sysmon_envsys_register(sc->sc_sme)) {
		aprint_error_dev(self, "couldn't register with envsys\n");
		sysmon_envsys_destroy(sc->sc_sme);
		sc->sc_sme = NULL;
	}

out:
	(void)pmf_device_register(self, asus_suspend, asus_resume);
	(void)acpi_register_notify(sc->sc_node, asus_notify_handler);
}
Exemplo n.º 12
0
static void
apple_smc_fan_attach_sensor(struct apple_smc_fan_softc *sc, uint8_t fan,
    const char *name, uint8_t sensor)
{
	char key_name[4 + 1];
	struct apple_smc_key **keyp;
	struct envsys_data *edata;
	int error;

	KASSERT(fan < sc->sc_nfans);
	KASSERT(sensor < __arraycount(fan_sensors));

	/* Format the name of the key for this fan sensor.   */
	(void)snprintf(key_name, sizeof(key_name), "F%d%s",
	    (int)sensor, fan_sensors[sensor].fs_key_suffix);
	KASSERT(strlen(key_name) == 4);

	/* Look up the key for this fan sensor. */
	keyp = &sc->sc_fans[fan].sensors[sensor].sensor_key;
	error = apple_smc_named_key(sc->sc_smc, key_name, APPLE_SMC_TYPE_FPE2,
	    keyp);
	if (error)
		goto fail0;

	/* Initialize the envsys_data record for this fan sensor.  */
	edata = &sc->sc_fans[fan].sensors[sensor].sensor_data;
	edata->units = ENVSYS_SFANRPM;
	edata->state = ENVSYS_SINVALID;
	edata->flags = ENVSYS_FHAS_ENTROPY;
	(void)snprintf(edata->desc, sizeof(edata->desc), "fan %s %s speed",
	    name, fan_sensors[sensor].fs_name);

	/* Attach this fan sensor to sysmon_envsys.  */
	error = sysmon_envsys_sensor_attach(sc->sc_sme, edata);
	if (error)
		goto fail1;

	/* Success!  */
	return;

fail1:	apple_smc_release_key(sc->sc_smc, *keyp);
fail0:	*keyp = NULL;
	aprint_error_dev(sc->sc_dev,
	    "failed to attach fan %s %s speed sensor: %d\n",
	    name, fan_sensors[sensor].fs_name, error);
}
Exemplo n.º 13
0
static void
owtemp_attach(device_t parent, device_t self, void *aux)
{
	struct owtemp_softc *sc = device_private(self);
	struct onewire_attach_args *oa = aux;

	aprint_naive("\n");

	sc->sc_onewire = oa->oa_onewire;
	sc->sc_rom = oa->oa_rom;

	switch(ONEWIRE_ROM_FAMILY_TYPE(sc->sc_rom)) {
	case ONEWIRE_FAMILY_DS18B20:
	case ONEWIRE_FAMILY_DS1822:
		sc->sc_owtemp_decode = owtemp_decode_ds18b20;
		break;
	case ONEWIRE_FAMILY_DS1920:
		sc->sc_owtemp_decode = owtemp_decode_ds1920;
		break;
	}

	sc->sc_sme = sysmon_envsys_create();

	/* Initialize sensor */
	sc->sc_sensor.units = ENVSYS_STEMP;
	sc->sc_sensor.state = ENVSYS_SINVALID;
	(void)strlcpy(sc->sc_sensor.desc,
	    device_xname(self), sizeof(sc->sc_sensor.desc));
	if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor)) {
		sysmon_envsys_destroy(sc->sc_sme);
		return;
	}

	/* Hook into system monitor. */
	sc->sc_sme->sme_name = device_xname(self);
	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_refresh = owtemp_refresh;

	if (sysmon_envsys_register(sc->sc_sme)) {
		aprint_error_dev(self, "unable to register with sysmon\n");
		sysmon_envsys_destroy(sc->sc_sme);
		return;
	}

	aprint_normal("\n");
}
Exemplo n.º 14
0
Arquivo: cac.c Projeto: ryo/netbsd-src
int
cac_create_sensors(struct cac_softc *sc)
{
	int			i;
	int nsensors = sc->sc_nunits;

	sc->sc_sme = sysmon_envsys_create();
	sc->sc_sensor = malloc(sizeof(envsys_data_t) * nsensors,
	    M_DEVBUF, M_NOWAIT | M_ZERO);
	if (sc->sc_sensor == NULL) {
		aprint_error_dev(sc->sc_dev, "can't allocate envsys_data_t\n");
		return(ENOMEM);
	}

	for (i = 0; i < nsensors; i++) {
		sc->sc_sensor[i].units = ENVSYS_DRIVE;
		sc->sc_sensor[i].state = ENVSYS_SINVALID;
		sc->sc_sensor[i].value_cur = ENVSYS_DRIVE_EMPTY;
		/* Enable monitoring for drive state changes */
		sc->sc_sensor[i].flags |= ENVSYS_FMONSTCHANGED;
		/* logical drives */
		snprintf(sc->sc_sensor[i].desc,
		    sizeof(sc->sc_sensor[i].desc), "%s:%d",
		    device_xname(sc->sc_dev), i);
		if (sysmon_envsys_sensor_attach(sc->sc_sme,
		    &sc->sc_sensor[i]))
			goto out;
	}
	sc->sc_sme->sme_name = device_xname(sc->sc_dev);
	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_refresh = cac_sensor_refresh;
	if (sysmon_envsys_register(sc->sc_sme)) {
		aprint_error_dev(sc->sc_dev, "unable to register with sysmon\n");
		return(1);
	}
	return (0);

out:
	free(sc->sc_sensor, M_DEVBUF);
	sysmon_envsys_destroy(sc->sc_sme);
	return EINVAL;
}
Exemplo n.º 15
0
static void
omap3_scm_sensor_attach(struct omap3_scm_softc *sc)
{
	uint32_t ctrl;

	/* Enable single conversion mode */
	ctrl = SCM_READ_REG(sc, CONTROL_TEMP_SENSOR);
	ctrl &= ~CONTROL_TEMP_SENSOR_CONTCONV;
	SCM_WRITE_REG(sc, CONTROL_TEMP_SENSOR, ctrl);

	sc->sc_sme = sysmon_envsys_create();
	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_name = device_xname(sc->sc_dev);
	sc->sc_sme->sme_refresh = omap3_scm_sensor_refresh;
	sc->sc_sensor.units = ENVSYS_STEMP;
	sc->sc_sensor.state = ENVSYS_SINVALID;
	sc->sc_sensor.flags = ENVSYS_FHAS_ENTROPY;
	strlcpy(sc->sc_sensor.desc, "TEMP", sizeof(sc->sc_sensor.desc));
	sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor);
	sysmon_envsys_register(sc->sc_sme);
}
Exemplo n.º 16
0
static void
vcmbox_create_sensors(struct vcmbox_softc *sc)
{
	uint32_t val;

	sc->sc_sensor[VCMBOX_SENSOR_TEMP].sensor = VCMBOX_SENSOR_TEMP;
	sc->sc_sensor[VCMBOX_SENSOR_TEMP].units = ENVSYS_STEMP;
	sc->sc_sensor[VCMBOX_SENSOR_TEMP].state = ENVSYS_SINVALID;
	sc->sc_sensor[VCMBOX_SENSOR_TEMP].flags = ENVSYS_FMONLIMITS |
						  ENVSYS_FHAS_ENTROPY;
	strlcpy(sc->sc_sensor[VCMBOX_SENSOR_TEMP].desc,
	    vcmbox_sensor_name[VCMBOX_SENSOR_TEMP],
	    sizeof(sc->sc_sensor[VCMBOX_SENSOR_TEMP].desc));
	if (vcmbox_read_temp(sc, VCPROPTAG_GET_MAX_TEMPERATURE,
			     vcmbox_sensor_id[VCMBOX_SENSOR_TEMP], &val) == 0) {
		sc->sc_sensor[VCMBOX_SENSOR_TEMP].value_max =
		    val * 1000 + 273150000;
		sc->sc_sensor[VCMBOX_SENSOR_TEMP].flags |= ENVSYS_FVALID_MAX;
	}
	sysmon_envsys_sensor_attach(sc->sc_sme,
	    &sc->sc_sensor[VCMBOX_SENSOR_TEMP]);
}
Exemplo n.º 17
0
static void
battery_setup_envsys(struct battery_softc *sc)
{
	int i;

	sc->sc_sme = sysmon_envsys_create();

	INITDATA(BAT_CPU_TEMPERATURE, ENVSYS_STEMP, "CPU temperature");
	INITDATA(BAT_AC_PRESENT, ENVSYS_INDICATOR, "AC present");
	INITDATA(BAT_PRESENT, ENVSYS_INDICATOR, "Battery present");
	INITDATA(BAT_VOLTAGE, ENVSYS_SVOLTS_DC, "Battery voltage");
	INITDATA(BAT_CHARGE, ENVSYS_SAMPHOUR, "Battery charge");
	INITDATA(BAT_MAX_CHARGE, ENVSYS_SAMPHOUR, "Battery design cap");
	INITDATA(BAT_CURRENT, ENVSYS_SAMPS, "Battery current");
	INITDATA(BAT_TEMPERATURE, ENVSYS_STEMP, "Battery temperature");
	INITDATA(BAT_CHARGING, ENVSYS_BATTERY_CHARGE, "Battery charging");
	INITDATA(BAT_FULL, ENVSYS_INDICATOR, "Battery full");
#undef INITDATA

	for (i = 0; i < BAT_NSENSORS; i++) {
		if (sysmon_envsys_sensor_attach(sc->sc_sme,
						&sc->sc_sensor[i])) {
			sysmon_envsys_destroy(sc->sc_sme);
			return;
		}
	}

	sc->sc_sme->sme_name = sc->sc_dev.dv_xname;
	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_refresh = battery_refresh;

	if (sysmon_envsys_register(sc->sc_sme)) {
		aprint_error("%s: unable to register with sysmon\n",
		    sc->sc_dev.dv_xname);
		sysmon_envsys_destroy(sc->sc_sme);
	}
}
Exemplo n.º 18
0
static void
adm1026_setup_volts(struct adm1026_softc *sc)
{
	int i;

	for (i = 0; i < ADM1026_MAX_VOLTS; i++) {
		/* Check configuration1 register to see if TDM2 is configured */
		if (adm1026_volts_table[i].check_tdm2 &&
		    ADM1026_PIN_IS_TDM2(sc->sc_cfg[0]))
			continue;
		strlcpy(sc->sc_sensor[ADM1026_VOLT_NUM(i)].desc,
		    adm1026_volts_table[i].desc,
		    sizeof(sc->sc_sensor[ADM1026_VOLT_NUM(i)].desc));
		sc->sc_sensor[ADM1026_VOLT_NUM(i)].units = ENVSYS_SVOLTS_DC;
		sc->sc_sensor[ADM1026_VOLT_NUM(i)].state = ENVSYS_SINVALID;
		if (sysmon_envsys_sensor_attach(
		    sc->sc_sme, &sc->sc_sensor[ADM1026_VOLT_NUM(i)])) {
			sysmon_envsys_destroy(sc->sc_sme);
			aprint_error_dev(sc->sc_dev,
			    "unable to attach volts %d at sysmon\n", i);
			return;
		}
	}
}
static void
acpitz_init_envsys(device_t dv)
{
    const int flags = ENVSYS_FMONLIMITS | ENVSYS_FMONNOTSUPP |
                      ENVSYS_FHAS_ENTROPY;
    struct acpitz_softc *sc = device_private(dv);
    unsigned int i;

    sc->sc_sme = sysmon_envsys_create();

    sc->sc_sme->sme_cookie = sc;
    sc->sc_sme->sme_name = device_xname(dv);
    sc->sc_sme->sme_flags = SME_DISABLE_REFRESH;
    sc->sc_sme->sme_get_limits = acpitz_get_limits;

    sc->sc_temp_sensor.flags = flags;
    sc->sc_temp_sensor.units = ENVSYS_STEMP;
    sc->sc_temp_sensor.state = ENVSYS_SINVALID;

    memset(sc->sc_temp_sensor.desc, 0, sizeof(sc->sc_temp_sensor.desc));
    if (sc->sc_psl) {
        for (i = 0; sc->sc_psl[i] != NULL; i++) {
            if (i > 0)
                strlcat(sc->sc_temp_sensor.desc, "/",
                        sizeof(sc->sc_temp_sensor.desc));
            strlcat(sc->sc_temp_sensor.desc,
                    device_xname(sc->sc_psl[i]->ci_dev),
                    sizeof(sc->sc_temp_sensor.desc));
        }
        strlcat(sc->sc_temp_sensor.desc, " ",
                sizeof(sc->sc_temp_sensor.desc));
    }
    strlcat(sc->sc_temp_sensor.desc, "temperature",
            sizeof(sc->sc_temp_sensor.desc));

    if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_temp_sensor))
        goto out;

    if (sc->sc_have_fan != false) {

        sc->sc_fan_sensor.flags = flags;
        sc->sc_fan_sensor.units = ENVSYS_SFANRPM;
        sc->sc_fan_sensor.state = ENVSYS_SINVALID;

        (void)strlcpy(sc->sc_fan_sensor.desc,
                      "FAN", sizeof(sc->sc_fan_sensor.desc));

        /* Ignore error because fan sensor is optional. */
        (void)sysmon_envsys_sensor_attach(sc->sc_sme,
                                          &sc->sc_fan_sensor);
    }

    if (sysmon_envsys_register(sc->sc_sme) == 0)
        return;

out:
    aprint_error_dev(dv, "unable to register with sysmon\n");

    sysmon_envsys_destroy(sc->sc_sme);
    sc->sc_sme = NULL;
}
Exemplo n.º 20
0
static void
aps_attach(device_t parent, device_t self, void *aux)
{
	struct aps_softc *sc = device_private(self);
	struct isa_attach_args *ia = aux;
	int iobase, i;

	sc->sc_iot = ia->ia_iot;
	iobase = ia->ia_io[0].ir_addr;

	if (bus_space_map(sc->sc_iot, iobase, APS_ADDR_SIZE, 0, &sc->sc_ioh)) {
		aprint_error(": can't map i/o space\n");
		return;
	}

	aprint_naive("\n");
	aprint_normal("\n");

	if (!aps_init(sc)) {
		aprint_error_dev(self, "failed to initialise\n");
		goto out;
	}

	/* Initialize sensors */
#define INITDATA(idx, unit, string)					\
	sc->sc_sensor[idx].units = unit;				\
	strlcpy(sc->sc_sensor[idx].desc, string,			\
	    sizeof(sc->sc_sensor[idx].desc));

	INITDATA(APS_SENSOR_XACCEL, ENVSYS_INTEGER, "X_ACCEL");
	INITDATA(APS_SENSOR_YACCEL, ENVSYS_INTEGER, "Y_ACCEL");
	INITDATA(APS_SENSOR_TEMP1, ENVSYS_STEMP, "TEMP_1");
	INITDATA(APS_SENSOR_TEMP2, ENVSYS_STEMP, "TEMP_2");
	INITDATA(APS_SENSOR_XVAR, ENVSYS_INTEGER, "X_VAR");
	INITDATA(APS_SENSOR_YVAR, ENVSYS_INTEGER, "Y_VAR");
	INITDATA(APS_SENSOR_KBACT, ENVSYS_INDICATOR, "Keyboard Active");
	INITDATA(APS_SENSOR_MSACT, ENVSYS_INDICATOR, "Mouse Active");
	INITDATA(APS_SENSOR_LIDOPEN, ENVSYS_INDICATOR, "Lid Open");

	sc->sc_sme = sysmon_envsys_create();
	for (i = 0; i < APS_NUM_SENSORS; i++) {
		sc->sc_sensor[i].state = ENVSYS_SVALID;
		if (sysmon_envsys_sensor_attach(sc->sc_sme,
						&sc->sc_sensor[i])) {
			sysmon_envsys_destroy(sc->sc_sme);
			goto out;
		}
	}
        /*
         * Register with the sysmon_envsys(9) framework.
         */
	sc->sc_sme->sme_name = device_xname(self);
	sc->sc_sme->sme_flags = SME_DISABLE_REFRESH;

	if ((i = sysmon_envsys_register(sc->sc_sme))) {
		aprint_error_dev(self,
		    "unable to register with sysmon (%d)\n", i);
		sysmon_envsys_destroy(sc->sc_sme);
		goto out;
	}

	if (!pmf_device_register(self, aps_suspend, aps_resume))
		aprint_error_dev(self, "couldn't establish power handler\n");

	/* Refresh sensor data every 0.5 seconds */
	callout_init(&sc->sc_callout, 0);
	callout_setfunc(&sc->sc_callout, aps_refresh, sc);
	callout_schedule(&sc->sc_callout, (hz) / 2);

        aprint_normal_dev(self, "Thinkpad Active Protection System\n");
	return;

out:
	bus_space_unmap(sc->sc_iot, sc->sc_ioh, APS_ADDR_SIZE);
}
Exemplo n.º 21
0
/*
 * Get the base address for the monitoring registers and set up the
 * sysmon_envsys(9) framework.
 */
static void
smsc_attach(device_t parent, device_t self, void *aux)
{
	struct smsc_softc *sc = device_private(self);
	struct isa_attach_args *ia = aux;
	bus_space_handle_t ioh;
	uint8_t rev, msb, lsb, chipid;
	unsigned address;
	int i;

	sc->sc_iot = ia->ia_iot;

	aprint_naive("\n");

	/* 
	 * To attach we need to find the actual Hardware Monitor
	 * I/O address space.
	 */
	if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, 2, 0,
	    &ioh)) {
		aprint_error(": can't map base i/o space\n");
		return;
	}

	/* Enter config mode */
	bus_space_write_1(ia->ia_iot, ioh, SMSC_ADDR, SMSC_CONFIG_START);

	/* 
	 * While we have the base registers mapped, grab the chip
	 * revision and device ID.
	 */
	rev = smsc_readreg(ia->ia_iot, ioh, SMSC_DEVICE_REVISION);
	chipid = smsc_readreg(ia->ia_iot, ioh, SMSC_DEVICE_ID);

	/* Select the Hardware Monitor LDN */
	smsc_writereg(ia->ia_iot, ioh, SMSC_LOGICAL_DEV_SEL,
	    SMSC_LOGICAL_DEVICE);

	/* Read the base address for the registers. */
	msb = smsc_readreg(ia->ia_iot, ioh, SMSC_IO_BASE_MSB);
	lsb = smsc_readreg(ia->ia_iot, ioh, SMSC_IO_BASE_LSB);
	address = (msb << 8) | lsb;

	/* Exit config mode */
	bus_space_write_1(ia->ia_iot, ioh, SMSC_ADDR, SMSC_CONFIG_END);
	bus_space_unmap(ia->ia_iot, ioh, 2);

	/* Map the Hardware Monitor I/O space. */
	if (bus_space_map(ia->ia_iot, address, 2, 0, &sc->sc_ioh)) {
		aprint_error(": can't map register i/o space\n");
		return;
	}

	sc->sc_sme = sysmon_envsys_create();

#define INITSENSOR(index, string, reg, type) 			\
	do {							\
		strlcpy(sc->sc_sensor[index].desc, string,	\
		    sizeof(sc->sc_sensor[index].desc));		\
		sc->sc_sensor[index].units = type;		\
		sc->sc_regs[index] = reg;			\
		sc->sc_sensor[index].state = ENVSYS_SVALID;	\
	} while (/* CONSTCOND */ 0)

	/* Temperature sensors */
	INITSENSOR(0, "Temp0", SMSC_TEMP1, ENVSYS_STEMP);
	INITSENSOR(1, "Temp1", SMSC_TEMP2, ENVSYS_STEMP);
	INITSENSOR(2, "Temp2", SMSC_TEMP3, ENVSYS_STEMP);
	INITSENSOR(3, "Temp3", SMSC_TEMP4, ENVSYS_STEMP);
	
	/* Fan sensors */
	INITSENSOR(4, "Fan0", SMSC_FAN1_LSB, ENVSYS_SFANRPM);
	INITSENSOR(5, "Fan1", SMSC_FAN2_LSB, ENVSYS_SFANRPM);
	INITSENSOR(6, "Fan2", SMSC_FAN3_LSB, ENVSYS_SFANRPM);
	INITSENSOR(7, "Fan3", SMSC_FAN4_LSB, ENVSYS_SFANRPM);

	for (i = 0; i < SMSC_MAX_SENSORS; i++) {
		sc->sc_sensor[i].state = ENVSYS_SINVALID;
		if (sysmon_envsys_sensor_attach(sc->sc_sme,
						&sc->sc_sensor[i])) {
			sysmon_envsys_destroy(sc->sc_sme);
			bus_space_unmap(sc->sc_iot, sc->sc_ioh, 2);
			return;
		}
	}

	sc->sc_sme->sme_name = device_xname(self);
	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_refresh = smsc_refresh;

	if ((i = sysmon_envsys_register(sc->sc_sme)) != 0) {
		aprint_error(": unable to register with sysmon (%d)\n", i);
		sysmon_envsys_destroy(sc->sc_sme);
		bus_space_unmap(sc->sc_iot, sc->sc_ioh, 2);
		return;
	}

	switch (chipid) {
	case SMSC_ID_47B397:
		aprint_normal(": SMSC LPC47B397 Super I/O");
		break;
	case SMSC_ID_SCH5307NS:
		aprint_normal(": SMSC SCH5307-NS Super I/O");
		break;
	case SMSC_ID_SCH5317:
		aprint_normal(": SMSC SCH5317 Super I/O");
		break;
	}

	aprint_normal(" (rev %u)\n", rev);
	aprint_normal_dev(self, "Hardware Monitor registers at 0x%04x\n",
	    address);
}
Exemplo n.º 22
0
static void
wmi_hp_sensor_init(struct wmi_hp_softc *sc)
{
	int sensor;

	KDASSERT(sc->sc_sme == NULL);
	KDASSERT(sc->sc_sensor != NULL);

	(void)memset(sc->sc_sensor, 0, WMI_HP_SENSOR_SIZE);

	sc->sc_sme = sysmon_envsys_create();

	wmi_hp_switch_init(sc);

	if (wmi_hp_method_read(sc, WMI_HP_METHOD_CMD_HDDTEMP) == true) {
		sensor = WMI_HP_SENSOR_HDDTEMP;
		(void)strlcpy(sc->sc_sensor[sensor].desc, "hddtemp",
		    ENVSYS_DESCLEN);
		sc->sc_sensor[sensor].state = ENVSYS_SVALID;
		sc->sc_sensor[sensor].units = ENVSYS_STEMP;
		sc->sc_sensor[sensor].value_cur =
		    sc->sc_val * 1000000 + 273150000;

		sysmon_envsys_sensor_attach(sc->sc_sme,
			&sc->sc_sensor[sensor]);
	}

	if (wmi_hp_method_read(sc, WMI_HP_METHOD_CMD_DISPLAY) == true) {
		sensor = WMI_HP_SENSOR_DISPLAY;
		(void)strlcpy(sc->sc_sensor[sensor].desc, "display",
		    ENVSYS_DESCLEN);
		sc->sc_sensor[sensor].state = ENVSYS_SVALID;
		sc->sc_sensor[sensor].units = ENVSYS_INDICATOR;
		sc->sc_sensor[sensor].value_cur = sc->sc_val;
		
		sysmon_envsys_sensor_attach(sc->sc_sme,
			&sc->sc_sensor[sensor]);
	}

	if (wmi_hp_method_read(sc, WMI_HP_METHOD_CMD_DOCK) == true) {
		sensor = WMI_HP_SENSOR_DOCK;
		(void)strlcpy(sc->sc_sensor[sensor].desc, "docking station",
		    ENVSYS_DESCLEN);
		sc->sc_sensor[sensor].state = ENVSYS_SVALID;
		sc->sc_sensor[sensor].units = ENVSYS_INDICATOR;
		sc->sc_sensor[sensor].value_cur = sc->sc_val;
		
		sysmon_envsys_sensor_attach(sc->sc_sme,
			&sc->sc_sensor[sensor]);
	}

	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_refresh = wmi_hp_sensor_refresh;
	sc->sc_sme->sme_name = device_xname(sc->sc_dev);

	if (sysmon_envsys_register(sc->sc_sme) != 0)
		goto fail;

	wmi_hp_sensor_switch_update(sc->sc_dev);

	return;

fail:
	aprint_debug_dev(sc->sc_dev, "failed to initialize sysmon\n");

	sysmon_envsys_destroy(sc->sc_sme);
	kmem_free(sc->sc_sensor, WMI_HP_SENSOR_SIZE);

	sc->sc_sme = NULL;
	sc->sc_sensor = NULL;
}
Exemplo n.º 23
0
static void
ecadc_attach(device_t parent, device_t self, void *aux)
{
	struct i2c_attach_args *ia = aux;
	struct ecadc_softc *sc = device_private(self);
	u_char term[256];
	u_char *cp, *desc;
	int64_t minv, warnv, crit, num, den;
	u_int8_t junk[PCF8591_CHANNELS + 1];
	envsys_data_t *sensor;
	int len, error, addr, chan, node = (int)ia->ia_cookie;
	u_int i;

	sc->sc_dev = self;
	if ((len = OF_getprop(node, "thermisters", term,
	    sizeof(term))) < 0) {
		aprint_error(": couldn't find \"thermisters\" property\n");
		return;
	}

	if (OF_getprop(node, "cpu-temp-factors", &sc->sc_cpu_xlate[2],
	    sizeof(sc->sc_cpu_xlate) - 2) < 0) {
		aprint_error(": couldn't find \"cpu-temp-factors\" property\n");
		return;
	}
	sc->sc_cpu_xlate[0] = sc->sc_cpu_xlate[1] = sc->sc_cpu_xlate[2];

	/* Only the Sun Enterprise 450 has these. */
	OF_getprop(node, "ps-temp-factors", &sc->sc_ps_xlate[2],
	    sizeof(sc->sc_ps_xlate) - 2);
	sc->sc_ps_xlate[0] = sc->sc_ps_xlate[1] = sc->sc_ps_xlate[2];

	cp = term;
	while (cp < term + len) {
		addr = cp[0] << 24 | cp[1] << 16 | cp[2] << 8 | cp[3]; cp += 4;
		chan = cp[0] << 24 | cp[1] << 16 | cp[2] << 8 | cp[3]; cp += 4;
		minv = cp[0] << 24 | cp[1] << 16 | cp[2] << 8 | cp[3]; cp += 4;
		warnv = cp[0] << 24 | cp[1] << 16 | cp[2] << 8 | cp[3]; cp += 4;
		crit = cp[0] << 24 | cp[1] << 16 | cp[2] << 8 | cp[3]; cp += 4;
		num = cp[0] << 24 | cp[1] << 16 | cp[2] << 8 | cp[3]; cp += 4;
		den = cp[0] << 24 | cp[1] << 16 | cp[2] << 8 | cp[3]; cp += 4;
		desc = cp;
		while (cp < term + len && *cp++);

		if (addr != (ia->ia_addr << 1))
			continue;

		if (num == 0 || den == 0)
			num = den = 1;

		sc->sc_channels[sc->sc_nchan].chan_num = chan;

		sensor = &sc->sc_channels[sc->sc_nchan].chan_sensor;
		sensor->units = ENVSYS_STEMP;
		sensor->flags |= ENVSYS_FMONLIMITS;
		sensor->state = ENVSYS_SINVALID;
		strlcpy(sensor->desc, desc, sizeof(sensor->desc));

		if (strncmp(desc, "CPU", 3) == 0)
			sc->sc_channels[sc->sc_nchan].chan_xlate =
			    sc->sc_cpu_xlate;
		else if (strncmp(desc, "PS", 2) == 0)
			sc->sc_channels[sc->sc_nchan].chan_xlate =
			    sc->sc_ps_xlate;
		else
			sc->sc_channels[sc->sc_nchan].chan_factor =
			    (1000000 * num) / den;
		sc->sc_channels[sc->sc_nchan].chan_min =
		    273150000 + 1000000 * minv;
		sc->sc_channels[sc->sc_nchan].chan_warn =
		    273150000 + 1000000 * warnv;
		sc->sc_channels[sc->sc_nchan].chan_crit =
		    273150000 + 1000000 * crit;
		sc->sc_nchan++;
	}

	sc->sc_tag = ia->ia_tag;
	sc->sc_addr = ia->ia_addr;

	iic_acquire_bus(sc->sc_tag, 0);

	/* Try a read now, so we can fail if it doesn't work */
	if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
	    NULL, 0, junk, sc->sc_nchan + 1, 0)) {
		aprint_error(": read failed\n");
		iic_release_bus(sc->sc_tag, 0);
		return;
	}

	iic_release_bus(sc->sc_tag, 0);

	/* Hook us into the sysmon_envsys subsystem */
	sc->sc_sme = sysmon_envsys_create();
	sc->sc_sme->sme_name = device_xname(self);
	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_refresh = ecadc_refresh;
	sc->sc_sme->sme_get_limits = ecadc_get_limits;

	/* Initialize sensor data. */
	for (i = 0; i < sc->sc_nchan; i++)
		sysmon_envsys_sensor_attach(sc->sc_sme,
		    &sc->sc_channels[i].chan_sensor);

	error = sysmon_envsys_register(sc->sc_sme);
	if (error) {
		aprint_error_dev(self, "error %d registering with sysmon\n",
			error);
		sysmon_envsys_destroy(sc->sc_sme);
		return;
	}

	aprint_naive(": Temp Sensors\n");
	aprint_normal(": %s Temp Sensors\n", ia->ia_name);
}
Exemplo n.º 24
0
static void
pic16lc_attach(device_t parent, device_t self, void *opaque)
{
	struct pic16lc_softc *sc = device_private(self);
	struct i2c_attach_args *ia = opaque;
	u_char ver[4];
	int i;

	sc->sc_dev = self;
	sc->sc_tag = ia->ia_tag;
	sc->sc_addr = ia->ia_addr;

	pic16lc = sc;

	sc->sc_sme = sysmon_envsys_create();

	/* initialize CPU sensor */
	sc->sc_sensor[XBOX_SENSOR_CPU].units = ENVSYS_STEMP;
	(void)strlcpy(sc->sc_sensor[XBOX_SENSOR_CPU].desc, "Xbox CPU Temp",
	    sizeof(sc->sc_sensor[XBOX_SENSOR_CPU]));
	/* initialize board sensor */
	sc->sc_sensor[XBOX_SENSOR_BOARD].units = ENVSYS_STEMP;
	(void)strlcpy(sc->sc_sensor[XBOX_SENSOR_BOARD].desc, "Xbox Board Temp",
	    sizeof(sc->sc_sensor[XBOX_SENSOR_BOARD]));

	for (i = 0; i < XBOX_NSENSORS; i++) {
		if (sysmon_envsys_sensor_attach(sc->sc_sme,
						&sc->sc_sensor[i])) {
			sysmon_envsys_destroy(sc->sc_sme);
			return;
		}
	}

	/* hook into sysmon */
	sc->sc_sme->sme_name = device_xname(sc->sc_dev);
	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_refresh = pic16lc_refresh;

	if (sysmon_envsys_register(sc->sc_sme)) {
		aprint_error_dev(self, "unable to register with sysmon\n");
		sysmon_envsys_destroy(sc->sc_sme);
		return;
	}

	if (iic_acquire_bus(sc->sc_tag, 0) != 0) {
		aprint_error(": unable to acquire i2c bus\n");
		return;
	}

	aprint_normal(": Xbox System Management Controller");

	/* find the PIC version */
	pic16lc_write_1(sc, PIC16LC_REG_VER, 0x00);
	pic16lc_read_1(sc, PIC16LC_REG_VER, &ver[0]);
	pic16lc_read_1(sc, PIC16LC_REG_VER, &ver[1]);
	pic16lc_read_1(sc, PIC16LC_REG_VER, &ver[2]);
	ver[3] = '\0';

	aprint_normal(" (rev. %s)\n", ver);

	pic16lc_setled(0xff);	/* orange */

	iic_release_bus(sc->sc_tag, 0);

	/* disable reset on eject */
	pic16lc_write_1(sc, PIC16LC_REG_RESETONEJECT, 0x01);

	sc->sc_ih = iic_smbus_intr_establish_proc(sc->sc_tag, pic16lc_intr, sc);
	if (sc->sc_ih == NULL)
		aprint_error_dev(self, "couldn't establish interrupt\n");

	return;
}
Exemplo n.º 25
0
void 
uyurex_attach(device_t parent, device_t self, void *aux)
{
	struct uyurex_softc *sc = device_private(self);
	struct usb_attach_arg *uaa = aux;
	struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa;
	usbd_device_handle dev = uha->parent->sc_udev;
	int size, repid, err;
	void *desc;

	sc->sc_udev = dev;
	sc->sc_hdev.sc_dev = self;
	sc->sc_hdev.sc_intr = uyurex_intr;
	sc->sc_hdev.sc_parent = uha->parent;
	sc->sc_hdev.sc_report_id = uha->reportid;

	uhidev_get_report_desc(uha->parent, &desc, &size);
	repid = uha->reportid;
	sc->sc_ilen = hid_report_size(desc, size, hid_input, repid);
	sc->sc_olen = hid_report_size(desc, size, hid_output, repid);
	sc->sc_flen = hid_report_size(desc, size, hid_feature, repid);

	aprint_normal("\n");
	aprint_naive("\n");

	err = uhidev_open(&sc->sc_hdev);
	if (err) {
		aprint_error_dev(self, "uyurex_open: uhidev_open %d\n", err);
		return;
	}
	sc->sc_ibuf = malloc(sc->sc_ilen, M_USBDEV, M_WAITOK);

	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
	    sc->sc_hdev.sc_dev);

	/* attach sensor */
	sc->sc_sme = sysmon_envsys_create();
	/* error handling? XXX */
	sc->sc_sme->sme_name = device_xname(self);

	/* add BBU sensor */
	sc->sc_sensor_val.units = ENVSYS_INTEGER;
	sc->sc_sensor_val.state = ENVSYS_SINVALID;
	sc->sc_sensor_val.flags = ENVSYS_FMONCRITICAL;	/* abuse XXX */
	strlcpy(sc->sc_sensor_val.desc, "BBU",
		sizeof(sc->sc_sensor_val.desc));
	sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor_val);

	/* add BBU delta sensor */
	sc->sc_sensor_delta.units = ENVSYS_INTEGER;
	sc->sc_sensor_delta.state = ENVSYS_SINVALID;
	strlcpy(sc->sc_sensor_delta.desc, "mBBU/sec",
		sizeof(sc->sc_sensor_delta.desc));
	sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor_delta);

	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_refresh = uyurex_refresh;
	sc->sc_sme->sme_events_timeout = UPDATE_TICK;
	sc->sc_sme->sme_flags = SME_INIT_REFRESH;
	if (sysmon_envsys_register(sc->sc_sme)) {
		aprint_error_dev(self, "unable to register with sysmon\n");
		sysmon_envsys_destroy(sc->sc_sme);
	}

	callout_init(&sc->sc_deltach, 0);
	callout_reset(&sc->sc_deltach, UPDATE_TICK * hz, uyurex_delta, sc);

	DPRINTF(("uyurex_attach: complete\n"));

	/* init device */ /* XXX */
	uyurex_set_mode(sc, 0);
}
Exemplo n.º 26
0
static
int
swsensor_init(void *arg)
{
	int error, val = 0;
	const char *key, *str;
	prop_dictionary_t pd = (prop_dictionary_t)arg;
	prop_object_t po, obj;
	prop_object_iterator_t iter;
	prop_type_t type;
	const struct sme_descr_entry *descr;

	swsensor_sme = sysmon_envsys_create();
	if (swsensor_sme == NULL)
		return ENOTTY;

	swsensor_sme->sme_name = "swsensor";
	swsensor_sme->sme_cookie = &swsensor_edata;
	swsensor_sme->sme_refresh = swsensor_refresh;
	swsensor_sme->sme_set_limits = NULL;
	swsensor_sme->sme_get_limits = NULL;

	/* Set defaults in case no prop dictionary given */

	swsensor_edata.units = ENVSYS_INTEGER;
	swsensor_edata.flags = 0;
	sw_sensor_mode = 0;
	sw_sensor_value = 0;
	sw_sensor_limit = 0;

	/* Iterate over the provided dictionary, if any */
	if (pd != NULL) {
		iter = prop_dictionary_iterator(pd);
		if (iter == NULL)
			return ENOMEM;

		while ((obj = prop_object_iterator_next(iter)) != NULL) {
			key = prop_dictionary_keysym_cstring_nocopy(obj);
			po  = prop_dictionary_get_keysym(pd, obj);
			type = prop_object_type(po);
			if (type == PROP_TYPE_NUMBER)
				val = prop_number_integer_value(po);

			/* Sensor type/units */
			if (strcmp(key, "type") == 0) {
				if (type == PROP_TYPE_NUMBER) {
					descr = sme_find_table_entry(
							SME_DESC_UNITS, val);
					if (descr == NULL)
						return EINVAL;
					swsensor_edata.units = descr->type;
					continue;
				}
				if (type != PROP_TYPE_STRING)
					return EINVAL;
				str = prop_string_cstring_nocopy(po);
				descr = sme_find_table_desc(SME_DESC_UNITS,
							    str);
				if (descr == NULL)
					return EINVAL;
				swsensor_edata.units = descr->type;
				continue;
			}

			/* Sensor flags */
			if (strcmp(key, "flags") == 0) {
				if (type != PROP_TYPE_NUMBER)
					return EINVAL;
				swsensor_edata.flags = val;
				continue;
			}

			/* Sensor limit behavior
			 *	0 - simple sensor, no hw limits
			 *	1 - simple sensor, hw provides initial limit
			 *	2 - complex sensor, hw provides settable 
			 *	    limits and does its own limit checking
			 */
			if (strcmp(key, "mode") == 0) {
				if (type != PROP_TYPE_NUMBER)
					return EINVAL;
				sw_sensor_mode = val;
				if (sw_sensor_mode > 2)
					sw_sensor_mode = 2;
				else if (sw_sensor_mode < 0)
					sw_sensor_mode = 0;
				continue;
			}

			/* Grab any limit that might be specified */
			if (strcmp(key, "limit") == 0) {
				if (type != PROP_TYPE_NUMBER)
					return EINVAL;
				sw_sensor_limit = val;
				continue;
			}

			/* Grab the initial value */
			if (strcmp(key, "value") == 0) {
				if (type != PROP_TYPE_NUMBER)
					return EINVAL;
				sw_sensor_value = val;
				continue;
			}

			/* Grab value_min and value_max */
			if (strcmp(key, "value_min") == 0) {
				if (type != PROP_TYPE_NUMBER)
					return EINVAL;
				swsensor_edata.value_min = val;
				swsensor_edata.flags |= ENVSYS_FVALID_MIN;
				continue;
			}
			if (strcmp(key, "value_max") == 0) {
				if (type != PROP_TYPE_NUMBER)
					return EINVAL;
				swsensor_edata.value_max = val;
				swsensor_edata.flags |= ENVSYS_FVALID_MAX;
				continue;
			}

			/* See if sensor reports percentages vs raw values */
			if (strcmp(key, "percentage") == 0) {
				if (type != PROP_TYPE_BOOL)
					return EINVAL;
				if (prop_bool_true(po))
					swsensor_edata.flags |= ENVSYS_FPERCENT;
				continue;
			}

			/* Unrecognized dicttionary object */
#ifdef DEBUG
			printf("%s: unknown attribute %s\n", __func__, key);
#endif
			return EINVAL;

		} /* while */
		prop_object_iterator_release(iter);
	}

	/* Initialize limit processing */
	if (sw_sensor_mode >= 1)
		swsensor_sme->sme_get_limits = swsensor_get_limits;

	if (sw_sensor_mode == 2)
		swsensor_sme->sme_set_limits = swsensor_set_limits;

	if (sw_sensor_mode != 0) {
		swsensor_edata.flags |= ENVSYS_FMONLIMITS;
		swsensor_get_limits(swsensor_sme, &swsensor_edata,
		    &sw_sensor_deflims, &sw_sensor_defprops);
	}

	strlcpy(swsensor_edata.desc, "sensor", ENVSYS_DESCLEN);

	/* Wait for refresh to validate the sensor value */
	swsensor_edata.state = ENVSYS_SINVALID;
	sw_sensor_state = ENVSYS_SVALID;

	error = sysmon_envsys_sensor_attach(swsensor_sme, &swsensor_edata);
	if (error != 0) {
		aprint_error("sysmon_envsys_sensor_attach failed: %d\n", error);
		return error;
	}

	error = sysmon_envsys_register(swsensor_sme);
	if (error != 0) {
		aprint_error("sysmon_envsys_register failed: %d\n", error);
		return error;
	}

	sysctl_swsensor_setup();
	aprint_normal("swsensor: initialized\n");

	return 0;
}
Exemplo n.º 27
0
static void
tctrl_sensor_setup(struct tctrl_softc *sc)
{
	int i, error;

	sc->sc_sme = sysmon_envsys_create();

	/* case temperature */
	(void)strlcpy(sc->sc_sensor[0].desc, "Case temperature",
	    sizeof(sc->sc_sensor[0].desc));
	sc->sc_sensor[0].units = ENVSYS_STEMP;
	sc->sc_sensor[0].state = ENVSYS_SINVALID;

	/* battery voltage */
	(void)strlcpy(sc->sc_sensor[1].desc, "Internal battery voltage",
	    sizeof(sc->sc_sensor[1].desc));
	sc->sc_sensor[1].units = ENVSYS_SVOLTS_DC;
	sc->sc_sensor[1].state = ENVSYS_SINVALID;

	/* DC voltage */
	(void)strlcpy(sc->sc_sensor[2].desc, "DC-In voltage",
	    sizeof(sc->sc_sensor[2].desc));
	sc->sc_sensor[2].units = ENVSYS_SVOLTS_DC;
	sc->sc_sensor[2].state = ENVSYS_SINVALID;

	for (i = 0; i < ENVSYS_NUMSENSORS; i++) {
		if (sysmon_envsys_sensor_attach(sc->sc_sme,
						&sc->sc_sensor[i])) {
			sysmon_envsys_destroy(sc->sc_sme);
			return;
		}
	}

	sc->sc_sme->sme_name = device_xname(sc->sc_dev);
	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_refresh = tctrl_refresh;

	if ((error = sysmon_envsys_register(sc->sc_sme)) != 0) {
		printf("%s: couldn't register sensors (%d)\n",
		    device_xname(sc->sc_dev), error);
		sysmon_envsys_destroy(sc->sc_sme);
		return;
	}

	/* now register the power button */

	sysmon_task_queue_init();

	sc->sc_powerpressed = 0;
	memset(&sc->sc_sm_pbutton, 0, sizeof(struct sysmon_pswitch));
	sc->sc_sm_pbutton.smpsw_name = device_xname(sc->sc_dev);
	sc->sc_sm_pbutton.smpsw_type = PSWITCH_TYPE_POWER;
	if (sysmon_pswitch_register(&sc->sc_sm_pbutton) != 0)
		printf("%s: unable to register power button with sysmon\n",
		    device_xname(sc->sc_dev));

	memset(&sc->sc_sm_lid, 0, sizeof(struct sysmon_pswitch));
	sc->sc_sm_lid.smpsw_name = device_xname(sc->sc_dev);
	sc->sc_sm_lid.smpsw_type = PSWITCH_TYPE_LID;
	if (sysmon_pswitch_register(&sc->sc_sm_lid) != 0)
		printf("%s: unable to register lid switch with sysmon\n",
		    device_xname(sc->sc_dev));

	memset(&sc->sc_sm_ac, 0, sizeof(struct sysmon_pswitch));
	sc->sc_sm_ac.smpsw_name = device_xname(sc->sc_dev);
	sc->sc_sm_ac.smpsw_type = PSWITCH_TYPE_ACADAPTER;
	if (sysmon_pswitch_register(&sc->sc_sm_ac) != 0)
		printf("%s: unable to register AC adaptor with sysmon\n",
		    device_xname(sc->sc_dev));
}
Exemplo n.º 28
0
void
ug2_attach(device_t dv)
{
	struct ug_softc *sc = device_private(dv);
	uint8_t buf[2];
	int i;
	struct ug2_motherboard_info *ai;
	struct ug2_sensor_info *si;

	aprint_normal(": Abit uGuru 2005 system monitor\n");

	if (ug2_read(sc, UG2_MISC_BANK, UG2_BOARD_ID, 2, buf) != 2) {
		aprint_error_dev(dv, "Cannot detect board ID. Using default\n");
		buf[0] = UG_MAX_MSB_BOARD;
		buf[1] = UG_MAX_LSB_BOARD;
	}

	if (buf[0] > UG_MAX_MSB_BOARD || buf[1] > UG_MAX_LSB_BOARD ||
		buf[1] < UG_MIN_LSB_BOARD) {
		aprint_error_dev(dv, "Invalid board ID(%X,%X). Using default\n",
			buf[0], buf[1]);
		buf[0] = UG_MAX_MSB_BOARD;
		buf[1] = UG_MAX_LSB_BOARD;
	}

	ai = &ug2_mb[buf[1] - UG_MIN_LSB_BOARD];

	aprint_normal_dev(dv, "mainboard %s (%.2X%.2X)\n",
	    ai->name, buf[0], buf[1]);

	sc->mbsens = (void*)ai->sensors;
	sc->sc_sme = sysmon_envsys_create();

	for (i = 0, si = ai->sensors; si && si->name; si++, i++) {
		COPYDESCR(sc->sc_sensor[i].desc, si->name);
		sc->sc_sensor[i].rfact = 1;
		sc->sc_sensor[i].state = ENVSYS_SVALID;
		switch (si->type) {
			case UG2_VOLTAGE_SENSOR:
				sc->sc_sensor[i].units = ENVSYS_SVOLTS_DC;
				sc->sc_sensor[i].rfact = UG_RFACT;
				break;
			case UG2_TEMP_SENSOR:
				sc->sc_sensor[i].units = ENVSYS_STEMP;
				break;
			case UG2_FAN_SENSOR:
				sc->sc_sensor[i].units = ENVSYS_SFANRPM;
				break;
			default:
				break;
		}
		if (sysmon_envsys_sensor_attach(sc->sc_sme,
						&sc->sc_sensor[i])) {
			sysmon_envsys_destroy(sc->sc_sme);
			return;
		}
	}
#undef COPYDESCR

	sc->sc_sme->sme_name = device_xname(dv);
	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_refresh = ug2_refresh;

	if (sysmon_envsys_register(sc->sc_sme)) {
		aprint_error_dev(dv, "unable to register with sysmon\n");
		sysmon_envsys_destroy(sc->sc_sme);
	}
}
Exemplo n.º 29
0
static void
itesio_isa_attach(device_t parent, device_t self, void *aux)
{
	struct itesio_softc *sc = device_private(self);
	struct isa_attach_args *ia = aux;
	int i;
	uint8_t cr;

	sc->sc_iot = ia->ia_iot;

	if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr, 2, 0,
			  &sc->sc_ioh)) {
		aprint_error(": can't map i/o space\n");
		return;
	}

	aprint_naive("\n");

	/*
	 * Enter to the Super I/O MB PNP mode.
	 */
	itesio_enter(sc->sc_iot, sc->sc_ioh);
	/*
	 * Get info from the Super I/O Global Configuration Registers:
	 * Chip IDs and Device Revision.
	 */
	sc->sc_chipid = (itesio_readreg(sc->sc_iot, sc->sc_ioh,
	    ITESIO_CHIPID1) << 8);
	sc->sc_chipid |= itesio_readreg(sc->sc_iot, sc->sc_ioh,
	    ITESIO_CHIPID2);
	sc->sc_devrev = (itesio_readreg(sc->sc_iot, sc->sc_ioh,
	    ITESIO_DEVREV) & 0x0f);
	/*
	 * Select the EC LDN to get the Base Address.
	 */
	itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_LDNSEL, ITESIO_EC_LDN);
	sc->sc_hwmon_baseaddr =
	    (itesio_readreg(sc->sc_iot, sc->sc_ioh, ITESIO_EC_MSB) << 8);
	sc->sc_hwmon_baseaddr |= itesio_readreg(sc->sc_iot, sc->sc_ioh,
	    ITESIO_EC_LSB);
	/*
	 * We are done, exit MB PNP mode.
	 */
	itesio_exit(sc->sc_iot, sc->sc_ioh);

	aprint_normal(": iTE IT%4xF Super I/O (rev %d)\n",
	    sc->sc_chipid, sc->sc_devrev);
	aprint_normal_dev(self, "Hardware Monitor registers at 0x%x\n",
	    sc->sc_hwmon_baseaddr);

	if (bus_space_map(sc->sc_ec_iot, sc->sc_hwmon_baseaddr, 8, 0,
	    &sc->sc_ec_ioh)) {
		aprint_error_dev(self, "cannot map hwmon i/o space\n");
		goto out2;
	}

	sc->sc_hwmon_mapped = true;

	/* Activate monitoring */
	cr = itesio_ecreadreg(sc, ITESIO_EC_CONFIG);
	SET(cr, 0x01);
	itesio_ecwritereg(sc, ITESIO_EC_CONFIG, cr);

#ifdef notyet
	/* Enable beep alarms */
	cr = itesio_ecreadreg(sc, ITESIO_EC_BEEPEER);
	SET(cr, 0x02);	/* Voltage exceeds limit */
	SET(cr, 0x04);	/* Temperature exceeds limit */
	itesio_ecwritereg(sc, ITESIO_EC_BEEPEER, cr);
#endif

	/*
	 * Initialize and attach sensors.
	 */
	itesio_setup_sensors(sc);
	sc->sc_sme = sysmon_envsys_create();
	for (i = 0; i < IT_NUM_SENSORS; i++) {
		if (sysmon_envsys_sensor_attach(sc->sc_sme,
						&sc->sc_sensor[i])) {
			sysmon_envsys_destroy(sc->sc_sme);
			goto out;
		}
	}
	/*
	 * Hook into the system monitor.
	 */
	sc->sc_sme->sme_name = device_xname(self);
	sc->sc_sme->sme_cookie = sc;
	sc->sc_sme->sme_refresh = itesio_refresh;
	
	if ((i = sysmon_envsys_register(sc->sc_sme))) {
		aprint_error_dev(self,
		    "unable to register with sysmon (%d)\n", i);
		sysmon_envsys_destroy(sc->sc_sme);
		goto out;
	}
	sc->sc_hwmon_enabled = true;

	if (!pmf_device_register(self, NULL, NULL))
		aprint_error_dev(self, "couldn't establish power handler\n");

	/* The IT8705 doesn't support the WDT */
	if (sc->sc_chipid == ITESIO_ID8705)
		goto out2;

	/*
	 * Initialize the watchdog timer.
	 */
	sc->sc_smw.smw_name = device_xname(self);
	sc->sc_smw.smw_cookie = sc;
	sc->sc_smw.smw_setmode = itesio_wdt_setmode;
	sc->sc_smw.smw_tickle = itesio_wdt_tickle;
	sc->sc_smw.smw_period = 60;

	if (sysmon_wdog_register(&sc->sc_smw)) {
		aprint_error_dev(self, "unable to register watchdog timer\n");
		goto out2;
	}
	sc->sc_wdt_enabled = true;
	aprint_normal_dev(self, "Watchdog Timer present\n");
	return;

out:
	bus_space_unmap(sc->sc_ec_iot, sc->sc_ec_ioh, 8);
out2:
	bus_space_unmap(sc->sc_iot, sc->sc_ioh, 2);
}