From patchwork Fri Feb 3 20:23:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Drake X-Patchwork-Id: 9555081 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 11445604A7 for ; Fri, 3 Feb 2017 20:23:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E628B271E0 for ; Fri, 3 Feb 2017 20:23:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA4FA28425; Fri, 3 Feb 2017 20:23:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2ACEE271E0 for ; Fri, 3 Feb 2017 20:23:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752062AbdBCUXT (ORCPT ); Fri, 3 Feb 2017 15:23:19 -0500 Received: from mail-ua0-f169.google.com ([209.85.217.169]:34303 "EHLO mail-ua0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751226AbdBCUXS (ORCPT ); Fri, 3 Feb 2017 15:23:18 -0500 Received: by mail-ua0-f169.google.com with SMTP id 35so22164838uak.1 for ; Fri, 03 Feb 2017 12:23:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessm-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=U25sZvBo8NGfROqbeTYD0LnpnnZy/kdve+WODZk0nDk=; b=Se3f8k/TyRT+TMnDixIW9BZ22rZxmP+Raj+5M+Ju6yaapZY6hXhCaDHJT6EKETRH3R zhAatrJUi8+T+7jWK8+ayxBXWqyxCal7JDSiZASzeFn3ccu6ebOiGgCJi1Du+R+mGz5C TNyxzx8QtavT2dL67SYWKkzl3ColnGxb2sPyJ5LuC5AiAB7uDto4SGy6KZQgmQB7wd6d NrivSbnqRNaB8wpeNgVvS5tyBDNweVJefcjgnhOYPUa8K+6Zz1lfAy9QJ5ndjv1L7UPB c3WxH66IZWJ8uvs1+PQsXL9Aue5L0lChoIFCt+GmiTigK9/b5CDzO+e2VX1goTNC9S+x jn8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=U25sZvBo8NGfROqbeTYD0LnpnnZy/kdve+WODZk0nDk=; b=IXVOrcofo+VfCpQG7/mljsSH+uvP6ZeG0dmvBQNtBhZrMzsSyy7BP7vjCGyRxqydSl qEncfXyRLzHM03KsWacQbsyOQAWrhIWWz03LfU9Jkwqf6KSOD3HjFkmwL5j2ec/6+M1l r7MJAk9j5Rz7OZq31PNUSI+AHn/0ncO2swzZ/CJlDYV0NeGR9BTlpmp5iyI+PSVfPqmy p6n0Fi4GmfMt+XPgzS/uydTwQ7Jkm1Vgn37HeHWOmUWAwEfKaI1Uvf0Kc01dZip2Paxa /1KUU2NVgtNQE1dfg9ODVg1kAKTmToKJTztYoxU9vJgKqvOYKmf7PyWY1HibOM7EfmE9 afiQ== X-Gm-Message-State: AIkVDXLE8bMtuc7WCra8h05fCyeIA2gtGm3HJjLPFlAJTNb1DbJlEGAp5K8DHoT5aQJybaPV X-Received: by 10.176.76.71 with SMTP id d7mr7983067uag.148.1486153397697; Fri, 03 Feb 2017 12:23:17 -0800 (PST) Received: from nuc.gallo.pinto ([186.77.198.208]) by smtp.gmail.com with ESMTPSA id d2sm10235215uad.8.2017.02.03.12.23.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Feb 2017 12:23:17 -0800 (PST) From: Daniel Drake To: jlee@suse.com, dvhart@infradead.org, andy@infradead.org Cc: platform-driver-x86@vger.kernel.org, linux@endlessm.com, chiu@endless.com, Chris Chiu Subject: [PATCH] acer-wmi: Inform firmware that RF Button Driver is active Date: Fri, 3 Feb 2017 14:23:07 -0600 Message-Id: <20170203202307.23586-1-drake@endlessm.com> X-Mailer: git-send-email 2.9.3 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Chris Chiu The same method to activate LM(Launch Manager) can also be used to activate the RF Button driver with different bit toggled in the same lm_status. To express that many functions this byte field can achieve, rename the lm_status to app_status. And also the app_mask is the bit mask which specifically indicate which bits are going to be changed. This solves a problem where the AR9565 wifi included in the Acer Aspire ES1-421 is permanently hard blocked according to the rfkill GPIO read by ath9k. We also enable use of the Fn+F3 airplane mode hotkey on this laptop and others such as the Acer TravelMate P238-M. This can happen either as a scancode or via an EC/WMI event. Signed-off-by: Chris Chiu Signed-off-by: Daniel Drake --- drivers/platform/x86/acer-wmi.c | 78 ++++++++++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 16 deletions(-) diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index c29b9b6..ecdf6f1 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -128,6 +128,7 @@ static const struct key_entry acer_wmi_keymap[] __initconst = { {KE_KEY, KEY_TOUCHPAD_OFF, {KEY_TOUCHPAD_OFF} }, {KE_IGNORE, 0x83, {KEY_TOUCHPAD_TOGGLE} }, {KE_KEY, 0x85, {KEY_TOUCHPAD_TOGGLE} }, + {KE_KEY, 0x86, {KEY_WLAN} }, {KE_END, 0} }; @@ -150,15 +151,30 @@ struct event_return_value { #define ACER_WMID3_GDS_BLUETOOTH (1<<11) /* BT */ #define ACER_WMID3_GDS_TOUCHPAD (1<<1) /* Touchpad */ -struct lm_input_params { +/* Hotkey Customized Setting and Acer Application Status. + * Set Device Default Value and Report Acer Application Status. + * When Acer Application starts, it will run this method to inform + * BIOS/EC that Acer Application is on. + * App Status + * Bit[0]: Launch Manager Status + * Bit[1]: ePM Status + * Bit[2]: Device Control Status + * Bit[3]: Acer Power Button Utility Status + * Bit[4]: RF Button Status + * Bit[5]: ODD PM Status + * Bit[6]: Device Default Value Control + * Bit[7]: Hall Sensor Application Status + */ +struct set_function_input_params { u8 function_num; /* Function Number */ u16 commun_devices; /* Communication type devices default status */ u16 devices; /* Other type devices default status */ - u8 lm_status; /* Launch Manager Status */ - u16 reserved; + u8 app_status; /* Acer Device Status. LM, ePM, RF Button... */ + u8 app_mask; /* Bit mask to app_status */ + u8 reserved; } __attribute__((packed)); -struct lm_return_value { +struct set_function_return_value { u8 error_code; /* Error Code */ u8 ec_return_value; /* EC Return Value */ u16 reserved; @@ -1769,13 +1785,14 @@ static void acer_wmi_notify(u32 value, void *context) } static acpi_status __init -wmid3_set_lm_mode(struct lm_input_params *params, - struct lm_return_value *return_value) +wmid3_set_function_mode(struct set_function_input_params *params, + struct set_function_return_value *return_value) { acpi_status status; union acpi_object *obj; - struct acpi_buffer input = { sizeof(struct lm_input_params), params }; + struct acpi_buffer input = { sizeof(struct set_function_input_params), + params }; struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output); @@ -1796,7 +1813,8 @@ wmid3_set_lm_mode(struct lm_input_params *params, return AE_ERROR; } - *return_value = *((struct lm_return_value *)obj->buffer.pointer); + *return_value = *((struct set_function_return_value *) + obj->buffer.pointer); kfree(obj); return status; @@ -1804,16 +1822,17 @@ wmid3_set_lm_mode(struct lm_input_params *params, static int __init acer_wmi_enable_ec_raw(void) { - struct lm_return_value return_value; + struct set_function_return_value return_value; acpi_status status; - struct lm_input_params params = { + struct set_function_input_params params = { .function_num = 0x1, .commun_devices = 0xFFFF, .devices = 0xFFFF, - .lm_status = 0x00, /* Launch Manager Deactive */ + .app_status = 0x00, /* Launch Manager Deactive */ + .app_mask = 0x01, }; - status = wmid3_set_lm_mode(¶ms, &return_value); + status = wmid3_set_function_mode(¶ms, &return_value); if (return_value.error_code || return_value.ec_return_value) pr_warn("Enabling EC raw mode failed: 0x%x - 0x%x\n", @@ -1827,16 +1846,17 @@ static int __init acer_wmi_enable_ec_raw(void) static int __init acer_wmi_enable_lm(void) { - struct lm_return_value return_value; + struct set_function_return_value return_value; acpi_status status; - struct lm_input_params params = { + struct set_function_input_params params = { .function_num = 0x1, .commun_devices = 0xFFFF, .devices = 0xFFFF, - .lm_status = 0x01, /* Launch Manager Active */ + .app_status = 0x01, /* Launch Manager Active */ + .app_mask = 0x01, }; - status = wmid3_set_lm_mode(¶ms, &return_value); + status = wmid3_set_function_mode(¶ms, &return_value); if (return_value.error_code || return_value.ec_return_value) pr_warn("Enabling Launch Manager failed: 0x%x - 0x%x\n", @@ -1846,6 +1866,28 @@ static int __init acer_wmi_enable_lm(void) return status; } +static int __init acer_wmi_enable_rf_button(void) +{ + struct set_function_return_value return_value; + acpi_status status; + struct set_function_input_params params = { + .function_num = 0x1, + .commun_devices = 0xFFFF, + .devices = 0xFFFF, + .app_status = 0x10, /* RF Button Active */ + .app_mask = 0x10, + }; + + status = wmid3_set_function_mode(¶ms, &return_value); + + if (return_value.error_code || return_value.ec_return_value) + pr_warn("Enabling RF Button failed: 0x%x - 0x%x\n", + return_value.error_code, + return_value.ec_return_value); + + return status; +} + #define ACER_WMID_ACCEL_HID "BST0001" static acpi_status __init acer_wmi_get_handle_cb(acpi_handle ah, u32 level, @@ -2229,6 +2271,10 @@ static int __init acer_wmi_init(void) interface->capability &= ~ACER_CAP_BRIGHTNESS; if (wmi_has_guid(WMID_GUID3)) { + if (ACPI_FAILURE(acer_wmi_enable_rf_button())) { + pr_err("Cannot enable RF Button Driver\n"); + return -ENODEV; + } if (ec_raw_mode) { if (ACPI_FAILURE(acer_wmi_enable_ec_raw())) { pr_err("Cannot enable EC raw mode\n");