From patchwork Tue Jan 5 16:16:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jo=C3=A3o_Paulo_Rechi_Vita?= X-Patchwork-Id: 7956081 Return-Path: X-Original-To: patchwork-platform-driver-x86@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 87A159F3E6 for ; Tue, 5 Jan 2016 16:17:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 787F820328 for ; Tue, 5 Jan 2016 16:17:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3F52C202C8 for ; Tue, 5 Jan 2016 16:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751543AbcAEQRz (ORCPT ); Tue, 5 Jan 2016 11:17:55 -0500 Received: from mail-qg0-f47.google.com ([209.85.192.47]:33348 "EHLO mail-qg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751456AbcAEQRy (ORCPT ); Tue, 5 Jan 2016 11:17:54 -0500 Received: by mail-qg0-f47.google.com with SMTP id b35so151713982qge.0; Tue, 05 Jan 2016 08:17:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=oFz12MLraAQwBFK5noXF+aVr3ydiOlsmQH43KVIAm/8=; b=zCYJ2VxkaN61ryuN2kr3UV0mF4Psa4G3jkUJLsVSQdLJGwDRfnIxpDpqWo9C0yV0uV Y4XZ2utkcJ5Pgkowhw3yAJM5ZFmSy3c9wEtIp1dToRpiDUW3jY4ob6siIAwupcQW0XyG tzccJtoZo4wxS+zI0FHf17xCUE7eBY7CAfKvtI6Njpb3NGoHfAMZzhVJDEtXhxTdMpN7 DPY2VqZTqU1fNN3/rUnuRjz/1v1MzOJ+xlCf17Z7shyb/x48A/gCxyZcFLzjMP/YMnnQ J1c3HFMTU3TgfrQWacpfmoxObYB5KVQhwMAyeARuM7Q5Y6rG7UxT59FP7fyF001cAoNt scxA== X-Received: by 10.140.176.130 with SMTP id w124mr129588463qhw.59.1452010673747; Tue, 05 Jan 2016 08:17:53 -0800 (PST) Received: from localhost.localdomain (c-98-239-150-235.hsd1.wv.comcast.net. [98.239.150.235]) by smtp.gmail.com with ESMTPSA id g90sm41492427qgg.45.2016.01.05.08.17.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Jan 2016 08:17:52 -0800 (PST) From: "=?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?=" X-Google-Original-From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= To: Darren Hart Cc: Corentin Chary , andy.shevchenko@gmail.com, platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, linux-kernel@vger.kernel.org, =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= Subject: [PATCH] platform/x86: Add Asus Wireless Radio Control driver Date: Tue, 5 Jan 2016 11:16:53 -0500 Message-Id: <1452010613-4673-1-git-send-email-jprvita@endlessm.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some Asus notebooks like the Asus E202SA and the Asus X555UB have a separate ACPI device for notifications from the airplane mode hotkey. This device is called "Wireless Radio Control" in Asus websites and ASHS in the DSDT, and its ACPI _HID is ATK4002 in the two models mentioned above. For these models, when the airplane mode hotkey (Fn+F2) is pressed, a query 0x0B is started in the Embedded Controller, and all this query does is a notify ASHS with the value 0x88 (for acpi_osi >= "Windows 2012"): Scope (_SB.PCI0.SBRG.EC0) { (...) Method (_Q0B, 0, NotSerialized) // _Qxx: EC Query { If ((MSOS () >= OSW8)) { Notify (ASHS, 0x88) // Device-Specific } Else { (...) } } } Signed-off-by: João Paulo Rechi Vita Reviewed-by: Andy Shevchenko --- MAINTAINERS | 6 +++ drivers/platform/x86/Kconfig | 14 ++++++ drivers/platform/x86/Makefile | 1 + drivers/platform/x86/asus-wireless.c | 83 ++++++++++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 drivers/platform/x86/asus-wireless.c diff --git a/MAINTAINERS b/MAINTAINERS index c984136..e1860f2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1791,6 +1791,12 @@ S: Maintained F: drivers/platform/x86/asus*.c F: drivers/platform/x86/eeepc*.c +ASUS WIRELESS RADIO CONTROL DRIVER +M: João Paulo Rechi Vita +L: platform-driver-x86@vger.kernel.org +S: Maintained +F: drivers/platform/x86/asus-wireless.c + ASYNCHRONOUS TRANSFERS/TRANSFORMS (IOAT) API R: Dan Williams W: http://sourceforge.net/projects/xscaleiop diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index d0bfcf8..749684e 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -587,6 +587,20 @@ config EEEPC_WMI If you have an ACPI-WMI compatible Eee PC laptop (>= 1000), say Y or M here. +config ASUS_WIRELESS + tristate "Asus Wireless Radio Control Driver" + depends on ACPI + depends on INPUT + ---help--- + The Asus Wireless Radio Control handles the airplane mode hotkey + present on some Asus laptops. + + Say Y or M here if you have an ASUS notebook with an airplane mode + hotkey. + + If you choose to compile this driver as a module the module will be + called asus-wireless. + config ACPI_WMI tristate "WMI" depends on ACPI diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index 4410e91..8b8df29 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -5,6 +5,7 @@ obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o obj-$(CONFIG_ASUS_WMI) += asus-wmi.o obj-$(CONFIG_ASUS_NB_WMI) += asus-nb-wmi.o +obj-$(CONFIG_ASUS_WIRELESS) += asus-wireless.o obj-$(CONFIG_EEEPC_LAPTOP) += eeepc-laptop.o obj-$(CONFIG_EEEPC_WMI) += eeepc-wmi.o obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o diff --git a/drivers/platform/x86/asus-wireless.c b/drivers/platform/x86/asus-wireless.c new file mode 100644 index 0000000..5058d48 --- /dev/null +++ b/drivers/platform/x86/asus-wireless.c @@ -0,0 +1,83 @@ +/* + * Asus Wireless Radio Control Driver + * + * Copyright (C) 2015-2016 Endless Mobile, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include + +struct asus_wireless_data { + struct input_dev *idev; +}; + +static void asus_wireless_notify(struct acpi_device *adev, u32 event) +{ + struct asus_wireless_data *data = acpi_driver_data(adev); + + dev_dbg(&adev->dev, "event=%#x\n", event); + if (event != 0x88) { + dev_notice(&adev->dev, "Unknown ASHS event: %#x\n", event); + return; + } + input_report_key(data->idev, KEY_RFKILL, 1); + input_report_key(data->idev, KEY_RFKILL, 0); + input_sync(data->idev); +} + +static int asus_wireless_add(struct acpi_device *adev) +{ + struct asus_wireless_data *data; + + data = devm_kzalloc(&adev->dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + adev->driver_data = data; + + data->idev = devm_input_allocate_device(&adev->dev); + if (!data->idev) + return -ENOMEM; + data->idev->name = "Asus Wireless Radio Control"; + data->idev->phys = "asus-wireless/input0"; + data->idev->id.bustype = BUS_HOST; + data->idev->id.vendor = PCI_VENDOR_ID_ASUSTEK; + set_bit(EV_KEY, data->idev->evbit); + set_bit(KEY_RFKILL, data->idev->keybit); + return input_register_device(data->idev); +} + +static int asus_wireless_remove(struct acpi_device *adev) +{ + return 0; +} + +static const struct acpi_device_id device_ids[] = { + {"ATK4002", 0}, + {"", 0}, +}; +MODULE_DEVICE_TABLE(acpi, device_ids); + +static struct acpi_driver asus_wireless_driver = { + .name = "Asus Wireless Radio Control Driver", + .class = "hotkey", + .ids = device_ids, + .ops = { + .add = asus_wireless_add, + .remove = asus_wireless_remove, + .notify = asus_wireless_notify, + }, +}; +module_acpi_driver(asus_wireless_driver); + +MODULE_DESCRIPTION("Asus Wireless Radio Control Driver"); +MODULE_AUTHOR("João Paulo Rechi Vita "); +MODULE_LICENSE("GPL");