Date: Thu, 16 May 2019 00:51:30 +0000 (UTC) From: Oleksandr Tymoshenko <gonzo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r347636 - stable/11/sys/dev/acpi_support Message-ID: <201905160051.x4G0pU5A073872@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gonzo Date: Thu May 16 00:51:30 2019 New Revision: 347636 URL: https://svnweb.freebsd.org/changeset/base/347636 Log: MFC r346647: [acpi_ibm] Add support for newer Thinkpad models Add support for newer Thinkpad models with id LEN0268. Was tested on Thinkpad T480 and ThinkPad X1 Yoga 2nd gen. PR: 229120 Submitted by: Ali Abdallah <aliovx@gmail.com> Modified: stable/11/sys/dev/acpi_support/acpi_ibm.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/acpi_support/acpi_ibm.c ============================================================================== --- stable/11/sys/dev/acpi_support/acpi_ibm.c Wed May 15 22:51:25 2019 (r347635) +++ stable/11/sys/dev/acpi_support/acpi_ibm.c Thu May 16 00:51:30 2019 (r347636) @@ -340,7 +340,7 @@ static devclass_t acpi_ibm_devclass; DRIVER_MODULE(acpi_ibm, acpi, acpi_ibm_driver, acpi_ibm_devclass, 0, 0); MODULE_DEPEND(acpi_ibm, acpi, 1, 1, 1); -static char *ibm_ids[] = {"IBM0068", "LEN0068", NULL}; +static char *ibm_ids[] = {"IBM0068", "LEN0068", "LEN0268", NULL}; static void ibm_led(void *softc, int onoff) @@ -387,9 +387,14 @@ static int acpi_ibm_attach(device_t dev) { int i; + int hkey; struct acpi_ibm_softc *sc; char *maker, *product; - devclass_t ec_devclass; + ACPI_OBJECT_LIST input; + ACPI_OBJECT params[1]; + ACPI_OBJECT out_obj; + ACPI_BUFFER result; + devclass_t ec_devclass; ACPI_FUNCTION_TRACE((char *)(uintptr_t) __func__); @@ -424,15 +429,42 @@ acpi_ibm_attach(device_t dev) "initialmask", CTLFLAG_RD, &sc->events_initialmask, 0, "Initial eventmask"); - /* The availmask is the bitmask of supported events */ - if (ACPI_FAILURE(acpi_GetInteger(sc->handle, - IBM_NAME_EVENTS_AVAILMASK, &sc->events_availmask))) + if (ACPI_SUCCESS (acpi_GetInteger(sc->handle, "MHKV", &hkey))) { + device_printf(dev, "Firmware version is 0x%X\n", hkey); + switch(hkey >> 8) + { + case 1: + /* The availmask is the bitmask of supported events */ + if (ACPI_FAILURE(acpi_GetInteger(sc->handle, + IBM_NAME_EVENTS_AVAILMASK, &sc->events_availmask))) + sc->events_availmask = 0xffffffff; + break; + + case 2: + result.Length = sizeof(out_obj); + result.Pointer = &out_obj; + params[0].Type = ACPI_TYPE_INTEGER; + params[0].Integer.Value = 1; + input.Pointer = params; + input.Count = 1; + + sc->events_availmask = 0xffffffff; + + if (ACPI_SUCCESS(AcpiEvaluateObject (sc->handle, + IBM_NAME_EVENTS_AVAILMASK, &input, &result))) + sc->events_availmask = out_obj.Integer.Value; + break; + default: + device_printf(dev, "Unknown firmware version 0x%x\n", hkey); + break; + } + } else sc->events_availmask = 0xffffffff; SYSCTL_ADD_UINT(sc->sysctl_ctx, - SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, - "availmask", CTLFLAG_RD, - &sc->events_availmask, 0, "Mask of supported events"); + SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, + "availmask", CTLFLAG_RD, + &sc->events_availmask, 0, "Mask of supported events"); } /* Hook up proc nodes */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905160051.x4G0pU5A073872>