Beispiel #1
0
void
toshiba_attach(struct device *parent, struct device *self, void *aux)
{
	struct acpitoshiba_softc *sc = (struct acpitoshiba_softc *)self;
	struct acpi_attach_args *aa = aux;
	int ret;

	sc->sc_acpi = (struct acpi_softc *)parent;
	sc->sc_devnode = aa->aaa_node;

	printf("\n");

	/* enable events and hotkeys */
	ret = toshiba_enable_events(sc);
	if ( ret != HCI_FAILURE) {
		/* Run toshiba_hotkey on button presses */
		aml_register_notify(sc->sc_devnode, aa->aaa_dev,
				toshiba_hotkey, sc, ACPIDEV_NOPOLL);

		/* wsconsctl purpose */
		ws_get_param = acpitoshiba_get_param;
		ws_set_param = acpitoshiba_set_param;
	}

}
Beispiel #2
0
void
aibs_attach(struct device *parent, struct device *self, void *aux)
{
	struct aibs_softc	*sc = (struct aibs_softc *)self;
	struct acpi_attach_args	*aa = aux;

	sc->sc_acpi = (struct acpi_softc *)parent;
	sc->sc_devnode = aa->aaa_node;

	strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname,
	    sizeof(sc->sc_sensordev.xname));
	SIMPLEQ_INIT(&sc->sc_sensorlist);

	aibs_probe(sc);
	printf("\n");

	if (sc->sc_mode)
		aibs_attach_new(sc);
	else {
		aibs_attach_sif(sc, SENSOR_TEMP);
		aibs_attach_sif(sc, SENSOR_FANRPM);
		aibs_attach_sif(sc, SENSOR_VOLTS_DC);
	}

	if (sc->sc_sensordev.sensors_count == 0) {
		printf("%s: no sensors found\n", DEVNAME(sc));
		return;
	}

	sensordev_install(&sc->sc_sensordev);

	aml_register_notify(sc->sc_devnode, aa->aaa_dev,
	    aibs_notify, sc, ACPIDEV_POLL);
}
Beispiel #3
0
void
acpiasus_attach(struct device *parent, struct device *self, void *aux)
{
	struct acpiasus_softc *sc = (struct acpiasus_softc *)self;
	struct acpi_attach_args *aa = aux;

	sc->sc_acpi = (struct acpi_softc *)parent;
	sc->sc_devnode = aa->aaa_node;

	printf("\n");

	acpiasus_init(self);

	aml_register_notify(sc->sc_devnode, aa->aaa_dev,
	    acpiasus_notify, sc, ACPIDEV_NOPOLL);
}
Beispiel #4
0
void
acpitz_attach(struct device *parent, struct device *self, void *aux)
{
	struct acpitz_softc	*sc = (struct acpitz_softc *)self;
	struct acpi_attach_args	*aa = aux;
	int			i;
	char			name[8];

	sc->sc_acpi = (struct acpi_softc *)parent;
	sc->sc_devnode = aa->aaa_node->child;

	sc->sc_lasttmp = -1;
	if ((sc->sc_tmp = acpitz_getreading(sc, "_TMP")) == -1) {
		printf(", failed to read _TMP\n");
		return;
	}

	if ((sc->sc_crt = acpitz_getreading(sc, "_CRT")) == -1) {
		printf(", no critical temperature defined!\n");
		sc->sc_crt = 0;
	} else
		printf(", critical temperature: %d degC\n",
		    (sc->sc_crt - 2732) / 10);

	for (i = 0; i < ACPITZ_MAX_AC; i++) {
		snprintf(name, sizeof name, "_AC%d", i);
		sc->sc_ac[i] = acpitz_getreading(sc, name);
		sc->sc_ac_stat[0] = -1;
	}

	sc->sc_hot = acpitz_getreading(sc, "_HOT");
	sc->sc_tc1 = acpitz_getreading(sc, "_TC1");
	sc->sc_tc2 = acpitz_getreading(sc, "_TC2");
	sc->sc_psv = acpitz_getreading(sc, "_PSV");

	strlcpy(sc->sc_sensdev.xname, DEVNAME(sc),
	    sizeof(sc->sc_sensdev.xname));
	strlcpy(sc->sc_sens.desc, "zone temperature",
	    sizeof(sc->sc_sens.desc));
	sc->sc_sens.type = SENSOR_TEMP;
	sensor_attach(&sc->sc_sensdev, &sc->sc_sens);
	sensordev_install(&sc->sc_sensdev);
	sc->sc_sens.value = 0;

	aml_register_notify(sc->sc_devnode->parent, NULL,
	    acpitz_notify, sc, ACPIDEV_POLL);
}
Beispiel #5
0
void
acpisony_attach(struct device *parent, struct device *self, void *aux)
{
	struct acpisony_softc	*sc = (struct acpisony_softc *)self;
	struct acpi_attach_args *aa = aux;

	sc->sc_acpi = (struct acpi_softc *)parent;
	sc->sc_devnode = aa->aaa_node;

	printf(": %s\n", sc->sc_devnode->name);

	/* Setup the notification masks */
	acpisony_notify_setup(sc);

	aml_register_notify(sc->sc_devnode, aa->aaa_dev,
	    acpisony_notify, sc, ACPIDEV_NOPOLL);
}
Beispiel #6
0
void
acpibat_attach(struct device *parent, struct device *self, void *aux)
{
    struct acpibat_softc	*sc = (struct acpibat_softc *)self;
    struct acpi_attach_args	*aa = aux;
    struct aml_value	res;

    sc->sc_acpi = (struct acpi_softc *)parent;
    sc->sc_devnode = aa->aaa_node;

    if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_STA", 0, NULL, &res)) {
        dnprintf(10, "%s: no _STA\n", DEVNAME(sc));
        return;
    }

    if ((res.v_integer & STA_BATTERY) != 0) {
        sc->sc_bat_present = 1;
        acpibat_getbif(sc);
        acpibat_getbst(sc);

        printf(": %s", sc->sc_devnode->name);
        if (sc->sc_bif.bif_model[0])
            printf(" model \"%s\"", sc->sc_bif.bif_model);
        if (sc->sc_bif.bif_serial[0])
            printf(" serial %s", sc->sc_bif.bif_serial);
        if (sc->sc_bif.bif_type[0])
            printf(" type %s", sc->sc_bif.bif_type);
        if (sc->sc_bif.bif_oem[0])
            printf(" oem \"%s\"", sc->sc_bif.bif_oem);
        printf("\n");
    } else {
        sc->sc_bat_present = 0;
        printf(": %s not present\n", sc->sc_devnode->name);
    }

    aml_freevalue(&res);

    /* create sensors */
    acpibat_monitor(sc);

    /* populate sensors */
    acpibat_refresh(sc);

    aml_register_notify(sc->sc_devnode, aa->aaa_dev,
                        acpibat_notify, sc, ACPIDEV_POLL);
}
Beispiel #7
0
void
acpidock_attach(struct device *parent, struct device *self, void *aux)
{
	struct acpidock_softc	*sc = (struct acpidock_softc *)self;
	struct acpi_attach_args *aa = aux;
	extern struct aml_node	aml_root;

	sc->sc_acpi = (struct acpi_softc *)parent;
	sc->sc_devnode = aa->aaa_node;

	printf(": %s", sc->sc_devnode->name);

	acpidock_status(sc);
	if (sc->sc_docked == ACPIDOCK_STATUS_DOCKED) {
		acpidock_docklock(sc, 1);
		acpidock_dockctl(sc, 1);
	}

	acpidock_status(sc);
	printf("%s docked (%d)\n",
	    sc->sc_docked == ACPIDOCK_STATUS_DOCKED ? "" : " not",
	    sc->sc_sta);

	strlcpy(sc->sc_sensdev.xname, DEVNAME(sc),
	    sizeof(sc->sc_sensdev.xname));
	if (sc->sc_docked)
		strlcpy(sc->sc_sens.desc, "docked",
		    sizeof(sc->sc_sens.desc));
	else
		strlcpy(sc->sc_sens.desc, "not docked",
		    sizeof(sc->sc_sens.desc));

	sc->sc_sens.type = SENSOR_INDICATOR;
	sc->sc_sens.value = sc->sc_docked == ACPIDOCK_STATUS_DOCKED;
	sensor_attach(&sc->sc_sensdev, &sc->sc_sens);
	sensordev_install(&sc->sc_sensdev);

	TAILQ_INIT(&sc->sc_deps_h);
	aml_find_node(&aml_root, "_EJD", acpidock_foundejd, sc);

	aml_register_notify(sc->sc_devnode, aa->aaa_dev,
	    acpidock_notify, sc, ACPIDEV_NOPOLL);
}
Beispiel #8
0
void
acpivout_attach(struct device *parent, struct device *self, void *aux)
{
    struct acpivout_softc	*sc = (struct acpivout_softc *)self;
    struct acpi_attach_args	*aaa = aux;

    sc->sc_acpi = ((struct acpivideo_softc *)parent)->sc_acpi;
    sc->sc_devnode = aaa->aaa_node;

    printf(": %s\n", sc->sc_devnode->name);

    aml_register_notify(sc->sc_devnode, aaa->aaa_dev,
                        acpivout_notify, sc, ACPIDEV_NOPOLL);

    ws_get_param = acpivout_get_param;
    ws_set_param = acpivout_set_param;

    acpivout_get_bcl(sc);
}
void
thinkpad_attach(struct device *parent, struct device *self, void *aux)
{
	struct acpithinkpad_softc *sc = (struct acpithinkpad_softc *)self;
	struct acpi_attach_args	*aa = aux;

	sc->sc_acpi = (struct acpi_softc *)parent;
	sc->sc_devnode = aa->aaa_node;

	printf("\n");

	/* Set event mask to receive everything */
	thinkpad_enable_events(sc);
	thinkpad_sensor_attach(sc);

	/* Run thinkpad_hotkey on button presses */
	aml_register_notify(sc->sc_devnode, aa->aaa_dev,
	    thinkpad_hotkey, sc, ACPIDEV_POLL);
}
Beispiel #10
0
void
acpivideo_attach(struct device *parent, struct device *self, void *aux)
{
	struct acpivideo_softc *sc = (struct acpivideo_softc *)self;
	struct acpi_attach_args *aaa = aux;

	sc->sc_acpi = (struct acpi_softc *)parent;
	sc->sc_devnode = aaa->aaa_node;

	printf(": %s\n", sc->sc_devnode->name);

	if (acpivideo_getpcibus(sc, sc->sc_devnode) == -1)
		return;

	aml_register_notify(sc->sc_devnode, aaa->aaa_dev,
	    acpivideo_notify, sc, ACPIDEV_NOPOLL);

	acpivideo_set_policy(sc,
	    DOS_SWITCH_BY_OSPM | DOS_BRIGHTNESS_BY_OSPM);

	aml_find_node(aaa->aaa_node, "_BCL", acpi_foundvout, sc);
}
Beispiel #11
0
void
acpicpu_attach(struct device *parent, struct device *self, void *aux)
{
    struct acpicpu_softc	*sc = (struct acpicpu_softc *)self;
    struct acpi_attach_args *aa = aux;
    struct                  aml_value res;
    int			i;

    sc->sc_acpi = (struct acpi_softc *)parent;
    sc->sc_devnode = aa->aaa_node;

    SLIST_INIT(&sc->sc_cstates);

    sc->sc_pss = NULL;

    printf(": %s: ", sc->sc_devnode->name);
    if (aml_evalnode(sc->sc_acpi, sc->sc_devnode, 0, NULL, &res) == 0) {
        if (res.type == AML_OBJTYPE_PROCESSOR) {
            sc->sc_cpu = res.v_processor.proc_id;
            sc->sc_pblk_addr = res.v_processor.proc_addr;
            sc->sc_pblk_len = res.v_processor.proc_len;
        }
        aml_freevalue(&res);
    }
    sc->sc_duty_off = sc->sc_acpi->sc_fadt->duty_offset;
    sc->sc_duty_wid = sc->sc_acpi->sc_fadt->duty_width;
    if (!valid_throttle(sc->sc_duty_off, sc->sc_duty_wid, sc->sc_pblk_addr))
        sc->sc_flags |= FLAGS_NOTHROTTLE;

#ifdef ACPI_DEBUG
    printf(": %s: ", sc->sc_devnode->name);
    printf("\n: hdr:%x pblk:%x,%x duty:%x,%x pstate:%x (%d throttling states)\n",
           sc->sc_acpi->sc_fadt->hdr_revision,
           sc->sc_pblk_addr, sc->sc_pblk_len,
           sc->sc_duty_off, sc->sc_duty_wid,
           sc->sc_acpi->sc_fadt->pstate_cnt,
           CPU_MAXSTATE(sc));
#endif

    /* Get C-States from _CST or FADT */
    if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_CST", 0, NULL, &res) == 0) {
        aml_foreachpkg(&res, 1, acpicpu_add_cstatepkg, sc);
        aml_freevalue(&res);
    }
    else {
        /* Some systems don't export a full PBLK, reduce functionality */
        if (sc->sc_pblk_len < 5)
            sc->sc_flags |= FLAGS_NO_C2;
        if (sc->sc_pblk_len < 6)
            sc->sc_flags |= FLAGS_NO_C3;
        acpicpu_add_cstate(sc, ACPI_STATE_C2, sc->sc_acpi->sc_fadt->p_lvl2_lat,
                           -1, sc->sc_pblk_addr + 4);
        acpicpu_add_cstate(sc, ACPI_STATE_C3, sc->sc_acpi->sc_fadt->p_lvl3_lat,
                           -1, sc->sc_pblk_addr + 5);
    }
    if (acpicpu_getpss(sc)) {
        /* XXX not the right test but has to do for now */
        sc->sc_flags |= FLAGS_NOPSS;
        goto nopss;
    }

