From patchwork Thu May 14 20:52:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 11549767 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6981E912 for ; Thu, 14 May 2020 20:52:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5139E2065C for ; Thu, 14 May 2020 20:52:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YanTDhIQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727777AbgENUwt (ORCPT ); Thu, 14 May 2020 16:52:49 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:59026 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726128AbgENUws (ORCPT ); Thu, 14 May 2020 16:52:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589489567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=TRlhx9oj6sSPvJNOutkCmEhgsKZc6d2s5G+nOqR8jaM=; b=YanTDhIQYegwEuZ1Av0ZuTsBsOFePJN+SAtFXhSeyJa7XfCndcsAmomth4ttc6u9sZfS+X beTIvebX7LT8PkifxUxYbCWixVWc78oDF0XyOz3zQyXqoEjlfF5KKt6d+bmuVkZX6lwO4g HRXBKpIM+1N0OGV7e/vG6rkyXSqTdjI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-168-C0qtEgwZO-iRW1qi20fDiQ-1; Thu, 14 May 2020 16:52:46 -0400 X-MC-Unique: C0qtEgwZO-iRW1qi20fDiQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E82B9835B40; Thu, 14 May 2020 20:52:44 +0000 (UTC) Received: from x1.localdomain.com (ovpn-112-24.ams2.redhat.com [10.36.112.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id A938A10013BD; Thu, 14 May 2020 20:52:43 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov Cc: Hans de Goede , linux-acpi@vger.kernel.org, linux-input@vger.kernel.org, platform-driver-x86@vger.kernel.org, Andy Shevchenko Subject: [PATCH 1/2] Input: soc_button_array - Add active_low setting to soc_button_info Date: Thu, 14 May 2020 22:52:41 +0200 Message-Id: <20200514205242.138230-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org This is a preparation patch for adding support for Intel INT33D3 ACPI devices. These INT33D3 devices follow yet another Intel defined (but not documented) ACPI GPIO button standard. Unlike the ACPI GPIO button devices supported so far, the GPIO used in the INT33D3 devices is active-high, rather then active-low. This commit makes setting the gpio_keys_button.active_low flag configurable through the soc_button_info struct and enables it for all currently supported devices. Signed-off-by: Hans de Goede --- drivers/input/misc/soc_button_array.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c index 08520b3a18b8..e3a22a61f5d9 100644 --- a/drivers/input/misc/soc_button_array.c +++ b/drivers/input/misc/soc_button_array.c @@ -23,6 +23,7 @@ struct soc_button_info { unsigned int event_code; bool autorepeat; bool wakeup; + bool active_low; }; struct soc_device_data { @@ -110,7 +111,7 @@ soc_button_device_create(struct platform_device *pdev, gpio_keys[n_buttons].type = info->event_type; gpio_keys[n_buttons].code = info->event_code; gpio_keys[n_buttons].gpio = gpio; - gpio_keys[n_buttons].active_low = 1; + gpio_keys[n_buttons].active_low = info->active_low; gpio_keys[n_buttons].desc = info->name; gpio_keys[n_buttons].wakeup = info->wakeup; /* These devices often use cheap buttons, use 50 ms debounce */ @@ -173,6 +174,7 @@ static int soc_button_parse_btn_desc(struct device *dev, } info->event_type = EV_KEY; + info->active_low = true; info->acpi_index = soc_button_get_acpi_object_int(&desc->package.elements[1]); upage = soc_button_get_acpi_object_int(&desc->package.elements[3]); @@ -383,11 +385,11 @@ static int soc_button_probe(struct platform_device *pdev) * Platforms" */ static const struct soc_button_info soc_button_PNP0C40[] = { - { "power", 0, EV_KEY, KEY_POWER, false, true }, - { "home", 1, EV_KEY, KEY_LEFTMETA, false, true }, - { "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false }, - { "volume_down", 3, EV_KEY, KEY_VOLUMEDOWN, true, false }, - { "rotation_lock", 4, EV_KEY, KEY_ROTATE_LOCK_TOGGLE, false, false }, + { "power", 0, EV_KEY, KEY_POWER, false, true, true }, + { "home", 1, EV_KEY, KEY_LEFTMETA, false, true, true }, + { "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false, true }, + { "volume_down", 3, EV_KEY, KEY_VOLUMEDOWN, true, false, true }, + { "rotation_lock", 4, EV_KEY, KEY_ROTATE_LOCK_TOGGLE, false, false, true }, { } }; @@ -444,9 +446,9 @@ static int soc_device_check_MSHW0040(struct device *dev) * Obtained from DSDT/testing. */ static const struct soc_button_info soc_button_MSHW0040[] = { - { "power", 0, EV_KEY, KEY_POWER, false, true }, - { "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false }, - { "volume_down", 4, EV_KEY, KEY_VOLUMEDOWN, true, false }, + { "power", 0, EV_KEY, KEY_POWER, false, true, true }, + { "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false, true }, + { "volume_down", 4, EV_KEY, KEY_VOLUMEDOWN, true, false, true }, { } }; From patchwork Thu May 14 20:52:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 11549771 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6FB43912 for ; Thu, 14 May 2020 20:52:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 561512065C for ; Thu, 14 May 2020 20:52:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Sl80lIr4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727929AbgENUwv (ORCPT ); Thu, 14 May 2020 16:52:51 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:28907 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727832AbgENUwu (ORCPT ); Thu, 14 May 2020 16:52:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589489569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z1B3fYOYm8pvnyTjtbhTkkBslablP1daKS/L1NhMlF8=; b=Sl80lIr4X1sI4SKCf/WERF5bRlYqZtmCrf6QHyfKVtW+B3yfLSor6uDVMl7oIEZFMXH6sv WaHSyMVQ1hUVaQLPXjA9z3f3R9Cz0DCM3N9fnp9cXWpq2aU1ZT5qtWuIgc990CKr2cEVyq RJhaXuT//+NrqKWAPFCp2vEWFqlg4sM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-441-PUP0xLt9Pd-c5w3zpS7DpQ-1; Thu, 14 May 2020 16:52:47 -0400 X-MC-Unique: PUP0xLt9Pd-c5w3zpS7DpQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 78ECB474; Thu, 14 May 2020 20:52:46 +0000 (UTC) Received: from x1.localdomain.com (ovpn-112-24.ams2.redhat.com [10.36.112.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3976F1000320; Thu, 14 May 2020 20:52:45 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov Cc: Hans de Goede , linux-acpi@vger.kernel.org, linux-input@vger.kernel.org, platform-driver-x86@vger.kernel.org, Andy Shevchenko Subject: [PATCH 2/2] Input: soc_button_array - Add support for INT33D3 tablet-mode switch devices Date: Thu, 14 May 2020 22:52:42 +0200 Message-Id: <20200514205242.138230-2-hdegoede@redhat.com> In-Reply-To: <20200514205242.138230-1-hdegoede@redhat.com> References: <20200514205242.138230-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org According to the Microsoft documentation for Windows 8 convertible devices, these devices should implement a PNP0C60 "laptop/slate mode state indicator" ACPI device. This device can work in 2 ways, if there is a GPIO which directly indicates the device is in tablet-mode or not then the direct-gpio mode should be used. If there is no such GPIO, but instead the events are coming from e.g. the embedded-controller, then there should still be a PNP0C60 ACPI device and event-injection should be used to send the events. The drivers/platform/x86/intel-vbtn.c code is an example from a standardized manner of doing the latter. On various 2-in-1s with either a detachable keyboard, or with 360° hinges, the direct GPIO mode is indicated by an ACPI device with a HID of INT33D3, which contains a single GpioInt in its ACPI resource table, which directly indicates if the device is in tablet-mode or not. This commit adds support for this to the soc_button_array code, as well as for the alternative ID9001 HID which some devices use instead of the INT33D3 HID. Signed-off-by: Hans de Goede --- drivers/input/misc/soc_button_array.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c index e3a22a61f5d9..837c787e9c4b 100644 --- a/drivers/input/misc/soc_button_array.c +++ b/drivers/input/misc/soc_button_array.c @@ -397,6 +397,15 @@ static const struct soc_device_data soc_device_PNP0C40 = { .button_info = soc_button_PNP0C40, }; +static const struct soc_button_info soc_button_INT33D3[] = { + { "tablet_mode", 0, EV_SW, SW_TABLET_MODE, false, false, false }, + { } +}; + +static const struct soc_device_data soc_device_INT33D3 = { + .button_info = soc_button_INT33D3, +}; + /* * Special device check for Surface Book 2 and Surface Pro (2017). * Both, the Surface Pro 4 (surfacepro3_button.c) and the above mentioned @@ -459,6 +468,8 @@ static const struct soc_device_data soc_device_MSHW0040 = { static const struct acpi_device_id soc_button_acpi_match[] = { { "PNP0C40", (unsigned long)&soc_device_PNP0C40 }, + { "INT33D3", (unsigned long)&soc_device_INT33D3 }, + { "ID9001", (unsigned long)&soc_device_INT33D3 }, { "ACPI0011", 0 }, /* Microsoft Surface Devices (5th and 6th generation) */