#ifdef ACPI_DEBUG
    for (i = 0; i < sc->sc_pss_len; i++) {
        dnprintf(20, "%d %d %d %d %d %d\n",
                 sc->sc_pss[i].pss_core_freq,
                 sc->sc_pss[i].pss_power,
                 sc->sc_pss[i].pss_trans_latency,
                 sc->sc_pss[i].pss_bus_latency,
                 sc->sc_pss[i].pss_ctrl,
                 sc->sc_pss[i].pss_status);
    }
    dnprintf(20, "\n");
#endif
    /* XXX this needs to be moved to probe routine */
    if (acpicpu_getpct(sc))
        return;

    /* Notify BIOS we are handing p-states */
    if (sc->sc_acpi->sc_fadt->pstate_cnt)
        acpi_write_pmreg(sc->sc_acpi, ACPIREG_SMICMD, 0,
                         sc->sc_acpi->sc_fadt->pstate_cnt);

    for (i = 0; i < sc->sc_pss_len; i++)
        printf("%d%s", sc->sc_pss[i].pss_core_freq,
               i < sc->sc_pss_len - 1 ? ", " : " MHz\n");

    aml_register_notify(sc->sc_devnode, NULL,
                        acpicpu_notify, sc, ACPIDEV_NOPOLL);

    if (setperf_prio < 30) {
        cpu_setperf = acpicpu_setperf;
        setperf_prio = 30;
        acpi_hasprocfvs = 1;
    }
    acpicpu_sc[sc->sc_dev.dv_unit] = sc;
    return;

nopss:
    if (sc->sc_flags & FLAGS_NOTHROTTLE)
        printf("no performance/throttling supported\n");
}